gloox  1.0.20
amp.h
1 /*
2  Copyright (c) 2006-2017 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 
25 namespace gloox
26 {
27 
28  class Tag;
29 
39  class GLOOX_API AMP : public StanzaExtension
40  {
41 
42  public:
47  {
51  ConditionInvalid
52  };
53 
58  {
59 
64  ActionInvalid
65  };
66 
71  {
72  DeliverDirect,
74  DeliverForward,
76  DeliverGateway,
78  DeliverNone,
81  DeliverStored,
83  DeliverInvalid
84  };
85 
90  {
91  MatchResourceAny,
93  MatchResourceExact,
95  MatchResourceOther,
97  MatchResourceInvalid
98  };
99 
103  enum Status
104  {
107  StatusInvalid
108  };
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__
std::list< const Rule * > RuleList
Definition: amp.h:175
DeliverType
Definition: amp.h:70
ActionType
Definition: amp.h:57
const RuleList & rules() const
Definition: amp.h:200
Status
Definition: amp.h:103
The namespace for the gloox library.
Definition: adhoc.cpp:27
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
virtual StanzaExtension * newInstance(const Tag *tag) const
Definition: amp.h:211
An abstraction of a JID.
Definition: jid.h:30
virtual StanzaExtension * clone() const
Definition: amp.h:220
ConditionType
Definition: amp.h:46
This is an implementation of XEP-0079 (Advanced Message Processing) as a StanzaExtension.
Definition: amp.h:39
MatchResourceType
Definition: amp.h:89
This is an abstraction of an XML element.
Definition: tag.h:46