amp.h
/*
Copyright (c) 2006-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 AMP_H__
#define AMP_H__
#include "stanzaextension.h"
#include "jid.h"
#include <string>
#include <list>
#include <ctime>
namespace gloox
{
class Tag;
class GLOOX_API AMP : public StanzaExtension
{
public:
enum ConditionType
{
ConditionDeliver,
ConditionExpireAt,
ConditionMatchResource,
ConditionInvalid
};
enum ActionType
{
ActionAlert,
ActionError,
ActionDrop,
ActionNotify,
ActionInvalid
};
enum DeliverType
{
DeliverDirect,
DeliverForward,
DeliverGateway,
DeliverNone,
DeliverStored,
DeliverInvalid
};
enum MatchResourceType
{
MatchResourceAny,
MatchResourceExact,
MatchResourceOther,
MatchResourceInvalid
};
enum Status
{
StatusAlert,
StatusNotify,
StatusInvalid
};
class GLOOX_API Rule
{
public:
Rule( DeliverType deliver, ActionType action );
Rule( const std::string& date, ActionType action );
Rule( MatchResourceType match, ActionType action );
Rule( const std::string& condition, const std::string& action,
const std::string& value );
~Rule();
Tag* tag() const;
private:
ConditionType m_condition;
union
{
DeliverType m_deliver;
MatchResourceType m_matchresource;
std::string* m_expireat;
};
ActionType m_action;
};
typedef std::list<const Rule*> RuleList;
AMP( bool perhop = false );
AMP( const Tag* tag );
void addRule( const Rule* rule );
const RuleList& rules() const { return m_rules; }
virtual ~AMP();
// reimplemented from StanzaExtension
virtual const std::string& filterString() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* newInstance( const Tag* tag ) const
{
return new AMP( tag );
}
// reimplemented from StanzaExtension
virtual Tag* tag() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* clone() const
{
AMP* a = new AMP();
a->m_perhop = m_perhop;
RuleList::const_iterator it = m_rules.begin();
for( ; it != m_rules.end(); ++it )
a->m_rules.push_back( new Rule( *(*it) ) );
a->m_status = m_status;
a->m_from = m_from;
a->m_to = m_to;
return a;
}
private:
bool m_perhop;
RuleList m_rules;
Status m_status;
JID m_from;
JID m_to;
};
}
#endif // AMP_H__
gloox::AMP::Rule
Definition amp.h:117
gloox::AMP::Rule::Rule
Rule(DeliverType deliver, ActionType action)
Definition amp.cpp:47
gloox::AMP::Rule::tag
Tag * tag() const
Definition amp.cpp:90
gloox::AMP
This is an implementation of XEP-0079 (Advanced Message Processing) as a StanzaExtension.
Definition amp.h:40
gloox::AMP::ActionType
ActionType
Definition amp.h:58
gloox::AMP::ActionError
@ ActionError
Definition amp.h:61
gloox::AMP::ActionNotify
@ ActionNotify
Definition amp.h:63
gloox::AMP::ActionInvalid
@ ActionInvalid
Definition amp.h:64
gloox::AMP::ActionDrop
@ ActionDrop
Definition amp.h:62
gloox::AMP::ActionAlert
@ ActionAlert
Definition amp.h:60
gloox::AMP::clone
virtual StanzaExtension * clone() const
Definition amp.h:220
gloox::AMP::addRule
void addRule(const Rule *rule)
Definition amp.cpp:155
gloox::AMP::AMP
AMP(bool perhop=false)
Definition amp.cpp:121
gloox::AMP::Status
Status
Definition amp.h:104
gloox::AMP::StatusAlert
@ StatusAlert
Definition amp.h:105
gloox::AMP::StatusNotify
@ StatusNotify
Definition amp.h:106
gloox::AMP::StatusInvalid
@ StatusInvalid
Definition amp.h:107
gloox::AMP::newInstance
virtual StanzaExtension * newInstance(const Tag *tag) const
Definition amp.h:211
gloox::AMP::ConditionType
ConditionType
Definition amp.h:47
gloox::AMP::ConditionDeliver
@ ConditionDeliver
Definition amp.h:48
gloox::AMP::ConditionInvalid
@ ConditionInvalid
Definition amp.h:51
gloox::AMP::ConditionExpireAt
@ ConditionExpireAt
Definition amp.h:49
gloox::AMP::ConditionMatchResource
@ ConditionMatchResource
Definition amp.h:50
gloox::AMP::MatchResourceType
MatchResourceType
Definition amp.h:90
gloox::AMP::MatchResourceAny
@ MatchResourceAny
Definition amp.h:91
gloox::AMP::MatchResourceExact
@ MatchResourceExact
Definition amp.h:93
gloox::AMP::MatchResourceInvalid
@ MatchResourceInvalid
Definition amp.h:97
gloox::AMP::MatchResourceOther
@ MatchResourceOther
Definition amp.h:95
gloox::AMP::DeliverType
DeliverType
Definition amp.h:71
gloox::AMP::DeliverStored
@ DeliverStored
Definition amp.h:81
gloox::AMP::DeliverInvalid
@ DeliverInvalid
Definition amp.h:83
gloox::AMP::DeliverNone
@ DeliverNone
Definition amp.h:78
gloox::AMP::DeliverDirect
@ DeliverDirect
Definition amp.h:72
gloox::AMP::DeliverGateway
@ DeliverGateway
Definition amp.h:76
gloox::AMP::DeliverForward
@ DeliverForward
Definition amp.h:74
gloox::AMP::tag
virtual Tag * tag() const
Definition amp.cpp:167
gloox::AMP::rules
const RuleList & rules() const
Definition amp.h:200
gloox::AMP::RuleList
std::list< const Rule * > RuleList
Definition amp.h:175
gloox::JID
An abstraction of a JID.
Definition jid.h:31
gloox::StanzaExtension::StanzaExtension
StanzaExtension(int type)
Definition stanzaextension.h:211
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