Add more compatibility stuff in xmlrpcs.inc; split the function used to serve system...
authorgggeek <giunta.gaetano@gmail.com>
Mon, 25 May 2015 18:47:00 +0000 (19:47 +0100)
committergggeek <giunta.gaetano@gmail.com>
Mon, 25 May 2015 18:47:00 +0000 (19:47 +0100)
lib/xmlrpc_wrappers.inc
lib/xmlrpcs.inc
src/Server.php

index c9e3449..021b1ce 100644 (file)
@@ -2,7 +2,7 @@
 
 /******************************************************************************
  *
- *** DEPRECATED ***
+ * *** DEPRECATED ***
  *
  * This file is only used to insure backwards compatibility
  * with the API of the library <= rev. 3
@@ -119,7 +119,7 @@ function build_remote_method_wrapper_code($client, $methodName, $xmlrpcFuncName,
     $code = "function $xmlrpcFuncName (";
     if ($clientCopyMode < 2) {
         // client copy mode 0 or 1 == partial / full client copy in emitted code
-        $innerCode = $this->build_client_wrapper_code($client, $clientCopyMode, $prefix, $namespace);
+        $innerCode = build_client_wrapper_code($client, $clientCopyMode, $prefix, $namespace);
         $innerCode .= "\$client->setDebug(\$debug);\n";
         $this_ = '';
     } else {
@@ -185,3 +185,30 @@ function build_remote_method_wrapper_code($client, $methodName, $xmlrpcFuncName,
 
     return array('source' => $code, 'docstring' => $mDesc);
 }
+
+/**
+ * @deprecated
+ */
+function build_client_wrapper_code($client, $verbatim_client_copy, $prefix='xmlrpc')
+{
+    $code = "\$client = new {$prefix}_client('".str_replace("'", "\'", $client->path).
+        "', '" . str_replace("'", "\'", $client->server) . "', $client->port);\n";
+
+    // copy all client fields to the client that will be generated runtime
+    // (this provides for future expansion or subclassing of client obj)
+    if ($verbatim_client_copy)
+    {
+        foreach($client as $fld => $val)
+        {
+            if($fld != 'debug' && $fld != 'return_type')
+            {
+                $val = var_export($val, true);
+                $code .= "\$client->$fld = $val;\n";
+            }
+        }
+    }
+    // only make sure that client always returns the correct data type
+    $code .= "\$client->return_type = '{$prefix}vals';\n";
+    //$code .= "\$client->setDebug(\$debug);\n";
+    return $code;
+}
\ No newline at end of file
index aa6a242..71cde1f 100644 (file)
@@ -36,7 +36,7 @@
 
 /******************************************************************************
  *
- *** DEPRECATED ***
+ * *** DEPRECATED ***
  *
  * This file is only used to insure backwards compatibility
  * with the API of the library <= rev. 3
@@ -59,7 +59,63 @@ class xmlrpc_server extends PhpXmlRpc\Server
 
 /* Expose as global functions the ones which are now class methods */
 
+/**
+ * @see PhpXmlRpc\Server::xmlrpc_debugmsg
+ * @param string $m
+ */
 function xmlrpc_debugmsg($m)
 {
     PhpXmlRpc\Server::xmlrpc_debugmsg($m);
 }
