Pass the account path to the Activity on creation

This commit is contained in:
Tomeu Vizoso 2010-07-13 12:15:43 +02:00
parent 1a4c721f3d
commit 46159e987b
2 changed files with 14 additions and 13 deletions

View File

@ -36,7 +36,8 @@ from sugar.presence.util import get_connection_manager
from telepathy.interfaces import ACCOUNT, \ from telepathy.interfaces import ACCOUNT, \
ACCOUNT_MANAGER, \ ACCOUNT_MANAGER, \
CONNECTION CONNECTION
from telepathy.constants import HANDLE_TYPE_CONTACT from telepathy.constants import HANDLE_TYPE_CONTACT, \
HANDLE_TYPE_ROOM
_logger = logging.getLogger('sugar.presence.presenceservice') _logger = logging.getLogger('sugar.presence.presenceservice')
@ -263,14 +264,16 @@ class PresenceService(gobject.GObject):
'instance') 'instance')
return self._activity_cache return self._activity_cache
else: else:
for connection in get_connection_manager().connections: connection_manager = get_connection_manager()
try: connections_per_account = connection_manager.get_connections_per_account()
room_handle = connection.GetActivity(activity_id) for account_path, connection in connections_per_account.items():
activity = Activity(connection, room_handle) room_handles = connection.RequestHandles(HANDLE_TYPE_ROOM,
self._activity_cache = activity [activity_id],
return activity dbus_interface=CONNECTION)
except: activity = Activity(account_path, connection,
pass room_handle=room_handles[0])
self._activity_cache = activity
return activity
return None return None

View File

@ -47,10 +47,8 @@ class ConnectionManager(object):
def get_connection(self, account_path): def get_connection(self, account_path):
return self._connections_per_account[account_path] return self._connections_per_account[account_path]
def get_connections(self): def get_connections_per_account(self):
return self._connections_per_account.values() return self._connections_per_account
connections = property(get_connections)
_connection_manager = None _connection_manager = None