2017-01-03 21:19:33 +01:00
|
|
|
#ifndef IRCMANAGER_H
|
|
|
|
#define IRCMANAGER_H
|
|
|
|
|
|
|
|
#define TWITCH_MAX_MESSAGELENGTH 500
|
|
|
|
|
2017-01-04 15:12:31 +01:00
|
|
|
#include "account.h"
|
2017-01-18 21:30:23 +01:00
|
|
|
#include "messages/message.h"
|
2017-01-16 03:15:07 +01:00
|
|
|
|
|
|
|
#include <IrcMessage>
|
|
|
|
#include <QMap>
|
|
|
|
#include <QMutex>
|
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
#include <QString>
|
2017-01-03 21:19:33 +01:00
|
|
|
|
2017-01-18 21:30:23 +01:00
|
|
|
namespace chatterino {
|
|
|
|
|
2017-01-03 21:19:33 +01:00
|
|
|
class IrcManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static void connect();
|
|
|
|
static void disconnect();
|
|
|
|
|
2017-01-29 13:23:22 +01:00
|
|
|
static void send(QString raw);
|
|
|
|
|
2017-01-04 15:12:31 +01:00
|
|
|
static const QString defaultClientId;
|
|
|
|
|
|
|
|
bool isTwitchBlockedUser(QString const &username);
|
2017-01-11 18:52:09 +01:00
|
|
|
bool tryAddIgnoredUser(QString const &username, QString &errorMessage);
|
2017-01-04 15:12:31 +01:00
|
|
|
void addIgnoredUser(QString const &username);
|
2017-01-11 18:52:09 +01:00
|
|
|
bool tryRemoveIgnoredUser(QString const &username, QString &errorMessage);
|
2017-01-04 15:12:31 +01:00
|
|
|
void removeIgnoredUser(QString const &username);
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
static Account *account;
|
|
|
|
|
|
|
|
static QNetworkAccessManager &
|
2017-01-18 04:33:30 +01:00
|
|
|
getAccessManager()
|
2017-01-11 18:52:09 +01:00
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return accessManager;
|
2017-01-11 18:52:09 +01:00
|
|
|
}
|
2017-01-04 15:12:31 +01:00
|
|
|
|
2017-01-17 00:15:44 +01:00
|
|
|
static void joinChannel(const QString &channel);
|
|
|
|
|
|
|
|
static void partChannel(const QString &channel);
|
|
|
|
|
2017-01-03 21:19:33 +01:00
|
|
|
private:
|
|
|
|
IrcManager();
|
|
|
|
|
2017-01-18 04:33:30 +01:00
|
|
|
static QMap<QString, bool> twitchBlockedUsers;
|
|
|
|
static QMutex twitchBlockedUsersMutex;
|
2017-01-04 15:12:31 +01:00
|
|
|
|
2017-01-18 04:33:30 +01:00
|
|
|
static QNetworkAccessManager accessManager;
|
2017-01-03 21:19:33 +01:00
|
|
|
|
2017-01-04 15:12:31 +01:00
|
|
|
static void beginConnecting();
|
2017-01-03 22:08:20 +01:00
|
|
|
|
2017-01-18 04:33:30 +01:00
|
|
|
static IrcConnection *connection;
|
|
|
|
static QMutex connectionMutex;
|
|
|
|
static long connectionGeneration;
|
2017-01-03 21:19:33 +01:00
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
static void messageReceived(IrcMessage *message);
|
|
|
|
static void privateMessageReceived(IrcPrivateMessage *message);
|
2017-01-03 21:19:33 +01:00
|
|
|
};
|
2017-01-18 21:30:23 +01:00
|
|
|
}
|
2017-01-03 21:19:33 +01:00
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
#endif // IRCMANAGER_H
|