diff --git a/src/services/CMakeLists.txt b/src/services/CMakeLists.txt
--- a/src/services/CMakeLists.txt
+++ b/src/services/CMakeLists.txt
@@ -17,7 +17,7 @@
endif()
if( LIBLASTFM_FOUND )
-# add_subdirectory( lastfm ) // Needs more work
+ add_subdirectory( lastfm )
endif()
add_subdirectory( opmldirectory )
diff --git a/src/services/lastfm/AvatarDownloader.cpp b/src/services/lastfm/AvatarDownloader.cpp
--- a/src/services/lastfm/AvatarDownloader.cpp
+++ b/src/services/lastfm/AvatarDownloader.cpp
@@ -38,7 +38,8 @@
m_userAvatarUrls.insert( url, username );
The::networkAccessManager()->getData( url, this,
- SLOT(downloaded(QUrl,QByteArray,NetworkAccessManagerProxy::Error)) );
+ &AvatarDownloader::downloaded);
+
}
void
diff --git a/src/services/lastfm/LastFmConfigWidget.ui b/src/services/lastfm/LastFmConfigWidget.ui
--- a/src/services/lastfm/LastFmConfigWidget.ui
+++ b/src/services/lastfm/LastFmConfigWidget.ui
@@ -7,7 +7,7 @@
0
0
450
- 460
+ 416
@@ -17,9 +17,31 @@
-
+
0
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 0
+ 0
+
+
+
+
-
@@ -91,26 +113,6 @@
- -
-
-
- Why not join the <a href="http://www.last.fm:80/group/Amarok+Users">Amarok Last.fm group</a> and share your musical tastes with other Amarok users?
-
-
- true
-
-
- true
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
-
@@ -200,6 +202,12 @@
Qt::Horizontal
+
+
+ 0
+ 0
+
+
@@ -210,13 +218,6 @@
-
-
- QLineEdit
- QLineEdit
-
-
-
kcfg_ScrobblerUsername
kcfg_ScrobblerPassword
diff --git a/src/services/lastfm/LastFmService.cpp b/src/services/lastfm/LastFmService.cpp
--- a/src/services/lastfm/LastFmService.cpp
+++ b/src/services/lastfm/LastFmService.cpp
@@ -54,12 +54,6 @@
#include
-QString md5( const QByteArray& src )
-{
- QByteArray const digest = QCryptographicHash::hash( src, QCryptographicHash::Md5 );
- return QString::fromLatin1( digest.toHex() ).rightJustified( 32, '0' );
-}
-
LastFmServiceFactory::LastFmServiceFactory()
: ServiceFactory()
{}
@@ -115,6 +109,9 @@
lastfm::ws::ApiKey = Amarok::lastfmApiKey();
lastfm::ws::SharedSecret = Amarok::lastfmApiSharedSecret();
+ // HTTPS is the only scheme supported by Auth
+ lastfm::ws::setScheme(lastfm::ws::Https);
+
// set the nam TWICE. Yes. It prevents liblastfm from deleting it, see their code
lastfm::setNetworkAccessManager( The::networkAccessManager() );
lastfm::setNetworkAccessManager( The::networkAccessManager() );
@@ -207,12 +204,10 @@
m_authenticateReply = 0;
}
- const QString authToken = md5( QString( "%1%2" ).arg( m_config->username(),
- md5( m_config->password().toUtf8() ) ).toUtf8() );
QMap query;
query[ "method" ] = "auth.getMobileSession";
+ query[ "password" ] = m_config->password();
query[ "username" ] = m_config->username();
- query[ "authToken" ] = authToken;
m_authenticateReply = lastfm::ws::post( query );
connect( m_authenticateReply, &QNetworkReply::finished, this, &LastFmService::onAuthenticated ); // calls continueReconfiguring()
}
diff --git a/src/services/lastfm/LastFmServiceCollection.h b/src/services/lastfm/LastFmServiceCollection.h
--- a/src/services/lastfm/LastFmServiceCollection.h
+++ b/src/services/lastfm/LastFmServiceCollection.h
@@ -45,15 +45,11 @@
virtual QueryMaker* queryMaker();
private Q_SLOTS:
- void slotAddNeighboursLoved();
- void slotAddNeighboursPersonal();
void slotAddFriendsLoved();
void slotAddFriendsPersonal();
private:
QMap< QString, QNetworkReply* > m_jobs;
- Meta::ServiceGenre *m_neighborsLoved;
- Meta::ServiceGenre *m_neighborsPersonal;
Meta::ServiceGenre *m_friendsLoved;
Meta::ServiceGenre *m_friendsPersonal;
};
diff --git a/src/services/lastfm/LastFmServiceCollection.cpp b/src/services/lastfm/LastFmServiceCollection.cpp
--- a/src/services/lastfm/LastFmServiceCollection.cpp
+++ b/src/services/lastfm/LastFmServiceCollection.cpp
@@ -37,14 +37,6 @@
Meta::GenrePtr globalTagsPtr( globalTags );
addGenre( globalTagsPtr );
- m_neighborsLoved = new Meta::ServiceGenre( i18n( "Neighbors' Loved Radio" ) );
- Meta::GenrePtr neighborsLovedPtr( m_neighborsLoved );
- addGenre( neighborsLovedPtr );
-
- m_neighborsPersonal = new Meta::ServiceGenre( i18n( "Neighbors' Personal Radio" ) );
- Meta::GenrePtr neighborsPersonalPtr( m_neighborsPersonal );
- addGenre( neighborsPersonalPtr );
-
m_friendsLoved = new Meta::ServiceGenre( i18n( "Friends' Loved Radio" ) );
Meta::GenrePtr friendsLovedPtr( m_friendsLoved );
addGenre( friendsLovedPtr );
@@ -55,7 +47,7 @@
// Only show these if the user is a subscriber.
QStringList lastfmPersonal;
- lastfmPersonal << "personal" << "recommended" << "loved" << "neighbours";
+ lastfmPersonal << "personal" << "recommended" << "loved";
foreach( const QString &station, lastfmPersonal )
{
@@ -81,15 +73,8 @@
}
QMap< QString, QString > params;
- params[ "method" ] = "user.getNeighbours";
- params[ "user" ] = userName;
- m_jobs[ "user.getNeighbours" ] = lastfm::ws::post( params );
-
- connect( m_jobs[ "user.getNeighbours" ], &QNetworkReply::finished, this, &LastFmServiceCollection::slotAddNeighboursLoved );
- //connect( m_jobs[ "user.getNeighbours" ], &QNetworkReply::finished, this, &LastFmServiceCollection::slotAddNeighboursPersonal );
- // TODO TMP HACK why do i get exceptions there...!?
-
params[ "method" ] = "user.getFriends";
+ params[ "user" ] = userName;
m_jobs[ "user.getFriends" ] = lastfm::ws::post( params );
connect( m_jobs[ "user.getFriends" ], &QNetworkReply::finished, this, &LastFmServiceCollection::slotAddFriendsLoved );
@@ -130,101 +115,6 @@
return i18n( "Last.fm" );
}
-void LastFmServiceCollection::slotAddNeighboursLoved()
-{
- DEBUG_BLOCK
- if( !m_jobs[ "user.getNeighbours" ] )
- {
- debug() << "BAD! got no result object";
- return;
- }
- switch (m_jobs[ "user.getNeighbours" ]->error())
- {
- case QNetworkReply::NoError:
- {
- // iterate through each neighbour
- lastfm::XmlQuery lfm;
- if( lfm.parse( m_jobs[ "user.getNeighbours" ]->readAll() ) )
- {
- foreach( const lastfm::XmlQuery &e, lfm[ "neighbours" ].children( "user" ) )
- {
- const QString name = e[ "name" ].text();
- //debug() << "got neighbour!!! - " << name;
- LastFm::Track *track = new LastFm::Track( "lastfm://user/" + name + "/loved" );
- Meta::TrackPtr trackPtr( track );
- m_neighborsLoved->addTrack( trackPtr );
- addTrack( trackPtr );
- }
-
- }
- else
- {
- debug() << "Got exception in parsing from last.fm:" << lfm.parseError().message();
- }
- break;
- }
-
- case QNetworkReply::AuthenticationRequiredError:
- debug() << "Last.fm: errorMessage: Sorry, we don't recognise that username, or you typed the password incorrectly.";
- break;
-
- default:
- debug() << "Last.fm: errorMessage: There was a problem communicating with the Last.fm services. Please try again later.";
- break;
- }
-
- m_jobs[ "user.getNeighbours" ]->deleteLater();
-}
-
-void LastFmServiceCollection::slotAddNeighboursPersonal()
-{
- DEBUG_BLOCK
- switch (m_jobs[ "user.getNeighbours" ]->error())
- {
- case QNetworkReply::NoError:
- {
- // iterate through each neighbour
- if( !m_jobs[ "user.getNeighbours" ] )
- {
- debug() << "BAD! got no result object";
- return;
- }
- lastfm::XmlQuery lfm;
- if( lfm.parse( m_jobs[ "user.getNeighbours" ]->readAll() ) )
- {
- // iterate through each neighbour
- foreach( const lastfm::XmlQuery &e, lfm[ "neighbours" ].children( "user" ) )
- {
- const QString name = e[ "name" ].text();
- debug() << "got neighbour!!! - " << name;
- LastFm::Track *track = new LastFm::Track( "lastfm://user/" + name + "/personal" );
- Meta::TrackPtr trackPtr( track );
- m_neighborsPersonal->addTrack( trackPtr );
- addTrack( trackPtr );
- }
-
-
- // should be safe, as both slots SHOULD get called before we return to the event loop...
- m_jobs[ "user.getNeighbours" ]->deleteLater();
- }
- else
- {
- debug() << "Got exception in parsing from last.fm:" << lfm.parseError().message();
- }
- break;
- }
-
- case QNetworkReply::AuthenticationRequiredError:
- debug() << "Last.fm: errorMessage: Sorry, we don't recognise that username, or you typed the password incorrectly.";
- break;
-
- default:
- debug() << "Last.fm: errorMessage: There was a problem communicating with the Last.fm services. Please try again later.";
- break;
- }
-
-}
-
void LastFmServiceCollection::slotAddFriendsLoved()
{
DEBUG_BLOCK
diff --git a/src/services/lastfm/LastFmServiceConfig.h b/src/services/lastfm/LastFmServiceConfig.h
--- a/src/services/lastfm/LastFmServiceConfig.h
+++ b/src/services/lastfm/LastFmServiceConfig.h
@@ -18,8 +18,6 @@
#ifndef LASTFMSERVICECONFIG_H
#define LASTFMSERVICECONFIG_H
-#include "services/lastfm/amarok_lastfm_shared_export.h"
-
#include
#include
#include
@@ -31,6 +29,12 @@
class LastFmServiceConfig;
typedef QSharedPointer LastFmServiceConfigPtr;
+#ifdef AMAROK_LASTFM_SHARED_EXPORT
+ #define AMAROK_LASTFM_SHARED_EXPORT Q_DECL_EXPORT
+#else
+ #define AMAROK_LASTFM_SHARED_EXPORT Q_DECL_IMPORT
+#endif
+
/**
* Configuration of the Last.fm plugin. Because some operations are async, you should
* connect to the updated() signal and listen to changes, especially ones to username,
diff --git a/src/services/lastfm/LastFmServiceSettings.h b/src/services/lastfm/LastFmServiceSettings.h
--- a/src/services/lastfm/LastFmServiceSettings.h
+++ b/src/services/lastfm/LastFmServiceSettings.h
@@ -25,6 +25,8 @@
#include
+#include
+
namespace Ui { class LastFmConfigWidget; }
class LastFmServiceSettings : public KCModule
diff --git a/src/services/lastfm/LastFmServiceSettings.cpp b/src/services/lastfm/LastFmServiceSettings.cpp
--- a/src/services/lastfm/LastFmServiceSettings.cpp
+++ b/src/services/lastfm/LastFmServiceSettings.cpp
@@ -37,13 +37,6 @@
K_PLUGIN_FACTORY_WITH_JSON( LastFmServiceSettingsFactory, "amarok_service_lastfm_config.json", registerPlugin(); )
-QString md5( const QByteArray& src )
-{
- QByteArray const digest = QCryptographicHash::hash( src, QCryptographicHash::Md5 );
- return QString::fromLatin1( digest.toHex() ).rightJustified( 32, '0' );
-}
-
-
LastFmServiceSettings::LastFmServiceSettings( QWidget *parent, const QVariantList &args )
: KCModule( parent, args )
, m_config( LastFmServiceConfig::instance() )
@@ -110,20 +103,17 @@
// set the global static Lastfm::Ws stuff
lastfm::ws::ApiKey = Amarok::lastfmApiKey();
lastfm::ws::SharedSecret = Amarok::lastfmApiSharedSecret();
- lastfm::ws::Username = m_configDialog->kcfg_ScrobblerUsername->text();
+ lastfm::ws::setScheme(lastfm::ws::Https);
if( lastfm::nam() != The::networkAccessManager() )
lastfm::setNetworkAccessManager( The::networkAccessManager() );
- debug() << "username:" << QString( QUrl::toPercentEncoding( lastfm::ws::Username ) );
-
- const QString authToken = md5( QString( "%1%2" ).arg( m_configDialog->kcfg_ScrobblerUsername->text() )
- .arg( md5( m_configDialog->kcfg_ScrobblerPassword->text().toUtf8() ) ).toUtf8() );
+ debug() << "username:" << QString( QUrl::toPercentEncoding( m_configDialog->kcfg_ScrobblerUsername->text().toUtf8() ) );
- // now authenticate w/ last.fm and get our session key
QMap query;
+
query[ "method" ] = "auth.getMobileSession";
- query[ "username" ] = m_configDialog->kcfg_ScrobblerUsername->text();
- query[ "authToken" ] = authToken;
+ query[ "password" ] = m_configDialog->kcfg_ScrobblerPassword->text().toUtf8();
+ query[ "username" ] = m_configDialog->kcfg_ScrobblerUsername->text().toUtf8();
m_authQuery = lastfm::ws::post( query );
connect( m_authQuery, &QNetworkReply::finished, this, &LastFmServiceSettings::onAuthenticated );
diff --git a/src/services/lastfm/meta/LastFmMultiPlayableCapability.h b/src/services/lastfm/meta/LastFmMultiPlayableCapability.h
--- a/src/services/lastfm/meta/LastFmMultiPlayableCapability.h
+++ b/src/services/lastfm/meta/LastFmMultiPlayableCapability.h
@@ -19,6 +19,7 @@
#include "core/support/Components.h"
#include "core/support/Debug.h"
+#include "core/logger/Logger.h"
#include "MainWindow.h"
#include "LastFmMeta.h"
#include "core/meta/forward_declarations.h"