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  * $Revision: 21788 $
00027  * $Author: rjongbloed $
00028  * $Date: 2008-12-11 23:42:13 -0600 (Thu, 11 Dec 2008) $
00029  */
00030 
00031 #ifndef PTLIB_XMLRPCSRVR_H
00032 #define PTLIB_XMLRPCSRVR_H
00033 
00034 #ifdef P_USE_PRAGMA
00035 #pragma interface
00036 #endif
00037 
00038 #include <ptclib/pxmlrpc.h>
00039 #include <ptclib/http.h>
00040 
00041 
00042 class PXMLRPCServerMethod : public PString
00043 {
00044   PCLASSINFO(PXMLRPCServerMethod, PString);
00045   public:
00046     PXMLRPCServerMethod(const PString & name)
00047       : PString(name) { }
00048 
00049     PNotifier methodFunc;
00050 };
00051 
00052 
00053 PSORTED_LIST(PXMLRPCServerMethodList, PXMLRPCServerMethod);
00054 
00055 
00056 class PXMLRPCServerResource : public PHTTPResource
00057 {
00058   PCLASSINFO(PXMLRPCServerResource, PHTTPResource);
00059   public:
00060     PXMLRPCServerResource();
00061     PXMLRPCServerResource(
00062       const PHTTPAuthority & auth    
00063     );
00064     PXMLRPCServerResource(
00065       const PURL & url               
00066     );
00067     PXMLRPCServerResource(
00068       const PURL & url,              
00069       const PHTTPAuthority & auth    
00070     );
00071 
00072     // overrides from PHTTPResource
00073     PBoolean LoadHeaders(PHTTPRequest & request);
00074     PBoolean OnPOSTData(PHTTPRequest & request, const PStringToString & data);
00075 
00076     // new functions
00077     virtual void OnXMLRPCRequest(const PString & body, PString & reply);
00078     virtual PBoolean SetMethod(const PString & methodName, const PNotifier & func);
00079     void OnXMLRPCRequest(const PString & methodName, PXMLRPCBlock & request, PString & reply);
00080 
00081     virtual PString FormatFault(
00082       PINDEX code,
00083       const PString & str
00084     );
00085 
00086   protected:
00087     PMutex methodMutex;
00088     PXMLRPCServerMethodList methodList;
00089 };
00090 
00091 
00092 class PXMLRPCServerParms : public PObject 
00093 {
00094   PCLASSINFO(PXMLRPCServerParms, PObject);
00095   public:
00096     PXMLRPCServerParms(
00097       PXMLRPCServerResource & res,
00098       PXMLRPCBlock & req
00099     ) : resource(res), request(req) { }
00100 
00101     void SetFault(
00102       PINDEX code,
00103       const PString & text
00104     ) { request.SetFault(code, resource.FormatFault(code, text)); }
00105 
00106     PXMLRPCServerResource & resource;
00107     PXMLRPCBlock & request;
00108     PXMLRPCBlock response;
00109 };
00110 
00111 
00112 #endif // PTLIB_XMLRPCSRVR_H
00113 
00114 
00115 // End Of File ///////////////////////////////////////////////////////////////

Generated on Thu May 27 01:36:48 2010 for PTLib by  doxygen 1.4.7