From bcb704366cb5e333a626c18c308c7e0448a8e69f Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kopete/libkopete/kopetesimplemessagehandler.h | 90 +++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 kopete/libkopete/kopetesimplemessagehandler.h (limited to 'kopete/libkopete/kopetesimplemessagehandler.h') diff --git a/kopete/libkopete/kopetesimplemessagehandler.h b/kopete/libkopete/kopetesimplemessagehandler.h new file mode 100644 index 00000000..af6de4ab --- /dev/null +++ b/kopete/libkopete/kopetesimplemessagehandler.h @@ -0,0 +1,90 @@ +/* + kopetesimplemessagehandler.h - Kopete Message Filtering - simple interface + + Copyright (c) 2004 by Richard Smith + Kopete (c) 2002-2004 by the Kopete developers + + ************************************************************************* + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + ************************************************************************* +*/ + +#ifndef KOPETESIMPLEMESSAGEHANDLER_H +#define KOPETESIMPLEMESSAGEHANDLER_H + +#include "kopete_export.h" +#include "kopetemessagehandler.h" + +namespace Kopete +{ + +/** + * @brief A MessageHandlerFactory that creates synchronous MessageHandlers that just call a slot + * + * A concrete MessageHandlerFactory. This class is intended to make writing MessageHandlers simpler; + * all that is required is to implement a message processing function and place an instance of this + * class in your Plugin-derived class. + * + * Whenever a message passes through a handler created by this factory, the slot passed to the + * constructor will be called. The slot should take a single argument of type (non-@p const) + * Message &. + */ +class KOPETE_EXPORT SimpleMessageHandlerFactory : public MessageHandlerFactory +{ +public: + /** + * @param direction The direction this factory should create message handlers for + * @param position Where in the chain the handler should be installed + * @param target The object to call back to when handling a message + * @param slot The slot on @p target to call when handling a message + * @see Kopete::MessageHandlerFactory::filterPosition + */ + SimpleMessageHandlerFactory( Message::MessageDirection direction, int position, + QObject *target, const char *slot ); + ~SimpleMessageHandlerFactory(); + + /** + * Creates and returns a SimpleMessageHandler object. + */ + MessageHandler *create( ChatSession *manager, Message::MessageDirection direction ); + /** + * Returns the filter position passed to the constructor if @p direction matches the + * direction passed to the constructor, otherwise returns @c StageDoNotCreate. + */ + int filterPosition( ChatSession *manager, Message::MessageDirection direction ); + +private: + class Private; + Private *d; +}; + +/** + * @internal This class is used to implement SimpleMessageHandlerFactory. + */ +class SimpleMessageHandler : public MessageHandler +{ + Q_OBJECT +public: + SimpleMessageHandler(); + ~SimpleMessageHandler(); + + void handleMessage( MessageEvent *event ); + +signals: + void handle( Kopete::Message &message ); + +private: + class Private; + Private *d; +}; + +} + +#endif + +// vim: set noet ts=4 sts=4 sw=4: -- cgit v1.2.1