Event backend porting
[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
58 public slots:
59   //! Creates and sends a MessageEvent
60   void displayMsg(NetworkEvent *event,
61                   Message::Type msgType,
62                   const QString &msg,
63                   const QString &sender = QString(),
64                   const QString &target = QString(),
65                   Message::Flags msgFlags = Message::None);
66 private:
67   void sendMessageEvent(MessageEvent *event);
68
69   CoreSession *_coreSession;
70   bool _whois;
71
72 };
73
74 #endif