added sasl auth

This commit is contained in:
fourtf 2019-09-15 13:15:29 +02:00
parent 22ca20ad2a
commit a390649d0f
5 changed files with 29 additions and 19 deletions

View file

@ -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;

View file

@ -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);
}
}

View file

@ -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) {

View file

@ -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;
}

View file

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>264</width>
<width>329</width>
<height>414</height>
</rect>
</property>
@ -158,6 +158,11 @@
<string>Server Password (/PASS $password)</string>
</property>
</item>
<item>
<property name="text">
<string>SASL</string>
</property>
</item>
</widget>
</item>
<item row="10" column="0">