10 _moduleLogger = logging.getLogger("connection_manager")
13 class TheOneRingConnectionManager(telepathy.server.ConnectionManager):
15 def __init__(self, shutdown_func=None):
16 telepathy.server.ConnectionManager.__init__(self, constants._telepathy_implementation_name_)
18 # self._protos is from super
19 self._protos[constants._telepathy_protocol_name_] = connection.TheOneRingConnection
20 self._on_shutdown = shutdown_func
21 _moduleLogger.info("Connection manager created")
23 def GetParameters(self, proto):
25 For org.freedesktop.telepathy.ConnectionManager
27 @returns the mandatory and optional parameters for creating a connection
29 if proto not in self._protos:
30 raise telepathy.NotImplemented('unknown protocol %s' % proto)
33 ConnectionClass = self._protos[proto]
34 mandatoryParameters = ConnectionClass._mandatory_parameters
35 optionalParameters = ConnectionClass._optional_parameters
36 defaultParameters = ConnectionClass._parameter_defaults
38 for parameterName, parameterType in mandatoryParameters.iteritems():
39 flags = telepathy.CONN_MGR_PARAM_FLAG_REQUIRED
40 if parameterName == "password":
41 flags |= telepathy.CONN_MGR_PARAM_FLAG_SECRET
50 for parameterName, parameterType in optionalParameters.iteritems():
51 if parameterName in defaultParameters:
52 flags = telepathy.CONN_MGR_PARAM_FLAG_HAS_DEFAULT
53 if parameterName == "password":
54 flags |= telepathy.CONN_MGR_PARAM_FLAG_SECRET
55 default = defaultParameters[parameterName]
69 def disconnected(self, conn):
71 Overrides telepathy.server.ConnectionManager
73 result = telepathy.server.ConnectionManager.disconnected(self, conn)
74 gobject.timeout_add(5000, self.shutdown)
78 Terminates all connections. Must be called upon quit
80 for connection in self._connections:
81 connection.Disconnect()
82 _moduleLogger.info("Connection manager quitting")
86 self._on_shutdown is not None and
87 len(self._connections) == 0