mirror-chatterino2/accountmanager.cpp
Bur0k b6d0776917 Make runnable again (#40)
* Compile before push DansGame

* Initialize them when they are needed, not on startup. This is THREAD-SAFE since C++11

* Changed user to account
2017-04-19 15:25:05 +02:00

43 lines
928 B
C++

#include "accountmanager.h"
namespace chatterino {
AccountManager::AccountManager()
: _twitchAnon("justinfan64537", "", "")
, _twitchUsers()
, _twitchUsersMutex()
{
}
twitch::TwitchUser &AccountManager::getTwitchAnon()
{
return _twitchAnon;
}
std::vector<twitch::TwitchUser> AccountManager::getTwitchUsers()
{
return std::vector<twitch::TwitchUser>(_twitchUsers);
}
bool AccountManager::removeTwitchUser(const QString &userName)
{
std::lock_guard<std::mutex> lock(_twitchUsersMutex);
for (auto it = _twitchUsers.begin(); it != _twitchUsers.end(); it++) {
if ((*it).getUserName() == userName) {
_twitchUsers.erase(it);
return true;
}
}
return false;
}
void AccountManager::addTwitchUser(const twitch::TwitchUser &user)
{
std::lock_guard<std::mutex> lock(_twitchUsersMutex);
_twitchUsers.push_back(user);
}
} // namespace chatterino