message.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef MESSAGE_H__
00014 #define MESSAGE_H__
00015
00016 #include "delayeddelivery.h"
00017 #include "stanza.h"
00018
00019 #include <string>
00020
00021 namespace gloox
00022 {
00023
00024 class JID;
00025
00033 class GLOOX_API Message : public Stanza
00034 {
00035
00036 friend class ClientBase;
00037
00038 public:
00039
00043 enum MessageType
00044 {
00045 Chat = 1,
00046 Error = 2,
00047 Groupchat = 4,
00048 Headline = 8,
00049 Normal = 16,
00050 Invalid = 32
00051 };
00052
00062 Message( MessageType type, const JID& to,
00063 const std::string& body = EmptyString, const std::string& subject = EmptyString,
00064 const std::string& thread = EmptyString, const std::string& xmllang = EmptyString );
00065
00069 virtual ~Message();
00070
00075 MessageType subtype() const { return m_subtype; }
00076
00086 const std::string body( const std::string& lang = "default" ) const
00087 {
00088 return findLang( m_bodies, m_body, lang );
00089 }
00090
00100 const std::string subject( const std::string& lang = "default" ) const
00101 {
00102 return findLang( m_subjects, m_subject, lang );
00103 }
00104
00109 const std::string& thread() const { return m_thread; }
00110
00115 void setThread( const std::string& thread ) { m_thread = thread; }
00116
00121 void setID( const std::string& id ) { m_id = id; }
00122
00128 const DelayedDelivery* when() const
00129 {
00130 return static_cast<const DelayedDelivery*>( findExtension( ExtDelay ) );
00131 }
00132
00133
00134 virtual Tag* tag() const;
00135
00136 private:
00137 #ifdef MESSAGE_TEST
00138 public:
00139 #endif
00140
00144 Message( Tag* tag );
00145
00146 MessageType m_subtype;
00147 std::string m_body;
00148 std::string m_subject;
00149 StringMap* m_bodies;
00150 StringMap* m_subjects;
00151 std::string m_thread;
00152 };
00153
00154 }
00155
00156 #endif // MESSAGE_H__