2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "controllers/accounts/Account.hpp"
|
|
|
|
#include "providers/twitch/TwitchUser.hpp"
|
2018-05-12 20:34:13 +02:00
|
|
|
|
2018-06-27 02:16:30 +02:00
|
|
|
#include <rapidjson/document.h>
|
2018-02-04 16:33:46 +01:00
|
|
|
#include <QColor>
|
2017-04-12 17:46:44 +02:00
|
|
|
#include <QString>
|
|
|
|
|
2018-06-27 02:16:30 +02:00
|
|
|
#include <functional>
|
|
|
|
#include <mutex>
|
2018-05-12 20:34:13 +02:00
|
|
|
#include <set>
|
2018-05-06 12:52:47 +02:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace chatterino {
|
2018-05-13 17:53:24 +02:00
|
|
|
|
|
|
|
enum IgnoreResult {
|
|
|
|
IgnoreResult_Success,
|
|
|
|
IgnoreResult_AlreadyIgnored,
|
|
|
|
IgnoreResult_Failed,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum UnignoreResult {
|
|
|
|
UnignoreResult_Success,
|
|
|
|
UnignoreResult_Failed,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum FollowResult {
|
|
|
|
FollowResult_Following,
|
|
|
|
FollowResult_NotFollowing,
|
|
|
|
FollowResult_Failed,
|
|
|
|
};
|
|
|
|
|
2018-06-26 17:06:17 +02:00
|
|
|
class TwitchAccount : public Account
|
2017-04-12 17:46:44 +02:00
|
|
|
{
|
|
|
|
public:
|
2018-07-06 19:23:47 +02:00
|
|
|
TwitchAccount(const QString &username, const QString &oauthToken_, const QString &oauthClient_,
|
2018-04-15 15:09:31 +02:00
|
|
|
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
|
|
|
|
2017-09-23 19:23:10 +02:00
|
|
|
const QString &getUserId() const;
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2017-12-26 11:59:26 +01: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-12-19 15:09:54 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
bool isAnon() const;
|
|
|
|
|
2018-05-12 20:34:13 +02:00
|
|
|
void loadIgnores();
|
2018-05-13 17:53:24 +02:00
|
|
|
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);
|
2018-05-12 20:34:13 +02:00
|
|
|
|
|
|
|
std::set<TwitchUser> getIgnores() const;
|
|
|
|
|
2018-06-27 02:16:30 +02:00
|
|
|
void loadEmotes(std::function<void(const rapidjson::Document &)> cb);
|
|
|
|
|
2018-02-04 16:33:46 +01:00
|
|
|
QColor color;
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
private:
|
2018-07-06 19:23:47 +02: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
|
|
|
};
|
2018-03-31 13:44:15 +02:00
|
|
|
|
2017-05-27 17:45:40 +02:00
|
|
|
} // namespace chatterino
|