• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kopete/libkopete

  • sources
  • kde-4.14
  • kdenetwork
  • kopete
  • libkopete
kopetesimplemessagehandler.cpp
Go to the documentation of this file.
1 /*
2  kopetemessagefilter.cpp - Kopete Message Filtering
3 
4  Copyright (c) 2004 by Richard Smith <kde@metafoo.co.uk>
5  Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
6 
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  *************************************************************************
15 */
16 
17 #include "kopetesimplemessagehandler.h"
18 #include "kopetemessageevent.h"
19 
20 #include <qpointer.h>
21 
22 namespace Kopete
23 {
24 
25 //BEGIN SimpleMessageHandlerFactory
26 
27 class SimpleMessageHandlerFactory::Private
28 {
29 public:
30  Message::MessageDirection direction;
31  int position;
32  QPointer<QObject> target;
33  const char *slot;
34 };
35 
36 SimpleMessageHandlerFactory::SimpleMessageHandlerFactory( Message::MessageDirection direction,
37  int position, QObject *target, const char *slot )
38  : d( new Private )
39 {
40  d->direction = direction;
41  d->position = position;
42  d->target = target;
43  d->slot = slot;
44 }
45 
46 SimpleMessageHandlerFactory::~SimpleMessageHandlerFactory()
47 {
48  delete d;
49 }
50 
51 MessageHandler *SimpleMessageHandlerFactory::create( ChatSession *manager, Message::MessageDirection direction )
52 {
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;
59 }
60 
61 int SimpleMessageHandlerFactory::filterPosition( ChatSession *manager, Message::MessageDirection direction )
62 {
63  Q_UNUSED( manager )
64  if ( direction != d->direction )
65  return StageDoNotCreate;
66  return d->position;
67 }
68 
69 //END SimpleMessageHandlerFactory
70 
71 //BEGIN SimpleMessageHandler
72 
73 class SimpleMessageHandler::Private
74 {
75 };
76 
77 SimpleMessageHandler::SimpleMessageHandler()
78  : d(0)
79 {
80 }
81 
82 SimpleMessageHandler::~SimpleMessageHandler()
83 {
84  delete d;
85 }
86 
87 void SimpleMessageHandler::handleMessage( MessageEvent *event )
88 {
89  Message message = event->message();
90  emit handle( message );
91  event->setMessage( message );
92  MessageHandler::handleMessage( event );
93 }
94 
95 //END SimpleMessageHandler
96 
97 }
98 
99 #include "kopetesimplemessagehandler.moc"
100 
101 // vim: set noet ts=4 sts=4 sw=4:
Kopete::MessageEvent
Definition: kopetemessageevent.h:41
QPointer< QObject >
Kopete::SimpleMessageHandlerFactory::filterPosition
int filterPosition(ChatSession *manager, Message::MessageDirection direction)
Returns the filter position passed to the constructor if direction matches the direction passed to th...
Definition: kopetesimplemessagehandler.cpp:61
Kopete::ChatSession
Definition: kopetechatsession.h:74
Kopete::SimpleMessageHandler::handle
void handle(Kopete::Message &message)
QObject
Kopete::Message::MessageDirection
MessageDirection
Direction of a message.
Definition: kopetemessage.h:88
Kopete::MessageHandler::handleMessage
virtual void handleMessage(MessageEvent *event)
Performs any processing necessary on the message.
Definition: kopetemessagehandler.cpp:63
Kopete::MessageHandlerFactory::StageDoNotCreate
do not create a filter for this stage
Definition: kopetemessagehandler.h:145
Kopete::SimpleMessageHandler::SimpleMessageHandler
SimpleMessageHandler()
Definition: kopetesimplemessagehandler.cpp:77
Kopete::SimpleMessageHandlerFactory::~SimpleMessageHandlerFactory
~SimpleMessageHandlerFactory()
Definition: kopetesimplemessagehandler.cpp:46
kopetemessageevent.h
Kopete::SimpleMessageHandler
Definition: kopetesimplemessagehandler.h:69
Kopete::MessageHandler
Definition: kopetemessagehandler.h:44
Kopete::SimpleMessageHandlerFactory::SimpleMessageHandlerFactory
SimpleMessageHandlerFactory(Message::MessageDirection direction, int position, QObject *target, const char *slot)
Definition: kopetesimplemessagehandler.cpp:36
Kopete::SimpleMessageHandler::handleMessage
void handleMessage(MessageEvent *event)
Performs any processing necessary on the message.
Definition: kopetesimplemessagehandler.cpp:87
Kopete::SimpleMessageHandler::~SimpleMessageHandler
~SimpleMessageHandler()
Definition: kopetesimplemessagehandler.cpp:82
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Kopete::SimpleMessageHandlerFactory::create
MessageHandler * create(ChatSession *manager, Message::MessageDirection direction)
Creates and returns a SimpleMessageHandler object.
Definition: kopetesimplemessagehandler.cpp:51
Kopete::Message
Representation of a message in Kopete.
Definition: kopetemessage.h:82
kopetesimplemessagehandler.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/libkopete

Skip menu "kopete/libkopete"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal