Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
WSPProxy Class Reference

#include <wspprivate.h>

Inheritance diagram for WSPProxy:
Inheritance graph
[legend]
Collaboration diagram for WSPProxy:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 WSPProxy ()
virtual ~WSPProxy ()
NS_DECL_ISUPPORTS
NS_DECL_NSIWEBSERVICEPROXY
NS_DECL_NSICLASSINFO
NS_IMETHOD 
CallMethod (PRUint16 methodIndex, const nsXPTMethodInfo *info, nsXPTCMiniVariant *params)
 Asynchronous processing : 1-> WSPProxy::CallMethod 2 -> WSPCallContext::CallAsync 3 -> nsSOAPCall::AsyncInvoke 4 -> nsXXXSOAPTransport::AsyncCall 5 -> nsIXMLHttpRequest::Send, nsXXXSOAPTransportCompletion::AddEventListener ---- asynchronous ---- 6 -> nsXXXSOAPTransportCompletion::HandleEvent 7 -> WSPCallContext::HandleResponse, WSPCallContext::CallCompletionListener 8 -> nsSOAPBlock::SetSchemaType, nsSOAPBlock::GetValue 9 -> nsSOAPEncoding::Decode, nsDefaultSOAPDecode::Decode 10 -> WSPProxy::CallCompleted.
NS_IMETHOD GetInterfaceInfo (nsIInterfaceInfo **info)
void GetListenerInterfaceInfo (nsIInterfaceInfo **aInfo)
void CallCompleted (WSPCallContext *aContext)
void Init (in nsIWSDLPort aPort, in nsIInterfaceInfo aPrimaryInterface, in nsIInterfaceInfoManager aInterfaceInfoManager, in AString aQualifier, in boolean aIsAsync)
void getInterfaces (out PRUint32 count,[array, size_is(count), retval] out nsIIDPtr array)
 Get an ordered list of the interface ids that instances of the class promise to implement.
nsISupports getHelperForLanguage (in PRUint32 language)
 Get a language mapping specific helper object that may assist in using objects of this class in a specific lanaguage.

Static Public Member Functions

static NS_METHOD Create (nsISupports *outer, const nsIID &aIID, void **aInstancePtr)
static nsresult XPTCMiniVariantToVariant (uint8 aTypeTag, nsXPTCMiniVariant aResult, nsIInterfaceInfo *aInterfaceInfo, nsIVariant **aVariant)
static nsresult ArrayXPTCMiniVariantToVariant (uint8 aTypeTag, nsXPTCMiniVariant aResult, PRUint32 aLength, nsIInterfaceInfo *aIfaceInfo, nsIVariant **aVariant)
static nsresult VariantToValue (uint8 aTypeTag, void *aValue, nsIInterfaceInfo *aInterfaceInfo, nsIVariant *aProperty)
static nsresult VariantToArrayValue (uint8 aTypeTag, nsXPTCMiniVariant *aResultSize, nsXPTCMiniVariant *aResultArray, nsIInterfaceInfo *aInterfaceInfo, nsIVariant *aProperty)
static nsresult ParameterToVariant (nsIInterfaceInfo *aInterfaceInfo, PRUint32 aMethodIndex, const nsXPTParamInfo *aParamInfo, nsXPTCMiniVariant aMiniVariant, PRUint32 aArrayLength, nsIVariant **aVariant)
static nsresult VariantToInParameter (nsIInterfaceInfo *aInterfaceInfo, PRUint32 aMethodIndex, const nsXPTParamInfo *aParamInfo, nsIVariant *aVariant, nsXPTCVariant *aXPTCVariant)
static nsresult VariantToOutParameter (nsIInterfaceInfo *aInterfaceInfo, PRUint32 aMethodIndex, const nsXPTParamInfo *aParamInfo, nsIVariant *aVariant, nsXPTCMiniVariant *aMiniVariant)
static nsresult WrapInPropertyBag (nsISupports *aInstance, nsIInterfaceInfo *aInterfaceInfo, nsIPropertyBag **aPropertyBag)
static nsresult WrapInComplexType (nsIPropertyBag *aPropertyBag, nsIInterfaceInfo *aInterfaceInfo, nsISupports **aComplexType)

Public Attributes

readonly attribute nsIWSDLPort port
 The WSDL port that this service proxy represents.
readonly attribute boolean isAsync
 PR_TRUE if the service proxy methods represent an asynchronous calling convention.
readonly attribute AString qualifier
 The qualifier used for interface names related to this service proxy.
readonly attribute
nsISimpleEnumerator 
pendingCalls
 An enumerator that returns the set of pending calls for the service proxy.
readonly attribute string primaryInterfaceName
 The name of the primary interface for this proxy.
readonly attribute string primaryAsyncListenerInterfaceName
 The name of the primary async listener interface for this proxy.
readonly attribute
nsIScriptableInterfaces 
interfaces
 The collection of interfaces related to this service proxy.
readonly attribute string contractID
 A contract ID through which an instance of this class can be created (or accessed as a service, if |flags & SINGLETON|), or null.
readonly attribute string classDescription
 A human readable string naming the class, or null.
readonly attribute nsCIDPtr classID
 A class ID through which an instance of this class can be created (or accessed as a service, if |flags & SINGLETON|), or null.
readonly attribute PRUint32 implementationLanguage
 Return language type from list in nsIProgrammingLanguage.
const PRUint32 SINGLETON = 1 << 0
 Bitflags for 'flags' attribute.
const PRUint32 THREADSAFE = 1 << 1
const PRUint32 MAIN_THREAD_ONLY = 1 << 2
const PRUint32 DOM_OBJECT = 1 << 3
const PRUint32 PLUGIN_OBJECT = 1 << 4
const PRUint32 EAGER_CLASSINFO = 1 << 5
const PRUint32 CONTENT_NODE = 1 << 6
 'flags' attribute bitflag: whether objects of this type implement nsIContent.
