From 71c35eb279b2271b89896dcff551ba762f66b3a5 Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 11 Mar 2013 02:04:20 +0100 Subject: Implement XEP-0118 (Fix #1840) - Add new theming options - Show the tune in the roster (both in contact line and infowin) - add an option to show tunes as info messages --- src/core.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/core.py') diff --git a/src/core.py b/src/core.py index a37788e7..8a5408d2 100644 --- a/src/core.py +++ b/src/core.py @@ -230,6 +230,7 @@ class Core(object): self.key_func.update(key_func) # Add handlers + self.xmpp.add_event_handler("user_tune_publish", self.on_tune_event) self.xmpp.add_event_handler('connected', self.on_connected) self.xmpp.add_event_handler('disconnected', self.on_disconnected) self.xmpp.add_event_handler('no_auth', self.on_failed_auth) @@ -2598,6 +2599,29 @@ class Core(object): else: self.refresh_window() + def on_tune_event(self, message): + contact = roster[message['from'].bare] + if not contact: + return + item = message['pubsub_event']['items']['item'] + if item.find('{http://jabber.org/protocol/tune}tune'): + item = item['tune'] + contact.tune = { + 'artist': item['artist'], + 'length': item['length'], + 'rating': item['rating'], + 'source': item['source'], + 'title': item['title'], + 'track': item['track'], + 'uri': item['uri'] + } + else: + contact.tune = {} + if config.get('display_tune_notifications', 'false') == 'true' and contact.tune: + self.information( + 'Tune from '+ message['from'].bare + ': ' + common.format_tune_string(contact.tune), + 'Tune') + def on_groupchat_message(self, message): """ Triggered whenever a message is received from a multi-user chat room. -- cgit v1.2.3