From d30e5df23ea4eab50a57e4b9b3c1703f83474937 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Tue, 1 May 2012 20:52:56 -0400 Subject: [PATCH] recreate scrobbler when changing credentials --- src/accounts/lastfm/LastFmPlugin.cpp | 10 +++++----- src/accounts/lastfm/LastFmPlugin.h | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/accounts/lastfm/LastFmPlugin.cpp b/src/accounts/lastfm/LastFmPlugin.cpp index f9ecc5a72..d49b815c8 100644 --- a/src/accounts/lastfm/LastFmPlugin.cpp +++ b/src/accounts/lastfm/LastFmPlugin.cpp @@ -1,6 +1,7 @@ /* === This file is part of Tomahawk Player - === * * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2012, Leo Franchi * * 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() ); diff --git a/src/accounts/lastfm/LastFmPlugin.h b/src/accounts/lastfm/LastFmPlugin.h index cd60717b4..3f1a22fb1 100644 --- a/src/accounts/lastfm/LastFmPlugin.h +++ b/src/accounts/lastfm/LastFmPlugin.h @@ -1,9 +1,11 @@ /* === This file is part of Tomahawk Player - === * * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2012, Leo Franchi * * 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,