mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
ircconnection and about page
This commit is contained in:
parent
5e7fc909e7
commit
8de0a59533
8 changed files with 516 additions and 485 deletions
|
@ -211,7 +211,8 @@ SOURCES += \
|
||||||
src/controllers/taggedusers/taggeduserscontroller.cpp \
|
src/controllers/taggedusers/taggeduserscontroller.cpp \
|
||||||
src/controllers/taggedusers/taggeduser.cpp \
|
src/controllers/taggedusers/taggeduser.cpp \
|
||||||
src/controllers/taggedusers/taggedusersmodel.cpp \
|
src/controllers/taggedusers/taggedusersmodel.cpp \
|
||||||
src/util/emotemap.cpp
|
src/util/emotemap.cpp \
|
||||||
|
src/providers/irc/ircconnection2.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/precompiled_header.hpp \
|
src/precompiled_header.hpp \
|
||||||
|
@ -365,7 +366,8 @@ HEADERS += \
|
||||||
src/providerid.hpp \
|
src/providerid.hpp \
|
||||||
src/controllers/taggedusers/taggedusersmodel.hpp \
|
src/controllers/taggedusers/taggedusersmodel.hpp \
|
||||||
src/util/qstringhash.hpp \
|
src/util/qstringhash.hpp \
|
||||||
src/util/mutexvalue.hpp
|
src/util/mutexvalue.hpp \
|
||||||
|
src/providers/irc/ircconnection2.hpp
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
resources/resources.qrc
|
resources/resources.qrc
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include "messages/limitedqueuesnapshot.hpp"
|
#include "messages/limitedqueuesnapshot.hpp"
|
||||||
#include "messages/message.hpp"
|
#include "messages/message.hpp"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
using namespace chatterino::messages;
|
using namespace chatterino::messages;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
@ -13,14 +15,14 @@ namespace irc {
|
||||||
AbstractIrcServer::AbstractIrcServer()
|
AbstractIrcServer::AbstractIrcServer()
|
||||||
{
|
{
|
||||||
// Initialize the connections
|
// Initialize the connections
|
||||||
this->writeConnection.reset(new Communi::IrcConnection);
|
this->writeConnection.reset(new IrcConnection);
|
||||||
this->writeConnection->moveToThread(QCoreApplication::instance()->thread());
|
this->writeConnection->moveToThread(QCoreApplication::instance()->thread());
|
||||||
|
|
||||||
QObject::connect(this->writeConnection.get(), &Communi::IrcConnection::messageReceived,
|
QObject::connect(this->writeConnection.get(), &Communi::IrcConnection::messageReceived,
|
||||||
[this](auto msg) { this->writeConnectionMessageReceived(msg); });
|
[this](auto msg) { this->writeConnectionMessageReceived(msg); });
|
||||||
|
|
||||||
// Listen to read connection message signals
|
// Listen to read connection message signals
|
||||||
this->readConnection.reset(new Communi::IrcConnection);
|
this->readConnection.reset(new IrcConnection);
|
||||||
this->readConnection->moveToThread(QCoreApplication::instance()->thread());
|
this->readConnection->moveToThread(QCoreApplication::instance()->thread());
|
||||||
|
|
||||||
QObject::connect(this->readConnection.get(), &Communi::IrcConnection::messageReceived,
|
QObject::connect(this->readConnection.get(), &Communi::IrcConnection::messageReceived,
|
||||||
|
@ -33,7 +35,7 @@ AbstractIrcServer::AbstractIrcServer()
|
||||||
[this] { this->onDisconnected(); });
|
[this] { this->onDisconnected(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
Communi::IrcConnection *AbstractIrcServer::getReadConnection() const
|
IrcConnection *AbstractIrcServer::getReadConnection() const
|
||||||
{
|
{
|
||||||
return this->readConnection.get();
|
return this->readConnection.get();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
#include "channel.hpp"
|
#include "channel.hpp"
|
||||||
|
|
||||||
#include <IrcConnection>
|
|
||||||
#include <IrcMessage>
|
#include <IrcMessage>
|
||||||
#include <pajlada/signals/signal.hpp>
|
#include <pajlada/signals/signal.hpp>
|
||||||
|
#include <providers/irc/ircconnection2.hpp>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
@ -19,7 +19,7 @@ public:
|
||||||
virtual ~AbstractIrcServer() = default;
|
virtual ~AbstractIrcServer() = default;
|
||||||
|
|
||||||
// connection
|
// connection
|
||||||
Communi::IrcConnection *getReadConnection() const;
|
IrcConnection *getReadConnection() const;
|
||||||
|
|
||||||
void connect();
|
void connect();
|
||||||
void disconnect();
|
void disconnect();
|
||||||
|
@ -43,8 +43,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
AbstractIrcServer();
|
AbstractIrcServer();
|
||||||
|
|
||||||
virtual void initializeConnection(Communi::IrcConnection *connection, bool isRead,
|
virtual void initializeConnection(IrcConnection *connection, bool isRead, bool isWrite) = 0;
|
||||||
bool isWrite) = 0;
|
|
||||||
virtual std::shared_ptr<Channel> createChannel(const QString &channelName) = 0;
|
virtual std::shared_ptr<Channel> createChannel(const QString &channelName) = 0;
|
||||||
|
|
||||||
virtual void privateMessageReceived(Communi::IrcPrivateMessage *message);
|
virtual void privateMessageReceived(Communi::IrcPrivateMessage *message);
|
||||||
|
@ -64,10 +63,12 @@ protected:
|
||||||
private:
|
private:
|
||||||
void initConnection();
|
void initConnection();
|
||||||
|
|
||||||
std::unique_ptr<Communi::IrcConnection> writeConnection = nullptr;
|
std::unique_ptr<IrcConnection> writeConnection = nullptr;
|
||||||
std::unique_ptr<Communi::IrcConnection> readConnection = nullptr;
|
std::unique_ptr<IrcConnection> readConnection = nullptr;
|
||||||
|
|
||||||
std::mutex connectionMutex;
|
std::mutex connectionMutex;
|
||||||
|
|
||||||
|
QTimer pingTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace irc
|
} // namespace irc
|
||||||
|
|
14
src/providers/irc/ircconnection2.cpp
Normal file
14
src/providers/irc/ircconnection2.cpp
Normal file
|
@ -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
|
17
src/providers/irc/ircconnection2.hpp
Normal file
17
src/providers/irc/ircconnection2.hpp
Normal file
|
@ -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 "providers/twitch/twitchmessagebuilder.hpp"
|
||||||
#include "util/posttothread.hpp"
|
#include "util/posttothread.hpp"
|
||||||
|
|
||||||
|
#include <IrcCommand>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
using namespace Communi;
|
// using namespace Communi;
|
||||||
using namespace chatterino::singletons;
|
using namespace chatterino::singletons;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
@ -32,7 +33,8 @@ void TwitchServer::initialize()
|
||||||
[this]() { util::postToThread([this] { this->connect(); }); });
|
[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();
|
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);
|
// this->refreshIgnoredUsers(username, oauthClient, oauthToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
connection->sendCommand(IrcCommand::createCapability("REQ", "twitch.tv/membership"));
|
connection->sendCommand(Communi::IrcCommand::createCapability("REQ", "twitch.tv/membership"));
|
||||||
connection->sendCommand(IrcCommand::createCapability("REQ", "twitch.tv/commands"));
|
connection->sendCommand(Communi::IrcCommand::createCapability("REQ", "twitch.tv/commands"));
|
||||||
connection->sendCommand(IrcCommand::createCapability("REQ", "twitch.tv/tags"));
|
connection->sendCommand(Communi::IrcCommand::createCapability("REQ", "twitch.tv/tags"));
|
||||||
|
|
||||||
connection->setHost("irc.chat.twitch.tv");
|
connection->setHost("irc.chat.twitch.tv");
|
||||||
connection->setPort(6667);
|
connection->setPort(6667);
|
||||||
|
@ -75,15 +77,15 @@ std::shared_ptr<Channel> TwitchServer::createChannel(const QString &channelName)
|
||||||
return std::shared_ptr<Channel>(channel);
|
return std::shared_ptr<Channel>(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchServer::privateMessageReceived(IrcPrivateMessage *message)
|
void TwitchServer::privateMessageReceived(Communi::IrcPrivateMessage *message)
|
||||||
{
|
{
|
||||||
IrcMessageHandler::getInstance().handlePrivMessage(message, *this);
|
IrcMessageHandler::getInstance().handlePrivMessage(message, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchServer::messageReceived(IrcMessage *message)
|
void TwitchServer::messageReceived(Communi::IrcMessage *message)
|
||||||
{
|
{
|
||||||
// this->readConnection
|
// this->readConnection
|
||||||
if (message->type() == IrcMessage::Type::Private) {
|
if (message->type() == Communi::IrcMessage::Type::Private) {
|
||||||
// We already have a handler for private messages
|
// We already have a handler for private messages
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +107,7 @@ void TwitchServer::messageReceived(IrcMessage *message)
|
||||||
} else if (command == "MODE") {
|
} else if (command == "MODE") {
|
||||||
handler.handleModeMessage(message);
|
handler.handleModeMessage(message);
|
||||||
} else if (command == "NOTICE") {
|
} else if (command == "NOTICE") {
|
||||||
handler.handleNoticeMessage(static_cast<IrcNoticeMessage *>(message));
|
handler.handleNoticeMessage(static_cast<Communi::IrcNoticeMessage *>(message));
|
||||||
} else if (command == "JOIN") {
|
} else if (command == "JOIN") {
|
||||||
handler.handleJoinMessage(message);
|
handler.handleJoinMessage(message);
|
||||||
} else if (command == "PART") {
|
} 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()) {
|
switch (message->type()) {
|
||||||
case IrcMessage::Type::Notice: {
|
case Communi::IrcMessage::Type::Notice: {
|
||||||
IrcMessageHandler::getInstance().handleWriteConnectionNoticeMessage(
|
IrcMessageHandler::getInstance().handleWriteConnectionNoticeMessage(
|
||||||
static_cast<IrcNoticeMessage *>(message));
|
static_cast<Communi::IrcNoticeMessage *>(message));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
default:;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,20 +182,6 @@ std::shared_ptr<Channel> TwitchServer::getChannelOrEmptyByID(const QString &chan
|
||||||
return Channel::getEmpty();
|
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)
|
QString TwitchServer::cleanChannelName(const QString &dirtyChannelName)
|
||||||
{
|
{
|
||||||
return dirtyChannelName.toLower();
|
return dirtyChannelName.toLower();
|
||||||
|
|
|
@ -33,7 +33,7 @@ public:
|
||||||
IndirectChannel watchingChannel;
|
IndirectChannel watchingChannel;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initializeConnection(Communi::IrcConnection *connection, bool isRead,
|
void initializeConnection(providers::irc::IrcConnection *connection, bool isRead,
|
||||||
bool isWrite) override;
|
bool isWrite) override;
|
||||||
std::shared_ptr<Channel> createChannel(const QString &channelName) override;
|
std::shared_ptr<Channel> createChannel(const QString &channelName) override;
|
||||||
|
|
||||||
|
|
|
@ -36,31 +36,35 @@ AboutPage::AboutPage()
|
||||||
// palette.setColor(QPalette::Link, "#a5cdff");
|
// palette.setColor(QPalette::Link, "#a5cdff");
|
||||||
// palette.setColor(QPalette::LinkVisited, "#a5cdff");
|
// palette.setColor(QPalette::LinkVisited, "#a5cdff");
|
||||||
|
|
||||||
auto created = layout.emplace<QLabel>();
|
/*auto xd = layout.emplace<QGroupBox>("Created by...");
|
||||||
{
|
{
|
||||||
created->setText(
|
auto created = xd.emplace<QLabel>();
|
||||||
"Twitch Chat Client created by <a href=\"https://github.com/fourtf\">fourtf</a>");
|
{
|
||||||
created->setTextFormat(Qt::RichText);
|
created->setText("Created by <a href=\"https://github.com/fourtf\">fourtf</a><br>"
|
||||||
created->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
"with big help from pajlada.");
|
||||||
Qt::LinksAccessibleByKeyboard |
|
created->setTextFormat(Qt::RichText);
|
||||||
Qt::LinksAccessibleByKeyboard);
|
created->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
||||||
created->setOpenExternalLinks(true);
|
Qt::LinksAccessibleByKeyboard |
|
||||||
// created->setPalette(palette);
|
Qt::LinksAccessibleByKeyboard);
|
||||||
}
|
created->setOpenExternalLinks(true);
|
||||||
|
// created->setPalette(palette);
|
||||||
|
}
|
||||||
|
|
||||||
auto github = layout.emplace<QLabel>();
|
// auto github = xd.emplace<QLabel>();
|
||||||
{
|
// {
|
||||||
github->setText(
|
// github->setText(
|
||||||
"<a href=\"https://github.com/fourtf/chatterino2\">Chatterino on Github</a>");
|
// "<a href=\"https://github.com/fourtf/chatterino2\">Chatterino on
|
||||||
github->setTextFormat(Qt::RichText);
|
// Github</a>");
|
||||||
github->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
// github->setTextFormat(Qt::RichText);
|
||||||
Qt::LinksAccessibleByKeyboard |
|
// github->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
||||||
Qt::LinksAccessibleByKeyboard);
|
// Qt::LinksAccessibleByKeyboard |
|
||||||
github->setOpenExternalLinks(true);
|
// Qt::LinksAccessibleByKeyboard);
|
||||||
// github->setPalette(palette);
|
// github->setOpenExternalLinks(true);
|
||||||
}
|
// // github->setPalette(palette);
|
||||||
|
// }
|
||||||
|
}*/
|
||||||
|
|
||||||
auto licenses = layout.emplace<QGroupBox>("Open source software used");
|
auto licenses = layout.emplace<QGroupBox>("Open source software used...");
|
||||||
{
|
{
|
||||||
auto form = licenses.emplace<QFormLayout>();
|
auto form = licenses.emplace<QFormLayout>();
|
||||||
|
|
||||||
|
@ -90,6 +94,7 @@ void AboutPage::addLicense(QFormLayout *form, const QString &name, const QString
|
||||||
a->setOpenExternalLinks(true);
|
a->setOpenExternalLinks(true);
|
||||||
auto *b = new SignalLabel();
|
auto *b = new SignalLabel();
|
||||||
b->setText("<a href=\"" + licenseLink + "\">show license</a>");
|
b->setText("<a href=\"" + licenseLink + "\">show license</a>");
|
||||||
|
b->setCursor(Qt::PointingHandCursor);
|
||||||
QObject::connect(b, &SignalLabel::mouseUp, [licenseLink] {
|
QObject::connect(b, &SignalLabel::mouseUp, [licenseLink] {
|
||||||
auto *edit = new QTextEdit;
|
auto *edit = new QTextEdit;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue