From 2ea5ac0c43e3e28d2b1774f5367d099271a1da32 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Mon, 1 Jul 2024 13:34:50 +0200 Subject: #1111 Remove xmlrpc-epi --- indra/llmessage/CMakeLists.txt | 3 - indra/llmessage/llfiltersd2xmlrpc.cpp | 778 ---------------------------------- indra/llmessage/llfiltersd2xmlrpc.h | 271 ------------ 3 files changed, 1052 deletions(-) delete mode 100644 indra/llmessage/llfiltersd2xmlrpc.cpp delete mode 100644 indra/llmessage/llfiltersd2xmlrpc.h (limited to 'indra/llmessage') diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index 5322139304..b2757a7306 100644 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -27,7 +27,6 @@ set(llmessage_SOURCE_FILES lldatapacker.cpp lldispatcher.cpp llexperiencecache.cpp - llfiltersd2xmlrpc.cpp llgenericstreamingmessage.cpp llhost.cpp llhttpnode.cpp @@ -111,7 +110,6 @@ set(llmessage_HEADER_FILES lleventflags.h llexperiencecache.h llextendedstatus.h - llfiltersd2xmlrpc.h llfollowcamparams.h llgenericstreamingmessage.h llhost.h @@ -193,7 +191,6 @@ target_link_libraries( llfilesystem llmath llcorehttp - ll::xmlrpc-epi ) target_include_directories( llmessage INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/indra/llmessage/llfiltersd2xmlrpc.cpp b/indra/llmessage/llfiltersd2xmlrpc.cpp deleted file mode 100644 index 84b56d54bf..0000000000 --- a/indra/llmessage/llfiltersd2xmlrpc.cpp +++ /dev/null @@ -1,778 +0,0 @@ -/** - * @file llfiltersd2xmlrpc.cpp - * @author Phoenix - * @date 2005-04-26 - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -/** - * xml rpc request: - * - * - * examples.getStateName - * 41 - * - * - * - * xml rpc response: - * - * - * - * South Dakota - * - * - * - * xml rpc fault: - * - * - * - * - * faultCode4 - * faultString... - * - * - * - * - * llsd rpc request: - * - * { 'method':'...', 'parameter':...]} - * - * - * llsd rpc response: - * - * { 'response':... } - * - * - * llsd rpc fault: - * - * { 'fault': {'code':i..., 'description':'...'} } - * - * - */ - -#include "linden_common.h" -#include "llfiltersd2xmlrpc.h" - -#include -#include - -#ifdef LL_USESYSTEMLIBS -#include -#else -#include -#endif - -#include "apr_base64.h" - -#include "llbuffer.h" -#include "llbufferstream.h" -#include "llfasttimer.h" -#include "llmemorystream.h" -#include "llsd.h" -#include "llsdserialize.h" -#include "lluuid.h" - -// spammy mode -//#define LL_SPEW_STREAM_OUT_DEBUGGING 1 - -/** - * String constants - */ -static const char XML_HEADER[] = ""; -static const char XMLRPC_REQUEST_HEADER_1[] = ""; -static const char XMLRPC_REQUEST_HEADER_2[] = ""; -static const char XMLRPC_REQUEST_FOOTER[] = ""; -static const char XMLRPC_METHOD_RESPONSE_HEADER[] = ""; -static const char XMLRPC_METHOD_RESPONSE_FOOTER[] = ""; -static const char XMLRPC_RESPONSE_HEADER[] = ""; -static const char XMLRPC_RESPONSE_FOOTER[] = ""; -static const char XMLRPC_FAULT_1[] = "faultCode"; -static const char XMLRPC_FAULT_2[] = "faultString"; -static const char XMLRPC_FAULT_3[] = ""; -static const char LLSDRPC_RESPONSE_HEADER[] = "{'response':"; -static const char LLSDRPC_RESPONSE_FOOTER[] = "}"; -const char LLSDRPC_REQUEST_HEADER_1[] = "{'method':'"; -const char LLSDRPC_REQUEST_HEADER_2[] = "', 'parameter': "; -const char LLSDRPC_REQUEST_FOOTER[] = "}"; -static const char LLSDRPC_FAULT_HADER_1[] = "{ 'fault': {'code':i"; -static const char LLSDRPC_FAULT_HADER_2[] = ", 'description':"; -static const char LLSDRPC_FAULT_FOOTER[] = "} }"; -static const S32 DEFAULT_PRECISION = 20; - -/** - * LLFilterSD2XMLRPC - */ -LLFilterSD2XMLRPC::LLFilterSD2XMLRPC() -{ -} - -LLFilterSD2XMLRPC::~LLFilterSD2XMLRPC() -{ -} - -std::string xml_escape_string(const std::string& in) -{ - std::ostringstream out; - std::string::const_iterator it = in.begin(); - std::string::const_iterator end = in.end(); - for(; it != end; ++it) - { - switch((*it)) - { - case '<': - out << "<"; - break; - case '>': - out << ">"; - break; - case '&': - out << "&"; - break; - case '\'': - out << "'"; - break; - case '"': - out << """; - break; - default: - out << (*it); - break; - } - } - return out.str(); -} - -void LLFilterSD2XMLRPC::streamOut(std::ostream& ostr, const LLSD& sd) -{ - ostr << ""; - switch(sd.type()) - { - case LLSD::TypeMap: - { -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(map) BEGIN" << LL_ENDL; -#endif - ostr << ""; - if(ostr.fail()) - { - LL_INFOS() << "STREAM FAILURE writing struct" << LL_ENDL; - } - LLSD::map_const_iterator it = sd.beginMap(); - LLSD::map_const_iterator end = sd.endMap(); - for(; it != end; ++it) - { - ostr << "" << xml_escape_string((*it).first) - << ""; - streamOut(ostr, (*it).second); - if(ostr.fail()) - { - LL_INFOS() << "STREAM FAILURE writing '" << (*it).first - << "' with sd type " << (*it).second.type() << LL_ENDL; - } - ostr << ""; - } - ostr << ""; -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(map) END" << LL_ENDL; -#endif - break; - } - case LLSD::TypeArray: - { -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(array) BEGIN" << LL_ENDL; -#endif - ostr << ""; - LLSD::array_const_iterator it = sd.beginArray(); - LLSD::array_const_iterator end = sd.endArray(); - for(; it != end; ++it) - { - streamOut(ostr, *it); - if(ostr.fail()) - { - LL_INFOS() << "STREAM FAILURE writing array element sd type " - << (*it).type() << LL_ENDL; - } - } -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(array) END" << LL_ENDL; -#endif - ostr << ""; - break; - } - case LLSD::TypeUndefined: - // treat undefined as a bool with a false value. - case LLSD::TypeBoolean: -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(bool)" << LL_ENDL; -#endif - ostr << "" << (sd.asBoolean() ? "1" : "0") << ""; - break; - case LLSD::TypeInteger: -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(int)" << LL_ENDL; -#endif - ostr << "" << sd.asInteger() << ""; - break; - case LLSD::TypeReal: -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(real)" << LL_ENDL; -#endif - ostr << "" << sd.asReal() << ""; - break; - case LLSD::TypeString: -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(string)" << LL_ENDL; -#endif - ostr << "" << xml_escape_string(sd.asString()) << ""; - break; - case LLSD::TypeUUID: -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(uuid)" << LL_ENDL; -#endif - // serialize it as a string - ostr << "" << sd.asString() << ""; - break; - case LLSD::TypeURI: - { -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(uri)" << LL_ENDL; -#endif - // serialize it as a string - ostr << "" << xml_escape_string(sd.asString()) << ""; - break; - } - case LLSD::TypeBinary: - { -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(binary)" << LL_ENDL; -#endif - // this is pretty inefficient, but we'll deal with that - // problem when it becomes one. - ostr << ""; - LLSD::Binary buffer = sd.asBinary(); - if(!buffer.empty()) - { - // *TODO: convert to LLBase64 - int b64_buffer_length = apr_base64_encode_len(static_cast(buffer.size())); - char* b64_buffer = new char[b64_buffer_length]; - b64_buffer_length = apr_base64_encode_binary( - b64_buffer, - &buffer[0], - static_cast(buffer.size())); - ostr.write(b64_buffer, b64_buffer_length - 1); - delete[] b64_buffer; - } - ostr << ""; - break; - } - case LLSD::TypeDate: -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(date)" << LL_ENDL; -#endif - // no need to escape this since it will be alpha-numeric. - ostr << "" << sd.asString() << ""; - break; - default: - // unhandled type - LL_WARNS() << "Unhandled structured data type: " << sd.type() - << LL_ENDL; - break; - } - ostr << ""; -} - -/** - * LLFilterSD2XMLRPCResponse - */ - -LLFilterSD2XMLRPCResponse::LLFilterSD2XMLRPCResponse() -{ -} - -LLFilterSD2XMLRPCResponse::~LLFilterSD2XMLRPCResponse() -{ -} - - -// virtual -LLIOPipe::EStatus LLFilterSD2XMLRPCResponse::process_impl( - const LLChannelDescriptors& channels, - buffer_ptr_t& buffer, - bool& eos, - LLSD& context, - LLPumpIO* pump) -{ - LL_PROFILE_ZONE_SCOPED; - - PUMP_DEBUG; - // This pipe does not work if it does not have everyting. This - // could be addressed by making a stream parser for llsd which - // handled partial information. - if(!eos) - { - return STATUS_BREAK; - } - - PUMP_DEBUG; - // we have everyting in the buffer, so turn the structure data rpc - // response into an xml rpc response. - LLBufferStream stream(channels, buffer.get()); - stream << XML_HEADER << XMLRPC_METHOD_RESPONSE_HEADER; - LLSD sd; - LLSDSerialize::fromNotation(sd, stream, buffer->count(channels.in())); - - PUMP_DEBUG; - LLIOPipe::EStatus rv = STATUS_ERROR; - if(sd.has("response")) - { - PUMP_DEBUG; - // it is a normal response. pack it up and ship it out. - stream.precision(DEFAULT_PRECISION); - stream << XMLRPC_RESPONSE_HEADER; - streamOut(stream, sd["response"]); - stream << XMLRPC_RESPONSE_FOOTER << XMLRPC_METHOD_RESPONSE_FOOTER; - rv = STATUS_DONE; - } - else if(sd.has("fault")) - { - PUMP_DEBUG; - // it is a fault. - stream << XMLRPC_FAULT_1 << sd["fault"]["code"].asInteger() - << XMLRPC_FAULT_2 - << xml_escape_string(sd["fault"]["description"].asString()) - << XMLRPC_FAULT_3 << XMLRPC_METHOD_RESPONSE_FOOTER; - rv = STATUS_DONE; - } - else - { - LL_WARNS() << "Unable to determine the type of LLSD response." << LL_ENDL; - } - PUMP_DEBUG; - return rv; -} - -/** - * LLFilterSD2XMLRPCRequest - */ -LLFilterSD2XMLRPCRequest::LLFilterSD2XMLRPCRequest() -{ -} - -LLFilterSD2XMLRPCRequest::LLFilterSD2XMLRPCRequest(const char* method) -{ - if(method) - { - mMethod.assign(method); - } -} - -LLFilterSD2XMLRPCRequest::~LLFilterSD2XMLRPCRequest() -{ -} - -// virtual -LLIOPipe::EStatus LLFilterSD2XMLRPCRequest::process_impl( - const LLChannelDescriptors& channels, - buffer_ptr_t& buffer, - bool& eos, - LLSD& context, - LLPumpIO* pump) -{ - LL_PROFILE_ZONE_SCOPED; - // This pipe does not work if it does not have everyting. This - // could be addressed by making a stream parser for llsd which - // handled partial information. - PUMP_DEBUG; - if(!eos) - { - LL_INFOS() << "!eos" << LL_ENDL; - return STATUS_BREAK; - } - - // See if we can parse it - LLBufferStream stream(channels, buffer.get()); - LLSD sd; - LLSDSerialize::fromNotation(sd, stream, buffer->count(channels.in())); - if(stream.fail()) - { - LL_INFOS() << "STREAM FAILURE reading structure data." << LL_ENDL; - } - - PUMP_DEBUG; - // We can get the method and parameters from either the member - // function or passed in via the buffer. We prefer the buffer if - // we found a parameter and a method, or fall back to using - // mMethod and putting everyting in the buffer into the parameter. - std::string method; - LLSD param_sd; - if(sd.has("method") && sd.has("parameter")) - { - method = sd["method"].asString(); - param_sd = sd["parameter"]; - } - else - { - method = mMethod; - param_sd = sd; - } - if(method.empty()) - { - LL_WARNS() << "SD -> XML Request no method found." << LL_ENDL; - return STATUS_ERROR; - } - - PUMP_DEBUG; - // We have a method, and some kind of parameter, so package it up - // and send it out. - LLBufferStream ostream(channels, buffer.get()); - ostream.precision(DEFAULT_PRECISION); - if(ostream.fail()) - { - LL_INFOS() << "STREAM FAILURE setting precision" << LL_ENDL; - } - ostream << XML_HEADER << XMLRPC_REQUEST_HEADER_1 - << xml_escape_string(method) << XMLRPC_REQUEST_HEADER_2; - if(ostream.fail()) - { - LL_INFOS() << "STREAM FAILURE writing method headers" << LL_ENDL; - } - switch(param_sd.type()) - { - case LLSD::TypeMap: - // If the params are a map, then we do not want to iterate - // through them since the iterators returned will be map - // ordered un-named values, which will lose the names, and - // only stream the values, turning it into an array. - ostream << ""; - streamOut(ostream, param_sd); - ostream << ""; - break; - case LLSD::TypeArray: - { - - LLSD::array_iterator it = param_sd.beginArray(); - LLSD::array_iterator end = param_sd.endArray(); - for(; it != end; ++it) - { - ostream << ""; - streamOut(ostream, *it); - ostream << ""; - } - break; - } - default: - ostream << ""; - streamOut(ostream, param_sd); - ostream << ""; - break; - } - - stream << XMLRPC_REQUEST_FOOTER; - return STATUS_DONE; -} - -/** - * LLFilterXMLRPCResponse2LLSD - */ -// this is a c function here since it's really an implementation -// detail that requires a header file just get the definition of the -// parameters. -LLIOPipe::EStatus stream_out(std::ostream& ostr, XMLRPC_VALUE value) -{ - XMLRPC_VALUE_TYPE_EASY type = XMLRPC_GetValueTypeEasy(value); - LLIOPipe::EStatus status = LLIOPipe::STATUS_OK; - switch(type) - { - case xmlrpc_type_base64: - { - S32 len = XMLRPC_GetValueStringLen(value); - const char* buf = XMLRPC_GetValueBase64(value); - ostr << " b("; - if((len > 0) && buf) - { - ostr << len << ")\""; - ostr.write(buf, len); - ostr << "\""; - } - else - { - ostr << "0)\"\""; - } - break; - } - case xmlrpc_type_boolean: - //LL_DEBUGS() << "stream_out() bool" << LL_ENDL; - ostr << " " << (XMLRPC_GetValueBoolean(value) ? "true" : "false"); - break; - case xmlrpc_type_datetime: - ostr << " d\"" << XMLRPC_GetValueDateTime_ISO8601(value) << "\""; - break; - case xmlrpc_type_double: - ostr << " r" << XMLRPC_GetValueDouble(value); - //LL_DEBUGS() << "stream_out() double" << XMLRPC_GetValueDouble(value) - // << LL_ENDL; - break; - case xmlrpc_type_int: - ostr << " i" << XMLRPC_GetValueInt(value); - //LL_DEBUGS() << "stream_out() integer:" << XMLRPC_GetValueInt(value) - // << LL_ENDL; - break; - case xmlrpc_type_string: - //LL_DEBUGS() << "stream_out() string: " << str << LL_ENDL; - ostr << " s(" << XMLRPC_GetValueStringLen(value) << ")'" - << XMLRPC_GetValueString(value) << "'"; - break; - case xmlrpc_type_array: // vector - case xmlrpc_type_mixed: // vector - { - //LL_DEBUGS() << "stream_out() array" << LL_ENDL; - ostr << " ["; - U32 needs_comma = 0; - XMLRPC_VALUE current = XMLRPC_VectorRewind(value); - while(current && (LLIOPipe::STATUS_OK == status)) - { - if(needs_comma++) ostr << ","; - status = stream_out(ostr, current); - current = XMLRPC_VectorNext(value); - } - ostr << "]"; - break; - } - case xmlrpc_type_struct: // still vector - { - //LL_DEBUGS() << "stream_out() struct" << LL_ENDL; - ostr << " {"; - std::string name; - U32 needs_comma = 0; - XMLRPC_VALUE current = XMLRPC_VectorRewind(value); - while(current && (LLIOPipe::STATUS_OK == status)) - { - if(needs_comma++) ostr << ","; - name.assign(XMLRPC_GetValueID(current)); - ostr << "'" << LLSDNotationFormatter::escapeString(name) << "':"; - status = stream_out(ostr, current); - current = XMLRPC_VectorNext(value); - } - ostr << "}"; - break; - } - case xmlrpc_type_empty: - case xmlrpc_type_none: - default: - status = LLIOPipe::STATUS_ERROR; - LL_WARNS() << "Found an empty xmlrpc type.." << LL_ENDL; - // not much we can do here... - break; - }; - return status; -} - -LLFilterXMLRPCResponse2LLSD::LLFilterXMLRPCResponse2LLSD() -{ -} - -LLFilterXMLRPCResponse2LLSD::~LLFilterXMLRPCResponse2LLSD() -{ -} - -LLIOPipe::EStatus LLFilterXMLRPCResponse2LLSD::process_impl( - const LLChannelDescriptors& channels, - buffer_ptr_t& buffer, - bool& eos, - LLSD& context, - LLPumpIO* pump) -{ - LL_PROFILE_ZONE_SCOPED; - - PUMP_DEBUG; - if(!eos) return STATUS_BREAK; - if(!buffer) return STATUS_ERROR; - - PUMP_DEBUG; - // *FIX: This technique for reading data is far from optimal. We - // need to have some kind of istream interface into the xml - // parser... - S32 bytes = buffer->countAfter(channels.in(), NULL); - if(!bytes) return STATUS_ERROR; - char* buf = new char[bytes + 1]; - buf[bytes] = '\0'; - buffer->readAfter(channels.in(), NULL, (U8*)buf, bytes); - - //LL_DEBUGS() << "xmlrpc response: " << buf << LL_ENDL; - - PUMP_DEBUG; - XMLRPC_REQUEST response = XMLRPC_REQUEST_FromXML( - buf, - bytes, - NULL); - if(!response) - { - LL_WARNS() << "XML -> SD Response unable to parse xml." << LL_ENDL; - delete[] buf; - return STATUS_ERROR; - } - - PUMP_DEBUG; - LLBufferStream stream(channels, buffer.get()); - stream.precision(DEFAULT_PRECISION); - if(XMLRPC_ResponseIsFault(response)) - { - PUMP_DEBUG; - stream << LLSDRPC_FAULT_HADER_1 - << XMLRPC_GetResponseFaultCode(response) - << LLSDRPC_FAULT_HADER_2; - const char* fault_str = XMLRPC_GetResponseFaultString(response); - std::string fault_string; - if(fault_str) - { - fault_string.assign(fault_str); - } - stream << "'" << LLSDNotationFormatter::escapeString(fault_string) - << "'" <countAfter(channels.in(), NULL); - if(!bytes) return STATUS_ERROR; - char* buf = new char[bytes + 1]; - buf[bytes] = '\0'; - buffer->readAfter(channels.in(), NULL, (U8*)buf, bytes); - - //LL_DEBUGS() << "xmlrpc request: " << buf << LL_ENDL; - - // Check the value in the buffer. XMLRPC_REQUEST_FromXML will report a error code 4 if - // values that are less than 0x20 are passed to it, except - // 0x09: Horizontal tab; 0x0a: New Line; 0x0d: Carriage - U8* cur_pBuf = (U8*)buf; - U8 cur_char; - for (S32 i=0; i SD Request process parse error." << LL_ENDL; - delete[] buf; - return STATUS_ERROR; - } - - PUMP_DEBUG; - LLBufferStream stream(channels, buffer.get()); - stream.precision(DEFAULT_PRECISION); - const char* name = XMLRPC_RequestGetMethodName(request); - stream << LLSDRPC_REQUEST_HEADER_1 << (name ? name : "") - << LLSDRPC_REQUEST_HEADER_2; - XMLRPC_VALUE param = XMLRPC_RequestGetData(request); - if(param) - { - PUMP_DEBUG; - S32 size = XMLRPC_VectorSize(param); - if(size > 1) - { - // if there are multiple parameters, stuff the values into - // an array so that the next step in the chain can read them. - stream << "["; - } - XMLRPC_VALUE current = XMLRPC_VectorRewind(param); - bool needs_comma = false; - while(current) - { - if(needs_comma) - { - stream << ","; - } - needs_comma = true; - stream_out(stream, current); - current = XMLRPC_VectorNext(param); - } - if(size > 1) - { - // close the array - stream << "]"; - } - } - stream << LLSDRPC_REQUEST_FOOTER; - XMLRPC_RequestFree(request, 1); - delete[] buf; - PUMP_DEBUG; - return STATUS_DONE; -} - diff --git a/indra/llmessage/llfiltersd2xmlrpc.h b/indra/llmessage/llfiltersd2xmlrpc.h deleted file mode 100644 index 55938d3e2b..0000000000 --- a/indra/llmessage/llfiltersd2xmlrpc.h +++ /dev/null @@ -1,271 +0,0 @@ -/** - * @file llfiltersd2xmlrpc.h - * @author Phoenix - * @date 2005-04-26 - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLFILTERSD2XMLRPC_H -#define LL_LLFILTERSD2XMLRPC_H - -/** - * These classes implement the necessary pipes for translating between - * xmlrpc and llsd rpc. The llsd rpcs mechanism was developed as an - * extensible and easy to parse serialization grammer which maintains - * a time efficient in-memory representation. - */ - -#include -#include "lliopipe.h" - -/** - * @class LLFilterSD2XMLRPC - * @brief Filter from serialized LLSD to an XMLRPC method call - * - * This clas provides common functionality for the LLFilterSD2XMLRPRC - * request and response classes. - */ -class LLFilterSD2XMLRPC : public LLIOPipe -{ -public: - LLFilterSD2XMLRPC(); - virtual ~LLFilterSD2XMLRPC(); - -protected: - /** - * @brief helper method - */ - void streamOut(std::ostream& ostr, const LLSD& sd); -}; - -/** - * @class LLFilterSD2XMLRPCResponse - * @brief Filter from serialized LLSD to an XMLRPC response - * - * This class filters a serialized LLSD object to an xmlrpc - * repsonse. Since resonses are limited to a single param, the xmlrprc - * response only serializes it as one object. - * This class correctly handles normal llsd responses as well as llsd - * rpc faults. - * - * For example, if given: - * {'response':[ i200, r3.4, {"foo":"bar"} ]} - * Would generate: - * - * - * - * 200 - * 3.4 - * - * foobar - * - * - * - */ -class LLFilterSD2XMLRPCResponse : public LLFilterSD2XMLRPC -{ -public: - // constructor - LLFilterSD2XMLRPCResponse(); - - // destructor - virtual ~LLFilterSD2XMLRPCResponse(); - - /* @name LLIOPipe virtual implementations - */ - //@{ -protected: - /** - * @brief Process the data in buffer. - */ - virtual EStatus process_impl( - const LLChannelDescriptors& channels, - buffer_ptr_t& buffer, - bool& eos, - LLSD& context, - LLPumpIO* pump); - //@} -}; - -/** - * @class LLFilterSD2XMLRPCRequest - * @brief Filter from serialized LLSD to an XMLRPC method call - * - * This class will accept any kind of serialized LLSD object, but you - * probably want to have an array on the outer boundary since this - * object will interpret each element in the top level LLSD as a - * parameter into the xmlrpc spec. - * - * For example, you would represent 3 params as: - * - * {'method'='foo', 'parameter':[i200, r3.4, {"foo":"bar"}]} - * - * To generate: - * - * - * - * 200 - * 3.4 - * - * foobar - * - * - * - * This class will accept 2 different kinds of encodings. The first - * just an array of params as long as you specify the method in the - * constructor. It will also accept a structured data in the form: - * {'method':'$method_name', 'parameter':[...] } In the latter form, the - * encoded 'method' will be used regardless of the construction of the - * object, and the 'parameter' will be used as parameter to the call. - */ -class LLFilterSD2XMLRPCRequest : public LLFilterSD2XMLRPC -{ -public: - // constructor - LLFilterSD2XMLRPCRequest(); - - // constructor - LLFilterSD2XMLRPCRequest(const char* method); - - // destructor - virtual ~LLFilterSD2XMLRPCRequest(); - - /* @name LLIOPipe virtual implementations - */ - //@{ -protected: - /** - * @brief Process the data in buffer. - */ - virtual EStatus process_impl( - const LLChannelDescriptors& channels, - buffer_ptr_t& buffer, - bool& eos, - LLSD& context, - LLPumpIO* pump); - //@} - -protected: - // The method name of this request. - std::string mMethod; -}; - -/** - * @class LLFilterXMLRPCResponse2LLSD - * @brief Filter from serialized XMLRPC method response to LLSD - * - * The xmlrpc spec states that responses can only have one element - * which can be of any supported type. - * This takes in xml of the form: - * - * - * ok - * - * And processes it into: - * 'ok' - * - */ -class LLFilterXMLRPCResponse2LLSD : public LLIOPipe -{ -public: - // constructor - LLFilterXMLRPCResponse2LLSD(); - - // destructor - virtual ~LLFilterXMLRPCResponse2LLSD(); - - /* @name LLIOPipe virtual implementations - */ - //@{ -protected: - /** - * @brief Process the data in buffer. - */ - virtual EStatus process_impl( - const LLChannelDescriptors& channels, - buffer_ptr_t& buffer, - bool& eos, - LLSD& context, - LLPumpIO* pump); - //@} - -protected: -}; - -/** - * @class LLFilterXMLRPCRequest2LLSD - * @brief Filter from serialized XMLRPC method call to LLSD - * - * This takes in xml of the form: - * - * - * repeat - * - * 4 - * ok - * - * - * And processes it into: - * { 'method':'repeat', 'params':[i4, 'ok'] } - */ -class LLFilterXMLRPCRequest2LLSD : public LLIOPipe -{ -public: - // constructor - LLFilterXMLRPCRequest2LLSD(); - - // destructor - virtual ~LLFilterXMLRPCRequest2LLSD(); - - /* @name LLIOPipe virtual implementations - */ - //@{ -protected: - /** - * @brief Process the data in buffer. - */ - virtual EStatus process_impl( - const LLChannelDescriptors& channels, - buffer_ptr_t& buffer, - bool& eos, - LLSD& context, - LLPumpIO* pump); - //@} - -protected: -}; - -/** - * @brief This function takes string, and escapes it appropritately - * for inclusion as xml data. - */ -std::string xml_escape_string(const std::string& in); - -/** - * @brief Externally available constants - */ -extern const char LLSDRPC_REQUEST_HEADER_1[]; -extern const char LLSDRPC_REQUEST_HEADER_2[]; -extern const char LLSDRPC_REQUEST_FOOTER[]; - -#endif // LL_LLFILTERSD2XMLRPC_H -- cgit v1.2.3