~ubuntu-branches/ubuntu/hoary/kvirc/hoary

« back to all changes in this revision

Viewing changes to src/kvirc/kvi_sparser.h

  • Committer: Bazaar Package Importer
  • Author(s): Robin Verduijn
  • Date: 2004-12-14 15:32:19 UTC
  • mfrom: (0.2.1 upstream) (1.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20041214153219-fdink3gyp2s20b6g
Tags: 2:2.1.3.1-2
* Change Recommends on xmms to a Suggests.
* Rebuild against KDE 3.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef _KVI_SPARSER_H_INCLUDED_
2
 
#define _KVI_SPARSER_H_INCLUDED_
3
 
 
4
 
//
5
 
//   File : kvi_sparser.h (/usr/build/NEW_kvirc/kvirc/src/kvirc/kvi_sparser.h)
6
 
//   Last major modification : Wed Feb 10 1999 19:13:55 by Szymon Stefanek
7
 
//
8
 
//   This file is part of the KVirc irc client distribution
9
 
//   Copyright (C) 1999-2000 Szymon Stefanek (stefanek@tin.it)
10
 
//
11
 
//   This program is FREE software. You can redistribute it and/or
12
 
//   modify it under the terms of the GNU General Public License
13
 
//   as published by the Free Software Foundation; either version 2
14
 
//   of the License, or (at your opinion) any later version.
15
 
//
16
 
//   This program is distributed in the HOPE that it will be USEFUL,
17
 
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
 
//   See the GNU General Public License for more details.
20
 
//
21
 
//   You should have received a copy of the GNU General Public License
22
 
//   along with this program. If not, write to the Free Software Foundation,
23
 
//   Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
 
//
25
 
 
26
 
#include <qobject.h>
27
 
#include <qlist.h>
28
 
 
29
 
#include "kvi_string.h"
30
 
 
31
 
 
32
 
class KviFrame;
33
 
class KviIrcSocket;
34
 
class KviConsole;
35
 
class KviStatusBar;
36
 
class KviIrcUser;
37
 
class KviChannel;
38
 
class KviWindow;
39
 
class KviUserParser;
40
 
 
41
 
// forward decl
42
 
typedef struct KviRawEventStruct KviRawEvent;
43
 
 
44
 
typedef struct KviIrcMessage
45
 
{
46
 
        KviStr szPrefix;
47
 
        KviStr szCommand;
48
 
        unsigned int    uCommand;
49
 
        KviStr szParams;
50
 
        bool   bHasBeenHandled; // Has been handled by a script
51
 
};
52
 
 
53
 
class KviServerParser;
54
 
 
55
 
typedef void (KviServerParser::*ircCmdParseProc) (KviIrcMessage *);
56
 
 
57
 
typedef struct KviIrcCommandEntry
58
 
{
59
 
        const char *     cmdName;
60
 
        int              cmdLen;
61
 
        ircCmdParseProc  cmdProc;
62
 
};
63
 
 
64
 
typedef void (KviServerParser::*ctcpRequestParseProc) (KviIrcUser &,const char *,const char *);
65
 
 
66
 
typedef struct KviCtcpCommandEntry
67
 
{
68
 
        const char *          ctcpName;
69
 
        int                   ctcpLen;
70
 
        char                  bCausesFlood;
71
 
        ctcpRequestParseProc  ctcpProc;
72
 
        ctcpRequestParseProc  ctcpReplyProc;
73
 
};
74
 
 
75
 
class KviServerParser : public QObject
76
 
{
77
 
        friend class KviIrcSocket;
78
 
        friend class KviFrame;
79
 
        Q_OBJECT
80
 
protected:
81
 
        KviServerParser(KviFrame *pFrm);
82
 
        ~KviServerParser();
83
 
private:
84
 
        KviFrame                  *m_pFrm;
85
 
        KviIrcSocket              *m_pSocket;
86
 
        KviConsole                *m_pConsole;
87
 
        KviStatusBar              *m_pStatus;
88
 
        KviUserParser             *m_pUserParser;
89
 
        static KviIrcCommandEntry cmdTable[];
90
 
        static KviCtcpCommandEntry ctcpCmdTable[];
91
 
        int m_iCtcpTimerId;
92
 
        int m_iCtcpCount;
93
 
        int m_iQueryTimerId;
94
 
        int m_iQueryCount;
95
 
        KviStr                     m_szLastNetsplit;
96
 
        int                        m_iNetsplitTimerId;
97
 
protected:
98
 
        void setup(KviIrcSocket *pSock,KviConsole *pConsole,KviUserParser *pUParser);
99
 
 
100
 
        bool isMe(const KviIrcUser &user);
101
 
        bool isMe(const char *nick);
102
 
 
103
 
        const char * skipToTrailing(const char *str);
104
 
        const char * skipWord(const char *str);
105
 
        const char * skipToUsername(const char *str);
106
 
 
107
 
        void getDateTimeStringFromCharTimeT(KviStr &buffer,const char *time_t_string);
108
 
 
109
 
        void parseMessage(char *msg_buffer); //Called directly from KviIrcSocket
110
 
        bool triggerRawEvent(KviIrcMessage *msg,QList<KviRawEvent> * lp);
111
 
 
112
 
        void parseNumericMessage(KviIrcMessage *msg);
113
 
        void parseLiteralMessage(KviIrcMessage *msg);
114
 
 
115
 
        void parseNumeric000_199(KviIrcMessage *msg);
116
 
        void parseNumeric200_399(KviIrcMessage *msg);
117
 
        void parseNumeric400_999(KviIrcMessage *msg);
118
 
 
119
 
        void parseNumericTopic(KviIrcMessage *msg);
120
 
        void parseNumericCreationTime(KviIrcMessage *msg);
121
 
        void parseNumericEndOfNames(KviIrcMessage *msg);
122
 
        void parseNumericNamesReply(KviIrcMessage *msg);
123
 
        void parseNumericChannelMode(KviIrcMessage *msg);
124
 
        void parseNumericBanList(KviIrcMessage *msg);
125
 
        void parseNumericExceptionList(KviIrcMessage *msg);
126
 
        void parseNumericInviteList(KviIrcMessage *msg);
127
 
        void parseNumericWhoReply(KviIrcMessage *msg);
128
 
        void parseNumericUserhost(KviIrcMessage *msg);
129
 
        void parseNumericWhoisReply(KviIrcMessage *msg);
130
 
        void parseNumericWatchList(KviIrcMessage *msg);
131
 
        void parseNumericIsonReply(KviIrcMessage *msg);
132
 
        void parseNumericLinks(KviIrcMessage *msg);
133
 
        void parseNumericList(KviIrcMessage *msg);
134
 
        void parseNumericVersion(KviIrcMessage *msg);
135
 
        void parseNumericMyInfo(KviIrcMessage *msg);
136
 
 
137
 
        void parseNumericErrorUnknownModeChar(KviIrcMessage *msg);
138
 
        void parseNumericErrorUnknownCommand(KviIrcMessage *msg);
139
 
 
140
 
        void parseUnhandledNumeric(KviIrcMessage *msg);
141
 
        void parseUnhandledNumericError(KviIrcMessage *msg);
142
 
 
143
 
        void parseJoin(KviIrcMessage *msg);
144
 
        void parsePing(KviIrcMessage *msg);
145
 
        void parsePart(KviIrcMessage *msg);
146
 
        void parseKick(KviIrcMessage *msg);
147
 
        void parseQuit(KviIrcMessage *msg);
148
 
        void parseMode(KviIrcMessage *msg);
149
 
        void parsePrivmsg(KviIrcMessage *msg);
150
 
        void parseNick(KviIrcMessage *msg);
151
 
        void parseTopic(KviIrcMessage *msg);
152
 
        void parseNotice(KviIrcMessage *msg);
153
 
        void parseInvite(KviIrcMessage *msg);
154
 
        void parseLocops(KviIrcMessage *msg);
155
 
        void parseGlobops(KviIrcMessage *msg);
156
 
        void parseWallops(KviIrcMessage *msg);
157
 
        void parseError(KviIrcMessage *msg);
158
 
 
159
 
        void handleChanUserMode(KviIrcMessage *msg,KviChannel *chan,bool bAdd,char mode,const char *src_nick,
160
 
                        const char *src_mask,const char *dst_nick);
161
 
        bool callChanUserModeEvent(KviChannel *chan,int event,const char *src_nick,
162
 
                        const char *src_mask,const char *dst_nick,bool isme=false,char mode=0,bool bAdd=false,const char *param=0);
163
 
        void handleChanMode(KviIrcMessage *msg,KviChannel *chan,bool bAdd,char mode,const char *src_nick,
164
 
                        const char *src_mask,const char *param);
165
 
 
166
 
        void parseUnhandledLiteral(KviIrcMessage *msg);
167
 
 
168
 
        // kvi_sparser.ctcp.cpp
169
 
        void parseCTCPPrivmsg(KviIrcUser &source,const char *target,const char *data);
170
 
        void parseCTCPNotice(KviIrcUser &source,const char *target,const char *data);
171
 
 
172
 
        void replyCTCP(const char *to,const char *type,const char *msg);
173
 
 
174
 
        void handleCTCPPingRequest(KviIrcUser &source,const char *target,const char *data);
175
 
        void handleCTCPVersionRequest(KviIrcUser &source,const char *target,const char *data);
176
 
        void handleCTCPTimeRequest(KviIrcUser &source,const char *target,const char *data);
177
 
        void handleCTCPUserinfoRequest(KviIrcUser &source,const char *target,const char *data);
178
 
        void handleCTCPClientinfoRequest(KviIrcUser &source,const char *target,const char *data);
179
 
        void handleCTCPSourceRequest(KviIrcUser &source,const char *target,const char *data);
180
 
        void handleCTCPDccRequest(KviIrcUser &source,const char *target,const char *data);
181
 
        void handleCTCPFingerRequest(KviIrcUser &source,const char *target,const char *data);
182
 
        void handleCTCPActionRequest(KviIrcUser &source,const char *target,const char *data);
183
 
        void handleCTCPPageRequest(KviIrcUser &source,const char *target,const char *data);
184
 
//      void handleCTCPSoundRequest(KviIrcUser &source,const char *target,const char *data);
185
 
        void handleCTCPErrmsgRequest(KviIrcUser &source,const char *target,const char *data);
186
 
        void handleCTCPMultimediaRequest(KviIrcUser &source,const char *target,const char *data);
187
 
 
188
 
        void handleCTCPPingReply(KviIrcUser &source,const char *target,const char *data);
189
 
        void handleCTCPVersionReply(KviIrcUser &source,const char *target,const char *data);
190
 
        void handleCTCPTimeReply(KviIrcUser &source,const char *target,const char *data);
191
 
        void handleCTCPUserinfoReply(KviIrcUser &source,const char *target,const char *data);
192
 
        void handleCTCPClientinfoReply(KviIrcUser &source,const char *target,const char *data);
193
 
        void handleCTCPSourceReply(KviIrcUser &source,const char *target,const char *data);
194
 
        void handleCTCPDccReply(KviIrcUser &source,const char *target,const char *data);
195
 
        void handleCTCPFingerReply(KviIrcUser &source,const char *target,const char *data);
196
 
        void handleCTCPActionReply(KviIrcUser &source,const char *target,const char *data);
197
 
        void handleCTCPPageReply(KviIrcUser &source,const char *target,const char *data);
198
 
//      void handleCTCPSoundReply(KviIrcUser &source,const char *target,const char *data);
199
 
        void handleCTCPErrmsgReply(KviIrcUser &source,const char *target,const char *data);
200
 
        void handleCTCPMultimediaReply(KviIrcUser &source,const char *target,const char *data);
201
 
 
202
 
        bool doActionEvent(KviIrcUser &source,const char *target,KviWindow *pOut,char create_query='0',const char *data=NULL);
203
 
        bool doMultimediaEvent(KviIrcUser &source,const char *target,KviWindow *pOut,int create_query,const char *filename);
204
 
        bool doCTCPEvent(const char *ctcpName,KviIrcUser &source,const char *target,bool bIgnore,KviWindow *pOut,const char *parms=NULL);
205
 
        bool doCTCPReplyEvent(const char *ctcpName,KviIrcUser &source,const char *target,KviWindow *pOut,const char *data=NULL);
206
 
        bool doCTCPFloodEvent(const char *ctcpName,KviIrcUser &source,const char *target,KviWindow *pOut,const char *parms=NULL);
207
 
 
208
 
        bool showCTCPRequest(const char *ctcpName,KviIrcUser &source,const char *target,bool bIgnore);
209
 
        void showCTCPReply(const char *ctcpName,KviIrcUser &source,const char *target,const char *data);
210
 
 
211
 
protected:
212
 
        virtual void timerEvent(QTimerEvent *e);
213
 
};
214
 
 
215
 
#endif //!_KVI_SPARSER_H_INCLUDED_