aboutsummaryrefslogtreecommitdiff
path: root/jobs/generated/profile.cpp
blob: 1f7092d7b31db61696ce8ea0146e0a3a856f889b (plain)
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
128
129
130
131
132
133
134
135
136
137
138
139
140
/******************************************************************************
 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
 */

#include "profile.h"

#include "converters.h"

#include <QtCore/QStringBuilder>

using namespace QMatrixClient;

static const auto basePath = QStringLiteral("/_matrix/client/r0");

SetDisplayNameJob::SetDisplayNameJob(const QString& userId, const QString& displayname)
    : BaseJob(HttpVerb::Put, "SetDisplayNameJob",
        basePath % "/profile/" % userId % "/displayname")
{
    QJsonObject _data;
    if (!displayname.isEmpty())
        _data.insert("displayname", toJson(displayname));
    setRequestData(_data);
}

class GetDisplayNameJob::Private
{
    public:
        QString displayname;
};

QUrl GetDisplayNameJob::makeRequestUrl(QUrl baseUrl, const QString& userId)
{
    return BaseJob::makeRequestUrl(baseUrl,
            basePath % "/profile/" % userId % "/displayname");
}

GetDisplayNameJob::GetDisplayNameJob(const QString& userId)
    : BaseJob(HttpVerb::Get, "GetDisplayNameJob",
        basePath % "/profile/" % userId % "/displayname", false)
    , d(new Private)
{
}

GetDisplayNameJob::~GetDisplayNameJob() = default;

const QString& GetDisplayNameJob::displayname() const
{
    return d->displayname;
}

BaseJob::Status GetDisplayNameJob::parseJson(const QJsonDocument& data)
{
    auto json = data.object();
    d->displayname = fromJson<QString>(json.value("displayname"));
    return Success;
}

SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QString& avatarUrl)
    : BaseJob(HttpVerb::Put, "SetAvatarUrlJob",
        basePath % "/profile/" % userId % "/avatar_url")
{
    QJsonObject _data;
    if (!avatarUrl.isEmpty())
        _data.insert("avatar_url", toJson(avatarUrl));
    setRequestData(_data);
}

class GetAvatarUrlJob::Private
{
    public:
        QString avatarUrl;
};

QUrl GetAvatarUrlJob::makeRequestUrl(QUrl baseUrl, const QString& userId)
{
    return BaseJob::makeRequestUrl(baseUrl,
            basePath % "/profile/" % userId % "/avatar_url");
}

GetAvatarUrlJob::GetAvatarUrlJob(const QString& userId)
    : BaseJob(HttpVerb::Get, "GetAvatarUrlJob",
        basePath % "/profile/" % userId % "/avatar_url", false)
    , d(new Private)
{
}

GetAvatarUrlJob::~GetAvatarUrlJob() = default;

const QString& GetAvatarUrlJob::avatarUrl() const
{
    return d->avatarUrl;
}

BaseJob::Status GetAvatarUrlJob::parseJson(const QJsonDocument& data)
{
    auto json = data.object();
    d->avatarUrl = fromJson<QString>(json.value("avatar_url"));
    return Success;
}

class GetUserProfileJob::Private
{
    public:
        QString avatarUrl;
        QString displayname;
};

QUrl GetUserProfileJob::makeRequestUrl(QUrl baseUrl, const QString& userId)
{
    return BaseJob::makeRequestUrl(baseUrl,
            basePath % "/profile/" % userId);
}

GetUserProfileJob::GetUserProfileJob(const QString& userId)
    : BaseJob(HttpVerb::Get, "GetUserProfileJob",
        basePath % "/profile/" % userId, false)
    , d(new Private)
{
}

GetUserProfileJob::~GetUserProfileJob() = default;

const QString& GetUserProfileJob::avatarUrl() const
{
    return d->avatarUrl;
}

const QString& GetUserProfileJob::displayname() const
{
    return d->displayname;
}

