X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Feventmanager.h;h=eb31921284cd93d548ebe299d493561dced8de0a;hb=6f38b6fdeb73e726c24b26a97b98c9cfe0fc8a0e;hp=d4f49c75b573154f7e5594b291762eb6cbfd752f;hpb=68eca2c9f0ae5acbda19a6965a2630bd4649ef24;p=quassel.git diff --git a/src/common/eventmanager.h b/src/common/eventmanager.h index d4f49c75..eb319212 100644 --- a/src/common/eventmanager.h +++ b/src/common/eventmanager.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2010 by the Quassel Project * + * Copyright (C) 2005-2012 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -23,7 +23,10 @@ #include +#include "types.h" + class Event; +class Network; class EventManager : public QObject { Q_OBJECT @@ -46,6 +49,7 @@ public: }; enum EventFlag { + Self = 0x01, ///< Self-generated (user input) event Fake = 0x08, ///< Ignore this in CoreSessionEventProcessor Netsplit = 0x10, ///< Netsplit join/part, ignore on display Backlog = 0x20, @@ -104,14 +108,19 @@ public: IrcEventNumericMask = 0x00000fff, /* for checking if an event is numeric */ MessageEvent = 0x00040000, ///< Stringified event suitable for converting to Message + + CtcpEvent = 0x00050000, + CtcpEventFlush }; EventManager(QObject *parent = 0); - virtual ~EventManager(); - EventType eventTypeByName(const QString &name) const; - EventType eventGroupByName(const QString &name) const; - QString enumName(EventType type) const; + static EventType eventTypeByName(const QString &name); + static EventType eventGroupByName(const QString &name); + static QString enumName(EventType type); + static QString enumName(int type); // for sanity tests + + Event *createEvent(const QVariantMap &map); public slots: void registerObject(QObject *object, Priority priority = NormalPriority, @@ -128,12 +137,12 @@ public slots: //! Send an event to the registered handlers /** The EventManager takes ownership of the event and will delete it once it's processed. - NOTE: This method is not threadsafe! @param event The event to be dispatched */ - void sendEvent(Event *event); + void postEvent(Event *event); protected: + virtual Network *networkById(NetworkId id) const = 0; virtual void customEvent(QEvent *event); private: @@ -158,23 +167,22 @@ private: inline HandlerHash ®isteredFilters() { return _registeredFilters; } //! Add handlers to an existing sorted (by priority) handler list - void insertHandlers(const QList &newHandlers, QList &existing); + void insertHandlers(const QList &newHandlers, QList &existing, bool checkDupes = false); //! Add filters to an existing filter hash void insertFilters(const QList &newFilters, QHash &existing); int findEventType(const QString &methodSignature, const QString &methodPrefix) const; - void processEvents(); + void processEvent(Event *event); void dispatchEvent(Event *event); //! @return the EventType enum - QMetaEnum eventEnum() const; + static QMetaEnum eventEnum(); HandlerHash _registeredHandlers; HandlerHash _registeredFilters; - mutable QMetaEnum _enum; - QList _eventQueue; + static QMetaEnum _enum; }; Q_DECLARE_OPERATORS_FOR_FLAGS(EventManager::EventFlags);