diff --git a/TODO.pep b/TODO.pep index 3e6072e9866e5932a44fa0f9baf9436047bbcc08..05c924dbf4e82ae837b1212dd8578540e2727539 100644 --- a/TODO.pep +++ b/TODO.pep @@ -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 diff --git a/src/common/connection.py b/src/common/connection.py index 89d22c3de7b0e11555221dbd9dbfad67a4cae136..393a7d741c2365bd7d42a1ea75e93da8cf5724e9 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -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'): diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 5d95db71e81886371310fbb5140ecc0580080ff9..1451da0a8062dbb3cf75219f2deccb735a5336d1 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -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) diff --git a/src/common/pep.py b/src/common/pep.py index 8b49d899ea2c023f80d282df4d838214c72419c3..9259820f5c9e4ef7be227070ad5cb59a8d31d702 100644 --- a/src/common/pep.py +++ b/src/common/pep.py @@ -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" diff --git a/src/roster_window.py b/src/roster_window.py index 91146bf99e191d32d37307fa9f2094074a630d75..803c4ff66de5e7b971e21a32f288ff72ad046293 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -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()