gloox  1.0.28
messagesession.h
1 /*
2  Copyright (c) 2005-2023 by Jakob Schröter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #ifndef MESSAGESESSION_H__
15 #define MESSAGESESSION_H__
16 
17 #include "jid.h"
18 #include "gloox.h"
19 
20 #include <string>
21 #include <list>
22 
23 namespace gloox
24 {
25 
26  class ClientBase;
27  class MessageFilter;
28  class MessageHandler;
29  class Message;
30 
145  class GLOOX_API MessageSession
146  {
147 
148  friend class MessageFilter;
149 
150  public:
169  MessageSession( ClientBase* parent, const JID& jid, bool wantUpgrade = true, int types = 0, bool honorTID = true );
170 
177  virtual ~MessageSession();
178 
183  const JID& target() const { return m_target; }
184 
190  const std::string& threadID() const { return m_thread; }
191 
197  void setThreadID( const std::string& thread ) { m_thread = thread; }
198 
204  bool honorThreadID() const { return m_honorThreadID; }
205 
213  { m_messageHandler = mh; }
214 
220  { m_messageHandler = 0; }
221 
226  virtual void send( const std::string& message );
227 
236  virtual void send( const std::string& message, const std::string& subject,
237  const StanzaExtensionList& sel = StanzaExtensionList() );
238 
248  { m_messageFilterList.push_back( mf ); }
249 
256  { m_messageFilterList.remove( mf ); }
257 
263  void disposeMessageFilter( MessageFilter* mf );
264 
269  int types() const { return m_types; }
270 
279  void resetResource();
280 
286  virtual void handleMessage( Message& msg );
287 
288  protected:
295  virtual void send( const Message& msg );
296  void decorate( Message& msg );
297  void setResource( const std::string& resource );
298 
299  typedef std::list<MessageFilter*> MessageFilterList;
300  MessageFilterList m_messageFilterList;
301 
302  ClientBase* m_parent;
303  JID m_target;
304  MessageHandler* m_messageHandler;
305 
306 
307  std::string m_thread;
308  int m_types;
309  bool m_wantResourceTracking;
310  bool m_hadMessages;
311  bool m_honorThreadID;
312 
313  };
314 
315 }
316 
317 #endif // MESSAGESESSION_H__
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition: clientbase.h:79
An abstraction of a JID.
Definition: jid.h:31
Virtual base class for message filters.
Definition: messagefilter.h:38
A virtual interface which can be reimplemented to receive incoming message stanzas.
An abstraction of a message session between any two entities.
const JID & target() const
void registerMessageFilter(MessageFilter *mf)
void registerMessageHandler(MessageHandler *mh)
bool honorThreadID() const
void removeMessageFilter(MessageFilter *mf)
const std::string & threadID() const
void setThreadID(const std::string &thread)
An abstraction of a message stanza.
Definition: message.h:34
The namespace for the gloox library.
Definition: adhoc.cpp:28
std::list< const StanzaExtension * > StanzaExtensionList
Definition: gloox.h:1268