24 #include "ircrequestparser.h"    25 #include "irc/ircadapterbase.h"    26 #include "irc/ircclient.h"    27 #include "irc/ircctcpparser.h"    28 #include "irc/ircglobal.h"    29 #include "irc/ircmessageclass.h"    30 #include "irc/ircnetworkadapter.h"    31 #include "irc/ircuserinfo.h"    32 #include <QStringList>    34 DClass<IRCRequestParser>
    50 IRCRequestParser::~IRCRequestParser()
    56         return d->adapter->network();
    59 const QString &IRCRequestParser::output()
 const    66         d->adapter = pAdapter;
    71         input = input.trimmed();
    75                 return ErrorMessageEmpty;
    80                 return ErrorInputNotPrependedWithSlash;
    86                 return ErrorMessageEmpty;
    89         QStringList inputSplit = input.split(
" ", QString::SkipEmptyParts);
    90         d->message = inputSplit.takeFirst().toUpper();
    91         d->tokens = inputSplit;
    93         IRCRequestParser::IRCRequestParseResult result = buildOutput();
    96                 if (isOutputTooLong())
    98                         return ErrorMessageTooLong;
   105 IRCRequestParser::IRCRequestParseResult IRCRequestParser::buildOutput()
   107         if (d->message == 
"QUIT")
   109                 d->output = QString(
"%1 :%2").arg(d->message, d->tokens.join(
" "));
   112         else if (d->message == 
"AWAY")
   114                 d->output = QString(
"%1 :%2").arg(d->message, d->tokens.join(
" "));
   116         else if (d->message == 
"PART")
   118                 if (d->tokens.isEmpty())
   120                         return ErrorInputInsufficientParameters;
   123                 QString channel = d->tokens.takeFirst();
   124                 QString farewellMessage = d->tokens.join(
" ");
   125                 d->output = QString(
"%1 %2 :%3").arg(d->message, channel, farewellMessage);
   127         else if (d->message == 
"KICK")
   129                 if (d->tokens.length() < 2)
   131                         return ErrorInputInsufficientParameters;
   134                 QString channel = d->tokens.takeFirst();
   135                 QString user = d->tokens.takeFirst();
   136                 QString reason = d->tokens.join(
" ");
   137                 d->output = QString(
"%1 %2 %3 :%4").arg(d->message, channel, user, reason);
   139         else if (d->message == 
"PRIVMSG" || d->message == 
"NOTICE")
   142                 if (d->tokens.length() < 2)
   144                         return ErrorInputInsufficientParameters;
   147                 QString recipient = d->tokens.takeFirst();
   148                 QString content = d->tokens.join(
" ");
   149                 d->output = QString(
"%1 %2 :%3").arg(d->message, recipient, content);
   150                 if (isOutputTooLong())
   155                         return ErrorMessageTooLong;
   157                 if (d->message == 
"PRIVMSG")
   165                                         case IRCCtcpParser::PrintAsNormalMessage:
   166                                                 network()->printMsgLiteral(recipient, ctcp.printable(), IRCMessageClass::Ctcp);
   168                                         case IRCCtcpParser::DisplayInServerTab:
   169                                                 network()->printWithClass(ctcp.printable(), QString(), IRCMessageClass::Ctcp);
   171                                         case IRCCtcpParser::DisplayThroughGlobalMessage:
   172                                                 network()->printToCurrentChatBox(ctcp.printable(), IRCMessageClass::Ctcp);
   174                                         case IRCCtcpParser::DontShow:
   184         else if (d->message == 
"MSG")
   188                 parse(d->adapter, QString(
"/PRIVMSG %1").arg(d->tokens.join(
" ")));
   190         else if (d->message == 
"QUERY")
   192                 if (!d->tokens.isEmpty())
   194                         QString recipient = d->tokens.takeFirst();
   195                         if (!IRCGlobal::isChannelName(recipient))
   197                                 IRCUserInfo userInfo(recipient, d->adapter->network());
   198                                 emit 
query(userInfo.cleanNickname());
   202         else if (d->message == 
"ME")
   204                 QString recipient = d->adapter->recipient();
   205                 if (recipient.isEmpty())
   207                         return ErrorChatWindowOnly;
   209                 QString content = d->tokens.join(
" ");
   210                 parse(d->adapter, QString(
"/PRIVMSG %1 %2ACTION %3%2").arg(recipient, QChar(0x1), content));
   214                 d->output = QString(
"%1 %2").arg(d->message, d->tokens.join(
" "));
   220 bool IRCRequestParser::isOutputTooLong()
 const   222         return d->output.toUtf8().length() > IRCClient::MAX_MESSAGE_LENGTH;
 Interprets communication between the client and the IRC server. 
 
Parses request and interprets them in a way that emulates mIRC (or any even slightly sane IRC client ...
 
Provides an unified communication interface between a client and IRC network entities. 
 
void query(const QString &who)
Emitted when "/query" alias is used. 
 
IRCRequestParseResult parse(IRCAdapterBase *pAdapter, QString input)
Parses input string and returns it through output string. Additional information is passed through re...
 
A question is being asked through PRIVMSG. 
 
void echoPrivmsg(const QString &recipient, const QString &content)
Echoes back all PRIVMSG commands. 
 
Holds information flags about given nickname.