const PRUint32 RESERVED = 1 << 31
readonly attribute PRUint32 flags
readonly attribute nsCID classIDNoAlloc
 Also a class ID through which an instance of this class can be created (or accessed as a service, if |flags & SINGLETON|).

Protected Member Functions

nsresult GetInterfaceName (PRBool listener, char **retval)

Protected Attributes

nsCOMPtr< nsIWSDLPortmPort
nsCOMPtr< nsIInterfaceInfomPrimaryInterface
nsCOMPtr< nsIInterfaceInfoManagermInterfaceInfoManager
nsString mQualifier
PRBool mIsAsync
nsCOMArray
< nsIWebServiceCallContext
mPendingCalls
const nsIIDmIID
nsCOMPtr< nsISupports > mAsyncListener
nsCOMPtr< nsIInterfaceInfomListenerInterfaceInfo
nsCOMPtr< nsIScriptableInterfacesmInterfaces

Detailed Description

Definition at line 94 of file wspprivate.h.


Constructor & Destructor Documentation

Definition at line 57 of file wspproxy.cpp.

  : mIID(nsnull)
{
}

Here is the caller graph for this function:

WSPProxy::~WSPProxy ( ) [virtual]

Definition at line 62 of file wspproxy.cpp.

{
}

Member Function Documentation

nsresult WSPProxy::ArrayXPTCMiniVariantToVariant ( uint8  aTypeTag,
nsXPTCMiniVariant  aResult,
PRUint32  aLength,
nsIInterfaceInfo aIfaceInfo,
nsIVariant **  aVariant 
) [static]

Definition at line 722 of file wspproxy.cpp.

