From 5f9eab3c62ff2a073372efe27a426699994771bb Mon Sep 17 00:00:00 2001 From: Piotr Gaczkowski Date: Sun, 25 Mar 2007 22:16:48 +0000 Subject: [PATCH] First buggy commit --- src/common/connection_handlers.py | 12 +++++++++ src/common/pubsub.py | 43 +++++++++++++++++++++++++++++++ src/tooltips.py | 7 +++++ 3 files changed, 62 insertions(+) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 2d853c84e..f6f73a8b8 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -34,6 +34,7 @@ from common import GnuPG from common import helpers from common import gajim from common import atom +from common import pep from common.commands import ConnectionCommands from common.pubsub import ConnectionPubSub @@ -1504,8 +1505,19 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, ''' Called when we receive with pubsub event. ''' # TODO: Logging? (actually services where logging would be useful, should # TODO: allow to access archives remotely...) + jid = msg.getAttr('from') event = msg.getTag('event') + # XEP-0107: User Mood + items = event.getTag('items', {'node': 'http://jabber.org/protocol/mood'}) + if items: pep.user_mood(items, self.name, jid) + # XEP-0118: User Tune + items = event.getTag('items', {'node': 'http://jabber.org/protocol/tune'}) + if items: pep.user_tune(items, self.name, jid) + # XEP-0080: User Geolocation + items = event.getTag('items', {'node': 'http://jabber.org/protocol/geoloc'}) + if items: pep.user_geoloc(items, self.name, jid) + items = event.getTag('items') if items is None: return diff --git a/src/common/pubsub.py b/src/common/pubsub.py index 00eb39aff..c4ee908f7 100644 --- a/src/common/pubsub.py +++ b/src/common/pubsub.py @@ -43,6 +43,49 @@ class ConnectionPubSub: self.connection.send(query) + def send_pb_delete(self, jid, node): + '''Deletes node.''' + query = xmpp.Iq('set', to=jid) + d = query.addChild('pubsub', namespace=xmpp.NS_PUBSUB) + d = d.addChild('delete', {'node': node}) + + self.connection.send(query) + + def send_pb_create(self, jid, node, configure = False, configure_form = None): + '''Creates new node.''' + query = xmpp.Iq('set', to=jid) + c = query.addChild('pubsub', namespace=xmpp.NS_PUBSUB) + c = c.addChild('create', {'node': node}) + if configure: + conf = c.addChild('configure') + if configure_form is not None: + conf.addChild(node=configuration_form) + + self.connection.send(query) + + def send_pb_configure(self, jid, node, cb, *cbargs, **cbkwargs): + query = xmpp.Iq('set', to=jid) + c = query.addChild('pubsub', namespace=xmpp.NS_PUBSUB) + c = c.addChild('configure', {'node': node}) + + id = self.connection.send(query) + + def on_configure(self, connection, query): + try: + filledform = cb(stanza['pubsub']['configure']['x'], *cbargs, **cbkwargs) + #TODO: Build a form + #TODO: Send it + + except CancelConfigure: + cancel = xmpp.Iq('set', to=jid) + ca = query.addChild('pubsub', namespace=xmpp.NS_PUBSUB) + ca = ca.addChild('configure', {'node': node}) + #ca = ca.addChild('x', namespace=xmpp.NS_DATA, {'type': 'cancel'}) + + self.connection.send(cancel) + + self.__callbacks[id] = (on_configure, (), {}) + def _PubSubCB(self, conn, stanza): try: cb, args, kwargs = self.__callbacks.pop(stanza.getID()) diff --git a/src/tooltips.py b/src/tooltips.py index 49194e0f5..75b07dfbf 100644 --- a/src/tooltips.py +++ b/src/tooltips.py @@ -478,6 +478,13 @@ class RosterTooltip(NotificationAreaTooltip): show = '' + show + '' # we append show below + if contact.mood: + mood = contact.mood.strip() + mood_text = contact.mood_text.strip() + if mood: + #print mood + properties.append(('%s: %s' % (mood, mood_text), None)) + if contact.status: status = contact.status.strip() if status: