diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 2d853c84e3c8e336b32bb69bc5c4682fd5769fa5..f6f73a8b81ccb57d9d039a75c5a5f74dd682464a 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 <message/> 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 00eb39afff6d563004c6f0ed93efa6fe07f8f5a0..c4ee908f77453132f152049a2c203ff9bc17de74 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 49194e0f56a4c74826ffa1e89312a40e7517f16f..75b07dfbfa41ef37955df1ff313ab767dac295bc 100644 --- a/src/tooltips.py +++ b/src/tooltips.py @@ -478,6 +478,13 @@ class RosterTooltip(NotificationAreaTooltip): show = '<i>' + show + '</i>' # we append show below + if contact.mood: + mood = contact.mood.strip() + mood_text = contact.mood_text.strip() + if mood: + #print mood + properties.append(('<b>%s:</b> %s' % (mood, mood_text), None)) + if contact.status: status = contact.status.strip() if status: