mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-10 08:04:25 +02:00
Merge pull request #142 from luisgabriel/master
Checking the reply status during the last.fm authentication process
This commit is contained in:
@@ -941,30 +941,29 @@ LastFmInfoPlugin::onAuthenticated()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( authJob->error() == QNetworkReply::NoError )
|
lastfm::XmlQuery lfm;
|
||||||
|
lfm.parse( authJob->readAll() );
|
||||||
|
if ( authJob->error() == QNetworkReply::NoError && lfm.attribute("status") == "ok" )
|
||||||
{
|
{
|
||||||
lastfm::XmlQuery lfm;
|
lastfm::ws::SessionKey = lfm[ "session" ][ "key" ].text();
|
||||||
lfm.parse( authJob->readAll() );
|
m_account.data()->setSessionKey( lastfm::ws::SessionKey.toLatin1() );
|
||||||
|
|
||||||
if ( lfm.children( "error" ).size() > 0 )
|
if ( m_account.data()->scrobble() )
|
||||||
{
|
m_scrobbler = new lastfm::Audioscrobbler( "thk" );
|
||||||
tLog() << "Error from authenticating with Last.fm service:" << lfm.text();
|
|
||||||
m_account.data()->setSessionKey( QByteArray() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lastfm::ws::SessionKey = lfm[ "session" ][ "key" ].text();
|
|
||||||
|
|
||||||
m_account.data()->setSessionKey( lastfm::ws::SessionKey.toLatin1() );
|
|
||||||
|
|
||||||
// qDebug() << "Got session key from last.fm";
|
|
||||||
if ( m_account.data()->scrobble() )
|
|
||||||
m_scrobbler = new lastfm::Audioscrobbler( "thk" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tLog() << "Got error in Last.fm authentication job:" << authJob->errorString();
|
m_account.data()->setSessionKey( QByteArray() );
|
||||||
|
|
||||||
|
QString error = "Got error in Last.fm authentication job";
|
||||||
|
if ( lfm.children( "error" ).size() > 0 )
|
||||||
|
error += ": " + lfm.text();
|
||||||
|
else if ( authJob->error() != QNetworkReply::NoError )
|
||||||
|
error += ": " + authJob->errorString();
|
||||||
|
else
|
||||||
|
error += ".";
|
||||||
|
|
||||||
|
tLog() << error.simplified();
|
||||||
}
|
}
|
||||||
|
|
||||||
authJob->deleteLater();
|
authJob->deleteLater();
|
||||||
|
Reference in New Issue
Block a user