X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fircserverhandler.cpp;h=ce15f7818ecf53ad56c9eaf79a56d53e8e56344d;hb=ea7fa1e8cc275e6c431512d2003ec960f647bbef;hp=30f5e2adfdc91b29168a7697e2d17c7b42d3e476;hpb=513c0edce6f4c69f16e6a00c144877e8d5940096;p=quassel.git diff --git a/src/core/ircserverhandler.cpp b/src/core/ircserverhandler.cpp index 30f5e2ad..ce15f781 100644 --- a/src/core/ircserverhandler.cpp +++ b/src/core/ircserverhandler.cpp @@ -84,6 +84,12 @@ void IrcServerHandler::handleServerMsg(QByteArray msg) { QString foo = serverDecode(params.takeFirst()); + // with SASL, the command is 'AUTHENTICATE +' and we should check for this here. + if(foo == QString("AUTHENTICATE +")) { + handleAuthenticate(); + return; + } + // a colon as the first chars indicates the existence of a prefix if(foo[0] == ':') { foo.remove(0, 1); @@ -160,6 +166,11 @@ void IrcServerHandler::defaultHandler(QString cmd, const QString &prefix, const case 321: case 366: case 376: break; + case 903: case 904: case 905: case 906: case 907: + { + network()->putRawLine("CAP END"); + emit displayMsg(Message::Info, BufferInfo::StatusBuffer, "", "CAP: " + params.join("")); + } // Everything else will be marked in red, so we can add them somewhere. default: if(_whois) { @@ -542,6 +553,31 @@ void IrcServerHandler::handleTopic(const QString &prefix, const QListname(), tr("%1 has changed topic for %2 to: \"%3\"").arg(ircuser->nick()).arg(channel->name()).arg(topic)); } +void IrcServerHandler::handleCap(const QString &prefix, const QList ¶ms) { + // for SASL, there will only be a single param of 'sasl', however you can check here for + // additional CAP messages (ls, multi-prefix, et cetera). + + Q_UNUSED(prefix); + + if(params.size() == 3) { + QString param = serverDecode(params[2]); + if(param == QString("sasl")) { // SASL Ready + network()->putRawLine(serverEncode("AUTHENTICATE PLAIN")); // Only working with PLAIN atm, blowfish later + } + } +} + +void IrcServerHandler::handleAuthenticate() { + QString construct = network()->saslAccount(); + construct.append(QChar(QChar::Null)); + construct.append(network()->saslAccount()); + construct.append(QChar(QChar::Null)); + construct.append(network()->saslPassword()); + QByteArray saslData = QByteArray(construct.toAscii().toBase64()); + saslData.prepend(QString("AUTHENTICATE ").toAscii()); + network()->putRawLine(saslData); +} + /* RPL_WELCOME */ void IrcServerHandler::handle001(const QString &prefix, const QList ¶ms) { network()->setCurrentServer(prefix); @@ -1067,6 +1103,24 @@ void IrcServerHandler::handle433(const QString &prefix, const QList tryNextNick(errnick); } +/* ERR_UNAVAILRESOURCE */ +void IrcServerHandler::handle437(const QString &prefix, const QList ¶ms) { + Q_UNUSED(prefix); + if(!checkParamCount("IrcServerHandler::handle437()", params, 1)) + return; + + QString errnick = serverDecode(params[0]); + emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", tr("Nick/channel is temporarily unavailable: %1").arg(errnick)); + + // if there is a problem while connecting to the server -> we handle it + // but only if our connection has not been finished yet... + if(!network()->currentServer().isEmpty()) + return; + + if(!network()->isChannelName(errnick)) + tryNextNick(errnick); +} + /* Handle signals from Netsplit objects */ void IrcServerHandler::handleNetsplitJoin(const QString &channel, const QStringList &users, const QStringList &modes, const QString& quitMessage) @@ -1077,17 +1131,20 @@ void IrcServerHandler::handleNetsplitJoin(const QString &channel, const QStringL } QList ircUsers; QStringList newModes = modes; + QStringList newUsers = users; foreach(QString user, users) { - IrcUser *iu = network()->updateNickFromMask(user); + IrcUser *iu = network()->ircUser(nickFromMask(user)); if(iu) ircUsers.append(iu); - else { - newModes.removeAt(users.indexOf(user)); + else { // the user already quit + int idx = users.indexOf(user); + newUsers.removeAt(idx); + newModes.removeAt(idx); } } - QString msg = users.join("#:#").append("#:#").append(quitMessage); + QString msg = newUsers.join("#:#").append("#:#").append(quitMessage); emit displayMsg(Message::NetsplitJoin, BufferInfo::ChannelBuffer, channel, msg); ircChannel->joinIrcUsers(ircUsers, newModes); }