diff options
author | Andres Salomon <dilinger@queued.net> | 2021-01-18 04:00:14 -0500 |
---|---|---|
committer | Andres Salomon <dilinger@queued.net> | 2021-01-18 04:00:14 -0500 |
commit | 09eb39236666e81d5da014acea011dcd74d0999b (patch) | |
tree | 52876d96be71be1a39d5d935c1295a51995e8949 /lib/csapi/definitions/client_device.h | |
parent | f1788ee27f33e9339334e0d79bde9a27d9ce2e44 (diff) | |
parent | a4e78956f105875625b572d8b98459ffa86fafe5 (diff) | |
download | libquotient-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/definitions/client_device.h')
-rw-r--r-- | lib/csapi/definitions/client_device.h | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/lib/csapi/definitions/client_device.h b/lib/csapi/definitions/client_device.h index a6224f71..a5ab1bfc 100644 --- a/lib/csapi/definitions/client_device.h +++ b/lib/csapi/definitions/client_device.h @@ -6,32 +6,43 @@ #include "converters.h" -#include "converters.h" +namespace Quotient { +/// A client device +struct Device { + /// Identifier of this device. + QString deviceId; + + /// Display name set by the user for this device. Absent if no name has been + /// set. + QString displayName; + + /// The IP address where this device was last seen. (May be a few minutes + /// out of date, for efficiency reasons). + QString lastSeenIp; -namespace QMatrixClient -{ - // Data structures + /// The timestamp (in milliseconds since the unix epoch) when this devices + /// was last seen. (May be a few minutes out of date, for efficiency + /// reasons). + Omittable<qint64> lastSeenTs; +}; - /// A client device - struct Device +template <> +struct JsonObjectConverter<Device> { + static void dumpTo(QJsonObject& jo, const Device& pod) { - /// Identifier of this device. - QString deviceId; - /// Display name set by the user for this device. Absent if no name has been - /// set. - QString displayName; - /// The IP address where this device was last seen. (May be a few minutes out - /// of date, for efficiency reasons). - QString lastSeenIp; - /// The timestamp (in milliseconds since the unix epoch) when this devices - /// was last seen. (May be a few minutes out of date, for efficiency - /// reasons). - Omittable<qint64> lastSeenTs; - }; - template <> struct JsonObjectConverter<Device> + addParam<>(jo, QStringLiteral("device_id"), pod.deviceId); + addParam<IfNotEmpty>(jo, QStringLiteral("display_name"), + pod.displayName); + addParam<IfNotEmpty>(jo, QStringLiteral("last_seen_ip"), pod.lastSeenIp); + addParam<IfNotEmpty>(jo, QStringLiteral("last_seen_ts"), pod.lastSeenTs); + } + static void fillFrom(const QJsonObject& jo, Device& pod) { - static void dumpTo(QJsonObject& jo, const Device& pod); - static void fillFrom(const QJsonObject& jo, Device& pod); - }; + fromJson(jo.value("device_id"_ls), pod.deviceId); + fromJson(jo.value("display_name"_ls), pod.displayName); + fromJson(jo.value("last_seen_ip"_ls), pod.lastSeenIp); + fromJson(jo.value("last_seen_ts"_ls), pod.lastSeenTs); + } +}; -} // namespace QMatrixClient +} // namespace Quotient |