aboutsummaryrefslogtreecommitdiff
path: root/lib/connection.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/connection.h')
-rw-r--r--lib/connection.h38
1 files changed, 35 insertions, 3 deletions
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 <functional>
#include <memory>
+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<Room*(Connection*, const QString&,
@@ -95,9 +120,6 @@ namespace QMatrixClient
class Connection: public QObject {
Q_OBJECT
- /** Whether or not the rooms state should be cached locally
- * \sa loadState(), saveState()
- */
Q_PROPERTY(User* localUser READ user NOTIFY stateChanged)
Q_PROPERTY(QString localUserId READ userId NOTIFY stateChanged)
Q_PROPERTY(QString deviceId READ deviceId NOTIFY stateChanged)
@@ -105,6 +127,9 @@ namespace QMatrixClient
Q_PROPERTY(QString defaultRoomVersion READ defaultRoomVersion NOTIFY capabilitiesLoaded)
Q_PROPERTY(QUrl homeserver READ homeserver WRITE setHomeserver NOTIFY homeserverChanged)
Q_PROPERTY(QString domain READ domain NOTIFY homeserverChanged)
+ Q_PROPERTY(QVector<QMatrixClient::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 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<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 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();