diff src/core/sat_main.py @ 1725:c1be6363bfab

core, plugin misc_account: set XMPP connection max retries to 0 when checking if an external account exists
author souliane <souliane@mailoo.org>
date Mon, 07 Dec 2015 19:56:12 +0100
parents 3c608d660f0b
children d17772b0fe22
line wrap: on
line diff
--- 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)