diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-05-01 20:04:51 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-05-01 20:54:17 +0900 |
commit | 21c62057bebd676a1950aa405a5f1a2c316c22ac (patch) | |
tree | e0c333c9a1e964f66ca160c50aca04765fa78c37 | |
parent | b657cd22aa64f24f2e0f9f31ef8a5d4e38a26a3a (diff) | |
download | libquotient-21c62057bebd676a1950aa405a5f1a2c316c22ac.tar.gz libquotient-21c62057bebd676a1950aa405a5f1a2c316c22ac.zip |
jobs/generated: use std::move in baseURL; type updates from the API files
The type updates are a matter of pending PR to matrix-doc yet.
-rw-r--r-- | lib/jobs/generated/administrative_contact.cpp | 4 | ||||
-rw-r--r-- | lib/jobs/generated/content-repo.cpp | 20 | ||||
-rw-r--r-- | lib/jobs/generated/content-repo.h | 6 | ||||
-rw-r--r-- | lib/jobs/generated/directory.cpp | 4 | ||||
-rw-r--r-- | lib/jobs/generated/leaving.cpp | 4 | ||||
-rw-r--r-- | lib/jobs/generated/logout.cpp | 2 | ||||
-rw-r--r-- | lib/jobs/generated/notifications.cpp | 96 | ||||
-rw-r--r-- | lib/jobs/generated/notifications.h | 25 | ||||
-rw-r--r-- | lib/jobs/generated/profile.cpp | 6 | ||||
-rw-r--r-- | lib/jobs/generated/versions.cpp | 2 | ||||
-rw-r--r-- | lib/jobs/generated/whoami.cpp | 2 |
11 files changed, 33 insertions, 138 deletions
diff --git a/lib/jobs/generated/administrative_contact.cpp b/lib/jobs/generated/administrative_contact.cpp index ede15344..bd74490c 100644 --- a/lib/jobs/generated/administrative_contact.cpp +++ b/lib/jobs/generated/administrative_contact.cpp @@ -44,7 +44,7 @@ class GetAccount3PIDsJob::Private QUrl GetAccount3PIDsJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/account/3pid"); } @@ -110,7 +110,7 @@ Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, bool bind) QUrl RequestTokenTo3PIDJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/account/3pid/email/requestToken"); } diff --git a/lib/jobs/generated/content-repo.cpp b/lib/jobs/generated/content-repo.cpp index 51011251..95fc5aed 100644 --- a/lib/jobs/generated/content-repo.cpp +++ b/lib/jobs/generated/content-repo.cpp @@ -65,7 +65,7 @@ class GetContentJob::Private QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/download/" % serverName % "/" % mediaId); } @@ -112,7 +112,7 @@ class GetContentOverrideNameJob::Private QUrl GetContentOverrideNameJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, const QString& fileName) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/download/" % serverName % "/" % mediaId % "/" % fileName); } @@ -168,7 +168,7 @@ BaseJob::Query queryToGetContentThumbnail(int width, int height, const QString& QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, int width, int height, const QString& method) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/thumbnail/" % serverName % "/" % mediaId, queryToGetContentThumbnail(width, height, method)); } @@ -205,11 +205,11 @@ BaseJob::Status GetContentThumbnailJob::parseReply(QNetworkReply* reply) class GetUrlPreviewJob::Private { public: - double matrixImageSize; + qint64 matrixImageSize; QString ogImage; }; -BaseJob::Query queryToGetUrlPreview(const QString& url, double ts) +BaseJob::Query queryToGetUrlPreview(const QString& url, qint64 ts) { BaseJob::Query _q; _q.addQueryItem("url", url); @@ -217,14 +217,14 @@ BaseJob::Query queryToGetUrlPreview(const QString& url, double ts) return _q; } -QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QString& url, double ts) +QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QString& url, qint64 ts) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/preview_url", queryToGetUrlPreview(url, ts)); } -GetUrlPreviewJob::GetUrlPreviewJob(const QString& url, double ts) +GetUrlPreviewJob::GetUrlPreviewJob(const QString& url, qint64 ts) : BaseJob(HttpVerb::Get, "GetUrlPreviewJob", basePath % "/preview_url", queryToGetUrlPreview(url, ts)) @@ -234,7 +234,7 @@ GetUrlPreviewJob::GetUrlPreviewJob(const QString& url, double ts) GetUrlPreviewJob::~GetUrlPreviewJob() = default; -double GetUrlPreviewJob::matrixImageSize() const +qint64 GetUrlPreviewJob::matrixImageSize() const { return d->matrixImageSize; } @@ -247,7 +247,7 @@ const QString& GetUrlPreviewJob::ogImage() const BaseJob::Status GetUrlPreviewJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - d->matrixImageSize = fromJson<double>(json.value("matrix:image:size")); + d->matrixImageSize = fromJson<qint64>(json.value("matrix:image:size")); d->ogImage = fromJson<QString>(json.value("og:image")); return Success; } diff --git a/lib/jobs/generated/content-repo.h b/lib/jobs/generated/content-repo.h index b4ea562f..e1e58f88 100644 --- a/lib/jobs/generated/content-repo.h +++ b/lib/jobs/generated/content-repo.h @@ -111,12 +111,12 @@ namespace QMatrixClient * a URL for GetUrlPreviewJob is necessary but the job * itself isn't. */ - static QUrl makeRequestUrl(QUrl baseUrl, const QString& url, double ts = {}); + static QUrl makeRequestUrl(QUrl baseUrl, const QString& url, qint64 ts = {}); - explicit GetUrlPreviewJob(const QString& url, double ts = {}); + explicit GetUrlPreviewJob(const QString& url, qint64 ts = {}); ~GetUrlPreviewJob() override; - double matrixImageSize() const; + qint64 matrixImageSize() const; const QString& ogImage() const; protected: diff --git a/lib/jobs/generated/directory.cpp b/lib/jobs/generated/directory.cpp index 9428dcee..6324a1f5 100644 --- a/lib/jobs/generated/directory.cpp +++ b/lib/jobs/generated/directory.cpp @@ -31,7 +31,7 @@ class GetRoomIdByAliasJob::Private QUrl GetRoomIdByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/room/" % roomAlias); } @@ -64,7 +64,7 @@ BaseJob::Status GetRoomIdByAliasJob::parseJson(const QJsonDocument& data) QUrl DeleteRoomAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/room/" % roomAlias); } diff --git a/lib/jobs/generated/leaving.cpp b/lib/jobs/generated/leaving.cpp index fbc40d11..afc4adbd 100644 --- a/lib/jobs/generated/leaving.cpp +++ b/lib/jobs/generated/leaving.cpp @@ -14,7 +14,7 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0"); QUrl LeaveRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/rooms/" % roomId % "/leave"); } @@ -26,7 +26,7 @@ LeaveRoomJob::LeaveRoomJob(const QString& roomId) QUrl ForgetRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/rooms/" % roomId % "/forget"); } diff --git a/lib/jobs/generated/logout.cpp b/lib/jobs/generated/logout.cpp index 83139842..b943dcd3 100644 --- a/lib/jobs/generated/logout.cpp +++ b/lib/jobs/generated/logout.cpp @@ -14,7 +14,7 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0"); QUrl LogoutJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/logout"); } diff --git a/lib/jobs/generated/notifications.cpp b/lib/jobs/generated/notifications.cpp index e3558097..ffd17b8a 100644 --- a/lib/jobs/generated/notifications.cpp +++ b/lib/jobs/generated/notifications.cpp @@ -12,94 +12,6 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0"); namespace QMatrixClient { - QJsonObject toJson(const GetNotificationsJob::Unsigned& pod) - { - QJsonObject o; - o.insert("age", toJson(pod.age)); - o.insert("prev_content", toJson(pod.prevContent)); - o.insert("transaction_id", toJson(pod.transactionId)); - o.insert("redacted_because", toJson(pod.redactedBecause)); - - return o; - } - - template <> struct FromJson<GetNotificationsJob::Unsigned> - { - GetNotificationsJob::Unsigned operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - GetNotificationsJob::Unsigned result; - result.age = - fromJson<qint64>(o.value("age")); - result.prevContent = - fromJson<QJsonObject>(o.value("prev_content")); - result.transactionId = - fromJson<QString>(o.value("transaction_id")); - result.redactedBecause = - fromJson<QJsonObject>(o.value("redacted_because")); - - return result; - } - }; -} // namespace QMatrixClient - -namespace QMatrixClient -{ - QJsonObject toJson(const GetNotificationsJob::Event& pod) - { - QJsonObject o; - o.insert("event_id", toJson(pod.eventId)); - o.insert("content", toJson(pod.content)); - o.insert("origin_server_ts", toJson(pod.originServerTimestamp)); - o.insert("sender", toJson(pod.sender)); - o.insert("state_key", toJson(pod.stateKey)); - o.insert("type", toJson(pod.type)); - o.insert("unsigned", toJson(pod.unsignedData)); - - return o; - } - - template <> struct FromJson<GetNotificationsJob::Event> - { - GetNotificationsJob::Event operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - GetNotificationsJob::Event result; - result.eventId = - fromJson<QString>(o.value("event_id")); - result.content = - fromJson<QJsonObject>(o.value("content")); - result.originServerTimestamp = - fromJson<qint64>(o.value("origin_server_ts")); - result.sender = - fromJson<QString>(o.value("sender")); - result.stateKey = - fromJson<QString>(o.value("state_key")); - result.type = - fromJson<QString>(o.value("type")); - result.unsignedData = - fromJson<GetNotificationsJob::Unsigned>(o.value("unsigned")); - - return result; - } - }; -} // namespace QMatrixClient - -namespace QMatrixClient -{ - QJsonObject toJson(const GetNotificationsJob::Notification& pod) - { - QJsonObject o; - o.insert("actions", toJson(pod.actions)); - o.insert("event", toJson(pod.event)); - o.insert("profile_tag", toJson(pod.profileTag)); - o.insert("read", toJson(pod.read)); - o.insert("room_id", toJson(pod.roomId)); - o.insert("ts", toJson(pod.ts)); - - return o; - } - template <> struct FromJson<GetNotificationsJob::Notification> { GetNotificationsJob::Notification operator()(const QJsonValue& jv) @@ -128,7 +40,7 @@ class GetNotificationsJob::Private { public: QString nextToken; - QVector<Notification> notifications; + std::vector<Notification> notifications; }; BaseJob::Query queryToGetNotifications(const QString& from, int limit, const QString& only) @@ -144,7 +56,7 @@ BaseJob::Query queryToGetNotifications(const QString& from, int limit, const QSt QUrl GetNotificationsJob::makeRequestUrl(QUrl baseUrl, const QString& from, int limit, const QString& only) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/notifications", queryToGetNotifications(from, limit, only)); } @@ -164,7 +76,7 @@ const QString& GetNotificationsJob::nextToken() const return d->nextToken; } -const QVector<GetNotificationsJob::Notification>& GetNotificationsJob::notifications() const +const std::vector<GetNotificationsJob::Notification>& GetNotificationsJob::notifications() const { return d->notifications; } @@ -176,7 +88,7 @@ BaseJob::Status GetNotificationsJob::parseJson(const QJsonDocument& data) if (!json.contains("notifications")) return { JsonParseError, "The key 'notifications' not found in the response" }; - d->notifications = fromJson<QVector<Notification>>(json.value("notifications")); + d->notifications = fromJson<std::vector<Notification>>(json.value("notifications")); return Success; } diff --git a/lib/jobs/generated/notifications.h b/lib/jobs/generated/notifications.h index 9249a1b7..72318f69 100644 --- a/lib/jobs/generated/notifications.h +++ b/lib/jobs/generated/notifications.h @@ -6,6 +6,8 @@ #include "../basejob.h" +#include <vector> +#include "events/event.h" #include <QtCore/QJsonObject> #include <QtCore/QVector> @@ -20,26 +22,7 @@ namespace QMatrixClient public: // Inner data structures - struct Unsigned - { - qint64 age; - QJsonObject prevContent; - QString transactionId; - QJsonObject redactedBecause; - - }; - - struct Event - { - QString eventId; - QJsonObject content; - qint64 originServerTimestamp; - QString sender; - QString stateKey; - QString type; - Unsigned unsignedData; - - }; + using Event = EventPtr; struct Notification { @@ -65,7 +48,7 @@ namespace QMatrixClient ~GetNotificationsJob() override; const QString& nextToken() const; - const QVector<Notification>& notifications() const; + const std::vector<Notification>& notifications() const; protected: Status parseJson(const QJsonDocument& data) override; diff --git a/lib/jobs/generated/profile.cpp b/lib/jobs/generated/profile.cpp index 1f7092d7..d8ddbc14 100644 --- a/lib/jobs/generated/profile.cpp +++ b/lib/jobs/generated/profile.cpp @@ -30,7 +30,7 @@ class GetDisplayNameJob::Private QUrl GetDisplayNameJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/profile/" % userId % "/displayname"); } @@ -73,7 +73,7 @@ class GetAvatarUrlJob::Private QUrl GetAvatarUrlJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/profile/" % userId % "/avatar_url"); } @@ -107,7 +107,7 @@ class GetUserProfileJob::Private QUrl GetUserProfileJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/profile/" % userId); } diff --git a/lib/jobs/generated/versions.cpp b/lib/jobs/generated/versions.cpp index b12594ca..3b03172c 100644 --- a/lib/jobs/generated/versions.cpp +++ b/lib/jobs/generated/versions.cpp @@ -20,7 +20,7 @@ class GetVersionsJob::Private QUrl GetVersionsJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/versions"); } diff --git a/lib/jobs/generated/whoami.cpp b/lib/jobs/generated/whoami.cpp index cc38fa4d..4c231b5f 100644 --- a/lib/jobs/generated/whoami.cpp +++ b/lib/jobs/generated/whoami.cpp @@ -20,7 +20,7 @@ class GetTokenOwnerJob::Private QUrl GetTokenOwnerJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/account/whoami"); } |