From eec809c89aa689e4a5870b5b33ede2fd7a884169 Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Sun, 16 Sep 2012 20:54:07 +0200
Subject: [PATCH] re-request file transfer to the correct resource

---
 src/filetransfers_window.py | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/filetransfers_window.py b/src/filetransfers_window.py
index 1e595a9b8f..04d7c18ee6 100644
--- a/src/filetransfers_window.py
+++ b/src/filetransfers_window.py
@@ -249,13 +249,17 @@ class FileTransfersWindow:
 
     def show_hash_error(self, jid, file_props, account):
 
-        def on_yes(dummy):
+        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
-            contact = gajim.contacts.get_contact_with_highest_priority(account,
-                                                                       jid)
-            fjid = contact.get_full_jid()
             sid = helpers.get_random_string_16()
             new_file_props = FilesProp.getNewFileProp(account, sid)
             new_file_props.file_name = file_props.file_name
@@ -278,8 +282,8 @@ class FileTransfersWindow:
         dialogs.YesNoDialog(('File transfer error'),
             _('The file %(file)s has been fully received, but it seems to be '
             'wrongly received.\nDo you want to reload it?') % \
-            {'file': file_name}, on_response_yes=on_yes,
-            type_=gtk.MESSAGE_ERROR)
+            {'file': file_name}, on_response_yes=(on_yes, jid, file_props,
+            account), type_=gtk.MESSAGE_ERROR)
 
     def show_file_send_request(self, account, contact):
         win = gtk.ScrolledWindow()
-- 
GitLab