Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/services/presence/presenceservice.py
diff options
context:
space:
mode:
Diffstat (limited to 'services/presence/presenceservice.py')
-rw-r--r--services/presence/presenceservice.py41
1 files changed, 32 insertions, 9 deletions
diff --git a/services/presence/presenceservice.py b/services/presence/presenceservice.py
index d71a3d2..1312fec 100644
--- a/services/presence/presenceservice.py
+++ b/services/presence/presenceservice.py
@@ -40,24 +40,36 @@ class NotFoundError(dbus.DBusException):
dbus.DBusException.__init__(self)
self._dbus_error_name = _PRESENCE_INTERFACE + '.NotFound'
+class DBusGObjectMetaclass(dbus.service.InterfaceType, gobject.GObjectMeta): pass
+class DBusGObject(dbus.service.Object, gobject.GObject): __metaclass__ = DBusGObjectMetaclass
+
+class PresenceService(DBusGObject):
+ __gtype_name__ = "PresenceService"
+
+ __gsignals__ = {
+ 'connection-status': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ ([gobject.TYPE_BOOLEAN]))
+ }
-class PresenceService(dbus.service.Object):
def __init__(self, test=0):
self._next_object_id = 0
+ self._connected = False
self._buddies = {} # key -> Buddy
self._handles_buddies = {} # tp client -> (handle -> Buddy)
self._activities = {} # activity id -> Activity
+ gobject.GObject.__init__(self)
+
bus = dbus.SessionBus()
self._bus_name = dbus.service.BusName(_PRESENCE_SERVICE, bus=bus)
# Create the Owner object
objid = self._get_next_object_id()
if test > 0:
- self._owner = TestOwner(self._bus_name, objid, test)
+ self._owner = TestOwner(self, self._bus_name, objid, test)
else:
- self._owner = ShellOwner(self._bus_name, objid)
+ self._owner = ShellOwner(self, self._bus_name, objid)
self._buddies[self._owner.props.key] = self._owner
self._registry = ManagerRegistry()
@@ -92,8 +104,15 @@ class PresenceService(dbus.service.Object):
async_err_cb(exc)
def _server_status_cb(self, plugin, status, reason):
+ # FIXME: figure out connection status when we have a salut plugin too
+ old_status = self._connected
if status == CONNECTION_STATUS_CONNECTED:
- pass
+ self._connected = True
+ else:
+ self._connected = False
+
+ if self._connected != old_status:
+ self.emit('connection-status', self._connected)
def _contact_online(self, tp, handle, props):
new_buddy = False
@@ -260,11 +279,10 @@ class PresenceService(dbus.service.Object):
@dbus.service.method(_PRESENCE_INTERFACE, in_signature="s", out_signature="o")
def GetActivityById(self, actid):
- if self._activities.has_key(actid):
- act = self._activities[actid]
- if act.props.valid:
- return act.object_path()
- raise NotFoundError("The activity was not found.")
+ act = self.internal_get_activity(actid)
+ if not act or not act.props.valid:
+ raise NotFoundError("The activity was not found.")
+ return act.object_path()
@dbus.service.method(_PRESENCE_INTERFACE, out_signature="ao")
def GetBuddies(self):
@@ -333,6 +351,11 @@ class PresenceService(dbus.service.Object):
if activity:
activity.set_properties(props)
+ def internal_get_activity(self, actid):
+ if not self._activities.has_key(actid):
+ return None
+ return self._activities[actid]
+
def main(test=False):
loop = gobject.MainLoop()