comparison 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
comparison
equal deleted inserted replaced
282:1b835bcfa663 283:c73a7cd36b54
596 input_widget.text = '' 596 input_widget.text = ''
597 597
598 def fileTransferEb(self, err_msg, cleaning_cb, profile): 598 def fileTransferEb(self, err_msg, cleaning_cb, profile):
599 if cleaning_cb is not None: 599 if cleaning_cb is not None:
600 cleaning_cb() 600 cleaning_cb()
601 # TODO: display message to user 601 msg = _(u"can't transfer file: {reason}").format(reason=err_msg)
602 log.warning(u"Can't transfer file: {}".format(err_msg)) 602 log.warning(msg)
603 self.addNote(_(u"File transfer error"),
604 msg,
605 level=C.XMLUI_DATA_LVL_WARNING)
603 606
604 def fileTransferCb(self, metadata, cleaning_cb, profile): 607 def fileTransferCb(self, metadata, cleaning_cb, profile):
605 log.debug("file transfered: {}".format(metadata)) 608 log.debug("file transfered: {}".format(metadata))
606 extra = {} 609 extra = {}
607 610
621 profile_key=profile 624 profile_key=profile
622 ) 625 )
623 626
624 def onTransferOK(self, file_path, cleaning_cb, transfer_type): 627 def onTransferOK(self, file_path, cleaning_cb, transfer_type):
625 if transfer_type == C.TRANSFER_UPLOAD: 628 if transfer_type == C.TRANSFER_UPLOAD:
629
626 G.host.bridge.fileUpload( 630 G.host.bridge.fileUpload(
627 file_path, 631 file_path,
628 "", 632 "",
629 "", 633 "",
630 {"ignore_tls_errors": C.boolConst(not G.host.tls_validation)}, 634 {"ignore_tls_errors": C.boolConst(not G.host.tls_validation)},
631 self.profile, 635 self.profile,
632 callback = partial( 636 callback = partial(
633 G.host.actionManager, 637 G.host.actionManager,
634 progress_cb = partial(self.fileTransferCb, cleaning_cb=cleaning_cb), 638 progress_cb = partial(self.fileTransferCb, cleaning_cb=cleaning_cb),
635 progress_eb = partial(self.fileTransferEb, cleaning_cb=cleaning_cb), 639 progress_eb = partial(self.fileTransferEb, cleaning_cb=cleaning_cb),
636 ) 640 profile = self.profile,
641 ),
642 errback = partial(G.host.errback,
643 message=_(u"can't upload file: {msg}"))
637 ) 644 )
638 elif transfer_type == C.TRANSFER_SEND: 645 elif transfer_type == C.TRANSFER_SEND:
639 if self.type == C.CHAT_GROUP: 646 if self.type == C.CHAT_GROUP:
640 log.warning(u"P2P transfer is not possible for group chat") 647 log.warning(u"P2P transfer is not possible for group chat")
641 # TODO: show an error dialog to user, or better hide the send button for 648 # TODO: show an error dialog to user, or better hide the send button for