gloox  1.0.20
message.h
1 /*
2  Copyright (c) 2007-2017 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 #ifndef MESSAGE_H__
14 #define MESSAGE_H__
15 
16 #include "delayeddelivery.h"
17 #include "stanza.h"
18 
19 #include <string>
20 
21 namespace gloox
22 {
23 
24  class JID;
25 
33  class GLOOX_API Message : public Stanza
34  {
35 
36  friend class ClientBase;
37  friend class Forward;
38 
39  public:
40 
45  {
46  Chat = 1,
47  Error = 2,
48  Groupchat = 4,
49  Headline = 8,
50  Normal = 16,
51  Invalid = 32
52  };
53 
63  Message( MessageType type, const JID& to,
64  const std::string& body = EmptyString, const std::string& subject = EmptyString,
65  const std::string& thread = EmptyString, const std::string& xmllang = EmptyString );
66 
70  virtual ~Message();
71 
76  MessageType subtype() const { return m_subtype; }
77 
87  const std::string body( const std::string& lang = "default" ) const
88  {
89  return findLang( m_bodies, m_body, lang );
90  }
91 
101  const std::string subject( const std::string& lang = "default" ) const
102  {
103  return findLang( m_subjects, m_subject, lang );
104  }
105 
110  const std::string& thread() const { return m_thread; }
111 
116  void setThread( const std::string& thread ) { m_thread = thread; }
117 
122  void setID( const std::string& id ) { m_id = id; }
123 
131  const DelayedDelivery* when() const
132  {
133  return static_cast<const DelayedDelivery*>( findExtension( ExtDelay ) );
134  }
135 
136  // reimplemented from Stanza
137  virtual Tag* tag() const;
138 
139  private:
140 #ifdef MESSAGE_TEST
141  public:
142 #endif
143 
147  Message( Tag* tag );
148 
149  MessageType m_subtype;
150  std::string m_body;
151  std::string m_subject;
152  StringMap* m_bodies;
153  StringMap* m_subjects;
154  std::string m_thread;
155  };
156 
157 }
158 
159 #endif // MESSAGE_H__
const DelayedDelivery * when() const
Definition: message.h:131
This is an implementation of Stanza Forwarding (XEP-0297) as a StanzaExtension.
Definition: forward.h:40
MessageType subtype() const
Definition: message.h:76
This is the base class for XMPP stanza abstractions.
Definition: stanza.h:33
This is an implementation of XEP-0203 (Delayed Delivery).
void setID(const std::string &id)
Definition: message.h:122
const std::string & thread() const
Definition: message.h:110
A stanza error abstraction implemented as a StanzaExtension.
Definition: error.h:34
const std::string body(const std::string &lang="default") const
Definition: message.h:87
An abstraction of a message stanza.
Definition: message.h:33
The namespace for the gloox library.
Definition: adhoc.cpp:27
std::map< std::string, std::string > StringMap
Definition: gloox.h:1261
An abstraction of a JID.
Definition: jid.h:30
void setThread(const std::string &thread)
Definition: message.h:116
const std::string subject(const std::string &lang="default") const
Definition: message.h:101
const std::string EmptyString
Definition: gloox.cpp:124
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition: clientbase.h:76
This is an abstraction of an XML element.
Definition: tag.h:46