Fix includes
[quassel.git] / src / core / coresessioneventprocessor.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2012 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
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) version 3.                                           *
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                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef CORESESSIONEVENTPROCESSOR_H
22 #define CORESESSIONEVENTPROCESSOR_H
23
24 #include "basichandler.h"
25 #include "corenetwork.h"
26 #include "networkevent.h"
27
28 class CoreSession;
29 class CtcpEvent;
30 class IrcEvent;
31 class IrcEventNumeric;
32 class Netsplit;
33
34 class CoreSessionEventProcessor : public BasicHandler {
35   Q_OBJECT
36
37 public:
38   CoreSessionEventProcessor(CoreSession *session);
39
40   inline CoreSession *coreSession() const { return _coreSession; }
41
42   Q_INVOKABLE void processIrcEventNumeric(IrcEventNumeric *event);
43
44   Q_INVOKABLE void processIrcEventAuthenticate(IrcEvent *event);   // SASL auth
45   Q_INVOKABLE void processIrcEventCap(IrcEvent *event);            // CAP framework
46   Q_INVOKABLE void processIrcEventInvite(IrcEvent *event);
47   Q_INVOKABLE void processIrcEventJoin(IrcEvent *event);
48   Q_INVOKABLE void lateProcessIrcEventKick(IrcEvent *event);
49   Q_INVOKABLE void processIrcEventMode(IrcEvent *event);
50   Q_INVOKABLE void lateProcessIrcEventNick(IrcEvent *event);
51   Q_INVOKABLE void lateProcessIrcEventPart(IrcEvent *event);
52   Q_INVOKABLE void processIrcEventPing(IrcEvent *event);
53   Q_INVOKABLE void processIrcEventPong(IrcEvent *event);
54   Q_INVOKABLE void processIrcEventQuit(IrcEvent *event);
55   Q_INVOKABLE void lateProcessIrcEventQuit(IrcEvent *event);
56   Q_INVOKABLE void processIrcEventTopic(IrcEvent *event);
57
58   Q_INVOKABLE void processIrcEvent001(IrcEvent *event);            // RPL_WELCOME
59   Q_INVOKABLE void processIrcEvent005(IrcEvent *event);            // RPL_ISUPPORT
60   Q_INVOKABLE void processIrcEvent221(IrcEvent *event);            // RPL_UMODEIS
61   Q_INVOKABLE void processIrcEvent250(IrcEvent *event);            // RPL_STATSCONN
62   Q_INVOKABLE void processIrcEvent265(IrcEvent *event);            // RPL_LOCALUSERS
63   Q_INVOKABLE void processIrcEvent266(IrcEvent *event);            // RPL_GLOBALUSERS
64   Q_INVOKABLE void processIrcEvent301(IrcEvent *event);            // RPL_AWAY
65   Q_INVOKABLE void processIrcEvent305(IrcEvent *event);            // RPL_UNAWAY
66   Q_INVOKABLE void processIrcEvent306(IrcEvent *event);            // RPL_NOWAWAY
67   Q_INVOKABLE void processIrcEvent307(IrcEvent *event);            // RPL_WHOISSERVICE
68   Q_INVOKABLE void processIrcEvent310(IrcEvent *event);            // RPL_SUSERHOST
69   Q_INVOKABLE void processIrcEvent311(IrcEvent *event);            // RPL_WHOISUSER
70   Q_INVOKABLE void processIrcEvent312(IrcEvent *event);            // RPL_WHOISSERVER
71   Q_INVOKABLE void processIrcEvent313(IrcEvent *event);            // RPL_WHOISOPERATOR
72   Q_INVOKABLE void processIrcEvent315(IrcEvent *event);            // RPL_ENDOFWHO
73   Q_INVOKABLE void processIrcEvent317(IrcEvent *event);            // RPL_WHOISIDLE
74   Q_INVOKABLE void processIrcEvent322(IrcEvent *event);            // RPL_LIST
75   Q_INVOKABLE void processIrcEvent323(IrcEvent *event);            // RPL_LISTEND
76   Q_INVOKABLE void processIrcEvent324(IrcEvent *event);            // RPL_CHANNELMODEIS
77   Q_INVOKABLE void processIrcEvent331(IrcEvent *event);            // RPL_NOTOPIC
78   Q_INVOKABLE void processIrcEvent332(IrcEvent *event);            // RPL_TOPIC
79   Q_INVOKABLE void processIrcEvent352(IrcEvent *event);            // RPL_WHOREPLY
80   Q_INVOKABLE void processIrcEvent353(IrcEvent *event);            // RPL_NAMREPLY
81   Q_INVOKABLE void processIrcEvent432(IrcEventNumeric *event);     // ERR_ERRONEUSNICKNAME
82   Q_INVOKABLE void processIrcEvent433(IrcEventNumeric *event);     // ERR_NICKNAMEINUSE
83   Q_INVOKABLE void processIrcEvent437(IrcEventNumeric *event);     // ERR_UNAVAILRESOURCE
84
85   // Q_INVOKABLE void processIrcEvent(IrcEvent *event);
86
87   /* CTCP handlers */
88   Q_INVOKABLE void processCtcpEvent(CtcpEvent *event);
89
90   Q_INVOKABLE void handleCtcpAction(CtcpEvent *event);
91   Q_INVOKABLE void handleCtcpClientinfo(CtcpEvent *event);
92   Q_INVOKABLE void handleCtcpPing(CtcpEvent *event);
93   Q_INVOKABLE void handleCtcpTime(CtcpEvent *event);
94   Q_INVOKABLE void handleCtcpVersion(CtcpEvent *event);
95   Q_INVOKABLE void defaultHandler(const QString &ctcpCmd, CtcpEvent *event);
96
97 signals:
98   void newEvent(Event *event);
99
100 protected:
101   bool checkParamCount(IrcEvent *event, int minParams);
102   inline CoreNetwork *coreNetwork(NetworkEvent *e) const { return qobject_cast<CoreNetwork *>(e->network()); }
103   void tryNextNick(NetworkEvent *e, const QString &errnick, bool erroneous = false);
104
105 private slots:
106   //! Joins after a netsplit
107   /** This slot handles a bulk-join after a netsplit is over
108     * \param net     The network
109     * \param channel The channel the users joined
110     * \param users   The list of users that joind the channel
111     * \param modes   The list of modes the users get set
112     * \param quitMessage The message we received when the netsplit occured
113     */
114   void handleNetsplitJoin(Network *net, const QString &channel, const QStringList &users, const QStringList &modes, const QString &quitMessage);
115
116   //! Quits after a netsplit
117   /** This slot handles a bulk-quit after a netsplit occured
118     * \param net     The network
119     * \param channel The channel the users quitted
120     * \param users   The list of users that got split
121     * \param quitMessage The message we received when the netsplit occured
122     */
123   void handleNetsplitQuit(Network *net, const QString &channel, const QStringList &users, const QString &quitMessage);
124
125   //! Netsplit finished
126   /** This slot deletes the netsplit object that sent the finished() signal
127     */
128   void handleNetsplitFinished();
129
130   void handleEarlyNetsplitJoin(Network *net, const QString &channel, const QStringList &users, const QStringList &modes);
131
132   //! Destroy any existing netsplits
133   /** This slot deletes all netsplit objects
134     * Used to get rid of existing netsplits on network reconnect
135     * \param network The network we want to clear
136     */
137   void destroyNetsplits(NetworkId network);
138
139 private:
140   CoreSession *_coreSession;
141
142   // structure to organize netsplits
143   // key: quit message
144   // value: the corresponding netsplit object
145   QHash<Network *, QHash<QString, Netsplit*> > _netsplits;
146 };
147
148 #endif