Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members  

jabberoox.hh

00001 /* jabberoox.hh
00002  * Jabber client library extensions
00003  *
00004  * Original Code Copyright (C) 1999-2001 Dave Smith (dave@jabber.org)
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  * 
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  * Contributor(s): Julian Missig
00021  *
00022  * This Original Code has been modified by IBM Corporation. Modifications 
00023  * made by IBM described herein are Copyright (c) International Business 
00024  * Machines Corporation, 2002.
00025  *
00026  * Date             Modified by     Description of modification
00027  * 01/20/2002       IBM Corp.       Updated to libjudo 1.1.1
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                // Accessors
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                // Mutators
00062                Action& operator<<(Value v) 
00063                     { _value = v; return *this;}
00064                Action& operator<<(const std::string& param) {
00065                     _param = param; return *this; }
00066                // Translator
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                // Accessors
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                // Mutators
00092                Condition& operator<<(Value v) 
00093                     { _value = v; return *this;}
00094                Condition& operator<<(const std::string& param) 
00095                     { _param = param; return *this; }
00096                // Translator
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           // Constructors
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           // XML converter
00115           std::string toXML() const;
00116           // Accessors
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 /*RL: Klasa nie skompiluje się w ten sposób, robimy więc na shared_ptr */
00135          class Agent
00136 //        : public std::list<Agent>, public SigC::Object
00137 : public std::list<boost::shared_ptr<Agent> >, public SigC::Object
00138      {
00139      public:
00140                  typedef boost::shared_ptr<Agent> agentPtr; //RL
00141           Agent(const Agent& a);
00142           Agent(const std::string& jid, const judo::Element& baseElement, Session& s);
00143           ~Agent();
00144      public:
00145           // Events
00146       SigC::Signal1<void, bool, SigC::Marshal<void> > evtFetchComplete;
00147           // Accessors
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           // Info ops
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           // Action ops
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

Generated on Thu Jul 24 13:31:51 2003 for jabberoo by doxygen1.3-rc3