From e92fec4bdc6a2e4e45dbaf5ae4bc318894f55320 Mon Sep 17 00:00:00 2001
From: Jefry Lagrange <jefry.reyes@gmail.com>
Date: Fri, 31 Aug 2012 13:54:40 -0400
Subject: [PATCH] send modification date of file being transfered

---
 src/common/jingle_content.py |  4 ++++
 src/filetransfers_window.py  | 13 ++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/common/jingle_content.py b/src/common/jingle_content.py
index cd43866b12..418a6ec475 100644
--- a/src/common/jingle_content.py
+++ b/src/common/jingle_content.py
@@ -174,6 +174,10 @@ class JingleContent(object):
             node = xmpp.simplexml.Node(tag='name')
             node.addData(self.file_props.name)
             file_tag.addChild(node=node)
+        if self.file_props.date:
+            node = xmpp.simplexml.Node(tag='date')
+            node.addData(self.file_props.date)
+            file_tag.addChild(node=node)
         if self.file_props.size:
             node = xmpp.simplexml.Node(tag='size')
             node.addData(self.file_props.size)
diff --git a/src/filetransfers_window.py b/src/filetransfers_window.py
index c2350de49c..c453eb06c2 100644
--- a/src/filetransfers_window.py
+++ b/src/filetransfers_window.py
@@ -664,10 +664,19 @@ class FileTransfersWindow:
                 return iter_
             iter_ = self.model.iter_next(iter_)
 
+    def __convert_date(self, epoch):
+        # Converts date-time from seconds from epoch to iso 8601
+        import time, datetime
+        ts = time.gmtime(epoch)
+        dt = datetime.datetime(ts.tm_year, ts.tm_mon, ts.tm_mday, ts.tm_hour, 
+                               ts.tm_min,  ts.tm_sec)
+        return dt.isoformat()
+
     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
+        Create new file_props object and set initial file transfer 
+        properties in it
         """
         if os.path.isfile(file_path):
             stat = os.stat(file_path)
@@ -680,8 +689,10 @@ class FileTransfersWindow:
             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
-- 
GitLab