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)
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
def __init__(self, host, port, jid, sid, sender_jid, on_success, on_failure): """ Try to establish and auth to proxy at (host, port) Call on_success, or on_failure according to the result. """ self.host = host self.port = port self.jid = jid self.on_success = on_success self.on_failure = on_failure self._sock = None self.file_props = FilesProp.getNewFileProp(jid, sid) self.file_props.is_a_proxy = True self.file_props.proxy_sender = sender_jid self.file_props.proxy_receiver = '[email protected]/test2' Socks5.__init__(self, gajim.idlequeue, host, port, None, None, None) self.sid = sid
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)
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)