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

jabberoo-component.hh

00001 /* jabberoo-component.hh
00002  * Jabber client library
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  * 2002-03-05       IBM Corp.       Updated to libjudo 1.1.5
00029  * 2002-07-09       IBM Corp.       Added Roster::getSession()
00030  */
00031 
00032 #ifndef INCL_JABBEROO_COMPONENT_H
00033 #define INCL_JABBEROO_COMPONENT_H
00034 
00035 #include <jabberoofwd.h>
00036 
00037 #include <judo.hpp>
00038 #include <sigc++/object.h>
00039 #include <sigc++/signal.h>
00040 
00041 #include <string>
00042 #include <list>
00043 #include <map>
00044 #include <XPath.h>
00045 #include <packet.hh>
00046 
00047 namespace jabberoo {
00048     
00049 class ComponentSession:
00050     public judo::ElementStreamEventListener, public judo::ElementStream, public SigC::Object
00051 {
00052 public:
00053     enum ConnectionState
00054     {
00055         csNotConnected,
00056         csAwaitingAuth,
00057         csConnected
00058     };
00059 
00060     ComponentSession();
00061     virtual ~ComponentSession();
00062 
00063     const std::string& getComponentID() const
00064     { return _componentID; }
00065 
00066     ConnectionState getState() const
00067     { return _connState; }
00068 
00069     void connect(const std::string& server, const std::string& componentID, 
00070             const std::string& password);
00071 
00072     void disconnect();
00073 
00074     judo::XPath::Query* registerXPath(const std::string& query, ElementCallbackFunc f);
00075 
00076     void unregisterXPath(judo::XPath::Query* id);
00077 
00078     ComponentSession& operator>>(const char* buffer) { push(buffer, strlen(buffer)); return *this; } 
00079     ComponentSession& operator<<(const Packet& p) { evtTransmitXML(p.toString().c_str()); return *this;}
00080     ComponentSession& operator<<(const char* buffer) { evtTransmitXML(buffer); return *this;}
00081     virtual void push(const char* data, int datasz);
00082 
00083 
00084     SigC::Signal1<void, const char*, SigC::Marshal<void> >        evtTransmitXML;
00085     SigC::Signal0<void, SigC::Marshal<void> >         evtConnected;
00086 protected:
00087     virtual void onDocumentStart(judo::Element* t);
00088     virtual void onElement(judo::Element* t);
00089     virtual void onCDATA(judo::CDATA* c);
00090     virtual void onDocumentEnd();
00091 
00092 private:
00093     std::string _server;
00094     std::string _componentID;
00095     std::string _password;
00096     std::string _SessionID;
00097     ConnectionState _connState;
00098     std::list<judo::XPath::Query*> _XPaths;
00099     std::map<judo::XPath::Query*, ElementCallbackFunc> _XPCallbacks;
00100 };
00101 
00102 } // namespace jabberoo
00103 #endif //INCL_JABBEROO_COMPONENT_H

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