message.h
/*
Copyright (c) 2007-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 MESSAGE_H__
#define MESSAGE_H__
#include "delayeddelivery.h"
#include "stanza.h"
#include <string>
namespace gloox
{
class JID;
class GLOOX_API Message : public Stanza
{
friend class ClientBase;
friend class Forward;
public:
enum MessageType
{
Chat = 1,
Error = 2,
Groupchat = 4,
Headline = 8,
Normal = 16,
Invalid = 32
};
Message( MessageType type, const JID& to,
const std::string& body = EmptyString, const std::string& subject = EmptyString,
const std::string& thread = EmptyString, const std::string& xmllang = EmptyString );
virtual ~Message();
MessageType subtype() const { return m_subtype; }
const std::string body( const std::string& lang = "default" ) const
{
return findLang( m_bodies, m_body, lang );
}
const std::string subject( const std::string& lang = "default" ) const
{
return findLang( m_subjects, m_subject, lang );
}
const std::string& thread() const { return m_thread; }
void setThread( const std::string& thread ) { m_thread = thread; }
void setID( const std::string& id ) { m_id = id; }
const DelayedDelivery* when() const
{
return static_cast<const DelayedDelivery*>( findExtension( ExtDelay ) );
}
// reimplemented from Stanza
virtual Tag* tag() const;
private:
#ifdef MESSAGE_TEST
public:
#endif
Message( Tag* tag );
MessageType m_subtype;
std::string m_body;
std::string m_subject;
StringMap* m_bodies;
StringMap* m_subjects;
std::string m_thread;
};
}
#endif // MESSAGE_H__
gloox::DelayedDelivery
This is an implementation of XEP-0203 (Delayed Delivery).
Definition delayeddelivery.h:39
gloox::JID
An abstraction of a JID.
Definition jid.h:31
gloox::Message
An abstraction of a message stanza.
Definition message.h:34
gloox::Message::subject
const std::string subject(const std::string &lang="default") const
Definition message.h:101
gloox::Message::body
const std::string body(const std::string &lang="default") const
Definition message.h:87
gloox::Message::setID
void setID(const std::string &id)
Definition message.h:122
gloox::Message::when
const DelayedDelivery * when() const
Definition message.h:131
gloox::Message::Message
Message(MessageType type, const JID &to, const std::string &body=EmptyString, const std::string &subject=EmptyString, const std::string &thread=EmptyString, const std::string &xmllang=EmptyString)
Definition message.cpp:54
gloox::Message::MessageType
MessageType
Definition message.h:45
gloox::Message::Error
@ Error
Definition message.h:47
gloox::Message::Headline
@ Headline
Definition message.h:49
gloox::Message::Normal
@ Normal
Definition message.h:50
gloox::Message::Groupchat
@ Groupchat
Definition message.h:48
gloox::Message::Chat
@ Chat
Definition message.h:46
gloox::Message::Invalid
@ Invalid
Definition message.h:51
gloox::Message::setThread
void setThread(const std::string &thread)
Definition message.h:116
gloox::Message::subtype
MessageType subtype() const
Definition message.h:76
gloox::Message::thread
const std::string & thread() const
Definition message.h:110
gloox::Stanza::id
const std::string & id() const
Definition stanza.h:63
gloox::Stanza::Stanza
Stanza(Tag *tag)
Definition stanza.cpp:31
gloox::Stanza::findExtension
const StanzaExtension * findExtension(int type) const
Definition stanza.cpp:57
gloox::Tag
This is an abstraction of an XML element.
Definition tag.h:47
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::EmptyString
const std::string EmptyString
Definition gloox.cpp:124
gloox::ExtDelay
@ ExtDelay
Definition stanzaextension.h:43
gloox::StringMap
std::map< std::string, std::string > StringMap
Definition gloox.h:1261