[Sugar-devel] [PATCH sugar] Fix inviting from friends view OLPC #10767

Simon Schampijer simon at schampijer.de
Thu Mar 24 16:52:04 EDT 2011


Add the contact_id and the account information to the buddymodel used in
the group view. We do not store it in the friends model as the id and the
account information may vary.

Signed-off-by: Simon Schampijer <simon at laptop.org>
---
 src/jarabe/model/friends.py |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/jarabe/model/friends.py b/src/jarabe/model/friends.py
index f78d785..7f50c1e 100644
--- a/src/jarabe/model/friends.py
+++ b/src/jarabe/model/friends.py
@@ -36,10 +36,11 @@ class FriendBuddyModel(BuddyModel):
 
     _NOT_PRESENT_COLOR = '#D5D5D5,#FFFFFF'
 
-    def __init__(self, nick, key):
+    def __init__(self, nick, key, account=None, contact_id=None):
         self._online_buddy = None
 
-        BuddyModel.__init__(self, nick=nick, key=key)
+        BuddyModel.__init__(self, nick=nick, key=key, account=account,
+                            contact_id=contact_id)
 
         neighborhood_model = neighborhood.get_model()
         neighborhood_model.connect('buddy-added', self.__buddy_added_cb)
@@ -60,6 +61,11 @@ class FriendBuddyModel(BuddyModel):
         self.notify('color')
         self.notify('present')
 
+        if buddy.contact_id != self.contact_id:
+            self.contact_id = buddy.contact_id
+        if buddy.account != self.account:
+            self.account = buddy.account
+
     def __buddy_removed_cb(self, model_, buddy):
         if buddy.key != self.key:
             return
@@ -117,7 +123,9 @@ class Friends(gobject.GObject):
 
     def make_friend(self, buddy):
         if not self.has_buddy(buddy):
-            buddy = FriendBuddyModel(key=buddy.key, nick=buddy.nick)
+            buddy = FriendBuddyModel(key=buddy.key, nick=buddy.nick,
+                                     account=buddy.account,
+                                     contact_id=buddy.contact_id)
             self.add_friend(buddy)
             self.save()
 
-- 
1.7.4



More information about the Sugar-devel mailing list