Show invite menu in wlm chat window immediately
[kdenetwork.git] / kopete / libkopete / kopetesimplemessagehandler.cpp
blob4fe9254dc8a26273c4e6ed64838d1da5ef79ec75
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 <qpointer.h>
22 namespace Kopete
25 //BEGIN SimpleMessageHandlerFactory
27 class SimpleMessageHandlerFactory::Private
29 public:
30 Message::MessageDirection direction;
31 int position;
32 QPointer<QObject> target;
33 const char *slot;
36 SimpleMessageHandlerFactory::SimpleMessageHandlerFactory( Message::MessageDirection direction,
37 int position, QObject *target, const char *slot )
38 : d( new Private )
40 d->direction = direction;
41 d->position = position;
42 d->target = target;
43 d->slot = slot;
46 SimpleMessageHandlerFactory::~SimpleMessageHandlerFactory()
48 delete d;
51 MessageHandler *SimpleMessageHandlerFactory::create( ChatSession *manager, Message::MessageDirection direction )
53 Q_UNUSED( manager )
54 if ( direction != d->direction )
55 return 0;
56 MessageHandler *handler = new SimpleMessageHandler;
57 QObject::connect( handler, SIGNAL( handle( Kopete::Message & ) ), d->target, d->slot );
58 return handler;
61 int SimpleMessageHandlerFactory::filterPosition( ChatSession *manager, Message::MessageDirection direction )
63 Q_UNUSED( manager )
64 if ( direction != d->direction )
65 return StageDoNotCreate;
66 return d->position;
69 //END SimpleMessageHandlerFactory
71 //BEGIN SimpleMessageHandler
73 class SimpleMessageHandler::Private
77 SimpleMessageHandler::SimpleMessageHandler()
78 : d(0)
82 SimpleMessageHandler::~SimpleMessageHandler()
84 delete d;
87 void SimpleMessageHandler::handleMessage( MessageEvent *event )
89 Message message = event->message();
90 emit handle( message );
91 event->setMessage( message );
92 MessageHandler::handleMessage( event );
95 //END SimpleMessageHandler
99 #include "kopetesimplemessagehandler.moc"
101 // vim: set noet ts=4 sts=4 sw=4: