From 2aaefdd52b1b937bef48001c9a04078805f3abe3 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 15 Jun 2006 17:41:49 -0400 Subject: [PATCH] Hook into PresenceService to find new advertisements and track them --- sugar/shell/StartPage.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sugar/shell/StartPage.py b/sugar/shell/StartPage.py index 6abe5eee..92102104 100644 --- a/sugar/shell/StartPage.py +++ b/sugar/shell/StartPage.py @@ -6,6 +6,9 @@ import dbus import cgi import google +from sugar.presence.PresenceService import PresenceService +from sugar.presence import Service +from sugar.browser import BrowserActivity class ActivitiesModel(gtk.ListStore): def __init__(self): @@ -52,6 +55,12 @@ class StartPage(gtk.HBox): def __init__(self): gtk.HBox.__init__(self) + self._pservice = PresenceService.get_instance() + self._pservice.connect("activity-announced", self._on_activity_announced_cb) + self._pservice.connect("new-service-adv", self._on_new_service_adv_cb) + self._pservice.start() + self._pservice.track_service_type(BrowserActivity._BROWSER_ACTIVITY_TYPE) + vbox = gtk.VBox() search_box = gtk.HBox(False, 6) @@ -84,10 +93,19 @@ class StartPage(gtk.HBox): self._activities = ActivitiesView() sw.add(self._activities) self._activities.show() - - self.pack_start(sw) + + self.pack_start(sw) sw.show() + def _on_new_service_adv_cb(self, pservice, uid, stype): + if uid is not None: + real_stype = Service.compose_service_type(stype, uid) + self._pservice.track_service_type(real_stype) + + def _on_activity_announced_cb(self, pservice, service, buddy): + (activity_uid, activity_stype) = service.get_activity_uid() + print "::: %s announced activity UID %s of type %s" % (buddy.get_nick_name(), activity_uid, activity_stype) + def _search_entry_activate_cb(self, entry): self._search()