From 3999a98514da2e79a3c8dbe7c54e10cf034f7074 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Sun, 10 Jun 2012 11:28:28 +0200 Subject: [PATCH] Only connect XMPP plugin when credentials are loaded --- src/accounts/xmpp/XmppAccount.cpp | 4 +++- src/accounts/xmpp/XmppAccount.h | 1 + src/accounts/xmpp/sip/XmppSip.cpp | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/accounts/xmpp/XmppAccount.cpp b/src/accounts/xmpp/XmppAccount.cpp index d205b78fd..d84c6dae5 100644 --- a/src/accounts/xmpp/XmppAccount.cpp +++ b/src/accounts/xmpp/XmppAccount.cpp @@ -40,6 +40,7 @@ XmppAccountFactory::createAccount( const QString& accountId ) XmppAccount::XmppAccount( const QString &accountId ) : Account( accountId ) + , m_credentialsLoading( true ) { connect( this, SIGNAL( credentialsLoaded( QVariantHash ) ), this, SLOT( onCredentialsLoaded( QVariantHash ) ) ); @@ -59,7 +60,7 @@ XmppAccount::~XmppAccount() void XmppAccount::authenticate() { - if ( connectionState() != Account::Connected ) + if ( connectionState() != Account::Connected && !m_credentialsLoading ) sipPlugin()->connectPlugin(); } @@ -96,6 +97,7 @@ void XmppAccount::onCredentialsLoaded( const QVariantHash& credentials ) { m_credentials = credentials; + m_credentialsLoading = false; if ( !m_xmppSipPlugin.isNull() ) m_xmppSipPlugin.data()->configurationChanged(); } diff --git a/src/accounts/xmpp/XmppAccount.h b/src/accounts/xmpp/XmppAccount.h index 1d8f120b6..3b8702122 100644 --- a/src/accounts/xmpp/XmppAccount.h +++ b/src/accounts/xmpp/XmppAccount.h @@ -91,6 +91,7 @@ protected: QWeakPointer< Tomahawk::InfoSystem::XmppInfoPlugin > m_xmppInfoPlugin; QVariantHash m_credentials; + bool m_credentialsLoading; }; }; diff --git a/src/accounts/xmpp/sip/XmppSip.cpp b/src/accounts/xmpp/sip/XmppSip.cpp index 754c5360d..e993e120f 100644 --- a/src/accounts/xmpp/sip/XmppSip.cpp +++ b/src/accounts/xmpp/sip/XmppSip.cpp @@ -581,6 +581,7 @@ XmppSipPlugin::configurationChanged() server = readServer(); port = readPort(); + qDebug() << Q_FUNC_INFO << "Configuration changed in SIP plugin:" << username << password << server << port << m_account->accountFriendlyName(); if ( m_currentUsername != username ) { m_currentUsername = username; @@ -610,6 +611,8 @@ XmppSipPlugin::configurationChanged() m_xmppAccount->saveCredentials( credentials ); } + + qDebug() << Q_FUNC_INFO << "reconnecting?" << reconnect << "enabled?" << m_account->enabled() << m_account->accountFriendlyName(); if ( reconnect ) setupClientHelper();