# HG changeset patch # User Goffi # Date 1483051630 -3600 # Node ID 4d8c122b86a6905583d40391185078116a31ad68 # Parent 5d2289127bb7b0275f2d853bcf091e2f3047c22f menu (upload): send transfer (i.e. P2P transfer) is now working diff -r 5d2289127bb7 -r 4d8c122b86a6 src/cagou/core/menu.py --- a/src/cagou/core/menu.py Thu Dec 29 23:47:07 2016 +0100 +++ b/src/cagou/core/menu.py Thu Dec 29 23:47:10 2016 +0100 @@ -230,7 +230,10 @@ def onTransferCb(file_path, cleaning_cb=None): if not external: self._closeUI(wid) - self.callback(file_path, cleaning_cb) + self.callback( + file_path, + cleaning_cb, + transfer_type = C.TRANSFER_UPLOAD if self.ids['upload_btn'].state == "down" else C.TRANSFER_SEND) wid = plug_info['factory'](plug_info, onTransferCb, self.cancel_cb, self.profiles) if not external: G.host.showExtraUI(wid) diff -r 5d2289127bb7 -r 4d8c122b86a6 src/cagou/kv/menu.kv --- a/src/cagou/kv/menu.kv Thu Dec 29 23:47:07 2016 +0100 +++ b/src/cagou/kv/menu.kv Thu Dec 29 23:47:10 2016 +0100 @@ -86,4 +86,3 @@ text_size: self.size halign: "center" valign: "top" - diff -r 5d2289127bb7 -r 4d8c122b86a6 src/cagou/plugins/plugin_wid_chat.py --- a/src/cagou/plugins/plugin_wid_chat.py Thu Dec 29 23:47:07 2016 +0100 +++ b/src/cagou/plugins/plugin_wid_chat.py Thu Dec 29 23:47:10 2016 +0100 @@ -633,15 +633,29 @@ else: self._waiting_pids[progress_id] = (self.fileTransferDone, cleaning_cb) - def onTransferOK(self, file_path, cleaning_cb): - G.host.bridge.fileTransfer( - file_path, - "", - "", - {"ignore_tls_errors": C.BOOL_TRUE}, # FIXME: should not be the default - self.profile, - callback = lambda progress_data: self.fileTransferCb(progress_data, cleaning_cb) - ) + def onTransferOK(self, file_path, cleaning_cb, transfer_type): + if transfer_type == C.TRANSFER_UPLOAD: + G.host.bridge.fileUpload( + file_path, + "", + "", + {"ignore_tls_errors": C.BOOL_TRUE}, # FIXME: should not be the default + self.profile, + callback = lambda progress_data: self.fileTransferCb(progress_data, cleaning_cb) + ) + elif transfer_type == C.TRANSFER_SEND: + if self.type == C.CHAT_GROUP: + log.warning(u"P2P transfer is not possible for group chat") + # TODO: show an error dialog to user, or better hide the send button for MUC + else: + jid_ = self.target + if not jid_.resource: + jid_ = G.host.contact_lists[self.profile].getFullJid(jid_) + G.host.bridge.fileSend(jid_, file_path, "", "", profile=self.profile) + # TODO: notification of sending/failing + else: + raise log.error(u"transfer of type {} are not handled".format(transfer_type)) + def _mucJoinCb(self, joined_data): joined, room_jid_s, occupants, user_nick, subject, profile = joined_data