From 7033aa5ad8152f77164a4c644837d1fe44aa0430 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Wed, 25 Mar 2020 20:35:30 +0100 Subject: Connection: support getting the list of login flows Backport of #386. --- lib/connection.h | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'lib/connection.h') diff --git a/lib/connection.h b/lib/connection.h index ea5be51a..ad228bf0 100644 --- a/lib/connection.h +++ b/lib/connection.h @@ -18,6 +18,7 @@ #pragma once +#include "csapi/login.h" #include "csapi/create_room.h" #include "joinstate.h" #include "events/accountdataevents.h" @@ -30,6 +31,8 @@ #include #include +Q_DECLARE_METATYPE(QMatrixClient::GetLoginFlowsJob::LoginFlow) + namespace QMatrixClient { class Room; @@ -51,6 +54,28 @@ namespace QMatrixClient 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 + namespace LoginFlows { + using LoginFlow = GetLoginFlowsJob::LoginFlow; + static const LoginFlow Password { "m.login.password" }; + static const LoginFlow SSO { "m.login.sso" }; + static const LoginFlow Token { "m.login.token" }; + } + class Connection; using room_factory_t = std::function 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 lazyLoadingChanged) @@ -246,6 +271,12 @@ namespace QMatrixClient 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 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 Room* room(const QString& roomId, JoinStates states = JoinState::Invite|JoinState::Join) const; @@ -550,6 +581,7 @@ namespace QMatrixClient void resolveError(QString error); void homeserverChanged(QUrl baseUrl); + void loginFlowsChanged(); void capabilitiesLoaded(); void connected(); -- cgit v1.2.3