Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/presence/PresenceService.py
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2006-06-16 20:32:56 (GMT)
committer Dan Williams <dcbw@redhat.com>2006-06-16 20:32:56 (GMT)
commit563810ec56860ecb3b4927a53db9cdf926b27032 (patch)
treea19c31e577d5aba4e76c6e2bc3075e74b4d9b131 /sugar/presence/PresenceService.py
parente4a8518d02c39562283a1152c0a3d484d3a990fc (diff)
Add hooks for filtering on specific application UIDs
Diffstat (limited to 'sugar/presence/PresenceService.py')
-rw-r--r--sugar/presence/PresenceService.py34
1 files changed, 30 insertions, 4 deletions
diff --git a/sugar/presence/PresenceService.py b/sugar/presence/PresenceService.py
index ec30db4..bb6f755 100644
--- a/sugar/presence/PresenceService.py
+++ b/sugar/presence/PresenceService.py
@@ -395,6 +395,25 @@ class PresenceService(gobject.GObject):
def _new_domain_cb_glue(self, interface, protocol, domain, flags=0):
gobject.idle_add(self._new_domain_cb, interface, protocol, domain, flags)
+ def track_activity(self, activity_uid):
+ """INTERNAL ONLY; register an activity's UID to recognize service
+ events for that specific activity."""
+ if not activity_uid or not util.validate_activity_uid(uid):
+ raise ValueError("activity uid must be a valid activity uid string.")
+ if activity_uid in self._allowed_activities:
+ return
+ self._allowed_activities.append(activity_uid)
+ self._check_and_resolve_service_advs(dec_stype)
+
+ def untrack_activity(self, activity_uid):
+ """INTERNAL ONLY; unregister an activity's UID to stop service
+ events for that specific activity."""
+ if not activity_uid or not util.validate_activity_uid(uid):
+ raise ValueError("activity uid must be a valid activity uid string.")
+ if activity_uid not in self._allowed_activities:
+ return
+ self._allowed_activities.remove(activity_uid)
+
def track_service_type(self, short_stype):
"""Requests that the Presence service look for and recognize
a certain mDNS service types."""
@@ -414,17 +433,24 @@ class PresenceService(gobject.GObject):
if uid:
raise RuntimeError("Can only track plain service types!")
self._allowed_service_types.append(dec_stype)
+ self._check_and_resolve_service_advs(dec_stype)
+ def _check_and_resolve_service_advs(self, specific_stype=None):
# Find unresolved services that match the service type
# we're now interested in, and resolve them
resolv_list = []
# Find all services first by their activity
+ search_types = self._allowed_service_types
+ if specific_stype:
+ search_types = [specific_stype]
for uid in self._allowed_activities:
- full_stype = Service.compose_service_type(dec_stype, uid)
- adv_list = self._find_service_adv(stype=full_stype)
- resolv_list = resolv_list + adv_list
+ for short_stype in search_stypes:
+ full_stype = Service.compose_service_type(short_stype, uid)
+ adv_list = self._find_service_adv(stype=full_stype)
+ resolv_list = resolv_list + adv_list
# Then, find services by just the plain service type
- resolv_list = resolv_list + self._find_service_adv(stype=dec_stype)
+ if specific_stype is not None:
+ resolv_list = resolv_list + self._find_service_adv(stype=specific_stype)
# Request resolution for them
for adv in resolv_list: