summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircmessageparser.h
Unidiff
Diffstat (limited to 'noncore/net/opieirc/ircmessageparser.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircmessageparser.h95
1 files changed, 95 insertions, 0 deletions
diff --git a/noncore/net/opieirc/ircmessageparser.h b/noncore/net/opieirc/ircmessageparser.h
new file mode 100644
index 0000000..b45b8f0
--- a/dev/null
+++ b/noncore/net/opieirc/ircmessageparser.h
@@ -0,0 +1,95 @@
1/*
2 OpieIRC - An embedded IRC client
3 Copyright (C) 2002 Wenzel Jakob
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19*/
20
21#ifndef __IRCMESSAGEPARSER_H
22#define __IRCMESSAGEPARSER_H
23
24#include "ircsession.h"
25
26/* Macro to facilitate the parser table's creation */
27#define FUNC(__proc) &IRCMessageParser::__proc
28
29class IRCMessageParser;
30
31/* Typedef representing a parser function */
32typedef void (IRCMessageParser::*IRCMessageParseProc)(IRCMessage *);
33
34/* Struct representing a literal command handler */
35typedef struct IRCLiteralMessageParserStruct {
36 char *commandName;
37 IRCMessageParseProc proc;
38};
39
40/* Struct representing a ctcp command handler */
41typedef struct IRCCTCPMessageParserStruct {
42 char *commandName;
43 IRCMessageParseProc proc;
44};
45
46/* Struct representing a numerical command handler */
47typedef struct IRCNumericalMessageParserStruct {
48 unsigned short commandNumber;
49 IRCMessageParseProc proc;
50};
51
52class IRCMessageParser : public QObject {
53 Q_OBJECT
54public:
55 /* Create an IRCMessageParser object */
56 IRCMessageParser(IRCSession *session);
57 /* Parse a server message and take the appropriate actions */
58 void parse(IRCMessage *message);
59signals:
60 /* Used to send commands to the UI (such as displaying text etc) */
61 void outputReady(IRCOutput output);
62private:
63 /* Parser functions */
64 void nullFunc(IRCMessage *message);
65 void parseLiteralPing(IRCMessage *message);
66 void parseLiteralNotice(IRCMessage *message);
67 void parseLiteralJoin(IRCMessage *message);
68 void parseLiteralPrivMsg(IRCMessage *message);
69 void parseLiteralNick(IRCMessage *message);
70 void parseLiteralPart(IRCMessage *message);
71 void parseLiteralQuit(IRCMessage *message);
72 void parseLiteralError(IRCMessage *message);
73 void parseLiteralMode(IRCMessage *message);
74 void parseLiteralKick(IRCMessage *message);
75 void parseNumerical001(IRCMessage *message);
76 void parseNumerical002(IRCMessage *message);
77 void parseNumerical003(IRCMessage *message);
78 void parseNumerical004(IRCMessage *message);
79 void parseNumerical005(IRCMessage *message);
80 void parseNumericalStats(IRCMessage *message);
81 void parseNumericalNames(IRCMessage *message);
82 void parseNumericalEndOfNames(IRCMessage *message);
83 void parseNumericalNicknameInUse(IRCMessage *message);
84 void parseCTCPPing(IRCMessage *message);
85 void parseCTCPVersion(IRCMessage *message);
86 void parseCTCPAction(IRCMessage *message);
87protected:
88 IRCSession *m_session;
89 /* Parser tables */
90 static IRCLiteralMessageParserStruct literalParserProcTable[];
91 static IRCNumericalMessageParserStruct numericalParserProcTable[];
92 static IRCCTCPMessageParserStruct ctcpParserProcTable[];
93};
94
95#endif /* __IRCMESSAGEPARSER_H */