#pragma once
#include <QMap>
#include <QObject>
#include <QPair>

class RegistryManager : public QObject {
    Q_OBJECT
   public:
    static RegistryManager *instance();
    static void cleanup();

    bool saveUserInfo(const QString &userId, const QString &username, const QString &password,
                      const QString &identity, const QString &certName);
    bool readUserInfo(const QString &userId, QString &username, QString &password);
    QStringList getAllUserIds();
    QStringList getAllUsernames();
    QString getPasswordByUsername(const QString &username);
    QMap<QString, QPair<QString, QString>> getAllUserInfos();
    QMap<QString, QString> getCurentLoginUser();
    void setCurentLoginUserId(const QString &username);

   private:
    explicit RegistryManager(QObject *parent = nullptr);
    ~RegistryManager();

    static RegistryManager *s_instance;
    const QString organizationName = "HXGC";
    const QString applicationName = "Smart Mine";
    QString currentLoginUserId;
};
