Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

pxmlrpcs.h

Go to the documentation of this file.
00001 /*
00002  * pxmlrpcs.h
00003  *
00004  * XML parser support
00005  *
00006  * Portable Windows Library
00007  *
00008  * Copyright (c) 2002 Equivalence Pty. Ltd.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Portable Windows Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Contributor(s): ______________________________________.
00025  *
00026  * $Log: pxmlrpcs.h,v $
00027  * Revision 1.3  2003/02/19 01:50:31  robertj
00028  * Change to make it easier to set a fault from the server function handler.
00029  *
00030  * Revision 1.2  2002/11/06 22:47:24  robertj
00031  * Fixed header comment (copyright etc)
00032  *
00033  * Revision 1.1  2002/10/02 08:54:34  craigs
00034  * Added support for XMLRPC server
00035  *
00036  */
00037 
00038 #ifndef _PXMLRPCSRVR_H
00039 #define _PXMLRPCSRVR_H
00040 
00041 #ifdef P_USE_PRAGMA
00042 #pragma interface
00043 #endif
00044 
00045 #include <ptclib/pxmlrpc.h>
00046 #include <ptclib/http.h>
00047 
00048 
00049 class PXMLRPCServerMethod : public PString
00050 {
00051   PCLASSINFO(PXMLRPCServerMethod, PString);
00052   public:
00053     PXMLRPCServerMethod(const PString & name)
00054       : PString(name) { }
00055 
00056     PNotifier methodFunc;
00057 };
00058 
00059 
00060 PSORTED_LIST(PXMLRPCServerMethodList, PXMLRPCServerMethod);
00061 
00062 
00063 class PXMLRPCServerResource : public PHTTPResource
00064 {
00065   PCLASSINFO(PXMLRPCServerResource, PHTTPResource);
00066   public:
00067     PXMLRPCServerResource();
00068     PXMLRPCServerResource(
00069       const PHTTPAuthority & auth    // Authorisation for the resource.
00070     );
00071     PXMLRPCServerResource(
00072       const PURL & url               // Name of the resource in URL space.
00073     );
00074     PXMLRPCServerResource(
00075       const PURL & url,              // Name of the resource in URL space.
00076       const PHTTPAuthority & auth    // Authorisation for the resource.
00077     );
00078 
00079     // overrides from PHTTPResource
00080     BOOL LoadHeaders(PHTTPRequest & request);
00081     BOOL OnPOSTData(PHTTPRequest & request, const PStringToString & data);
00082 
00083     // new functions
00084     virtual void OnXMLRPCRequest(const PString & body, PString & reply);
00085     virtual BOOL SetMethod(const PString & methodName, const PNotifier & func);
00086     void OnXMLRPCRequest(const PString & methodName, PXMLRPCBlock & request, PString & reply);
00087 
00088     virtual PString FormatFault(
00089       PINDEX code,
00090       const PString & str
00091     );
00092 
00093   protected:
00094     PMutex methodMutex;
00095     PXMLRPCServerMethodList methodList;
00096 };
00097 
00098 
00099 class PXMLRPCServerParms : public PObject 
00100 {
00101   PCLASSINFO(PXMLRPCServerParms, PObject);
00102   public:
00103     PXMLRPCServerParms(
00104       PXMLRPCServerResource & _resource,
00105       PXMLRPCBlock & _request
00106     ) : resource(_resource), request(_request) { }
00107 
00108     void SetFault(
00109       PINDEX code,
00110       const PString & text
00111     ) { request.SetFault(code, resource.FormatFault(code, text)); }
00112 
00113     PXMLRPCServerResource & resource;
00114     PXMLRPCBlock & request;
00115     PXMLRPCBlock response;
00116 };
00117 
00118 
00119 #endif
00120 
00121 

Generated on Tue Mar 15 10:44:52 2005 for PWLib by  doxygen 1.4.0