gloox 1.0.28
amp.h
1/*
2 Copyright (c) 2006-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
14#ifndef AMP_H__
15#define AMP_H__
16
17#include "stanzaextension.h"
18#include "jid.h"
19
20#include <string>
21#include <list>
22
23#include <ctime>
24
25namespace gloox
26{
27
28 class Tag;
29
39 class GLOOX_API AMP : public StanzaExtension
40 {
41
42 public:
53
66
85
99
109
116 class GLOOX_API Rule
117 {
118 public:
124 Rule( DeliverType deliver, ActionType action );
125
131 Rule( const std::string& date, ActionType action );
132
138 Rule( MatchResourceType match, ActionType action );
139
146 Rule( const std::string& condition, const std::string& action,
147 const std::string& value );
148
152 ~Rule();
153
158 Tag* tag() const;
159
160 private:
161 ConditionType m_condition;
162 union
163 {
164 DeliverType m_deliver;
165 MatchResourceType m_matchresource;
166 std::string* m_expireat;
167 };
168 ActionType m_action;
169
170 };
171
175 typedef std::list<const Rule*> RuleList;
176
182 AMP( bool perhop = false );
183
188 AMP( const Tag* tag );
189
194 void addRule( const Rule* rule );
195
200 const RuleList& rules() const { return m_rules; }
201
205 virtual ~AMP();
206
207 // reimplemented from StanzaExtension
208 virtual const std::string& filterString() const;
209
210 // reimplemented from StanzaExtension
211 virtual StanzaExtension* newInstance( const Tag* tag ) const
212 {
213 return new AMP( tag );
214 }
215
216 // reimplemented from StanzaExtension
217 virtual Tag* tag() const;
218
219 // reimplemented from StanzaExtension
220 virtual StanzaExtension* clone() const
221 {
222 AMP* a = new AMP();
223 a->m_perhop = m_perhop;
224 RuleList::const_iterator it = m_rules.begin();
225 for( ; it != m_rules.end(); ++it )
226 a->m_rules.push_back( new Rule( *(*it) ) );
227 a->m_status = m_status;
228 a->m_from = m_from;
229 a->m_to = m_to;
230 return a;
231 }
232
233 private:
234 bool m_perhop;
235 RuleList m_rules;
236 Status m_status;
237 JID m_from;
238 JID m_to;
239 };
240
241}
242
243#endif // AMP_H__
Rule(DeliverType deliver, ActionType action)
Definition amp.cpp:47
Tag * tag() const
Definition amp.cpp:90
This is an implementation of XEP-0079 (Advanced Message Processing) as a StanzaExtension.
Definition amp.h:40
ActionType
Definition amp.h:58
@ ActionError
Definition amp.h:61
@ ActionNotify
Definition amp.h:63
@ ActionInvalid
Definition amp.h:64
@ ActionDrop
Definition amp.h:62
@ ActionAlert
Definition amp.h:60
virtual StanzaExtension * clone() const
Definition amp.h:220
void addRule(const Rule *rule)
Definition amp.cpp:155
AMP(bool perhop=false)
Definition amp.cpp:121
@ StatusAlert
Definition amp.h:105
@ StatusNotify
Definition amp.h:106
@ StatusInvalid
Definition amp.h:107
virtual StanzaExtension * newInstance(const Tag *tag) const
Definition amp.h:211
ConditionType
Definition amp.h:47
@ ConditionDeliver
Definition amp.h:48
@ ConditionInvalid
Definition amp.h:51
@ ConditionExpireAt
Definition amp.h:49
@ ConditionMatchResource
Definition amp.h:50
MatchResourceType
Definition amp.h:90
@ MatchResourceAny
Definition amp.h:91
@ MatchResourceExact
Definition amp.h:93
@ MatchResourceInvalid
Definition amp.h:97
@ MatchResourceOther
Definition amp.h:95
DeliverType
Definition amp.h:71
@ DeliverStored
Definition amp.h:81
@ DeliverInvalid
Definition amp.h:83
@ DeliverNone
Definition amp.h:78
@ DeliverDirect
Definition amp.h:72
@ DeliverGateway
Definition amp.h:76
@ DeliverForward
Definition amp.h:74
virtual Tag * tag() const
Definition amp.cpp:167
const RuleList & rules() const
Definition amp.h:200
std::list< const Rule * > RuleList
Definition amp.h:175
An abstraction of a JID.
Definition jid.h:31
This is an abstraction of an XML element.
Definition tag.h:47
The namespace for the gloox library.
Definition adhoc.cpp:28