diff cagou/plugins/plugin_wid_chat.py @ 322:e2b51663d8b8

core, android: new share widget + added Cagou to "share" menu: - new intent filter to add Cagou to share menu for all media types - minimum Kivy version is now 1.11.0 - new "Share" widget to display data to share via SàT and select the target - new core.platform_ module (the suffix "_" avoid trouble with standard "platform" module), for platform specific code. - Android intent are now checked on startup and "on_new_intent" events - if a android.intent.action.SEND action is received (i.e. some data is shared), the "Share" widget is shown - new Cagou.share method to share data using "Share" widget - new Cagou.getAncestorWidget method to easily retrieve an instance of a specific class in a widget's ancestors - ContactList's Avatar and ContactItem widgets have been moved to core.common
author Goffi <goffi@goffi.org>
date Fri, 06 Dec 2019 13:23:03 +0100
parents 772c170b47a9
children 5868a5575e01
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_chat.py	Fri Dec 06 13:23:03 2019 +0100
+++ b/cagou/plugins/plugin_wid_chat.py	Fri Dec 06 13:23:03 2019 +0100
@@ -183,7 +183,7 @@
     chat = properties.ObjectProperty()
 
     def on_release(self, *args):
-        menu.TransferMenu(callback=self.chat.onTransferOK).show(self)
+        menu.TransferMenu(callback=self.chat.transferFile).show(self)
 
 
 class ExtraMenu(DropDown):
@@ -664,11 +664,14 @@
             profile_key=profile
             )
 
-    def onTransferOK(self, file_path, cleaning_cb, transfer_type):
-        if transfer_type == C.TRANSFER_UPLOAD:
+        if cleaning_cb is not None:
+            cleaning_cb()
+
 
+    def transferFile(self, file_path, transfer_type=C.TRANSFER_UPLOAD, cleaning_cb=None):
+        if transfer_type == C.TRANSFER_UPLOAD:
             G.host.bridge.fileUpload(
-                file_path,
+                str(file_path),
                 "",
                 "",
                 {"ignore_tls_errors": C.boolConst(not G.host.tls_validation)},
@@ -691,7 +694,7 @@
                 jid_ = self.target
                 if not jid_.resource:
                     jid_ = G.host.contact_lists[self.profile].getFullJid(jid_)
-                G.host.bridge.fileSend(str(jid_), file_path, "", "", {},
+                G.host.bridge.fileSend(str(jid_), str(file_path), "", "", {},
                                        profile=self.profile)
                 # TODO: notification of sending/failing
         else: