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 <time.h>
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 private:
00220 bool m_perhop;
00221 RuleList m_rules;
00222 Status m_status;
00223 JID m_from;
00224 JID m_to;
00225 };
00226
00227 }
00228
00229 #endif // AMP_H__