gloox  1.0.1
message.h
1 /*
2  Copyright (c) 2007-2012 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 
38  public:
39 
44  {
45  Chat = 1,
46  Error = 2,
47  Groupchat = 4,
48  Headline = 8,
49  Normal = 16,
50  Invalid = 32
51  };
52 
62  Message( MessageType type, const JID& to,
63  const std::string& body = EmptyString, const std::string& subject = EmptyString,
64  const std::string& thread = EmptyString, const std::string& xmllang = EmptyString );
65 
69  virtual ~Message();
70 
75  MessageType subtype() const { return m_subtype; }
76 
86  const std::string body( const std::string& lang = "default" ) const
87  {
88  return findLang( m_bodies, m_body, lang );
89  }
90 
100  const std::string subject( const std::string& lang = "default" ) const
101  {
102  return findLang( m_subjects, m_subject, lang );
103  }
104 
109  const std::string& thread() const { return m_thread; }
110 
115  void setThread( const std::string& thread ) { m_thread = thread; }
116 
121  void setID( const std::string& id ) { m_id = id; }
122 
130  const DelayedDelivery* when() const
131  {
132  return static_cast<const DelayedDelivery*>( findExtension( ExtDelay ) );
133  }
134 
135  // reimplemented from Stanza
136  virtual Tag* tag() const;
137 
138  private:
139 #ifdef MESSAGE_TEST
140  public:
141 #endif
142 
146  Message( Tag* tag );
147 
148  MessageType m_subtype;
149  std::string m_body;
150  std::string m_subject;
151  StringMap* m_bodies;
152  StringMap* m_subjects;
153  std::string m_thread;
154  };
155 
156 }
157 
158 #endif // MESSAGE_H__