diff --git a/oauth/kqoauthauthreplyserver.cpp b/oauth/kqoauthauthreplyserver.cpp index 30f25de..5c55edd 100644 --- a/oauth/kqoauthauthreplyserver.cpp +++ b/oauth/kqoauthauthreplyserver.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "kqoauthauthreplyserver.h" #include "kqoauthauthreplyserver_p.h" @@ -103,7 +104,8 @@ QMultiMap KQOAuthAuthReplyServerPrivate::parseQueryParams(QByt splitGetLine.prepend("http://localhost"); // Now, make it a URL QUrl getTokenUrl(splitGetLine); - QList< QPair > tokens = getTokenUrl.queryItems(); // Ask QUrl to do our work. + QUrlQuery qry(getTokenUrl); + QList< QPair > tokens = qry.queryItems(); QMultiMap queryParams; QPair tokenPair; diff --git a/oauth/kqoauthmanager.cpp b/oauth/kqoauthmanager.cpp index 4471a50..b31d65b 100644 --- a/oauth/kqoauthmanager.cpp +++ b/oauth/kqoauthmanager.cpp @@ -22,10 +22,10 @@ * along with KQOAuth. If not, see */ #include +#include #include "kqoauthmanager.h" #include "kqoauthmanager_p.h" -#include "bps/navigator.h" ////////////// Private d_ptr implementation //////////////// @@ -219,7 +219,9 @@ void KQOAuthManager::executeRequest(KQOAuthRequest *request) { // Take the original URL and append the query params to it. QUrl urlWithParams = networkRequest.url(); - urlWithParams.setQueryItems(urlParams); + QUrlQuery qry; + qry.setQueryItems(urlParams); + urlWithParams.setQuery(qry); networkRequest.setUrl(urlWithParams); // Submit the request including the params. @@ -333,7 +335,9 @@ void KQOAuthManager::executeAuthorizedRequest(KQOAuthRequest *request, int id) { // Take the original URL and append the query params to it. QUrl urlWithParams = networkRequest.url(); - urlWithParams.setQueryItems(urlParams); + QUrlQuery qry; + qry.setQueryItems(urlParams); + urlWithParams.setQuery(qry); networkRequest.setUrl(urlWithParams); qDebug() << networkRequest.url(); @@ -454,17 +458,20 @@ void KQOAuthManager::getOauth2UserAuthorization(QUrl authorizationEndpoint, QStr QString serverString = "http://localhost:"; serverString.append(QString::number(d->callbackServer->serverPort())); QUrl openWebPageUrl(authorizationEndpoint.toString(), QUrl::StrictMode); - openWebPageUrl.addQueryItem(OAUTH2_KEY_CLIENT_ID, consumerKey); - openWebPageUrl.addQueryItem(OAUTH2_KEY_RESPONSE_TYPE, "token"); - openWebPageUrl.addQueryItem(OAUTH2_KEY_REDIRECT_URI, serverString); + QUrlQuery qry; + qry.addQueryItem(OAUTH2_KEY_CLIENT_ID, consumerKey); + qry.addQueryItem(OAUTH2_KEY_RESPONSE_TYPE, "token"); + qry.addQueryItem(OAUTH2_KEY_REDIRECT_URI, serverString); if(additionalParams.size() > 0) { QList< QPair > urlParams = d->createQueryParams(additionalParams); for(int i=0; i < urlParams.length(); i++){ - openWebPageUrl.addQueryItem(urlParams[i].first, urlParams[i].second); + qry.addQueryItem(urlParams[i].first, urlParams[i].second); } } + openWebPageUrl.setQuery(qry); qDebug() << openWebPageUrl.toString(); - navigator_invoke(openWebPageUrl.toString().toStdString().c_str(),0); +// navigator_invoke(openWebPageUrl.toString().toStdString().c_str(),0); + emit openBrowser(openWebPageUrl); } QUrl KQOAuthManager::getUserAuthorizationUrl(QUrl authorizationEndpoint) { @@ -486,7 +493,9 @@ QUrl KQOAuthManager::getUserAuthorizationUrl(QUrl authorizationEndpoint) { QPair tokenParam = qMakePair(QString("oauth_token"), QString(d->requestToken)); QUrl openWebPageUrl(authorizationEndpoint.toString(), QUrl::StrictMode); - openWebPageUrl.addQueryItem(tokenParam.first, tokenParam.second); + QUrlQuery qry; + qry.addQueryItem(tokenParam.first, tokenParam.second); + openWebPageUrl.setQuery(qry); qDebug() << openWebPageUrl.toString(); return openWebPageUrl; @@ -499,7 +508,8 @@ void KQOAuthManager::getUserAuthorization(QUrl authorizationEndpoint) { // Open the user's default browser to the resource authorization page provided // by the service. - navigator_invoke(openWebPageUrl.toString().toStdString().c_str(),0); +// navigator_invoke(openWebPageUrl.toString().toStdString().c_str(),0); + emit openBrowser(openWebPageUrl); } } diff --git a/oauth/kqoauthmanager.h b/oauth/kqoauthmanager.h index 6778626..30af718 100644 --- a/oauth/kqoauthmanager.h +++ b/oauth/kqoauthmanager.h @@ -187,6 +187,8 @@ Q_SIGNALS: // This ends the kQOAuth interactions. void authorizedRequestDone(); + void openBrowser(QUrl url); + private Q_SLOTS: void onRequestReplyReceived( QNetworkReply *reply ); void onAuthorizedRequestReplyReceived( QNetworkReply *reply ); diff --git a/oauth/kqoauthutils.cpp b/oauth/kqoauthutils.cpp index d021385..70e80ad 100644 --- a/oauth/kqoauthutils.cpp +++ b/oauth/kqoauthutils.cpp @@ -30,7 +30,7 @@ QString KQOAuthUtils::hmac_sha1(const QString &message, const QString &key) { - QByteArray keyBytes = key.toAscii(); + QByteArray keyBytes = key.toLatin1(); int keyLength; // Lenght of key word const int blockSize = 64; // Both MD5 and SHA-1 have a block size of 64. @@ -64,7 +64,7 @@ QString KQOAuthUtils::hmac_sha1(const QString &message, const QString &key) workArray.append(ipad, 64); /* http://tools.ietf.org/html/rfc2104 - (3) */ - workArray.append(message.toAscii()); + workArray.append(message.toLatin1()); /* http://tools.ietf.org/html/rfc2104 - (4) */ diff --git a/oauth/src.pri b/oauth/src.pri new file mode 100644 index 0000000..c05ce9c --- /dev/null +++ b/oauth/src.pri @@ -0,0 +1,27 @@ +QT *= network + +INCLUDEPATH += $$PWD + +SOURCES += \ + $$PWD/kqoauth2request.cpp \ + $$PWD/kqoauthauthreplyserver.cpp \ + $$PWD/kqoauthmanager.cpp \ + $$PWD/kqoauthrequest_1.cpp \ + $$PWD/kqoauthrequest.cpp \ + $$PWD/kqoauthrequest_xauth.cpp \ + $$PWD/kqoauthutils.cpp + +HEADERS += \ + $$PWD/kqoauth2request.h \ + $$PWD/kqoauth2request_p.h \ + $$PWD/kqoauthauthreplyserver.h \ + $$PWD/kqoauthauthreplyserver_p.h \ + $$PWD/kqoauthglobals.h \ + $$PWD/kqoauthmanager.h \ + $$PWD/kqoauthmanager_p.h \ + $$PWD/kqoauthrequest_1.h \ + $$PWD/kqoauthrequest.h \ + $$PWD/kqoauthrequest_p.h \ + $$PWD/kqoauthrequest_xauth.h \ + $$PWD/kqoauthrequest_xauth_p.h \ + $$PWD/kqoauthutils.h