From 257d70a3772be3bcead638572e9a07c8e2d3190c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 05 Jul 2007 15:11:11 +0000 Subject: buddy, activity: cope with missing interfaces gracefully --- diff --git a/src/activity.py b/src/activity.py index 47fcd76..cc3cf7c 100644 --- a/src/activity.py +++ b/src/activity.py @@ -179,6 +179,11 @@ class Activity(ExportedGObject): assert self._room, self._room conn = self._tp.get_connection() + if CONN_INTERFACE_ACTIVITY_PROPERTIES not in conn: + # we should already have warned about this somewhere - + # certainly, don't emit a warning per activity! + return + def got_properties_err(e): _logger.warning('Failed to get initial activity properties ' 'for %s: %s', self._id, e) @@ -756,6 +761,10 @@ class Activity(ExportedGObject): conn = self._tp.get_connection() + if CONN_INTERFACE_ACTIVITY_PROPERTIES not in conn: + # we should already have warned about this somewhere + return + def properties_set(e=None): if e is None: _logger.debug('Successfully set activity properties for %s', diff --git a/src/buddy.py b/src/buddy.py index c1e0c9e..1ec05ff 100644 --- a/src/buddy.py +++ b/src/buddy.py @@ -563,6 +563,9 @@ class Buddy(ExportedGObject): conn = tp.get_connection() handle, identifier = self._handles[tp] + if CONN_INTERFACE_AVATARS not in conn: + return + if icon is None: icon = buddy_icon_cache.get_icon(conn.object_path, identifier, new_avatar_token) @@ -636,6 +639,12 @@ class GenericOwner(Buddy): uses SetActivities on BuddyInfo channel """ conn = tp.get_connection() + + if CONN_INTERFACE_BUDDY_INFO not in conn: + _logger.warning('%s does not support BuddyInfo - unable to ' + 'set activities') + return + conn[CONN_INTERFACE_BUDDY_INFO].SetActivities( self._activities_by_connection[tp].iteritems(), reply_handler=_noop, @@ -663,6 +672,12 @@ class GenericOwner(Buddy): _logger.debug("Setting current activity to '%s' (handle %s)", cur_activity, cur_activity_handle) conn = tp.get_connection() + + if CONN_INTERFACE_BUDDY_INFO not in conn: + _logger.warning('%s does not support BuddyInfo - unable to ' + 'set current activity') + return + conn[CONN_INTERFACE_BUDDY_INFO].SetCurrentActivity(cur_activity, cur_activity_handle, reply_handler=_noop, @@ -672,6 +687,12 @@ class GenericOwner(Buddy): def _set_self_alias(self, tp): self_handle = self._handles[tp][0] conn = tp.get_connection() + + if CONN_INTERFACE_ALIASING not in conn: + _logger.warning('%s does not support aliasing - unable to ' + 'set my own alias') + return False + conn[CONN_INTERFACE_ALIASING].SetAliases({self_handle: self._nick}, reply_handler=_noop, error_handler=lambda e: @@ -698,6 +719,11 @@ class GenericOwner(Buddy): del props['ip4-address'] if connected: + if CONN_INTERFACE_BUDDY_INFO not in conn: + _logger.warning('%s does not support BuddyInfo - unable to ' + 'set my own buddy properties') + return False + conn[CONN_INTERFACE_BUDDY_INFO].SetProperties(props, reply_handler=_noop, error_handler=lambda e: @@ -749,6 +775,11 @@ class GenericOwner(Buddy): conn = tp.get_connection() icon_data = self._icon + if CONN_INTERFACE_AVATARS not in conn: + _logger.warning('%s does not support Avatars - unable to ' + 'set my own avatar on this connection') + return + m = new_md5() m.update(icon_data) digest = m.hexdigest() -- cgit v0.9.1