From a390649d0fb2b930a150e1ad1b5392f49bb28188 Mon Sep 17 00:00:00 2001 From: fourtf Date: Sun, 15 Sep 2019 13:15:29 +0200 Subject: [PATCH] added sasl auth --- src/providers/irc/Irc2.hpp | 2 +- src/providers/irc/IrcServer.cpp | 33 +++++++++++---------- src/providers/twitch/TwitchIrcServer.cpp | 2 -- src/widgets/dialogs/IrcConnectionEditor.cpp | 4 +++ src/widgets/dialogs/IrcConnectionEditor.ui | 7 ++++- 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/providers/irc/Irc2.hpp b/src/providers/irc/Irc2.hpp index 56244c856..0d40f6fe1 100644 --- a/src/providers/irc/Irc2.hpp +++ b/src/providers/irc/Irc2.hpp @@ -10,7 +10,7 @@ class QAbstractTableModel; namespace chatterino { -enum class IrcAuthType { Anonymous, Custom, Pass }; +enum class IrcAuthType { Anonymous, Custom, Pass, Sasl }; struct IrcServerData { QString host; diff --git a/src/providers/irc/IrcServer.cpp b/src/providers/irc/IrcServer.cpp index a0f5907fa..1ef1ffc99 100644 --- a/src/providers/irc/IrcServer.cpp +++ b/src/providers/irc/IrcServer.cpp @@ -63,23 +63,26 @@ void IrcServer::initializeConnection(IrcConnection *connection, connection->setRealName(this->data_->real.isEmpty() ? this->data_->user : this->data_->nick); - if (this->data_->authType == IrcAuthType::Pass) + switch (this->data_->authType) { - this->data_->getPassword( - this, [conn = new QObjectRef(connection) /* can't copy */, - this](const QString &password) mutable { - if (*conn) - { - (*conn)->setPassword(password); - this->open(Both); - } + case IrcAuthType::Sasl: + connection->setSaslMechanism("PLAIN"); + [[fallthrough]]; + case IrcAuthType::Pass: + this->data_->getPassword( + this, [conn = new QObjectRef(connection) /* can't copy */, + this](const QString &password) mutable { + if (*conn) + { + (*conn)->setPassword(password); + this->open(Both); + } - delete conn; - }); - } - else - { - this->open(Both); + delete conn; + }); + break; + default: + this->open(Both); } } diff --git a/src/providers/twitch/TwitchIrcServer.cpp b/src/providers/twitch/TwitchIrcServer.cpp index 7ecfbff89..271536e9c 100644 --- a/src/providers/twitch/TwitchIrcServer.cpp +++ b/src/providers/twitch/TwitchIrcServer.cpp @@ -43,8 +43,6 @@ TwitchIrcServer::TwitchIrcServer() , mentionsChannel(new Channel("/mentions", Channel::Type::TwitchMentions)) , watchingChannel(Channel::getEmpty(), Channel::Type::TwitchWatching) { - qDebug() << "init TwitchServer"; - this->pubsub = new PubSub; // getSettings()->twitchSeperateWriteConnection.connect([this](auto, auto) { diff --git a/src/widgets/dialogs/IrcConnectionEditor.cpp b/src/widgets/dialogs/IrcConnectionEditor.cpp index 1adfdf295..055b229fe 100644 --- a/src/widgets/dialogs/IrcConnectionEditor.cpp +++ b/src/widgets/dialogs/IrcConnectionEditor.cpp @@ -40,6 +40,8 @@ IrcConnectionEditor::IrcConnectionEditor(const IrcServerData &data, bool isAdd, return 1; case IrcAuthType::Pass: return 2; + case IrcAuthType::Sasl: + return 3; default: return 0; } @@ -83,6 +85,8 @@ IrcServerData IrcConnectionEditor::data() return IrcAuthType::Custom; case 2: return IrcAuthType::Pass; + case 3: + return IrcAuthType::Sasl; default: return IrcAuthType::Anonymous; } diff --git a/src/widgets/dialogs/IrcConnectionEditor.ui b/src/widgets/dialogs/IrcConnectionEditor.ui index e054ac557..516fe2b55 100644 --- a/src/widgets/dialogs/IrcConnectionEditor.ui +++ b/src/widgets/dialogs/IrcConnectionEditor.ui @@ -6,7 +6,7 @@ 0 0 - 264 + 329 414 @@ -158,6 +158,11 @@ Server Password (/PASS $password) + + + SASL + +