mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-19 23:39:42 +01:00
* DRY: Moved md5() helper method to TomahawkUtils.
This commit is contained in:
parent
6172ef3df4
commit
1b09361c51
@ -26,12 +26,6 @@
|
||||
|
||||
using namespace Tomahawk::InfoSystem;
|
||||
|
||||
static QString
|
||||
md5( const QByteArray& src )
|
||||
{
|
||||
QByteArray const digest = QCryptographicHash::hash( src, QCryptographicHash::Md5 );
|
||||
return QString::fromLatin1( digest.toHex() ).rightJustified( 32, '0' );
|
||||
}
|
||||
|
||||
RoviPlugin::RoviPlugin()
|
||||
: InfoPlugin()
|
||||
@ -191,6 +185,6 @@ QByteArray
|
||||
RoviPlugin::generateSig() const
|
||||
{
|
||||
QByteArray raw = m_apiKey + m_secret + QString::number( QDateTime::currentMSecsSinceEpoch() / 1000 ).toLatin1();
|
||||
return md5( raw ).toLatin1();
|
||||
return TomahawkUtils::md5( raw ).toLatin1();
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
#include <QCryptographicHash>
|
||||
#include <QNetworkConfiguration>
|
||||
#include <QDomElement>
|
||||
|
||||
@ -38,13 +37,6 @@
|
||||
|
||||
using namespace Tomahawk::InfoSystem;
|
||||
|
||||
static QString
|
||||
md5( const QByteArray& src )
|
||||
{
|
||||
QByteArray const digest = QCryptographicHash::hash( src, QCryptographicHash::Md5 );
|
||||
return QString::fromLatin1( digest.toHex() ).rightJustified( 32, '0' );
|
||||
}
|
||||
|
||||
|
||||
LastFmPlugin::LastFmPlugin()
|
||||
: InfoPlugin()
|
||||
@ -429,9 +421,9 @@ LastFmPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSy
|
||||
c[ "id" ] = "chart.getHypedArtists";
|
||||
c[ "label" ] = "Hyped Artists";
|
||||
artist_charts.append( c );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QVariantMap charts;
|
||||
charts.insert( "Tracks", QVariant::fromValue< QList< InfoStringHash > >( track_charts ) );
|
||||
charts.insert( "Artists", QVariant::fromValue< QList< InfoStringHash > >( artist_charts ) );
|
||||
@ -777,7 +769,7 @@ LastFmPlugin::createScrobbler()
|
||||
if( TomahawkSettings::instance()->lastFmSessionKey().isEmpty() ) // no session key, so get one
|
||||
{
|
||||
qDebug() << "LastFmPlugin::createScrobbler Session key is empty";
|
||||
QString authToken = md5( ( lastfm::ws::Username.toLower() + md5( m_pw.toUtf8() ) ).toUtf8() );
|
||||
QString authToken = TomahawkUtils::md5( ( lastfm::ws::Username.toLower() + TomahawkUtils::md5( m_pw.toUtf8() ) ).toUtf8() );
|
||||
|
||||
QMap<QString, QString> query;
|
||||
query[ "method" ] = "auth.getMobileSession";
|
||||
|
@ -27,14 +27,15 @@
|
||||
#include <lastfm/ws.h>
|
||||
#endif
|
||||
|
||||
#include <QtNetwork/QNetworkConfiguration>
|
||||
#include <QtNetwork/QNetworkAccessManager>
|
||||
#include <QtNetwork/QNetworkProxy>
|
||||
#include <QNetworkConfiguration>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkProxy>
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QMutex>
|
||||
#include <QCoreApplication>
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
#include <QMutex>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#include <windows.h>
|
||||
@ -543,14 +544,6 @@ newerVersion( const QString& oldVersion, const QString& newVersion )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
crash()
|
||||
{
|
||||
volatile int* a = (int*)(NULL);
|
||||
*a = 1;
|
||||
}
|
||||
|
||||
|
||||
// taken from util/fileutils.cpp in kdevplatform
|
||||
bool
|
||||
removeDirectory( const QString& dir )
|
||||
@ -584,4 +577,20 @@ quint64 infosystemRequestId()
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
md5( const QByteArray& data )
|
||||
{
|
||||
QByteArray const digest = QCryptographicHash::hash( data, QCryptographicHash::Md5 );
|
||||
return QString::fromLatin1( digest.toHex() ).rightJustified( 32, '0' );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
crash()
|
||||
{
|
||||
volatile int* a = (int*)(NULL);
|
||||
*a = 1;
|
||||
}
|
||||
|
||||
} // ns
|
||||
|
@ -81,16 +81,15 @@ namespace TomahawkUtils
|
||||
DLLEXPORT bool newerVersion( const QString& oldVersion, const QString& newVersion );
|
||||
|
||||
DLLEXPORT NetworkProxyFactory* proxyFactory( bool noMutexLocker = false );
|
||||
DLLEXPORT QNetworkAccessManager* nam();
|
||||
|
||||
DLLEXPORT void setProxyFactory( TomahawkUtils::NetworkProxyFactory* factory, bool noMutexLocker = false );
|
||||
DLLEXPORT QNetworkAccessManager* nam();
|
||||
DLLEXPORT void setNam( QNetworkAccessManager* nam, bool noMutexLocker = false );
|
||||
DLLEXPORT quint64 infosystemRequestId();
|
||||
|
||||
DLLEXPORT void crash();
|
||||
|
||||
DLLEXPORT QString md5( const QByteArray& data );
|
||||
DLLEXPORT bool removeDirectory( const QString& dir );
|
||||
|
||||
DLLEXPORT quint64 infosystemRequestId();
|
||||
DLLEXPORT void crash();
|
||||
}
|
||||
|
||||
#endif // TOMAHAWKUTILS_H
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
#include "utils/tomahawkutilsgui.h"
|
||||
|
||||
#include <QCryptographicHash>
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
@ -59,12 +58,6 @@
|
||||
#include "ui_proxydialog.h"
|
||||
#include "ui_stackedsettingsdialog.h"
|
||||
|
||||
static QString
|
||||
md5( const QByteArray& src )
|
||||
{
|
||||
QByteArray const digest = QCryptographicHash::hash( src, QCryptographicHash::Md5 );
|
||||
return QString::fromLatin1( digest.toHex() ).rightJustified( 32, '0' );
|
||||
}
|
||||
|
||||
SettingsDialog::SettingsDialog( QWidget *parent )
|
||||
: QDialog( parent )
|
||||
@ -409,7 +402,7 @@ SettingsDialog::testLastFmLogin()
|
||||
ui->pushButtonTestLastfmLogin->setEnabled( false );
|
||||
ui->pushButtonTestLastfmLogin->setText( "Testing..." );
|
||||
|
||||
QString authToken = md5( ( ui->lineEditLastfmUsername->text().toLower() + md5( ui->lineEditLastfmPassword->text().toUtf8() ) ).toUtf8() );
|
||||
QString authToken = TomahawkUtils::md5( ( ui->lineEditLastfmUsername->text().toLower() + TomahawkUtils::md5( ui->lineEditLastfmPassword->text().toUtf8() ) ).toUtf8() );
|
||||
|
||||
// now authenticate w/ last.fm and get our session key
|
||||
QMap<QString, QString> query;
|
||||
|
Loading…
x
Reference in New Issue
Block a user