Esempio n. 1
0
 def on_yes(dummy, fjid, file_props, account):
     # Delete old file
     os.remove(file_props.file_name)
     jid, resource = gajim.get_room_and_nick_from_fjid(fjid)
     if resource:
         contact = gajim.contacts.get_contact(account, jid, resource)
     else:
         contact = gajim.contacts.get_contact_with_highest_priority(
             account, jid)
         fjid = contact.get_full_jid()
     # Request the file to the sender
     sid = helpers.get_random_string_16()
     new_file_props = FilesProp.getNewFileProp(account, sid)
     new_file_props.file_name = file_props.file_name
     new_file_props.name = file_props.name
     new_file_props.desc = file_props.desc
     new_file_props.size = file_props.size
     new_file_props.date = file_props.date
     new_file_props.hash_ = file_props.hash_
     new_file_props.type_ = 'r'
     tsid = gajim.connections[account].start_file_transfer(fjid,
                                                     new_file_props,
                                                         True)
     new_file_props.transport_sid = tsid
     self.add_transfer(account, contact, new_file_props)
Esempio n. 2
0
 def get_send_file_props(self, account, contact, file_path, file_name,
 file_desc=''):
     """
     Create new file_props object and set initial file transfer
     properties in it
     """
     if os.path.isfile(file_path):
         stat = os.stat(file_path)
     else:
         dialogs.ErrorDialog(_('Invalid File'), _('File: ') + file_path)
         return None
     if stat[6] == 0:
         dialogs.ErrorDialog(_('Invalid File'),
         _('It is not possible to send empty files'))
         return None
     file_props = FilesProp.getNewFileProp(account,
                                 sid=helpers.get_random_string_16())
     mod_date = os.path.getmtime(file_path)
     file_props.file_name = file_path
     file_props.name = file_name
     file_props.date = self.__convert_date(mod_date)
     file_props.type_ = 's'
     file_props.desc = file_desc
     file_props.elapsed_time = 0
     file_props.size = stat[6]
     file_props.sender = account
     file_props.receiver = contact
     file_props.tt_account = account
     return file_props
Esempio n. 3
0
 def on_yes(dummy, fjid, file_props, account):
     # Delete old file
     os.remove(file_props.file_name)
     jid, resource = gajim.get_room_and_nick_from_fjid(fjid)
     if resource:
         contact = gajim.contacts.get_contact(account, jid, resource)
     else:
         contact = gajim.contacts.get_contact_with_highest_priority(
             account, jid)
         fjid = contact.get_full_jid()
     # Request the file to the sender
     sid = helpers.get_random_string_16()
     new_file_props = FilesProp.getNewFileProp(account, sid)
     new_file_props.file_name = file_props.file_name
     new_file_props.name = file_props.name
     new_file_props.desc = file_props.desc
     new_file_props.size = file_props.size
     new_file_props.date = file_props.date
     new_file_props.hash_ = file_props.hash_
     new_file_props.type_ = 'r'
     tsid = gajim.connections[account].start_file_transfer(fjid,
                                                     new_file_props,
                                                         True)
     new_file_props.transport_sid = tsid
     self.add_transfer(account, contact, new_file_props)
Esempio n. 4
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
Esempio n. 5
0
 def get_send_file_props(self, account, contact, file_path, file_name,
 file_desc=''):
     """
     Create new file_props object and set initial file transfer
     properties in it
     """
     if os.path.isfile(file_path):
         stat = os.stat(file_path)
     else:
         dialogs.ErrorDialog(_('Invalid File'), _('File: ') + file_path)
         return None
     if stat[6] == 0:
         dialogs.ErrorDialog(_('Invalid File'),
         _('It is not possible to send empty files'))
         return None
     file_props = FilesProp.getNewFileProp(account,
                                 sid=helpers.get_random_string_16())
     mod_date = os.path.getmtime(file_path)
     file_props.file_name = file_path
     file_props.name = file_name
     file_props.date = self.__convert_date(mod_date)
     file_props.type_ = 's'
     file_props.desc = file_desc
     file_props.elapsed_time = 0
     file_props.size = stat[6]
     file_props.sender = account
     file_props.receiver = contact
     file_props.tt_account = account
     return file_props
