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
|
|
|
|
|
2023-08-18 14:52:06 -04:00
|
|
|
#include <QDir>
|
2023-07-30 08:49:34 -04:00
|
|
|
#include <QObject>
|
2023-09-16 18:01:02 -04:00
|
|
|
#include <QtQml/qqmlregistration.h>
|
2023-10-06 18:08:21 -04:00
|
|
|
#include <qcorotask.h>
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
#include "accountconfig.h"
|
|
|
|
|
|
|
|
class LauncherCore;
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
2023-08-18 22:36:33 -04:00
|
|
|
Q_PROPERTY(int language READ language WRITE setLanguage NOTIFY languageChanged)
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_PROPERTY(QString lodestoneId READ lodestoneId WRITE setLodestoneId NOTIFY lodestoneIdChanged)
|
|
|
|
Q_PROPERTY(QString avatarUrl READ avatarUrl NOTIFY avatarUrlChanged)
|
|
|
|
Q_PROPERTY(bool isSapphire READ isSapphire WRITE setIsSapphire NOTIFY isSapphireChanged)
|
|
|
|
Q_PROPERTY(QString lobbyUrl READ lobbyUrl WRITE setLobbyUrl NOTIFY lobbyUrlChanged)
|
|
|
|
Q_PROPERTY(bool rememberPassword READ rememberPassword WRITE setRememberPassword NOTIFY rememberPasswordChanged)
|
|
|
|
Q_PROPERTY(bool rememberOTP READ rememberOTP WRITE setRememberOTP NOTIFY rememberOTPChanged)
|
|
|
|
Q_PROPERTY(bool useOTP READ useOTP WRITE setUseOTP NOTIFY useOTPChanged)
|
|
|
|
Q_PROPERTY(GameLicense license READ license WRITE setLicense NOTIFY licenseChanged)
|
|
|
|
Q_PROPERTY(bool isFreeTrial READ isFreeTrial WRITE setIsFreeTrial NOTIFY isFreeTrialChanged)
|
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:
|
|
|
|
explicit Account(LauncherCore &launcher, const QString &key, QObject *parent = nullptr);
|
|
|
|
|
|
|
|
enum class GameLicense { WindowsStandalone, WindowsSteam, macOS };
|
|
|
|
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 name() const;
|
2023-07-30 08:49:34 -04:00
|
|
|
void setName(const QString &name);
|
|
|
|
|
2023-09-16 21:22:20 -04:00
|
|
|
[[nodiscard]] int language() const;
|
2023-08-18 22:36:33 -04:00
|
|
|
void setLanguage(int value);
|
|
|
|
|
2023-09-16 21:22:20 -04:00
|
|
|
[[nodiscard]] QString lodestoneId() const;
|
2023-07-30 08:49:34 -04:00
|
|
|
void setLodestoneId(const QString &id);
|
|
|
|
|
2023-09-16 21:22:20 -04:00
|
|
|
[[nodiscard]] QString avatarUrl() const;
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-09-16 21:22:20 -04:00
|
|
|
[[nodiscard]] bool isSapphire() const;
|
2023-07-30 08:49:34 -04:00
|
|
|
void setIsSapphire(bool value);
|
|
|
|
|
2023-09-16 21:22:20 -04:00
|
|
|
[[nodiscard]] QString lobbyUrl() const;
|
2023-07-30 08:49:34 -04:00
|
|
|
void setLobbyUrl(const QString &url);
|
|
|
|
|
2023-09-16 21:22:20 -04:00
|
|
|
[[nodiscard]] bool rememberPassword() const;
|
2023-07-30 08:49:34 -04:00
|
|
|
void setRememberPassword(bool value);
|
|
|
|
|
2023-09-16 21:22:20 -04:00
|
|
|
[[nodiscard]] bool rememberOTP() const;
|
2023-07-30 08:49:34 -04:00
|
|
|
void setRememberOTP(bool value);
|
|
|
|
|
2023-09-16 21:22:20 -04:00
|
|
|
[[nodiscard]] bool useOTP() const;
|
2023-07-30 08:49:34 -04:00
|
|
|
void setUseOTP(bool value);
|
|
|
|
|
2023-09-16 21:22:20 -04:00
|
|
|
[[nodiscard]] GameLicense license() const;
|
2023-07-30 08:49:34 -04:00
|
|
|
void setLicense(GameLicense license);
|
|
|
|
|
2023-09-16 21:22:20 -04:00
|
|
|
[[nodiscard]] bool isFreeTrial() const;
|
2023-07-30 08:49:34 -04:00
|
|
|
void setIsFreeTrial(bool value);
|
|
|
|
|
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);
|
|
|
|
|
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;
|
2023-08-18 14:52:06 -04:00
|
|
|
|
2023-10-11 14:40:56 -04:00
|
|
|
/// Updates FFXIV.cfg with some recommended options like turning the opening cutscene movie off
|
2023-10-11 13:03:23 -04:00
|
|
|
void updateConfig();
|
|
|
|
|
2023-12-20 19:47:57 -05:00
|
|
|
[[nodiscard]] bool needsPassword() const;
|
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_SIGNALS:
|
|
|
|
void nameChanged();
|
2023-08-18 22:36:33 -04:00
|
|
|
void languageChanged();
|
2023-07-30 08:49:34 -04:00
|
|
|
void lodestoneIdChanged();
|
|
|
|
void avatarUrlChanged();
|
|
|
|
void isSapphireChanged();
|
|
|
|
void lobbyUrlChanged();
|
|
|
|
void rememberPasswordChanged();
|
|
|
|
void rememberOTPChanged();
|
|
|
|
void useOTPChanged();
|
|
|
|
void licenseChanged();
|
|
|
|
void isFreeTrialChanged();
|
2023-12-20 19:47:57 -05:00
|
|
|
bool needsPasswordChanged();
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
void fetchAvatar();
|
2023-12-20 19:47:57 -05:00
|
|
|
QCoro::Task<> fetchPassword();
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sets a value in the keychain. This function is asynchronous.
|
|
|
|
*/
|
2023-12-20 21:52:43 -05:00
|
|
|
void setKeychainValue(const QString &key, const QString &value);
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Retrieves a value from the keychain. This function is synchronous.
|
|
|
|
*/
|
2023-10-06 18:08:21 -04:00
|
|
|
QCoro::Task<QString> getKeychainValue(const QString &key);
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
AccountConfig m_config;
|
|
|
|
QString m_key;
|
2023-12-17 11:05:57 -05:00
|
|
|
QString m_avatarUrl;
|
2023-07-30 08:49:34 -04:00
|
|
|
LauncherCore &m_launcher;
|
2023-12-20 19:47:57 -05:00
|
|
|
bool m_needsPassword = false;
|
2023-07-30 08:49:34 -04:00
|
|
|
};
|