comparison 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
comparison
equal deleted inserted replaced
321:a6eb154ba266 322:e2b51663d8b8
181 181
182 class TransferButton(SymbolButton): 182 class TransferButton(SymbolButton):
183 chat = properties.ObjectProperty() 183 chat = properties.ObjectProperty()
184 184
185 def on_release(self, *args): 185 def on_release(self, *args):
186 menu.TransferMenu(callback=self.chat.onTransferOK).show(self) 186 menu.TransferMenu(callback=self.chat.transferFile).show(self)
187 187
188 188
189 class ExtraMenu(DropDown): 189 class ExtraMenu(DropDown):
190 chat = properties.ObjectProperty() 190 chat = properties.ObjectProperty()
191 191
662 if self.type == C.CHAT_GROUP else C.MESS_TYPE_CHAT), 662 if self.type == C.CHAT_GROUP else C.MESS_TYPE_CHAT),
663 extra = extra, 663 extra = extra,
664 profile_key=profile 664 profile_key=profile
665 ) 665 )
666 666
667 def onTransferOK(self, file_path, cleaning_cb, transfer_type): 667 if cleaning_cb is not None:
668 cleaning_cb()
669
670
671 def transferFile(self, file_path, transfer_type=C.TRANSFER_UPLOAD, cleaning_cb=None):
668 if transfer_type == C.TRANSFER_UPLOAD: 672 if transfer_type == C.TRANSFER_UPLOAD:
669
670 G.host.bridge.fileUpload( 673 G.host.bridge.fileUpload(
671 file_path, 674 str(file_path),
672 "", 675 "",
673 "", 676 "",
674 {"ignore_tls_errors": C.boolConst(not G.host.tls_validation)}, 677 {"ignore_tls_errors": C.boolConst(not G.host.tls_validation)},
675 self.profile, 678 self.profile,
676 callback = partial( 679 callback = partial(
689 # MUC 692 # MUC
690 else: 693 else:
691 jid_ = self.target 694 jid_ = self.target
692 if not jid_.resource: 695 if not jid_.resource:
693 jid_ = G.host.contact_lists[self.profile].getFullJid(jid_) 696 jid_ = G.host.contact_lists[self.profile].getFullJid(jid_)
694 G.host.bridge.fileSend(str(jid_), file_path, "", "", {}, 697 G.host.bridge.fileSend(str(jid_), str(file_path), "", "", {},
695 profile=self.profile) 698 profile=self.profile)
696 # TODO: notification of sending/failing 699 # TODO: notification of sending/failing
697 else: 700 else:
698 raise log.error("transfer of type {} are not handled".format(transfer_type)) 701 raise log.error("transfer of type {} are not handled".format(transfer_type))
699 702