summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilian Wolff <mail@milianw.de>2016-08-21 21:03:09 (GMT)
committerMilian Wolff <mail@milianw.de>2016-08-21 21:03:09 (GMT)
commitd64b70c3e8892b1fe8fd2a81147d29d98985174b (patch)
treef2565826e3493793a69da6513b7f21f2f8bfbc41
parent1a594a71a930aa017280c3adf8681ed203d04c68 (diff)
Use QUrlQuery to fix compile when deprecated features are disabled
Most notably, this uses QUrlQuery to get/set query items. Also, it is now being used to construct the encoded query for POST requests.
-rw-r--r--src/shareserviceurl/shareserviceurlmanager.cpp1
-rw-r--r--src/storageservice/box/boxjob.cpp29
-rw-r--r--src/storageservice/dropbox/dropboxjob.cpp117
-rw-r--r--src/storageservice/dropbox/dropboxjob.h5
-rw-r--r--src/storageservice/hubic/hubicjob.cpp23
-rw-r--r--src/storageservice/webdav/webdavjob.cpp5
-rw-r--r--src/storageservice/yousendit/yousenditjob.cpp46
-rw-r--r--src/translator/googletranslator.cpp1
-rw-r--r--src/util/pimutil.cpp1
9 files changed, 131 insertions, 97 deletions
diff --git a/src/shareserviceurl/shareserviceurlmanager.cpp b/src/shareserviceurl/shareserviceurlmanager.cpp
index f935605..f9b27b3 100644
--- a/src/shareserviceurl/shareserviceurlmanager.cpp
+++ b/src/shareserviceurl/shareserviceurlmanager.cpp
@@ -22,6 +22,7 @@
#include <KLocalizedString>
#include <QMenu>
#include <QDesktopServices>
+#include <QUrlQuery>
using namespace PimCommon;
diff --git a/src/storageservice/box/boxjob.cpp b/src/storageservice/box/boxjob.cpp
index e73a19e..3b19f0c 100644
--- a/src/storageservice/box/boxjob.cpp
+++ b/src/storageservice/box/boxjob.cpp
@@ -26,6 +26,7 @@
#include "pimcommon_debug.h"
#include <QFile>
+#include <QUrlQuery>
using namespace PimCommon;
@@ -72,12 +73,14 @@ void BoxJob::requestTokenAccess()
mError = false;
mActionType = PimCommon::StorageServiceAbstract::RequestTokenAction;
QUrl url(mServiceUrl + mAuthorizePath);
- url.addQueryItem(QStringLiteral("response_type"), QStringLiteral("code"));
- url.addQueryItem(QStringLiteral("client_id"), mClientId);
- url.addQueryItem(QStringLiteral("redirect_uri"), mRedirectUri);
+ QUrlQuery query;
+ query.addQueryItem(QStringLiteral("response_type"), QStringLiteral("code"));
+ query.addQueryItem(QStringLiteral("client_id"), mClientId);
+ query.addQueryItem(QStringLiteral("redirect_uri"), mRedirectUri);
if (!mScope.isEmpty()) {
- url.addQueryItem(QStringLiteral("scope"), mScope);
+ query.addQueryItem(QStringLiteral("scope"), mScope);
}
+ url.setQuery(query);
mAuthUrl = url;
//qCDebug(PIMCOMMON_LOG)<<" url"<<url;
delete mAuthDialog;
@@ -104,7 +107,7 @@ void BoxJob::slotRedirect(const QUrl &url)
void BoxJob::parseRedirectUrl(const QUrl &url)
{
- const QList<QPair<QString, QString> > listQuery = url.queryItems();
+ const QList<QPair<QString, QString> > listQuery = QUrlQuery(url).queryItems();
//qCDebug(PIMCOMMON_LOG)<< "listQuery "<<listQuery;
QString authorizeCode;
@@ -136,13 +139,13 @@ void BoxJob::getTokenAccess(const QString &authorizeCode)
mError = false;
QNetworkRequest request(QUrl(mServiceUrl + mPathToken));
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
- QUrl postData;
+ QUrlQuery postData;
postData.addQueryItem(QStringLiteral("code"), authorizeCode);
postData.addQueryItem(QStringLiteral("redirect_uri"), mRedirectUri);
postData.addQueryItem(QStringLiteral("grant_type"), QStringLiteral("authorization_code"));
postData.addQueryItem(QStringLiteral("client_id"), mClientId);
postData.addQueryItem(QStringLiteral("client_secret"), mClientSecret);
- QNetworkReply *reply = mNetworkAccessManager->post(request, postData.encodedQuery());
+ QNetworkReply *reply = mNetworkAccessManager->post(request, postData.query(QUrl::FullyEncoded).toUtf8());
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &BoxJob::slotError);
}
@@ -302,14 +305,14 @@ void BoxJob::refreshToken()
mActionType = PimCommon::StorageServiceAbstract::AccessTokenAction;
QNetworkRequest request(QUrl(QStringLiteral("https://www.box.com/api/oauth2/token")));
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
- QUrl postData;
+ QUrlQuery postData;
postData.addQueryItem(QStringLiteral("refresh_token"), mRefreshToken);
postData.addQueryItem(QStringLiteral("grant_type"), QStringLiteral("refresh_token"));
postData.addQueryItem(QStringLiteral("client_id"), mClientId);
postData.addQueryItem(QStringLiteral("client_secret"), mClientSecret);
//qCDebug(PIMCOMMON_LOG)<<"refreshToken postData: "<<postData;
- QNetworkReply *reply = mNetworkAccessManager->post(request, postData.encodedQuery());
+ QNetworkReply *reply = mNetworkAccessManager->post(request, postData.query(QUrl::FullyEncoded).toUtf8());
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &BoxJob::slotError);
}
@@ -332,7 +335,9 @@ void BoxJob::deleteFolder(const QString &foldername)
mError = false;
QUrl url;
url.setUrl(mApiUrl + mFolderInfoPath + foldername);
- url.addQueryItem(QStringLiteral("recursive"), QStringLiteral("true"));
+ QUrlQuery query;
+ query.addQueryItem(QStringLiteral("recursive"), QStringLiteral("true"));
+ url.setQuery(query);
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
request.setRawHeader("Authorization", "Bearer " + mToken.toLatin1());
@@ -445,10 +450,10 @@ QNetworkReply *BoxJob::uploadFile(const QString &filename, const QString &upload
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
request.setRawHeader("Authorization", "Bearer " + mToken.toLatin1());
- QUrl postData;
+ QUrlQuery postData;
postData.addQueryItem(QStringLiteral("parent_id"), destination);
postData.addQueryItem(QStringLiteral("filename"), uploadAsName);
- QNetworkReply *reply = mNetworkAccessManager->post(request, postData.encodedQuery());
+ QNetworkReply *reply = mNetworkAccessManager->post(request, postData.query(QUrl::FullyEncoded).toUtf8());
file->setParent(reply);
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &BoxJob::slotError);
return reply;
diff --git a/src/storageservice/dropbox/dropboxjob.cpp b/src/storageservice/dropbox/dropboxjob.cpp
index 3d37831..28f769c 100644
--- a/src/storageservice/dropbox/dropboxjob.cpp
+++ b/src/storageservice/dropbox/dropboxjob.cpp
@@ -32,6 +32,7 @@
#include "pimcommon_debug.h"
#include <QPointer>
#include <QJsonDocument>
+#include <QUrlQuery>
using namespace PimCommon;
@@ -68,8 +69,7 @@ void DropBoxJob::requestTokenAccess()
QNetworkRequest request(QUrl(mApiPath + QLatin1String("oauth/request_token")));
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
- QUrl postData;
-
+ QUrlQuery postData;
postData.addQueryItem(QStringLiteral("oauth_consumer_key"), mOauthconsumerKey);
postData.addQueryItem(QStringLiteral("oauth_nonce"), mNonce);
postData.addQueryItem(QStringLiteral("oauth_signature"), mOauthSignature);
@@ -77,7 +77,7 @@ void DropBoxJob::requestTokenAccess()
postData.addQueryItem(QStringLiteral("oauth_timestamp"), mTimestamp);
postData.addQueryItem(QStringLiteral("oauth_version"), mOauthVersion);
- QNetworkReply *reply = mNetworkAccessManager->post(request, postData.encodedQuery());
+ QNetworkReply *reply = mNetworkAccessManager->post(request, postData.query(QUrl::FullyEncoded).toUtf8());
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &DropBoxJob::slotError);
}
@@ -88,7 +88,7 @@ void DropBoxJob::getTokenAccess()
QNetworkRequest request(QUrl(mApiPath + QLatin1String("oauth/access_token")));
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
- QUrl postData;
+ QUrlQuery postData;
postData.addQueryItem(QStringLiteral("oauth_consumer_key"), mOauthconsumerKey);
postData.addQueryItem(QStringLiteral("oauth_nonce"), mNonce);
postData.addQueryItem(QStringLiteral("oauth_signature"), mAccessOauthSignature);
@@ -97,7 +97,7 @@ void DropBoxJob::getTokenAccess()
postData.addQueryItem(QStringLiteral("oauth_version"), mOauthVersion);
postData.addQueryItem(QStringLiteral("oauth_token"), mOauthToken);
- QNetworkReply *reply = mNetworkAccessManager->post(request, postData.encodedQuery());
+ QNetworkReply *reply = mNetworkAccessManager->post(request, postData.query(QUrl::FullyEncoded).toUtf8());
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &DropBoxJob::slotError);
}
@@ -357,7 +357,9 @@ void DropBoxJob::parseRequestToken(const QString &result)
void DropBoxJob::doAuthentication()
{
QUrl url(mApiPath + QLatin1String("oauth/authorize"));
- url.addQueryItem(QStringLiteral("oauth_token"), mOauthToken);
+ QUrlQuery query;
+ query.addQueryItem(QStringLiteral("oauth_token"), mOauthToken);
+ url.setQuery(query);
QPointer<StorageAuthViewDialog> dlg = new StorageAuthViewDialog;
dlg->setUrl(url);
if (dlg->exec()) {
@@ -376,9 +378,10 @@ void DropBoxJob::createFolderJob(const QString &foldername, const QString &desti
qCDebug(PIMCOMMON_LOG) << " folder empty!";
}
QUrl url(mApiPath + QLatin1String("fileops/create_folder"));
- url.addQueryItem(QStringLiteral("root"), mRootPath);
- url.addQueryItem(QStringLiteral("path"), destination + QLatin1Char('/') + foldername);
- addDefaultUrlItem(url);
+ auto query = defaultUrlQuery();
+ query.addQueryItem(QStringLiteral("root"), mRootPath);
+ query.addQueryItem(QStringLiteral("path"), destination + QLatin1Char('/') + foldername);
+ url.setQuery(query);
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
QNetworkReply *reply = mNetworkAccessManager->get(request);
@@ -421,7 +424,7 @@ void DropBoxJob::accountInfo()
mActionType = PimCommon::StorageServiceAbstract::AccountInfoAction;
mError = false;
QUrl url(mApiPath + QLatin1String("account/info"));
- addDefaultUrlItem(url);
+ url.setQuery(defaultUrlQuery());
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
@@ -434,7 +437,7 @@ void DropBoxJob::listFolder(const QString &folder)
mActionType = PimCommon::StorageServiceAbstract::ListFolderAction;
mError = false;
QUrl url(mApiPath + QLatin1String("metadata/dropbox/") + folder);
- addDefaultUrlItem(url);
+ url.setQuery(defaultUrlQuery());
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
@@ -474,8 +477,9 @@ void DropBoxJob::shareLink(const QString &root, const QString &path)
mError = false;
QUrl url = QUrl(mApiPath + QStringLiteral("shares/%1/%2").arg(root).arg(path));
- url.addQueryItem(QStringLiteral("root"), mRootPath);
- addDefaultUrlItem(url);
+ auto query = defaultUrlQuery();
+ query.addQueryItem(QStringLiteral("root"), mRootPath);
+ url.setQuery(query);;
QNetworkRequest request(url);
QNetworkReply *reply = mNetworkAccessManager->get(request);
@@ -520,9 +524,10 @@ void DropBoxJob::deleteFile(const QString &filename)
mActionType = PimCommon::StorageServiceAbstract::DeleteFileAction;
mError = false;
QUrl url = QUrl(mApiPath + QLatin1String("fileops/delete"));
- url.addQueryItem(QStringLiteral("root"), mRootPath);
- url.addQueryItem(QStringLiteral("path"), filename);
- addDefaultUrlItem(url);
+ auto query = defaultUrlQuery();
+ query.addQueryItem(QStringLiteral("root"), mRootPath);
+ query.addQueryItem(QStringLiteral("path"), filename);
+ url.setQuery(query);
QNetworkRequest request(url);
QNetworkReply *reply = mNetworkAccessManager->get(request);
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &DropBoxJob::slotError);
@@ -533,9 +538,10 @@ void DropBoxJob::deleteFolder(const QString &foldername)
mActionType = PimCommon::StorageServiceAbstract::DeleteFolderAction;
mError = false;
QUrl url = QUrl(mApiPath + QLatin1String("fileops/delete"));
- url.addQueryItem(QStringLiteral("root"), mRootPath);
- url.addQueryItem(QStringLiteral("path"), foldername);
- addDefaultUrlItem(url);
+ auto query = defaultUrlQuery();
+ query.addQueryItem(QStringLiteral("root"), mRootPath);
+ query.addQueryItem(QStringLiteral("path"), foldername);
+ url.setQuery(query);
QNetworkRequest request(url);
QNetworkReply *reply = mNetworkAccessManager->get(request);
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &DropBoxJob::slotError);
@@ -546,9 +552,9 @@ void DropBoxJob::renameFolder(const QString &source, const QString &destination)
mActionType = PimCommon::StorageServiceAbstract::RenameFolderAction;
mError = false;
QUrl url = QUrl(mApiPath + QLatin1String("fileops/move"));
- url.addQueryItem(QStringLiteral("root"), mRootPath);
- addDefaultUrlItem(url);
- url.addQueryItem(QStringLiteral("from_path"), source);
+ auto query = defaultUrlQuery();
+ query.addQueryItem(QStringLiteral("root"), mRootPath);
+ query.addQueryItem(QStringLiteral("from_path"), source);
QStringList parts = source.split(QStringLiteral("/"), QString::SkipEmptyParts);
parts.removeLast();
@@ -564,7 +570,8 @@ void DropBoxJob::renameFolder(const QString &source, const QString &destination)
}
const QString newPath = destinationFolder.append(destination);
- url.addQueryItem(QStringLiteral("to_path"), newPath);
+ query.addQueryItem(QStringLiteral("to_path"), newPath);
+ url.setQuery(query);
QNetworkRequest request(url);
QNetworkReply *reply = mNetworkAccessManager->get(request);
@@ -576,8 +583,8 @@ void DropBoxJob::renameFile(const QString &oldName, const QString &newName)
mActionType = PimCommon::StorageServiceAbstract::RenameFileAction;
mError = false;
QUrl url = QUrl(mApiPath + QLatin1String("fileops/move"));
- url.addQueryItem(QStringLiteral("root"), mRootPath);
- addDefaultUrlItem(url);
+ auto query = defaultUrlQuery();
+ query.addQueryItem(QStringLiteral("root"), mRootPath);
//Generate new path.
QStringList parts = oldName.split(QStringLiteral("/"), QString::SkipEmptyParts);
@@ -595,8 +602,9 @@ void DropBoxJob::renameFile(const QString &oldName, const QString &newName)
const QString newPath = destinationFolder.append(newName);
- url.addQueryItem(QStringLiteral("from_path"), oldName);
- url.addQueryItem(QStringLiteral("to_path"), newPath);
+ query.addQueryItem(QStringLiteral("from_path"), oldName);
+ query.addQueryItem(QStringLiteral("to_path"), newPath);
+ url.setQuery(query);
QNetworkRequest request(url);
QNetworkReply *reply = mNetworkAccessManager->get(request);
@@ -608,10 +616,11 @@ void DropBoxJob::moveFolder(const QString &source, const QString &destination)
mActionType = PimCommon::StorageServiceAbstract::MoveFolderAction;
mError = false;
QUrl url = QUrl(mApiPath + QLatin1String("fileops/move"));
- url.addQueryItem(QStringLiteral("root"), mRootPath);
- addDefaultUrlItem(url);
- url.addQueryItem(QStringLiteral("from_path"), source);
- url.addQueryItem(QStringLiteral("to_path"), destination + source);
+ auto query = defaultUrlQuery();
+ query.addQueryItem(QStringLiteral("root"), mRootPath);
+ query.addQueryItem(QStringLiteral("from_path"), source);
+ query.addQueryItem(QStringLiteral("to_path"), destination + source);
+ url.setQuery(query);
QNetworkRequest request(url);
QNetworkReply *reply = mNetworkAccessManager->get(request);
@@ -623,10 +632,11 @@ void DropBoxJob::moveFile(const QString &source, const QString &destination)
mActionType = PimCommon::StorageServiceAbstract::MoveFileAction;
mError = false;
QUrl url = QUrl(mApiPath + QLatin1String("fileops/move"));
- url.addQueryItem(QStringLiteral("root"), mRootPath);
- addDefaultUrlItem(url);
- url.addQueryItem(QStringLiteral("from_path"), source);
- url.addQueryItem(QStringLiteral("to_path"), destination + source);
+ auto query = defaultUrlQuery();
+ query.addQueryItem(QStringLiteral("root"), mRootPath);
+ query.addQueryItem(QStringLiteral("from_path"), source);
+ query.addQueryItem(QStringLiteral("to_path"), destination + source);
+ url.setQuery(query);
QNetworkRequest request(url);
QNetworkReply *reply = mNetworkAccessManager->get(request);
@@ -638,10 +648,11 @@ void DropBoxJob::copyFile(const QString &source, const QString &destination)
mActionType = PimCommon::StorageServiceAbstract::CopyFileAction;
mError = false;
QUrl url = QUrl(mApiPath + QLatin1String("fileops/copy"));
- url.addQueryItem(QStringLiteral("root"), mRootPath);
- addDefaultUrlItem(url);
- url.addQueryItem(QStringLiteral("from_path"), source);
- url.addQueryItem(QStringLiteral("to_path"), destination + source);
+ auto query = defaultUrlQuery();
+ query.addQueryItem(QStringLiteral("root"), mRootPath);
+ query.addQueryItem(QStringLiteral("from_path"), source);
+ query.addQueryItem(QStringLiteral("to_path"), destination + source);
+ url.setQuery(query);
QNetworkRequest request(url);
QNetworkReply *reply = mNetworkAccessManager->get(request);
@@ -653,25 +664,29 @@ void DropBoxJob::copyFolder(const QString &source, const QString &destination)
mActionType = PimCommon::StorageServiceAbstract::CopyFolderAction;
mError = false;
QUrl url = QUrl(mApiPath + QLatin1String("fileops/copy"));
- url.addQueryItem(QStringLiteral("root"), mRootPath);
- addDefaultUrlItem(url);
- url.addQueryItem(QStringLiteral("from_path"), source);
- url.addQueryItem(QStringLiteral("to_path"), destination + source);
+ auto query = defaultUrlQuery();
+ query.addQueryItem(QStringLiteral("root"), mRootPath);
+ query.addQueryItem(QStringLiteral("from_path"), source);
+ query.addQueryItem(QStringLiteral("to_path"), destination + source);
+ url.setQuery(query);
QNetworkRequest request(url);
QNetworkReply *reply = mNetworkAccessManager->get(request);
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &DropBoxJob::slotError);
}
-void DropBoxJob::addDefaultUrlItem(QUrl &url)
+QUrlQuery DropBoxJob::defaultUrlQuery() const
{
- url.addQueryItem(QStringLiteral("oauth_consumer_key"), mOauthconsumerKey);
- url.addQueryItem(QStringLiteral("oauth_nonce"), mNonce);
- url.addQueryItem(QStringLiteral("oauth_signature"), mAccessOauthSignature.replace(QLatin1Char('&'), QStringLiteral("%26")));
- url.addQueryItem(QStringLiteral("oauth_signature_method"), mOauthSignatureMethod);
- url.addQueryItem(QStringLiteral("oauth_timestamp"), mTimestamp);
- url.addQueryItem(QStringLiteral("oauth_version"), mOauthVersion);
- url.addQueryItem(QStringLiteral("oauth_token"), mOauthToken);
+ QUrlQuery query;
+ query.addQueryItem(QStringLiteral("oauth_consumer_key"), mOauthconsumerKey);
+ query.addQueryItem(QStringLiteral("oauth_nonce"), mNonce);
+ auto signature = mAccessOauthSignature;
+ query.addQueryItem(QStringLiteral("oauth_signature"), signature.replace(QLatin1Char('&'), QStringLiteral("%26")));
+ query.addQueryItem(QStringLiteral("oauth_signature_method"), mOauthSignatureMethod);
+ query.addQueryItem(QStringLiteral("oauth_timestamp"), mTimestamp);
+ query.addQueryItem(QStringLiteral("oauth_version"), mOauthVersion);
+ query.addQueryItem(QStringLiteral("oauth_token"), mOauthToken);
+ return query;
}
void DropBoxJob::parseShareLink(const QString &data)
diff --git a/src/storageservice/dropbox/dropboxjob.h b/src/storageservice/dropbox/dropboxjob.h
index 7324c4e..95da15c 100644
--- a/src/storageservice/dropbox/dropboxjob.h
+++ b/src/storageservice/dropbox/dropboxjob.h
@@ -19,6 +19,9 @@
#define DROPBOXJOB_H
#include "storageservice/job/storageserviceabstractjob.h"
#include <QNetworkReply>
+
+class QUrlQuery;
+
namespace PimCommon
{
class AccountInfo;
@@ -56,7 +59,7 @@ Q_SIGNALS:
private:
QString extractPathFromData(const QString &data);
void createFolderJob(const QString &foldername, const QString &destination);
- void addDefaultUrlItem(QUrl &url);
+ QUrlQuery defaultUrlQuery() const;
void getTokenAccess();
void parseRequestToken(const QString &result);
void doAuthentication();
diff --git a/src/storageservice/hubic/hubicjob.cpp b/src/storageservice/hubic/hubicjob.cpp
index a484ca1..19297cb 100644
--- a/src/storageservice/hubic/hubicjob.cpp
+++ b/src/storageservice/hubic/hubicjob.cpp
@@ -25,6 +25,7 @@
#include "pimcommon_debug.h"
#include <QFile>
#include <QJsonParseError>
+#include <QUrlQuery>
using namespace PimCommon;
@@ -71,12 +72,14 @@ void HubicJob::requestTokenAccess()
mError = false;
mActionType = PimCommon::StorageServiceAbstract::RequestTokenAction;
QUrl url(mServiceUrl + mAuthorizePath);
- url.addQueryItem(QStringLiteral("response_type"), QStringLiteral("code"));
- url.addQueryItem(QStringLiteral("client_id"), mClientId);
- url.addQueryItem(QStringLiteral("redirect_uri"), mRedirectUri);
+ QUrlQuery query;
+ query.addQueryItem(QStringLiteral("response_type"), QStringLiteral("code"));
+ query.addQueryItem(QStringLiteral("client_id"), mClientId);
+ query.addQueryItem(QStringLiteral("redirect_uri"), mRedirectUri);
if (!mScope.isEmpty()) {
- url.addQueryItem(QStringLiteral("scope"), mScope);
+ query.addQueryItem(QStringLiteral("scope"), mScope);
}
+ url.setQuery(query);
mAuthUrl = url;
//qCDebug(PIMCOMMON_LOG)<<" url"<<url;
delete mAuthDialog;
@@ -103,7 +106,7 @@ void HubicJob::slotRedirect(const QUrl &url)
void HubicJob::parseRedirectUrl(const QUrl &url)
{
- const QList<QPair<QString, QString> > listQuery = url.queryItems();
+ const QList<QPair<QString, QString> > listQuery = QUrlQuery(url).queryItems();
//qCDebug(PIMCOMMON_LOG)<< "listQuery "<<listQuery;
QString authorizeCode;
@@ -134,13 +137,13 @@ void HubicJob::getTokenAccess(const QString &authorizeCode)
mError = false;
QNetworkRequest request(QUrl(mServiceUrl + mPathToken));
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
- QUrl postData;
+ QUrlQuery postData;
postData.addQueryItem(QStringLiteral("code"), authorizeCode);
postData.addQueryItem(QStringLiteral("redirect_uri"), mRedirectUri);
postData.addQueryItem(QStringLiteral("grant_type"), QStringLiteral("authorization_code"));
postData.addQueryItem(QStringLiteral("client_id"), mClientId);
postData.addQueryItem(QStringLiteral("client_secret"), mClientSecret);
- QNetworkReply *reply = mNetworkAccessManager->post(request, postData.encodedQuery());
+ QNetworkReply *reply = mNetworkAccessManager->post(request, postData.query(QUrl::FullyEncoded).toUtf8());
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &HubicJob::slotError);
}
@@ -293,14 +296,14 @@ void HubicJob::refreshToken()
mActionType = PimCommon::StorageServiceAbstract::AccessTokenAction;
QNetworkRequest request(QUrl(QStringLiteral("https://api.hubic.com/oauth/token/")));
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
- QUrl postData;
+ QUrlQuery postData;
postData.addQueryItem(QStringLiteral("refresh_token"), mRefreshToken);
postData.addQueryItem(QStringLiteral("grant_type"), QStringLiteral("refresh_token"));
postData.addQueryItem(QStringLiteral("client_id"), mClientId);
postData.addQueryItem(QStringLiteral("client_secret"), mClientSecret);
- qCDebug(PIMCOMMON_LOG) << "refreshToken postData: " << postData;
+ qCDebug(PIMCOMMON_LOG) << "refreshToken postData: " << postData.queryItems();
- QNetworkReply *reply = mNetworkAccessManager->post(request, postData.encodedQuery());
+ QNetworkReply *reply = mNetworkAccessManager->post(request, postData.query(QUrl::FullyEncoded).toUtf8());
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &HubicJob::slotError);
}
diff --git a/src/storageservice/webdav/webdavjob.cpp b/src/storageservice/webdav/webdavjob.cpp
index 999d4f9..f085e31 100644
--- a/src/storageservice/webdav/webdavjob.cpp
+++ b/src/storageservice/webdav/webdavjob.cpp
@@ -32,6 +32,7 @@
#include <QFile>
#include <QDomDocument>
#include <QDomNodeList>
+#include <QUrlQuery>
using namespace PimCommon;
@@ -586,10 +587,10 @@ void WebDavJob::shareLink(const QString &/*root*/, const QString &path)
qCDebug(PIMCOMMON_LOG) << " filePath" << filePath;
qCDebug(PIMCOMMON_LOG) << " url" << (path2.scheme() + QLatin1String("://") + path2.host() + mShareApi);
request.setHeader(QNetworkRequest::ContentTypeHeader, QLatin1String("application/x-www-form-urlencoded"));
- QUrl postData;
+ QUrlQuery postData;
postData.addQueryItem(QStringLiteral("path"), filePath);
postData.addQueryItem(QStringLiteral("shareType"), QString::number(3)); //public link
- QNetworkReply *reply = mNetworkAccessManager->post(request, postData.encodedQuery());
+ QNetworkReply *reply = mNetworkAccessManager->post(request, postData.query(QUrl::FullyEncoded).toUtf8());
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &WebDavJob::slotError);
}
diff --git a/src/storageservice/yousendit/yousenditjob.cpp b/src/storageservice/yousendit/yousenditjob.cpp
index 990eb24..ab40e4b 100644
--- a/src/storageservice/yousendit/yousenditjob.cpp
+++ b/src/storageservice/yousendit/yousenditjob.cpp
@@ -26,6 +26,7 @@
#include <QJsonParseError>
#include <QNetworkReply>
#include <QPointer>
+#include <QUrlQuery>
using namespace PimCommon;
@@ -124,10 +125,10 @@ void YouSendItJob::renameFolder(const QString &source, const QString &destinatio
QUrl url(mDefaultUrl + QStringLiteral("/dpi/v1/folder/%1/rename?name=%2").arg(source).arg(destination));
QNetworkRequest request = setDefaultHeader(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
- QUrl postData;
+ QUrlQuery postData;
postData.addQueryItem(QStringLiteral("name"), destination);
- QNetworkReply *reply = mNetworkAccessManager->put(request, postData.encodedQuery());
+ QNetworkReply *reply = mNetworkAccessManager->put(request, postData.query(QUrl::FullyEncoded).toUtf8());
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &YouSendItJob::slotError);
}
@@ -140,9 +141,9 @@ void YouSendItJob::renameFile(const QString &oldName, const QString &newName)
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
- QUrl postData;
+ QUrlQuery postData;
postData.addQueryItem(QStringLiteral("name"), newName);
- QNetworkReply *reply = mNetworkAccessManager->put(request, postData.encodedQuery());
+ QNetworkReply *reply = mNetworkAccessManager->put(request, postData.query(QUrl::FullyEncoded).toUtf8());
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &YouSendItJob::slotError);
}
@@ -154,9 +155,9 @@ void YouSendItJob::moveFolder(const QString &source, const QString &destination)
QNetworkRequest request = setDefaultHeader(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
- QUrl postData;
+ QUrlQuery postData;
postData.addQueryItem(QStringLiteral("parentId"), destination);
- QNetworkReply *reply = mNetworkAccessManager->put(request, postData.encodedQuery());
+ QNetworkReply *reply = mNetworkAccessManager->put(request, postData.query(QUrl::FullyEncoded).toUtf8());
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &YouSendItJob::slotError);
}
@@ -168,9 +169,9 @@ void YouSendItJob::moveFile(const QString &source, const QString &destination)
QNetworkRequest request = setDefaultHeader(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
- QUrl postData;
+ QUrlQuery postData;
postData.addQueryItem(QStringLiteral("parentId"), destination);
- QNetworkReply *reply = mNetworkAccessManager->put(request, postData.encodedQuery());
+ QNetworkReply *reply = mNetworkAccessManager->put(request, postData.query(QUrl::FullyEncoded).toUtf8());
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &YouSendItJob::slotError);
}
@@ -198,12 +199,11 @@ void YouSendItJob::requestTokenAccess()
request.setRawHeader("X-Api-Key", mApiKey.toLatin1());
request.setRawHeader("Accept", "application/json");
- QUrl postData;
-
+ QUrlQuery postData;
postData.addQueryItem(QStringLiteral("email"), mUsername);
postData.addQueryItem(QStringLiteral("password"), mPassword);
//qCDebug(PIMCOMMON_LOG)<<" postData"<<postData;
- QNetworkReply *reply = mNetworkAccessManager->post(request, postData.encodedQuery());
+ QNetworkReply *reply = mNetworkAccessManager->post(request, postData.query(QUrl::FullyEncoded).toUtf8());
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &YouSendItJob::slotError);
}
@@ -217,10 +217,10 @@ QNetworkReply *YouSendItJob::uploadFile(const QString &filename, const QString &
mError = false;
QUrl url(mDefaultUrl + QLatin1String("/dpi/v1/folder/file/initUpload"));
QNetworkRequest request = setDefaultHeader(url);
- QUrl postData;
+ QUrlQuery postData;
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
- QNetworkReply *reply = mNetworkAccessManager->post(request, postData.encodedQuery());
+ QNetworkReply *reply = mNetworkAccessManager->post(request, postData.query(QUrl::FullyEncoded).toUtf8());
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &YouSendItJob::slotError);
return reply;
}
@@ -236,8 +236,10 @@ void YouSendItJob::listFolder(const QString &folder)
} else {
url.setUrl(mDefaultUrl + QStringLiteral("/dpi/v1/folder/%1").arg(folder));
}
- url.addQueryItem(QStringLiteral("email"), mUsername);
- url.addQueryItem(QStringLiteral("X-Auth-Token"), mToken);
+ QUrlQuery query;
+ query.addQueryItem(QStringLiteral("email"), mUsername);
+ query.addQueryItem(QStringLiteral("X-Auth-Token"), mToken);
+ url.setQuery(query);
QNetworkRequest request = setDefaultHeader(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
QNetworkReply *reply = mNetworkAccessManager->get(request);
@@ -249,8 +251,10 @@ void YouSendItJob::accountInfo()
mActionType = PimCommon::StorageServiceAbstract::AccountInfoAction;
mError = false;
QUrl url(mDefaultUrl + QLatin1String("/dpi/v2/user"));
- url.addQueryItem(QStringLiteral("email"), mUsername);
- url.addQueryItem(QStringLiteral("X-Auth-Token"), mToken);
+ QUrlQuery query;
+ query.addQueryItem(QStringLiteral("email"), mUsername);
+ query.addQueryItem(QStringLiteral("X-Auth-Token"), mToken);
+ url.setQuery(query);
QNetworkRequest request = setDefaultHeader(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
QNetworkReply *reply = mNetworkAccessManager->get(request);
@@ -268,13 +272,13 @@ void YouSendItJob::createFolderJob(const QString &foldername, const QString &des
{
QUrl url(mDefaultUrl + QLatin1String("/dpi/v1/folder"));
QNetworkRequest request = setDefaultHeader(url);
- QUrl postData;
+ QUrlQuery postData;
postData.addQueryItem(QStringLiteral("name"), foldername);
if (!destination.isEmpty()) {
postData.addQueryItem(QStringLiteral("parentId"), destination);
}
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
- QNetworkReply *reply = mNetworkAccessManager->post(request, postData.encodedQuery());
+ QNetworkReply *reply = mNetworkAccessManager->post(request, postData.query(QUrl::FullyEncoded).toUtf8());
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &YouSendItJob::slotError);
}
@@ -647,11 +651,11 @@ void YouSendItJob::startUploadFile(const QString &fileId)
request.setRawHeader("filename", "test.txt");
request.setRawHeader("Accept", "application/json");
request.setRawHeader("X-Auth-Token", mToken.toLatin1());
- QUrl postData;
+ QUrlQuery postData;
postData.addQueryItem(QStringLiteral("fileId"), fileId);
request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
- QNetworkReply *reply = mNetworkAccessManager->post(request, postData.encodedQuery());
+ QNetworkReply *reply = mNetworkAccessManager->post(request, postData.query(QUrl::FullyEncoded).toUtf8());
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &YouSendItJob::slotError);
//Multipart
//TODO
diff --git a/src/translator/googletranslator.cpp b/src/translator/googletranslator.cpp
index a8f5c88..2e052e3 100644
--- a/src/translator/googletranslator.cpp
+++ b/src/translator/googletranslator.cpp
@@ -24,6 +24,7 @@
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QPointer>
+#include <QUrlQuery>
using namespace PimCommon;
diff --git a/src/util/pimutil.cpp b/src/util/pimutil.cpp
index 94e2568..835653f 100644
--- a/src/util/pimutil.cpp
+++ b/src/util/pimutil.cpp
@@ -48,6 +48,7 @@
#include <QTextStream>
#include <QWidget>
#include <QPointer>
+#include <QUrlQuery>
#include <AgentInstance>
#include <AkonadiCore/AgentManager>
#include <AkonadiCore/ServerManager>