+ else if (bufferInfo.type() == BufferInfo::ChannelBuffer) {
+ banChannel = bufferInfo.bufferName();
+ }
+ else {
+ emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", QString("Error: channel unknown in command: /BAN %1").arg(msg));
+ return;
+ }
+
+ if (!params.isEmpty() && !params.contains("!") && network()->ircUser(params[0])) {
+ IrcUser *ircuser = network()->ircUser(params[0]);
+ // generalizedHost changes <nick> to *!ident@*.sld.tld.
+ QString generalizedHost = ircuser->host();
+ if (generalizedHost.isEmpty()) {
+ emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", QString("Error: host unknown in command: /BAN %1").arg(msg));
+ return;
+ }
+
+ static QRegExp ipAddress("\\d+\\.\\d+\\.\\d+\\.\\d+");
+ if (ipAddress.exactMatch(generalizedHost)) {
+ int lastDotPos = generalizedHost.lastIndexOf('.') + 1;
+ generalizedHost.replace(lastDotPos, generalizedHost.length() - lastDotPos, '*');
+ }
+ else if (generalizedHost.lastIndexOf(".") != -1 && generalizedHost.lastIndexOf(".", generalizedHost.lastIndexOf(".")-1) != -1) {
+ int secondLastPeriodPosition = generalizedHost.lastIndexOf(".", generalizedHost.lastIndexOf(".")-1);
+ generalizedHost.replace(0, secondLastPeriodPosition, "*");
+ }
+ banUser = QString("*!%1@%2").arg(ircuser->user(), generalizedHost);
+ }
+ else {
+ banUser = params.join(" ");
+ }
+
+ QString banMode = ban ? "+b" : "-b";
+ QString banMsg = QString("MODE %1 %2 %3").arg(banChannel, banMode, banUser);
+ emit putRawLine(serverEncode(banMsg));
+}
+
+
+void CoreUserInputHandler::handleCtcp(const BufferInfo &bufferInfo, const QString &msg)
+{
+ Q_UNUSED(bufferInfo)
+
+ QString nick = msg.section(' ', 0, 0);
+ QString ctcpTag = msg.section(' ', 1, 1).toUpper();
+ if (ctcpTag.isEmpty())
+ return;
+
+ QString message = msg.section(' ', 2);
+ QString verboseMessage = tr("sending CTCP-%1 request to %2").arg(ctcpTag).arg(nick);
+
+ if (ctcpTag == "PING") {
+ message = QString::number(QDateTime::currentMSecsSinceEpoch());
+ }
+
+ // FIXME make this a proper event
+ coreNetwork()->coreSession()->ctcpParser()->query(coreNetwork(), nick, ctcpTag, message);
+ emit displayMsg(Message::Action, BufferInfo::StatusBuffer, "", verboseMessage, network()->myNick());
+}
+
+
+void CoreUserInputHandler::handleDelkey(const BufferInfo &bufferInfo, const QString &msg)
+{
+ QString bufname = bufferInfo.bufferName().isNull() ? "" : bufferInfo.bufferName();
+#ifdef HAVE_QCA2
+ if (!bufferInfo.isValid())
+ return;
+
+ if (!Cipher::neededFeaturesAvailable()) {
+ emit displayMsg(Message::Error, typeByTarget(bufname), bufname, tr("Error: QCA provider plugin not found. It is usually provided by the qca-ossl plugin."));
+ return;
+ }
+
+ QStringList parms = msg.split(' ', QString::SkipEmptyParts);
+
+ if (parms.isEmpty() && !bufferInfo.bufferName().isEmpty() && bufferInfo.acceptsRegularMessages())
+ parms.prepend(bufferInfo.bufferName());
+
+ if (parms.isEmpty()) {
+ emit displayMsg(Message::Info, typeByTarget(bufname), bufname,
+ tr("[usage] /delkey <nick|channel> deletes the encryption key for nick or channel or just /delkey when in a channel or query."));
+ return;
+ }
+
+ QString target = parms.at(0);
+
+ if (network()->cipherKey(target).isEmpty()) {
+ emit displayMsg(Message::Info, typeByTarget(bufname), bufname, tr("No key has been set for %1.").arg(target));
+ return;
+ }
+
+ network()->setCipherKey(target, QByteArray());
+ emit displayMsg(Message::Info, typeByTarget(bufname), bufname, tr("The key for %1 has been deleted.").arg(target));
+
+#else
+ Q_UNUSED(msg)
+ emit displayMsg(Message::Error, typeByTarget(bufname), bufname, tr("Error: Setting an encryption key requires Quassel to have been built "
+ "with support for the Qt Cryptographic Architecture (QCA2) library. "
+ "Contact your distributor about a Quassel package with QCA2 "
+ "support, or rebuild Quassel with QCA2 present."));
+#endif
+}