[Pkg-owncloud-commits] [owncloud-client] 232/484: JSONApiJob: Add method to add additional query parameter.

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Dec 16 00:37:46 UTC 2015


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 9545af0d435221234ea5836f4c0bdc479e40a433
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Mon Nov 2 17:37:23 2015 +0100

    JSONApiJob: Add method to add additional query parameter.
---
 src/libsync/networkjobs.cpp |  9 ++++++++-
 src/libsync/networkjobs.h   | 14 ++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp
index e3f780a..1ceaa82 100644
--- a/src/libsync/networkjobs.cpp
+++ b/src/libsync/networkjobs.cpp
@@ -583,12 +583,19 @@ bool EntityExistsJob::finished()
 JsonApiJob::JsonApiJob(const AccountPtr &account, const QString& path, QObject* parent): AbstractNetworkJob(account, path, parent)
 { }
 
+void JsonApiJob::addQueryParams(QList< QPair<QString,QString> > params)
+{
+    _additionalParams = params;
+}
+
 void JsonApiJob::start()
 {
     QNetworkRequest req;
     req.setRawHeader("OCS-APIREQUEST", "true");
     QUrl url = Account::concatUrlPath(account()->url(), path());
-    url.setQueryItems(QList<QPair<QString, QString> >() << qMakePair(QString::fromLatin1("format"), QString::fromLatin1("json")));
+    QList<QPair<QString, QString> > params = _additionalParams;
+    params << qMakePair(QString::fromLatin1("format"), QString::fromLatin1("json"));
+    url.setQueryItems(params);
     setReply(davRequest("GET", url, req));
     setupConnections(reply());
     AbstractNetworkJob::start();
diff --git a/src/libsync/networkjobs.h b/src/libsync/networkjobs.h
index 5a8dc90..f2aeb2a 100644
--- a/src/libsync/networkjobs.h
+++ b/src/libsync/networkjobs.h
@@ -209,12 +209,26 @@ class OWNCLOUDSYNC_EXPORT JsonApiJob : public AbstractNetworkJob {
     Q_OBJECT
 public:
     explicit JsonApiJob(const AccountPtr &account, const QString &path, QObject *parent = 0);
+
+    /**
+     * @brief addQueryParams - add more parameters to the ocs call
+     * @param params: list pairs of strings containing the parameter name and the value.
+     *
+     * All parameters from the passed list are appended to the query. Note
+     * that the format=json parameter is added automatically and does not
+     * need to be set this way.
+     *
+     * This function needs to be called before start() obviously.
+     */
+    void addQueryParams(QList< QPair<QString,QString> > params);
 public slots:
     void start() Q_DECL_OVERRIDE;
 protected:
     bool finished() Q_DECL_OVERRIDE;
 signals:
     void jsonRecieved(const QVariantMap &json);
+private:
+    QList< QPair<QString,QString> > _additionalParams;
 };
 
 } // namespace OCC

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list