{
  nsresult rv;

  nsCOMPtr<nsIWritableVariant> retvar =
    do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
  if (NS_FAILED(rv)) {
    return rv;
  }

  if (aLength) {
    PRUint32 i = 0;
    void* array = aResult.val.p;
    void* entries;
    nsISupports** entriesSup = nsnull;
    const nsIID* iid = nsnull;

    switch (aTypeTag) {
      case nsXPTType::T_I8:
      case nsXPTType::T_I16:
      case nsXPTType::T_I32:
      case nsXPTType::T_I64:
      case nsXPTType::T_U8:
      case nsXPTType::T_U16:
      case nsXPTType::T_U32:
      case nsXPTType::T_U64:
      case nsXPTType::T_FLOAT:
      case nsXPTType::T_DOUBLE:
      case nsXPTType::T_BOOL:
      case nsXPTType::T_CHAR:
      case nsXPTType::T_WCHAR:
      case nsXPTType::T_CHAR_STR:
      case nsXPTType::T_WCHAR_STR:
        entries = array;
        break;
      case nsXPTType::T_INTERFACE:
      {
        aInterfaceInfo->GetIIDShared(&iid);
        if (iid->Equals(NS_GET_IID(nsIVariant))) {
          entries = array;
        }
        else {
          entriesSup = (nsISupports**)nsMemory::Alloc(aLength *
                                                      sizeof(nsISupports*));
          if (!entriesSup) {
            return NS_ERROR_OUT_OF_MEMORY;
          }
          const nsIID& propbagIID = NS_GET_IID(nsIPropertyBag);
          iid = &propbagIID;
          entries = (void*)entriesSup;
          for(i = 0; i < aLength; i++) {
            nsISupports* instance = *((nsISupports**)array + i);
            nsISupports** outptr = entriesSup + i;
            if (instance) {
              nsCOMPtr<nsIPropertyBag> propBag;
              rv = WrapInPropertyBag(instance, aInterfaceInfo,
                                     getter_AddRefs(propBag));
              if (NS_FAILED(rv)) {
                break;
              }
              propBag->QueryInterface(NS_GET_IID(nsISupports),
                                      (void**)outptr);
            }
            else {
              *outptr = nsnull;
            }
          }
        }
        aTypeTag = nsXPTType::T_INTERFACE_IS;
        break;
      }
      default:
        NS_ERROR("Conversion of illegal array type");
        return NS_ERROR_FAILURE;
    }

    if (NS_SUCCEEDED(rv)) {
      rv = retvar->SetAsArray(aTypeTag, iid, aLength, entries);
    }

    if (entriesSup) {
      NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(i, entriesSup);
    }
  }
  else {
    retvar->SetAsEmpty();
  }

  if (NS_SUCCEEDED(rv)) {
    *aVariant = retvar;
    NS_ADDREF(*aVariant);
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1348 of file wspproxy.cpp.

{
  mPendingCalls.RemoveObject(aContext);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Asynchronous processing : 1-> WSPProxy::CallMethod 2 -> WSPCallContext::CallAsync 3 -> nsSOAPCall::AsyncInvoke 4 -> nsXXXSOAPTransport::AsyncCall 5 -> nsIXMLHttpRequest::Send, nsXXXSOAPTransportCompletion::AddEventListener ---- asynchronous ---- 6 -> nsXXXSOAPTransportCompletion::HandleEvent 7 -> WSPCallContext::HandleResponse, WSPCallContext::CallCompletionListener 8 -> nsSOAPBlock::SetSchemaType, nsSOAPBlock::GetValue 9 -> nsSOAPEncoding::Decode, nsDefaultSOAPDecode::Decode 10 -> WSPProxy::CallCompleted.

Definition at line 179 of file wspproxy.cpp.

{
  nsresult rv;
  nsCOMPtr<nsIWebServiceCallContext> cc;
  nsCOMPtr<nsIWSDLBinding> binding;

  if (methodIndex < 3) {
    NS_ERROR("WSPProxy: bad method index");
    return NS_ERROR_FAILURE;
  }

  // The first method in the interface for async callers is the
  // one to set the async listener
  if (mIsAsync && (methodIndex == 3)) {
    nsISupports* listener = NS_STATIC_CAST(nsISupports*, params[0].val.p);
    mAsyncListener = listener;
    return NS_OK;
  }

  PRUint32 methodOffset;
  if (mIsAsync) {
    methodOffset = 4;
  }
  else {
    methodOffset = 3;
  }

  nsCOMPtr<nsIWSDLOperation> operation;
  rv = mPort->GetOperation(methodIndex - methodOffset,
                           getter_AddRefs(operation));
  if (NS_FAILED(rv)) {
    return rv;
  }

  nsCOMPtr<nsIWSDLMessage> input;
  rv = operation->GetInput(getter_AddRefs(input));
  if (NS_FAILED(rv)) {
    return rv;
  }

  // Create the call instance
  nsCOMPtr<nsISOAPCall> call = do_CreateInstance(NS_SOAPCALL_CONTRACTID, &rv);
  if (NS_FAILED(rv)) {
    return rv;
  }

  nsCOMPtr<nsISOAPEncoding> encoding =
    do_CreateInstance(NS_SOAPENCODING_CONTRACTID, &rv);
  if (NS_FAILED(rv)) {
    return rv;
  }
  call->SetEncoding(encoding);

  // Get the method name and target object uri
  nsAutoString methodName, targetObjectURI;
  rv = operation->GetBinding(getter_AddRefs(binding));
  if (NS_FAILED(rv)) {
    return rv;
  }

  nsCOMPtr<nsISOAPOperationBinding> operationBinding =
    do_QueryInterface(binding, &rv);
  if (NS_FAILED(rv)) {
    return rv;
  }

  nsAutoString soapAction;
  operationBinding->GetSoapAction(soapAction);
  call->SetActionURI(soapAction);

  PRUint16 style;
  operationBinding->GetStyle(&style);
  // If the style is RPC, find the method name and target object URI.
  // If it is document-style, these are both left blank.
  if (style == nsISOAPPortBinding::STYLE_RPC) {
    operation->GetName(methodName);
    rv = input->GetBinding(getter_AddRefs(binding));
    if (NS_FAILED(rv)) {
      return rv;
    }
    nsCOMPtr<nsISOAPMessageBinding> messageBinding =
      do_QueryInterface(binding, &rv);
    if (NS_FAILED(rv)) {
      return rv;
    }
    messageBinding->GetNamespace(targetObjectURI);
  }

  // Set the transport URI
  rv = mPort->GetBinding(getter_AddRefs(binding));
  if (NS_FAILED(rv)) {
    return rv;
  }
  nsCOMPtr<nsISOAPPortBinding> portBinding = do_QueryInterface(binding, &rv);
  if (NS_FAILED(rv)) {
    return rv;
  }

  nsAutoString address;
  portBinding->GetAddress(address);
  rv = call->SetTransportURI(address);
  if (NS_FAILED(rv)) {
    return rv;
  }

  PRUint16 version;
  portBinding->GetSoapVersion(&version);
  if (version == nsISOAPMessage::VERSION_UNKNOWN) {
    version = nsISOAPMessage::VERSION_1_1;
  }

  // Set up the parameters to the call
  PRUint32 i, partCount;
  input->GetPartCount(&partCount);

  PRUint32 maxParamIndex = info->GetParamCount()-1;

  // Iterate through the parts to figure out how many are
  // body vs. header blocks
  nsCOMPtr<nsIWSDLPart> part;
  PRUint32 headerCount = 0, bodyCount = 0;

  for (i = 0; i < partCount; i++) {
    rv = input->GetPart(i, getter_AddRefs(part));
    if (NS_FAILED(rv)) {
      return rv;
    }

    rv = part->GetBinding(getter_AddRefs(binding));
    if (NS_FAILED(rv)) {
      return rv;
    }

    nsCOMPtr<nsISOAPPartBinding> partBinding = do_QueryInterface(binding, &rv);
    if (NS_FAILED(rv)) {
      return rv;
    }

    PRUint16 location;
    partBinding->GetLocation(&location);
    if (location == nsISOAPPartBinding::LOCATION_HEADER) {
      headerCount++;
    }
    else if (location == nsISOAPPartBinding::LOCATION_BODY) {
      bodyCount++;
    }
  }

  // Allocate parameter and header blocks
  nsISOAPParameter** bodyBlocks = nsnull;
  if (bodyCount) {
    bodyBlocks = NS_STATIC_CAST(nsISOAPParameter**,
                      nsMemory::Alloc(bodyCount * sizeof(nsISOAPParameter*)));
    if (!bodyBlocks) {
      return NS_ERROR_OUT_OF_MEMORY;
    }
    for (i = 0; i < bodyCount; i++) {
      rv = CallCreateInstance(NS_SOAPPARAMETER_CONTRACTID, &bodyBlocks[i]);
      if (NS_FAILED(rv)) {
        NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(i, bodyBlocks);

        return rv;
      }
    }
  }

  nsISOAPHeaderBlock** headerBlocks = nsnull;
  if (headerCount) {
    headerBlocks = NS_STATIC_CAST(nsISOAPHeaderBlock**,
                   nsMemory::Alloc(headerCount * sizeof(nsISOAPHeaderBlock*)));
    if (!headerBlocks) {
      if (bodyBlocks) {
        NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(bodyCount, bodyBlocks);
      }
      return NS_ERROR_OUT_OF_MEMORY;
    }
    for (i = 0; i < headerCount; i++) {
      rv = CallCreateInstance(NS_SOAPHEADERBLOCK_CONTRACTID, &headerBlocks[i]);
      if (NS_FAILED(rv)) {
        if (bodyBlocks) {
          NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(bodyCount, bodyBlocks);
        }
        NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(i, headerBlocks);

        return rv;
      }
    }
  }

  // Now iterate through the parameters and set up the parameter blocks
  PRUint32 bodyEntry = 0, headerEntry = 0, paramIndex = 0;
  for (i = 0; i < partCount; paramIndex++, i++) {
    input->GetPart(i, getter_AddRefs(part));
    part->GetBinding(getter_AddRefs(binding));
    nsCOMPtr<nsISOAPPartBinding> partBinding = do_QueryInterface(binding);
    PRUint16 location;
    partBinding->GetLocation(&location);

    nsCOMPtr<nsISOAPBlock> block;
    if (location == nsISOAPPartBinding::LOCATION_HEADER) {
      block = do_QueryInterface(headerBlocks[headerEntry++]);
    }
    else if (location == nsISOAPPartBinding::LOCATION_BODY) {
      block = do_QueryInterface(bodyBlocks[bodyEntry++]);
    }

    if (!block) {
      rv = NS_ERROR_FAILURE;
      goto call_method_end;
    }

    // Get the name, namespaceURI and type of the block based on
    // information from the WSDL part. If the schema component
    // associated with the part is an element, these values come
    // from the schema description of the element. If it is a
    // type, then the values are gathered from elsewhere.
    nsCOMPtr<nsISchemaComponent> schemaComponent;
    rv = part->GetSchemaComponent(getter_AddRefs(schemaComponent));
    if (NS_FAILED(rv)) {
      goto call_method_end;
    }

    nsCOMPtr<nsISchemaType> type;
    nsAutoString blockName, blockNamespace;
    nsCOMPtr<nsISchemaElement> element = do_QueryInterface(schemaComponent);

    if (element) {
      rv = element->GetType(getter_AddRefs(type));
      if (NS_FAILED(rv)) {
        goto call_method_end;
      }

      element->GetName(blockName);
      element->GetTargetNamespace(blockNamespace);
    }
    else {
      type = do_QueryInterface(schemaComponent);

      nsAutoString paramName;
      part->GetName(paramName);

      blockName.Assign(paramName);
      partBinding->GetNamespace(blockNamespace);
    }

    block->SetName(blockName);
    block->SetNamespaceURI(blockNamespace);
    block->SetSchemaType(type);

    nsAutoString encodingStyle;
    PRUint16 use;

    partBinding->GetUse(&use);
    // XXX Need a way to specify that a block should not be
    // encoded.
    if (use == nsISOAPPartBinding::USE_ENCODED) {
      partBinding->GetEncodingStyle(encodingStyle);
      if (!encodingStyle.IsEmpty()) {
        nsCOMPtr<nsISOAPEncoding> partEncoding;
        encoding->GetAssociatedEncoding(encodingStyle, PR_FALSE,
                                        getter_AddRefs(partEncoding));
        block->SetEncoding(partEncoding);
      }
    }

    // Look ahead in the param info array to see if the current part has to be
    // treated as an array. If so then get the array length from the current
    // param and increment the param index.

    PRUint32 arrayLength;

    if (paramIndex < maxParamIndex &&
        info->GetParam((PRUint8)(paramIndex + 1)).GetType().IsArray()) {
      arrayLength = params[paramIndex++].val.u32;
    }
    else {
      arrayLength = 0;
    }

    NS_ASSERTION(paramIndex <= maxParamIndex,
                 "WSDL/IInfo param count mismatch");

    const nsXPTParamInfo& paramInfo = info->GetParam(paramIndex);

    nsCOMPtr<nsIVariant> value;
    rv = ParameterToVariant(mPrimaryInterface, methodIndex,
                            &paramInfo, params[paramIndex],
                            arrayLength, getter_AddRefs(value));
    if (NS_FAILED(rv)) {
      goto call_method_end;
    }

    block->SetValue(value);
  }

  // Encode the parameters to the call
  rv = call->Encode(version,
                    methodName, targetObjectURI,
                    headerCount, headerBlocks,
                    bodyCount, bodyBlocks);
  if (NS_FAILED(rv)) {
    goto call_method_end;
  }

  WSPCallContext* ccInst;
  ccInst = new WSPCallContext(this, call, methodName, operation);
  if (!ccInst) {
    rv = NS_ERROR_OUT_OF_MEMORY;
    goto call_method_end;
  }
  cc = ccInst;

  if (mIsAsync) {
    PRUint8 pcount;
    pcount = info->GetParamCount();
    // There has to be at least one parameter - the retval.
    if (pcount == 0) {
      rv = NS_ERROR_FAILURE;
      goto call_method_end;
    }

#ifdef DEBUG
    // The last one should be the retval.
    const nsXPTParamInfo& retParamInfo = info->GetParam(pcount - 1);
    if (!retParamInfo.IsRetval()) {
      rv = NS_ERROR_FAILURE;
      goto call_method_end;
    }

    // It should be an interface pointer
    const nsXPTType& retType = retParamInfo.GetType();
    if (!retType.IsInterfacePointer()) {
      rv = NS_ERROR_FAILURE;
      goto call_method_end;
    }
#endif

    nsIWebServiceCallContext** retval =
      NS_STATIC_CAST(nsIWebServiceCallContext**, params[pcount-1].val.p);
    if (!retval) {
      rv = NS_ERROR_FAILURE;
      goto call_method_end;
    }
    *retval = cc;
    NS_ADDREF(*retval);

    rv = ccInst->CallAsync(methodIndex, mAsyncListener);
    if (NS_FAILED(rv)) {
      goto call_method_end;
    }

    mPendingCalls.AppendObject(ccInst);
  }
  else {
    rv = ccInst->CallSync(methodIndex, params);
  }

call_method_end:
  if (bodyBlocks) {
    NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(bodyCount, bodyBlocks);
  }
  if (headerBlocks) {
    NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(headerCount, headerBlocks);
  }
  return rv;
}

Here is the call graph for this function:

NS_METHOD WSPProxy::Create ( nsISupports *  outer,
const nsIID aIID,
void **  aInstancePtr 
) [static]

Definition at line 116 of file wspproxy.cpp.

{
  NS_ENSURE_ARG_POINTER(aInstancePtr);
  NS_ENSURE_NO_AGGREGATION(outer);

  WSPProxy* proxy = new WSPProxy();
  if (!proxy) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  NS_ADDREF(proxy);
  nsresult rv = proxy->QueryInterface(aIID, aInstancePtr);
  NS_RELEASE(proxy);
  return rv;
}

Here is the call graph for this function:

nsISupports nsIClassInfo::getHelperForLanguage ( in PRUint32  language) [inherited]

Get a language mapping specific helper object that may assist in using objects of this class in a specific lanaguage.

For instance, if asked for the helper for nsIProgrammingLanguage::JAVASCRIPT this might return an object that can be QI'd into the nsIXPCScriptable interface to assist XPConnect in supplying JavaScript specific behavior to callers of the instance object.

see: nsIProgrammingLanguage.idl

Should return null if no helper available for given language.

Definition at line 1139 of file wspproxy.cpp.

{
  NS_ENSURE_ARG_POINTER(info);

  *info = mPrimaryInterface;
  NS_ADDREF(*info);

  return NS_OK;
}

Here is the call graph for this function:

nsresult WSPProxy::GetInterfaceName ( PRBool  listener,
char **  retval 
) [protected]

Definition at line 1193 of file wspproxy.cpp.

{
  if (!mPrimaryInterface) {
    return NS_ERROR_FAILURE;
  }

  const char* rawName;
  nsresult rv = mPrimaryInterface->GetNameShared(&rawName);
  if (NS_FAILED(rv)) {
    return rv;
  }

  nsCAutoString name;

  if (listener) {
    if (mIsAsync) {
      name.Assign(rawName, strlen(rawName) - (sizeof("Async")-1) );
    }
    else {
      name.Assign(rawName);
    }
    name.Append("Listener");
  }
  else {
    name.Assign(rawName);
  }

  *retval = (char*) nsMemory::Clone(name.get(), name.Length()+1);
  return *retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}

Here is the call graph for this function:

void nsIClassInfo::getInterfaces ( out PRUint32  count,
[array, size_is(count), retval] out nsIIDPtr  array 
) [inherited]

Get an ordered list of the interface ids that instances of the class promise to implement.

Note that nsISupports is an implicit member of any such list and need not be included.

Should set *count = 0 and *array = null and return NS_OK if getting the list is not supported.

Definition at line 1341 of file wspproxy.cpp.

{
  *aInfo = mListenerInterfaceInfo;
  NS_IF_ADDREF(*aInfo);
}

Here is the caller graph for this function:

void nsIWebServiceProxy::Init ( in nsIWSDLPort  aPort,
in nsIInterfaceInfo  aPrimaryInterface,
in nsIInterfaceInfoManager  aInterfaceInfoManager,
in AString  aQualifier,
in boolean  aIsAsync 
) [inherited]
nsresult WSPProxy::ParameterToVariant ( nsIInterfaceInfo aInterfaceInfo,
PRUint32  aMethodIndex,
const nsXPTParamInfo aParamInfo,
nsXPTCMiniVariant  aMiniVariant,
PRUint32  aArrayLength,
nsIVariant **  aVariant 
) [static]

Definition at line 549 of file wspproxy.cpp.

{
  nsXPTType type;
  nsresult rv = aInterfaceInfo->GetTypeForParam(aMethodIndex, aParamInfo,
                                                0, &type);
  if (NS_FAILED(rv)) {
    return rv;
  }

  uint8 type_tag = type.TagPart();
  nsCOMPtr<nsIInterfaceInfo> iinfo;
  if (type.IsArray()) {
    nsXPTType arrayType;
    rv = aInterfaceInfo->GetTypeForParam(aMethodIndex, aParamInfo,
                                         1, &arrayType);
    if (NS_FAILED(rv)) {
      return rv;
    }

    if (arrayType.IsInterfacePointer()) {
      rv = aInterfaceInfo->GetInfoForParam(aMethodIndex, aParamInfo,
                                           getter_AddRefs(iinfo));
      if (NS_FAILED(rv)) {
        return rv;
      }
    }
    return ArrayXPTCMiniVariantToVariant(arrayType.TagPart(), aMiniVariant,
                                         aArrayLength, iinfo, aVariant);
  }

  // else

  if (type.IsInterfacePointer()) {
    rv = aInterfaceInfo->GetInfoForParam(aMethodIndex, aParamInfo,
                                         getter_AddRefs(iinfo));
    if (NS_FAILED(rv)) {
      return rv;
    }
  }

  return XPTCMiniVariantToVariant(type_tag, aMiniVariant, iinfo, aVariant);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult WSPProxy::VariantToArrayValue ( uint8  aTypeTag,
nsXPTCMiniVariant aResultSize,
nsXPTCMiniVariant aResultArray,
nsIInterfaceInfo aInterfaceInfo,
nsIVariant aProperty 
) [static]

Definition at line 1049 of file wspproxy.cpp.

{
  void* array;
  PRUint16 type;
  PRUint32 count;

  nsIID arrayIID;
  nsresult rv = aProperty->GetAsArray(&type, &arrayIID, &count, &array);
  if (NS_FAILED(rv)) {
    return rv;
  }

  aResultSize->val.u32 = count;

  switch (aTypeTag) {
    case nsXPTType::T_I8:
    case nsXPTType::T_U8:
    case nsXPTType::T_I16:
    case nsXPTType::T_U16:
    case nsXPTType::T_I32:
    case nsXPTType::T_U32:
    case nsXPTType::T_I64:
    case nsXPTType::T_U64:
    case nsXPTType::T_FLOAT:
    case nsXPTType::T_DOUBLE:
    case nsXPTType::T_BOOL:
    case nsXPTType::T_CHAR:
    case nsXPTType::T_WCHAR:
    case nsXPTType::T_CHAR_STR:
    case nsXPTType::T_WCHAR_STR:
      aResultArray->val.p = array;
      break;
    case nsXPTType::T_INTERFACE:
    case nsXPTType::T_INTERFACE_IS:
    {
      if (arrayIID.Equals(NS_GET_IID(nsIVariant))) {
        aResultArray->val.p = array;
      }
      else if (!arrayIID.Equals(NS_GET_IID(nsIPropertyBag))) {
        NS_ERROR("Array of complex types should be represented by property "
                 "bags");
        return NS_ERROR_FAILURE;
      }
      else {
        nsISupports** outptr =
          (nsISupports**)nsMemory::Alloc(count * sizeof(nsISupports*));
        if (!outptr) {
          return NS_ERROR_OUT_OF_MEMORY;
        }
        nsISupports** arraySup = (nsISupports**)array;
        const nsIID* iid;
        aInterfaceInfo->GetIIDShared(&iid);
        PRUint32 i;
        for (i = 0; i < count; i++) {
          nsCOMPtr<nsIPropertyBag> propBag(do_QueryInterface(arraySup[i]));
          if (!propBag) {
            *(outptr + i) = nsnull;
          }
          else {
            nsCOMPtr<nsISupports> wrapper;
            rv = WrapInComplexType(propBag, aInterfaceInfo,
                                   getter_AddRefs(wrapper));
            if (NS_FAILED(rv)) {
              NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(i, outptr);
              return rv;
            }
            rv = wrapper->QueryInterface(*iid, (void**)(outptr + i));
            if (NS_FAILED(rv)) {
              NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(i, outptr);
              return rv;
            }
          }
        }
        aResultArray->val.p = outptr;
      }
      break;
    }
    default:
      NS_ERROR("Conversion of illegal array type");
      return NS_ERROR_FAILURE;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult WSPProxy::VariantToInParameter ( nsIInterfaceInfo aInterfaceInfo,
PRUint32  aMethodIndex,
const nsXPTParamInfo aParamInfo,
nsIVariant aVariant,
nsXPTCVariant aXPTCVariant 
) [static]

Definition at line 824 of file wspproxy.cpp.

{
  nsXPTType type;
  nsresult rv = aInterfaceInfo->GetTypeForParam(aMethodIndex, aParamInfo,
                                                0, &type);
  if (NS_FAILED(rv)) {
    return rv;
  }
  
  
  uint8 type_tag = type.TagPart();
  nsCOMPtr<nsIInterfaceInfo> iinfo;
  if (type.IsArray()) {
    nsXPTType arrayType;
    rv = aInterfaceInfo->GetTypeForParam(aMethodIndex, aParamInfo,
                                         1, &arrayType);
    if (NS_FAILED(rv)) {
      return rv;
    }

    if (arrayType.IsInterfacePointer()) {
      rv = aInterfaceInfo->GetInfoForParam(aMethodIndex, aParamInfo,
                                           getter_AddRefs(iinfo));
      if (NS_FAILED(rv)) {
        return rv;
      }
    }

    aXPTCVariant[0].type = nsXPTType::T_U32;
    aXPTCVariant[1].type = nsXPTType::T_ARRAY;
    aXPTCVariant[1].SetValIsArray();
    return VariantToArrayValue(arrayType.TagPart(), aXPTCVariant, aXPTCVariant+1,
                               iinfo, aVariant);
  }
  // Set the param's type on the XPTCVariant because xptcinvoke's 
  // invoke_copy_to_stack depends on it. This fixes bug 203434.
  aXPTCVariant->type = type;
  // else
  if (type.IsInterfacePointer()) {
    rv = aInterfaceInfo->GetInfoForParam(aMethodIndex, aParamInfo, 
                                         getter_AddRefs(iinfo));
    if (NS_FAILED(rv)) {
      return rv;
    }
  }

  if (type_tag == nsXPTType::T_DOMSTRING) {
    // T_DOMSTRING values are expected to be stored in an nsAString
    // object pointed to by the nsXPTCVariant...
    return VariantToValue(type_tag, aXPTCVariant->val.p, iinfo, aVariant);
  }
  // else

  // ... but other types are expected to be stored directly in the
  // variant itself.
  return VariantToValue(type_tag, &aXPTCVariant->val, iinfo, aVariant);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult WSPProxy::VariantToOutParameter ( nsIInterfaceInfo aInterfaceInfo,
PRUint32  aMethodIndex,
const nsXPTParamInfo aParamInfo,
nsIVariant aVariant,
nsXPTCMiniVariant aMiniVariant 
) [static]

Definition at line 887 of file wspproxy.cpp.

{
  nsXPTType type;
  nsresult rv = aInterfaceInfo->GetTypeForParam(aMethodIndex, aParamInfo,
                                                0, &type);
  if (NS_FAILED(rv)) {
    return rv;
  }
  uint8 type_tag = type.TagPart();
  nsCOMPtr<nsIInterfaceInfo> iinfo;
  if (type.IsArray()) {
    nsXPTType arrayType;
    rv = aInterfaceInfo->GetTypeForParam(aMethodIndex, aParamInfo,
                                         1, &arrayType);
    if (NS_FAILED(rv)) {
      return rv;
    }

    if (arrayType.IsInterfacePointer()) {
      rv = aInterfaceInfo->GetInfoForParam(aMethodIndex, aParamInfo,
                                           getter_AddRefs(iinfo));
      if (NS_FAILED(rv)) {
        return rv;
      }
    }
    return VariantToArrayValue(arrayType.TagPart(), 
                               aMiniVariant, aMiniVariant + 1,
                               iinfo, aVariant);
  }
  // else
  if (type.IsInterfacePointer()) {
    rv = aInterfaceInfo->GetInfoForParam(aMethodIndex, aParamInfo,
                                         getter_AddRefs(iinfo));
    if (NS_FAILED(rv)) {
      return rv;
    }
  }
  return VariantToValue(type_tag, aMiniVariant->val.p, iinfo, aVariant);
}

Here is the call graph for this function:

nsresult WSPProxy::VariantToValue ( uint8  aTypeTag,
void aValue,
nsIInterfaceInfo aInterfaceInfo,
nsIVariant aProperty 
) [static]

Definition at line 950 of file wspproxy.cpp.

{
  nsresult rv = NS_OK;

  switch(aTypeTag) {
    case nsXPTType::T_I8:
      rv = aProperty->GetAsInt8((PRUint8*)aValue);
      break;
    case nsXPTType::T_I16:
      rv = aProperty->GetAsInt16((PRInt16*)aValue);
      break;
    case nsXPTType::T_I32:
      rv = aProperty->GetAsInt32((PRInt32*)aValue);
      break;
    case nsXPTType::T_I64:
      rv = aProperty->GetAsInt64((PRInt64*)aValue);
      break;
    case nsXPTType::T_U8:
      rv = aProperty->GetAsUint8((PRUint8*)aValue);
      break;
    case nsXPTType::T_U16:
      rv = aProperty->GetAsUint16((PRUint16*)aValue);
      break;
    case nsXPTType::T_U32:
      rv = aProperty->GetAsUint32((PRUint32*)aValue);
      break;
    case nsXPTType::T_U64:
      rv = aProperty->GetAsUint64((PRUint64*)aValue);
      break;
    case nsXPTType::T_FLOAT:
      rv = aProperty->GetAsFloat((float*)aValue);
      break;
    case nsXPTType::T_DOUBLE:
      rv = aProperty->GetAsDouble((double*)aValue);
      break;
    case nsXPTType::T_BOOL:
      rv = aProperty->GetAsBool((PRBool*)aValue);
      break;
    case nsXPTType::T_CHAR:
      rv = aProperty->GetAsChar((char*)aValue);
      break;
    case nsXPTType::T_WCHAR:
      rv = aProperty->GetAsWChar((PRUnichar*)aValue);
      break;
    case nsXPTType::T_CHAR_STR:
      rv = aProperty->GetAsString((char**)aValue);
      break;
    case nsXPTType::T_WCHAR_STR:
      rv = aProperty->GetAsWString((PRUnichar**)aValue);
      break;
    case nsXPTType::T_DOMSTRING:
    case nsXPTType::T_ASTRING:
      rv = aProperty->GetAsAString(*(nsAString*)aValue);
      break;
    case nsXPTType::T_INTERFACE:
    {
      const nsIID* iid;
      aInterfaceInfo->GetIIDShared(&iid);
      PRUint16 dataType;
      aProperty->GetDataType(&dataType);
      if (dataType == nsIDataType::VTYPE_EMPTY) {
        *(nsISupports**)aValue = nsnull;
      }
      else if (iid->Equals(NS_GET_IID(nsIVariant))) {
        *(nsIVariant**)aValue = aProperty;
        NS_ADDREF(*(nsIVariant**)aValue);
      }
      else {
        nsCOMPtr<nsISupports> sup;
        rv = aProperty->GetAsISupports(getter_AddRefs(sup));
        if (NS_FAILED(rv)) {
          return rv;
        }
        nsCOMPtr<nsIPropertyBag> propBag = do_QueryInterface(sup, &rv);
        if (NS_FAILED(rv)) {
          return rv;
        }
        nsCOMPtr<nsISupports> wrapper;
        rv = WrapInComplexType(propBag, aInterfaceInfo,
                               getter_AddRefs(wrapper));
        if (NS_FAILED(rv)) {
          return rv;
        }

        rv = wrapper->QueryInterface(*iid, (void**)aValue);
      }
      break;
    }
    default:
      NS_ERROR("Bad attribute type for complex type interface");
      rv = NS_ERROR_FAILURE;
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult WSPProxy::WrapInComplexType ( nsIPropertyBag aPropertyBag,
nsIInterfaceInfo aInterfaceInfo,
nsISupports **  aComplexType 
) [static]

Definition at line 932 of file wspproxy.cpp.

{
  *aComplexType = nsnull;
  nsRefPtr<WSPPropertyBagWrapper> wrapper = new WSPPropertyBagWrapper();
  if (!wrapper) {
    return NS_ERROR_OUT_OF_MEMORY;
  }
  nsresult rv = wrapper->Init(aPropertyBag, aInterfaceInfo);
  if (NS_FAILED(rv)) {
    return rv;
  }
  wrapper->QueryInterface(NS_GET_IID(nsISupports), (void**)aComplexType);
  return NS_OK;
}

Here is the caller graph for this function:

nsresult WSPProxy::WrapInPropertyBag ( nsISupports *  aInstance,
nsIInterfaceInfo aInterfaceInfo,
nsIPropertyBag **  aPropertyBag 
) [static]

Definition at line 597 of file wspproxy.cpp.

{
  *aPropertyBag = nsnull;
  nsresult rv;
  nsCOMPtr<nsIWebServiceComplexTypeWrapper> wrapper =
    do_CreateInstance(NS_WEBSERVICECOMPLEXTYPEWRAPPER_CONTRACTID, &rv);
  if (NS_FAILED(rv)) {
    return rv;
  }
  rv = wrapper->Init(aInstance, aInterfaceInfo);
  if (NS_FAILED(rv)) {
    return rv;
  }
  return CallQueryInterface(wrapper, aPropertyBag);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult WSPProxy::XPTCMiniVariantToVariant ( uint8  aTypeTag,
nsXPTCMiniVariant  aResult,
nsIInterfaceInfo aInterfaceInfo,
nsIVariant **  aVariant 
) [static]

Definition at line 616 of file wspproxy.cpp.

{
  nsresult rv;

  // If a variant is passed in, just return it as is.
  if (aTypeTag == nsXPTType::T_INTERFACE) {
    nsISupports* inst = (nsISupports*)aResult.val.p;
    nsCOMPtr<nsIVariant> instVar = do_QueryInterface(inst);
    if (instVar) {
      *aVariant = instVar;
      NS_ADDREF(*aVariant);
      return NS_OK;
    }
  }

  nsCOMPtr<nsIWritableVariant> var =
    do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
  if (NS_FAILED(rv)) {
    return rv;
  }

  switch (aTypeTag) {
    case nsXPTType::T_I8:
      var->SetAsInt8(aResult.val.i8);
      break;
    case nsXPTType::T_I16:
      var->SetAsInt16(aResult.val.i16);
      break;
    case nsXPTType::T_I32:
      var->SetAsInt32(aResult.val.i32);
      break;
    case nsXPTType::T_I64:
      var->SetAsInt64(aResult.val.i64);
      break;
    case nsXPTType::T_U8:
      var->SetAsUint8(aResult.val.u8);
      break;
    case nsXPTType::T_U16:
      var->SetAsUint16(aResult.val.u16);
      break;
    case nsXPTType::T_U32:
      var->SetAsUint32(aResult.val.u32);
      break;
    case nsXPTType::T_U64:
      var->SetAsUint64(aResult.val.u64);
      break;
    case nsXPTType::T_FLOAT:
      var->SetAsFloat(aResult.val.f);
      break;
    case nsXPTType::T_DOUBLE:
      var->SetAsDouble(aResult.val.d);
      break;
    case nsXPTType::T_BOOL:
      var->SetAsBool(aResult.val.b);
      break;
    case nsXPTType::T_CHAR:
      var->SetAsChar(aResult.val.c);
      break;
    case nsXPTType::T_WCHAR:
      var->SetAsWChar(aResult.val.wc);
      break;
    case nsXPTType::T_CHAR_STR:
      var->SetAsString(NS_STATIC_CAST(char*, aResult.val.p));
      break;
    case nsXPTType::T_WCHAR_STR:
      var->SetAsWString(NS_STATIC_CAST(PRUnichar*, aResult.val.p));
      break;
    case nsXPTType::T_DOMSTRING:
    case nsXPTType::T_ASTRING:
      var->SetAsAString(*((nsAString*)aResult.val.p));
      break;
    case nsXPTType::T_INTERFACE:
    {
      nsISupports* instance = (nsISupports*)aResult.val.p;
      if (instance) {
        nsCOMPtr<nsIPropertyBag> propBag;
        rv = WrapInPropertyBag(instance, aInterfaceInfo,
                               getter_AddRefs(propBag));
        if (NS_FAILED(rv)) {
          return rv;
        }
        var->SetAsInterface(NS_GET_IID(nsIPropertyBag), propBag);
        // AFAICT, there is no need to release the instance here 
        // because the caller who owns the object should be releasing it.
        // NS_RELEASE(instance); 
      }
      else {
        var->SetAsEmpty();
      }

      break;
    }
    default:
      NS_ERROR("Bad attribute type for complex type interface");
      rv = NS_ERROR_FAILURE;
  }

  *aVariant = var;
  NS_ADDREF(*aVariant);

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

A human readable string naming the class, or null.

Definition at line 86 of file nsIClassInfo.idl.

readonly attribute nsCIDPtr nsIClassInfo::classID [inherited]

A class ID through which an instance of this class can be created (or accessed as a service, if |flags & SINGLETON|), or null.

Definition at line 92 of file nsIClassInfo.idl.

Also a class ID through which an instance of this class can be created (or accessed as a service, if |flags & SINGLETON|).

If the class does not have a CID, it should return NS_ERROR_NOT_AVAILABLE. This attribute exists so C++ callers can avoid allocating and freeing a CID, as would happen if they used classID.

Definition at line 130 of file nsIClassInfo.idl.

'flags' attribute bitflag: whether objects of this type implement nsIContent.

Definition at line 113 of file nsIClassInfo.idl.

A contract ID through which an instance of this class can be created (or accessed as a service, if |flags & SINGLETON|), or null.

Definition at line 81 of file nsIClassInfo.idl.

const PRUint32 nsIClassInfo::DOM_OBJECT = 1 << 3 [inherited]

Definition at line 106 of file nsIClassInfo.idl.

Definition at line 108 of file nsIClassInfo.idl.

readonly attribute PRUint32 nsIClassInfo::flags [inherited]

Definition at line 121 of file nsIClassInfo.idl.

Return language type from list in nsIProgrammingLanguage.

Definition at line 98 of file nsIClassInfo.idl.

The collection of interfaces related to this service proxy.

This will include the primary interface implemented by the service proxy as well as any listener or complex type interfaces required for method parameters and return values. NOTE: only interesting from JavaScript.

Definition at line 208 of file nsIWebServiceProxy.idl.

PR_TRUE if the service proxy methods represent an asynchronous calling convention.

PR_FALSE if the methods are synchronous.

Definition at line 172 of file nsIWebServiceProxy.idl.

Definition at line 105 of file nsIClassInfo.idl.

nsCOMPtr<nsISupports> WSPProxy::mAsyncListener [protected]

Definition at line 173 of file wspprivate.h.

const nsIID* WSPProxy::mIID [protected]

Definition at line 172 of file wspprivate.h.

Definition at line 168 of file wspprivate.h.

Definition at line 175 of file wspprivate.h.

Definition at line 170 of file wspprivate.h.

Definition at line 174 of file wspprivate.h.

Definition at line 171 of file wspprivate.h.

Definition at line 166 of file wspprivate.h.

Definition at line 167 of file wspprivate.h.

Definition at line 169 of file wspprivate.h.

An enumerator that returns the set of pending calls for the service proxy.

Each call is an instance of the nsIWebServiceCallContext interface.

See also:
nsIWebServiceCallContext

Definition at line 187 of file nsIWebServiceProxy.idl.

Definition at line 107 of file nsIClassInfo.idl.

The WSDL port that this service proxy represents.

See also:
nsIWSDLPort

Definition at line 166 of file nsIWebServiceProxy.idl.

The name of the primary async listener interface for this proxy.

This will be null if this is not an async proxy.

Definition at line 199 of file nsIWebServiceProxy.idl.

The name of the primary interface for this proxy.

This may or may not be the async version depending on whether or not this is an async proxy.

Definition at line 193 of file nsIWebServiceProxy.idl.

readonly attribute AString nsIWebServiceProxy::qualifier [inherited]

The qualifier used for interface names related to this service proxy.

Definition at line 178 of file nsIWebServiceProxy.idl.

const PRUint32 nsIClassInfo::RESERVED = 1 << 31 [inherited]

Definition at line 118 of file nsIClassInfo.idl.

const PRUint32 nsIClassInfo::SINGLETON = 1 << 0 [inherited]

Bitflags for 'flags' attribute.

Definition at line 103 of file nsIClassInfo.idl.

const PRUint32 nsIClassInfo::THREADSAFE = 1 << 1 [inherited]

Definition at line 104 of file nsIClassInfo.idl.


The documentation for this class was generated from the following files: