2023-08-05 22:14:05 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
#pragma once
|
|
|
|
|
2024-07-04 20:53:06 -04:00
|
|
|
#include <QtQml>
|
2023-10-06 18:08:21 -04:00
|
|
|
#include <qcorotask.h>
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2025-03-17 18:27:17 -04:00
|
|
|
class AccountConfig;
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
class Account : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2023-09-16 18:01:02 -04:00
|
|
|
QML_ELEMENT
|
|
|
|
QML_UNCREATABLE("Use from AccountManager")
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2025-03-17 18:27:17 -04:00
|
|
|
Q_PROPERTY(AccountConfig *config READ config CONSTANT)
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_PROPERTY(QString avatarUrl READ avatarUrl NOTIFY avatarUrlChanged)
|
2023-12-20 19:47:57 -05:00
|
|
|
Q_PROPERTY(bool needsPassword READ needsPassword NOTIFY needsPasswordChanged)
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
public:
|
2024-08-22 18:53:46 -04:00
|
|
|
explicit Account(const QString &key, QObject *parent = nullptr);
|
2025-03-17 18:47:32 -04:00
|
|
|
~Account() override;
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2025-03-17 18:27:17 -04:00
|
|
|
enum GameLicense {
|
|
|
|
WindowsStandalone,
|
|
|
|
WindowsSteam,
|
|
|
|
macOS
|
|
|
|
};
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_ENUM(GameLicense)
|
|
|
|
|
2023-09-16 21:22:20 -04:00
|
|
|
[[nodiscard]] QString uuid() const;
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-09-16 21:22:20 -04:00
|
|
|
[[nodiscard]] QString avatarUrl() const;
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-07-30 10:11:14 -04:00
|
|
|
Q_INVOKABLE QString getPassword();
|
2023-07-30 08:49:34 -04:00
|
|
|
void setPassword(const QString &password);
|
|
|
|
|
2024-08-22 18:46:45 -04:00
|
|
|
void setAvatarUrl(const QString &url);
|
|
|
|
|
2023-07-30 10:11:14 -04:00
|
|
|
Q_INVOKABLE QString getOTP();
|
2023-09-20 15:33:26 -04:00
|
|
|
Q_INVOKABLE void setOTPSecret(const QString &secret);
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-10-11 14:40:56 -04:00
|
|
|
/// Returns the path to the FFXIV config folder
|
2023-09-16 21:22:20 -04:00
|
|
|
[[nodiscard]] QDir getConfigDir() const;
|
2024-04-19 20:50:14 -04:00
|
|
|
[[nodiscard]] Q_INVOKABLE QString getConfigPath() const;
|
2023-08-18 14:52:06 -04:00
|
|
|
|
2023-12-20 19:47:57 -05:00
|
|
|
[[nodiscard]] bool needsPassword() const;
|
|
|
|
|
2025-03-17 18:27:17 -04:00
|
|
|
AccountConfig *config() const;
|
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_SIGNALS:
|
|
|
|
void avatarUrlChanged();
|
2023-12-20 19:47:57 -05:00
|
|
|
bool needsPasswordChanged();
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
private:
|
2023-12-20 19:47:57 -05:00
|
|
|
QCoro::Task<> fetchPassword();
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2024-07-04 20:53:06 -04:00
|
|
|
/**
|
|
|
|
* @brief Sets a value in the keychain. This function is asynchronous.
|
2023-07-30 08:49:34 -04:00
|
|
|
*/
|
2023-12-20 21:52:43 -05:00
|
|
|
void setKeychainValue(const QString &key, const QString &value);
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2024-07-04 20:53:06 -04:00
|
|
|
/**
|
|
|
|
* @brief Retrieves a value from the keychain. This function is synchronous.
|
2023-07-30 08:49:34 -04:00
|
|
|
*/
|
2023-10-06 18:08:21 -04:00
|
|
|
QCoro::Task<QString> getKeychainValue(const QString &key);
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2025-03-17 18:27:17 -04:00
|
|
|
AccountConfig *m_config;
|
2023-07-30 08:49:34 -04:00
|
|
|
QString m_key;
|
2023-12-17 11:05:57 -05:00
|
|
|
QString m_avatarUrl;
|
2023-12-20 19:47:57 -05:00
|
|
|
bool m_needsPassword = false;
|
2025-03-17 18:27:17 -04:00
|
|
|
};
|