1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/******************************************************************************
* THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
*/
#include "presence.h"
#include "converters.h"
#include <QtCore/QStringBuilder>
using namespace QMatrixClient;
static const auto basePath = QStringLiteral("/_matrix/client/r0");
SetPresenceJob::SetPresenceJob(const QString& userId, const QString& presence, const QString& statusMsg)
: BaseJob(HttpVerb::Put, "SetPresenceJob",
basePath % "/presence/" % userId % "/status")
{
QJsonObject _data;
addParam<>(_data, "presence", presence);
addParam<IfNotEmpty>(_data, "status_msg", statusMsg);
setRequestData(_data);
}
class GetPresenceJob::Private
{
public:
QString presence;
Omittable<int> lastActiveAgo;
QString statusMsg;
bool currentlyActive;
};
QUrl GetPresenceJob::makeRequestUrl(QUrl baseUrl, const QString& userId)
{
return BaseJob::makeRequestUrl(std::move(baseUrl),
basePath % "/presence/" % userId % "/status");
}
GetPresenceJob::GetPresenceJob(const QString& userId)
: BaseJob(HttpVerb::Get, "GetPresenceJob",
basePath % "/presence/" % userId % "/status", false)
, d(new Private)
{
}
GetPresenceJob::~GetPresenceJob() = default;
const QString& GetPresenceJob::presence() const
{
return d->presence;
}
Omittable<int> GetPresenceJob::lastActiveAgo() const
{
return d->lastActiveAgo;
}
const QString& GetPresenceJob::statusMsg() const
{
return d->statusMsg;
}
bool GetPresenceJob::currentlyActive() const
{
return d->currentlyActive;
}
BaseJob::Status GetPresenceJob::parseJson(const QJsonDocument& data)
{
auto json = data.object();
if (!json.contains("presence"))
return { JsonParseError,
"The key 'presence' not found in the response" };
d->presence = fromJson<QString>(json.value("presence"));
d->lastActiveAgo = fromJson<int>(json.value("last_active_ago"));
d->statusMsg = fromJson<QString>(json.value("status_msg"));
d->currentlyActive = fromJson<bool>(json.value("currently_active"));
return Success;
}
ModifyPresenceListJob::ModifyPresenceListJob(const QString& userId, const QStringList& invite, const QStringList& drop)
: BaseJob(HttpVerb::Post, "ModifyPresenceListJob",
basePath % "/presence/list/" % userId)
{
QJsonObject _data;
addParam<IfNotEmpty>(_data, "invite", invite);
addParam<IfNotEmpty>(_data, "drop", drop);
setRequestData(_data);
}
class GetPresenceForListJob::Private
{
public:
Events data;
};
QUrl GetPresenceForListJob::makeRequestUrl(QUrl baseUrl, const QString& userId)
{
return BaseJob::makeRequestUrl(std::move(baseUrl),
basePath % "/presence/list/" % userId);
}
GetPresenceForListJob::GetPresenceForListJob(const QString& userId)
: BaseJob(HttpVerb::Get, "GetPresenceForListJob",
basePath % "/presence/list/" % userId, false)
, d(new Private)
{
}
GetPresenceForListJob::~GetPresenceForListJob() = default;
Events&& GetPresenceForListJob::data()
{
return std::move(d->data);
}
BaseJob::Status GetPresenceForListJob::parseJson(const QJsonDocument& data)
{
auto json = data.object();
if (!json.contains("data"))
return { JsonParseError,
"The key 'data' not found in the response" };
d->data = fromJson<Events>(json.value("data"));
return Success;
}
|