libQuotient
A Qt library for building matrix clients
client_device.h
Go to the documentation of this file.
1 // THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
2 
3 #pragma once
4 
5 #include <Quotient/converters.h>
6 
7 namespace Quotient {
8 //! A client device
9 struct QUOTIENT_API Device {
10  //! Identifier of this device.
11  QString deviceId;
12 
13  //! Display name set by the user for this device. Absent if no name has been
14  //! set.
15  QString displayName{};
16 
17  //! The IP address where this device was last seen. (May be a few minutes out
18  //! of date, for efficiency reasons).
19  QString lastSeenIp{};
20 
21  //! The timestamp (in milliseconds since the unix epoch) when this devices
22  //! was last seen. (May be a few minutes out of date, for efficiency
23  //! reasons).
24  std::optional<qint64> lastSeenTs{};
25 };
26 
27 template <>
28 struct JsonObjectConverter<Device> {
29  static void dumpTo(QJsonObject& jo, const Device& pod)
30  {
31  addParam<>(jo, "device_id"_L1, pod.deviceId);
32  addParam<IfNotEmpty>(jo, "display_name"_L1, pod.displayName);
33  addParam<IfNotEmpty>(jo, "last_seen_ip"_L1, pod.lastSeenIp);
34  addParam<IfNotEmpty>(jo, "last_seen_ts"_L1, pod.lastSeenTs);
35  }
36  static void fillFrom(const QJsonObject& jo, Device& pod)
37  {
38  fillFromJson(jo.value("device_id"_L1), pod.deviceId);
39  fillFromJson(jo.value("display_name"_L1), pod.displayName);
40  fillFromJson(jo.value("last_seen_ip"_L1), pod.lastSeenIp);
41  fillFromJson(jo.value("last_seen_ts"_L1), pod.lastSeenTs);
42  }
43 };
44 
45 } // namespace Quotient