PWLib
1.10.10
|
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.4 2005/11/30 12:47:37 csoutheren 00028 * Removed tabs, reformatted some code, and changed tags for Doxygen 00029 * 00030 * Revision 1.3 2003/02/19 01:50:31 robertj 00031 * Change to make it easier to set a fault from the server function handler. 00032 * 00033 * Revision 1.2 2002/11/06 22:47:24 robertj 00034 * Fixed header comment (copyright etc) 00035 * 00036 * Revision 1.1 2002/10/02 08:54:34 craigs 00037 * Added support for XMLRPC server 00038 * 00039 */ 00040 00041 #ifndef _PXMLRPCSRVR_H 00042 #define _PXMLRPCSRVR_H 00043 00044 #ifdef P_USE_PRAGMA 00045 #pragma interface 00046 #endif 00047 00048 #include <ptclib/pxmlrpc.h> 00049 #include <ptclib/http.h> 00050 00051 00052 class PXMLRPCServerMethod : public PString 00053 { 00054 PCLASSINFO(PXMLRPCServerMethod, PString); 00055 public: 00056 PXMLRPCServerMethod(const PString & name) 00057 : PString(name) { } 00058 00059 PNotifier methodFunc; 00060 }; 00061 00062 00063 PSORTED_LIST(PXMLRPCServerMethodList, PXMLRPCServerMethod); 00064 00065 00066 class PXMLRPCServerResource : public PHTTPResource 00067 { 00068 PCLASSINFO(PXMLRPCServerResource, PHTTPResource); 00069 public: 00070 PXMLRPCServerResource(); 00071 PXMLRPCServerResource( 00072 const PHTTPAuthority & auth 00073 ); 00074 PXMLRPCServerResource( 00075 const PURL & url 00076 ); 00077 PXMLRPCServerResource( 00078 const PURL & url, 00079 const PHTTPAuthority & auth 00080 ); 00081 00082 // overrides from PHTTPResource 00083 BOOL LoadHeaders(PHTTPRequest & request); 00084 BOOL OnPOSTData(PHTTPRequest & request, const PStringToString & data); 00085 00086 // new functions 00087 virtual void OnXMLRPCRequest(const PString & body, PString & reply); 00088 virtual BOOL SetMethod(const PString & methodName, const PNotifier & func); 00089 void OnXMLRPCRequest(const PString & methodName, PXMLRPCBlock & request, PString & reply); 00090 00091 virtual PString FormatFault( 00092 PINDEX code, 00093 const PString & str 00094 ); 00095 00096 protected: 00097 PMutex methodMutex; 00098 PXMLRPCServerMethodList methodList; 00099 }; 00100 00101 00102 class PXMLRPCServerParms : public PObject 00103 { 00104 PCLASSINFO(PXMLRPCServerParms, PObject); 00105 public: 00106 PXMLRPCServerParms( 00107 PXMLRPCServerResource & _resource, 00108 PXMLRPCBlock & _request 00109 ) : resource(_resource), request(_request) { } 00110 00111 void SetFault( 00112 PINDEX code, 00113 const PString & text 00114 ) { request.SetFault(code, resource.FormatFault(code, text)); } 00115 00116 PXMLRPCServerResource & resource; 00117 PXMLRPCBlock & request; 00118 PXMLRPCBlock response; 00119 }; 00120 00121 00122 #endif 00123 00124