summaryrefslogtreecommitdiff
path: root/src/core.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2013-03-11 02:04:20 +0100
committermathieui <mathieui@mathieui.net>2013-03-11 02:04:20 +0100
commit71c35eb279b2271b89896dcff551ba762f66b3a5 (patch)
tree280bc7e66b453310851dcb4e9793e9f4083561eb /src/core.py
parenteb2e5825bceec1171f0e154cb72f5870576a94f2 (diff)
downloadpoezio-71c35eb279b2271b89896dcff551ba762f66b3a5.tar.gz
poezio-71c35eb279b2271b89896dcff551ba762f66b3a5.tar.bz2
poezio-71c35eb279b2271b89896dcff551ba762f66b3a5.tar.xz
poezio-71c35eb279b2271b89896dcff551ba762f66b3a5.zip
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
Diffstat (limited to 'src/core.py')
-rw-r--r--src/core.py24
1 files changed, 24 insertions, 0 deletions
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.