2017-01-03 21:19:33 +01:00
|
|
|
#ifndef IRCMANAGER_H
|
|
|
|
#define IRCMANAGER_H
|
|
|
|
|
|
|
|
#define TWITCH_MAX_MESSAGELENGTH 500
|
|
|
|
|
2017-01-18 21:30:23 +01:00
|
|
|
#include "messages/message.h"
|
2017-04-12 17:46:44 +02:00
|
|
|
#include "twitch/twitchuser.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-03-11 11:32:19 +01:00
|
|
|
#include <memory>
|
|
|
|
|
2017-01-18 21:30:23 +01:00
|
|
|
namespace chatterino {
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
class IrcManager : public QObject
|
2017-01-03 21:19:33 +01:00
|
|
|
{
|
2017-04-12 17:46:44 +02:00
|
|
|
Q_OBJECT
|
2017-01-03 21:19:33 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
public:
|
|
|
|
static IrcManager &getInstance()
|
|
|
|
{
|
|
|
|
return instance;
|
|
|
|
}
|
2017-01-29 13:23:22 +01:00
|
|
|
|
2017-01-04 15:12:31 +01:00
|
|
|
static const QString defaultClientId;
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
void connect();
|
|
|
|
void disconnect();
|
|
|
|
|
|
|
|
void send(QString raw);
|
|
|
|
|
2017-01-04 15:12:31 +01:00
|
|
|
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-04-12 17:46:44 +02:00
|
|
|
QNetworkAccessManager &getAccessManager();
|
2017-01-11 18:52:09 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
void sendJoin(const QString &channel);
|
2017-01-04 15:12:31 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
void partChannel(const QString &channel);
|
2017-01-17 00:15:44 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
const twitch::TwitchUser &getUser() const;
|
|
|
|
void setUser(const twitch::TwitchUser &account);
|
2017-01-17 00:15:44 +01:00
|
|
|
|
2017-01-03 21:19:33 +01:00
|
|
|
private:
|
2017-04-12 17:46:44 +02:00
|
|
|
static IrcManager instance;
|
2017-01-03 21:19:33 +01:00
|
|
|
IrcManager();
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
// variables
|
|
|
|
twitch::TwitchUser _account;
|
|
|
|
|
|
|
|
std::shared_ptr<Communi::IrcConnection> _connection;
|
|
|
|
QMutex _connectionMutex;
|
|
|
|
long _connectionGeneration;
|
2017-01-04 15:12:31 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
QMap<QString, bool> _twitchBlockedUsers;
|
|
|
|
QMutex _twitchBlockedUsersMutex;
|
2017-01-03 21:19:33 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
QNetworkAccessManager _accessManager;
|
2017-01-03 22:08:20 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
// methods
|
|
|
|
void beginConnecting();
|
2017-01-03 21:19:33 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
void messageReceived(Communi::IrcMessage *message);
|
|
|
|
void privateMessageReceived(Communi::IrcPrivateMessage *message);
|
2017-01-03 21:19:33 +01:00
|
|
|
};
|
2017-04-14 17:47:28 +02:00
|
|
|
} // namespace chatterino
|
2017-01-03 21:19:33 +01:00
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
#endif // IRCMANAGER_H
|