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



Author: hp
Date: 2008-01-10 16:49:14 -0600 (Thu, 10 Jan 2008)
New Revision: 7183

Modified:
   bigboard/trunk/bigboard/people_tracker.py
   bigboard/trunk/bigboard/stocks/people/peoplewidgets.py
Log:
add some additional local buddy handling

Modified: bigboard/trunk/bigboard/people_tracker.py
===================================================================
--- bigboard/trunk/bigboard/people_tracker.py	2008-01-10 19:54:22 UTC (rev 7182)
+++ bigboard/trunk/bigboard/people_tracker.py	2008-01-10 22:49:14 UTC (rev 7183)
@@ -95,6 +95,13 @@
 
             if resource.protocol == 'mugshot-local':
                 self.local_buddy = resource
+
+                ## The merge code in the data model won't know about the user 
+                ## corresponding to the local buddy, so the merge rule won't 
+                ## trigger to create local_buddy.user, unless we do this
+                _logger.debug("Ensuring we load user %s" % (self.local_buddy.name))
+                query = bigboard.globals.get_data_model().query_resource(self.local_buddy.name, "+")
+                query.execute()
             else:
                 self.local_buddy = None
 
@@ -367,7 +374,7 @@
             if resource.class_id == "online-desktop:/p/o/buddy":
                 try:
                     user = resource.user
-                except:
+                except AttributeError:
                     user = None
                     
                 if user != None:
@@ -550,7 +557,9 @@
             return False
 
         if hider.is_contact and \
-                (hidden.resource == hider.aim_buddy or hidden.resource == hider.xmpp_buddy):
+                (hidden.resource == hider.aim_buddy or \
+                     hidden.resource == hider.xmpp_buddy or \
+                     hidden.resource == hider.local_buddy):
             return True
         else:
             return False
@@ -574,7 +583,7 @@
     """
     
     def __init__(self):
-        self.__model = DataModel(bigboard.globals.server_name)
+        self.__model = bigboard.globals.get_data_model()
         self.__model.add_ready_handler(self.__on_ready)
 
         self.contacts = SinglePersonSet()
@@ -592,14 +601,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;statusMessage];mugshotLocalBuddies [+;icon];xmpps;xmppBuddies [+;icon;statusMessage];emails;status]'
+        contact_props = '[+;name;user [+;photoUrl;mugshotLocalBuddy];aims;aimBuddies [+;icon;statusMessage];mugshotLocalBuddies [+;icon;user];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;statusMessage;contact %s]; xmppBuddies [+;icon;statusMessage;contact %s]; mugshotLocalBuddies [+;icon;contact %s]" % (contact_props, contact_props, contact_props))
+                                            "aimBuddies [+;icon;statusMessage;contact %s]; xmppBuddies [+;icon;statusMessage;contact %s]; mugshotLocalBuddies [+;icon;user;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	2008-01-10 19:54:22 UTC (rev 7182)
+++ bigboard/trunk/bigboard/stocks/people/peoplewidgets.py	2008-01-10 22:49:14 UTC (rev 7183)
@@ -724,11 +724,21 @@
                              address=address)
         query.execute()
 
+    def __create_user_contact(self, user_resource):
+        _logger.debug("creating contact %s" % (str(user_resource)))
+        
+        model = globals.get_data_model()
+        query = model.update(("http://mugshot.org/p/contacts";, "createUserContact"),
+                             user=user_resource);
+        query.execute()
+
     def __add_to_network_clicked(self, link):
         if self.person.aim:
             self.__create_contact('aim', self.person.aim)
         elif self.person.xmpp:
             self.__create_contact('xmpp', self.person.xmpp)
+        elif self.person.local_buddy:
+            self.__create_user_contact(self.person.local_buddy.user)
 
         # action_taken = False to leave the stock open which seems nicer in this case
         self.emit("close", False)



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