From bfc4dccc0f2cc92aed968f77b6c3a8a5967f8bb0 Mon Sep 17 00:00:00 2001
From: Jefry Lagrange <jefry.reyes@gmail.com>
Date: Fri, 7 Sep 2012 10:01:11 -0400
Subject: [PATCH] add new FT in FT window when we are requesting file

---
 src/common/jingle.py        |  3 ++-
 src/filetransfers_window.py | 16 +++++++++++++---
 src/gui_interface.py        |  4 +++-
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/common/jingle.py b/src/common/jingle.py
index 2509297556..45bf7154b9 100644
--- a/src/common/jingle.py
+++ b/src/common/jingle.py
@@ -196,7 +196,8 @@ class ConnectionJingle(object):
 
     def get_files_info(self, hash_=None, name=None):
         if hash_:
-            for f in self.files:
+            for f in self.files: # DEBUG
+                #if f['hash'] == '1294809248109223':
                 if f['hash'] == hash_:
                     return f
         elif name:
diff --git a/src/filetransfers_window.py b/src/filetransfers_window.py
index c453eb06c2..64da830327 100644
--- a/src/filetransfers_window.py
+++ b/src/filetransfers_window.py
@@ -254,10 +254,20 @@ class FileTransfersWindow:
             contact = gajim.contacts.get_contact_with_highest_priority(account,
                                                                        jid)
             fjid = contact.get_full_jid()
-            sid = gajim.connections[account].start_file_transfer(fjid,
-                                                            file_props,
+            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)
-            file_props.transport_sid = sid
+            new_file_props.transport_sid = tsid
+            self.add_transfer(account, contact, new_file_props)
 
         if file_props.type_ == 'r':
             file_name = os.path.basename(file_props.file_name)
diff --git a/src/gui_interface.py b/src/gui_interface.py
index 3d96d229cb..1259068ad1 100644
--- a/src/gui_interface.py
+++ b/src/gui_interface.py
@@ -912,13 +912,15 @@ class Interface:
                 account=account, keyID=keyID)
             gajim.contacts.add_contact(account, contact)
             self.roster.add_contact(obj.jid, account)
+        contact = gajim.contacts.get_first_contact_from_jid(account, obj.jid)
         if obj.file_props.session_type == 'jingle':
             request = obj.stanza.getTag('jingle').getTag('content')\
                         .getTag('description').getTag('request')
             if request:
                 # If we get a request instead
+                ft_win = self.instances['file_transfers']
+                ft_win.add_transfer(account, contact, obj.file_props)
                 return
-        contact = gajim.contacts.get_first_contact_from_jid(account, obj.jid)
         if helpers.allow_popup_window(account):
             self.instances['file_transfers'].show_file_request(account, contact,
                 obj.file_props)
-- 
GitLab