Better Tune support
This commit is contained in:
parent
947ec8e933
commit
55a7061ea3
3
TODO.pep
3
TODO.pep
|
@ -1,11 +1,8 @@
|
||||||
• configure access model when changing it in the combobox
|
• configure access model when changing it in the combobox
|
||||||
• configure tab in preferences for PEP
|
|
||||||
• PEP in status change
|
• PEP in status change
|
||||||
|
|
||||||
Tune use cases:
|
Tune use cases:
|
||||||
• on connection of an account set Tune to current track
|
|
||||||
• on disconnection of an account set Tune to None
|
• on disconnection of an account set Tune to None
|
||||||
• on change of a track set Tune to a new value
|
|
||||||
|
|
||||||
Tooltips use cases:
|
Tooltips use cases:
|
||||||
• Show PEP in contact tooltips
|
• Show PEP in contact tooltips
|
||||||
|
|
|
@ -50,11 +50,6 @@ log = logging.getLogger('gajim.c.connection')
|
||||||
|
|
||||||
import gtkgui_helpers
|
import gtkgui_helpers
|
||||||
|
|
||||||
from common import dbus_support
|
|
||||||
if dbus_support.supported:
|
|
||||||
from music_track_listener import MusicTrackListener
|
|
||||||
import dbus
|
|
||||||
|
|
||||||
ssl_error = {
|
ssl_error = {
|
||||||
2: "Unable to get issuer certificate",
|
2: "Unable to get issuer certificate",
|
||||||
3: "Unable to get certificate CRL",
|
3: "Unable to get certificate CRL",
|
||||||
|
@ -532,11 +527,6 @@ class Connection(ConnectionHandlers):
|
||||||
if self.on_connect_auth:
|
if self.on_connect_auth:
|
||||||
self.on_connect_auth(con)
|
self.on_connect_auth(con)
|
||||||
self.on_connect_auth = None
|
self.on_connect_auth = None
|
||||||
#FIXME: should set the Tune per account only
|
|
||||||
listener = MusicTrackListener.get()
|
|
||||||
track = listener.get_playing_track()
|
|
||||||
gajim.interface.roster._music_track_changed(listener, track)
|
|
||||||
# print "%s - %s" % (track.artist, track.title)
|
|
||||||
else:
|
else:
|
||||||
# Forget password if needed
|
# Forget password if needed
|
||||||
if not gajim.config.get_per('accounts', self.name, 'savepass'):
|
if not gajim.config.get_per('accounts', self.name, 'savepass'):
|
||||||
|
|
|
@ -40,6 +40,11 @@ from common.commands import ConnectionCommands
|
||||||
from common.pubsub import ConnectionPubSub
|
from common.pubsub import ConnectionPubSub
|
||||||
from common.caps import ConnectionCaps
|
from common.caps import ConnectionCaps
|
||||||
|
|
||||||
|
from common import dbus_support
|
||||||
|
if dbus_support.supported:
|
||||||
|
import dbus
|
||||||
|
from music_track_listener import MusicTrackListener
|
||||||
|
|
||||||
STATUS_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd',
|
STATUS_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd',
|
||||||
'invisible', 'error']
|
'invisible', 'error']
|
||||||
# kind of events we can wait for an answer
|
# kind of events we can wait for an answer
|
||||||
|
@ -816,6 +821,11 @@ class ConnectionDisco:
|
||||||
if identity['category'] == 'pubsub' and identity['type'] == \
|
if identity['category'] == 'pubsub' and identity['type'] == \
|
||||||
'pep':
|
'pep':
|
||||||
self.pep_supported = True
|
self.pep_supported = True
|
||||||
|
listener = MusicTrackListener.get()
|
||||||
|
track = listener.get_playing_track()
|
||||||
|
if gajim.config.get('publish_tune'):
|
||||||
|
gajim.interface.roster._music_track_changed(listener,
|
||||||
|
track, self.name)
|
||||||
break
|
break
|
||||||
if features.__contains__(common.xmpp.NS_BYTESTREAM):
|
if features.__contains__(common.xmpp.NS_BYTESTREAM):
|
||||||
gajim.proxy65_manager.resolve(jid, self.connection, self.name)
|
gajim.proxy65_manager.resolve(jid, self.connection, self.name)
|
||||||
|
|
|
@ -101,8 +101,11 @@ def user_send_activity(account, activity, subactivity = '', message = ''):
|
||||||
gajim.connections[account].send_pb_publish('', xmpp.NS_ACTIVITY, item, '0')
|
gajim.connections[account].send_pb_publish('', xmpp.NS_ACTIVITY, item, '0')
|
||||||
|
|
||||||
def user_send_tune(account, artist = '', title = '', source = '', track = 0,length = 0, items = None):
|
def user_send_tune(account, artist = '', title = '', source = '', track = 0,length = 0, items = None):
|
||||||
if gajim.config.get('publish_tune') == False:
|
print "Tune to be created"
|
||||||
|
if (gajim.config.get('publish_tune') == False) or \
|
||||||
|
(gajim.connections[account].pep_supported == False):
|
||||||
return
|
return
|
||||||
|
print "publish_tune == True and pep_supported"
|
||||||
item = xmpp.Node('tune', {'xmlns': xmpp.NS_TUNE})
|
item = xmpp.Node('tune', {'xmlns': xmpp.NS_TUNE})
|
||||||
if artist != '':
|
if artist != '':
|
||||||
i = item.addChild('artist')
|
i = item.addChild('artist')
|
||||||
|
@ -123,3 +126,4 @@ def user_send_tune(account, artist = '', title = '', source = '', track = 0,leng
|
||||||
item.addChild(payload=items)
|
item.addChild(payload=items)
|
||||||
|
|
||||||
gajim.connections[account].send_pb_publish('', xmpp.NS_TUNE, item, '0')
|
gajim.connections[account].send_pb_publish('', xmpp.NS_TUNE, item, '0')
|
||||||
|
print "Tune published"
|
||||||
|
|
|
@ -3623,14 +3623,14 @@ class RosterWindow:
|
||||||
listener = MusicTrackListener.get()
|
listener = MusicTrackListener.get()
|
||||||
self._music_track_changed_signal = listener.connect(
|
self._music_track_changed_signal = listener.connect(
|
||||||
'music-track-changed', self._music_track_changed)
|
'music-track-changed', self._music_track_changed)
|
||||||
track = listener.get_playing_track()
|
track = listener.get_playing_track()
|
||||||
self._music_track_changed(listener, track)
|
self._music_track_changed(listener, track)
|
||||||
else:
|
else:
|
||||||
if self._music_track_changed_signal is not None:
|
if self._music_track_changed_signal is not None:
|
||||||
listener = MusicTrackListener.get()
|
listener = MusicTrackListener.get()
|
||||||
listener.disconnect(self._music_track_changed_signal)
|
listener.disconnect(self._music_track_changed_signal)
|
||||||
self._music_track_changed_signal = None
|
self._music_track_changed_signal = None
|
||||||
self._music_track_changed(None, None)
|
self._music_track_changed(None, None)
|
||||||
|
|
||||||
def _change_awn_icon_status(self, status):
|
def _change_awn_icon_status(self, status):
|
||||||
if not dbus_support.supported:
|
if not dbus_support.supported:
|
||||||
|
@ -3658,9 +3658,11 @@ class RosterWindow:
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _music_track_changed(self, unused_listener, music_track_info):
|
def _music_track_changed(self, unused_listener, music_track_info,
|
||||||
|
account=''):
|
||||||
from common import pep
|
from common import pep
|
||||||
accounts = gajim.connections.keys()
|
if account == '':
|
||||||
|
accounts = gajim.connections.keys()
|
||||||
if music_track_info is None:
|
if music_track_info is None:
|
||||||
artist = ''
|
artist = ''
|
||||||
title = ''
|
title = ''
|
||||||
|
@ -3681,14 +3683,18 @@ class RosterWindow:
|
||||||
status_message = '♪ ' + _('"%(title)s" by %(artist)s') % \
|
status_message = '♪ ' + _('"%(title)s" by %(artist)s') % \
|
||||||
{'title': music_track_info.title,
|
{'title': music_track_info.title,
|
||||||
'artist': music_track_info.artist } + ' ♪'
|
'artist': music_track_info.artist } + ' ♪'
|
||||||
for account in accounts:
|
print "change (%s - %s) for %s" % (artist, title, account)
|
||||||
if not gajim.config.get_per('accounts', account,
|
if account == '':
|
||||||
'sync_with_global_status'):
|
print "Multi accounts"
|
||||||
continue
|
for account in accounts:
|
||||||
#FIXME: updates should arrive, when all accounts are
|
if not gajim.config.get_per('accounts', account,
|
||||||
# connected and we know their abilities
|
'sync_with_global_status'):
|
||||||
if not gajim.connections[account].pep_supported:
|
continue
|
||||||
continue
|
if not gajim.connections[account].pep_supported:
|
||||||
|
continue
|
||||||
|
pep.user_send_tune(account, artist, title, source = '')
|
||||||
|
else:
|
||||||
|
print "Single account"
|
||||||
pep.user_send_tune(account, artist, title, source = '')
|
pep.user_send_tune(account, artist, title, source = '')
|
||||||
|
|
||||||
|
|
||||||
|
@ -5270,12 +5276,7 @@ class RosterWindow:
|
||||||
self.tooltip = tooltips.RosterTooltip()
|
self.tooltip = tooltips.RosterTooltip()
|
||||||
self.draw_roster()
|
self.draw_roster()
|
||||||
|
|
||||||
## Music Track notifications
|
self.enable_syncing_status_msg_from_current_music_track(gajim.config.get('publish_tune'))
|
||||||
## FIXME: we use a timeout because changing status of
|
|
||||||
## accounts has no effect until they are connected.
|
|
||||||
gobject.timeout_add(1000,
|
|
||||||
self.enable_syncing_status_msg_from_current_music_track,
|
|
||||||
gajim.config.get('pub_tune'))
|
|
||||||
|
|
||||||
if gajim.config.get('show_roster_on_startup'):
|
if gajim.config.get('show_roster_on_startup'):
|
||||||
self.window.show_all()
|
self.window.show_all()
|
||||||
|
|
Loading…
Reference in New Issue