privacymanager.h
/*
Copyright (c) 2005-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 PRIVACYMANAGER_H__
#define PRIVACYMANAGER_H__
#include "iqhandler.h"
#include "privacylisthandler.h"
#include "stanzaextension.h"
#include <string>
namespace gloox
{
class ClientBase;
class GLOOX_API PrivacyManager : public IqHandler
{
public:
PrivacyManager( ClientBase* parent );
virtual ~PrivacyManager();
std::string store( const std::string& name, const PrivacyListHandler::PrivacyList& list );
std::string requestListNames()
{ return operation( PLRequestNames, EmptyString ); }
std::string requestList( const std::string& name )
{ return operation( PLRequestList, name ); }
std::string removeList( const std::string& name )
{ return operation( PLRemove, name ); }
std::string setDefault( const std::string& name )
{ return operation( PLDefault, name ); }
std::string unsetDefault()
{ return operation( PLUnsetDefault, EmptyString ); }
std::string setActive( const std::string& name )
{ return operation( PLActivate, name ); }
std::string unsetActive()
{ return operation( PLUnsetActivate, EmptyString ); }
void registerPrivacyListHandler( PrivacyListHandler* plh )
{ m_privacyListHandler = plh; }
void removePrivacyListHandler()
{ m_privacyListHandler = 0; }
// reimplemented from IqHandler.
virtual bool handleIq( const IQ& iq );
// reimplemented from IqHandler.
virtual void handleIqID( const IQ& iq, int context );
private:
enum IdType
{
PLRequestNames,
PLRequestList,
PLActivate,
PLDefault,
PLUnsetActivate,
PLUnsetDefault,
PLRemove,
PLStore
};
class Query : public StanzaExtension
{
public:
Query( IdType context, const std::string& name,
const PrivacyListHandler::PrivacyList& list = PrivacyListHandler::PrivacyList() );
Query( const Tag* tag = 0 );
virtual ~Query();
const std::string& active() const { return m_active; }
const std::string& def() const { return m_default; }
const PrivacyListHandler::PrivacyList& items() const
{ return m_items; }
const StringList& names() const { return m_names; }
const std::string& name() const
{
if( m_names.empty())
return EmptyString;
else
return (*m_names.begin());
}
// reimplemented from StanzaExtension
virtual const std::string& filterString() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* newInstance( const Tag* tag ) const
{
return new Query( tag );
}
// reimplemented from StanzaExtension
virtual Tag* tag() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* clone() const
{
return new Query( *this );
}
private:
IdType m_context;
StringList m_names;
std::string m_default;
std::string m_active;
PrivacyListHandler::PrivacyList m_items;
};
std::string operation( IdType context, const std::string& name );
ClientBase* m_parent;
PrivacyListHandler* m_privacyListHandler;
};
}
#endif // PRIVACYMANAGER_H__
gloox::ClientBase
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition clientbase.h:79
gloox::IQ
An abstraction of an IQ stanza.
Definition iq.h:34
gloox::IqHandler
A virtual interface which can be reimplemented to receive IQ stanzas.
Definition iqhandler.h:32
gloox::PrivacyListHandler
A virtual interface that allows to retrieve Privacy Lists.
Definition privacylisthandler.h:51
gloox::PrivacyListHandler::PrivacyList
std::list< PrivacyItem > PrivacyList
Definition privacylisthandler.h:57
gloox::PrivacyManager::removePrivacyListHandler
void removePrivacyListHandler()
Definition privacymanager.h:113
gloox::PrivacyManager::requestListNames
std::string requestListNames()
Definition privacymanager.h:59
gloox::PrivacyManager::removeList
std::string removeList(const std::string &name)
Definition privacymanager.h:73
gloox::PrivacyManager::setDefault
std::string setDefault(const std::string &name)
Definition privacymanager.h:80
gloox::PrivacyManager::unsetActive
std::string unsetActive()
Definition privacymanager.h:99
gloox::PrivacyManager::setActive
std::string setActive(const std::string &name)
Definition privacymanager.h:93
gloox::PrivacyManager::registerPrivacyListHandler
void registerPrivacyListHandler(PrivacyListHandler *plh)
Definition privacymanager.h:107
gloox::PrivacyManager::PrivacyManager
PrivacyManager(ClientBase *parent)
Definition privacymanager.cpp:192
gloox::PrivacyManager::unsetDefault
std::string unsetDefault()
Definition privacymanager.h:86
gloox::PrivacyManager::requestList
std::string requestList(const std::string &name)
Definition privacymanager.h:66
gloox::PrivacyManager::store
std::string store(const std::string &name, const PrivacyListHandler::PrivacyList &list)
Definition privacymanager.cpp:223
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::StringList
std::list< std::string > StringList
Definition gloox.h:1251
gloox::EmptyString
const std::string EmptyString
Definition gloox.cpp:124