core, bridge, frontends: removed deprecated bridge method askConfirmation, confirmationAnswer, actionResult, actionResultExt and getWaitingConf

This commit is contained in:
Goffi 2016-08-28 19:23:58 +02:00
commit 55357178ef
3 changed files with 6 additions and 309 deletions

View file

@ -207,20 +207,6 @@ class DBusBridgeFrontend(BridgeFrontend):
error_handler = lambda err:errback(dbus_to_bridge_exception(err))
return self.db_core_iface.asyncGetParamsValuesFromCategory(category, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
def confirmationAnswer(self, id, accepted, data, profile, callback=None, errback=None):
if callback is None:
error_handler = None
else:
if errback is None:
errback = log.error
error_handler = lambda err:errback(dbus_to_bridge_exception(err))
kwargs={}
if callback is not None:
kwargs['timeout'] = const_TIMEOUT
kwargs['reply_handler'] = callback
kwargs['error_handler'] = error_handler
return self.db_core_iface.confirmationAnswer(id, accepted, data, profile, **kwargs)
def delContact(self, entity_jid, profile_key="@DEFAULT@", callback=None, errback=None):
if callback is None:
error_handler = None
@ -480,20 +466,6 @@ class DBusBridgeFrontend(BridgeFrontend):
kwargs['error_handler'] = error_handler
return unicode(self.db_core_iface.getVersion(**kwargs))
def getWaitingConf(self, profile_key, callback=None, errback=None):
if callback is None:
error_handler = None
else:
if errback is None:
errback = log.error
error_handler = lambda err:errback(dbus_to_bridge_exception(err))
kwargs={}
if callback is not None:
kwargs['timeout'] = const_TIMEOUT
kwargs['reply_handler'] = callback
kwargs['error_handler'] = error_handler
return self.db_core_iface.getWaitingConf(profile_key, **kwargs)
def getWaitingSub(self, profile_key="@DEFAULT@", callback=None, errback=None):
if callback is None:
error_handler = None

View file

@ -28,7 +28,6 @@ from sat.tools import config as sat_config
import urwid
from urwid.util import is_wide_char
from urwid_satext import sat_widgets
from urwid_satext.files_management import FileDialog
from sat_frontends.bridge.DBus import DBusBridgeFrontend
from sat_frontends.quick_frontend.quick_app import QuickApp
from sat_frontends.quick_frontend import quick_utils
@ -43,7 +42,6 @@ from sat_frontends.primitivus.keys import action_key_map as a_key
from sat_frontends.primitivus import config
from sat_frontends.tools.misc import InputHistory
from sat_frontends.tools import jid
from os.path import join
import signal
import sys
@ -744,78 +742,6 @@ class PrimitivusApp(QuickApp, InputHistory):
def _actionManagerUnknownError(self):
self.alert(_("Error"), _(u"Unmanaged action"))
def askConfirmationHandler(self, confirmation_id, confirmation_type, data, profile):
answer_data = {}
def dir_selected_cb(path):
dest_path = join(path, data['filename'])
answer_data["dest_path"] = quick_utils.getNewPath(dest_path)
self.addProgress(confirmation_id, dest_path)
accept_cb(None)
def accept_file_transfer_cb(widget):
self.removePopUp()
pop_up_widget = FileDialog(dir_selected_cb, refuse_cb, title=_(u"Where do you want to save the file ?"), style=['dir'])
self.showPopUp(pop_up_widget)
def accept_cb(widget):
self.removePopUp()
self.bridge.confirmationAnswer(confirmation_id, True, answer_data, profile)
def refuse_cb(widget):
self.removePopUp()
self.bridge.confirmationAnswer(confirmation_id, False, answer_data, profile)
if confirmation_type == "FILE_TRANSFER":
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)
self.showPopUp(pop_up_widget)
elif confirmation_type == "YES/NO":
pop_up_widget = sat_widgets.ConfirmDialog(data["message"], no_cb=refuse_cb, yes_cb=accept_cb)
self.showPopUp(pop_up_widget)
def actionResultHandler(self, type_, id, data, profile):
# FIXME: to be removed
if not id in self.current_action_ids:
log.debug (_('unknown id, ignoring'))
return
if type_ == "SUPPRESS":
self.current_action_ids.remove(id)
elif type_ == "XMLUI":
self.current_action_ids.remove(id)
log.debug (_("XML user interface received"))
misc = {}
#FIXME FIXME FIXME: must clean all this crap !
title = _('Form')
if data['type'] == 'registration':
title = _('Registration')
misc['target'] = data['target']
misc['action_back'] = self.bridge.gatewayRegister
ui = xmlui.create(self, title=title, xml_data=data['xml'], misc=misc, profile=profile)
if data['type'] == 'registration':
ui.show('popup')
else:
ui.show('window')
elif type_ == "ERROR":
self.current_action_ids.remove(id)
self.alert(_("Error"), unicode(data["message"])) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore
elif type_ == "RESULT":
self.current_action_ids.remove(id)
if self.current_action_ids_cb.has_key(id):
callback = self.current_action_ids_cb[id]
del self.current_action_ids_cb[id]
callback(data)
elif type_ == "DICT_DICT":
self.current_action_ids.remove(id)
if self.current_action_ids_cb.has_key(id):
callback = self.current_action_ids_cb[id]
del self.current_action_ids_cb[id]
callback(data)
else:
log.error (_("FIXME FIXME FIXME: type [%s] not implemented") % type_)
raise NotImplementedError
def roomJoinedHandler(self, room_jid_s, room_nicks, user_nick, subject, profile):
super(PrimitivusApp, self).roomJoinedHandler(room_jid_s, room_nicks, user_nick, subject, profile)
# if self.selected_widget is None:

