Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/buddy.py34
-rw-r--r--src/telepathy_plugin.py2
2 files changed, 31 insertions, 5 deletions
diff --git a/src/buddy.py b/src/buddy.py
index 2e83270..c1e0c9e 100644
--- a/src/buddy.py
+++ b/src/buddy.py
@@ -27,6 +27,7 @@ except ImportError:
import gobject
import gtk
import dbus
+import dbus.proxies
import dbus.service
from dbus.gobject_service import ExportedGObject
from telepathy.constants import CONNECTION_STATUS_CONNECTED
@@ -678,7 +679,10 @@ class GenericOwner(Buddy):
# Hack so we can use this as a timeout handler
return False
- def _set_self_olpc_properties(self, tp):
+ def set_properties_before_connect(self, tp):
+ self._set_self_olpc_properties(tp, connected=False)
+
+ def _set_self_olpc_properties(self, tp, connected=True):
conn = tp.get_connection()
# FIXME: omit color/key/ip4-address if None?
@@ -693,10 +697,30 @@ class GenericOwner(Buddy):
if tp._PROTOCOL == 'salut':
del props['ip4-address']
- conn[CONN_INTERFACE_BUDDY_INFO].SetProperties(props,
- reply_handler=_noop,
- error_handler=lambda e:
- _logger.warning('Error setting OLPC properties: %s', e))
+ if connected:
+ conn[CONN_INTERFACE_BUDDY_INFO].SetProperties(props,
+ reply_handler=_noop,
+ error_handler=lambda e:
+ _logger.warning('Error setting OLPC properties: %s', e))
+ else:
+ # we don't yet know whether the connection supports setting buddy
+ # properties
+ # FIXME: remove this hack, and the import of dbus.proxies, when
+ # we have a newer tp-python that makes dbus_object public
+ try:
+ obj = conn.dbus_object
+ if not isinstance(obj, dbus.proxies.ProxyObject):
+ raise AttributeError
+ except AttributeError:
+ obj = conn._dbus_object
+
+ obj.SetProperties(props, dbus_interface=CONN_INTERFACE_BUDDY_INFO,
+ reply_handler=lambda:
+ _logger.debug('Successfully preloaded buddy props'),
+ error_handler=lambda e:
+ _logger.debug('Failed to preload buddy properties, '
+ 'will try again after Connect(): %s', e))
+
# Hack so we can use this as a timeout handler
return False
diff --git a/src/telepathy_plugin.py b/src/telepathy_plugin.py
index bbc4201..7d84536 100644
--- a/src/telepathy_plugin.py
+++ b/src/telepathy_plugin.py
@@ -196,6 +196,8 @@ class TelepathyPlugin(gobject.GObject):
self._conn = conn
status = self._conn[CONN_INTERFACE].GetStatus()
+ self._owner.set_properties_before_connect(self)
+
if status == CONNECTION_STATUS_DISCONNECTED:
def connect_reply():
_logger.debug('%r: Connect() succeeded', self)