r7070 - in bigboard/trunk/bigboard: . stocks/people



Author: hp
Date: 2007-12-17 14:15:54 -0600 (Mon, 17 Dec 2007)
New Revision: 7070

Modified:
   bigboard/trunk/bigboard/people_tracker.py
   bigboard/trunk/bigboard/stocks/people/peoplewidgets.py
Log:
display IM status messages in people stock

Modified: bigboard/trunk/bigboard/people_tracker.py
===================================================================
--- bigboard/trunk/bigboard/people_tracker.py	2007-12-17 18:29:21 UTC (rev 7069)
+++ bigboard/trunk/bigboard/people_tracker.py	2007-12-17 20:15:54 UTC (rev 7070)
@@ -583,14 +583,14 @@
         # When we disconnect from the server we freeze existing content, then on reconnect
         # we clear everything and start over.
 
-        contact_props = '[+;name;user [+;photoUrl;mugshotLocalBuddy];aims;aimBuddies [+;icon];mugshotLocalBuddies [+;icon];xmpps;xmppBuddies [+;icon];emails;status]'
+        contact_props = '[+;name;user [+;photoUrl;mugshotLocalBuddy];aims;aimBuddies [+;icon;statusMessage];mugshotLocalBuddies [+;icon];xmpps;xmppBuddies [+;icon;statusMessage];emails;status]'
 
         query = self.__model.query_resource(self.__model.self_resource, "contacts %s" % contact_props)
         query.add_handler(self.__on_got_self)
         query.execute()
         
         query = self.__model.query_resource(self.__model.global_resource,
-                                            "aimBuddies [+;icon;contact %s]; xmppBuddies [+;icon;contact %s]; mugshotLocalBuddies [+;icon;contact %s]" % (contact_props, contact_props, contact_props))
+                                            "aimBuddies [+;icon;statusMessage;contact %s]; xmppBuddies [+;icon;statusMessage;contact %s]; mugshotLocalBuddies [+;icon;contact %s]" % (contact_props, contact_props, contact_props))
 
         query.add_handler(self.__on_got_global)
         query.execute()

Modified: bigboard/trunk/bigboard/stocks/people/peoplewidgets.py
===================================================================
--- bigboard/trunk/bigboard/stocks/people/peoplewidgets.py	2007-12-17 18:29:21 UTC (rev 7069)
+++ bigboard/trunk/bigboard/stocks/people/peoplewidgets.py	2007-12-17 20:15:54 UTC (rev 7070)
@@ -18,6 +18,7 @@
 _logger = logging.getLogger("bigboard.stocks.PeopleStock")
 
 STATUS_MUSIC = 0
+STATUS_IM = 1
 
 def _open_aim(aim):
     ## purple-remote only allows lowercase "goim" here, unfortunately I'm guessing 
@@ -37,6 +38,37 @@
     
     os.spawnlp(os.P_NOWAIT, 'gnome-open', 'gnome-open', url)
 
+class StatusMessage(hippo.CanvasText):
+    def __init__(self):
+        hippo.CanvasText.__init__(self, color=0x666666ff)
+        self.__buddies = []
+
+        self.connect('destroy', self.__on_destroy)
+
+    def __on_destroy(self, canvas_item):
+        for b in self.__buddies:
+            b.disconnect(self.__on_buddy_changed)        
+
+    def set_buddies(self, buddies):
+        for b in self.__buddies:
+            b.disconnect(self.__on_buddy_changed)
+
+        self.__buddies = buddies
+        
+        for b in self.__buddies:
+            b.connect(self.__on_buddy_changed, 'statusMessage')
+            self.__on_buddy_changed(b)
+
+    def __on_buddy_changed(self, buddy):
+        message = None
+        try:
+            message = buddy.statusMessage
+        except AttributeError:
+            pass
+        
+        if message and message != '':
+            self.set_property('text', message)
+
 class PersonItem(PhotoContentItem):
     def __init__(self, person, **kwargs):
         PhotoContentItem.__init__(self, **kwargs)
@@ -142,6 +174,13 @@
         self.__name.set_property("text", self.person.display_name) #+ " " + str(self.person._debug_rank))
         self.__photo.set_url(self.person.icon_url)
 
+    def __reset_im_status(self):
+        buddies = self.person.aim_buddies + self.person.xmpp_buddies
+        if len(buddies) > 0:
+            sm = StatusMessage()
+            sm.set_buddies(buddies)
+            self.__set_status(STATUS_IM, sm)
+
     def __update_aim_buddy(self, person):
         if person.aim_buddy:
             if not self.__aim_icon:
@@ -150,8 +189,10 @@
         else:
             if self.__aim_icon:
                 self.__aim_icon.destroy()
-                self.__aim_icon = None
+                self.__aim_icon = None        
 
+        self.__reset_im_status()
+
     def __update_xmpp_buddy(self, person):
         if person.xmpp_buddy:
             if not self.__xmpp_icon:
@@ -162,6 +203,8 @@
                 self.__xmpp_icon.destroy()
                 self.__xmpp_icon = None
 
+        self.__reset_im_status()
+
     def __timeout_track(self):
         self.__current_track_timeout = None
         self.__update_current_track(self.person.resource.user)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]