messagesession.h
/*
Copyright (c) 2005-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef MESSAGESESSION_H__
#define MESSAGESESSION_H__
#include "jid.h"
#include "gloox.h"
#include <string>
#include <list>
namespace gloox
{
class ClientBase;
class MessageFilter;
class MessageHandler;
class Message;
class GLOOX_API MessageSession
{
friend class MessageFilter;
public:
MessageSession( ClientBase* parent, const JID& jid, bool wantUpgrade = true, int types = 0, bool honorTID = true );
virtual ~MessageSession();
const JID& target() const { return m_target; }
const std::string& threadID() const { return m_thread; }
void setThreadID( const std::string& thread ) { m_thread = thread; }
bool honorThreadID() const { return m_honorThreadID; }
void registerMessageHandler( MessageHandler* mh )
{ m_messageHandler = mh; }
void removeMessageHandler()
{ m_messageHandler = 0; }
virtual void send( const std::string& message );
virtual void send( const std::string& message, const std::string& subject,
const StanzaExtensionList& sel = StanzaExtensionList() );
void registerMessageFilter( MessageFilter* mf )
{ m_messageFilterList.push_back( mf ); }
void removeMessageFilter( MessageFilter* mf )
{ m_messageFilterList.remove( mf ); }
void disposeMessageFilter( MessageFilter* mf );
int types() const { return m_types; }
void resetResource();
virtual void handleMessage( Message& msg );
protected:
virtual void send( const Message& msg );
void decorate( Message& msg );
void setResource( const std::string& resource );
typedef std::list<MessageFilter*> MessageFilterList;
MessageFilterList m_messageFilterList;
ClientBase* m_parent;
JID m_target;
MessageHandler* m_messageHandler;
std::string m_thread;
int m_types;
bool m_wantResourceTracking;
bool m_hadMessages;
bool m_honorThreadID;
};
}
#endif // MESSAGESESSION_H__
gloox::ClientBase
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition clientbase.h:79
gloox::JID
An abstraction of a JID.
Definition jid.h:31
gloox::MessageFilter
Virtual base class for message filters.
Definition messagefilter.h:38
gloox::MessageHandler
A virtual interface which can be reimplemented to receive incoming message stanzas.
Definition messagehandler.h:37
gloox::MessageSession::registerMessageFilter
void registerMessageFilter(MessageFilter *mf)
Definition messagesession.h:247
gloox::MessageSession::registerMessageHandler
void registerMessageHandler(MessageHandler *mh)
Definition messagesession.h:212
gloox::MessageSession::honorThreadID
bool honorThreadID() const
Definition messagesession.h:204
gloox::MessageSession::MessageSession
MessageSession(ClientBase *parent, const JID &jid, bool wantUpgrade=true, int types=0, bool honorTID=true)
Definition messagesession.cpp:24
gloox::MessageSession::removeMessageFilter
void removeMessageFilter(MessageFilter *mf)
Definition messagesession.h:255
gloox::MessageSession::threadID
const std::string & threadID() const
Definition messagesession.h:190
gloox::MessageSession::removeMessageHandler
void removeMessageHandler()
Definition messagesession.h:219
gloox::MessageSession::target
const JID & target() const
Definition messagesession.h:183
gloox::MessageSession::types
int types() const
Definition messagesession.h:269
gloox::MessageSession::setThreadID
void setThreadID(const std::string &thread)
Definition messagesession.h:197
gloox::Message
An abstraction of a message stanza.
Definition message.h:34
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::StanzaExtensionList
std::list< const StanzaExtension * > StanzaExtensionList
Definition gloox.h:1272