From 1a4c721f3d564dcb7d395196130c0299a4ec1fd4 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Mon, 12 Jul 2010 18:33:19 +0000 Subject: Identify buddies and activities by their account and ids instead of connection and handle. --- (limited to 'src/sugar/presence/util.py') diff --git a/src/sugar/presence/util.py b/src/sugar/presence/util.py index 265e390..f00228f 100644 --- a/src/sugar/presence/util.py +++ b/src/sugar/presence/util.py @@ -10,7 +10,7 @@ ACCOUNT_MANAGER_PATH = '/org/freedesktop/Telepathy/AccountManager' class ConnectionManager(object): def __init__(self): - self.connections_per_account = [] + self._connections_per_account = {} bus = dbus.SessionBus() obj = bus.get_object(ACCOUNT_MANAGER_SERVICE, ACCOUNT_MANAGER_PATH) @@ -32,11 +32,11 @@ class ConnectionManager(object): connection_name = connection_path.replace('/', '.')[1:] connection = bus.get_object(connection_name, connection_path) - self.connections[account_path] = connection + self._connections_per_account[account_path] = connection def get_preferred_connection(self): best_connection = None, None - for account_path, connection in self.connections.items(): + for account_path, connection in self._connections_per_account.items(): if 'salut' in connection.object_path: best_connection = account_path, connection elif 'gabble' in connection.object_path: @@ -44,6 +44,14 @@ class ConnectionManager(object): break return best_connection + def get_connection(self, account_path): + return self._connections_per_account[account_path] + + def get_connections(self): + return self._connections_per_account.values() + + connections = property(get_connections) + _connection_manager = None def get_connection_manager(): -- cgit v0.9.1