c31842eeefbfbe836cfcb6dec261542858ee66c5
[quassel.git] / src / core / eventstringifier.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2010 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 EVENTSTRINGIFIER_H
22 #define EVENTSTRINGIFIER_H
23
24 #include <QObject>
25
26 #include "ircevent.h"
27 #include "message.h"
28
29 class CoreSession;
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 QObject {
36   Q_OBJECT
37
38 public:
39   explicit EventStringifier(CoreSession *parent);
40
41   inline CoreSession *coreSession() const { return _coreSession; }
42
43   MessageEvent *createMessageEvent(NetworkEvent *event,
44                                    Message::Type msgType,
45                                    const QString &msg,
46                                    const QString &sender = QString(),
47                                    const QString &target = QString(),
48                                    Message::Flags msgFlags = Message::None);
49
50   //! Handle generic numeric events
51   Q_INVOKABLE void processIrcEventNumeric(IrcEventNumeric *event);
52
53   Q_INVOKABLE void processIrcEventInvite(IrcEvent *event);
54   Q_INVOKABLE void earlyProcessIrcEventKick(IrcEvent *event);
55   Q_INVOKABLE void earlyProcessIrcEventNick(IrcEvent *event);
56   Q_INVOKABLE void earlyProcessIrcEventPart(IrcEvent *event);
57   Q_INVOKABLE void processIrcEventPong(IrcEvent *event);
58   Q_INVOKABLE void processIrcEventTopic(IrcEvent *event);
59
60   Q_INVOKABLE void processIrcEvent005(IrcEvent *event);      // RPL_ISUPPORT
61   Q_INVOKABLE void processIrcEvent301(IrcEvent *event);      // RPL_AWAY
62   Q_INVOKABLE void processIrcEvent305(IrcEvent *event);      // RPL_UNAWAY
63   Q_INVOKABLE void processIrcEvent306(IrcEvent *event);      // RPL_NOWAWAY
64   Q_INVOKABLE void processIrcEvent311(IrcEvent *event);      // RPL_WHOISUSER
65   Q_INVOKABLE void processIrcEvent312(IrcEvent *event);      // RPL_WHOISSERVER
66   Q_INVOKABLE void processIrcEvent314(IrcEvent *event);      // RPL_WHOWASUSER
67   Q_INVOKABLE void processIrcEvent315(IrcEvent *event);      // RPL_ENDOFWHO
68   Q_INVOKABLE void processIrcEvent317(IrcEvent *event);      // RPL_WHOISIDLE
69   Q_INVOKABLE void processIrcEvent318(IrcEvent *event);      // RPL_ENDOFWHOIS
70   Q_INVOKABLE void processIrcEvent319(IrcEvent *event);      // RPL_WHOISCHANNELS
71   Q_INVOKABLE void processIrcEvent322(IrcEvent *event);      // RPL_LIST
72   Q_INVOKABLE void processIrcEvent323(IrcEvent *event);      // RPL_LISTEND
73   Q_INVOKABLE void processIrcEvent328(IrcEvent *event);      // RPL_??? (channel creation time)
74   Q_INVOKABLE void processIrcEvent329(IrcEvent *event);      // RPL_??? (channel homepage)
75   Q_INVOKABLE void processIrcEvent330(IrcEvent *event);      // RPL_WHOISACCOUNT (quakenet/snircd/undernet)
76   Q_INVOKABLE void processIrcEvent331(IrcEvent *event);      // RPL_NOTOPIC
77   Q_INVOKABLE void processIrcEvent332(IrcEvent *event);      // RPL_TOPIC
78   Q_INVOKABLE void processIrcEvent333(IrcEvent *event);      // RPL_??? (topic set by)
79   Q_INVOKABLE void processIrcEvent341(IrcEvent *event);      // RPL_INVITING
80   Q_INVOKABLE void processIrcEvent352(IrcEvent *event);      // RPL_WHOREPLY
81   Q_INVOKABLE void processIrcEvent369(IrcEvent *event);      // RPL_ENDOFWHOWAS
82
83
84   // Q_INVOKABLE void processIrcEvent(IrcEvent *event);
85
86 public slots:
87   //! Creates and sends a MessageEvent
88   void displayMsg(NetworkEvent *event,
89                   Message::Type msgType,
90                   const QString &msg,
91                   const QString &sender = QString(),
92                   const QString &target = QString(),
93                   Message::Flags msgFlags = Message::None);
94
95 private:
96   bool checkParamCount(IrcEvent *event, int minParams);
97   void sendMessageEvent(MessageEvent *event);
98
99   CoreSession *_coreSession;
100   bool _whois;
101
102 };
103
104 #endif