changeset 1180:69aace10b46d

Primitivus (file transfer): an error popup is shown when bad unicode is used in path, and an info popup is show to indicate that the file request has been sent
author Goffi <goffi@goffi.org>
date Mon, 08 Sep 2014 15:50:51 +0200
parents 9a85836f0d45
children ca8ce5a47969
files frontends/src/primitivus/chat.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/primitivus/chat.py	Mon Sep 08 15:50:51 2014 +0200
+++ b/frontends/src/primitivus/chat.py	Mon Sep 08 15:50:51 2014 +0200
@@ -18,6 +18,8 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from sat.core.i18n import _
+from sat.core import log as logging
+log = logging.getLogger(__name__)
 import urwid
 from urwid_satext import sat_widgets
 from urwid_satext.files_management import FileDialog
@@ -385,6 +387,12 @@
     #MISC EVENTS#
     def onFileSelected(self, filepath):
         self.host.removePopUp()
+        try:
+            filepath = filepath.decode('utf-8') # FIXME: correctly manage unicode
+        except UnicodeError:
+            log.error("FIXME: filepath with unicode error are not managed yet")
+            self.host.showDialog(_(u"File has a unicode error in its name, it's not yet managed by SàT"), title=_("Can't send file"), type_="error")
+            return
         #FIXME: check last_resource: what if self.target.resource exists ?
         last_resource = self.host.bridge.getLastResource(unicode(self.target.bare), self.host.profile)
         if last_resource:
@@ -393,3 +401,4 @@
             full_jid = self.target
         progress_id = self.host.bridge.sendFile(full_jid, filepath, {}, self.host.profile)
         self.host.addProgress(progress_id,filepath)
+        self.host.showDialog(_(u"You file request has been sent, we are waiting for your contact answer"), title=_("File request sent"))