mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 17:14:00 +02:00
Save credentials as well as committing them to storage
This commit is contained in:
@@ -53,7 +53,7 @@ TwitterAccount::TwitterAccount( const QString &accountId )
|
|||||||
setAccountServiceName( "Twitter" );
|
setAccountServiceName( "Twitter" );
|
||||||
setTypes( AccountTypes( StatusPushType | SipType ) );
|
setTypes( AccountTypes( StatusPushType | SipType ) );
|
||||||
|
|
||||||
connect( this, SIGNAL( credentialsChanged( QVariantHash ) ), this, SLOT( onCredentialsChanged( QVariantHash ) ) );
|
connect( this, SIGNAL( credentialsLoaded( QVariantHash ) ), this, SLOT( onCredentialsLoaded( QVariantHash ) ) );
|
||||||
|
|
||||||
qDebug() << "Got cached peers:" << configuration() << configuration()[ "cachedpeers" ];
|
qDebug() << "Got cached peers:" << configuration() << configuration()[ "cachedpeers" ];
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ TwitterAccount::configDialogAuthedSignalSlot( bool authed )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TwitterAccount::onCredentialsChanged( const QVariantHash &credentials )
|
TwitterAccount::onCredentialsLoaded( const QVariantHash &credentials )
|
||||||
{
|
{
|
||||||
// Credentials loaded
|
// Credentials loaded
|
||||||
bool reload = false;
|
bool reload = false;
|
||||||
@@ -101,6 +101,15 @@ TwitterAccount::onCredentialsChanged( const QVariantHash &credentials )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TwitterAccount::setCredentials( const QVariantHash &credentials )
|
||||||
|
{
|
||||||
|
m_credentials = credentials;
|
||||||
|
|
||||||
|
saveCredentials( credentials );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Account::ConnectionState
|
Account::ConnectionState
|
||||||
TwitterAccount::connectionState() const
|
TwitterAccount::connectionState() const
|
||||||
{
|
{
|
||||||
|
@@ -80,12 +80,14 @@ public:
|
|||||||
TomahawkOAuthTwitter* twitterAuth() const { return m_twitterAuth.data(); }
|
TomahawkOAuthTwitter* twitterAuth() const { return m_twitterAuth.data(); }
|
||||||
|
|
||||||
QVariantHash credentials() const { return m_credentials; }
|
QVariantHash credentials() const { return m_credentials; }
|
||||||
|
void setCredentials( const QVariantHash& creds );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nowAuthenticated( const QWeakPointer< TomahawkOAuthTwitter >&, const QTweetUser &user );
|
void nowAuthenticated( const QWeakPointer< TomahawkOAuthTwitter >&, const QTweetUser &user );
|
||||||
void nowDeauthenticated();
|
void nowDeauthenticated();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onCredentialsChanged( const QVariantHash& credentials );
|
void onCredentialsLoaded( const QVariantHash& credentials );
|
||||||
|
|
||||||
void authenticateSlot();
|
void authenticateSlot();
|
||||||
void configDialogAuthedSignalSlot( bool authed );
|
void configDialogAuthedSignalSlot( bool authed );
|
||||||
|
@@ -112,7 +112,7 @@ TwitterConfigWidget::authenticateTwitter()
|
|||||||
QVariantHash credentials = m_account->credentials();
|
QVariantHash credentials = m_account->credentials();
|
||||||
credentials[ "oauthtoken" ] = twitAuth->oauthToken();
|
credentials[ "oauthtoken" ] = twitAuth->oauthToken();
|
||||||
credentials[ "oauthtokensecret" ] = twitAuth->oauthTokenSecret();
|
credentials[ "oauthtokensecret" ] = twitAuth->oauthTokenSecret();
|
||||||
m_account->saveCredentials( credentials );
|
m_account->setCredentials( credentials );
|
||||||
|
|
||||||
QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( twitAuth, this );
|
QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( twitAuth, this );
|
||||||
connect( credVerifier, SIGNAL( parsedUser( const QTweetUser & ) ), SLOT( authenticateVerifyReply( const QTweetUser & ) ) );
|
connect( credVerifier, SIGNAL( parsedUser( const QTweetUser & ) ), SLOT( authenticateVerifyReply( const QTweetUser & ) ) );
|
||||||
@@ -133,7 +133,7 @@ TwitterConfigWidget::authenticateVerifyReply( const QTweetUser &user )
|
|||||||
|
|
||||||
QVariantHash credentials = m_account->credentials();
|
QVariantHash credentials = m_account->credentials();
|
||||||
credentials[ "username" ] = user.screenName();
|
credentials[ "username" ] = user.screenName();
|
||||||
m_account->saveCredentials( credentials );
|
m_account->setCredentials( credentials );
|
||||||
|
|
||||||
QVariantHash configuration = m_account->configuration();
|
QVariantHash configuration = m_account->configuration();
|
||||||
configuration[ "sipcachedfriendssinceid" ] = 0;
|
configuration[ "sipcachedfriendssinceid" ] = 0;
|
||||||
@@ -165,7 +165,7 @@ void
|
|||||||
TwitterConfigWidget::deauthenticateTwitter()
|
TwitterConfigWidget::deauthenticateTwitter()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
m_account->saveCredentials( QVariantHash() );
|
m_account->setCredentials( QVariantHash() );
|
||||||
|
|
||||||
m_ui->twitterStatusLabel->setText(tr("Status: No saved credentials"));
|
m_ui->twitterStatusLabel->setText(tr("Status: No saved credentials"));
|
||||||
m_ui->twitterAuthenticateButton->setText( tr( "Authenticate" ) );
|
m_ui->twitterAuthenticateButton->setText( tr( "Authenticate" ) );
|
||||||
|
@@ -41,7 +41,7 @@ XmppAccountFactory::createAccount( const QString& accountId )
|
|||||||
XmppAccount::XmppAccount( const QString &accountId )
|
XmppAccount::XmppAccount( const QString &accountId )
|
||||||
: Account( accountId )
|
: Account( accountId )
|
||||||
{
|
{
|
||||||
connect( this, SIGNAL( credentialsChanged( QVariantHash ) ), this, SLOT( onCredentialsChanged( QVariantHash ) ) );
|
connect( this, SIGNAL( credentialsLoaded( QVariantHash ) ), this, SLOT( onCredentialsLoaded( QVariantHash ) ) );
|
||||||
|
|
||||||
setAccountServiceName( "Jabber (XMPP)" );
|
setAccountServiceName( "Jabber (XMPP)" );
|
||||||
setTypes( SipType );
|
setTypes( SipType );
|
||||||
@@ -93,7 +93,7 @@ XmppAccount::saveConfig()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmppAccount::onCredentialsChanged( const QVariantHash& credentials )
|
XmppAccount::onCredentialsLoaded( const QVariantHash& credentials )
|
||||||
{
|
{
|
||||||
m_credentials = credentials;
|
m_credentials = credentials;
|
||||||
if ( !m_xmppSipPlugin.isNull() )
|
if ( !m_xmppSipPlugin.isNull() )
|
||||||
@@ -101,6 +101,15 @@ XmppAccount::onCredentialsChanged( const QVariantHash& credentials )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
XmppAccount::setCredentials( const QVariantHash &credentials )
|
||||||
|
{
|
||||||
|
m_credentials = credentials;
|
||||||
|
|
||||||
|
saveCredentials( credentials );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
InfoSystem::InfoPluginPtr
|
InfoSystem::InfoPluginPtr
|
||||||
XmppAccount::infoPlugin()
|
XmppAccount::infoPlugin()
|
||||||
{
|
{
|
||||||
|
@@ -78,11 +78,12 @@ public:
|
|||||||
void saveConfig();
|
void saveConfig();
|
||||||
|
|
||||||
QVariantHash credentials() const { return m_credentials; }
|
QVariantHash credentials() const { return m_credentials; }
|
||||||
|
void setCredentials( const QVariantHash& credentials );
|
||||||
|
|
||||||
virtual Tomahawk::Accounts::Account::ConnectionState connectionState() const;
|
virtual Tomahawk::Accounts::Account::ConnectionState connectionState() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onCredentialsChanged( const QVariantHash& credentials );
|
void onCredentialsLoaded( const QVariantHash& credentials );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QWeakPointer< QWidget > m_configWidget; // so the google wrapper can change the config dialog a bit
|
QWeakPointer< QWidget > m_configWidget; // so the google wrapper can change the config dialog a bit
|
||||||
|
@@ -68,7 +68,7 @@ XmppConfigWidget::saveConfig()
|
|||||||
m_account->setConfiguration( configuration);
|
m_account->setConfiguration( configuration);
|
||||||
m_account->sync();
|
m_account->sync();
|
||||||
|
|
||||||
m_account->saveCredentials( credentials );
|
m_account->setCredentials( credentials );
|
||||||
|
|
||||||
static_cast< XmppSipPlugin* >( m_account->sipPlugin() )->checkSettings();
|
static_cast< XmppSipPlugin* >( m_account->sipPlugin() )->checkSettings();
|
||||||
}
|
}
|
||||||
|
@@ -611,12 +611,13 @@ XmppSipPlugin::configurationChanged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( reconnect )
|
if ( reconnect )
|
||||||
|
setupClientHelper();
|
||||||
|
|
||||||
|
if ( reconnect && m_account->enabled() )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "Reconnecting jreen plugin...";
|
qDebug() << Q_FUNC_INFO << "Reconnecting jreen plugin...";
|
||||||
disconnectPlugin();
|
disconnectPlugin();
|
||||||
|
|
||||||
setupClientHelper();
|
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << "Updated settings";
|
qDebug() << Q_FUNC_INFO << "Updated settings";
|
||||||
connectPlugin();
|
connectPlugin();
|
||||||
}
|
}
|
||||||
|
@@ -616,6 +616,8 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion )
|
|||||||
qDebug() << "Migrating account credentials for account:" << account;
|
qDebug() << "Migrating account credentials for account:" << account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove( "credentials" );
|
||||||
|
|
||||||
endGroup();
|
endGroup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -133,7 +133,7 @@ Account::keychainJobFinished( QKeychain::Job* j )
|
|||||||
|
|
||||||
tLog() << Q_FUNC_INFO << readJob->key();
|
tLog() << Q_FUNC_INFO << readJob->key();
|
||||||
|
|
||||||
emit credentialsChanged( credentials );
|
emit credentialsLoaded( credentials );
|
||||||
}
|
}
|
||||||
else if ( QKeychain::WritePasswordJob* writeJob = qobject_cast< QKeychain::WritePasswordJob* >( j ) )
|
else if ( QKeychain::WritePasswordJob* writeJob = qobject_cast< QKeychain::WritePasswordJob* >( j ) )
|
||||||
{
|
{
|
||||||
|
@@ -146,7 +146,7 @@ signals:
|
|||||||
|
|
||||||
void configurationChanged();
|
void configurationChanged();
|
||||||
|
|
||||||
void credentialsChanged( const QVariantHash& credentials );
|
void credentialsLoaded( const QVariantHash& credentials );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void loadFromConfig( const QString &accountId );
|
virtual void loadFromConfig( const QString &accountId );
|
||||||
|
@@ -55,7 +55,7 @@ LastFmAccountFactory::icon() const
|
|||||||
LastFmAccount::LastFmAccount( const QString& accountId )
|
LastFmAccount::LastFmAccount( const QString& accountId )
|
||||||
: CustomAtticaAccount( accountId )
|
: CustomAtticaAccount( accountId )
|
||||||
{
|
{
|
||||||
connect( this, SIGNAL( credentialsChanged( QVariantHash ) ), this, SLOT( onCredentialsChanged( QVariantHash ) ) );
|
connect( this, SIGNAL( credentialsLoaded( QVariantHash ) ), this, SLOT( onCredentialsLoaded( QVariantHash ) ) );
|
||||||
|
|
||||||
setAccountFriendlyName( "Last.Fm" );
|
setAccountFriendlyName( "Last.Fm" );
|
||||||
m_icon.load( RESPATH "images/lastfm-icon.png" );
|
m_icon.load( RESPATH "images/lastfm-icon.png" );
|
||||||
@@ -196,7 +196,7 @@ LastFmAccount::saveConfig()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LastFmAccount::onCredentialsChanged(const QVariantHash &credentials)
|
LastFmAccount::onCredentialsLoaded(const QVariantHash &credentials)
|
||||||
{
|
{
|
||||||
m_credentials = credentials;
|
m_credentials = credentials;
|
||||||
if ( !m_infoPlugin.isNull() )
|
if ( !m_infoPlugin.isNull() )
|
||||||
|
@@ -101,7 +101,7 @@ private slots:
|
|||||||
|
|
||||||
void resolverChanged();
|
void resolverChanged();
|
||||||
|
|
||||||
void onCredentialsChanged( const QVariantHash& credentials );
|
void onCredentialsLoaded( const QVariantHash& credentials );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void hookupResolver();
|
void hookupResolver();
|
||||||
|
@@ -100,7 +100,7 @@ SpotifyAccount::~SpotifyAccount()
|
|||||||
void
|
void
|
||||||
SpotifyAccount::init()
|
SpotifyAccount::init()
|
||||||
{
|
{
|
||||||
connect( this, SIGNAL( credentialsChanged( QVariantHash ) ), this, SLOT( onCredentialsChanged( QVariantHash ) ) );
|
connect( this, SIGNAL( credentialsLoaded( QVariantHash ) ), this, SLOT( onCredentialsLoaded( QVariantHash ) ) );
|
||||||
|
|
||||||
setAccountFriendlyName( "Spotify" );
|
setAccountFriendlyName( "Spotify" );
|
||||||
setAccountServiceName( "spotify" );
|
setAccountServiceName( "spotify" );
|
||||||
@@ -185,11 +185,18 @@ SpotifyAccount::hookupResolver()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyAccount::onCredentialsChanged(const QVariantHash &credentials)
|
SpotifyAccount::onCredentialsLoaded( const QVariantHash &credentials )
|
||||||
{
|
{
|
||||||
m_credentials = credentials;
|
m_credentials = credentials;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SpotifyAccount::setCredentials(const QVariantHash &creds)
|
||||||
|
{
|
||||||
|
m_credentials = creds;
|
||||||
|
|
||||||
|
saveCredentials( creds );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -103,6 +103,7 @@ public:
|
|||||||
void setManualResolverPath( const QString& resolverPath );
|
void setManualResolverPath( const QString& resolverPath );
|
||||||
|
|
||||||
QVariantHash credentials() const { return m_credentials; }
|
QVariantHash credentials() const { return m_credentials; }
|
||||||
|
void setCredentials( const QVariantHash& creds );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void aboutToShow( QAction* action, const Tomahawk::playlist_ptr& playlist );
|
void aboutToShow( QAction* action, const Tomahawk::playlist_ptr& playlist );
|
||||||
@@ -110,7 +111,7 @@ public slots:
|
|||||||
void atticaLoaded(Attica::Content::List);
|
void atticaLoaded(Attica::Content::List);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onCredentialsChanged( const QVariantHash& credentials );
|
void onCredentialsLoaded( const QVariantHash& credentials );
|
||||||
|
|
||||||
void resolverChanged();
|
void resolverChanged();
|
||||||
void resolverInstalled( const QString& resolverId );
|
void resolverInstalled( const QString& resolverId );
|
||||||
|
Reference in New Issue
Block a user