1 #include "ircctcpparser.h"
6 #include "irc/ircnetworkadapter.h"
13 IRCCtcpParser::CtcpEcho echo;
27 const QString &recipient, const QString &msg, MessageType msgType)
33 d->recipient = recipient;
37 IRCCtcpParser::~IRCCtcpParser()
41 IRCCtcpParser::CtcpEcho IRCCtcpParser::echo()
const
46 bool IRCCtcpParser::isCommand(
const QString &candidate)
48 return d->command.compare(candidate, Qt::CaseInsensitive) == 0;
51 bool IRCCtcpParser::isCtcp()
const
53 if (d->msg.length() <= 2)
57 return d->msg[0] == 0x1 && d->msg[d->msg.length() - 1] == 0x1;
60 bool IRCCtcpParser::parse()
67 d->printable = tr(
"CTCP %1: [%2] %3 %4").arg(typeToName(), d->sender, d->command, d->params.join(
" "));
68 if (isCommand(
"action"))
70 d->echo = PrintAsNormalMessage;
71 d->printable = tr(
"%1 %2").arg(d->sender, d->params.join(
" "));
77 d->echo = DisplayInServerTab;
78 if (isCommand(
"clientinfo"))
80 d->reply =
"CLIENTINFO ACTION VERSION TIME PING";
82 else if (isCommand(
"version"))
86 else if (isCommand(
"time"))
88 d->reply = QString(
"TIME %1").arg(QDateTime::currentDateTime().toString(
"yyyy-MM-dd hh:mm:ss"));
90 else if (isCommand(
"ping"))
92 d->reply = QString(
"PING %1").arg(d->params[0]);
95 else if (d->msgType ==
Reply)
97 d->echo = DisplayThroughGlobalMessage;
98 if (isCommand(
"ping"))
103 d->echo = DisplayInServerTab;
104 qint64 timestamp = d->params.takeFirst().toLongLong();
105 d->network->userPing(d->sender, timestamp);
110 qDebug() <<
"Unknown d->msgType in IRCCtcpParser";
116 const QString &IRCCtcpParser::printable()
const
121 const QString &IRCCtcpParser::reply()
const
126 void IRCCtcpParser::tokenizeMsg()
128 QString stripped = d->msg.mid(1, d->msg.length() - 2);
129 QStringList tokens = stripped.split(
" ");
130 d->command = tokens.takeFirst();
134 QString IRCCtcpParser::typeToName()
const
139 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().