Adding conic dependency, fixing bug with disconnecting from conic, reducing the numbe...
[theonering] / src / connection_manager.py
index 42153ac..0f75671 100644 (file)
@@ -1,9 +1,18 @@
+"""
+Empathy Experience:
+       Can't call
+       When first started, reports all read conversations when some might have been read
+       When first started, reports all of an SMS conversation even though some has been reported previously
+       Still leaking one of two contact lists
+"""
+
 import logging
 
 import gobject
 import telepathy
 
 import constants
+import tp
 import gtk_toolbox
 import connection
 
@@ -11,10 +20,10 @@ import connection
 _moduleLogger = logging.getLogger("connection_manager")
 
 
-class TheOneRingConnectionManager(telepathy.server.ConnectionManager):
+class TheOneRingConnectionManager(tp.ConnectionManager):
 
        def __init__(self, shutdown_func=None):
-               telepathy.server.ConnectionManager.__init__(self, constants._telepathy_implementation_name_)
+               tp.ConnectionManager.__init__(self, constants._telepathy_implementation_name_)
 
                # self._protos is from super
                self._protos[constants._telepathy_protocol_name_] = connection.TheOneRingConnection
@@ -29,51 +38,41 @@ class TheOneRingConnectionManager(telepathy.server.ConnectionManager):
                @returns the mandatory and optional parameters for creating a connection
                """
                if proto not in self._protos:
-                       raise telepathy.NotImplemented('unknown protocol %s' % proto)
+                       raise telepathy.errors.NotImplemented('unknown protocol %s' % proto)
 
                result = []
                ConnectionClass = self._protos[proto]
                mandatoryParameters = ConnectionClass._mandatory_parameters
                optionalParameters = ConnectionClass._optional_parameters
                defaultParameters = ConnectionClass._parameter_defaults
+               secretParameters = ConnectionClass._secret_parameters
 
                for parameterName, parameterType in mandatoryParameters.iteritems():
                        flags = telepathy.CONN_MGR_PARAM_FLAG_REQUIRED
-                       if parameterName == "password":
+                       if parameterName in secretParameters:
                                flags |= telepathy.CONN_MGR_PARAM_FLAG_SECRET
-                       param = (
-                               parameterName,
-                               flags,
-                               parameterType,
-                               '',
-                       )
+                       param = (parameterName, flags, parameterType, "")
                        result.append(param)
 
                for parameterName, parameterType in optionalParameters.iteritems():
+                       flags = 0
+                       default = ""
+                       if parameterName in secretParameters:
+                               flags |= telepathy.CONN_MGR_PARAM_FLAG_SECRET
                        if parameterName in defaultParameters:
-                               flags = telepathy.CONN_MGR_PARAM_FLAG_HAS_DEFAULT
-                               if parameterName == "password":
-                                       flags |= telepathy.CONN_MGR_PARAM_FLAG_SECRET
+                               flags |= telepathy.CONN_MGR_PARAM_FLAG_HAS_DEFAULT
                                default = defaultParameters[parameterName]
-                       else:
-                               flags = 0
-                               default = ""
-                       param = (
-                               parameterName,
-                               flags,
-                               parameterName,
-                               default,
-                       )
+                       param = (parameterName, flags, parameterType, default)
                        result.append(param)
 
                return result
 
        def disconnected(self, conn):
                """
-               Overrides telepathy.server.ConnectionManager
+               Overrides tp.ConnectionManager
                """
-               result = telepathy.server.ConnectionManager.disconnected(self, conn)
-               gobject.timeout_add(5000, self.shutdown)
+               result = tp.ConnectionManager.disconnected(self, conn)
+               gobject.timeout_add(5000, self._shutdown)
 
        def quit(self):
                """
@@ -83,6 +82,7 @@ class TheOneRingConnectionManager(telepathy.server.ConnectionManager):
                        connection.Disconnect()
                _moduleLogger.info("Connection manager quitting")
 
+       @gtk_toolbox.log_exception(_moduleLogger)
        def _shutdown(self):
                if (
                        self._on_shutdown is not None and