Example #1
0
MethodResponse
   Dispatcher::system_listMethods(const MethodCall &calldata,
                                  const Dispatcher *disp)
{
  ULXR_TRACE("system_listMethods");
  if (calldata.numParams() > 1)
    throw ParameterException(InvalidMethodParameterError,
                             "At most 1 parameter allowed for \"system.listMethods\"");

  if (   calldata.numParams() == 1
      && calldata.getParam(0).getType() != RpcStrType)
    throw ParameterException(InvalidMethodParameterError,
                             "Parameter 1 not of type \"String\" \"system.listMethods\"");

// FIXME: what to do with param 1 if present ??

  Array arr;
  std::string m_prev;

  MethodCallMap::const_iterator it;
  for (it = disp->methodcalls.begin(); it != disp->methodcalls.end(); ++it)
    if (   m_prev != (*it).first.method_name
        && (*it).first.method_name.length() != 0)
    {
      arr.addItem(RpcString((*it).first.method_name));
      m_prev = (*it).first.method_name;
    }
  return MethodResponse (arr);
}
Example #2
0
MethodResponse
   Dispatcher::system_methodHelp(const MethodCall &calldata,
                                 const Dispatcher *disp)
{
  ULXR_TRACE("system_methodHelp");
  if (calldata.numParams() != 1)
    throw ParameterException(InvalidMethodParameterError,
                             "Exactly 1 parameter allowed for \"system.methodHelp\"");

  if (calldata.getParam(0).getType() != RpcStrType)
    throw ParameterException(InvalidMethodParameterError,
                             "Parameter 1 not of type \"String\" \"system.listMethods\"");

  RpcString vs = calldata.getParam(0);
  std::string name = vs.getString();
  std::string s;

  MethodCallMap::const_iterator it;
  std::string s_prev;
  for (it = disp->methodcalls.begin(); it != disp->methodcalls.end(); ++it)
    if (name == (*it).first.method_name && (*it).first.documentation.length() != 0)
    {
      if (   s_prev != (*it).first.documentation
          && (*it).first.documentation.length() != 0)
      {
        if (s.length() != 0)
          s = "* " +s + "\n* ";
        s += (*it).first.documentation;
      }
      s_prev = (*it).first.documentation;
    }

  return MethodResponse (RpcString(s));
}
Example #3
0
  Dispatcher::MethodCallDescriptor::MethodCallDescriptor(const MethodCall &call)
{
  method_name = call.getMethodName();
  documentation = "";
  return_signature = "";

  signature = call.getSignature(false);

  calltype = CallNone;
  invoked = 0;
  enabled = true;
}
Example #4
0
void Protocol::sendRpcCall(const MethodCall &call,
                                       const std::string &/*resource*/)
{
    ULXR_TRACE("sendRpcCall");
    std::string xml = call.getXml(0)+"\n";
    getConnection()->write(xml.c_str(), xml.length());
}
Example #5
0
MethodResponse
   Dispatcher::xml_pretty_print(const MethodCall &calldata,
                                const Dispatcher *disp)
{
  ULXR_TRACE("xml_pretty_print");
  if (calldata.numParams() > 1)
    throw ParameterException(InvalidMethodParameterError,
                             "At most 1 parameter allowed for \"system.listMethods\"");

  if (   calldata.numParams() == 1
      && calldata.getParam(0).getType() != RpcBoolean)
    throw ParameterException(InvalidMethodParameterError,
                             "Parameter 1 not of type \"Boolean\" \"ulxmlrpcpp.xml_pretty_print\"");

  bool enable = Boolean(calldata.getParam(0)).getBoolean();
  enableXmlPrettyPrint(enable);
  return MethodResponse (Void());
}
Example #6
0
MethodResponse Dispatcher::dispatchCallLoc(const MethodCall &call) const
{
  ULXR_TRACE("dispatchCallLoc: " << call.getMethodName());

  MethodCallDescriptor desc(call);
  MethodCallMap::const_iterator it;
  if ((it = methodcalls.find(desc)) != methodcalls.end() )
  {
    MethodCall_t mc = (*it).second;
    if (!(*it).first.isEnabled())
    {
      std::string s = "method \"";
      s += desc.getSignature(true, false);
      s += "\": currently unavailable.";
      return MethodResponse (MethodNotFoundError, s);
    }

    else
    {
      if ((*it).first.calltype == CallSystem)
      {
        ULXR_TRACE("Now calling system function: " + (*it).first.getSignature(true, true));
        (*it).first.incInvoked();
        return mc.system_function(call, this);
      }

      else if ((*it).first.calltype == CallStatic)
      {
        ULXR_TRACE("Now calling static function: " + (*it).first.getSignature(true, true));
        (*it).first.incInvoked();
        return mc.static_function(call);
      }

      else if ((*it).first.calltype == CallDynamic)
      {
        ULXR_TRACE("Now calling dynamic function: " + (*it).first.getSignature(true, true));
        (*it).first.incInvoked();
        return mc.dynamic_function->call(call);
      }

      else
      {
        std::string s = "method \"";
        s += desc.getSignature(true, false);
        s += "\": internal problem to find method.";
        return MethodResponse (MethodNotFoundError, s);
      }
    }
  }

  std::string s = "method \"";
  s += desc.getSignature(true, false);
  s += "\" unknown method and/or signature.";
  return MethodResponse (MethodNotFoundError, s);
}
Example #7
0
MethodResponse
   Dispatcher::system_methodSignature(const MethodCall &calldata,
                                      const Dispatcher *disp)
{
  ULXR_TRACE("system_methodSignature");
  if (calldata.numParams() != 1)
    throw ParameterException(InvalidMethodParameterError,
                             "Exactly 1 parameter allowed for \"system.methodSignature\"");

  if (calldata.getParam(0).getType() != RpcStrType)
    throw ParameterException(InvalidMethodParameterError,
                             "Parameter 1 not of type \"String\" \"system.listMethods\"");

  RpcString vs = calldata.getParam(0);
  std::string name = vs.getString();
  MethodCallMap::const_iterator it;
  Array ret_arr;
  for (it = disp->methodcalls.begin(); it != disp->methodcalls.end(); ++it)
  {
    Array sigarr;
    std::string sig = (*it).first.getSignature(true, true);
    if (name == (*it).first.method_name && sig.length() != 0)
    {
      std::size_t pos;
      while ((pos = sig.find(',')) != std::string::npos)
      {
        sigarr.addItem(RpcString(sig.substr(0, pos)));
        sig.erase(0, pos+1);
      }
      sigarr.addItem(RpcString(sig));
      ret_arr.addItem(sigarr);
    }
  }

  if (ret_arr.size() == 0)
    return MethodResponse (Integer(1));  // non-Array ==< no signatures
  else
    return MethodResponse (ret_arr);
}
Example #8
0
void Requester::send_call (const MethodCall &calldata,
                           const CppString &rpc_root)
{
  ULXR_TRACE(ULXR_PCHAR("send_call ") << calldata.getMethodName());
  if (!protocol->isOpen() )
    protocol->open();
  else
    protocol->resetConnection();

#ifdef ULXR_ENFORCE_NON_PERSISTENT
  protocol->setPersistent(false);
#endif

  protocol->sendRpcCall(calldata, rpc_root, wbxml_mode);
}
Example #9
0
MethodResponse
  Dispatcher::system_getCapabilities(const MethodCall &calldata,
                                     const Dispatcher *disp)
{
  if (calldata.numParams() > 1)
    throw ParameterException(InvalidMethodParameterError,
                             "No parameters allowed for \"system.listMethods\"");

  Struct sysCap;
  disp->getCapabilities(sysCap);

  Struct opStr;
  opStr.addMember("faults_interop", sysCap);
  return MethodResponse (opStr);
}