mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
18cb4bd6e5
* Add `<functional>` include to QStringHash.hpp This ensures the base `std::hash` template is declared before this specialization * Add missing includes to `src/providers/twitch/TwitchAccountManager.hpp` * Move explicit HelixChatters constructor to the source file * Remove unused includes & add used includes to NicknamesModel.hpp * NicknamesModel.hpp: Remove `virtual` when `override` is used * Add missing QStringHash include to TwitchEmotes.cpp * Add missing includes to various files * Print Qt version in cmake step Technically unrelated, but I'm sneaking it in * Add changelog entry
78 lines
1.8 KiB
C++
78 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include "common/ChatterinoSetting.hpp"
|
|
#include "common/SignalVector.hpp"
|
|
#include "util/QStringHash.hpp"
|
|
#include "util/RapidJsonSerializeQString.hpp"
|
|
|
|
#include <boost/signals2.hpp>
|
|
#include <QString>
|
|
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <vector>
|
|
|
|
//
|
|
// Warning: This class is not supposed to be created directly.
|
|
// Get yourself an instance from our friends over at
|
|
// AccountManager.hpp
|
|
//
|
|
|
|
namespace chatterino {
|
|
|
|
class TwitchAccount;
|
|
class AccountController;
|
|
|
|
class TwitchAccountManager
|
|
{
|
|
TwitchAccountManager();
|
|
|
|
public:
|
|
struct UserData {
|
|
QString username;
|
|
QString userID;
|
|
QString clientID;
|
|
QString oauthToken;
|
|
};
|
|
|
|
// Returns the current twitchUsers, or the anonymous user if we're not
|
|
// currently logged in
|
|
std::shared_ptr<TwitchAccount> getCurrent();
|
|
|
|
std::vector<QString> getUsernames() const;
|
|
|
|
std::shared_ptr<TwitchAccount> findUserByUsername(
|
|
const QString &username) const;
|
|
bool userExists(const QString &username) const;
|
|
|
|
void reloadUsers();
|
|
void load();
|
|
|
|
bool isLoggedIn() const;
|
|
|
|
pajlada::Settings::Setting<QString> currentUsername{"/accounts/current",
|
|
""};
|
|
// pajlada::Signals::NoArgSignal currentUserChanged;
|
|
boost::signals2::signal<void()> currentUserChanged;
|
|
pajlada::Signals::NoArgSignal userListUpdated;
|
|
|
|
SignalVector<std::shared_ptr<TwitchAccount>> accounts;
|
|
|
|
private:
|
|
enum class AddUserResponse {
|
|
UserAlreadyExists,
|
|
UserValuesUpdated,
|
|
UserAdded,
|
|
};
|
|
AddUserResponse addUser(const UserData &data);
|
|
bool removeUser(TwitchAccount *account);
|
|
|
|
std::shared_ptr<TwitchAccount> currentUser_;
|
|
|
|
std::shared_ptr<TwitchAccount> anonymousUser_;
|
|
mutable std::mutex mutex_;
|
|
|
|
friend class AccountController;
|
|
};
|
|
|
|
} // namespace chatterino
|