ircresponseparser.h
1 //------------------------------------------------------------------------------
2 // ircresponseparser.h
3 //------------------------------------------------------------------------------
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301, USA.
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2010 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef __IRCRESPONSEPARSER_H__
24 #define __IRCRESPONSEPARSER_H__
25 
26 #include "irc/entities/ircresponseparseresult.h"
27 #include "dptr.h"
28 
29 #include <QDateTime>
30 #include <QObject>
31 #include <QString>
32 
33 class IRCMessageClass;
34 class IRCNetworkAdapter;
35 
36 class IRCResponseParser : public QObject
37 {
38  Q_OBJECT
39 
40  public:
43 
54  IRCResponseParseResult parse(const QString& message);
55 
56  signals:
63  void helloClient(const QString& nickname);
64 
65  void kick(const QString& channel, const QString& byWhom, const QString& whoIsKicked, const QString& reason);
66  void kill(const QString& victim, const QString& comment);
67 
68  void iSupportReceived(const QString &line);
69 
73  void modeInfo(const QString& channel, const QString& whoSetThis, const QString& modeParams);
74  void namesListReceived(const QString& channel, const QStringList& names);
75  void namesListEndReceived(const QString& channel);
76  void nicknameInUse(const QString& nickname);
77  void noSuchNickname(const QString& nickname);
78  void parseError(const QString& error);
79 
90  void print(const QString& printWhat, const QString& printWhere);
94  void printWithClass(const QString& printWhat, const QString& printWhere, const IRCMessageClass& msgClass);
95  void printToNetworksCurrentChatBox(const QString &printWhat, const IRCMessageClass &msgClass);
96 
97  void privMsgReceived(const QString& recipient, const QString& sender, const QString& content);
102  void privMsgLiteralReceived(const QString& recipient, const QString& content, const IRCMessageClass& msgClass);
103  void sendPongMessage(const QString& sendWhere);
104  void userChangesNickname(const QString& oldNickname, const QString& newNickname);
105  void userIdleTime(const QString &nick, int secondsIdle);
106  void userJoinsChannel(const QString& channel, const QString& nickname, const QString& fullSignature);
107  void userNetworkJoinDateTime(const QString &nick, const QDateTime &timeOfJoin);
108  void userModeChanged(const QString& channel, const QString& nickname,
109  const QList<char> &flagsAdded, const QList<char> &flagsRemoved);
110  void userPartsChannel(const QString& channel, const QString& nickname, const QString& farewellMessage);
111  void userQuitsNetwork(const QString& nickname, const QString& farewellMessage);
112 
116  void whoIsUser(const QString& nickname, const QString& user, const QString& hostName, const QString& realName);
117 
118  private:
119  enum FlagModes
120  {
121  FlagModeAdd,
122  FlagModeRemove,
123  FlagModeError
124  };
125 
127 
128  bool isPrefixIgnored() const;
129  QString joinAndTrimColonIfNecessary(const QStringList& strList) const;
130 
135  FlagModes getFlagMode(char c);
136 
137  IRCResponseParseResult parseMessage();
138 
139  void parsePrivMsgOrNotice();
146  void parseUserModeMessage(const QString& channel, QString flagsString, QStringList& nicknames);
147 
148  QString& trimColonIfNecessary(QString& str) const;
149 };
150 
151 #endif
Interprets communication between the client and the IRC server.
void print(const QString &printWhat, const QString &printWhere)
Tells the network adapter to print a message.
void privMsgLiteralReceived(const QString &recipient, const QString &content, const IRCMessageClass &msgClass)
Create chat window if necessary and display message 'as is' without further string gluing...
void modeInfo(const QString &channel, const QString &whoSetThis, const QString &modeParams)
Carries info about MODE for display.
IRCResponseParseResult parse(const QString &message)
Parses the message received from the network.
void whoIsUser(const QString &nickname, const QString &user, const QString &hostName, const QString &realName)
Emitted with response 311 RPL_WHOISUSER.
void helloClient(const QString &nickname)
Emitted when user successfuly joins the network.
Result info generated by the IRCResponseParser.
void printWithClass(const QString &printWhat, const QString &printWhere, const IRCMessageClass &msgClass)
Same as print(), but allows to specify message class.