diff --git a/src/accounts/twitter/TwitterAccount.cpp b/src/accounts/twitter/TwitterAccount.cpp index a3b1dbe67..9f93d96d9 100644 --- a/src/accounts/twitter/TwitterAccount.cpp +++ b/src/accounts/twitter/TwitterAccount.cpp @@ -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 { diff --git a/src/accounts/twitter/TwitterAccount.h b/src/accounts/twitter/TwitterAccount.h index 3c4550037..e7a00a5d0 100644 --- a/src/accounts/twitter/TwitterAccount.h +++ b/src/accounts/twitter/TwitterAccount.h @@ -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 ); diff --git a/src/accounts/twitter/TwitterConfigWidget.cpp b/src/accounts/twitter/TwitterConfigWidget.cpp index aef70c20b..26daa676d 100644 --- a/src/accounts/twitter/TwitterConfigWidget.cpp +++ b/src/accounts/twitter/TwitterConfigWidget.cpp @@ -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" ) ); diff --git a/src/accounts/xmpp/XmppAccount.cpp b/src/accounts/xmpp/XmppAccount.cpp index e894e49c4..d205b78fd 100644 --- a/src/accounts/xmpp/XmppAccount.cpp +++ b/src/accounts/xmpp/XmppAccount.cpp @@ -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() { diff --git a/src/accounts/xmpp/XmppAccount.h b/src/accounts/xmpp/XmppAccount.h index 23348b47d..1d8f120b6 100644 --- a/src/accounts/xmpp/XmppAccount.h +++ b/src/accounts/xmpp/XmppAccount.h @@ -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 diff --git a/src/accounts/xmpp/XmppConfigWidget.cpp b/src/accounts/xmpp/XmppConfigWidget.cpp index 7ccd31071..789a3ba75 100644 --- a/src/accounts/xmpp/XmppConfigWidget.cpp +++ b/src/accounts/xmpp/XmppConfigWidget.cpp @@ -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(); } diff --git a/src/accounts/xmpp/sip/XmppSip.cpp b/src/accounts/xmpp/sip/XmppSip.cpp index d2c6115fc..754c5360d 100644 --- a/src/accounts/xmpp/sip/XmppSip.cpp +++ b/src/accounts/xmpp/sip/XmppSip.cpp @@ -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(); } diff --git a/src/libtomahawk/TomahawkSettings.cpp b/src/libtomahawk/TomahawkSettings.cpp index 405df9411..d70d07357 100644 --- a/src/libtomahawk/TomahawkSettings.cpp +++ b/src/libtomahawk/TomahawkSettings.cpp @@ -616,6 +616,8 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion ) qDebug() << "Migrating account credentials for account:" << account; } + remove( "credentials" ); + endGroup(); } } diff --git a/src/libtomahawk/accounts/Account.cpp b/src/libtomahawk/accounts/Account.cpp index be93ef641..3888b2e63 100644 --- a/src/libtomahawk/accounts/Account.cpp +++ b/src/libtomahawk/accounts/Account.cpp @@ -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 ) ) { diff --git a/src/libtomahawk/accounts/Account.h b/src/libtomahawk/accounts/Account.h index 1ff2e9d59..60bb43401 100644 --- a/src/libtomahawk/accounts/Account.h +++ b/src/libtomahawk/accounts/Account.h @@ -146,7 +146,7 @@ signals: void configurationChanged(); - void credentialsChanged( const QVariantHash& credentials ); + void credentialsLoaded( const QVariantHash& credentials ); protected: virtual void loadFromConfig( const QString &accountId ); diff --git a/src/libtomahawk/accounts/lastfm/LastFmAccount.cpp b/src/libtomahawk/accounts/lastfm/LastFmAccount.cpp index eb8e08006..15a26f551 100644 --- a/src/libtomahawk/accounts/lastfm/LastFmAccount.cpp +++ b/src/libtomahawk/accounts/lastfm/LastFmAccount.cpp @@ -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() ) diff --git a/src/libtomahawk/accounts/lastfm/LastFmAccount.h b/src/libtomahawk/accounts/lastfm/LastFmAccount.h index 478f4fcc7..9ab75d6b1 100644 --- a/src/libtomahawk/accounts/lastfm/LastFmAccount.h +++ b/src/libtomahawk/accounts/lastfm/LastFmAccount.h @@ -101,7 +101,7 @@ private slots: void resolverChanged(); - void onCredentialsChanged( const QVariantHash& credentials ); + void onCredentialsLoaded( const QVariantHash& credentials ); private: void hookupResolver(); diff --git a/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp b/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp index d661fd09f..7511f55b6 100644 --- a/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp +++ b/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp @@ -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 ); } diff --git a/src/libtomahawk/accounts/spotify/SpotifyAccount.h b/src/libtomahawk/accounts/spotify/SpotifyAccount.h index cc1a490ce..427156a1f 100644 --- a/src/libtomahawk/accounts/spotify/SpotifyAccount.h +++ b/src/libtomahawk/accounts/spotify/SpotifyAccount.h @@ -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 );