ircconnection and about page
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include "messages/limitedqueuesnapshot.hpp"
|
||||
#include "messages/message.hpp"
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
using namespace chatterino::messages;
|
||||
|
||||
namespace chatterino {
|
||||
@@ -13,14 +15,14 @@ namespace irc {
|
||||
AbstractIrcServer::AbstractIrcServer()
|
||||
{
|
||||
// Initialize the connections
|
||||
this->writeConnection.reset(new Communi::IrcConnection);
|
||||
this->writeConnection.reset(new IrcConnection);
|
||||
this->writeConnection->moveToThread(QCoreApplication::instance()->thread());
|
||||
|
||||
QObject::connect(this->writeConnection.get(), &Communi::IrcConnection::messageReceived,
|
||||
[this](auto msg) { this->writeConnectionMessageReceived(msg); });
|
||||
|
||||
// Listen to read connection message signals
|
||||
this->readConnection.reset(new Communi::IrcConnection);
|
||||
this->readConnection.reset(new IrcConnection);
|
||||
this->readConnection->moveToThread(QCoreApplication::instance()->thread());
|
||||
|
||||
QObject::connect(this->readConnection.get(), &Communi::IrcConnection::messageReceived,
|
||||
@@ -33,7 +35,7 @@ AbstractIrcServer::AbstractIrcServer()
|
||||
[this] { this->onDisconnected(); });
|
||||
}
|
||||
|
||||
Communi::IrcConnection *AbstractIrcServer::getReadConnection() const
|
||||
IrcConnection *AbstractIrcServer::getReadConnection() const
|
||||
{
|
||||
return this->readConnection.get();
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
#include "channel.hpp"
|
||||
|
||||
#include <IrcConnection>
|
||||
#include <IrcMessage>
|
||||
#include <pajlada/signals/signal.hpp>
|
||||
#include <providers/irc/ircconnection2.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
virtual ~AbstractIrcServer() = default;
|
||||
|
||||
// connection
|
||||
Communi::IrcConnection *getReadConnection() const;
|
||||
IrcConnection *getReadConnection() const;
|
||||
|
||||
void connect();
|
||||
void disconnect();
|
||||
@@ -43,8 +43,7 @@ public:
|
||||
protected:
|
||||
AbstractIrcServer();
|
||||
|
||||
virtual void initializeConnection(Communi::IrcConnection *connection, bool isRead,
|
||||
bool isWrite) = 0;
|
||||
virtual void initializeConnection(IrcConnection *connection, bool isRead, bool isWrite) = 0;
|
||||
virtual std::shared_ptr<Channel> createChannel(const QString &channelName) = 0;
|
||||
|
||||
virtual void privateMessageReceived(Communi::IrcPrivateMessage *message);
|
||||
@@ -64,10 +63,12 @@ protected:
|
||||
private:
|
||||
void initConnection();
|
||||
|
||||
std::unique_ptr<Communi::IrcConnection> writeConnection = nullptr;
|
||||
std::unique_ptr<Communi::IrcConnection> readConnection = nullptr;
|
||||
std::unique_ptr<IrcConnection> writeConnection = nullptr;
|
||||
std::unique_ptr<IrcConnection> readConnection = nullptr;
|
||||
|
||||
std::mutex connectionMutex;
|
||||
|
||||
QTimer pingTimer;
|
||||
};
|
||||
|
||||
} // namespace irc
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "ircconnection2.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
namespace providers {
|
||||
namespace irc {
|
||||
|
||||
IrcConnection::IrcConnection(QObject *parent)
|
||||
: Communi::IrcConnection(parent)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace irc
|
||||
} // namespace providers
|
||||
} // namespace chatterino
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <IrcConnection>
|
||||
|
||||
namespace chatterino {
|
||||
namespace providers {
|
||||
namespace irc {
|
||||
|
||||
class IrcConnection : public Communi::IrcConnection
|
||||
{
|
||||
public:
|
||||
IrcConnection(QObject *parent = nullptr);
|
||||
};
|
||||
|
||||
} // namespace irc
|
||||
} // namespace providers
|
||||
} // namespace chatterino
|
||||
@@ -9,9 +9,10 @@
|
||||
#include "providers/twitch/twitchmessagebuilder.hpp"
|
||||
#include "util/posttothread.hpp"
|
||||
|
||||
#include <IrcCommand>
|
||||
#include <cassert>
|
||||
|
||||
using namespace Communi;
|
||||
// using namespace Communi;
|
||||
using namespace chatterino::singletons;
|
||||
|
||||
namespace chatterino {
|
||||
@@ -32,7 +33,8 @@ void TwitchServer::initialize()
|
||||
[this]() { util::postToThread([this] { this->connect(); }); });
|
||||
}
|
||||
|
||||
void TwitchServer::initializeConnection(IrcConnection *connection, bool isRead, bool isWrite)
|
||||
void TwitchServer::initializeConnection(providers::irc::IrcConnection *connection, bool isRead,
|
||||
bool isWrite)
|
||||
{
|
||||
std::shared_ptr<TwitchAccount> account = getApp()->accounts->twitch.getCurrent();
|
||||
|
||||
@@ -57,9 +59,9 @@ void TwitchServer::initializeConnection(IrcConnection *connection, bool isRead,
|
||||
// this->refreshIgnoredUsers(username, oauthClient, oauthToken);
|
||||
}
|
||||
|
||||
connection->sendCommand(IrcCommand::createCapability("REQ", "twitch.tv/membership"));
|
||||
connection->sendCommand(IrcCommand::createCapability("REQ", "twitch.tv/commands"));
|
||||
connection->sendCommand(IrcCommand::createCapability("REQ", "twitch.tv/tags"));
|
||||
connection->sendCommand(Communi::IrcCommand::createCapability("REQ", "twitch.tv/membership"));
|
||||
connection->sendCommand(Communi::IrcCommand::createCapability("REQ", "twitch.tv/commands"));
|
||||
connection->sendCommand(Communi::IrcCommand::createCapability("REQ", "twitch.tv/tags"));
|
||||
|
||||
connection->setHost("irc.chat.twitch.tv");
|
||||
connection->setPort(6667);
|
||||
@@ -75,15 +77,15 @@ std::shared_ptr<Channel> TwitchServer::createChannel(const QString &channelName)
|
||||
return std::shared_ptr<Channel>(channel);
|
||||
}
|
||||
|
||||
void TwitchServer::privateMessageReceived(IrcPrivateMessage *message)
|
||||
void TwitchServer::privateMessageReceived(Communi::IrcPrivateMessage *message)
|
||||
{
|
||||
IrcMessageHandler::getInstance().handlePrivMessage(message, *this);
|
||||
}
|
||||
|
||||
void TwitchServer::messageReceived(IrcMessage *message)
|
||||
void TwitchServer::messageReceived(Communi::IrcMessage *message)
|
||||
{
|
||||
// this->readConnection
|
||||
if (message->type() == IrcMessage::Type::Private) {
|
||||
if (message->type() == Communi::IrcMessage::Type::Private) {
|
||||
// We already have a handler for private messages
|
||||
return;
|
||||
}
|
||||
@@ -105,7 +107,7 @@ void TwitchServer::messageReceived(IrcMessage *message)
|
||||
} else if (command == "MODE") {
|
||||
handler.handleModeMessage(message);
|
||||
} else if (command == "NOTICE") {
|
||||
handler.handleNoticeMessage(static_cast<IrcNoticeMessage *>(message));
|
||||
handler.handleNoticeMessage(static_cast<Communi::IrcNoticeMessage *>(message));
|
||||
} else if (command == "JOIN") {
|
||||
handler.handleJoinMessage(message);
|
||||
} else if (command == "PART") {
|
||||
@@ -113,13 +115,15 @@ void TwitchServer::messageReceived(IrcMessage *message)
|
||||
}
|
||||
}
|
||||
|
||||
void TwitchServer::writeConnectionMessageReceived(IrcMessage *message)
|
||||
void TwitchServer::writeConnectionMessageReceived(Communi::IrcMessage *message)
|
||||
{
|
||||
switch (message->type()) {
|
||||
case IrcMessage::Type::Notice: {
|
||||
case Communi::IrcMessage::Type::Notice: {
|
||||
IrcMessageHandler::getInstance().handleWriteConnectionNoticeMessage(
|
||||
static_cast<IrcNoticeMessage *>(message));
|
||||
static_cast<Communi::IrcNoticeMessage *>(message));
|
||||
} break;
|
||||
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,20 +182,6 @@ std::shared_ptr<Channel> TwitchServer::getChannelOrEmptyByID(const QString &chan
|
||||
return Channel::getEmpty();
|
||||
}
|
||||
|
||||
// QString TwitchServer::getLastWhisperedPerson() const
|
||||
//{
|
||||
// std::lock_guard<std::mutex> guard(this->lastWhisperedPersonMutex);
|
||||
|
||||
// return this->lastWhisperedPerson;
|
||||
//}
|
||||
|
||||
// void TwitchServer::setLastWhisperedPerson(const QString &person)
|
||||
//{
|
||||
// std::lock_guard<std::mutex> guard(this->lastWhisperedPersonMutex);
|
||||
|
||||
// this->lastWhisperedPerson = person;
|
||||
//}
|
||||
|
||||
QString TwitchServer::cleanChannelName(const QString &dirtyChannelName)
|
||||
{
|
||||
return dirtyChannelName.toLower();
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
IndirectChannel watchingChannel;
|
||||
|
||||
protected:
|
||||
void initializeConnection(Communi::IrcConnection *connection, bool isRead,
|
||||
void initializeConnection(providers::irc::IrcConnection *connection, bool isRead,
|
||||
bool isWrite) override;
|
||||
std::shared_ptr<Channel> createChannel(const QString &channelName) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user