+ static const char *cmd = "JOIN";
+ i = 0;
+ QStringList joinChans, joinKeys;
+ int slicesize = chans.count();
+ QList<QByteArray> 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.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;
+ }
+ joinChans.clear();
+ joinKeys.clear();
+ }
+ }
+}
+
+
+void CoreUserInputHandler::handleKick(const BufferInfo &bufferInfo, const QString &msg)
+{
+ QString nick = msg.section(' ', 0, 0, QString::SectionSkipEmpty);
+ QString reason = msg.section(' ', 1, -1, QString::SectionSkipEmpty).trimmed();
+ if (reason.isEmpty())
+ reason = network()->identityPtr()->kickReason();
+
+ QList<QByteArray> params;
+ params << serverEncode(bufferInfo.bufferName()) << serverEncode(nick) << channelEncode(bufferInfo.bufferName(), reason);
+ emit putCmd("KICK", params);
+}
+
+
+void CoreUserInputHandler::handleKill(const BufferInfo &bufferInfo, const QString &msg)
+{
+ Q_UNUSED(bufferInfo)
+ QString nick = msg.section(' ', 0, 0, QString::SectionSkipEmpty);
+ QString pass = msg.section(' ', 1, -1, QString::SectionSkipEmpty);
+ QList<QByteArray> params;
+ params << serverEncode(nick) << serverEncode(pass);
+ emit putCmd("KILL", params);
+}
+
+
+void CoreUserInputHandler::handleList(const BufferInfo &bufferInfo, const QString &msg)
+{
+ Q_UNUSED(bufferInfo)
+ emit putCmd("LIST", serverEncode(msg.split(' ', QString::SkipEmptyParts)));
+}
+
+
+void CoreUserInputHandler::handleMe(const BufferInfo &bufferInfo, const QString &msg)
+{
+ if (bufferInfo.bufferName().isEmpty()) return; // server buffer
+ // FIXME make this a proper event
+ coreNetwork()->coreSession()->ctcpParser()->query(coreNetwork(), bufferInfo.bufferName(), "ACTION", msg);
+ emit displayMsg(Message::Action, bufferInfo.type(), bufferInfo.bufferName(), msg, network()->myNick(), Message::Self);