aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/device_management.h
diff options
context:
space:
mode:
authorAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
committerAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
commit09eb39236666e81d5da014acea011dcd74d0999b (patch)
tree52876d96be71be1a39d5d935c1295a51995e8949 /lib/csapi/device_management.h
parentf1788ee27f33e9339334e0d79bde9a27d9ce2e44 (diff)
parenta4e78956f105875625b572d8b98459ffa86fafe5 (diff)
downloadlibquotient-09eb39236666e81d5da014acea011dcd74d0999b.tar.gz
libquotient-09eb39236666e81d5da014acea011dcd74d0999b.zip
Update upstream source from tag 'upstream/0.6.4'
Update to upstream version '0.6.4' with Debian dir aa8705fd74743e79c043bc9e3e425d5064404cfe
Diffstat (limited to 'lib/csapi/device_management.h')
-rw-r--r--lib/csapi/device_management.h232
1 files changed, 112 insertions, 120 deletions
diff --git a/lib/csapi/device_management.h b/lib/csapi/device_management.h
index f41efdbc..47dc7ec8 100644
--- a/lib/csapi/device_management.h
+++ b/lib/csapi/device_management.h
@@ -4,132 +4,124 @@
#pragma once
-#include "jobs/basejob.h"
-
#include "csapi/definitions/auth_data.h"
-#include <QtCore/QVector>
-#include "converters.h"
#include "csapi/definitions/client_device.h"
-namespace QMatrixClient
-{
- // Operations
-
- /// List registered devices for the current user
- ///
- /// Gets information about all devices for the current user.
- class GetDevicesJob : public BaseJob
- {
- public:
- explicit GetDevicesJob();
-
- /*! Construct a URL without creating a full-fledged job object
- *
- * This function can be used when a URL for
- * GetDevicesJob is necessary but the job
- * itself isn't.
- */
- static QUrl makeRequestUrl(QUrl baseUrl);
-
- ~GetDevicesJob() override;
+#include "jobs/basejob.h"
- // Result properties
+namespace Quotient {
- /// A list of all registered devices for this user.
- const QVector<Device>& devices() const;
+/*! \brief List registered devices for the current user
+ *
+ * Gets information about all devices for the current user.
+ */
+class GetDevicesJob : public BaseJob {
+public:
+ /// List registered devices for the current user
+ explicit GetDevicesJob();
- protected:
- Status parseJson(const QJsonDocument& data) override;
+ /*! \brief Construct a URL without creating a full-fledged job object
+ *
+ * This function can be used when a URL for GetDevicesJob
+ * is necessary but the job itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl);
- private:
- class Private;
- QScopedPointer<Private> d;
- };
+ // Result properties
- /// Get a single device
- ///
- /// Gets information on a single device, by device id.
- class GetDeviceJob : public BaseJob
- {
- public:
- /*! Get a single device
- * \param deviceId
- * The device to retrieve.
- */
- explicit GetDeviceJob(const QString& deviceId);
-
- /*! Construct a URL without creating a full-fledged job object
- *
- * This function can be used when a URL for
- * GetDeviceJob is necessary but the job
- * itself isn't.
- */
- static QUrl makeRequestUrl(QUrl baseUrl, const QString& deviceId);
-
- ~GetDeviceJob() override;
-
- // Result properties
-
- /// Device information
- const Device& data() const;
-
- protected:
- Status parseJson(const QJsonDocument& data) override;
-
- private:
- class Private;
- QScopedPointer<Private> d;
- };
-
- /// Update a device
- ///
- /// Updates the metadata on the given device.
- class UpdateDeviceJob : public BaseJob
- {
- public:
- /*! Update a device
- * \param deviceId
- * The device to update.
- * \param displayName
- * The new display name for this device. If not given, the
- * display name is unchanged.
- */
- explicit UpdateDeviceJob(const QString& deviceId, const QString& displayName = {});
- };
-
- /// Delete a device
- ///
- /// This API endpoint uses the `User-Interactive Authentication API`_.
- ///
- /// Deletes the given device, and invalidates any access token associated with it.
- class DeleteDeviceJob : public BaseJob
+ /// A list of all registered devices for this user.
+ QVector<Device> devices() const
{
- public:
- /*! Delete a device
- * \param deviceId
- * The device to delete.
- * \param auth
- * Additional authentication information for the
- * user-interactive authentication API.
- */
- explicit DeleteDeviceJob(const QString& deviceId, const Omittable<AuthenticationData>& auth = none);
- };
-
- /// Bulk deletion of devices
- ///
- /// This API endpoint uses the `User-Interactive Authentication API`_.
- ///
- /// Deletes the given devices, and invalidates any access token associated with them.
- class DeleteDevicesJob : public BaseJob
- {
- public:
- /*! Bulk deletion of devices
- * \param devices
- * The list of device IDs to delete.
- * \param auth
- * Additional authentication information for the
- * user-interactive authentication API.
- */
- explicit DeleteDevicesJob(const QStringList& devices, const Omittable<AuthenticationData>& auth = none);
- };
-} // namespace QMatrixClient
+ return loadFromJson<QVector<Device>>("devices"_ls);
+ }
+};
+
+/*! \brief Get a single device
+ *
+ * Gets information on a single device, by device id.
+ */
+class GetDeviceJob : public BaseJob {
+public:
+ /*! \brief Get a single device
+ *
+ * \param deviceId
+ * The device to retrieve.
+ */
+ explicit GetDeviceJob(const QString& deviceId);
+
+ /*! \brief Construct a URL without creating a full-fledged job object
+ *
+ * This function can be used when a URL for GetDeviceJob
+ * is necessary but the job itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl, const QString& deviceId);
+
+ // Result properties
+
+ /// Device information
+ Device device() const { return fromJson<Device>(jsonData()); }
+};
+
+/*! \brief Update a device
+ *
+ * Updates the metadata on the given device.
+ */
+class UpdateDeviceJob : public BaseJob {
+public:
+ /*! \brief Update a device
+ *
+ * \param deviceId
+ * The device to update.
+ *
+ * \param displayName
+ * The new display name for this device. If not given, the
+ * display name is unchanged.
+ */
+ explicit UpdateDeviceJob(const QString& deviceId,
+ const QString& displayName = {});
+};
+
+/*! \brief Delete a device
+ *
+ * This API endpoint uses the `User-Interactive Authentication API`_.
+ *
+ * Deletes the given device, and invalidates any access token associated with it.
+ */
+class DeleteDeviceJob : public BaseJob {
+public:
+ /*! \brief Delete a device
+ *
+ * \param deviceId
+ * The device to delete.
+ *
+ * \param auth
+ * Additional authentication information for the
+ * user-interactive authentication API.
+ */
+ explicit DeleteDeviceJob(const QString& deviceId,
+ const Omittable<AuthenticationData>& auth = none);
+};
+
+/*! \brief Bulk deletion of devices
+ *
+ * This API endpoint uses the `User-Interactive Authentication API`_.
+ *
+ * Deletes the given devices, and invalidates any access token associated with
+ * them.
+ */
+class DeleteDevicesJob : public BaseJob {
+public:
+ /*! \brief Bulk deletion of devices
+ *
+ * \param devices
+ * The list of device IDs to delete.
+ *
+ * \param auth
+ * Additional authentication information for the
+ * user-interactive authentication API.
+ */
+ explicit DeleteDevicesJob(const QStringList& devices,
+ const Omittable<AuthenticationData>& auth = none);
+};
+
+} // namespace Quotient