gloox  1.0.24
presence.h
1 /*
2  Copyright (c) 2007-2019 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
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__
gloox::Stanza
This is the base class for XMPP stanza abstractions.
Definition: stanza.h:34
gloox::Presence::addStatus
void addStatus(const std::string &status, const std::string &lang=EmptyString)
Definition: presence.h:117
gloox::Presence::Available
@ Available
Definition: presence.h:44
gloox::Presence::Error
@ Error
Definition: presence.h:51
gloox::Presence::status
const std::string status(const std::string &lang="default") const
Definition: presence.h:106
gloox::Presence::XA
@ XA
Definition: presence.h:48
gloox::Presence::PresenceType
PresenceType
Definition: presence.h:43
gloox::Presence::Chat
@ Chat
Definition: presence.h:45
gloox::Presence::Unavailable
@ Unavailable
Definition: presence.h:49
gloox::Presence
An abstraction of a presence stanza.
Definition: presence.h:33
gloox::Presence::priority
int priority() const
Definition: presence.h:131
gloox::Presence::Away
@ Away
Definition: presence.h:46
gloox::JID
An abstraction of a JID.
Definition: jid.h:31
gloox::Presence::subtype
PresenceType subtype() const
Definition: presence.h:76
gloox
The namespace for the gloox library.
Definition: adhoc.cpp:28
gloox::Tag
This is an abstraction of an XML element.
Definition: tag.h:47
gloox::Presence::setPresence
void setPresence(PresenceType type)
Definition: presence.h:95
gloox::ClientBase
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition: clientbase.h:79
gloox::Presence::Probe
@ Probe
Definition: presence.h:50
gloox::Capabilities
This is an implementation of XEP-0115 (Entity Capabilities).
Definition: capabilities.h:37
gloox::Presence::presence
PresenceType presence() const
Definition: presence.h:89
gloox::EmptyString
const std::string EmptyString
Definition: gloox.cpp:124
gloox::Presence::DND
@ DND
Definition: presence.h:47
gloox::StringMap
std::map< std::string, std::string > StringMap
Definition: gloox.h:1261