Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/presence
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-04-23 16:06:41 (GMT)
committer Dan Williams <dcbw@redhat.com>2007-04-23 16:06:41 (GMT)
commit4ca4e5564ec2a010707865c8811a5415ff6943e1 (patch)
treee4cc268a94fefe1545116245314cd68fa67a2f54 /sugar/presence
parent6513fef6b2618de861531e350700f05b9d0fcfe2 (diff)
Add test code for Sugar PresenceService bindings
Diffstat (limited to 'sugar/presence')
-rw-r--r--sugar/presence/presenceservice.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/sugar/presence/presenceservice.py b/sugar/presence/presenceservice.py
index 13684a5..ce5fbc5 100644
--- a/sugar/presence/presenceservice.py
+++ b/sugar/presence/presenceservice.py
@@ -66,16 +66,17 @@ class PresenceService(gobject.GObject):
_PS_ACTIVITY_OP = DBUS_PATH + "/Activities/"
- def __init__(self):
+ def __init__(self, allow_offline_iface=True):
"""Initialise the service and attempt to connect to events
"""
gobject.GObject.__init__(self)
self._objcache = {}
# attempt to load the interface to the service...
+ self._allow_offline_iface = allow_offline_iface
self._get_ps()
_bus_ = None
- def _get_bus( self ):
+ def _get_bus(self):
"""Retrieve dbus session-bus or create new"""
if not self._bus_:
self._bus_ = dbus.SessionBus()
@@ -85,7 +86,7 @@ class PresenceService(gobject.GObject):
"""DBUS SessionBus object for user-local communications"""
)
_ps_ = None
- def _get_ps( self ):
+ def _get_ps(self):
"""Retrieve dbus interface to PresenceService
Also registers for updates from various dbus events on the
@@ -110,7 +111,9 @@ class PresenceService(gobject.GObject):
"""Failure retrieving %r interface from the D-BUS service %r %r: %s""",
DBUS_INTERFACE, DBUS_SERVICE, DBUS_PATH, err
)
- return _OfflineInterface()
+ if self._allow_offline_iface:
+ return _OfflineInterface()
+ raise RuntimeError("Failed to connect to the presence service.")
else:
self._ps_ = ps
ps.connect_to_signal('BuddyAppeared', self._buddy_appeared_cb)