23 #include "ircctcpparser.h" 27 #include <QStringList> 28 #include "irc/ircnetworkadapter.h" 35 IRCCtcpParser::CtcpEcho echo;
49 const QString &recipient, const QString &msg, MessageType msgType)
55 d->recipient = recipient;
59 IRCCtcpParser::~IRCCtcpParser()
63 IRCCtcpParser::CtcpEcho IRCCtcpParser::echo()
const 68 bool IRCCtcpParser::isCommand(
const QString &candidate)
70 return d->command.compare(candidate, Qt::CaseInsensitive) == 0;
73 bool IRCCtcpParser::isCtcp()
const 75 if (d->msg.length() <= 2)
79 return d->msg[0].unicode() == 0x1 && d->msg[d->msg.length() - 1].unicode() == 0x1;
82 bool IRCCtcpParser::parse()
89 d->printable = tr(
"CTCP %1: [%2] %3 %4").arg(typeToName(), d->sender, d->command, d->params.join(
" "));
90 if (isCommand(
"action"))
92 d->echo = PrintAsNormalMessage;
93 d->printable = tr(
"%1 %2").arg(d->sender, d->params.join(
" "));
99 d->echo = DisplayInServerTab;
100 if (isCommand(
"clientinfo"))
102 d->reply =
"CLIENTINFO ACTION VERSION TIME PING";
104 else if (isCommand(
"version"))
108 else if (isCommand(
"time"))
110 d->reply = QString(
"TIME %1").arg(QDateTime::currentDateTime().toString(
"yyyy-MM-dd hh:mm:ss"));
112 else if (isCommand(
"ping"))
114 d->reply = QString(
"PING %1").arg(d->params[0]);
117 else if (d->msgType ==
Reply)
119 d->echo = DisplayThroughGlobalMessage;
120 if (isCommand(
"ping"))
125 d->echo = DisplayInServerTab;
126 qint64 timestamp = d->params.takeFirst().toLongLong();
127 d->network->userPing(d->sender, timestamp);
132 qDebug() <<
"Unknown d->msgType in IRCCtcpParser";
138 const QString &IRCCtcpParser::printable()
const 143 const QString &IRCCtcpParser::reply()
const 148 void IRCCtcpParser::tokenizeMsg()
150 QString stripped = d->msg.mid(1, d->msg.length() - 2);
151 QStringList tokens = stripped.split(
" ");
152 d->command = tokens.takeFirst();
156 QString IRCCtcpParser::typeToName()
const 161 return tr(
"REQUEST");
Interprets communication between the client and the IRC server.
An answer is being sent through NOTICE.
A question is being asked through PRIVMSG.
static QString fullVersionInfoWithOs()
Combines program's name, versionRevision() and operatingSystem().