mucmessagesession.cpp
/*
Copyright (c) 2006-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.
*/
#include "mucmessagesession.h"
#include "clientbase.h"
#include "message.h"
#include "messagehandler.h"
namespace gloox
{
MUCMessageSession::MUCMessageSession( ClientBase* parent, const JID& jid )
: MessageSession( parent, jid, false, Message::Groupchat | Message::Chat
| Message::Normal | Message::Error,
false )
{
}
MUCMessageSession::~MUCMessageSession()
{
}
void MUCMessageSession::handleMessage( Message& msg )
{
if( m_messageHandler )
m_messageHandler->handleMessage( msg );
}
void MUCMessageSession::send( const std::string& message )
{
send( message, EmptyString );
}
void MUCMessageSession::send( const std::string& message, const std::string& subject, const StanzaExtensionList& sel )
{
if( !m_hadMessages )
{
m_thread = "gloox" + m_parent->getID();
m_hadMessages = true;
}
Message m( Message::Groupchat, m_target.bare(), message, subject, m_thread );
m.setID( m_parent->getID() );
decorate( m );
if( sel.size() )
{
StanzaExtensionList::const_iterator it = sel.begin();
for( ; it != sel.end(); ++it )
m.addExtension( (*it));
}
MessageSession::send( m );
}
void MUCMessageSession::setSubject( const std::string& subject )
{
Message m( Message::Groupchat, m_target.bareJID(), EmptyString, subject );
m_parent->send( m );
}
}
gloox::ClientBase
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition clientbase.h:79
gloox::Error
A stanza error abstraction implemented as a StanzaExtension.
Definition error.h:35
gloox::JID
An abstraction of a JID.
Definition jid.h:31
gloox::MUCMessageSession::~MUCMessageSession
virtual ~MUCMessageSession()
Definition mucmessagesession.cpp:29
gloox::MUCMessageSession::send
virtual void send(const std::string &message)
Definition mucmessagesession.cpp:39
gloox::MUCMessageSession::MUCMessageSession
MUCMessageSession(ClientBase *parent, const JID &jid)
Definition mucmessagesession.cpp:22
gloox::MUCMessageSession::setSubject
virtual void setSubject(const std::string &subject)
Definition mucmessagesession.cpp:66
gloox::MUCMessageSession::handleMessage
virtual void handleMessage(Message &msg)
Definition mucmessagesession.cpp:33
gloox::MessageSession::send
virtual void send(const std::string &message)
Definition messagesession.cpp:62
gloox::MessageSession::MessageSession
MessageSession(ClientBase *parent, const JID &jid, bool wantUpgrade=true, int types=0, bool honorTID=true)
Definition messagesession.cpp:24
gloox::Message
An abstraction of a message stanza.
Definition message.h:34
gloox::Message::setID
void setID(const std::string &id)
Definition message.h:122
gloox::Message::Groupchat
@ Groupchat
Definition message.h:48
gloox::Stanza::addExtension
void addExtension(const StanzaExtension *se)
Definition stanza.cpp:52
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::StanzaExtensionList
std::list< const StanzaExtension * > StanzaExtensionList
Definition gloox.h:1272
gloox::EmptyString
const std::string EmptyString
Definition gloox.cpp:124