diff options
author | Tobias Fella <fella@posteo.de> | 2022-05-27 21:03:31 +0200 |
---|---|---|
committer | Tobias Fella <fella@posteo.de> | 2022-05-27 21:13:44 +0200 |
commit | 946cd4cb73f95526aa09777afc2a493610d9696d (patch) | |
tree | ee3bb02888addc2afc6d51528574d6b2cfa31b9d /lib/accountregistry.h | |
parent | 729ba7da174eacc88bf9bd4e2e80eeab3fc92716 (diff) | |
download | libquotient-946cd4cb73f95526aa09777afc2a493610d9696d.tar.gz libquotient-946cd4cb73f95526aa09777afc2a493610d9696d.zip |
Load and store accounts in the keychain
Diffstat (limited to 'lib/accountregistry.h')
-rw-r--r-- | lib/accountregistry.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/accountregistry.h b/lib/accountregistry.h index 2f6dffdf..ab337303 100644 --- a/lib/accountregistry.h +++ b/lib/accountregistry.h @@ -5,15 +5,25 @@ #pragma once #include "quotient_export.h" +#include "settings.h" #include <QtCore/QAbstractListModel> +namespace QKeychain { +class ReadPasswordJob; +} + namespace Quotient { class Connection; class QUOTIENT_API AccountRegistry : public QAbstractListModel, private QVector<Connection*> { Q_OBJECT + /// Number of accounts that are currently fully loaded + Q_PROPERTY(int accountCount READ rowCount NOTIFY accountCountChanged) + /// List of accounts that are currently in some stage of being loaded (Reading token from keychain, trying to contact server, etc). + /// Can be used to inform the user or to show a login screen if size() == 0 and no accounts are loaded + Q_PROPERTY(QStringList accountsLoading READ accountsLoading NOTIFY accountsLoadingChanged) public: using const_iterator = QVector::const_iterator; using const_reference = QVector::const_reference; @@ -52,6 +62,16 @@ public: [[nodiscard]] int rowCount( const QModelIndex& parent = QModelIndex()) const override; [[nodiscard]] QHash<int, QByteArray> roleNames() const override; + + QStringList accountsLoading() const; + + void invokeLogin(); +Q_SIGNALS: + void accountCountChanged(); + void accountsLoadingChanged(); +private: + QKeychain::ReadPasswordJob* loadAccessTokenFromKeychain(const QString &userId); + QStringList m_accountsLoading; }; inline QUOTIENT_API AccountRegistry Accounts {}; |