From 08769b28038541b906c0c55424ef476505252401 Mon Sep 17 00:00:00 2001 From: Camila San Date: Fri, 26 Jan 2018 13:11:35 +0100 Subject: [PATCH] Adds OcsAppsJob to retrieve apps enabled for the user. Signed-off-by: Camila San --- src/gui/CMakeLists.txt | 3 ++- src/gui/ocsappsjob.cpp | 37 +++++++++++++++++++++++++++++ src/gui/ocsappsjob.h | 53 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 src/gui/ocsappsjob.cpp create mode 100644 src/gui/ocsappsjob.h diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 70aaecf1f..ee282ca4e 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -59,8 +59,9 @@ set(client_SRCS logbrowser.cpp navigationpanehelper.cpp networksettings.cpp - ocsjob.cpp + ocsappsjob.cpp ocsexternalsitesjob.cpp + ocsjob.cpp ocssharejob.cpp ocsshareejob.cpp openfilemanager.cpp diff --git a/src/gui/ocsappsjob.cpp b/src/gui/ocsappsjob.cpp new file mode 100644 index 000000000..0a8654fd9 --- /dev/null +++ b/src/gui/ocsappsjob.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (C) by Camila Ayres + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "ocsappsjob.h" + +namespace OCC { + +OcsAppsJob::OcsAppsJob(AccountPtr account) + : OcsJob(account) +{ + setPath("ocs/v1.php/cloud/apps/enabled"); + connect(this, &OcsAppsJob::jobFinished, this, &OcsAppsJob::jobDone); +} + +void OcsAppsJob::getApps() +{ + setVerb("GET"); + start(); +} + +void OcsAppsJob::jobDone(const QJsonDocument &reply) +{ + + emit appsJobFinished(reply); +} +} diff --git a/src/gui/ocsappsjob.h b/src/gui/ocsappsjob.h new file mode 100644 index 000000000..7109af153 --- /dev/null +++ b/src/gui/ocsappsjob.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) by Camila Ayres + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#ifndef OCSAPPSJOB_H +#define OCSAPPSJOB_H + +#include "ocsjob.h" +class QJsonDocument; + +namespace OCC { + +/** + * @brief The OcsAppsJob class + * @ingroup gui + * + * Fetching enabled apps from the OCS Apps API + */ +class OcsAppsJob : public OcsJob +{ + Q_OBJECT +public: + explicit OcsAppsJob(AccountPtr account); + + /** + * Get a list of enabled apps for the current user + */ + void getApps(); + +signals: + /** + * Result of the OCS request + * + * @param reply The reply + */ + void appsJobFinished(const QJsonDocument &reply); + +private slots: + void jobDone(const QJsonDocument &reply); +}; +} + +#endif // OCSAPPSJOB_H