Adding some deadcode for later
[theonering] / src / connection.py
index cbdb388..73ec4a4 100644 (file)
@@ -207,17 +207,11 @@ class TheOneRingConnection(
                        self.__channelManager.channel_for_props(publishProps, signal=True)
                except gvoice.backend.NetworkError, e:
                        _moduleLogger.exception("Connection Failed")
-                       self.StatusChanged(
-                               telepathy.CONNECTION_STATUS_DISCONNECTED,
-                               telepathy.CONNECTION_STATUS_REASON_NETWORK_ERROR
-                       )
+                       self.disconnect(telepathy.CONNECTION_STATUS_REASON_NETWORK_ERROR)
                        return
                except Exception, e:
                        _moduleLogger.exception("Connection Failed")
-                       self.StatusChanged(
-                               telepathy.CONNECTION_STATUS_DISCONNECTED,
-                               telepathy.CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED
-                       )
+                       self.disconnect(telepathy.CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED)
                        return
 
                _moduleLogger.info("Connected")
@@ -231,12 +225,8 @@ class TheOneRingConnection(
                """
                For org.freedesktop.telepathy.Connection
                """
-               self.StatusChanged(
-                       telepathy.CONNECTION_STATUS_DISCONNECTED,
-                       telepathy.CONNECTION_STATUS_REASON_REQUESTED
-               )
                try:
-                       self.disconnect()
+                       self.disconnect(telepathy.CONNECTION_STATUS_REASON_REQUESTED)
                except Exception:
                        _moduleLogger.exception("Error durring disconnect")
 
@@ -277,8 +267,15 @@ class TheOneRingConnection(
 
                return props
 
-       def disconnect(self):
+       def disconnect(self, reason):
                _moduleLogger.info("Disconnecting")
+               # Not having the disconnect first can cause weird behavior with clients
+               # including not being able to reconnect or even crashing
+               self.StatusChanged(
+                       telepathy.CONNECTION_STATUS_DISCONNECTED,
+                       reason,
+               )
+
                for plumber in self._plumbing:
                        plumber.stop()