diff options
| author | Andrew Branson <andrew.branson@jolla.com> | 2026-02-10 10:41:02 +0100 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@jolla.com> | 2026-02-10 17:09:39 +0100 |
| commit | 4351f4627ba9e71775438dd26c9acddd002c7e11 (patch) | |
| tree | 3c72c980c5c81507109087bda67052b7ec8216b6 /transferengine-plugins/mastodonshareservicestatus.h | |
Initial commit
Diffstat (limited to 'transferengine-plugins/mastodonshareservicestatus.h')
| -rw-r--r-- | transferengine-plugins/mastodonshareservicestatus.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/transferengine-plugins/mastodonshareservicestatus.h b/transferengine-plugins/mastodonshareservicestatus.h new file mode 100644 index 0000000..571efd5 --- /dev/null +++ b/transferengine-plugins/mastodonshareservicestatus.h @@ -0,0 +1,75 @@ +#ifndef MASTODONSHARESERVICESTATUS_H +#define MASTODONSHARESERVICESTATUS_H + +#include <QtCore/QHash> +#include <QtCore/QObject> +#include <QtCore/QVector> + +#include <accountauthenticator.h> + +namespace Accounts { +class Account; +class Manager; +} + +namespace SignOn { +class Error; +class SessionData; +} + +class MastodonShareServiceStatus : public QObject +{ + Q_OBJECT + +public: + explicit MastodonShareServiceStatus(QObject *parent = 0); + + enum QueryStatusMode { + PassiveMode = 0, + SignInMode = 1 + }; + + void queryStatus(QueryStatusMode mode = SignInMode); + + struct AccountDetails { + int accountId = 0; + QString providerName; + QString displayName; + QString accessToken; + QString apiHost; + }; + + AccountDetails details(int index = 0) const; + AccountDetails detailsByIdentifier(int accountIdentifier) const; + int count() const; + + bool setCredentialsNeedUpdate(int accountId, const QString &serviceName); + +Q_SIGNALS: + void serviceReady(); + void serviceError(const QString &message); + +private Q_SLOTS: + void signOnResponse(const SignOn::SessionData &responseData); + void signOnError(const SignOn::Error &error); + +private: + enum AccountDetailsState { + Waiting, + Populated, + Error + }; + + static QString normalizeApiHost(const QString &rawHost); + void setAccountDetailsState(int accountId, AccountDetailsState state); + void signIn(int accountId); + + AccountAuthenticator *m_auth; + Accounts::Manager *m_accountManager; + QString m_serviceName; + QVector<AccountDetails> m_accountDetails; + QHash<int, int> m_accountIdToDetailsIdx; + QHash<int, AccountDetailsState> m_accountDetailsState; +}; + +#endif // MASTODONSHARESERVICESTATUS_H |
