core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
This commit is contained in:
parent
f719875f0b
commit
244a33d2c7
1 changed files with 32 additions and 41 deletions
|
|
@ -49,7 +49,6 @@ class QuickApp(object):
|
|||
sys.exit(1)
|
||||
self.bridge.register("connected", self.connected)
|
||||
self.bridge.register("disconnected", self.disconnected)
|
||||
self.bridge.register("connectionError", self.connectionError)
|
||||
self.bridge.register("newContact", self.newContact)
|
||||
self.bridge.register("newMessage", self._newMessage)
|
||||
self.bridge.register("newAlert", self.newAlert)
|
||||
|
|
@ -152,10 +151,19 @@ class QuickApp(object):
|
|||
self.bridge.asyncGetParamA("Watched", "Misc", profile_key=profile,
|
||||
callback=lambda watched: self.plug_profile_4(watched, autoconnect, profile), errback=self._getParamError)
|
||||
|
||||
def asyncConnect(self, profile, callback=None, errback=None):
|
||||
if not callback:
|
||||
callback = lambda dummy: None
|
||||
if not errback:
|
||||
def errback(failure):
|
||||
log.error(_(u"Can't connect profile [%s]") % failure)
|
||||
self.launchAction(C.CHANGE_XMPP_PASSWD_ID, {}, profile_key=profile)
|
||||
self.bridge.asyncConnect(profile, callback=callback, errback=errback)
|
||||
|
||||
def plug_profile_4(self, watched, autoconnect, profile):
|
||||
if autoconnect and not self.bridge.isConnected(profile):
|
||||
#Does the user want autoconnection ?
|
||||
self.bridge.asyncConnect(profile, callback=lambda dummy: self.plug_profile_5(watched, autoconnect, profile), errback=lambda ignore: log.error(_('Error during autoconnection')))
|
||||
self.asyncConnect(profile, callback=lambda dummy: self.plug_profile_5(watched, autoconnect, profile))
|
||||
else:
|
||||
self.plug_profile_5(watched, autoconnect, profile)
|
||||
|
||||
|
|
@ -229,17 +237,6 @@ class QuickApp(object):
|
|||
self.contact_list.clearContacts()
|
||||
self.setStatusOnline(False)
|
||||
|
||||
def connectionError(self, error_type, profile):
|
||||
"""called when something goes wrong with the connection"""
|
||||
if not self.check_profile(profile):
|
||||
return
|
||||
log.debug(_("Connection Error"))
|
||||
self.disconnected(profile)
|
||||
if error_type == "AUTH_ERROR":
|
||||
self.launchAction(C.CHANGE_XMPP_PASSWD_ID, {}, profile_key=profile)
|
||||
else:
|
||||
log.error(_('FIXME: error_type %s not implemented') % error_type)
|
||||
|
||||
def newContact(self, JabberId, attributes, groups, profile):
|
||||
if not self.check_profile(profile):
|
||||
return
|
||||
|
|
@ -612,6 +609,15 @@ class QuickApp(object):
|
|||
def actionResult(self, type, id, data):
|
||||
raise NotImplementedError
|
||||
|
||||
def launchAction(self, callback_id, data=None, profile_key="@NONE@"):
|
||||
""" Launch a dynamic action
|
||||
@param callback_id: id of the action to launch
|
||||
@param data: data needed only for certain actions
|
||||
@param profile_key: %(doc_profile_key)s
|
||||
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def onExit(self):
|
||||
"""Must be called when the frontend is terminating"""
|
||||
#TODO: mange multi-profile here
|
||||
|
|
|
|||
Loading…
Reference in a new issue