mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-09-09 13:41:18 +02:00
Correctly connect after authing
This commit is contained in:
@@ -307,8 +307,8 @@ HatchetAccount::onPasswordLoginFinished( QNetworkReply* reply, const QString& us
|
||||
|
||||
if ( !authenticationToken.isEmpty() )
|
||||
{
|
||||
// We're succesful! Now log in with our authtoken for access
|
||||
fetchAccessTokens();
|
||||
if ( sipPlugin() )
|
||||
sipPlugin()->connectPlugin();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,6 +316,7 @@ HatchetAccount::onPasswordLoginFinished( QNetworkReply* reply, const QString& us
|
||||
void
|
||||
HatchetAccount::onFetchAccessTokensFinished()
|
||||
{
|
||||
tLog() << Q_FUNC_INFO;
|
||||
QNetworkReply* reply = qobject_cast< QNetworkReply* >( sender() );
|
||||
Q_ASSERT( reply );
|
||||
bool ok;
|
||||
@@ -324,14 +325,14 @@ HatchetAccount::onFetchAccessTokensFinished()
|
||||
{
|
||||
if ( resp["code"].toInt() == 140 )
|
||||
{
|
||||
tLog() << "Expired credentials, need to reauthenticate with password";
|
||||
tLog() << Q_FUNC_INFO << "Expired credentials, need to reauthenticate with password";
|
||||
QVariantHash creds = credentials();
|
||||
creds.remove( "authtoken" );
|
||||
setCredentials( creds );
|
||||
syncConfig();
|
||||
}
|
||||
else
|
||||
tLog() << "Unable to fetch access tokens";
|
||||
tLog() << Q_FUNC_INFO << "Unable to fetch access tokens";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -340,6 +341,8 @@ HatchetAccount::onFetchAccessTokensFinished()
|
||||
setCredentials( creds );
|
||||
syncConfig();
|
||||
|
||||
tLog() << Q_FUNC_INFO << "Access tokens fetched successfully";
|
||||
|
||||
emit accessTokensFetched();
|
||||
}
|
||||
|
||||
@@ -403,8 +406,8 @@ HatchetAccount::parseReply( QNetworkReply* reply, bool& okRet ) const
|
||||
tLog() << "Error from tomahawk server response, or in parsing from json:" << resp.value( "error" ).toString() << resp;
|
||||
}
|
||||
|
||||
tLog() << Q_FUNC_INFO << "Got reply" << resp.keys();
|
||||
tLog() << Q_FUNC_INFO << "Got reply" << resp.values();
|
||||
tLog() << Q_FUNC_INFO << "Got keys" << resp.keys();
|
||||
tLog() << Q_FUNC_INFO << "Got values" << resp.values();
|
||||
okRet = true;
|
||||
return resp;
|
||||
}
|
||||
|
@@ -110,8 +110,10 @@ HatchetSipPlugin::hatchetAccount() const
|
||||
void
|
||||
HatchetSipPlugin::connectPlugin()
|
||||
{
|
||||
tLog() << Q_FUNC_INFO;
|
||||
if ( !m_account->isAuthenticated() )
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "Account not authenticated, not continuing";
|
||||
//FIXME: Prompt user for password?
|
||||
return;
|
||||
}
|
||||
@@ -124,6 +126,7 @@ HatchetSipPlugin::connectPlugin()
|
||||
void
|
||||
HatchetSipPlugin::disconnectPlugin()
|
||||
{
|
||||
tLog() << Q_FUNC_INFO;
|
||||
if ( m_webSocketThreadController && m_webSocketThreadController->isRunning() )
|
||||
emit disconnectWebSocket();
|
||||
else
|
||||
@@ -137,8 +140,12 @@ HatchetSipPlugin::disconnectPlugin()
|
||||
void
|
||||
HatchetSipPlugin::connectWebSocket()
|
||||
{
|
||||
tLog() << Q_FUNC_INFO;
|
||||
if ( m_webSocketThreadController )
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "Already have a thread running, bailing";
|
||||
return;
|
||||
}
|
||||
|
||||
m_webSocketThreadController = QPointer< WebSocketThreadController >( new WebSocketThreadController( this ) );
|
||||
|
||||
|
Reference in New Issue
Block a user