projects
/
quassel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Made CTCP VERSION reply more verbose. Set a more reasonable default font.
[quassel.git]
/
src
/
core
/
ctcphandler.cpp
diff --git
a/src/core/ctcphandler.cpp
b/src/core/ctcphandler.cpp
index
788055c
..
a3bd308
100644
(file)
--- a/
src/core/ctcphandler.cpp
+++ b/
src/core/ctcphandler.cpp
@@
-1,11
+1,11
@@
/***************************************************************************
/***************************************************************************
- * Copyright (C) 2005-0
7 by The Quassel Team
*
+ * Copyright (C) 2005-0
8 by the Quassel Project
*
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
- * (at your option)
any later version.
*
+ * (at your option)
version 3.
*
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
@@
-19,10
+19,11
@@
***************************************************************************/
#include "ctcphandler.h"
***************************************************************************/
#include "ctcphandler.h"
+#include "global.h"
#include "util.h"
#include "message.h"
#include "util.h"
#include "message.h"
-CtcpHandler::CtcpHandler(
Server
*parent)
+CtcpHandler::CtcpHandler(
NetworkConnection
*parent)
: BasicHandler(parent) {
QString MQUOTE = QString('\020');
: BasicHandler(parent) {
QString MQUOTE = QString('\020');
@@
-48,7
+49,7
@@
QString CtcpHandler::dequote(QString message) {
if(i+1 < message.size()) {
for(ctcpquote = ctcpMDequoteHash.begin(); ctcpquote != ctcpMDequoteHash.end(); ++ctcpquote) {
if(message.mid(i,2) == ctcpquote.key()) {
if(i+1 < message.size()) {
for(ctcpquote = ctcpMDequoteHash.begin(); ctcpquote != ctcpMDequoteHash.end(); ++ctcpquote) {
if(message.mid(i,2) == ctcpquote.key()) {
-
dequotedMessage +
= ctcpquote.value();
+
messagepart
= ctcpquote.value();
i++;
break;
}
i++;
break;
}
@@
-81,16
+82,21
@@
QString CtcpHandler::XdelimDequote(QString message) {
return dequotedMessage;
}
return dequotedMessage;
}
-QStringList CtcpHandler::parse(CtcpType ctcptype, QString prefix, QString target, QString message) {
- QStringList messages;
+void CtcpHandler::parse(Message::Type messageType, QString prefix, QString target, QString message) {
QString ctcp;
//lowlevel message dequote
QString dequotedMessage = dequote(message);
QString ctcp;
//lowlevel message dequote
QString dequotedMessage = dequote(message);
-
+
+ CtcpType ctcptype = (messageType == Message::Notice)
+ ? CtcpReply
+ : CtcpQuery;
+
// extract tagged / extended data
while(dequotedMessage.contains(XDELIM)) {
// extract tagged / extended data
while(dequotedMessage.contains(XDELIM)) {
- messages << dequotedMessage.section(XDELIM,0,0);
+ if(dequotedMessage.indexOf(XDELIM) > 0)
+ emit displayMsg(messageType, target, dequotedMessage.section(XDELIM,0,0), prefix);
+ // messages << dequotedMessage.section(XDELIM,0,0), prefix);
ctcp = XdelimDequote(dequotedMessage.section(XDELIM,1,1));
dequotedMessage = dequotedMessage.section(XDELIM,2,2);
ctcp = XdelimDequote(dequotedMessage.section(XDELIM,1,1));
dequotedMessage = dequotedMessage.section(XDELIM,2,2);
@@
-100,10
+106,10
@@
QStringList CtcpHandler::parse(CtcpType ctcptype, QString prefix, QString target
handle(ctcpcmd, Q_ARG(CtcpType, ctcptype), Q_ARG(QString, prefix), Q_ARG(QString, target), Q_ARG(QString, ctcpparam));
}
handle(ctcpcmd, Q_ARG(CtcpType, ctcptype), Q_ARG(QString, prefix), Q_ARG(QString, target), Q_ARG(QString, ctcpparam));
}
- if(!dequotedMessage.isEmpty()) {
- messages << dequotedMessage;
- }
- return messages;
+
+ if(!dequotedMessage.isEmpty())
+ emit displayMsg(messageType, target, dequotedMessage, prefix);
+
}
QString CtcpHandler::pack(QString ctcpTag, QString message) {
}
QString CtcpHandler::pack(QString ctcpTag, QString message) {
@@
-126,29
+132,40
@@
void CtcpHandler::reply(QString bufname, QString ctcpTag, QString message) {
// CTCP HANDLER
//******************************/
void CtcpHandler::handleAction(CtcpType ctcptype, QString prefix, QString target, QString param) {
// CTCP HANDLER
//******************************/
void CtcpHandler::handleAction(CtcpType ctcptype, QString prefix, QString target, QString param) {
+ Q_UNUSED(ctcptype)
emit displayMsg(Message::Action, target, param, prefix);
}
void CtcpHandler::handlePing(CtcpType ctcptype, QString prefix, QString target, QString param) {
emit displayMsg(Message::Action, target, param, prefix);
}
void CtcpHandler::handlePing(CtcpType ctcptype, QString prefix, QString target, QString param) {
+ Q_UNUSED(target)
if(ctcptype == CtcpQuery) {
reply(nickFromMask(prefix), "PING", param);
emit displayMsg(Message::Server, "", tr("Received CTCP PING request from %1").arg(prefix));
} else {
// display ping answer
if(ctcptype == CtcpQuery) {
reply(nickFromMask(prefix), "PING", param);
emit displayMsg(Message::Server, "", tr("Received CTCP PING request from %1").arg(prefix));
} else {
// display ping answer
+ uint now = QDateTime::currentDateTime().toTime_t();
+ uint then = QDateTime().fromTime_t(param.toInt()).toTime_t();
+ emit displayMsg(Message::Server, "", tr("Received CTCP PING answer from %1 with %2 seconds round trip time").arg(prefix).arg(now-then));
}
}
void CtcpHandler::handleVersion(CtcpType ctcptype, QString prefix, QString target, QString param) {
}
}
void CtcpHandler::handleVersion(CtcpType ctcptype, QString prefix, QString target, QString param) {
+ Q_UNUSED(target)
if(ctcptype == CtcpQuery) {
// FIXME use real Info about quassel :)
if(ctcptype == CtcpQuery) {
// FIXME use real Info about quassel :)
- reply(nickFromMask(prefix), "VERSION", QString("Quassel IRC (Pre-Release) - http://www.quassel-irc.org"));
+ reply(nickFromMask(prefix), "VERSION", QString("Quassel IRC (v%1 build >= %2) -- http://www.quassel-irc.org")
+ .arg(Global::quasselVersion).arg(Global::quasselBuild));
emit displayMsg(Message::Server, "", tr("Received CTCP VERSION request by %1").arg(prefix));
} else {
emit displayMsg(Message::Server, "", tr("Received CTCP VERSION request by %1").arg(prefix));
} else {
- // TODO display Version answer
+ // display Version answer
+ emit displayMsg(Message::Server, "", tr("Received CTCP VERSION answer from %1: %2").arg(prefix).arg(param));
}
}
void CtcpHandler::defaultHandler(QString cmd, CtcpType ctcptype, QString prefix, QString target, QString param) {
}
}
void CtcpHandler::defaultHandler(QString cmd, CtcpType ctcptype, QString prefix, QString target, QString param) {
+ Q_UNUSED(ctcptype);
+ Q_UNUSED(target);
+ Q_UNUSED(param);
emit displayMsg(Message::Error, "", tr("Received unknown CTCP %1 by %2").arg(cmd).arg(prefix));
}
emit displayMsg(Message::Error, "", tr("Received unknown CTCP %1 by %2").arg(cmd).arg(prefix));
}