2
* Whiteboard session manager
3
* Jabber received message processors
6
* David Yip <yipdw@rose-hulman.edu>
8
* Copyright (c) 2005 Authors
10
* Released under GNU GPL, read the file 'COPYING' for more information
13
#ifndef __WHITEBOARD_MESSAGE_PROCESSORS_H__
14
#define __WHITEBOARD_MESSAGE_PROCESSORS_H__
16
#include "jabber_whiteboard/typedefs.h"
18
#include "gc-managed.h"
19
#include "gc-finalized.h"
23
namespace Whiteboard {
27
// Processor forward declarations
29
struct DocumentSignalHandler;
30
struct ConnectRequestHandler;
31
struct ConnectErrorHandler;
32
struct ChatSynchronizeHandler;
35
* Encapsulates a pointer to an LmMessage along with additional information,
36
* such as the message's sequence number, its sender, and its body.
38
* All of the above data members can be extracted directly from the LmMessage;
39
* they are provided for convenience.
41
struct JabberMessage {
46
* The constructor attaches a reference to the LmMessage to prevent Loudmouth from
47
* freeing the message.
49
JabberMessage(LmMessage* m) : message(m), sequence(0)
51
lm_message_ref(this->message);
57
* The destructor deletes a reference to the LmMessage, which, assuming all other
58
* references have been deleted, will allow Loudmouth to free the LmMessage object.
62
lm_message_unref(this->message);
66
// TODO: Hide, or, better, remove this. There's no real reason why it should be here,
67
// and it allows for the possibility of reference count-induced memory leaks.
69
* Pointer to original Loudmouth message object.
74
* Sequence number of this message.
76
unsigned int sequence;
79
* The JID of this message's sender.
84
* The body of this message.
89
// noncopyable, nonassignable (for now, anyway...)
90
// JabberMessage(JabberMessage const&);
91
// JabberMessage& operator=(JabberMessage const&);
95
* A MessageProcessor is a functor that is associated with one or more Inkboard message types.
96
* When an Inkboard client receives an Inkboard message, it passes it to the appropriate
99
struct MessageProcessor : public GC::Managed<>, public GC::Finalized {
101
virtual ~MessageProcessor()
107
* Functor action operator.
109
* \param mode The type of the message being processed.
110
* \param m A reference to the JabberMessage encapsulating the received Jabber message.
112
virtual LmHandlerResult operator()(MessageType mode, JabberMessage& m) = 0;
117
* \param sm The SessionManager with which a MessageProcessor instance is associated.
119
MessageProcessor(SessionManager* sm) : _sm(sm) { }
122
* Pointer to the associated SessionManager object.
127
// noncopyable, nonassignable
128
MessageProcessor(MessageProcessor const&);
129
MessageProcessor& operator=(MessageProcessor const&);
133
struct ProcessorShell : public GC::Managed<>, public std::binary_function< MessageType, JabberMessage, LmHandlerResult > {
135
ProcessorShell(MessageProcessor* mpm) : _mpm(mpm) { }
137
LmHandlerResult operator()(MessageType type, JabberMessage msg)
139
return (*this->_mpm)(type, msg);
142
MessageProcessor* _mpm;
147
* Initialize the message -> MessageProcessor map.
149
* \param sm The SessionManager with which all created MessageProcessors should be associated with.
150
* \param mpm Reference to the MessageProcessorMap to initialize.
152
void initialize_received_message_processors(SessionManager* sm, MessageProcessorMap& mpm);
155
* Clean up the message -> MessageProcessor map.
157
* \param mpm Reference to the MessageProcessorMap to clean up.
159
void destroy_received_message_processors(MessageProcessorMap& mpm);
170
c-file-style:"stroustrup"
171
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
176
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :