diff cagou/plugins/plugin_wid_chat.py @ 283:c73a7cd36b54

chat: show warning note on failing fileUpload + added forgotten "profile" argument
author Goffi <goffi@goffi.org>
date Mon, 25 Mar 2019 07:11:09 +0100
parents 1b835bcfa663
children ca4daced4638
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_chat.py	Mon Mar 25 07:11:09 2019 +0100
+++ b/cagou/plugins/plugin_wid_chat.py	Mon Mar 25 07:11:09 2019 +0100
@@ -598,8 +598,11 @@
     def fileTransferEb(self, err_msg, cleaning_cb, profile):
         if cleaning_cb is not None:
             cleaning_cb()
-        # TODO: display message to user
-        log.warning(u"Can't transfer file: {}".format(err_msg))
+        msg = _(u"can't transfer file: {reason}").format(reason=err_msg)
+        log.warning(msg)
+        self.addNote(_(u"File transfer error"),
+                     msg,
+                     level=C.XMLUI_DATA_LVL_WARNING)
 
     def fileTransferCb(self, metadata, cleaning_cb, profile):
         log.debug("file transfered: {}".format(metadata))
@@ -623,6 +626,7 @@
 
     def onTransferOK(self, file_path, cleaning_cb, transfer_type):
         if transfer_type == C.TRANSFER_UPLOAD:
+
             G.host.bridge.fileUpload(
                 file_path,
                 "",
@@ -633,7 +637,10 @@
                     G.host.actionManager,
                     progress_cb = partial(self.fileTransferCb, cleaning_cb=cleaning_cb),
                     progress_eb = partial(self.fileTransferEb, cleaning_cb=cleaning_cb),
-                    )
+                    profile = self.profile,
+                    ),
+                errback = partial(G.host.errback,
+                                  message=_(u"can't upload file: {msg}"))
             )
         elif transfer_type == C.TRANSFER_SEND:
             if self.type == C.CHAT_GROUP: