2 kopetesimplemessagehandler.h - Kopete Message Filtering - simple interface
4 Copyright (c) 2004 by Richard Smith <kde@metafoo.co.uk>
5 Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
7 *************************************************************************
9 * This library is free software; you can redistribute it and/or *
10 * modify it under the terms of the GNU Lesser General Public *
11 * License as published by the Free Software Foundation; either *
12 * version 2 of the License, or (at your option) any later version. *
14 *************************************************************************
17 #ifndef KOPETESIMPLEMESSAGEHANDLER_H
18 #define KOPETESIMPLEMESSAGEHANDLER_H
20 #include "kopete_export.h"
21 #include "kopetemessagehandler.h"
27 * @brief A MessageHandlerFactory that creates synchronous MessageHandlers that just call a slot
29 * A concrete MessageHandlerFactory. This class is intended to make writing MessageHandlers simpler;
30 * all that is required is to implement a message processing function and place an instance of this
31 * class in your Plugin-derived class.
33 * Whenever a message passes through a handler created by this factory, the slot passed to the
34 * constructor will be called. The slot should take a single argument of type (non-@p const)
37 class KOPETE_EXPORT SimpleMessageHandlerFactory
: public MessageHandlerFactory
41 * @param direction The direction this factory should create message handlers for
42 * @param position Where in the chain the handler should be installed
43 * @param target The object to call back to when handling a message
44 * @param slot The slot on @p target to call when handling a message
45 * @see Kopete::MessageHandlerFactory::filterPosition
47 SimpleMessageHandlerFactory( Message::MessageDirection direction
, int position
,
48 QObject
*target
, const char *slot
);
49 ~SimpleMessageHandlerFactory();
52 * Creates and returns a SimpleMessageHandler object.
54 MessageHandler
*create( ChatSession
*manager
, Message::MessageDirection direction
);
56 * Returns the filter position passed to the constructor if @p direction matches the
57 * direction passed to the constructor, otherwise returns @c StageDoNotCreate.
59 int filterPosition( ChatSession
*manager
, Message::MessageDirection direction
);
67 * @internal This class is used to implement SimpleMessageHandlerFactory.
69 class SimpleMessageHandler
: public MessageHandler
73 SimpleMessageHandler();
74 ~SimpleMessageHandler();
76 void handleMessage( MessageEvent
*event
);
79 void handle( Kopete::Message
&message
);
90 // vim: set noet ts=4 sts=4 sw=4: