Better Tune support

This commit is contained in:
Piotr Gaczkowski 2007-08-10 20:18:32 +00:00
parent 947ec8e933
commit 55a7061ea3
5 changed files with 35 additions and 33 deletions

View File

@ -1,11 +1,8 @@
• configure access model when changing it in the combobox
• configure tab in preferences for PEP
• PEP in status change
Tune use cases:
• on connection of an account set Tune to current track
• on disconnection of an account set Tune to None
• on change of a track set Tune to a new value
Tooltips use cases:
• Show PEP in contact tooltips

View File

@ -50,11 +50,6 @@ log = logging.getLogger('gajim.c.connection')
import gtkgui_helpers
from common import dbus_support
if dbus_support.supported:
from music_track_listener import MusicTrackListener
import dbus
ssl_error = {
2: "Unable to get issuer certificate",
3: "Unable to get certificate CRL",
@ -532,11 +527,6 @@ class Connection(ConnectionHandlers):
if self.on_connect_auth:
self.on_connect_auth(con)
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:
# Forget password if needed
if not gajim.config.get_per('accounts', self.name, 'savepass'):

View File

@ -40,6 +40,11 @@ from common.commands import ConnectionCommands
from common.pubsub import ConnectionPubSub
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',
'invisible', 'error']
# kind of events we can wait for an answer
@ -816,6 +821,11 @@ class ConnectionDisco:
if identity['category'] == 'pubsub' and identity['type'] == \
'pep':
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
if features.__contains__(common.xmpp.NS_BYTESTREAM):
gajim.proxy65_manager.resolve(jid, self.connection, self.name)

View File

@ -101,8 +101,11 @@ def user_send_activity(account, activity, subactivity = '', message = ''):
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):
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
print "publish_tune == True and pep_supported"
item = xmpp.Node('tune', {'xmlns': xmpp.NS_TUNE})
if artist != '':
i = item.addChild('artist')
@ -123,3 +126,4 @@ def user_send_tune(account, artist = '', title = '', source = '', track = 0,leng
item.addChild(payload=items)
gajim.connections[account].send_pb_publish('', xmpp.NS_TUNE, item, '0')
print "Tune published"

View File

@ -3623,14 +3623,14 @@ class RosterWindow:
listener = MusicTrackListener.get()
self._music_track_changed_signal = listener.connect(
'music-track-changed', self._music_track_changed)
track = listener.get_playing_track()
self._music_track_changed(listener, track)
track = listener.get_playing_track()
self._music_track_changed(listener, track)
else:
if self._music_track_changed_signal is not None:
listener = MusicTrackListener.get()
listener.disconnect(self._music_track_changed_signal)
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):
if not dbus_support.supported:
@ -3658,9 +3658,11 @@ class RosterWindow:
except Exception, e:
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
accounts = gajim.connections.keys()
if account == '':
accounts = gajim.connections.keys()
if music_track_info is None:
artist = ''
title = ''
@ -3681,14 +3683,18 @@ class RosterWindow:
status_message = '' + _('"%(title)s" by %(artist)s') % \
{'title': music_track_info.title,
'artist': music_track_info.artist } + ''
for account in accounts:
if not gajim.config.get_per('accounts', account,
'sync_with_global_status'):
continue
#FIXME: updates should arrive, when all accounts are
# connected and we know their abilities
if not gajim.connections[account].pep_supported:
continue
print "change (%s - %s) for %s" % (artist, title, account)
if account == '':
print "Multi accounts"
for account in accounts:
if not gajim.config.get_per('accounts', account,
'sync_with_global_status'):
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 = '')
@ -5270,12 +5276,7 @@ class RosterWindow:
self.tooltip = tooltips.RosterTooltip()
self.draw_roster()
## Music Track notifications
## 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'))
self.enable_syncing_status_msg_from_current_music_track(gajim.config.get('publish_tune'))
if gajim.config.get('show_roster_on_startup'):
self.window.show_all()