mirror-chatterino2/src/providers/twitch/TwitchAccount.hpp

87 lines
2.3 KiB
C++
Raw Normal View History

#pragma once
2017-04-12 17:46:44 +02:00
#include "controllers/accounts/account.hpp"
#include "providers/twitch/twitchuser.hpp"
#include <QColor>
2017-04-12 17:46:44 +02:00
#include <QString>
#include <set>
2018-05-06 12:52:47 +02:00
2017-04-14 17:52:22 +02:00
namespace chatterino {
enum IgnoreResult {
IgnoreResult_Success,
IgnoreResult_AlreadyIgnored,
IgnoreResult_Failed,
};
enum UnignoreResult {
UnignoreResult_Success,
UnignoreResult_Failed,
};
enum FollowResult {
FollowResult_Following,
FollowResult_NotFollowing,
FollowResult_Failed,
};
2018-02-05 15:11:50 +01:00
namespace providers {
2017-04-14 17:52:22 +02:00
namespace twitch {
2018-05-06 12:52:47 +02:00
class TwitchAccount : public controllers::accounts::Account
2017-04-12 17:46:44 +02:00
{
public:
TwitchAccount(const QString &username, const QString &oauthToken, const QString &oauthClient,
const QString &_userID);
2017-04-12 17:46:44 +02:00
2018-05-06 12:52:47 +02:00
virtual QString toString() const override;
2018-02-05 15:11:50 +01:00
const QString &getUserName() const;
2017-04-12 17:46:44 +02:00
const QString &getOAuthToken() const;
const QString &getOAuthClient() const;
2018-02-05 15:11:50 +01:00
const QString &getUserId() const;
2017-04-12 17:46:44 +02:00
// Attempts to update the users OAuth Client ID
// Returns true if the value has changed, otherwise false
bool setOAuthClient(const QString &newClientID);
// Attempts to update the users OAuth Token
// Returns true if the value has changed, otherwise false
bool setOAuthToken(const QString &newOAuthToken);
2017-04-12 17:46:44 +02:00
bool isAnon() const;
void loadIgnores();
void ignore(const QString &targetName,
std::function<void(IgnoreResult, const QString &)> onFinished);
void ignoreByID(const QString &targetUserID, const QString &targetName,
std::function<void(IgnoreResult, const QString &)> onFinished);
void unignore(const QString &targetName,
std::function<void(UnignoreResult, const QString &)> onFinished);
void unignoreByID(const QString &targetUserID, const QString &targetName,
std::function<void(UnignoreResult, const QString &message)> onFinished);
void checkFollow(const QString targetUserID, std::function<void(FollowResult)> onFinished);
std::set<TwitchUser> getIgnores() const;
QColor color;
2017-04-12 17:46:44 +02:00
private:
2018-02-05 15:11:50 +01:00
QString oauthClient;
QString oauthToken;
QString userName;
QString userId;
const bool _isAnon;
mutable std::mutex ignoresMutex;
std::set<TwitchUser> ignores;
2017-04-12 17:46:44 +02:00
};
} // namespace twitch
2018-02-05 15:11:50 +01:00
} // namespace providers
} // namespace chatterino