mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-19 15:29:42 +01:00
Merge pull request #221 from tomahawk-player/hatchet-qt5-qurl
Handle QUrls in Hatchet unified for Qt4+5
This commit is contained in:
commit
15cb87048a
@ -271,13 +271,13 @@ HatchetAccount::loginWithPassword( const QString& username, const QString& passw
|
||||
req.setHeader( QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded" );
|
||||
|
||||
QUrl params;
|
||||
params.addQueryItem( "username", username );
|
||||
params.addQueryItem( "password", password );
|
||||
params.addQueryItem( "grant_type", "password" );
|
||||
TomahawkUtils::urlAddQueryItem( params, "username", username );
|
||||
TomahawkUtils::urlAddQueryItem( params, "password", password );
|
||||
TomahawkUtils::urlAddQueryItem( params, "grant_type", "password" );
|
||||
if ( !otp.isEmpty() )
|
||||
params.addQueryItem( "otp", otp );
|
||||
TomahawkUtils::urlAddQueryItem( params, "otp", otp );
|
||||
|
||||
QByteArray data = params.encodedQuery();
|
||||
QByteArray data = TomahawkUtils::encodedQuery( params );
|
||||
|
||||
QNetworkReply* reply = Tomahawk::Utils::nam()->post( req, data );
|
||||
|
||||
@ -325,9 +325,9 @@ HatchetAccount::fetchAccessToken( const QString& type )
|
||||
tLog() << "Intercepting; new mandella access token needed";
|
||||
req.setHeader( QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded" );
|
||||
QUrl params;
|
||||
params.addQueryItem( "grant_type", "refresh_token" );
|
||||
params.addQueryItem( "refresh_token", refreshToken() );
|
||||
QByteArray data = params.encodedQuery();
|
||||
TomahawkUtils::urlAddQueryItem( params, "grant_type", "refresh_token" );
|
||||
TomahawkUtils::urlAddQueryItem( params, "refresh_token", refreshToken() );
|
||||
QByteArray data = TomahawkUtils::encodedQuery( params );
|
||||
reply = Tomahawk::Utils::nam()->post( req, data );
|
||||
reply->setProperty( "originalType", type );
|
||||
}
|
||||
|
@ -904,4 +904,14 @@ percentEncode( const QUrl& url )
|
||||
return data;
|
||||
}
|
||||
|
||||
QByteArray
|
||||
encodedQuery( const QUrl& url )
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
return url.query(QUrl::FullyEncoded).toUtf8();
|
||||
#else
|
||||
return url.encodedQuery();
|
||||
#endif
|
||||
}
|
||||
|
||||
} // ns
|
||||
|
@ -213,6 +213,7 @@ namespace TomahawkUtils
|
||||
DLLEXPORT bool urlHasQueryItem( const QUrl& url, const QString& key );
|
||||
DLLEXPORT QList<QPair<QString, QString> > urlQueryItems( const QUrl& url );
|
||||
DLLEXPORT void urlSetQuery( QUrl& url, const QString& query );
|
||||
DLLEXPORT QByteArray encodedQuery( const QUrl& url );
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user