00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef INCL_JABBEROOX_HH
00031 #define INCL_JABBEROOX_HH
00032
00033 #include <string>
00034 #include <list>
00035 #include <jabberoofwd.h>
00036 #include <sigc++/object.h>
00037 #include <sigc++/signal.h>
00038 #include <boost/shared_ptr.hpp>
00039 namespace jabberoo
00040 {
00041 class Filter
00042 {
00043 public:
00044 class Action
00045 {
00046 public:
00047 enum Value
00048 {
00049 Invalid = -1, SetType, ForwardTo, ReplyWith, StoreOffline, Continue
00050 };
00051 Action(Value v = SetType, const std::string& param = "")
00052 : _value(v), _param(param) {}
00053
00054 bool requires_param()
00055 { return Action::ParamReq[_value]; }
00056 const std::string& param() const
00057 { return _param; }
00058 Value value() const
00059 { return _value; }
00060 std::string toXML() const;
00061
00062 Action& operator<<(Value v)
00063 { _value = v; return *this;}
00064 Action& operator<<(const std::string& param) {
00065 _param = param; return *this; }
00066
00067 static Value translate(const std::string& s);
00068 private:
00069 static const bool ParamReq[5];
00070 Value _value;
00071 std::string _param;
00072 };
00073
00074 class Condition
00075 {
00076 public:
00077 enum Value
00078 {
00079 Invalid = -1, Unavailable, From, MyResourceEquals, SubjectEquals, BodyEquals, ShowEquals, TypeEquals
00080 };
00081 Condition(Value v = Unavailable, const std::string& param = "")
00082 : _value(v), _param(param) {}
00083
00084 bool requires_param()
00085 { return Condition::ParamReq[_value]; }
00086 const std::string& param() const
00087 { return _param; }
00088 Value value() const
00089 { return _value; }
00090 std::string toXML() const;
00091
00092 Condition& operator<<(Value v)
00093 { _value = v; return *this;}
00094 Condition& operator<<(const std::string& param)
00095 { _param = param; return *this; }
00096
00097 static Value translate(const std::string& s);
00098 private:
00099 static const bool ParamReq[7];
00100 Value _value;
00101 std::string _param;
00102 };
00103
00104 typedef std::list<Action> ActionList;
00105 typedef std::list<Condition> ConditionList;
00106
00107 public:
00108
00109 Filter(const std::string& name);
00110 Filter(const judo::Element& rule);
00111 Filter(const Filter& f);
00112 bool operator==(const Filter& f) const { return &f == this; }
00113 bool operator==(const Filter& f) { return &f == this; }
00114
00115 std::string toXML() const;
00116
00117 ActionList& Actions() { return _actions; }
00118 ConditionList& Conditions() { return _conditions; }
00119 const std::string& Name() const { return _name; }
00120 void setName(const std::string& newname) { _name = newname; }
00121 private:
00122 ActionList _actions;
00123 ConditionList _conditions;
00124 std::string _name;
00125 };
00126
00127 class FilterList
00128 : public std::list<Filter>
00129 {
00130 public:
00131 FilterList(const judo::Element& query);
00132 std::string toXML() const;
00133 };
00134
00135 class Agent
00136
00137 : public std::list<boost::shared_ptr<Agent> >, public SigC::Object
00138 {
00139 public:
00140 typedef boost::shared_ptr<Agent> agentPtr;
00141 Agent(const Agent& a);
00142 Agent(const std::string& jid, const judo::Element& baseElement, Session& s);
00143 ~Agent();
00144 public:
00145
00146 SigC::Signal1<void, bool, SigC::Marshal<void> > evtFetchComplete;
00147
00148 const std::string& JID() const { return _jid; };
00149 const std::string& name() const { return _name; };
00150 const std::string& description() const { return _desc; };
00151 const std::string& service() const { return _service; };
00152 const std::string& transport() const { return _transport; };
00153
00154 bool isRegisterable() const { return _registerable; };
00155 bool isSearchable() const { return _searchable; };
00156 bool isGCCapable() const { return _gc_capable; };
00157 bool hasAgents() const { return _subagents; };
00158
00159 void requestRegister(ElementCallbackFunc f);
00160 void requestSearch(ElementCallbackFunc f);
00161 void fetch();
00162 protected:
00163 void on_fetch(const judo::Element& iq);
00164 private:
00165 std::string _jid;
00166 std::string _name;
00167 std::string _desc;
00168 std::string _service;
00169 std::string _transport;
00170 bool _registerable;
00171 bool _searchable;
00172 bool _subagents;
00173 bool _gc_capable;
00174 bool _fetchrequested;
00175 Session& _session;
00176 };
00177
00178 class AgentList
00179 : public std::list<Agent>
00180 {
00181 public:
00182 AgentList(const judo::Element& query, Session& s);
00183 void load(const judo::Element& query, Session& s);
00184 };
00185
00186
00187 };
00188
00189 #endif