Mercurial > libervia-desktop-kivy
changeset 98:4d8c122b86a6
menu (upload): send transfer (i.e. P2P transfer) is now working
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 29 Dec 2016 23:47:10 +0100 |
parents | 5d2289127bb7 |
children | f67b9baa81f0 |
files | src/cagou/core/menu.py src/cagou/kv/menu.kv src/cagou/plugins/plugin_wid_chat.py |
diffstat | 3 files changed, 27 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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" -
--- 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