23 #include "ircctcpparser.h" 25 #include "irc/ircnetworkadapter.h" 29 #include <QStringList> 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)
77 return d->msg[0].unicode() == 0x1 && d->msg[d->msg.length() - 1].unicode() == 0x1;
80 bool IRCCtcpParser::parse()
85 d->printable = tr(
"CTCP %1: [%2] %3 %4").arg(typeToName(), d->sender, d->command, d->params.join(
" "));
86 if (isCommand(
"action"))
88 d->echo = PrintAsNormalMessage;
89 d->printable = tr(
"%1 %2").arg(d->sender, d->params.join(
" "));
95 d->echo = DisplayInServerTab;
96 if (isCommand(
"clientinfo"))
97 d->reply =
"CLIENTINFO ACTION VERSION TIME PING";
98 else if (isCommand(
"version"))
100 else if (isCommand(
"time"))
101 d->reply = QString(
"TIME %1").arg(QDateTime::currentDateTime().toString(
"yyyy-MM-dd hh:mm:ss"));
102 else if (isCommand(
"ping"))
103 d->reply = QString(
"PING %1").arg(d->params[0]);
105 else if (d->msgType ==
Reply)
107 d->echo = DisplayThroughGlobalMessage;
108 if (isCommand(
"ping"))
113 d->echo = DisplayInServerTab;
114 qint64 timestamp = d->params.takeFirst().toLongLong();
115 d->network->userPing(d->sender, timestamp);
119 qDebug() <<
"Unknown d->msgType in IRCCtcpParser";
124 const QString &IRCCtcpParser::printable()
const 129 const QString &IRCCtcpParser::reply()
const 134 void IRCCtcpParser::tokenizeMsg()
136 QString stripped = d->msg.mid(1, d->msg.length() - 2);
137 QStringList tokens = stripped.split(
" ");
138 d->command = tokens.takeFirst();
142 QString IRCCtcpParser::typeToName()
const 147 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().