BaseJob::Status GetUserProfileJob::parseJson(const QJsonDocument& data)
{
    auto json = data.object();
    d->avatarUrl = fromJson<QString>(json.value("avatar_url"));
    d->displayname = fromJson<QString>(json.value("displayname"));
    return Success;
}
">userSigningKeys() const { return loadFromJson<QHash<QString, CrossSigningKey>>( "user_signing_keys"_ls); } }; template <> struct JsonObjectConverter<QueryKeysJob::UnsignedDeviceInfo> { static void fillFrom(const QJsonObject& jo, QueryKeysJob::UnsignedDeviceInfo& result) { fromJson(jo.value("device_display_name"_ls), result.deviceDisplayName); } }; template <> struct JsonObjectConverter<QueryKeysJob::DeviceInformation> { static void fillFrom(const QJsonObject& jo, QueryKeysJob::DeviceInformation& result) { fillFromJson<DeviceKeys>(jo, result); fromJson(jo.value("unsigned"_ls), result.unsignedData); } }; /*! \brief Claim one-time encryption keys. * * Claims one-time keys for use in pre-key messages. */ class QUOTIENT_API ClaimKeysJob : public BaseJob { public: /*! \brief Claim one-time encryption keys. * * \param oneTimeKeys * The keys to be claimed. A map from user ID, to a map from * device ID to algorithm name. * * \param timeout * The time (in milliseconds) to wait when downloading keys from * remote servers. 10 seconds is the recommended default. */ explicit ClaimKeysJob( const QHash<QString, QHash<QString, QString>>& oneTimeKeys, Omittable<int> timeout = none); // Result properties /// If any remote homeservers could not be reached, they are /// recorded here. The names of the properties are the names of /// the unreachable servers. /// /// If the homeserver could be reached, but the user or device /// was unknown, no failure is recorded. Instead, the corresponding /// user or device is missing from the `one_time_keys` result. QHash<QString, QJsonObject> failures() const { return loadFromJson<QHash<QString, QJsonObject>>("failures"_ls); } /// One-time keys for the queried devices. A map from user ID, to a /// map from devices to a map from `<algorithm>:<key_id>` to the key object. /// /// See the [key algorithms](/client-server-api/#key-algorithms) section for /// information on the Key Object format. QHash<QString, QHash<QString, QVariant>> oneTimeKeys() const { return loadFromJson<QHash<QString, QHash<QString, QVariant>>>( "one_time_keys"_ls); } }; /*! \brief Query users with recent device key updates. * * Gets a list of users who have updated their device identity keys since a * previous sync token. * * The server should include in the results any users who: * * * currently share a room with the calling user (ie, both users have * membership state `join`); *and* * * added new device identity keys or removed an existing device with * identity keys, between `from` and `to`. */ class QUOTIENT_API GetKeysChangesJob : public BaseJob { public: /*! \brief Query users with recent device key updates. * * \param from * The desired start point of the list. Should be the `next_batch` field * from a response to an earlier call to * [`/sync`](/client-server-api/#get_matrixclientr0sync). Users who have not * uploaded new device identity keys since this point, nor deleted * existing devices with identity keys since then, will be excluded * from the results. * * \param to * The desired end point of the list. Should be the `next_batch` * field from a recent call to * [`/sync`](/client-server-api/#get_matrixclientr0sync) - typically the * most recent such call. This may be used by the server as a hint to check * its caches are up to date. */ explicit GetKeysChangesJob(const QString& from, const QString& to); /*! \brief Construct a URL without creating a full-fledged job object * * This function can be used when a URL for GetKeysChangesJob * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& from, const QString& to); // Result properties /// The Matrix User IDs of all users who updated their device /// identity keys. QStringList changed() const { return loadFromJson<QStringList>("changed"_ls); } /// The Matrix User IDs of all users who may have left all /// the end-to-end encrypted rooms they previously shared /// with the user. QStringList left() const { return loadFromJson<QStringList>("left"_ls); } }; } // namespace Quotient