Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
This commit is contained in:
commit
9786385baa
@ -236,6 +236,28 @@ class Buddy(ExportedGObject):
|
||||
full set of properties, just the changes.
|
||||
"""
|
||||
|
||||
@dbus.service.signal(_BUDDY_INTERFACE, signature='sou')
|
||||
def TelepathyHandleAdded(self, tp_conn_name, tp_conn_path, handle):
|
||||
"""Another Telepathy handle has become associated with the buddy.
|
||||
|
||||
This must only be emitted for non-channel-specific handles.
|
||||
|
||||
tp_conn_name -- The bus name at which the Telepathy connection may be
|
||||
found
|
||||
tp_conn_path -- The object path at which the Telepathy connection may
|
||||
be found
|
||||
handle -- The handle of type CONTACT, which is not channel-specific,
|
||||
newly associated with the buddy
|
||||
"""
|
||||
|
||||
@dbus.service.signal(_BUDDY_INTERFACE, signature='sou')
|
||||
def TelepathyHandleRemoved(self, tp_conn_name, tp_conn_path, handle):
|
||||
"""A Telepathy handle has ceased to be associated with the buddy,
|
||||
probably because that contact went offline.
|
||||
|
||||
The parameters are the same as for TelepathyHandleAdded.
|
||||
"""
|
||||
|
||||
# dbus methods
|
||||
@dbus.service.method(_BUDDY_INTERFACE,
|
||||
in_signature="", out_signature="ay")
|
||||
@ -294,6 +316,22 @@ class Buddy(ExportedGObject):
|
||||
props[_PROP_CURACT] = ""
|
||||
return props
|
||||
|
||||
@dbus.service.method(_BUDDY_INTERFACE,
|
||||
in_signature='', out_signature='a(sou)')
|
||||
def GetTelepathyHandles(self):
|
||||
"""Return a list of non-channel-specific Telepathy contact handles
|
||||
associated with this Buddy.
|
||||
|
||||
:Returns:
|
||||
An array of triples (connection well-known bus name, connection
|
||||
object path, handle).
|
||||
"""
|
||||
ret = []
|
||||
for plugin in self.handles:
|
||||
conn = plugin.get_connection()
|
||||
ret.append((str(conn.service_name), conn.object_path,
|
||||
self.handles[plugin]))
|
||||
|
||||
# methods
|
||||
def object_path(self):
|
||||
"""Retrieve our dbus.ObjectPath object"""
|
||||
|
@ -125,6 +125,7 @@ class ServerPlugin(gobject.GObject):
|
||||
"""
|
||||
gobject.GObject.__init__(self)
|
||||
|
||||
self._conn = None
|
||||
self._icon_cache = BuddyIconCache()
|
||||
|
||||
self._registry = registry
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user