aboutsummaryrefslogtreecommitdiff
path: root/lib/connection.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-03-13 18:39:59 +0100
committerKitsune Ral <Kitsune-Ral@users.sf.net>2020-03-13 18:39:59 +0100
commit4102144290312ebed7d4af69dd640835275a9675 (patch)
tree33599d55519b5d32dc82b485cb348b6f685d679c /lib/connection.h
parent301d29e8db272938b0977af5db872c80f89fd708 (diff)
downloadlibquotient-4102144290312ebed7d4af69dd640835275a9675.tar.gz
libquotient-4102144290312ebed7d4af69dd640835275a9675.zip
Connection: support getting the list of login flows
The flows themselves are not facilitated in any way (yet).
Diffstat (limited to 'lib/connection.h')
-rw-r--r--lib/connection.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/connection.h b/lib/connection.h
index b57f0ca8..9d89ca43 100644
--- a/lib/connection.h
+++ b/lib/connection.h
@@ -21,6 +21,7 @@
#include "joinstate.h"
#include "qt_connection_util.h"
+#include "csapi/login.h"
#include "csapi/create_room.h"
#include "events/accountdataevents.h"
@@ -36,6 +37,8 @@ namespace QtOlm {
class Account;
}
+Q_DECLARE_METATYPE(Quotient::GetLoginFlowsJob::LoginFlow)
+
namespace Quotient {
Q_NAMESPACE
@@ -58,6 +61,28 @@ class SendToDeviceJob;
class SendMessageJob;
class LeaveRoomJob;
+// To simplify comparisons of LoginFlows
+
+inline bool operator==(const GetLoginFlowsJob::LoginFlow& lhs,
+ const GetLoginFlowsJob::LoginFlow& rhs)
+{
+ return lhs.type == rhs.type;
+}
+
+inline bool operator!=(const GetLoginFlowsJob::LoginFlow& lhs,
+ const GetLoginFlowsJob::LoginFlow& rhs)
+{
+ return !(lhs == rhs);
+}
+
+/// Predefined login flows
+struct LoginFlows {
+ using LoginFlow = GetLoginFlowsJob::LoginFlow;
+ static inline const LoginFlow Password { "m.login.password" };
+ static inline const LoginFlow SSO { "m.login.sso" };
+ static inline const LoginFlow Token { "m.login.token" };
+};
+
class Connection;
using room_factory_t =
@@ -117,6 +142,9 @@ class Connection : public QObject {
Q_PROPERTY(QUrl homeserver READ homeserver WRITE setHomeserver NOTIFY
homeserverChanged)
Q_PROPERTY(QString domain READ domain NOTIFY homeserverChanged)
+ Q_PROPERTY(QVector<Quotient::GetLoginFlowsJob::LoginFlow> loginFlows READ loginFlows NOTIFY loginFlowsChanged)
+ Q_PROPERTY(bool supportsSso READ supportsSso NOTIFY loginFlowsChanged)
+ Q_PROPERTY(bool supportsPasswordAuth READ supportsPasswordAuth NOTIFY loginFlowsChanged)
Q_PROPERTY(bool cacheState READ cacheState WRITE setCacheState NOTIFY
cacheStateChanged)
Q_PROPERTY(bool lazyLoading READ lazyLoading WRITE setLazyLoading NOTIFY
@@ -281,6 +309,12 @@ public:
QUrl homeserver() const;
/** Get the domain name used for ids/aliases on the server */
QString domain() const;
+ /** Get the list of supported login flows */
+ QVector<GetLoginFlowsJob::LoginFlow> loginFlows() const;
+ /** Check whether the current homeserver supports password auth */
+ bool supportsPasswordAuth() const;
+ /** Check whether the current homeserver supports SSO */
+ bool supportsSso() const;
/** Find a room by its id and a mask of applicable states */
Q_INVOKABLE Quotient::Room*
room(const QString& roomId,
@@ -421,6 +455,18 @@ public:
std::forward<JobArgTs>(jobArgs)...);
}
+ /*! Get a request URL for a job with specified type and arguments
+ *
+ * This calls JobT::makeRequestUrl() prepending the connection's homeserver
+ * to the list of arguments.
+ */
+ template <typename JobT, typename... JobArgTs>
+ QUrl getUrlForApi(JobArgTs&&... jobArgs) const
+ {
+ return JobT::makeRequestUrl(homeserver(),
+ std::forward<JobArgTs>(jobArgs)...);
+ }
+
/** Generate a new transaction id. Transaction id's are unique within
* a single Connection object
*/
@@ -609,6 +655,7 @@ signals:
void resolveError(QString error);
void homeserverChanged(QUrl baseUrl);
+ void loginFlowsChanged();
void capabilitiesLoaded();
void connected();