1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-21 16:29:43 +01:00

recreate scrobbler when changing credentials

This commit is contained in:
Leo Franchi 2012-05-01 20:52:56 -04:00
parent 455d7816e5
commit d30e5df23e
2 changed files with 8 additions and 6 deletions

View File

@ -1,6 +1,7 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2012, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -57,9 +58,6 @@ LastFmPlugin::init()
tDebug() << "Failure: move to the worker thread before running init";
return;
}
// Flush session key cache
// TODO WHY FLUSH
// m_account->setSessionKey( QByteArray() );
lastfm::ws::ApiKey = "7194b85b6d1f424fe1668173a78c0c4a";
lastfm::ws::SharedSecret = "ba80f1df6d27ae63e9cb1d33ccf2052f";
@ -719,7 +717,7 @@ LastFmPlugin::settingsChanged()
{
if ( m_account.isNull() )
return;
if ( !m_scrobbler && m_account.data()->scrobble() )
{ // can simply create the scrobbler
lastfm::ws::Username = m_account.data()->username();
@ -735,6 +733,7 @@ LastFmPlugin::settingsChanged()
else if ( m_account.data()->username() != lastfm::ws::Username ||
m_account.data()->password() != m_pw )
{
qDebug() << "Last.fm credentials changed, re-creating scrobbler";
lastfm::ws::Username = m_account.data()->username();
m_pw = m_account.data()->password();
// credentials have changed, have to re-create scrobbler for them to take effect
@ -744,6 +743,7 @@ LastFmPlugin::settingsChanged()
m_scrobbler = 0;
}
m_account.data()->setSessionKey( QString() );
createScrobbler();
}
}
@ -758,7 +758,7 @@ LastFmPlugin::onAuthenticated()
tLog() << Q_FUNC_INFO << "Help! No longer got a last.fm auth job!";
return;
}
if ( authJob->error() == QNetworkReply::NoError )
{
lastfm::XmlQuery lfm = lastfm::XmlQuery( authJob->readAll() );

View File

@ -1,9 +1,11 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2012, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,