summary refs log tree commit diff
path: root/src/LoginPage.h
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-03-06 19:51:17 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2022-03-06 19:51:17 +0100
commit9482ac4e7acd23b1873450be977c50526677b1a3 (patch)
treef0c6a134491b33b3f7e2a7d6e095f381c8edbf17 /src/LoginPage.h
parentMobile message input (#962) (diff)
downloadnheko-9482ac4e7acd23b1873450be977c50526677b1a3.tar.xz
Allow explicit selection of SSO method
fixes #975
Diffstat (limited to 'src/LoginPage.h')
-rw-r--r--src/LoginPage.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/LoginPage.h b/src/LoginPage.h
index 9a1b9653..47896fda 100644
--- a/src/LoginPage.h
+++ b/src/LoginPage.h
@@ -7,6 +7,7 @@
 #pragma once
 
 #include <QObject>
+#include <QVariantList>
 
 namespace mtx {
 namespace responses {
@@ -14,6 +15,23 @@ struct Login;
 }
 }
 
+struct SSOProvider
+{
+    Q_GADGET
+    Q_PROPERTY(QString avatarUrl READ avatarUrl CONSTANT)
+    Q_PROPERTY(QString name READ name CONSTANT)
+    Q_PROPERTY(QString id READ id CONSTANT)
+
+public:
+    [[nodiscard]] QString avatarUrl() const { return avatarUrl_; }
+    [[nodiscard]] QString name() const { return name_.toHtmlEscaped(); }
+    [[nodiscard]] QString id() const { return id_; }
+
+    QString avatarUrl_;
+    QString name_;
+    QString id_;
+};
+
 class LoginPage : public QObject
 {
     Q_OBJECT
@@ -30,6 +48,8 @@ class LoginPage : public QObject
     Q_PROPERTY(bool ssoSupported READ ssoSupported NOTIFY versionLookedUp)
     Q_PROPERTY(bool homeserverNeeded READ homeserverNeeded NOTIFY versionLookedUp)
 
+    Q_PROPERTY(QVariantList identityProviders READ identityProviders NOTIFY versionLookedUp)
+
 public:
     enum class LoginMethod
     {
@@ -51,6 +71,7 @@ public:
     bool ssoSupported() const { return ssoSupported_; }
     bool homeserverNeeded() const { return homeserverNeeded_; }
     bool homeserverValid() const { return homeserverValid_; }
+    QVariantList identityProviders() const { return identityProviders_; }
 
     QString homeserver() { return homeserver_; }
     QString mxid() { return mxid_; }
@@ -89,7 +110,7 @@ signals:
 
     //! Used to trigger the corresponding slot outside of the main thread.
     void versionErrorCb(const QString &err);
-    void versionOkCb(bool passwordSupported, bool ssoSupported);
+    void versionOkCb(bool passwordSupported, bool ssoSupported, QVariantList identityProviders);
 
     void loginOk(const mtx::responses::Login &res);
 
@@ -116,7 +137,7 @@ public slots:
     // Callback for errors produced during server probing
     void versionError(const QString &error_message);
     // Callback for successful server probing
-    void versionOk(bool passwordSupported, bool ssoSupported);
+    void versionOk(bool passwordSupported, bool ssoSupported, QVariantList identityProviders);
 
 private:
     void checkHomeserverVersion();
@@ -137,6 +158,8 @@ private:
     QString mxidError_;
     QString error_;
 
+    QVariantList identityProviders_;
+
     bool passwordSupported_ = true;
     bool ssoSupported_      = false;