diff --git a/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp b/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp index d8a976a30..e37f79ec3 100644 --- a/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp +++ b/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp @@ -32,6 +32,7 @@ #include "SpotifyInfoPlugin.h" #include "infosystem/InfoSystem.h" #include "utils/Logger.h" +#include "TomahawkSettings.h" #ifndef ENABLE_HEADLESS #include "jobview/JobStatusView.h" @@ -226,7 +227,7 @@ SpotifyAccount::hookupResolver() connect( m_spotifyResolver.data(), SIGNAL( changed() ), this, SLOT( resolverChanged() ) ); connect( m_spotifyResolver.data(), SIGNAL( customMessage( QString,QVariantMap ) ), this, SLOT( resolverMessage( QString, QVariantMap ) ) ); - + connect( ActionCollection::instance(), SIGNAL( privacyModeChanged() ), SLOT( privateModeChanged() ) ); // Always get logged in status QVariantMap msg; msg[ "_msgtype" ] = "getCredentials"; @@ -433,6 +434,17 @@ SpotifyAccount::starTrack(const QString &artist, const QString &title, const boo } +void +SpotifyAccount::privateModeChanged() +{ + qDebug() << Q_FUNC_INFO << "Sending privateMode"; + QVariantMap msg; + msg[ "_msgtype" ] = "setPrivacyMode"; + msg[ "private" ] = ( m_configWidget.data()->persitentPrivacy() || TomahawkSettings::instance()->privateListeningMode() != TomahawkSettings::PublicListening ); + sendMessage( msg ); +} + + bool SpotifyAccount::loggedIn() const { @@ -1123,6 +1135,7 @@ SpotifyAccount::configurationWidget() m_configWidget = QPointer< SpotifyAccountConfig >( new SpotifyAccountConfig( this ) ); connect( m_configWidget.data(), SIGNAL( login( QString,QString ) ), this, SLOT( login( QString,QString ) ) ); connect( m_configWidget.data(), SIGNAL( logout() ), this, SLOT( logout() ) ); + connect( m_configWidget.data(), SIGNAL( updatePrivacy( bool ) ), this, SLOT( privateModeChanged() ) ); m_configWidget.data()->setPlaylists( m_allSpotifyPlaylists.values() ); } @@ -1178,6 +1191,8 @@ SpotifyAccount::saveConfig() QVariantHash config = configuration(); config[ "deleteOnUnsync" ] = m_configWidget.data()->deleteOnUnsync(); config[ "loveSync" ] = m_configWidget.data()->loveSync(); + config[ "persitentPrivacy" ] = m_configWidget.data()->persitentPrivacy(); + setConfiguration( config ); m_configWidget.data()->saveSettings(); @@ -1214,7 +1229,7 @@ SpotifyAccount::login( const QString& username, const QString& password ) msg[ "_msgtype" ] = "login"; msg[ "username" ] = username; msg[ "password" ] = password; - + msg[ "privateSession" ] = ( m_configWidget.data()->persitentPrivacy() || TomahawkSettings::instance()->privateListeningMode() != TomahawkSettings::PublicListening ); msg[ "highQuality" ] = m_configWidget.data()->highQuality(); m_spotifyResolver.data()->sendMessage( msg ); @@ -1465,6 +1480,13 @@ SpotifyAccount::loveSync() const } +bool +SpotifyAccount::persitentPrivacy() const +{ + return configuration().value( "persitentPrivacy", false ).toBool(); +} + + void SpotifyAccount::stopPlaylistSync( SpotifyPlaylistInfo* playlist, bool forceDontDelete ) { diff --git a/src/libtomahawk/accounts/spotify/SpotifyAccount.h b/src/libtomahawk/accounts/spotify/SpotifyAccount.h index 372cc9f8b..c8f231d32 100644 --- a/src/libtomahawk/accounts/spotify/SpotifyAccount.h +++ b/src/libtomahawk/accounts/spotify/SpotifyAccount.h @@ -112,6 +112,8 @@ public: bool deleteOnUnsync() const; bool loveSync() const; + bool persitentPrivacy() const; + void starTrack( const QString& artist, const QString& title, const bool starred ); void setManualResolverPath( const QString& resolverPath ); @@ -131,6 +133,7 @@ private slots: void resolverInstalled( const QString& resolverId ); void resolverMessage( const QString& msgType, const QVariantMap& msg ); + void privateModeChanged(); void login( const QString& username, const QString& password ); void logout(); diff --git a/src/libtomahawk/accounts/spotify/SpotifyAccountConfig.cpp b/src/libtomahawk/accounts/spotify/SpotifyAccountConfig.cpp index e834de8d0..45d27b15a 100644 --- a/src/libtomahawk/accounts/spotify/SpotifyAccountConfig.cpp +++ b/src/libtomahawk/accounts/spotify/SpotifyAccountConfig.cpp @@ -49,7 +49,9 @@ SpotifyAccountConfig::SpotifyAccountConfig( SpotifyAccount *account ) m_ui->loginButton->setDefault( true ); connect( m_ui->loginButton, SIGNAL( clicked( bool ) ), this, SLOT( doLogin() ) ); - connect( m_ui->loveSync, SIGNAL( toggled(bool) ), this, SLOT( showStarredPlaylist(bool) ) ); + connect( m_ui->loveSync, SIGNAL( toggled( bool ) ), this, SLOT( showStarredPlaylist( bool ) ) ); + connect( m_ui->persitentPrivacy, SIGNAL( toggled( bool ) ), this, SIGNAL( updatePrivacy( bool ) ) ); + connect( m_ui->usernameEdit, SIGNAL( textEdited( QString ) ), this, SLOT( resetLoginButton() ) ); connect( m_ui->passwordEdit, SIGNAL( textEdited( QString ) ), this, SLOT( resetLoginButton() ) ); connect( m_ui->selectAllCheckbox, SIGNAL( stateChanged( int ) ), this, SLOT( selectAllPlaylists() ) ); @@ -78,6 +80,7 @@ SpotifyAccountConfig::loadFromConfig() m_ui->streamingCheckbox->setChecked( m_account->credentials().value( "highQuality" ).toBool() ); m_ui->deleteOnUnsync->setChecked( m_account->deleteOnUnsync() ); m_ui->loveSync->setChecked( m_account->loveSync() ); + m_ui->persitentPrivacy->setChecked( m_account->persitentPrivacy() ); if ( m_account->loggedIn() ) { @@ -149,6 +152,13 @@ SpotifyAccountConfig::loveSync() const } +bool +SpotifyAccountConfig::persitentPrivacy() const +{ + return m_ui->persitentPrivacy->isChecked(); +} + + void SpotifyAccountConfig::setPlaylists( const QList& playlists ) { @@ -223,6 +233,7 @@ SpotifyAccountConfig::loginResponse( bool success, const QString& msg, const QSt } + void SpotifyAccountConfig::showStarredPlaylist( bool hide ) { diff --git a/src/libtomahawk/accounts/spotify/SpotifyAccountConfig.h b/src/libtomahawk/accounts/spotify/SpotifyAccountConfig.h index 6224108bb..81aa36a64 100644 --- a/src/libtomahawk/accounts/spotify/SpotifyAccountConfig.h +++ b/src/libtomahawk/accounts/spotify/SpotifyAccountConfig.h @@ -53,6 +53,7 @@ public: bool highQuality() const; bool deleteOnUnsync() const; bool loveSync() const; + bool persitentPrivacy() const; void setPlaylists( const QList< SpotifyPlaylistInfo* >& playlists ); @@ -66,6 +67,7 @@ public: signals: void login( const QString& username, const QString& pw ); void logout(); + void updatePrivacy( bool ); protected: void showEvent( QShowEvent* event ); @@ -74,7 +76,7 @@ private slots: void doLogin(); void resetLoginButton(); void selectAllPlaylists(); - void showStarredPlaylist(bool); + void showStarredPlaylist( bool ); private: void showLoggedIn(); diff --git a/src/libtomahawk/accounts/spotify/SpotifyAccountConfig.ui b/src/libtomahawk/accounts/spotify/SpotifyAccountConfig.ui index 8eb3e55f5..b269e2d44 100644 --- a/src/libtomahawk/accounts/spotify/SpotifyAccountConfig.ui +++ b/src/libtomahawk/accounts/spotify/SpotifyAccountConfig.ui @@ -6,8 +6,8 @@ 0 0 - 375 - 487 + 406 + 534 @@ -34,7 +34,7 @@ - :/data/images/spotify-logo.png + :/data/images/spotify-logo.png true @@ -178,10 +178,20 @@ + + + + Use this to force Spotify to never announce listening data to Social Networks + + + Always run in Private Mode + + + - +