gloox  1.0.9
message.h
1 /*
2  Copyright (c) 2007-2013 by Jakob Schroeter <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__