Revert "services/presence/: move more of the handle tracking into the Buddy object".
It shouldn't have been applied before "services/presence: buddy: add mapping
to/from Telepathy handles" which has not yet been reviewed.
This reverts commit 78356b1956
.
Conflicts:
services/presence/presenceservice.py
This commit is contained in:
parent
677eb1629c
commit
494e17b3cd
@ -80,9 +80,7 @@ class Buddy(ExportedGObject):
|
||||
'property-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
([gobject.TYPE_PYOBJECT])),
|
||||
'icon-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
([gobject.TYPE_PYOBJECT])),
|
||||
'disappeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
([])),
|
||||
([gobject.TYPE_PYOBJECT]))
|
||||
}
|
||||
|
||||
__gproperties__ = {
|
||||
@ -238,12 +236,6 @@ class Buddy(ExportedGObject):
|
||||
full set of properties, just the changes.
|
||||
"""
|
||||
|
||||
def add_telepathy_handle(self, tp_client, handle):
|
||||
"""Add a Telepathy handle."""
|
||||
conn = tp_client.get_connection()
|
||||
self.TelepathyHandleAdded(conn.service_name, conn.object_path, handle)
|
||||
self.handles[tp_client] = handle
|
||||
|
||||
@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.
|
||||
@ -258,21 +250,6 @@ class Buddy(ExportedGObject):
|
||||
newly associated with the buddy
|
||||
"""
|
||||
|
||||
def remove_telepathy_handle(self, tp_client, handle):
|
||||
"""Remove a Telepathy handle."""
|
||||
conn = tp_client.get_connection()
|
||||
my_handle = self.handles.get(tp_client, 0)
|
||||
if my_handle == handle:
|
||||
del self.handles[tp_client]
|
||||
self.TelepathyHandleRemoved(conn.service_name, conn.object_path,
|
||||
handle)
|
||||
if not self.handles:
|
||||
self.emit('disappeared')
|
||||
else:
|
||||
_logger.debug('Telepathy handle %u supposedly removed, but '
|
||||
'my handle on that connection is %u - ignoring',
|
||||
handle, my_handle)
|
||||
|
||||
@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,
|
||||
|
@ -126,12 +126,12 @@ class PresenceService(ExportedGObject):
|
||||
objid = self._get_next_object_id()
|
||||
buddy = Buddy(self._bus_name, objid, key=key)
|
||||
buddy.connect("validity-changed", self._buddy_validity_changed_cb)
|
||||
buddy.connect("disappeared", self._buddy_disappeared_cb)
|
||||
self._buddies[key] = buddy
|
||||
|
||||
self._handles_buddies[tp][handle] = buddy
|
||||
buddies = self._handles_buddies[tp]
|
||||
buddies[handle] = buddy
|
||||
# store the handle of the buddy for this CM
|
||||
buddy.add_telepathy_handle(tp, handle)
|
||||
buddy.handles[tp] = handle
|
||||
|
||||
buddy.set_properties(props)
|
||||
|
||||
@ -143,12 +143,6 @@ class PresenceService(ExportedGObject):
|
||||
self.BuddyDisappeared(buddy.object_path())
|
||||
_logger.debug("Buddy left: %s (%s)" % (buddy.props.nick, buddy.props.color))
|
||||
|
||||
def _buddy_disappeared_cb(self, buddy):
|
||||
if buddy.props.valid:
|
||||
self.BuddyDisappeared(buddy.object_path())
|
||||
_logger.debug('Buddy left: %s (%s)' % (buddy.props.nick, buddy.props.color))
|
||||
self._buddies.pop(buddy.props.key)
|
||||
|
||||
def _contact_offline(self, tp, handle):
|
||||
if not self._handles_buddies[tp].has_key(handle):
|
||||
return
|
||||
@ -157,7 +151,12 @@ class PresenceService(ExportedGObject):
|
||||
key = buddy.props.key
|
||||
|
||||
# the handle of the buddy for this CM is not valid anymore
|
||||
buddy.remove_telepathy_handle(tp, handle)
|
||||
buddy.handles.pop(tp)
|
||||
if not buddy.handles:
|
||||
if buddy.props.valid:
|
||||
self.BuddyDisappeared(buddy.object_path())
|
||||
_logger.debug("Buddy left: %s (%s)" % (buddy.props.nick, buddy.props.color))
|
||||
self._buddies.pop(key)
|
||||
|
||||
def _get_next_object_id(self):
|
||||
"""Increment and return the object ID counter."""
|
||||
@ -305,42 +304,6 @@ class PresenceService(ExportedGObject):
|
||||
return buddy.object_path()
|
||||
raise NotFoundError("The buddy was not found.")
|
||||
|
||||
@dbus.service.method(_PRESENCE_INTERFACE, in_signature='sou',
|
||||
out_signature='o')
|
||||
def GetBuddyByTelepathyHandle(self, tp_conn_name, tp_conn_path, handle):
|
||||
"""Get the buddy corresponding to a Telepathy handle.
|
||||
|
||||
: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 object path of a Buddy
|
||||
:Raises NotFoundError: if the buddy is not found.
|
||||
"""
|
||||
for tp, handles in self._handles_buddies.iteritems():
|
||||
conn = tp.get_connection()
|
||||
if conn is None:
|
||||
continue
|
||||
if (conn.service_name == tp_conn_name
|
||||
and conn.object_path == tp_conn_path):
|
||||
buddy = handles.get(handle)
|
||||
if buddy is not None and buddy.props.valid:
|
||||
return buddy.object_path()
|
||||
# either the handle is invalid, or we don't have a Buddy
|
||||
# object for that buddy because we don't have all their
|
||||
# details yet
|
||||
raise NotFoundError("The buddy %u was not found on the "
|
||||
"connection to %s:%s"
|
||||
% (handle, tp_conn_name, tp_conn_path))
|
||||
raise NotFoundError("The buddy %u was not found: we have no "
|
||||
"connection to %s:%s" % (handle, tp_conn_name,
|
||||
tp_conn_path))
|
||||
|
||||
@dbus.service.method(_PRESENCE_INTERFACE, out_signature="o")
|
||||
def GetOwner(self):
|
||||
if not self._owner:
|
||||
|
Loading…
Reference in New Issue
Block a user