amp.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef AMP_H__
00015 #define AMP_H__
00016
00017 #include "stanzaextension.h"
00018 #include "jid.h"
00019
00020 #include <string>
00021 #include <list>
00022
00023 #include <ctime>
00024
00025 namespace gloox
00026 {
00027
00028 class Tag;
00029
00039 class GLOOX_API AMP : public StanzaExtension
00040 {
00041
00042 public:
00046 enum ConditionType
00047 {
00048 ConditionDeliver,
00049 ConditionExpireAt,
00050 ConditionMatchResource,
00051 ConditionInvalid
00052 };
00053
00057 enum ActionType
00058 {
00059
00060 ActionAlert,
00061 ActionError,
00062 ActionDrop,
00063 ActionNotify,
00064 ActionInvalid
00065 };
00066
00070 enum DeliverType
00071 {
00072 DeliverDirect,
00074 DeliverForward,
00076 DeliverGateway,
00078 DeliverNone,
00081 DeliverStored,
00083 DeliverInvalid
00084 };
00085
00089 enum MatchResourceType
00090 {
00091 MatchResourceAny,
00093 MatchResourceExact,
00095 MatchResourceOther,
00097 MatchResourceInvalid
00098 };
00099
00103 enum Status
00104 {
00105 StatusAlert,
00106 StatusNotify,
00107 StatusInvalid
00108 };
00109
00116 class GLOOX_API Rule
00117 {
00118 public:
00124 Rule( DeliverType deliver, ActionType action );
00125
00131 Rule( const std::string& date, ActionType action );
00132
00138 Rule( MatchResourceType match, ActionType action );
00139
00146 Rule( const std::string& condition, const std::string& action,
00147 const std::string& value );
00148
00152 ~Rule();
00153
00158 Tag* tag() const;
00159
00160 private:
00161 ConditionType m_condition;
00162 union
00163 {
00164 DeliverType m_deliver;
00165 MatchResourceType m_matchresource;
00166 std::string* m_expireat;
00167 };
00168 ActionType m_action;
00169
00170 };
00171
00175 typedef std::list<const Rule*> RuleList;
00176
00182 AMP( bool perhop = false );
00183
00188 AMP( const Tag* tag );
00189
00194 void addRule( const Rule* rule );
00195
00200 const RuleList& rules() const { return m_rules; }
00201
00205 virtual ~AMP();
00206
00207
00208 virtual const std::string& filterString() const;
00209
00210
00211 virtual StanzaExtension* newInstance( const Tag* tag ) const
00212 {
00213 return new AMP( tag );
00214 }
00215
00216
00217 virtual Tag* tag() const;
00218
00219
00220 virtual StanzaExtension* clone() const
00221 {
00222 AMP* a = new AMP();
00223 a->m_perhop = m_perhop;
00224 RuleList::const_iterator it = m_rules.begin();
00225 for( ; it != m_rules.end(); ++it )
00226 a->m_rules.push_back( new Rule( *(*it) ) );
00227 a->m_status = m_status;
00228 a->m_from = m_from;
00229 a->m_to = m_to;
00230 return a;
00231 }
00232
00233 private:
00234 bool m_perhop;
00235 RuleList m_rules;
00236 Status m_status;
00237 JID m_from;
00238 JID m_to;
00239 };
00240
00241 }
00242
00243 #endif // AMP_H__