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