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/taggeduser.cpp \
|
||||
src/controllers/taggedusers/taggedusersmodel.cpp \
|
||||
src/util/emotemap.cpp
|
||||
src/util/emotemap.cpp \
|
||||
src/providers/irc/ircconnection2.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/precompiled_header.hpp \
|
||||
|
@ -365,7 +366,8 @@ HEADERS += \
|
|||
src/providerid.hpp \
|
||||
src/controllers/taggedusers/taggedusersmodel.hpp \
|
||||
src/util/qstringhash.hpp \
|
||||
src/util/mutexvalue.hpp
|
||||
src/util/mutexvalue.hpp \
|
||||
src/providers/irc/ircconnection2.hpp
|
||||
|
||||
RESOURCES += \
|
||||
resources/resources.qrc
|
||||
|
|
|
@ -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
|
||||
|
|
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 "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;
|
||||
|
||||
|
|
|
@ -36,31 +36,35 @@ AboutPage::AboutPage()
|
|||
// palette.setColor(QPalette::Link, "#a5cdff");
|
||||
// palette.setColor(QPalette::LinkVisited, "#a5cdff");
|
||||
|
||||
auto created = layout.emplace<QLabel>();
|
||||
/*auto xd = layout.emplace<QGroupBox>("Created by...");
|
||||
{
|
||||
created->setText(
|
||||
"Twitch Chat Client created by <a href=\"https://github.com/fourtf\">fourtf</a>");
|
||||
created->setTextFormat(Qt::RichText);
|
||||
created->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
||||
Qt::LinksAccessibleByKeyboard |
|
||||
Qt::LinksAccessibleByKeyboard);
|
||||
created->setOpenExternalLinks(true);
|
||||
// created->setPalette(palette);
|
||||
}
|
||||
auto created = xd.emplace<QLabel>();
|
||||
{
|
||||
created->setText("Created by <a href=\"https://github.com/fourtf\">fourtf</a><br>"
|
||||
"with big help from pajlada.");
|
||||
created->setTextFormat(Qt::RichText);
|
||||
created->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
||||
Qt::LinksAccessibleByKeyboard |
|
||||
Qt::LinksAccessibleByKeyboard);
|
||||
created->setOpenExternalLinks(true);
|
||||
// created->setPalette(palette);
|
||||
}
|
||||
|
||||
auto github = layout.emplace<QLabel>();
|
||||
{
|
||||
github->setText(
|
||||
"<a href=\"https://github.com/fourtf/chatterino2\">Chatterino on Github</a>");
|
||||
github->setTextFormat(Qt::RichText);
|
||||
github->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
||||
Qt::LinksAccessibleByKeyboard |
|
||||
Qt::LinksAccessibleByKeyboard);
|
||||
github->setOpenExternalLinks(true);
|
||||
// github->setPalette(palette);
|
||||
}
|
||||
// auto github = xd.emplace<QLabel>();
|
||||
// {
|
||||
// github->setText(
|
||||
// "<a href=\"https://github.com/fourtf/chatterino2\">Chatterino on
|
||||
// Github</a>");
|
||||
// github->setTextFormat(Qt::RichText);
|
||||
// github->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
||||
// Qt::LinksAccessibleByKeyboard |
|
||||
// Qt::LinksAccessibleByKeyboard);
|
||||
// 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>();
|
||||
|
||||
|
@ -90,6 +94,7 @@ void AboutPage::addLicense(QFormLayout *form, const QString &name, const QString
|
|||
a->setOpenExternalLinks(true);
|
||||
auto *b = new SignalLabel();
|
||||
b->setText("<a href=\"" + licenseLink + "\">show license</a>");
|
||||
b->setCursor(Qt::PointingHandCursor);
|
||||
QObject::connect(b, &SignalLabel::mouseUp, [licenseLink] {
|
||||
auto *edit = new QTextEdit;
|
||||
|
||||
|
|
Loading…
Reference in a new issue