gloox  1.1-svn
message.h
1 /*
2  Copyright (c) 2007-2009 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 
128  const DelayedDelivery* when() const
129  {
130  return static_cast<const DelayedDelivery*>( findExtension( ExtDelay ) );
131  }
132 
133  // reimplemented from Stanza
134  virtual Tag* tag() const;
135 
136  private:
137 #ifdef MESSAGE_TEST
138  public:
139 #endif
140 
144  Message( Tag* tag );
145 
146  MessageType m_subtype;
147  std::string m_body;
148  std::string m_subject;
149  StringMap* m_bodies;
150  StringMap* m_subjects;
151  std::string m_thread;
152  };
153 
154 }
155 
156 #endif // MESSAGE_H__