Changeset View
Changeset View
Standalone View
Standalone View
src/services/lastfm/LastFmServiceSettings.cpp
Context not available. | |||||
37 | 37 | | |||
---|---|---|---|---|---|
38 | K_PLUGIN_FACTORY_WITH_JSON( LastFmServiceSettingsFactory, "amarok_service_lastfm_config.json", registerPlugin<LastFmServiceSettings>(); ) | 38 | K_PLUGIN_FACTORY_WITH_JSON( LastFmServiceSettingsFactory, "amarok_service_lastfm_config.json", registerPlugin<LastFmServiceSettings>(); ) | ||
39 | 39 | | |||
40 | QString md5( const QByteArray& src ) | | |||
41 | { | | |||
42 | QByteArray const digest = QCryptographicHash::hash( src, QCryptographicHash::Md5 ); | | |||
43 | return QString::fromLatin1( digest.toHex() ).rightJustified( 32, '0' ); | | |||
44 | } | | |||
45 | | ||||
46 | | ||||
47 | LastFmServiceSettings::LastFmServiceSettings( QWidget *parent, const QVariantList &args ) | 40 | LastFmServiceSettings::LastFmServiceSettings( QWidget *parent, const QVariantList &args ) | ||
48 | : KCModule( parent, args ) | 41 | : KCModule( parent, args ) | ||
49 | , m_config( LastFmServiceConfig::instance() ) | 42 | , m_config( LastFmServiceConfig::instance() ) | ||
Context not available. | |||||
110 | // set the global static Lastfm::Ws stuff | 103 | // set the global static Lastfm::Ws stuff | ||
111 | lastfm::ws::ApiKey = Amarok::lastfmApiKey(); | 104 | lastfm::ws::ApiKey = Amarok::lastfmApiKey(); | ||
112 | lastfm::ws::SharedSecret = Amarok::lastfmApiSharedSecret(); | 105 | lastfm::ws::SharedSecret = Amarok::lastfmApiSharedSecret(); | ||
113 | lastfm::ws::Username = m_configDialog->kcfg_ScrobblerUsername->text(); | 106 | lastfm::ws::setScheme(lastfm::ws::Https); | ||
114 | if( lastfm::nam() != The::networkAccessManager() ) | 107 | if( lastfm::nam() != The::networkAccessManager() ) | ||
115 | lastfm::setNetworkAccessManager( The::networkAccessManager() ); | 108 | lastfm::setNetworkAccessManager( The::networkAccessManager() ); | ||
116 | 109 | | |||
117 | debug() << "username:" << QString( QUrl::toPercentEncoding( lastfm::ws::Username ) ); | 110 | debug() << "username:" << QString( QUrl::toPercentEncoding( m_configDialog->kcfg_ScrobblerUsername->text().toUtf8() ) ); | ||
118 | | ||||
119 | const QString authToken = md5( QString( "%1%2" ).arg( m_configDialog->kcfg_ScrobblerUsername->text() ) | | |||
120 | .arg( md5( m_configDialog->kcfg_ScrobblerPassword->text().toUtf8() ) ).toUtf8() ); | | |||
121 | 111 | | |||
122 | // now authenticate w/ last.fm and get our session key | | |||
123 | QMap<QString, QString> query; | 112 | QMap<QString, QString> query; | ||
113 | | ||||
124 | query[ "method" ] = "auth.getMobileSession"; | 114 | query[ "method" ] = "auth.getMobileSession"; | ||
125 | query[ "username" ] = m_configDialog->kcfg_ScrobblerUsername->text(); | 115 | query[ "password" ] = m_configDialog->kcfg_ScrobblerPassword->text().toUtf8(); | ||
126 | query[ "authToken" ] = authToken; | 116 | query[ "username" ] = m_configDialog->kcfg_ScrobblerUsername->text().toUtf8(); | ||
127 | m_authQuery = lastfm::ws::post( query ); | 117 | m_authQuery = lastfm::ws::post( query ); | ||
128 | 118 | | |||
129 | connect( m_authQuery, &QNetworkReply::finished, this, &LastFmServiceSettings::onAuthenticated ); | 119 | connect( m_authQuery, &QNetworkReply::finished, this, &LastFmServiceSettings::onAuthenticated ); | ||
Context not available. |