Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/jarabe/model/neighborhood.py
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-09-16 16:35:32 (GMT)
committer Tomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-09-17 16:06:15 (GMT)
commit9a0b3b51888f4ddfe834bd093b6147b3ea1bd7ec (patch)
treebc2d080ba043686bc74c720b7ca5c7d33c8f5b5d /src/jarabe/model/neighborhood.py
parent0b95b36d85e08a4df3a63c78f1cf8b549f06a5fa (diff)
Properly store and load friends #2331
Because FriendBuddyModel has a different life cycle than BuddyModel (are tracked also when online), we need to store the key and nick so we can represent them in the UI when the contact are not online and also so we can relate to the contact when it becomes online. * src/jarabe/model/buddy.py: Move out FriendBuddyModel and add a handle property to BuddyModel. * src/jarabe/model/filetransfer.py: Ask neighborhood.py for the buddy associated to a handle. * src/jarabe/model/friends.py: Add FriendBuddyModel. * src/jarabe/model/neighborhood.py: Set the contact handle on the BuddyModel.
Diffstat (limited to 'src/jarabe/model/neighborhood.py')
-rw-r--r--src/jarabe/model/neighborhood.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/jarabe/model/neighborhood.py b/src/jarabe/model/neighborhood.py
index a7e43f0..6f73bfe 100644
--- a/src/jarabe/model/neighborhood.py
+++ b/src/jarabe/model/neighborhood.py
@@ -160,7 +160,8 @@ class _Account(gobject.GObject):
'activity-removed': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, ([object])),
'buddy-added': (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE, ([object, object, object])),
+ gobject.TYPE_NONE,
+ ([object, object, object, object])),
'buddy-updated': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, ([object, object])),
'buddy-removed': (gobject.SIGNAL_RUN_FIRST,
@@ -538,7 +539,7 @@ class _Account(gobject.GObject):
def __got_buddy_info_cb(self, handle, nick, properties):
logging.debug('_Account.__got_buddy_info_cb %r', properties)
self.emit('buddy-added', self._buddy_handles[handle], nick,
- properties.get('key', None))
+ properties.get('key', None), handle)
self.emit('buddy-updated', self._buddy_handles[handle], properties)
def __get_contact_attributes_cb(self, attributes):
@@ -589,7 +590,7 @@ class _Account(gobject.GObject):
'BuddyInfo.GetCurrentActivity'),
timeout=_QUERY_DBUS_TIMEOUT)
else:
- self.emit('buddy-added', contact_id, nick, None)
+ self.emit('buddy-added', contact_id, nick, None, handle)
def __got_activities_cb(self, buddy_handle, activities):
logging.debug('_Account.__got_activities_cb %r %r', buddy_handle,
@@ -812,7 +813,7 @@ class Neighborhood(gobject.GObject):
if needs_reconnect:
account.Reconnect()
- def __buddy_added_cb(self, account, contact_id, nick, key):
+ def __buddy_added_cb(self, account, contact_id, nick, key, handle):
logging.debug('__buddy_added_cb %r', contact_id)
if contact_id in self._buddies:
@@ -823,7 +824,8 @@ class Neighborhood(gobject.GObject):
nick=nick,
account=account.object_path,
contact_id=contact_id,
- key=key)
+ key=key,
+ handle=handle)
self._buddies[contact_id] = buddy
self.emit('buddy-added', buddy)
@@ -948,6 +950,18 @@ class Neighborhood(gobject.GObject):
def get_buddies(self):
return self._buddies.values()
+ def get_buddy_by_key(self, key):
+ for buddy in self._buddies.values():
+ if buddy.key == key:
+ return buddy
+ return None
+
+ def get_buddy_by_handle(self, contact_handle):
+ for buddy in self._buddies.values():
+ if not buddy.is_owner() and buddy.handle == contact_handle:
+ return buddy
+ return None
+
def get_activity(self, activity_id):
return self._activities.get(activity_id, None)