Philipp Hörist pushed to branch master at gajim / gajim


Commits:
d6dc367d by Philipp Hörist at 2023-08-22T21:00:26+02:00
fix: Make it impossible to connect without config

Fixes #11608

- - - - -


1 changed file:

- gajim/common/client.py


Changes:

=====================================
gajim/common/client.py
=====================================
@@ -266,7 +266,7 @@ def _on_disconnected(self,
 
             if error in ('not-authorized', 'no-password'):
                 def _on_password() -> None:
-                    self._prepare_for_connect()
+                    self.connect()
 
                 app.ged.raise_event(PasswordRequired(client=self,
                                                      on_password=_on_password))
@@ -377,7 +377,7 @@ def change_status(self, show: str, message: str) -> None:
             if show == 'offline':
                 return
 
-            self._prepare_for_connect()
+            self.connect()
             return
 
         if self._state.is_connecting:
@@ -392,7 +392,7 @@ def change_status(self, show: str, message: str) -> None:
                 self._destroy_client = True
                 self._abort_reconnect()
             else:
-                self._prepare_for_connect()
+                self.connect()
             return
 
         # We are connected
@@ -521,7 +521,18 @@ def _send_message(self, message: OutgoingMessage) -> None:
                         msg_log_id=log_line_id,
                         play_sound=message.play_sound))
 
-    def _prepare_for_connect(self) -> None:
+    def connect(
+        self,
+        ignored_tls_errors: IgnoredTlsErrorsT = None
+    ) -> None:
+
+        log.info('Connect')
+
+        if self._state not in (ClientState.DISCONNECTED,
+                               ClientState.RECONNECT_SCHEDULED):
+            # Do not try to reco while we are already trying
+            return
+
         custom_host = get_custom_host(self._account)
         if custom_host is not None:
             self._client.set_custom_host(*custom_host)
@@ -547,19 +558,10 @@ def _prepare_for_connect(self) -> None:
         password = passwords.get_password(self._account)
         self._client.set_password(password)
 
-        self.connect()
-
-    def connect(self, ignored_tls_errors: IgnoredTlsErrorsT = None) -> None:
-        if self._state not in (ClientState.DISCONNECTED,
-                               ClientState.RECONNECT_SCHEDULED):
-            # Do not try to reco while we are already trying
-            return
-
-        log.info('Connect')
-
         self._client.set_accepted_certificates(
             app.cert_store.get_certificates())
         self._client.set_ignored_tls_errors(ignored_tls_errors)
+
         self._reconnect = True
         self._disable_reconnect_timer()
         self._set_state(ClientState.CONNECTING)
@@ -578,7 +580,7 @@ def _schedule_reconnect(self) -> None:
         self._set_state(ClientState.RECONNECT_SCHEDULED)
         log.info('Reconnect to %s in 3s', self._account)
         self._reconnect_timer_source = GLib.timeout_add_seconds(
-            3, self._prepare_for_connect)
+            3, self.connect)
 
     def _abort_reconnect(self) -> None:
         self._set_state(ClientState.DISCONNECTED)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/d6dc367db61a5e25e8c8592e1c84ab2e88e0eb2f

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/d6dc367db61a5e25e8c8592e1c84ab2e88e0eb2f
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to