Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2007-05-24 15:54:15 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2007-05-24 15:54:15 (GMT)
commit9786385baa523e074584f825e9a5127f1dc23f8f (patch)
treebc2de593e129ebe3fdf574ea9f98b27036876689 /sugar
parent98c5c0734ecfbf3e996b80bbe0b615e63b94295a (diff)
parent494e17b3cd03aa43a5d170d42e4463428a000272 (diff)
Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
Diffstat (limited to 'sugar')
-rw-r--r--sugar/presence/presenceservice.py45
1 files changed, 33 insertions, 12 deletions
diff --git a/sugar/presence/presenceservice.py b/sugar/presence/presenceservice.py
index 1bc9a57..a0b60ee 100644
--- a/sugar/presence/presenceservice.py
+++ b/sugar/presence/presenceservice.py
@@ -16,20 +16,15 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
-import dbus, dbus.glib, gobject
import logging
-# XXX use absolute imports
-# from sugar.presence import buddy, activity
-# this *kind* of relative import is deprecated
-# with an explicit relative import slated to be
-# introduced (available in Python 2.5 with a __future__
-# import), that would read as:
-# from . import buddy, activity
-# see PEP: http://docs.python.org/whatsnew/pep-328.html
+import dbus
+import dbus.exceptions
+import dbus.glib
+import gobject
-import buddy
-from activity import Activity
+from sugar.presence.buddy import Buddy
+from sugar.presence.activity import Activity
DBUS_SERVICE = "org.laptop.Sugar.Presence"
@@ -159,7 +154,7 @@ class PresenceService(gobject.GObject):
obj = self._objcache[object_path]
except KeyError:
if object_path.startswith(self._PS_BUDDY_OP):
- obj = buddy.Buddy(self._bus, self._new_object,
+ obj = Buddy(self._bus, self._new_object,
self._del_object, object_path)
elif object_path.startswith(self._PS_ACTIVITY_OP):
obj = Activity(self._bus, self._new_object,
@@ -317,6 +312,32 @@ class PresenceService(gobject.GObject):
return None
return self._new_object(buddy_op)
+ def get_buddy_by_telepathy_handle(self, tp_conn_name, tp_conn_path,
+ handle):
+ """Retrieve single Buddy object for the given public key
+
+ :Parameters:
+ `tp_conn_name` : str
+ The well-known bus name of a Telepathy connection
+ `tp_conn_path` : dbus.ObjectPath
+ The object path of the Telepathy connection
+ `handle` : int or long
+ The handle of a Telepathy contact on that connection,
+ of type HANDLE_TYPE_CONTACT. This may not be a
+ channel-specific handle.
+ :Returns: the Buddy object, or None if the buddy is not found
+ """
+ try:
+ buddy_op = self._ps.GetBuddyByTelepathyHandle(tp_conn_name,
+ tp_conn_path,
+ handle)
+ except dbus.exceptions.DBusException, err:
+ _logger.warn('Unable to retrieve buddy handle for handle %u at '
+ 'conn %s:%s from presence service: %s',
+ handle, tp_conn_name, tp_conn_path, err)
+ return None
+ return self._new_object(buddy_op)
+
def get_owner(self):
"""Retrieves the laptop "owner" Buddy object."""
try: