+void CoreUserInputHandler::handleKeyx(const BufferInfo &bufferInfo, const QString &msg)
+{
+#ifdef HAVE_QCA2
+ if (!bufferInfo.isValid())
+ return;
+
+ if (!Cipher::neededFeaturesAvailable())
+ return;
+
+ QStringList parms = msg.split(' ', QString::SkipEmptyParts);
+
+ if (parms.count() == 0 && !bufferInfo.bufferName().isEmpty())
+ parms.prepend(bufferInfo.bufferName());
+ else if (parms.count() != 1) {
+ emit displayMsg(Message::Info, bufferInfo.bufferName(),
+ tr("[usage] /keyx [<nick|channel>] Initiates a DH1080 key exchange with the target."));
+ return;
+ }
+
+ QString target = parms.at(0);
+
+ Cipher *cipher = network()->cipher(target);
+ if (!cipher) // happens when there is no CoreIrcChannel for the target
+ return;
+
+ QByteArray pubKey = cipher->initKeyExchange();
+ if (pubKey.isEmpty())
+ emit displayMsg(Message::Error, bufferInfo.bufferName(), tr("Failed to initiate key exchange with %1.").arg(target));
+ else {
+ QList<QByteArray> params;
+ params << serverEncode(target) << serverEncode("DH1080_INIT ") + pubKey;
+ emit putCmd("NOTICE", params);
+ emit displayMsg(Message::Info, bufferInfo.bufferName(), tr("Initiated key exchange with %1.").arg(target));
+ }
+#else
+ Q_UNUSED(msg)
+ emit displayMsg(Message::Error, bufferInfo.bufferName(), tr("Error: Setting an encryption key requires Quassel to have been built "
+ "with support for the Qt Cryptographic Architecture (QCA) library. "
+ "Contact your distributor about a Quassel package with QCA "
+ "support, or rebuild Quassel with QCA present."));
+#endif
+}
+
+
+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);
+}
+
+
+void CoreUserInputHandler::handleMode(const BufferInfo &bufferInfo, const QString &msg)
+{
+ Q_UNUSED(bufferInfo)
+
+ QStringList params = msg.split(' ', QString::SkipEmptyParts);
+ // if the first argument is neither a channel nor us (user modes are only to oneself) the current buffer is assumed to be the target
+ if (!params.isEmpty()) {
+ if (!network()->isChannelName(params[0]) && !network()->isMyNick(params[0]))
+ params.prepend(bufferInfo.bufferName());
+ if (network()->isMyNick(params[0]) && params.count() == 2)
+ network()->updateIssuedModes(params[1]);
+ if (params[0] == "-reset" && params.count() == 1) {
+ // FIXME: give feedback to the user (I don't want to add new strings right now)
+ network()->resetPersistentModes();
+ return;
+ }
+ }
+
+ // TODO handle correct encoding for buffer modes (channelEncode())
+ emit putCmd("MODE", serverEncode(params));