Пример #1
0
 def start_file_transfer(self, jid, file_props, request=False):
     logger.info("start file transfer with file: %s", file_props)
     contact = gajim.contacts.get_contact_with_highest_priority(
         self.name, gajim.get_jid_without_resource(jid))
     if gajim.contacts.is_gc_contact(self.name, jid):
         gcc = jid.split('/')
         if len(gcc) == 2:
             contact = gajim.contacts.get_gc_contact(
                 self.name, gcc[0], gcc[1])
     if contact is None:
         return
     use_security = contact.supports(nbxmpp.NS_JINGLE_XTLS)
     jingle = JingleSession(self,
                            weinitiate=True,
                            jid=jid,
                            werequest=request)
     # this is a file transfer
     jingle.session_type_FT = True
     self._sessions[jingle.sid] = jingle
     file_props.sid = jingle.sid
     if contact.supports(nbxmpp.NS_JINGLE_BYTESTREAM):
         transport = JingleTransportSocks5()
     elif contact.supports(nbxmpp.NS_JINGLE_IBB):
         transport = JingleTransportIBB()
     c = JingleFileTransfer(jingle,
                            transport=transport,
                            file_props=file_props,
                            use_security=use_security)
     file_props.algo = self.__hash_support(contact)
     jingle.add_content('file' + helpers.get_random_string_16(), c)
     jingle.start_session()
     return c.transport.sid
Пример #2
0
 def start_file_transfer(self, jid, file_props, request=False):
     logger.info("start file transfer with file: %s" % file_props)
     contact = gajim.contacts.get_contact_with_highest_priority(self.name,
         gajim.get_jid_without_resource(jid))
     if gajim.contacts.is_gc_contact(self.name,jid):
         gcc = jid.split('/')
         if len(gcc) == 2:
             contact = gajim.contacts.get_gc_contact(self.name, gcc[0], gcc[1])
     if contact is None:
         return
     use_security = contact.supports(nbxmpp.NS_JINGLE_XTLS)
     jingle = JingleSession(self, weinitiate=True, jid=jid, werequest=request)
     # this is a file transfer
     jingle.session_type_FT = True
     self._sessions[jingle.sid] = jingle
     file_props.sid = jingle.sid
     if contact.supports(nbxmpp.NS_JINGLE_BYTESTREAM):
         transport = JingleTransportSocks5()
     elif contact.supports(nbxmpp.NS_JINGLE_IBB):
         transport = JingleTransportIBB()
     c = JingleFileTransfer(jingle, transport=transport,
         file_props=file_props, use_security=use_security)
     file_props.algo = self.__hash_support(contact)
     jingle.add_content('file' + helpers.get_random_string_16(), c)
     jingle.start_session()
     return c.transport.sid