Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2007-06-15 14:42:13 (GMT)
committer Simon McVittie <simon.mcvittie@collabora.co.uk>2007-06-15 14:42:13 (GMT)
commit11117fc2677c4c2ddbdbd150ca5be9e9d209eb20 (patch)
tree9c8fc1a1ffdd8c3db22ebfa01f3388d45c93e203
parent9916a4c6b3e1b9d189879902d5911217ad98f7fa (diff)
Try to set owner properties before connection - newer versions of Gabble and Salut allow this, and it avoids a race condition in the Salut case
-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)