aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/joining.cpp
diff options
context:
space:
mode:
authorBlack Hat <bhat@encom.eu.org>2019-09-26 22:22:36 -0700
committerBlack Hat <bhat@encom.eu.org>2019-09-26 22:22:36 -0700
commit363cf452bcdbaf6ff1cf94a83ca66cbb31122346 (patch)
treec64c8fda885e4e1785130e8ee3e7c47fd18cbf67 /lib/csapi/joining.cpp
parent412e2cf19449e73aa7da729e9c5de6502687aade (diff)
parent944653463fe4134c82d85e2d01e2bc0fa43fd727 (diff)
downloadlibquotient-363cf452bcdbaf6ff1cf94a83ca66cbb31122346.tar.gz
libquotient-363cf452bcdbaf6ff1cf94a83ca66cbb31122346.zip
Merge branch 'master' of https://github.com/quotient-im/libQuotient into
bhat-libqtolm-update
Diffstat (limited to 'lib/csapi/joining.cpp')
-rw-r--r--lib/csapi/joining.cpp113
1 files changed, 59 insertions, 54 deletions
diff --git a/lib/csapi/joining.cpp b/lib/csapi/joining.cpp
index 544f442f..2dd617bb 100644
--- a/lib/csapi/joining.cpp
+++ b/lib/csapi/joining.cpp
@@ -8,89 +8,95 @@
#include <QtCore/QStringBuilder>
-using namespace QMatrixClient;
+using namespace Quotient;
static const auto basePath = QStringLiteral("/_matrix/client/r0");
-namespace QMatrixClient
+// Converters
+namespace Quotient
{
- // Converters
- template <> struct JsonObjectConverter<JoinRoomByIdJob::ThirdPartySigned>
+template <>
+struct JsonObjectConverter<JoinRoomByIdJob::ThirdPartySigned>
+{
+ static void dumpTo(QJsonObject& jo,
+ const JoinRoomByIdJob::ThirdPartySigned& pod)
{
- static void dumpTo(QJsonObject& jo, const JoinRoomByIdJob::ThirdPartySigned& pod)
- {
- addParam<>(jo, QStringLiteral("sender"), pod.sender);
- addParam<>(jo, QStringLiteral("mxid"), pod.mxid);
- addParam<>(jo, QStringLiteral("token"), pod.token);
- addParam<>(jo, QStringLiteral("signatures"), pod.signatures);
- }
- };
-} // namespace QMatrixClient
+ addParam<>(jo, QStringLiteral("sender"), pod.sender);
+ addParam<>(jo, QStringLiteral("mxid"), pod.mxid);
+ addParam<>(jo, QStringLiteral("token"), pod.token);
+ addParam<>(jo, QStringLiteral("signatures"), pod.signatures);
+ }
+};
+
+} // namespace Quotient
class JoinRoomByIdJob::Private
{
- public:
- QString roomId;
+public:
+ QString roomId;
};
static const auto JoinRoomByIdJobName = QStringLiteral("JoinRoomByIdJob");
-JoinRoomByIdJob::JoinRoomByIdJob(const QString& roomId, const Omittable<ThirdPartySigned>& thirdPartySigned)
+JoinRoomByIdJob::JoinRoomByIdJob(
+ const QString& roomId, const Omittable<ThirdPartySigned>& thirdPartySigned)
: BaseJob(HttpVerb::Post, JoinRoomByIdJobName,
- basePath % "/rooms/" % roomId % "/join")
+ basePath % "/rooms/" % roomId % "/join")
, d(new Private)
{
QJsonObject _data;
- addParam<IfNotEmpty>(_data, QStringLiteral("third_party_signed"), thirdPartySigned);
+ addParam<IfNotEmpty>(_data, QStringLiteral("third_party_signed"),
+ thirdPartySigned);
setRequestData(_data);
}
JoinRoomByIdJob::~JoinRoomByIdJob() = default;
-const QString& JoinRoomByIdJob::roomId() const
-{
- return d->roomId;
-}
+const QString& JoinRoomByIdJob::roomId() const { return d->roomId; }
BaseJob::Status JoinRoomByIdJob::parseJson(const QJsonDocument& data)
{
auto json = data.object();
if (!json.contains("room_id"_ls))
return { IncorrectResponse,
- "The key 'room_id' not found in the response" };
+ "The key 'room_id' not found in the response" };
fromJson(json.value("room_id"_ls), d->roomId);
+
return Success;
}
-namespace QMatrixClient
+// Converters
+namespace Quotient
{
- // Converters
- template <> struct JsonObjectConverter<JoinRoomJob::Signed>
+template <>
+struct JsonObjectConverter<JoinRoomJob::Signed>
+{
+ static void dumpTo(QJsonObject& jo, const JoinRoomJob::Signed& pod)
{
- static void dumpTo(QJsonObject& jo, const JoinRoomJob::Signed& pod)
- {
- addParam<>(jo, QStringLiteral("sender"), pod.sender);
- addParam<>(jo, QStringLiteral("mxid"), pod.mxid);
- addParam<>(jo, QStringLiteral("token"), pod.token);
- addParam<>(jo, QStringLiteral("signatures"), pod.signatures);
- }
- };
-
- template <> struct JsonObjectConverter<JoinRoomJob::ThirdPartySigned>
+ addParam<>(jo, QStringLiteral("sender"), pod.sender);
+ addParam<>(jo, QStringLiteral("mxid"), pod.mxid);
+ addParam<>(jo, QStringLiteral("token"), pod.token);
+ addParam<>(jo, QStringLiteral("signatures"), pod.signatures);
+ }
+};
+
+template <>
+struct JsonObjectConverter<JoinRoomJob::ThirdPartySigned>
+{
+ static void dumpTo(QJsonObject& jo, const JoinRoomJob::ThirdPartySigned& pod)
{
- static void dumpTo(QJsonObject& jo, const JoinRoomJob::ThirdPartySigned& pod)
- {
- addParam<>(jo, QStringLiteral("signed"), pod.signedData);
- }
- };
-} // namespace QMatrixClient
+ addParam<>(jo, QStringLiteral("signed"), pod.signedData);
+ }
+};
+
+} // namespace Quotient
class JoinRoomJob::Private
{
- public:
- QString roomId;
+public:
+ QString roomId;
};
BaseJob::Query queryToJoinRoom(const QStringList& serverName)
@@ -102,31 +108,30 @@ BaseJob::Query queryToJoinRoom(const QStringList& serverName)
static const auto JoinRoomJobName = QStringLiteral("JoinRoomJob");
-JoinRoomJob::JoinRoomJob(const QString& roomIdOrAlias, const QStringList& serverName, const Omittable<ThirdPartySigned>& thirdPartySigned)
+JoinRoomJob::JoinRoomJob(const QString& roomIdOrAlias,
+ const QStringList& serverName,
+ const Omittable<ThirdPartySigned>& thirdPartySigned)
: BaseJob(HttpVerb::Post, JoinRoomJobName,
- basePath % "/join/" % roomIdOrAlias,
- queryToJoinRoom(serverName))
+ basePath % "/join/" % roomIdOrAlias, queryToJoinRoom(serverName))
, d(new Private)
{
QJsonObject _data;
- addParam<IfNotEmpty>(_data, QStringLiteral("third_party_signed"), thirdPartySigned);
+ addParam<IfNotEmpty>(_data, QStringLiteral("third_party_signed"),
+ thirdPartySigned);
setRequestData(_data);
}
JoinRoomJob::~JoinRoomJob() = default;
-const QString& JoinRoomJob::roomId() const
-{
- return d->roomId;
-}
+const QString& JoinRoomJob::roomId() const { return d->roomId; }
BaseJob::Status JoinRoomJob::parseJson(const QJsonDocument& data)
{
auto json = data.object();
if (!json.contains("room_id"_ls))
return { IncorrectResponse,
- "The key 'room_id' not found in the response" };
+ "The key 'room_id' not found in the response" };
fromJson(json.value("room_id"_ls), d->roomId);
+
return Success;
}
-