+
+function _xmlrpcs_getCapabilities($server, $m=null)
+{
+    return PhpXmlRpc\Server::_xmlrpcs_getCapabilities($server, $m);
+}
+
+$_xmlrpcs_listMethods_sig=array(array($GLOBALS['xmlrpcArray']));
+$_xmlrpcs_listMethods_doc='This method lists all the methods that the XML-RPC server knows how to dispatch';
+$_xmlrpcs_listMethods_sdoc=array(array('list of method names'));
+function _xmlrpcs_listMethods($server, $m=null) // if called in plain php values mode, second param is missing
+{
+    return PhpXmlRpc\Server::_xmlrpcs_listMethods($server, $m);
+}
+
+$_xmlrpcs_methodSignature_sig=array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcString']));
+$_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)';
+$_xmlrpcs_methodSignature_sdoc=array(array('list of known signatures, each sig being an array of xmlrpc type names', 'name of method to be described'));
+function _xmlrpcs_methodSignature($server, $m)
+{
+    return PhpXmlRpc\Server::_xmlrpcs_methodSignature($server, $m);
+}
+
+$_xmlrpcs_methodHelp_sig=array(array($GLOBALS['xmlrpcString'], $GLOBALS['xmlrpcString']));
+$_xmlrpcs_methodHelp_doc='Returns help text if defined for the method passed, otherwise returns an empty string';
+$_xmlrpcs_methodHelp_sdoc=array(array('method description', 'name of the method to be described'));
+function _xmlrpcs_methodHelp($server, $m)
+{
+    return PhpXmlRpc\Server::_xmlrpcs_methodHelp($server, $m);
+}
+
+function _xmlrpcs_multicall_error($err)
+{
+    return PhpXmlRpc\Server::_xmlrpcs_multicall_error($err);
+}
+
+function _xmlrpcs_multicall_do_call($server, $call)
+{
+    return PhpXmlRpc\Server::_xmlrpcs_multicall_do_call($server, $call);
+}
+
+function _xmlrpcs_multicall_do_call_phpvals($server, $call)
+{
+    return PhpXmlRpc\Server::_xmlrpcs_multicall_do_call_phpvals($server, $call);
+}
+
+$_xmlrpcs_multicall_sig = array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcArray']));
+$_xmlrpcs_multicall_doc = 'Boxcar multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details';
+$_xmlrpcs_multicall_sdoc = array(array('list of response structs, where each struct has the usual members', 'list of calls, with each call being represented as a struct, with members "methodname" and "params"'));
+function _xmlrpcs_multicall($server, $m)
+{
+    return PhpXmlRpc\Server::_xmlrpcs_multicall($server, $m);
+}
index 9f74412..d8e591d 100644 (file)
@@ -702,6 +702,10 @@ class Server
         $this->debug_info .= $string . "\n";
     }
 
+    /**
+     * @param string $charsetEncoding
+     * @return string
+     */
     protected function xml_header($charsetEncoding = '')
     {
         if ($charsetEncoding != '') {
@@ -713,6 +717,9 @@ class Server
 
     /* Functions that implement system.XXX methods of xmlrpc servers */
 
+    /**
+     * @return array
+     */
     public function getSystemDispatchMap()
     {
         return array(
@@ -751,36 +758,45 @@ class Server
         );
     }
 
-    public static function _xmlrpcs_getCapabilities($server, $req = null)
+    /**
+     * @return array
+     */
+    public function getCapabilities()
     {
         $outAr = array(
             // xmlrpc spec: always supported
-            'xmlrpc' => new Value(array(
-                'specUrl' => new Value('http://www.xmlrpc.com/spec', 'string'),
-                'specVersion' => new Value(1, 'int'),
-            ), 'struct'),
+            'xmlrpc' => array(
+                'specUrl' => 'http://www.xmlrpc.com/spec',
+                'specVersion' => 1
+            ),
             // if we support system.xxx functions, we always support multicall, too...
             // Note that, as of 2006/09/17, the following URL does not respond anymore
-            'system.multicall' => new Value(array(
-                'specUrl' => new Value('http://www.xmlrpc.com/discuss/msgReader$1208', 'string'),
-                'specVersion' => new Value(1, 'int'),
-            ), 'struct'),
+            'system.multicall' => array(
+                'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
+                'specVersion' => 1
+            ),
             // introspection: version 2! we support 'mixed', too
-            'introspection' => new Value(array(
-                'specUrl' => new Value('http://phpxmlrpc.sourceforge.net/doc-2/ch10.html', 'string'),
-                'specVersion' => new Value(2, 'int'),
-            ), 'struct'),
+            'introspection' => array(
+                'specUrl' => 'http://phpxmlrpc.sourceforge.net/doc-2/ch10.html',
+                'specVersion' => 2,
+            ),
         );
 
         // NIL extension
         if (PhpXmlRpc::$xmlrpc_null_extension) {
-            $outAr['nil'] = new Value(array(
-                'specUrl' => new Value('http://www.ontosys.com/xml-rpc/extensions.php', 'string'),
-                'specVersion' => new Value(1, 'int'),
-            ), 'struct');
+            $outAr['nil'] = array(
+                'specUrl' => 'http://www.ontosys.com/xml-rpc/extensions.php',
+                'specVersion' => 1
+            );
         }
 
-        return new Response(new Value($outAr, 'struct'));
+        return $outAr;
+    }
+
+    public static function _xmlrpcs_getCapabilities($server, $req = null)
+    {
+        $encoder = new Encoder();
+        return new Response($encoder->encode($server->getCapabilities()));
     }
 
     public static function _xmlrpcs_listMethods($server, $req = null) // if called in plain php values mode, second param is missing