Esempio n. 6
0
	def get_send_file_props(self, account, contact, file_path, file_name,
	file_desc=''):
		''' create new file_props dict and set initial file transfer 
		properties in it'''
		file_props = {'file-name' : file_path, 'name' : file_name, 
			'type' : 's', 'desc' : file_desc}
		if os.path.isfile(file_path):
			stat = os.stat(file_path)
		else:
			dialogs.ErrorDialog(_('Invalid File'), _('File: ')  + file_path)
			return None
		if stat[6] == 0:
			dialogs.ErrorDialog(_('Invalid File'), 
			_('It is not possible to send empty files'))
			return None
		file_props['elapsed-time'] = 0
		file_props['size'] = unicode(stat[6])
		file_props['sid'] = helpers.get_random_string_16()
		file_props['completed'] = False
		file_props['started'] = False
		file_props['sender'] = account
		file_props['receiver'] = contact
		file_props['tt_account'] = account
		# keep the last time: transfered_size to compute transfer speed
		file_props['transfered_size'] = []
		return file_props
Esempio n. 7
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
Esempio n. 8
0
	def __init__(self, proxy, sender_jid):
		self.proxy = proxy
		self.state = S_INITIAL
		self.active_connection = None
		self.connections = []
		self.host_tester = None
		self.receiver_tester = None
		self.jid = None
		self.host = None
		self.port = None
		self.sid = helpers.get_random_string_16()
		self.sender_jid = sender_jid
Esempio n. 9
0
 def __init__(self, proxy, sender_jid):
     self.proxy = proxy
     self.state = S_INITIAL
     self.active_connection = None
     self.connections = []
     self.host_tester = None
     self.receiver_tester = None
     self.jid = None
     self.host = None
     self.port = None
     self.sid = helpers.get_random_string_16()
     self.sender_jid = sender_jid
Esempio n. 10
0
 def __init__(self, proxy, sender_jid, testit):
     """
     if testit is False, don't test it, only get IP/port
     """
     self.proxy = proxy
     self.state = S_INITIAL
     self.active_connection = None
     self.connections = []
     self.host_tester = None
     self.receiver_tester = None
     self.jid = None
     self.host = None
     self.port = None
     self.sid = helpers.get_random_string_16()
     self.sender_jid = sender_jid
     self.testit = testit
Esempio n. 11
0
 def __init__(self, proxy, sender_jid, testit):
     """
     if testit is False, don't test it, only get IP/port
     """
     self.proxy = proxy
     self.state = S_INITIAL
     self.active_connection = None
     self.connections = []
     self.host_tester = None
     self.receiver_tester = None
     self.jid = None
     self.host = None
     self.port = None
     self.sid = helpers.get_random_string_16()
     self.sender_jid = sender_jid
     self.testit = testit
Esempio n. 12
0
 def on_download_clicked(self, widget, data=None):
     tree, row = self.tv_search.get_selection().get_selected()
     path = tree.get_path(row)
     file_info = self.brw_file_info[path]
     fjid = self.get_contact_from_iter(tree, row)
     # Request the file
     file_path = os.path.join(self.plugin.config['incoming_dir'],
                              file_info[0])
     sid = helpers.get_random_string_16()
     new_file_props = FilesProp.getNewFileProp(self.account, sid)
     new_file_props.file_name = file_path
     print file_path
     new_file_props.name = file_info[0]
     new_file_props.desc = file_info[4]
     new_file_props.size = file_info[2]
     new_file_props.date = file_info[1]
     new_file_props.hash_ = None if file_info[3] == '' else file_info[3]
     new_file_props.type_ = 'r'
     tsid = gajim.connections[self.account].start_file_transfer(
         fjid, new_file_props, True)
     new_file_props.transport_sid = tsid
     ft_window = gajim.interface.instances['file_transfers']
     contact = gajim.contacts.get_contact_from_full_jid(self.account, fjid)
     ft_window.add_transfer(self.account, contact, new_file_props)
Esempio n. 13
0
 def on_download_clicked(self, widget, data=None):
     tree, row = self.tv_search.get_selection().get_selected()
     path = tree.get_path(row)
     file_info = self.brw_file_info[path]
     fjid = self.get_contact_from_iter(tree, row)
     # Request the file
     file_path = os.path.join(self.plugin.config['incoming_dir'],
         file_info[0])
     sid = helpers.get_random_string_16()
     new_file_props = FilesProp.getNewFileProp(self.account, sid)
     new_file_props.file_name = file_path
     print file_path
     new_file_props.name = file_info[0]
     new_file_props.desc = file_info[4]
     new_file_props.size = file_info[2]
     new_file_props.date = file_info[1]
     new_file_props.hash_ = None if file_info[3] == '' else file_info[3]
     new_file_props.type_ = 'r'
     tsid = gajim.connections[self.account].start_file_transfer(fjid,
         new_file_props, True)
     new_file_props.transport_sid = tsid
     ft_window = gajim.interface.instances['file_transfers']
     contact = gajim.contacts.get_contact_from_full_jid(self.account, fjid)
     ft_window .add_transfer(self.account, contact, new_file_props)