diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 7cfd7d0ed..c17ae636d 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -246,6 +246,8 @@ class ConnectionBytestream: def send_file_request(self, file_props): ''' send iq for new FT request ''' + if not self.connection or self.connected < 2: + return our_jid = gajim.get_jid_from_account(self.name) resource = self.server_resource frm = our_jid + '/' + resource @@ -396,7 +398,7 @@ class ConnectionBytestream: file_props = self.files_props[id] if file_props['streamhost-used']: for host in file_props['proxyhosts']: - if host['initiator'] == frm: + if host['initiator'] == frm and host.has_key('idx'): gajim.socks5queue.activate_proxy(host['idx']) raise common.xmpp.NodeProcessed @@ -478,6 +480,9 @@ class ConnectionBytestream: if file_props is None: # file properties for jid is none return + if file_props.has_key('request-id'): + # we have already sent streamhosts info + return file_props['receiver'] = helpers.get_full_jid_from_iq(iq_obj) si = iq_obj.getTag('si') file_tag = si.getTag('file') diff --git a/src/common/socks5.py b/src/common/socks5.py index aad4c6bab..da74297bd 100644 --- a/src/common/socks5.py +++ b/src/common/socks5.py @@ -740,6 +740,8 @@ class Socks5Sender(Socks5, IdleObject): def send_file(self): ''' start sending the file over verified connection ''' + if self.file_props['started']: + return self.file_props['error'] = 0 self.file_props['disconnect_cb'] = self.disconnect self.file_props['started'] = True diff --git a/src/filetransfers_window.py b/src/filetransfers_window.py index 19b5e70bc..0862c422d 100644 --- a/src/filetransfers_window.py +++ b/src/filetransfers_window.py @@ -312,12 +312,13 @@ _('Connection with peer cannot be established.')) if file_props.has_key('desc'): sec_text += '\n\t' + _('Description: %s') % file_props['desc'] prim_text = _('%s wants to send you a file:') % contact.jid + dialog, dialog2 = None, None def on_response_ok(widget, account, contact, file_props): - self.dialog.destroy() + dialog.destroy() def on_ok(widget, account, contact, file_props): - file_path = self.dialog2.get_filename() + file_path = dialog2.get_filename() file_path = gtkgui_helpers.decode_filechooser_file_paths( (file_path,))[0] if os.path.exists(file_path): @@ -329,18 +330,18 @@ _('Connection with peer cannot be established.')) _('This file already exists'), _('What do you want to do?'), not dl_finished) response = dialog.get_response() - if response == gtk.RESPONSE_CANCEL: + if response < 0: return elif response == 100: file_props['offset'] = dl_size - self.dialog2.destroy() + dialog2.destroy() self._start_receive(file_path, account, contact, file_props) def on_cancel(widget, account, contact, file_props): - self.dialog2.destroy() + dialog2.destroy() gajim.connections[account].send_file_rejection(file_props) - self.dialog2 = dialogs.FileChooserDialog( + dialog2 = dialogs.FileChooserDialog( title_text = _('Save File as...'), action = gtk.FILE_CHOOSER_ACTION_SAVE, buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, @@ -350,16 +351,20 @@ _('Connection with peer cannot be established.')) on_response_ok = (on_ok, account, contact, file_props), on_response_cancel = (on_cancel, account, contact, file_props)) - self.dialog2.set_current_name(file_props['name']) + dialog2.set_current_name(file_props['name']) + dialog2.connect('delete-event', lambda widget, event: + on_cancel(widget, account, contact, file_props)) def on_response_cancel(widget, account, file_props): - self.dialog.destroy() + dialog.destroy() gajim.connections[account].send_file_rejection(file_props) - self.dialog = dialogs.NonModalConfirmationDialog(prim_text, sec_text, + dialog = dialogs.NonModalConfirmationDialog(prim_text, sec_text, on_response_ok = (on_response_ok, account, contact, file_props), on_response_cancel = (on_response_cancel, account, file_props)) - self.dialog.popup() + dialog.connect('delete-event', lambda widget, event: + on_response_cancel(widget, account, file_props)) + dialog.popup() def set_images(self): ''' create pixbufs for status images in transfer rows'''