summaryrefslogtreecommitdiffstats
path: root/src/jabber_whiteboard/message-node.h
blob: 8609597ce46f7a2c5312b13cfe97d1a4386c2853 (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
130
131
132
133
134
135
/**
 * Whiteboard message queue and queue handler functions
 * Node for storing messages in message queues
 * 
 * Authors:
 * David Yip <yipdw@rose-hulman.edu>
 *
 * Copyright (c) 2005 Authors
 *
 * Released under GNU GPL, read the file 'COPYING' for more information
 */

#ifndef __WHITEBOARD_MESSAGE_NODE_H__
#define __WHITEBOARD_MESSAGE_NODE_H__

#include <string>
#include <glibmm.h>

#include "gc-managed.h"
#include "gc-anchored.h"
#include "gc-finalized.h"
#include "message.h"

namespace Inkscape {

namespace Whiteboard {

/**
 * Encapsulates a document change message received by or sent to an Inkboard client.
 *
 * Received messages that end up in a MessageNode are of the following types:
 * <ol>
 * 	<li>CHANGE_REPEATABLE</li>
 * 	<li>CHANGE_NOT_REPEATABLE</li>
 * 	<li>CHANGE_COMMIT</li>
 * 	<li>DOCUMENT_BEGIN</li>
 * 	<li>DOCUMENT_END</li>
 * 	<li>DUMMY_CHANGE</li>
 * </ol>
 *
 * This class is intended for use in MessageQueues, although it could potentially
 * see use outside of that context.
 *
 * \see Inkscape::Whiteboard::MessageQueue
 */
class MessageNode : public GC::Managed<>, public GC::Anchored, public GC::Finalized {
public:
	/**
	 * Constructor.
	 *
	 * \param seq The sequence number of the message being encapsulated.
	 * \param sender The sender of the message.
	 * \param recip The intended recipient. 
	 * \param message_body The body of the message.
	 * \param type The type of the message.
	 * \param chatroom Whether or not this message is to be sent to / was received from a chatroom.
	 */
	MessageNode(unsigned int seq, std::string sender, std::string recip, Glib::ustring const& message_body, MessageType type, bool document, bool chatroom) :
		_seq(seq), _type(type), _message(message_body), _document(document), _chatroom(chatroom)
	{
		this->_sender = sender;
		this->_recipient = recip;
	}

    virtual ~MessageNode() 
	{
//		g_log(NULL, G_LOG_LEVEL_DEBUG, "MessageNode destructor");
		/*
		if (this->_message) {
			delete this->_message;
		}
		*/
	}

	unsigned int sequence()
	{
		return this->_seq;
	}

	MessageType type()
	{
		return this->_type;
	}

	bool chatroom()
	{
		return this->_chatroom;
	}

	bool document()
	{
		return this->_document;
	}

	std::string recipient()
	{
		return this->_recipient;
	}

	std::string sender()
	{
		return this->_sender;
	}

	Glib::ustring const& message()
	{
		return this->_message;
	}

private:
	unsigned int _seq;
	std::string _sender;
	std::string _recipient;
	MessageType _type;
	Glib::ustring _message;
	bool _document;
	bool _chatroom;
};

}

}

#endif

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :