1 /***************************************************************************
2 * Copyright (C) 2005-2010 by the Quassel Project *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
21 #ifndef EVENTMANAGER_H
22 #define EVENTMANAGER_H
29 class EventManager : public QObject {
35 enum RegistrationMode {
45 GenericEvent = 0x000000,
47 IrcServerEvent = 0x010000,
48 IrcServerLooking = 0x010001,
49 IrcServerConnecting = 0x010002,
50 IrcServerConnected = 0x010003,
51 IrcServerConnectionFailure = 0x010004,
52 IrcServerDisconnected = 0x010005,
53 IrcServerQuit = 0x010006,
55 IrcServerIncoming = 0x010007,
58 IrcEventCap = 0x020001,
59 IrcEventCapAuthenticate = 0x020002,
60 IrcEventInvite = 0x020003,
61 IrcEventJoin = 0x020004,
62 IrcEventKick = 0x020005,
63 IrcEventMode = 0x020006,
64 IrcEventNick = 0x020007,
65 IrcEventNotice = 0x020008,
66 IrcEventPart = 0x020009,
67 IrcEventPing = 0x02000a,
68 IrcEventPong = 0x02000b,
69 IrcEventPrivmsg = 0x02000c,
70 IrcEventQuit = 0x02000d,
71 IrcEventTopic = 0x02000e,
73 IrcEventNumeric = 0x021000 /* needs 1000 (0x03e8) consecutive free values! */
76 EventManager(QObject *parent = 0);
77 //virtual ~EventManager();
79 QStringList providesEnums();
82 void registerObject(QObject *object, RegistrationMode mode = Append, const QString &methodPrefix = "handle");
83 void registerEventHandler(EventType event, QObject *object, const char *slot, RegistrationMode mode = Append);
84 void registerEventHandler(QList<EventType> events, QObject *object, const char *slot, RegistrationMode mode = Append);
86 //void sendEvent(Event *event);
93 explicit Handler(QObject *obj = 0, int method = 0) {
99 typedef QHash<EventType, QList<Handler> > HandlerHash;
101 inline const HandlerHash ®isteredHandlers() const { return _registeredHandlers; }
102 inline HandlerHash ®isteredHandlers() { return _registeredHandlers; }
103 HandlerHash _registeredHandlers;