Indicate whether a key is set for the buffer.
[quassel.git] / src / core / eventstringifier.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2013 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  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20
21 #ifndef EVENTSTRINGIFIER_H
22 #define EVENTSTRINGIFIER_H
23
24 #include "basichandler.h"
25 #include "ircevent.h"
26 #include "message.h"
27
28 class CoreSession;
29 class CtcpEvent;
30 class MessageEvent;
31
32 //! Generates user-visible MessageEvents from incoming IrcEvents
33
34 /* replaces the string-generating parts of the old IrcServerHandler */
35 class EventStringifier : public BasicHandler
36 {
37     Q_OBJECT
38
39 public:
40     explicit EventStringifier(CoreSession *parent);
41
42     inline CoreSession *coreSession() const { return _coreSession; }
43
44     MessageEvent *createMessageEvent(NetworkEvent *event,
45         Message::Type msgType,
46         const QString &msg,
47         const QString &sender = QString(),
48         const QString &target = QString(),
49         Message::Flags msgFlags = Message::None);
50
51     // legacy handlers
52     Q_INVOKABLE void processNetworkSplitJoin(NetworkSplitEvent *event);
53     Q_INVOKABLE void processNetworkSplitQuit(NetworkSplitEvent *event);
54
55     //! Handle generic numeric events
56     Q_INVOKABLE void processIrcEventNumeric(IrcEventNumeric *event);
57
58     Q_INVOKABLE void processIrcEventInvite(IrcEvent *event);
59     Q_INVOKABLE void processIrcEventJoin(IrcEvent *event);
60     Q_INVOKABLE void processIrcEventKick(IrcEvent *event);
61     Q_INVOKABLE void processIrcEventMode(IrcEvent *event);
62     Q_INVOKABLE void processIrcEventNick(IrcEvent *event);
63     Q_INVOKABLE void processIrcEventPart(IrcEvent *event);
64     Q_INVOKABLE void processIrcEventPong(IrcEvent *event);
65     Q_INVOKABLE void processIrcEventQuit(IrcEvent *event);
66     Q_INVOKABLE void processIrcEventTopic(IrcEvent *event);
67     Q_INVOKABLE void processIrcEventWallops(IrcEvent *event);
68
69     Q_INVOKABLE void processIrcEvent005(IrcEvent *event);    // RPL_ISUPPORT
70     Q_INVOKABLE void processIrcEvent301(IrcEvent *event);    // RPL_AWAY
71     Q_INVOKABLE void processIrcEvent305(IrcEvent *event);    // RPL_UNAWAY
72     Q_INVOKABLE void processIrcEvent306(IrcEvent *event);    // RPL_NOWAWAY
73     Q_INVOKABLE void processIrcEvent311(IrcEvent *event);    // RPL_WHOISUSER
74     Q_INVOKABLE void processIrcEvent312(IrcEvent *event);    // RPL_WHOISSERVER
75     Q_INVOKABLE void processIrcEvent314(IrcEvent *event);    // RPL_WHOWASUSER
76     Q_INVOKABLE void processIrcEvent315(IrcEvent *event);    // RPL_ENDOFWHO
77     Q_INVOKABLE void processIrcEvent317(IrcEvent *event);    // RPL_WHOISIDLE
78     Q_INVOKABLE void processIrcEvent318(IrcEvent *event);    // RPL_ENDOFWHOIS
79     Q_INVOKABLE void processIrcEvent319(IrcEvent *event);    // RPL_WHOISCHANNELS
80     Q_INVOKABLE void processIrcEvent322(IrcEvent *event);    // RPL_LIST
81     Q_INVOKABLE void processIrcEvent323(IrcEvent *event);    // RPL_LISTEND
82     Q_INVOKABLE void processIrcEvent324(IrcEvent *event);    // RPL_CHANNELMODEIS
83     Q_INVOKABLE void processIrcEvent328(IrcEvent *event);    // RPL_??? (channel creation time)
84     Q_INVOKABLE void processIrcEvent329(IrcEvent *event);    // RPL_??? (channel homepage)
85     Q_INVOKABLE void processIrcEvent330(IrcEvent *event);    // RPL_WHOISACCOUNT (quakenet/snircd/undernet)
86     Q_INVOKABLE void processIrcEvent331(IrcEvent *event);    // RPL_NOTOPIC
87     Q_INVOKABLE void processIrcEvent332(IrcEvent *event);    // RPL_TOPIC
88     Q_INVOKABLE void processIrcEvent333(IrcEvent *event);    // RPL_??? (topic set by)
89     Q_INVOKABLE void processIrcEvent341(IrcEvent *event);    // RPL_INVITING
90     Q_INVOKABLE void processIrcEvent352(IrcEvent *event);    // RPL_WHOREPLY
91     Q_INVOKABLE void processIrcEvent369(IrcEvent *event);    // RPL_ENDOFWHOWAS
92     Q_INVOKABLE void processIrcEvent432(IrcEvent *event);    // ERR_ERRONEUSNICKNAME
93     Q_INVOKABLE void processIrcEvent433(IrcEvent *event);    // ERR_NICKNAMEINUSE
94     Q_INVOKABLE void processIrcEvent437(IrcEvent *event);    // ERR_UNAVAILRESOURCE
95
96     // Q_INVOKABLE void processIrcEvent(IrcEvent *event);
97
98     /* CTCP handlers */
99     Q_INVOKABLE void processCtcpEvent(CtcpEvent *event);
100
101     Q_INVOKABLE void handleCtcpAction(CtcpEvent *event);
102     Q_INVOKABLE void handleCtcpPing(CtcpEvent *event);
103     Q_INVOKABLE void defaultHandler(const QString &cmd, CtcpEvent *event);
104
105 public slots:
106     //! Creates and sends a MessageEvent
107     void displayMsg(NetworkEvent *event,
108         Message::Type msgType,
109         const QString &msg,
110         const QString &sender = QString(),
111         const QString &target = QString(),
112         Message::Flags msgFlags = Message::None);
113
114 signals:
115     void newMessageEvent(Event *event);
116
117 private:
118     bool checkParamCount(IrcEvent *event, int minParams);
119
120     CoreSession *_coreSession;
121     bool _whois;
122 };
123
124
125 #endif