Mercurial > libervia-backend
comparison frontends/src/primitivus/primitivus @ 2050:046449cc2bff
core, bridge, frontends: removed deprecated bridge method askConfirmation, confirmationAnswer, actionResult, actionResultExt and getWaitingConf
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 28 Aug 2016 19:23:58 +0200 |
parents | 88c41a195728 |
children | 7834743705f0 |
comparison
equal
deleted
inserted
replaced
2049:b67aece4a667 | 2050:046449cc2bff |
---|---|
26 log = logging.getLogger(__name__) | 26 log = logging.getLogger(__name__) |
27 from sat.tools import config as sat_config | 27 from sat.tools import config as sat_config |
28 import urwid | 28 import urwid |
29 from urwid.util import is_wide_char | 29 from urwid.util import is_wide_char |
30 from urwid_satext import sat_widgets | 30 from urwid_satext import sat_widgets |
31 from urwid_satext.files_management import FileDialog | |
32 from sat_frontends.bridge.DBus import DBusBridgeFrontend | 31 from sat_frontends.bridge.DBus import DBusBridgeFrontend |
33 from sat_frontends.quick_frontend.quick_app import QuickApp | 32 from sat_frontends.quick_frontend.quick_app import QuickApp |
34 from sat_frontends.quick_frontend import quick_utils | 33 from sat_frontends.quick_frontend import quick_utils |
35 from sat_frontends.quick_frontend import quick_chat | 34 from sat_frontends.quick_frontend import quick_chat |
36 from sat_frontends.primitivus.profile_manager import ProfileManager | 35 from sat_frontends.primitivus.profile_manager import ProfileManager |
41 from sat_frontends.primitivus.notify import Notify | 40 from sat_frontends.primitivus.notify import Notify |
42 from sat_frontends.primitivus.keys import action_key_map as a_key | 41 from sat_frontends.primitivus.keys import action_key_map as a_key |
43 from sat_frontends.primitivus import config | 42 from sat_frontends.primitivus import config |
44 from sat_frontends.tools.misc import InputHistory | 43 from sat_frontends.tools.misc import InputHistory |
45 from sat_frontends.tools import jid | 44 from sat_frontends.tools import jid |
46 from os.path import join | |
47 import signal | 45 import signal |
48 import sys | 46 import sys |
49 | 47 |
50 | 48 |
51 class EditBar(sat_widgets.ModalEdit): | 49 class EditBar(sat_widgets.ModalEdit): |
742 self.redraw() # FIXME: invalidate cache in a more efficient way | 740 self.redraw() # FIXME: invalidate cache in a more efficient way |
743 | 741 |
744 def _actionManagerUnknownError(self): | 742 def _actionManagerUnknownError(self): |
745 self.alert(_("Error"), _(u"Unmanaged action")) | 743 self.alert(_("Error"), _(u"Unmanaged action")) |
746 | 744 |
747 def askConfirmationHandler(self, confirmation_id, confirmation_type, data, profile): | |
748 answer_data = {} | |
749 | |
750 def dir_selected_cb(path): | |
751 dest_path = join(path, data['filename']) | |
752 answer_data["dest_path"] = quick_utils.getNewPath(dest_path) | |
753 self.addProgress(confirmation_id, dest_path) | |
754 accept_cb(None) | |
755 | |
756 def accept_file_transfer_cb(widget): | |
757 self.removePopUp() | |
758 pop_up_widget = FileDialog(dir_selected_cb, refuse_cb, title=_(u"Where do you want to save the file ?"), style=['dir']) | |
759 self.showPopUp(pop_up_widget) | |
760 | |
761 def accept_cb(widget): | |
762 self.removePopUp() | |
763 self.bridge.confirmationAnswer(confirmation_id, True, answer_data, profile) | |
764 | |
765 def refuse_cb(widget): | |
766 self.removePopUp() | |
767 self.bridge.confirmationAnswer(confirmation_id, False, answer_data, profile) | |
768 | |
769 if confirmation_type == "FILE_TRANSFER": | |
770 pop_up_widget = sat_widgets.ConfirmDialog(_("The contact %(jid)s wants to send you the file %(filename)s\nDo you accept ?") % {'jid':data["from"], 'filename':data["filename"]}, no_cb=refuse_cb, yes_cb=accept_file_transfer_cb) | |
771 self.showPopUp(pop_up_widget) | |
772 | |
773 elif confirmation_type == "YES/NO": | |
774 pop_up_widget = sat_widgets.ConfirmDialog(data["message"], no_cb=refuse_cb, yes_cb=accept_cb) | |
775 self.showPopUp(pop_up_widget) | |
776 | |
777 def actionResultHandler(self, type_, id, data, profile): | |
778 # FIXME: to be removed | |
779 | |
780 if not id in self.current_action_ids: | |
781 log.debug (_('unknown id, ignoring')) | |
782 return | |
783 if type_ == "SUPPRESS": | |
784 self.current_action_ids.remove(id) | |
785 elif type_ == "XMLUI": | |
786 self.current_action_ids.remove(id) | |
787 log.debug (_("XML user interface received")) | |
788 misc = {} | |
789 #FIXME FIXME FIXME: must clean all this crap ! | |
790 title = _('Form') | |
791 if data['type'] == 'registration': | |
792 title = _('Registration') | |
793 misc['target'] = data['target'] | |
794 misc['action_back'] = self.bridge.gatewayRegister | |
795 ui = xmlui.create(self, title=title, xml_data=data['xml'], misc=misc, profile=profile) | |
796 if data['type'] == 'registration': | |
797 ui.show('popup') | |
798 else: | |
799 ui.show('window') | |
800 elif type_ == "ERROR": | |
801 self.current_action_ids.remove(id) | |
802 self.alert(_("Error"), unicode(data["message"])) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore | |
803 elif type_ == "RESULT": | |
804 self.current_action_ids.remove(id) | |
805 if self.current_action_ids_cb.has_key(id): | |
806 callback = self.current_action_ids_cb[id] | |
807 del self.current_action_ids_cb[id] | |
808 callback(data) | |
809 elif type_ == "DICT_DICT": | |
810 self.current_action_ids.remove(id) | |
811 if self.current_action_ids_cb.has_key(id): | |
812 callback = self.current_action_ids_cb[id] | |
813 del self.current_action_ids_cb[id] | |
814 callback(data) | |
815 else: | |
816 log.error (_("FIXME FIXME FIXME: type [%s] not implemented") % type_) | |
817 raise NotImplementedError | |
818 | |
819 def roomJoinedHandler(self, room_jid_s, room_nicks, user_nick, subject, profile): | 745 def roomJoinedHandler(self, room_jid_s, room_nicks, user_nick, subject, profile): |
820 super(PrimitivusApp, self).roomJoinedHandler(room_jid_s, room_nicks, user_nick, subject, profile) | 746 super(PrimitivusApp, self).roomJoinedHandler(room_jid_s, room_nicks, user_nick, subject, profile) |
821 # if self.selected_widget is None: | 747 # if self.selected_widget is None: |
822 # for contact_list in self.widgets.getWidgets(ContactList): | 748 # for contact_list in self.widgets.getWidgets(ContactList): |
823 # if profile in contact_list.profiles: | 749 # if profile in contact_list.profiles: |