# HG changeset patch # User souliane # Date 1449514572 -3600 # Node ID c1be6363bfabaf62a63a431c7fd1db7fb9f5acc5 # Parent 13e43b2cd7a2c1211afa53236a02389b2d206f80 core, plugin misc_account: set XMPP connection max retries to 0 when checking if an external account exists diff -r 13e43b2cd7a2 -r c1be6363bfab src/core/constants.py --- a/src/core/constants.py Mon Dec 07 15:57:33 2015 +0100 +++ b/src/core/constants.py Mon Dec 07 19:56:12 2015 +0100 @@ -38,6 +38,7 @@ # Protocol XMPP_C2S_PORT = 5222 XMPP_KEEP_ALIFE = 180 + XMPP_MAX_RETRIES = 2 ## Parameters ## diff -r 13e43b2cd7a2 -r c1be6363bfab src/core/sat_main.py --- a/src/core/sat_main.py Mon Dec 07 15:57:33 2015 +0100 +++ b/src/core/sat_main.py Mon Dec 07 19:56:12 2015 +0100 @@ -251,12 +251,13 @@ profile = self.memory.getProfileName(profile_key) return self.asyncConnect(profile, password) - def asyncConnect(self, profile, password=''): + def asyncConnect(self, profile, password='', max_retries=C.XMPP_MAX_RETRIES): """Retrieve the individual parameters, authenticate the profile and initiate the connection to the associated XMPP server. + @param profile: %(doc_profile)s @param password (string): the SàT profile password - @param profile: %(doc_profile)s + @param max_retries (int): max number of connection retries @return (D(bool)): - True if the XMPP connection was already established - False if the XMPP connection has been initiated (it may still fail) @@ -266,7 +267,7 @@ if self.isConnected(profile): log.info(_("already connected !")) return True - d = self._connectXMPPClient(profile) + d = self._connectXMPPClient(profile, max_retries) return d.addCallback(lambda dummy: False) d = self.memory.startSession(password, profile) @@ -274,7 +275,7 @@ return d @defer.inlineCallbacks - def _connectXMPPClient(self, profile): + def _connectXMPPClient(self, profile, max_retries): """This part is called from asyncConnect when we have loaded individual parameters from memory""" try: port = int(self.memory.getParamA(C.FORCE_PORT_PARAM, "Connection", profile_key=profile)) @@ -285,7 +286,8 @@ password = yield self.memory.asyncGetParamA("Password", "Connection", profile_key=profile) current = self.profiles[profile] = xmpp.SatXMPPClient(self, profile, jid.JID(self.memory.getParamA("JabberID", "Connection", profile_key=profile)), - password, self.memory.getParamA(C.FORCE_SERVER_PARAM, "Connection", profile_key=profile), port) + password, self.memory.getParamA(C.FORCE_SERVER_PARAM, "Connection", profile_key=profile), + port, max_retries) current.messageProt = xmpp.SatMessageProtocol(self) current.messageProt.setHandlerParent(current) diff -r 13e43b2cd7a2 -r c1be6363bfab src/core/xmpp.py --- a/src/core/xmpp.py Mon Dec 07 15:57:33 2015 +0100 +++ b/src/core/xmpp.py Mon Dec 07 19:56:12 2015 +0100 @@ -34,12 +34,12 @@ class SatXMPPClient(client.XMPPClient): implements(iwokkel.IDisco) - def __init__(self, host_app, profile, user_jid, password, host=None, port=C.XMPP_C2S_PORT): + def __init__(self, host_app, profile, user_jid, password, host=None, port=C.XMPP_C2S_PORT, max_retries=C.XMPP_MAX_RETRIES): # XXX: DNS SRV records are checked when the host is not specified. # If no SRV record is found, the host is directly extracted from the JID. client.XMPPClient.__init__(self, user_jid, password, host or None, port or C.XMPP_C2S_PORT) self.factory.clientConnectionLost = self.connectionLost - self.factory.maxRetries = 2 + self.factory.maxRetries = max_retries self.__connected = False self.profile = profile self.host_app = host_app diff -r 13e43b2cd7a2 -r c1be6363bfab src/plugins/plugin_misc_account.py --- a/src/plugins/plugin_misc_account.py Mon Dec 07 15:57:33 2015 +0100 +++ b/src/plugins/plugin_misc_account.py Mon Dec 07 19:56:12 2015 +0100 @@ -541,7 +541,7 @@ d = self.registerAccount(None, password, jid_s, jid_s) d.addCallback(lambda dummy: self.host.memory.getProfileName(jid_s)) # checks if the profile has been successfuly created - d.addCallback(self.host.asyncConnect, password) + d.addCallback(self.host.asyncConnect, password, 0) def removeProfile(failure): # profile has been successfully created but the XMPP credentials are wrong! log.debug("Removing previously auto-created profile: %s" % failure.getErrorMessage())