mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 07:36:48 +02:00
TWK-1389: Utilize private sessions, if private
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
#include "SpotifyInfoPlugin.h"
|
#include "SpotifyInfoPlugin.h"
|
||||||
#include "infosystem/InfoSystem.h"
|
#include "infosystem/InfoSystem.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "TomahawkSettings.h"
|
||||||
|
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
#include "jobview/JobStatusView.h"
|
#include "jobview/JobStatusView.h"
|
||||||
@@ -226,7 +227,7 @@ SpotifyAccount::hookupResolver()
|
|||||||
|
|
||||||
connect( m_spotifyResolver.data(), SIGNAL( changed() ), this, SLOT( resolverChanged() ) );
|
connect( m_spotifyResolver.data(), SIGNAL( changed() ), this, SLOT( resolverChanged() ) );
|
||||||
connect( m_spotifyResolver.data(), SIGNAL( customMessage( QString,QVariantMap ) ), this, SLOT( resolverMessage( QString, QVariantMap ) ) );
|
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
|
// Always get logged in status
|
||||||
QVariantMap msg;
|
QVariantMap msg;
|
||||||
msg[ "_msgtype" ] = "getCredentials";
|
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
|
bool
|
||||||
SpotifyAccount::loggedIn() const
|
SpotifyAccount::loggedIn() const
|
||||||
{
|
{
|
||||||
@@ -1123,6 +1135,7 @@ SpotifyAccount::configurationWidget()
|
|||||||
m_configWidget = QPointer< SpotifyAccountConfig >( new SpotifyAccountConfig( this ) );
|
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( login( QString,QString ) ), this, SLOT( login( QString,QString ) ) );
|
||||||
connect( m_configWidget.data(), SIGNAL( logout() ), this, SLOT( logout() ) );
|
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() );
|
m_configWidget.data()->setPlaylists( m_allSpotifyPlaylists.values() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1178,6 +1191,8 @@ SpotifyAccount::saveConfig()
|
|||||||
QVariantHash config = configuration();
|
QVariantHash config = configuration();
|
||||||
config[ "deleteOnUnsync" ] = m_configWidget.data()->deleteOnUnsync();
|
config[ "deleteOnUnsync" ] = m_configWidget.data()->deleteOnUnsync();
|
||||||
config[ "loveSync" ] = m_configWidget.data()->loveSync();
|
config[ "loveSync" ] = m_configWidget.data()->loveSync();
|
||||||
|
config[ "persitentPrivacy" ] = m_configWidget.data()->persitentPrivacy();
|
||||||
|
|
||||||
setConfiguration( config );
|
setConfiguration( config );
|
||||||
|
|
||||||
m_configWidget.data()->saveSettings();
|
m_configWidget.data()->saveSettings();
|
||||||
@@ -1214,7 +1229,7 @@ SpotifyAccount::login( const QString& username, const QString& password )
|
|||||||
msg[ "_msgtype" ] = "login";
|
msg[ "_msgtype" ] = "login";
|
||||||
msg[ "username" ] = username;
|
msg[ "username" ] = username;
|
||||||
msg[ "password" ] = password;
|
msg[ "password" ] = password;
|
||||||
|
msg[ "privateSession" ] = ( m_configWidget.data()->persitentPrivacy() || TomahawkSettings::instance()->privateListeningMode() != TomahawkSettings::PublicListening );
|
||||||
msg[ "highQuality" ] = m_configWidget.data()->highQuality();
|
msg[ "highQuality" ] = m_configWidget.data()->highQuality();
|
||||||
|
|
||||||
m_spotifyResolver.data()->sendMessage( msg );
|
m_spotifyResolver.data()->sendMessage( msg );
|
||||||
@@ -1465,6 +1480,13 @@ SpotifyAccount::loveSync() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
SpotifyAccount::persitentPrivacy() const
|
||||||
|
{
|
||||||
|
return configuration().value( "persitentPrivacy", false ).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyAccount::stopPlaylistSync( SpotifyPlaylistInfo* playlist, bool forceDontDelete )
|
SpotifyAccount::stopPlaylistSync( SpotifyPlaylistInfo* playlist, bool forceDontDelete )
|
||||||
{
|
{
|
||||||
|
@@ -112,6 +112,8 @@ public:
|
|||||||
|
|
||||||
bool deleteOnUnsync() const;
|
bool deleteOnUnsync() const;
|
||||||
bool loveSync() const;
|
bool loveSync() const;
|
||||||
|
bool persitentPrivacy() const;
|
||||||
|
|
||||||
void starTrack( const QString& artist, const QString& title, const bool starred );
|
void starTrack( const QString& artist, const QString& title, const bool starred );
|
||||||
void setManualResolverPath( const QString& resolverPath );
|
void setManualResolverPath( const QString& resolverPath );
|
||||||
|
|
||||||
@@ -131,6 +133,7 @@ private slots:
|
|||||||
void resolverInstalled( const QString& resolverId );
|
void resolverInstalled( const QString& resolverId );
|
||||||
|
|
||||||
void resolverMessage( const QString& msgType, const QVariantMap& msg );
|
void resolverMessage( const QString& msgType, const QVariantMap& msg );
|
||||||
|
void privateModeChanged();
|
||||||
|
|
||||||
void login( const QString& username, const QString& password );
|
void login( const QString& username, const QString& password );
|
||||||
void logout();
|
void logout();
|
||||||
|
@@ -49,7 +49,9 @@ SpotifyAccountConfig::SpotifyAccountConfig( SpotifyAccount *account )
|
|||||||
m_ui->loginButton->setDefault( true );
|
m_ui->loginButton->setDefault( true );
|
||||||
|
|
||||||
connect( m_ui->loginButton, SIGNAL( clicked( bool ) ), this, SLOT( doLogin() ) );
|
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->usernameEdit, SIGNAL( textEdited( QString ) ), this, SLOT( resetLoginButton() ) );
|
||||||
connect( m_ui->passwordEdit, 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() ) );
|
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->streamingCheckbox->setChecked( m_account->credentials().value( "highQuality" ).toBool() );
|
||||||
m_ui->deleteOnUnsync->setChecked( m_account->deleteOnUnsync() );
|
m_ui->deleteOnUnsync->setChecked( m_account->deleteOnUnsync() );
|
||||||
m_ui->loveSync->setChecked( m_account->loveSync() );
|
m_ui->loveSync->setChecked( m_account->loveSync() );
|
||||||
|
m_ui->persitentPrivacy->setChecked( m_account->persitentPrivacy() );
|
||||||
|
|
||||||
if ( m_account->loggedIn() )
|
if ( m_account->loggedIn() )
|
||||||
{
|
{
|
||||||
@@ -149,6 +152,13 @@ SpotifyAccountConfig::loveSync() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
SpotifyAccountConfig::persitentPrivacy() const
|
||||||
|
{
|
||||||
|
return m_ui->persitentPrivacy->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyAccountConfig::setPlaylists( const QList<SpotifyPlaylistInfo *>& playlists )
|
SpotifyAccountConfig::setPlaylists( const QList<SpotifyPlaylistInfo *>& playlists )
|
||||||
{
|
{
|
||||||
@@ -223,6 +233,7 @@ SpotifyAccountConfig::loginResponse( bool success, const QString& msg, const QSt
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyAccountConfig::showStarredPlaylist( bool hide )
|
SpotifyAccountConfig::showStarredPlaylist( bool hide )
|
||||||
{
|
{
|
||||||
|
@@ -53,6 +53,7 @@ public:
|
|||||||
bool highQuality() const;
|
bool highQuality() const;
|
||||||
bool deleteOnUnsync() const;
|
bool deleteOnUnsync() const;
|
||||||
bool loveSync() const;
|
bool loveSync() const;
|
||||||
|
bool persitentPrivacy() const;
|
||||||
|
|
||||||
void setPlaylists( const QList< SpotifyPlaylistInfo* >& playlists );
|
void setPlaylists( const QList< SpotifyPlaylistInfo* >& playlists );
|
||||||
|
|
||||||
@@ -66,6 +67,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void login( const QString& username, const QString& pw );
|
void login( const QString& username, const QString& pw );
|
||||||
void logout();
|
void logout();
|
||||||
|
void updatePrivacy( bool );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void showEvent( QShowEvent* event );
|
void showEvent( QShowEvent* event );
|
||||||
@@ -74,7 +76,7 @@ private slots:
|
|||||||
void doLogin();
|
void doLogin();
|
||||||
void resetLoginButton();
|
void resetLoginButton();
|
||||||
void selectAllPlaylists();
|
void selectAllPlaylists();
|
||||||
void showStarredPlaylist(bool);
|
void showStarredPlaylist( bool );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void showLoggedIn();
|
void showLoggedIn();
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>375</width>
|
<width>406</width>
|
||||||
<height>487</height>
|
<height>534</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="pixmap">
|
<property name="pixmap">
|
||||||
<pixmap resource="../../../resources.qrc">:/data/images/spotify-logo.png</pixmap>
|
<pixmap resource="../../../../resources.qrc">:/data/images/spotify-logo.png</pixmap>
|
||||||
</property>
|
</property>
|
||||||
<property name="scaledContents">
|
<property name="scaledContents">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@@ -178,10 +178,20 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="persitentPrivacy">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Use this to force Spotify to never announce listening data to Social Networks</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Always run in Private Mode</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../../resources.qrc"/>
|
<include location="../../../../resources.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
Reference in New Issue
Block a user