mirror-chatterino2/src/accountmanager.hpp

58 lines
1.2 KiB
C++
Raw Normal View History

#pragma once
2017-04-12 17:46:44 +02:00
2017-06-11 09:31:45 +02:00
#include "twitch/twitchuser.hpp"
2017-04-12 17:46:44 +02:00
2017-09-24 18:14:22 +02:00
#include <pajlada/settings/setting.hpp>
2017-04-13 16:06:23 +02:00
#include <mutex>
#include <vector>
2017-04-13 16:06:23 +02:00
2017-04-12 17:46:44 +02:00
namespace chatterino {
class AccountManager;
class TwitchAccountManager
{
public:
// Returns the current twitchUsers, or the anonymous user if we're not currently logged in
std::shared_ptr<twitch::TwitchUser> getCurrent();
std::vector<QString> getUsernames() const;
std::shared_ptr<twitch::TwitchUser> findUserByUsername(const QString &username) const;
bool userExists(const QString &username) const;
pajlada::Settings::Setting<std::string> currentUsername = {"/accounts/current", ""};
pajlada::Signals::NoArgSignal userChanged;
private:
bool addUser(std::shared_ptr<twitch::TwitchUser> user);
std::shared_ptr<twitch::TwitchUser> currentUser;
std::shared_ptr<twitch::TwitchUser> anonymousUser;
std::vector<std::shared_ptr<twitch::TwitchUser>> users;
mutable std::mutex mutex;
friend class AccountManager;
};
2017-04-12 17:46:44 +02:00
class AccountManager
{
public:
static AccountManager &getInstance()
{
static AccountManager instance;
2017-04-12 17:46:44 +02:00
return instance;
}
void load();
TwitchAccountManager Twitch;
2017-04-12 17:46:44 +02:00
private:
AccountManager();
};
2017-04-14 17:52:22 +02:00
} // namespace chatterino