summaryrefslogtreecommitdiffstats
path: root/kopete/libkopete/kopetemessageevent.h
blob: 7beb1aa2a592d84cafcd14e76fd6336482ba220e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
    kopetemessageevent.h - Kopete Message Event

    Copyright (c) 2003 by Olivier Goffart <ogoffart @ kde.org>
    Copyright (c) 2002 by Duncan Mac-Vicar Prett <duncan@kde.org>
    Copyright (c) 2002 by Hendrik vom Lehn <hvl@linux-4-ever.de>
    Copyright (c) 2004 by Richard Smith <richard@metafoo.co.uk>

    Kopete    (c) 2002 by the Kopete developers  <kopete-devel@kde.org>

    *************************************************************************
    *                                                                       *
    * This library is free software; you can redistribute it and/or         *
    * modify it under the terms of the GNU Lesser General Public            *
    * License as published by the Free Software Foundation; either          *
    * version 2 of the License, or (at your option) any later version.      *
    *                                                                       *
    *************************************************************************
*/

#ifndef KOPETEMESSAGEEVENT_H
#define KOPETEMESSAGEEVENT_H

#include <qobject.h>

#include "kopetemessage.h"

#include "kopete_export.h"

namespace Kopete
{

/**
 * @author Olivier Goffart <ogoffart @ kde.org>
 * @author Richard Smith   <richard@metafoo.co.uk>
 *
 * Kopete::MessageEvent is used when a new messages arrives, it is
 * caught by the UI. It contains just informations about
 * the message, and a signal when it is terminated (i.e.
 * the message is read
 **/
class KOPETE_EXPORT MessageEvent : public QObject
{
	Q_OBJECT

public:
	MessageEvent(const Kopete::Message& , QObject* parent=0L, const char *name=0L);
	~MessageEvent();

	/**
	 * @return A copy of the message
	 */
	Kopete::Message message();
	
	/**
	 * Sets the message contained in this event.
	 * @param message The new value for the message
	 */
	void setMessage( const Kopete::Message &message );

	/**
	 * The state of the event.
	 * - @c Nothing means that the event has not been accepted or ignored
	 * - @c Applied if the event has been applied
	 * - @c Ignored if the event has been ignored
	 */
	enum EventState { Nothing , Applied , Ignored };

	EventState state();

public slots:
	/**
	 * @deprecated Use accept() instead to continue the processing of this event once the caller has moved to using MessageHandlers
	 * 
	 * execute the event
	 */
	void apply();
	
	/**
	 * @deprecated Use discard() instead to destroy this event once the caller has moved to using MessageHandlers
	 * 
	 * ignore the event
	 */
	void ignore();
	
	/**
	 * @brief Passes the event to the next handler
	 * 
	 * Call this when you've finished processing this event
	 */
	void accept();
	
	/**
	 * @brief Discards the event
	 *
	 * If this event should not be processed any further, this function
	 * should be called to discard it.
	 */
	void discard();
	
signals:
	/**
	 * The event has been processed
	 */
	void done(Kopete::MessageEvent *);
	
	/**
	 * The event has been discarded.
	 * @param event The event sending the signal.
	 */
	void discarded(Kopete::MessageEvent *event);
	
	/**
	 * The event has been accepted by its current handler.
	 * @param event The event sending the signal.
	 */
	void accepted(Kopete::MessageEvent *event);

private:
	class Private;
	Private *d;
};

}

#endif

// vim: set noet ts=4 sts=4 sw=4: