Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2007-02-27 22:51:53 (GMT)
committer Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>2007-02-27 22:51:53 (GMT)
commit81b636c8e1c21e7cb84d593b18612c466204b7ac (patch)
treeaa883f505f9ac8ddabff282696de299f6dc50ade /services
parent152d95f3ded7a7695ac37e42bfece276b6964b80 (diff)
start of support of the org.freedesktop.Telepathy.Connection.Interface.OLPC.BuddyInfo interface
Diffstat (limited to 'services')
-rw-r--r--services/presence2/presenceservice.py11
-rw-r--r--services/presence2/server_plugin.py41
2 files changed, 34 insertions, 18 deletions
diff --git a/services/presence2/presenceservice.py b/services/presence2/presenceservice.py
index 32afcf7..9dee12f 100644
--- a/services/presence2/presenceservice.py
+++ b/services/presence2/presenceservice.py
@@ -65,6 +65,8 @@ class PresenceService(dbus.service.Object):
self._server_plugin.connect('contact-online', self._contact_online)
self._server_plugin.connect('contact-offline', self._contact_offline)
self._server_plugin.connect('avatar-updated', self._avatar_updated)
+ self._server_plugin.connect('properties-changed', self._properties_changed)
+ self._server_plugin.connect('activities-changed', self._activities_changed)
self._server_plugin.start()
# Set up the link local connection
@@ -123,6 +125,15 @@ class PresenceService(dbus.service.Object):
if buddy:
buddy.set_icon(avatar)
+ def _properties_changed(self, tp, handle, prop):
+ buddy = self._handles[tp].get(handle)
+
+ if buddy:
+ buddy.set_properties(prop)
+
+ def _activities_changed(self, tp, handle, prop):
+ pass
+
@dbus.service.signal(_PRESENCE_INTERFACE, signature="o")
def ActivityAppeared(self, activity):
pass
diff --git a/services/presence2/server_plugin.py b/services/presence2/server_plugin.py
index 0cce49c..610bcc3 100644
--- a/services/presence2/server_plugin.py
+++ b/services/presence2/server_plugin.py
@@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import gobject
+import dbus
from sugar import profile
from sugar import util
from buddyiconcache import BuddyIconCache
@@ -31,6 +32,8 @@ from telepathy.constants import (
CONNECTION_HANDLE_TYPE_LIST, CONNECTION_HANDLE_TYPE_CONTACT,
CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED)
+CONN_INTERFACE_BUDDY_INFO = 'org.laptop.Telepathy.BuddyInfo'
+
_PROTOCOL = "jabber"
class ServerPlugin(gobject.GObject):
@@ -42,6 +45,10 @@ class ServerPlugin(gobject.GObject):
'status': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
([gobject.TYPE_INT, gobject.TYPE_INT])),
'avatar-updated': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ ([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT])),
+ 'properties-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ ([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT])),
+ 'activities-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT]))
}
@@ -167,24 +174,13 @@ class ServerPlugin(gobject.GObject):
self._conn._valid_interfaces.add(CONN_INTERFACE_AVATARS)
self._conn[CONN_INTERFACE_AVATARS].connect_to_signal('AvatarUpdated', self._avatar_updated_cb)
- #if CONN_INTERFACE_AVATARS in self._conn:
- # tokens = self._conn[CONN_INTERFACE_AVATARS].RequestAvatarTokens(subscribe_handles)
-
- # #for handle, token in zip(subscribe_handles, tokens):
- # for handle in subscribe_handles:
- # avatar, mime_type = self._conn[CONN_INTERFACE_AVATARS].RequestAvatar(handle)
- # self.buddies[handle].avatar = ''.join(map(chr, avatar))
-
- # import gtk
- # window = gtk.Window()
- # window.set_title(self.buddies[handle].alias)
- # loader = gtk.gdk.PixbufLoader()
- # loader.write(self.buddies[handle].avatar)
- # loader.close()
- # image = gtk.Image()
- # image.set_from_pixbuf(loader.get_pixbuf())
- # window.add(image)
- # window.show_all()
+
+ if CONN_INTERFACE_BUDDY_INFO not in self._conn.get_valid_interfaces():
+ print 'OLPC information not available'
+ self.disconnect()
+
+ self._conn[CONN_INTERFACE_BUDDY_INFO].connect_to_signal('PropertiesChanged', self._properties_changed_cb)
+ self._conn[CONN_INTERFACE_BUDDY_INFO].connect_to_signal('ActivitiesChanged', self._activities_changed_cb)
def _status_changed_cb(self, state, reason):
gobject.idle_add(self._status_changed_cb2, state, reason)
@@ -262,3 +258,12 @@ class ServerPlugin(gobject.GObject):
self._icon_cache.store_icon(jid, new_avatar_token, icon)
self.emit("avatar-updated", handle, icon)
+
+ def set_properties(self, properties):
+ self._conn[CONN_INTERFACE_BUDDY_INFO].SetProperties(properties)
+
+ def _properties_changed_cb(self, contact, properties):
+ self.emit("properties-changed", contact, properties)
+
+ def _activities_changed_cb(self, contact, activities):
+ self.emit("activities-changed", contact, activities)