gloox  1.0.27
presence.h
1 /*
2  Copyright (c) 2007-2023 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 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
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__
This is an implementation of XEP-0115 (Entity Capabilities).
Definition: capabilities.h:37
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition: clientbase.h:79
An abstraction of a JID.
Definition: jid.h:31
An abstraction of a presence stanza.
Definition: presence.h:33
void setPresence(PresenceType type)
Definition: presence.h:95
int priority() const
Definition: presence.h:131
PresenceType presence() const
Definition: presence.h:89
PresenceType subtype() const
Definition: presence.h:76
const std::string status(const std::string &lang="default") const
Definition: presence.h:106
void addStatus(const std::string &status, const std::string &lang=EmptyString)
Definition: presence.h:117
This is the base class for XMPP stanza abstractions.
Definition: stanza.h:34
This is an abstraction of an XML element.
Definition: tag.h:47
The namespace for the gloox library.
Definition: adhoc.cpp:28
const std::string EmptyString
Definition: gloox.cpp:124
std::map< std::string, std::string > StringMap
Definition: gloox.h:1261