View file

@ -46,6 +46,8 @@ except (TypeError, AttributeError): # Error raised is not the same depending on
class ProfileManager(object):
"""Class managing all data relative to one profile, and plugging in mechanism"""
# TODO: handle waiting XMLUI requests: getWaitingConf doesn't exist anymore
# and a way to keep some XMLUI request between sessions is expected in backend
host = None
bridge = None
cache_keys_to_get = ['avatar']
@ -136,13 +138,6 @@ class ProfileManager(object):
self.host.presenceUpdateHandler(jabber_id, show, priority, statuses, self.profile)
self.host.bridge.getEntityData(contact, ['avatar', 'nick'], self.profile, callback=lambda data, contact=contact: gotEntityData(data, contact), errback=lambda failure, contact=contact: log.debug(u"No cache data for {}".format(contact)))
#Finaly, we get the waiting confirmation requests
self.bridge.getWaitingConf(self.profile, callback=self._plug_profile_gotWaitingConf)
def _plug_profile_gotWaitingConf(self, waiting_confs):
for confirm_id, confirm_type, data in waiting_confs:
self.host.askConfirmationHandler(confirm_id, confirm_type, data, self.profile)
# At this point, profile should be fully plugged
# and we launch frontend specific method
self.host.profilePlugged(self.profile)
@ -238,18 +233,14 @@ class QuickApp(object):
self.registerSignal("actionNew")
self.registerSignal("newContact")
self.registerSignal("messageNew")
self.registerSignal("newAlert")
self.registerSignal("presenceUpdate")
self.registerSignal("subscribe")
self.registerSignal("paramUpdate")
self.registerSignal("contactDeleted")
self.registerSignal("entityDataUpdated")
self.registerSignal("askConfirmation")
self.registerSignal("actionResult")
self.registerSignal("progressStarted")
self.registerSignal("progressFinished")
self.registerSignal("progressError")
self.registerSignal("actionResultExt", self.actionResultHandler)
self.registerSignal("mucRoomJoined", iface="plugin")
self.registerSignal("mucRoomLeft", iface="plugin")
self.registerSignal("mucRoomUserChangedNick", iface="plugin")
@ -263,8 +254,6 @@ class QuickApp(object):
quick_games.Quiz.registerSignals(self)
quick_games.Radiocol.registerSignals(self)
self.current_action_ids = set() # FIXME: to be removed
self.current_action_ids_cb = {} # FIXME: to be removed
self._notif_id = 0
self._notifications = OrderedDict()
self.media_dir = self.bridge.getConfig('', 'media_dir')
@ -485,9 +474,6 @@ class QuickApp(object):
# we want to be sure to have at least one QuickChat instance
self.widgets.getOrCreateWidget(quick_chat.QuickChat, target, type_=C.CHAT_ONE2ONE, on_new_widget=None, profile=profile)
self.current_action_ids = set() # FIXME: to be removed
self.current_action_ids_cb = {} # FIXME: to be removed
if not from_jid in contact_list and from_jid.bare != self.profiles[profile].whoami.bare:
#XXX: needed to show entities which haven't sent any
# presence information and which are not in roster
@ -516,10 +502,6 @@ class QuickApp(object):
self.bridge.messageSend(unicode(to_jid), message, subject, mess_type, extra, profile_key, callback=callback, errback=errback)
def newAlertHandler(self, msg, title, alert_type, profile):
assert alert_type in ['INFO', 'ERROR']
self.showDialog(unicode(msg), unicode(title), alert_type.lower())
def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE):
raise NotImplementedError
@ -788,12 +770,6 @@ class QuickApp(object):
self.callListeners('avatar', entity, filename, profile=profile)
self.bridge.getAvatarFile(value, callback=gotFilename)
def askConfirmationHandler(self, confirm_id, confirm_type, data, profile):
raise NotImplementedError
def actionResultHandler(self, type, id, data, profile):
raise NotImplementedError
def actionManager(self, action_data, callback=None, ui_show_cb=None, user_action=True, profile=C.PROF_KEY_NONE):
"""Handle backend action