Ticket #1753: 1753.patch

File 1753.patch, 1.9 KB (added by sascha_silbe, 11 years ago)

PresenceService.get_buddy(): accept object path

  • src/sugar/presence/presenceservice.py

    From: Sascha Silbe <sascha-pgp@silbe.org>
    Subject: [PATCH] PresenceService.get_buddy(): accept object path (#1753)
    
    In addition to public keys accept DBus object paths to be used as identifier
    for get_buddy().
    This is a prerequisite for inviting legacy clients to Chat.
    
    Signed-off-by: Sascha Silbe <sascha-pgp@silbe.org>
    
    ---
     src/sugar/presence/presenceservice.py |   13 ++++++++-----
     1 files changed, 8 insertions(+), 5 deletions(-)
    
    diff --git a/src/sugar/presence/presenceservice.py b/src/sugar/presence/presenceservice.py
    index f4aa6df..d9449da 100644
    a b class PresenceService(gobject.GObject): 
    394394             error_handler=lambda e: \
    395395                    self._get_buddies_error_cb(error_handler, e))
    396396
    397     def get_buddy(self, key):
    398         """Retrieve single Buddy object for the given public key
     397    def get_buddy(self, ident):
     398        """Retrieve single Buddy object for the given public key or object path
    399399
    400         key -- buddy's public encryption key
     400        ident -- buddy's public encryption key or DBus object path
    401401
    402402        returns single Buddy object or None if the activity
    403403            is not found using GetBuddyByPublicKey on the
    404404            service
    405405        """
     406        if ident.startswith('/'):
     407            return self._new_object(ident)
     408
    406409        try:
    407             buddy_op = self._ps.GetBuddyByPublicKey(dbus.ByteArray(key))
     410            buddy_op = self._ps.GetBuddyByPublicKey(dbus.ByteArray(ident))
    408411        except dbus.exceptions.DBusException:
    409412            _logger.exception('Unable to retrieve buddy handle for %r from '
    410                 'presence service', key)
     413                'presence service', ident)
    411414            return None
    412415        return self._new_object(buddy_op)
    413416