aboutsummaryrefslogtreecommitdiff
path: root/jobs/generated
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-10-19 19:36:10 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2017-10-19 19:40:47 +0900
commit76438ba95d16c7d007fc16ffc194889f937a19f7 (patch)
treee0c578596254532310b7f0d8f4a37236bfa0670b /jobs/generated
parent756e716886036447915a10992189774991f4dd8d (diff)
downloadlibquotient-76438ba95d16c7d007fc16ffc194889f937a19f7.tar.gz
libquotient-76438ba95d16c7d007fc16ffc194889f937a19f7.zip
Introduce device_id and initial_device_name support; switch to generated LoginJob
This is _almost_ a backwards-compatible change, except that connect*() and other relevant methods in Connection are no more virtual (that wasn't much useful anyway). Otherwise it's a matter of passing initial_device_name to connectToServer(), saving device_id (along with access_token) from the result of LoginJob and then passing device_id (along with access_token, again) to connectWithToken() upon the next run.
Diffstat (limited to 'jobs/generated')
-rw-r--r--jobs/generated/login.cpp89
-rw-r--r--jobs/generated/login.h38
2 files changed, 127 insertions, 0 deletions
diff --git a/jobs/generated/login.cpp b/jobs/generated/login.cpp
new file mode 100644
index 00000000..6e8294e7
--- /dev/null
+++ b/jobs/generated/login.cpp
@@ -0,0 +1,89 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+
+#include "login.h"
+
+#include "jobs/converters.h"
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+class LoginJob::Private
+{
+ public:
+ QString user_id;
+ QString access_token;
+ QString home_server;
+ QString device_id;
+
+};
+
+LoginJob::LoginJob(QString type, QString user, QString medium, QString address, QString password, QString token, QString device_id, QString initial_device_display_name)
+ : BaseJob(HttpVerb::Post, "LoginJob",
+ basePath % "/login",
+ Query { }, Data { }, false
+ ), d(new Private)
+{
+ Data _data;
+ _data.insert("type", toJson(type));
+ if (!user.isEmpty())
+ _data.insert("user", toJson(user));
+ if (!medium.isEmpty())
+ _data.insert("medium", toJson(medium));
+ if (!address.isEmpty())
+ _data.insert("address", toJson(address));
+ if (!password.isEmpty())
+ _data.insert("password", toJson(password));
+ if (!token.isEmpty())
+ _data.insert("token", toJson(token));
+ if (!device_id.isEmpty())
+ _data.insert("device_id", toJson(device_id));
+ if (!initial_device_display_name.isEmpty())
+ _data.insert("initial_device_display_name", toJson(initial_device_display_name));
+ setRequestData(_data);
+}
+
+LoginJob::~LoginJob()
+{
+ delete d;
+}
+
+const QString& LoginJob::user_id() const
+{
+ return d->user_id;
+}
+
+const QString& LoginJob::access_token() const
+{
+ return d->access_token;
+}
+
+const QString& LoginJob::home_server() const
+{
+ return d->home_server;
+}
+
+const QString& LoginJob::device_id() const
+{
+ return d->device_id;
+}
+
+BaseJob::Status LoginJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+
+ d->user_id = fromJson<QString>(json.value("user_id"));
+
+ d->access_token = fromJson<QString>(json.value("access_token"));
+
+ d->home_server = fromJson<QString>(json.value("home_server"));
+
+ d->device_id = fromJson<QString>(json.value("device_id"));
+
+ return Success;
+}
+
diff --git a/jobs/generated/login.h b/jobs/generated/login.h
new file mode 100644
index 00000000..dc89206d
--- /dev/null
+++ b/jobs/generated/login.h
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+
+#pragma once
+
+#include "../basejob.h"
+
+#include <QtCore/QString>
+
+
+namespace QMatrixClient
+{
+
+ // Operations
+
+ class LoginJob : public BaseJob
+ {
+ public:
+ explicit LoginJob(QString type, QString user = {}, QString medium = {}, QString address = {}, QString password = {}, QString token = {}, QString device_id = {}, QString initial_device_display_name = {});
+
+ ~LoginJob() override;
+
+ const QString& user_id() const;
+ const QString& access_token() const;
+ const QString& home_server() const;
+ const QString& device_id() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ Private* d;
+ };
+
+} // namespace QMatrixClient