aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/login.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-11 18:34:41 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-11 18:34:41 +0900
commit606db144b9ef6f1b2958ff49c4a6860bff48090c (patch)
treea9716d076722497a91ea94f6ff2281eebf205d0f /lib/csapi/login.cpp
parent88834ea75ee3304f8ab773e05aa64ce84643f236 (diff)
downloadlibquotient-606db144b9ef6f1b2958ff49c4a6860bff48090c.tar.gz
libquotient-606db144b9ef6f1b2958ff49c4a6860bff48090c.zip
csapi: Update to the latest API definitions
Presence requires authentication; GetConfigJob; GetLoginFlowsJob; serverName parameter in JoinRoomJob.
Diffstat (limited to 'lib/csapi/login.cpp')
-rw-r--r--lib/csapi/login.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/csapi/login.cpp b/lib/csapi/login.cpp
index b8734d05..3956a1c4 100644
--- a/lib/csapi/login.cpp
+++ b/lib/csapi/login.cpp
@@ -12,6 +12,59 @@ using namespace QMatrixClient;
static const auto basePath = QStringLiteral("/_matrix/client/r0");
+namespace QMatrixClient
+{
+ // Converters
+
+ template <> struct FromJson<GetLoginFlowsJob::LoginFlow>
+ {
+ GetLoginFlowsJob::LoginFlow operator()(const QJsonValue& jv)
+ {
+ const auto& _json = jv.toObject();
+ GetLoginFlowsJob::LoginFlow result;
+ result.type =
+ fromJson<QString>(_json.value("type"_ls));
+
+ return result;
+ }
+ };
+} // namespace QMatrixClient
+
+class GetLoginFlowsJob::Private
+{
+ public:
+ QVector<LoginFlow> flows;
+};
+
+QUrl GetLoginFlowsJob::makeRequestUrl(QUrl baseUrl)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/login");
+}
+
+static const auto GetLoginFlowsJobName = QStringLiteral("GetLoginFlowsJob");
+
+GetLoginFlowsJob::GetLoginFlowsJob()
+ : BaseJob(HttpVerb::Get, GetLoginFlowsJobName,
+ basePath % "/login", false)
+ , d(new Private)
+{
+}
+
+GetLoginFlowsJob::~GetLoginFlowsJob() = default;
+
+const QVector<GetLoginFlowsJob::LoginFlow>& GetLoginFlowsJob::flows() const
+{
+ return d->flows;
+}
+
+BaseJob::Status GetLoginFlowsJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ d->flows = fromJson<QVector<LoginFlow>>(json.value("flows"_ls));
+ return Success;
+}
+
class LoginJob::Private
{
public: