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