presence.h
/*
Copyright (c) 2007-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef PRESENCE_H__
#define PRESENCE_H__
#include "stanza.h"
#include <string>
namespace gloox
{
class Capabilities;
class JID;
class GLOOX_API Presence : public Stanza
{
friend class ClientBase;
public:
enum PresenceType
{
Available,
Chat,
Away,
DND,
XA,
Unavailable,
Probe,
Error,
Invalid
};
Presence( PresenceType type, const JID& to, const std::string& status = EmptyString,
int priority = 0, const std::string& xmllang = EmptyString );
virtual ~Presence();
PresenceType subtype() const { return m_subtype; }
const Capabilities* capabilities() const;
//#warning FIXME return something useful (only 'show' values?) or kill this func
PresenceType presence() const { return m_subtype; }
void setPresence( PresenceType type ) { m_subtype = type; }
const std::string status( const std::string& lang = "default" ) const
{
return findLang( m_stati, m_status, lang );
}
void addStatus( const std::string& status, const std::string& lang = EmptyString )
{
setLang( &m_stati, m_status, status, lang );
}
void resetStatus();
int priority() const { return m_priority; }
void setPriority( int priority );
// reimplemented from Stanza
virtual Tag* tag() const;
private:
#ifdef PRESENCE_TEST
public:
#endif
Presence( Tag* tag );
PresenceType m_subtype;
StringMap* m_stati;
std::string m_status;
int m_priority;
};
}
#endif // PRESENCE_H__
gloox::Capabilities
This is an implementation of XEP-0115 (Entity Capabilities).
Definition capabilities.h:37
gloox::JID
An abstraction of a JID.
Definition jid.h:31
gloox::Presence
An abstraction of a presence stanza.
Definition presence.h:33
gloox::Presence::setPresence
void setPresence(PresenceType type)
Definition presence.h:95
gloox::Presence::priority
int priority() const
Definition presence.h:131
gloox::Presence::Presence
Presence(PresenceType type, const JID &to, const std::string &status=EmptyString, int priority=0, const std::string &xmllang=EmptyString)
Definition presence.cpp:72
gloox::Presence::presence
PresenceType presence() const
Definition presence.h:89
gloox::Presence::subtype
PresenceType subtype() const
Definition presence.h:76
gloox::Presence::status
const std::string status(const std::string &lang="default") const
Definition presence.h:106
gloox::Presence::addStatus
void addStatus(const std::string &status, const std::string &lang=EmptyString)
Definition presence.h:117
gloox::Presence::PresenceType
PresenceType
Definition presence.h:43
gloox::Presence::Away
@ Away
Definition presence.h:46
gloox::Presence::Available
@ Available
Definition presence.h:44
gloox::Presence::Error
@ Error
Definition presence.h:51
gloox::Presence::XA
@ XA
Definition presence.h:48
gloox::Presence::Probe
@ Probe
Definition presence.h:50
gloox::Presence::Chat
@ Chat
Definition presence.h:45
gloox::Presence::DND
@ DND
Definition presence.h:47
gloox::Presence::Invalid
@ Invalid
Definition presence.h:52
gloox::Presence::Unavailable
@ Unavailable
Definition presence.h:49
gloox::Stanza::Stanza
Stanza(Tag *tag)
Definition stanza.cpp:31
gloox::Tag
This is an abstraction of an XML element.
Definition tag.h:47
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::EmptyString
const std::string EmptyString
Definition gloox.cpp:124
gloox::StringMap
std::map< std::string, std::string > StringMap
Definition gloox.h:1261