2 kopetemessagefilter.cpp - Kopete Message Filtering
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 #include "kopetesimplemessagehandler.h"
18 #include "kopetemessageevent.h"
20 #include <kstaticdeleter.h>
27 //BEGIN SimpleMessageHandlerFactory
29 class SimpleMessageHandlerFactory::Private
32 Message::MessageDirection direction
;
34 QPointer
<QObject
> target
;
38 SimpleMessageHandlerFactory::SimpleMessageHandlerFactory( Message::MessageDirection direction
,
39 int position
, QObject
*target
, const char *slot
)
42 d
->direction
= direction
;
43 d
->position
= position
;
48 SimpleMessageHandlerFactory::~SimpleMessageHandlerFactory()
53 MessageHandler
*SimpleMessageHandlerFactory::create( ChatSession
*manager
, Message::MessageDirection direction
)
56 if ( direction
!= d
->direction
)
58 MessageHandler
*handler
= new SimpleMessageHandler
;
59 QObject::connect( handler
, SIGNAL( handle( Kopete::Message
& ) ), d
->target
, d
->slot
);
63 int SimpleMessageHandlerFactory::filterPosition( ChatSession
*manager
, Message::MessageDirection direction
)
66 if ( direction
!= d
->direction
)
67 return StageDoNotCreate
;
71 //END SimpleMessageHandlerFactory
73 //BEGIN SimpleMessageHandler
75 class SimpleMessageHandler::Private
79 SimpleMessageHandler::SimpleMessageHandler()
84 SimpleMessageHandler::~SimpleMessageHandler()
89 void SimpleMessageHandler::handleMessage( MessageEvent
*event
)
91 Message message
= event
->message();
92 emit
handle( message
);
93 event
->setMessage( message
);
94 MessageHandler::handleMessage( event
);
97 //END SimpleMessageHandler
101 #include "kopetesimplemessagehandler.moc"
103 // vim: set noet ts=4 sts=4 sw=4: