int xdelimPos = -1;
int xdelimEndPos = -1;
int spacePos = -1;
+ QList<QByteArray> replies;
while((xdelimPos = dequotedMessage.indexOf(XDELIM)) != -1) {
if(xdelimPos > 0)
displayMsg(messageType, target, userDecode(target, dequotedMessage.left(xdelimPos)), prefix, flags);
ctcpparam = QString();
}
- handle(ctcpcmd, Q_ARG(CtcpType, ctcptype), Q_ARG(QString, prefix), Q_ARG(QString, target), Q_ARG(QString, ctcpparam));
+ if(ctcpcmd.toUpper() == QLatin1String("ACTION") || !_ignoreListManager->ctcpMatch(prefix, network()->networkName(), ctcpcmd.toUpper())) {
+ QString reply_;
+ handle(ctcpcmd, Q_ARG(CtcpType, ctcptype), Q_ARG(QString, prefix), Q_ARG(QString, target), Q_ARG(QString, ctcpparam), Q_ARG(QString, reply_));
+ if(ctcptype == CtcpQuery && !reply_.isNull()) {
+ replies << lowLevelQuote(pack(serverEncode(ctcpcmd), userEncode(nickFromMask(prefix), reply_)));
+ }
+ }
+ }
+ if(ctcptype == CtcpQuery && !replies.isEmpty()) {
+ packedReply(nickFromMask(prefix), replies);
}
if(!dequotedMessage.isEmpty())
emit putCmd("NOTICE", params);
}
+void CtcpHandler::packedReply(const QString &bufname, const QList<QByteArray> &replies) {
+ QList<QByteArray> params;
+
+ int answerSize = 0;
+ for(int i = 0; i < replies.count(); i++) {
+ answerSize += replies.at(i).size();
+ }
+
+ QByteArray quotedReply;
+ quotedReply.reserve(answerSize);
+ for(int i = 0; i < replies.count(); i++) {
+ quotedReply.append(replies.at(i));
+ }
+
+ params << serverEncode(bufname) << quotedReply;
+ emit putCmd("NOTICE", params);
+}
+
//******************************/
// CTCP HANDLER
//******************************/
-void CtcpHandler::handleAction(CtcpType ctcptype, const QString &prefix, const QString &target, const QString ¶m) {
+void CtcpHandler::handleAction(CtcpType ctcptype, const QString &prefix, const QString &target, const QString ¶m, QString &/*reply*/) {
Q_UNUSED(ctcptype)
emit displayMsg(Message::Action, typeByTarget(target), target, param, prefix);
}
-void CtcpHandler::handlePing(CtcpType ctcptype, const QString &prefix, const QString &target, const QString ¶m) {
+void CtcpHandler::handleClientinfo(CtcpType ctcptype, const QString &prefix, const QString &target, const QString ¶m, QString &reply) {
Q_UNUSED(target)
if(ctcptype == CtcpQuery) {
- if(_ignoreListManager->ctcpMatch(prefix, network()->networkName(), "PING"))
- return;
- reply(nickFromMask(prefix), "PING", param);
+ QStringList supportedHandlers;
+ foreach(QString handler, providesHandlers()) {
+ supportedHandlers << handler.toUpper();
+ }
+ reply = supportedHandlers.join(" ");
+ emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP CLIENTINFO request from %1").arg(prefix));
+ } else {
+ // display clientinfo answer
+ emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP CLIENTINFO answer from %1: %2")
+ .arg(nickFromMask(prefix)).arg(param));
+ }
+}
+
+void CtcpHandler::handlePing(CtcpType ctcptype, const QString &prefix, const QString &target, const QString ¶m, QString &reply) {
+ Q_UNUSED(target)
+ if(ctcptype == CtcpQuery) {
+ reply = param;
emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP PING request from %1").arg(prefix));
} else {
// display ping answer
}
}
-void CtcpHandler::handleVersion(CtcpType ctcptype, const QString &prefix, const QString &target, const QString ¶m) {
+void CtcpHandler::handleVersion(CtcpType ctcptype, const QString &prefix, const QString &target, const QString ¶m, QString &reply) {
Q_UNUSED(target)
if(ctcptype == CtcpQuery) {
- if(_ignoreListManager->ctcpMatch(prefix, network()->networkName(), "VERSION"))
- return;
- reply(nickFromMask(prefix), "VERSION", QString("Quassel IRC %1 (built on %2) -- http://www.quassel-irc.org")
- .arg(Quassel::buildInfo().plainVersionString)
- .arg(Quassel::buildInfo().buildDate));
+ reply = QString("Quassel IRC %1 (built on %2) -- http://www.quassel-irc.org").arg(Quassel::buildInfo().plainVersionString).arg(Quassel::buildInfo().buildDate);
emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP VERSION request by %1").arg(prefix));
} else {
// display Version answer
}
}
-void CtcpHandler::handleTime(CtcpType ctcptype, const QString &prefix, const QString &target, const QString ¶m) {
+void CtcpHandler::handleTime(CtcpType ctcptype, const QString &prefix, const QString &target, const QString ¶m, QString &reply) {
Q_UNUSED(target)
if(ctcptype == CtcpQuery) {
- if(_ignoreListManager->ctcpMatch(prefix, network()->networkName(), "TIME"))
- return;
- reply(nickFromMask(prefix), "TIME", QDateTime::currentDateTime().toString());
+ reply = QDateTime::currentDateTime().toString();
emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP TIME request by %1").arg(prefix));
- }
- else {
+ } else {
emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP TIME answer from %1: %2")
.arg(nickFromMask(prefix)).arg(param));
}
}
-void CtcpHandler::defaultHandler(const QString &cmd, CtcpType ctcptype, const QString &prefix, const QString &target, const QString ¶m) {
+void CtcpHandler::defaultHandler(const QString &cmd, CtcpType ctcptype, const QString &prefix, const QString &target, const QString ¶m, QString &reply) {
Q_UNUSED(ctcptype);
Q_UNUSED(target);
- if(!_ignoreListManager->ctcpMatch(prefix, network()->networkName())) {
- QString str = tr("Received unknown CTCP %1 by %2").arg(cmd).arg(prefix);
- if(!param.isEmpty())
- str.append(tr(" with arguments: %1").arg(param));
- emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", str);
- }
+ Q_UNUSED(reply);
+ QString str = tr("Received unknown CTCP %1 by %2").arg(cmd).arg(prefix);
+ if(!param.isEmpty())
+ str.append(tr(" with arguments: %1").arg(param));
+ emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", str);
}