diff options
Diffstat (limited to 'lib/csapi/rooms.cpp')
-rw-r--r-- | lib/csapi/rooms.cpp | 60 |
1 files changed, 21 insertions, 39 deletions
diff --git a/lib/csapi/rooms.cpp b/lib/csapi/rooms.cpp index 5bfbe44d..234e33df 100644 --- a/lib/csapi/rooms.cpp +++ b/lib/csapi/rooms.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetOneRoomEventJob::Private -{ +class GetOneRoomEventJob::Private { public: EventPtr data; }; @@ -26,11 +25,9 @@ QUrl GetOneRoomEventJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, % eventId); } -static const auto GetOneRoomEventJobName = QStringLiteral("GetOneRoomEventJob"); - GetOneRoomEventJob::GetOneRoomEventJob(const QString& roomId, const QString& eventId) - : BaseJob(HttpVerb::Get, GetOneRoomEventJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetOneRoomEventJob"), basePath % "/rooms/" % roomId % "/event/" % eventId) , d(new Private) {} @@ -42,6 +39,7 @@ EventPtr&& GetOneRoomEventJob::data() { return std::move(d->data); } BaseJob::Status GetOneRoomEventJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } @@ -54,13 +52,10 @@ QUrl GetRoomStateWithKeyJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, % eventType % "/" % stateKey); } -static const auto GetRoomStateWithKeyJobName = - QStringLiteral("GetRoomStateWithKeyJob"); - GetRoomStateWithKeyJob::GetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, const QString& stateKey) - : BaseJob(HttpVerb::Get, GetRoomStateWithKeyJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomStateWithKeyJob"), basePath % "/rooms/" % roomId % "/state/" % eventType % "/" % stateKey) {} @@ -73,17 +68,13 @@ QUrl GetRoomStateByTypeJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, % eventType); } -static const auto GetRoomStateByTypeJobName = - QStringLiteral("GetRoomStateByTypeJob"); - GetRoomStateByTypeJob::GetRoomStateByTypeJob(const QString& roomId, const QString& eventType) - : BaseJob(HttpVerb::Get, GetRoomStateByTypeJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomStateByTypeJob"), basePath % "/rooms/" % roomId % "/state/" % eventType) {} -class GetRoomStateJob::Private -{ +class GetRoomStateJob::Private { public: StateEvents data; }; @@ -94,10 +85,8 @@ QUrl GetRoomStateJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) basePath % "/rooms/" % roomId % "/state"); } -static const auto GetRoomStateJobName = QStringLiteral("GetRoomStateJob"); - GetRoomStateJob::GetRoomStateJob(const QString& roomId) - : BaseJob(HttpVerb::Get, GetRoomStateJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomStateJob"), basePath % "/rooms/" % roomId % "/state") , d(new Private) {} @@ -109,11 +98,11 @@ StateEvents&& GetRoomStateJob::data() { return std::move(d->data); } BaseJob::Status GetRoomStateJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class GetMembersByRoomJob::Private -{ +class GetMembersByRoomJob::Private { public: EventsArray<RoomMemberEvent> chunk; }; @@ -134,19 +123,17 @@ QUrl GetMembersByRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& membership, const QString& notMembership) { - return BaseJob::makeRequestUrl( - std::move(baseUrl), basePath % "/rooms/" % roomId % "/members", - queryToGetMembersByRoom(at, membership, notMembership)); + return BaseJob::makeRequestUrl(std::move(baseUrl), + basePath % "/rooms/" % roomId % "/members", + queryToGetMembersByRoom(at, membership, + notMembership)); } -static const auto GetMembersByRoomJobName = - QStringLiteral("GetMembersByRoomJob"); - GetMembersByRoomJob::GetMembersByRoomJob(const QString& roomId, const QString& at, const QString& membership, const QString& notMembership) - : BaseJob(HttpVerb::Get, GetMembersByRoomJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetMembersByRoomJob"), basePath % "/rooms/" % roomId % "/members", queryToGetMembersByRoom(at, membership, notMembership)) , d(new Private) @@ -168,12 +155,10 @@ BaseJob::Status GetMembersByRoomJob::parseJson(const QJsonDocument& data) } // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter<GetJoinedMembersByRoomJob::RoomMember> -{ +struct JsonObjectConverter<GetJoinedMembersByRoomJob::RoomMember> { static void fillFrom(const QJsonObject& jo, GetJoinedMembersByRoomJob::RoomMember& result) { @@ -184,8 +169,7 @@ struct JsonObjectConverter<GetJoinedMembersByRoomJob::RoomMember> } // namespace Quotient -class GetJoinedMembersByRoomJob::Private -{ +class GetJoinedMembersByRoomJob::Private { public: QHash<QString, RoomMember> joined; }; @@ -193,15 +177,13 @@ public: QUrl GetJoinedMembersByRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { - return BaseJob::makeRequestUrl( - std::move(baseUrl), basePath % "/rooms/" % roomId % "/joined_members"); + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/rooms/" + % roomId + % "/joined_members"); } -static const auto GetJoinedMembersByRoomJobName = - QStringLiteral("GetJoinedMembersByRoomJob"); - GetJoinedMembersByRoomJob::GetJoinedMembersByRoomJob(const QString& roomId) - : BaseJob(HttpVerb::Get, GetJoinedMembersByRoomJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetJoinedMembersByRoomJob"), basePath % "/rooms/" % roomId % "/joined_members") , d(new Private) {} |