gloox  1.0.9
presence.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 PRESENCE_H__
14 #define PRESENCE_H__
15 
16 #include "stanza.h"
17 
18 #include <string>
19 
20 namespace gloox
21 {
22 
23  class Capabilities;
24  class JID;
25 
32  class GLOOX_API Presence : public Stanza
33  {
34 
35  friend class ClientBase;
36 
37  public:
38 
43  {
45  Chat,
46  Away,
47  DND,
48  XA,
52  Invalid
53  };
54 
64  Presence( PresenceType type, const JID& to, const std::string& status = EmptyString,
65  int priority = 0, const std::string& xmllang = EmptyString );
66 
70  virtual ~Presence();
71 
76  PresenceType subtype() const { return m_subtype; }
77 
82  const Capabilities* capabilities() const;
83 
88 //#warning FIXME return something useful (only 'show' values?) or kill this func
89  PresenceType presence() const { return m_subtype; }
90 
95  void setPresence( PresenceType type ) { m_subtype = type; }
96 
106  const std::string status( const std::string& lang = "default" ) const
107  {
108  return findLang( m_stati, m_status, lang );
109  }
110 
117  void addStatus( const std::string& status, const std::string& lang = EmptyString )
118  {
119  setLang( &m_stati, m_status, status, lang );
120  }
121 
125  void resetStatus();
126 
131  int priority() const { return m_priority; }
132 
137  void setPriority( int priority );
138 
139  // reimplemented from Stanza
140  virtual Tag* tag() const;
141 
142  private:
143 #ifdef PRESENCE_TEST
144  public:
145 #endif
146 
150  Presence( Tag* tag );
151 
152  PresenceType m_subtype;
153  StringMap* m_stati;
154  std::string m_status;
155  int m_priority;
156 
157  };
158 
159 }
160 
161 #endif // PRESENCE_H__