X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fcoreuserinputhandler.cpp;h=b7f1cc0290aae10119bd6d5da1869d71664b1003;hb=d329046faaae47c39af14d9019b542b945e628d7;hp=a2feda9aa91f51072c2822957ef93b96dc5aa0ce;hpb=ca8f178da7892a9b8b16a4c9bac286b15c2a53d5;p=quassel.git diff --git a/src/core/coreuserinputhandler.cpp b/src/core/coreuserinputhandler.cpp index a2feda9a..b7f1cc02 100644 --- a/src/core/coreuserinputhandler.cpp +++ b/src/core/coreuserinputhandler.cpp @@ -128,8 +128,8 @@ void CoreUserInputHandler::handleCtcp(const BufferInfo &bufferInfo, const QStrin if(ctcpTag.isEmpty()) return; - QString message = ""; - QString verboseMessage = tr("sending CTCP-%1 request").arg(ctcpTag); + QString message = msg.section(' ', 2); + QString verboseMessage = tr("sending CTCP-%1 request to %2").arg(ctcpTag).arg(nick); if(ctcpTag == "PING") { uint now = QDateTime::currentDateTime().toTime_t(); @@ -169,16 +169,23 @@ void CoreUserInputHandler::handleJoin(const BufferInfo &bufferInfo, const QStrin QString sane_msg = msg; sane_msg.replace(QRegExp(", +"), ","); QStringList params = sane_msg.trimmed().split(" "); + QStringList chans = params[0].split(",", QString::SkipEmptyParts); QStringList keys; + if(params.count() > 1) + keys = params[1].split(","); + int i; for(i = 0; i < chans.count(); i++) { if(!network()->isChannelName(chans[i])) chans[i].prepend('#'); - } - if(params.count() > 1) - keys = params[1].split(","); + if(i < keys.count()) { + network()->addChannelKey(chans[i], keys[i]); + } else { + network()->removeChannelKey(chans[i]); + } + } static const char *cmd = "JOIN"; i = 0; @@ -186,18 +193,24 @@ void CoreUserInputHandler::handleJoin(const BufferInfo &bufferInfo, const QStrin int slicesize = chans.count(); QList encodedParams; + // go through all to-be-joined channels and (re)build the join list while(i < chans.count()) { joinChans.append(chans.at(i)); if(i < keys.count()) joinKeys.append(keys.at(i)); + // if the channel list we built so far either contains all requested channels or exceeds + // the desired amount of channels in this slice, try to send what we have so far if(++i == chans.count() || joinChans.count() >= slicesize) { - params[0] = joinChans.join(","); - params[1] = joinKeys.join(","); + params.clear(); + params.append(joinChans.join(",")); + params.append(joinKeys.join(",")); encodedParams = serverEncode(params); + // check if it fits in one command if(lastParamOverrun(cmd, encodedParams) == 0) { emit putCmd(cmd, encodedParams); } else if(slicesize > 1) { + // back to start of slice, try again with half the amount of channels i -= slicesize; slicesize /= 2; } @@ -205,16 +218,6 @@ void CoreUserInputHandler::handleJoin(const BufferInfo &bufferInfo, const QStrin joinKeys.clear(); } } - - i = 0; - for(; i < keys.count(); i++) { - if(i >= chans.count()) - break; - network()->addChannelKey(chans[i], keys[i]); - } - for(; i < chans.count(); i++) { - network()->removeChannelKey(chans[i]); - } } void CoreUserInputHandler::handleKick(const BufferInfo &bufferInfo, const QString &msg) {