From 3d1b7ac4cf90da27e55bf1933c7b994b48b0ba11 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Tue, 24 Jul 2012 22:37:08 -0400 Subject: [PATCH] Differentiate between setting subscribed and changing status --- .../accounts/spotify/SpotifyAccount.cpp | 8 ++++---- .../accounts/spotify/SpotifyPlaylistUpdater.cpp | 15 +++++++++++++-- .../accounts/spotify/SpotifyPlaylistUpdater.h | 3 +++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp b/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp index f330678ea..a5d643dbf 100644 --- a/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp +++ b/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp @@ -679,7 +679,7 @@ SpotifyAccount::setSubscribedForPlaylist( const playlist_ptr& playlist, bool sub sendMessage( msg, this ); updater->setSync( subscribed ); - updater->setSubscribed( subscribed ); + updater->setSubscribedStatus( subscribed ); } @@ -733,7 +733,7 @@ SpotifyAccount::resolverMessage( const QString &msgType, const QVariantMap &msg QObject* receiver = m_qidToSlotMap[ qid ].first; QString slot = m_qidToSlotMap[ qid ].second; m_qidToSlotMap.remove( qid ); - + QVariant extraData; if ( m_qidToExtraData.contains( qid ) ) extraData = m_qidToExtraData.take( qid ); @@ -1214,7 +1214,7 @@ SpotifyAccount::sendMessage( const QVariantMap &m, QObject* obj, const QString& } m_qidToExtraData[ qid ] = extraData; - + m_spotifyResolver.data()->sendMessage( msg ); return qid; @@ -1312,7 +1312,7 @@ SpotifyAccount::setSyncForPlaylist( const QString& spotifyPlaylistId, bool sync if ( info ) info->sync = sync; - + if ( !m_configWidget.isNull() ) m_configWidget.data()->setPlaylists( m_allSpotifyPlaylists.values() ); diff --git a/src/libtomahawk/accounts/spotify/SpotifyPlaylistUpdater.cpp b/src/libtomahawk/accounts/spotify/SpotifyPlaylistUpdater.cpp index e2c4ab252..d0474cabe 100644 --- a/src/libtomahawk/accounts/spotify/SpotifyPlaylistUpdater.cpp +++ b/src/libtomahawk/accounts/spotify/SpotifyPlaylistUpdater.cpp @@ -65,7 +65,7 @@ SpotifyUpdaterFactory::create( const Tomahawk::playlist_ptr& pl, const QVariantH SpotifyPlaylistUpdater* updater = new SpotifyPlaylistUpdater( m_account.data(), latestRev, spotifyId, pl ); updater->setSync( sync ); updater->setCanSubscribe( canSubscribe ); - updater->setSubscribed( isSubscribed ); + updater->setSubscribedStatus( isSubscribed ); m_account.data()->registerUpdaterForPlaylist( spotifyId, updater ); return updater; @@ -242,8 +242,9 @@ SpotifyPlaylistUpdater::sync() const return m_sync; } + void -SpotifyPlaylistUpdater::setSubscribed( bool subscribed ) +SpotifyPlaylistUpdater::setSubscribedStatus( bool subscribed ) { if ( m_subscribed == subscribed ) return; @@ -255,6 +256,16 @@ SpotifyPlaylistUpdater::setSubscribed( bool subscribed ) } +void +SpotifyPlaylistUpdater::setSubscribed( bool subscribed ) +{ + if ( !m_spotify.isNull() ) + m_spotify.data()->setSubscribedForPlaylist( playlist(), subscribed ); + + // Spotify account will in turn call setSUbscribedStatus +} + + bool SpotifyPlaylistUpdater::subscribed() const { diff --git a/src/libtomahawk/accounts/spotify/SpotifyPlaylistUpdater.h b/src/libtomahawk/accounts/spotify/SpotifyPlaylistUpdater.h index 3345a8c4b..10ceef393 100644 --- a/src/libtomahawk/accounts/spotify/SpotifyPlaylistUpdater.h +++ b/src/libtomahawk/accounts/spotify/SpotifyPlaylistUpdater.h @@ -55,7 +55,10 @@ public: bool sync() const; void setSync( bool sync ); bool subscribed() const; + // actually change the subscribed value in spotify void setSubscribed( bool subscribed ); + // Just set the subscribed flag + void setSubscribedStatus( bool subscribed ); bool canSubscribe() const; void setCanSubscribe( bool canSub ); QString spotifyId() const { return m_spotifyId; }