Merge ICQ/AIM Presence stuff and clean it.
[kdenetwork.git] / kopete / libkopete / kopetesimplemessagehandler.cpp
blob227d7267524826e8ab59347b5688e89758fa4501
1 /*
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 *************************************************************************
8 * *
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. *
13 * *
14 *************************************************************************
17 #include "kopetesimplemessagehandler.h"
18 #include "kopetemessageevent.h"
20 #include <kstaticdeleter.h>
22 #include <qpointer.h>
24 namespace Kopete
27 //BEGIN SimpleMessageHandlerFactory
29 class SimpleMessageHandlerFactory::Private
31 public:
32 Message::MessageDirection direction;
33 int position;
34 QPointer<QObject> target;
35 const char *slot;
38 SimpleMessageHandlerFactory::SimpleMessageHandlerFactory( Message::MessageDirection direction,
39 int position, QObject *target, const char *slot )
40 : d( new Private )
42 d->direction = direction;
43 d->position = position;
44 d->target = target;
45 d->slot = slot;
48 SimpleMessageHandlerFactory::~SimpleMessageHandlerFactory()
50 delete d;
53 MessageHandler *SimpleMessageHandlerFactory::create( ChatSession *manager, Message::MessageDirection direction )
55 Q_UNUSED( manager )
56 if ( direction != d->direction )
57 return 0;
58 MessageHandler *handler = new SimpleMessageHandler;
59 QObject::connect( handler, SIGNAL( handle( Kopete::Message & ) ), d->target, d->slot );
60 return handler;
63 int SimpleMessageHandlerFactory::filterPosition( ChatSession *manager, Message::MessageDirection direction )
65 Q_UNUSED( manager )
66 if ( direction != d->direction )
67 return StageDoNotCreate;
68 return d->position;
71 //END SimpleMessageHandlerFactory
73 //BEGIN SimpleMessageHandler
75 class SimpleMessageHandler::Private
79 SimpleMessageHandler::SimpleMessageHandler()
80 : d(0)
84 SimpleMessageHandler::~SimpleMessageHandler()
86 delete d;
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: