app/core/AccountSession.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "data/AccountConfig.h" | ||
| 4 | #include <QObject> | ||
| 5 | #include <QPointer> | ||
| 6 | #include <QVariantList> | ||
| 7 | |||
| 8 | class CredentialStore; | ||
| 9 | class MailSessionCore; | ||
| 10 | |||
| 11 | // Account/keyring/network ownership belongs to the mail session, not a window. | ||
| 12 | // Local account publication precedes credential resolution and network startup. | ||
| 13 | class AccountSession final : public QObject { | ||
| 14 | Q_OBJECT | ||
| 15 | public: | ||
| 16 | explicit AccountSession(MailSessionCore &session, QObject *parent = nullptr); | ||
| 17 | ~AccountSession() override; | ||
| 18 | |||
| 19 | // The directory is explicit. Empty input never falls back to a private profile. | ||
| 20 | void load(const QString &accountsDirectory, bool connectToServer = true); | ||
| 21 | bool selectAccount(const QString &id); | ||
| 22 | void configurationSaved(const QString &id); | ||
| 23 | // Q07: applies a persisted removal. Removing the active account switches | ||
| 24 | // to the first remaining one (persisted like a manual switch) or lands in | ||
| 25 | // the unconfigured state; removing another account updates selector | ||
| 26 | // metadata only, exactly like configurationSaved's non-active path. | ||
| 27 | void configurationRemoved(const QString &id); | ||
| 28 | 4332 | QVariantList availableAccounts() const { return m_availableAccounts; } | |
| 29 | // Already loaded non-secret form metadata. Reading a settings list must not | ||
| 30 | // reenter credential migration or pump a nested keyring event loop. | ||
| 31 | 2537 | QVariantList configurationMetadata() const { return m_configurationMetadata; } | |
| 32 | std::optional<AccountConfig> configuration(const QString &id) const; | ||
| 33 | // F-50 (SPRINT-104): every loaded configuration, non-secret (the same | ||
| 34 | // blanked copies configuration(id) returns) for the background watches. | ||
| 35 | 4081 | const std::vector<AccountConfig> &configurations() const { return m_configurations; } | |
| 36 | 303804 | const std::optional<AccountConfig> &primary() const { return m_primary; } | |
| 37 | 1922 | quint64 generation() const { return m_generation; } | |
| 38 | 6432 | bool networkEnabled() const { return m_networkEnabled; } | |
| 39 | 30 | bool resolvingCredentials() const { return m_resolvingCredentials; } | |
| 40 | |||
| 41 | signals: | ||
| 42 | void availableAccountsChanged(); | ||
| 43 | void configurationChanged(const QString &id); | ||
| 44 | // configurationRemoved() applied a removal (the background watches end). | ||
| 45 | void accountRemoved(const QString &id); | ||
| 46 | void accountsLoaded(quint64 generation); | ||
| 47 | void credentialsResolved(quint64 generation); | ||
| 48 | |||
| 49 | private: | ||
| 50 | void activate(std::vector<AccountConfig> accounts, const QString &selectedId, bool connectToServer); | ||
| 51 | QString m_accountsDirectory; | ||
| 52 | QVariantList m_availableAccounts; | ||
| 53 | QVariantList m_configurationMetadata; | ||
| 54 | std::vector<AccountConfig> m_configurations; | ||
| 55 | void updateConfigurationMetadata(const std::vector<AccountConfig> &accounts); | ||
| 56 | MailSessionCore &m_session; | ||
| 57 | std::optional<AccountConfig> m_primary; | ||
| 58 | QPointer<CredentialStore> m_credentials; | ||
| 59 | quint64 m_generation = 0; | ||
| 60 | bool m_networkEnabled = false; | ||
| 61 | bool m_resolvingCredentials = false; | ||
| 62 | }; | ||
| 63 |