Back to index

lightning-sunbird  0.9+nobinonly
Enumerations | Functions | Variables
nsJSInstall.cpp File Reference
#include "jsapi.h"
#include "nsJSFile.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsBuildID.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsInstall.h"
#include "nsInstallFile.h"
#include "nsInstallTrigger.h"
#include "nsIPromptService.h"
#include "nsIDOMInstallVersion.h"
#include <stdio.h>
#include "nsJSFileSpecObj.h"

Go to the source code of this file.

Enumerations

enum  Install_slots {
  INSTALL_PLATFORM = -1, INSTALL_JARFILE = -2, INSTALL_ARCHIVE = -3, INSTALL_ARGUMENTS = -4,
  INSTALL_URL = -5, INSTALL_FLAGS = -6, INSTALL_FINALSTATUS = -7, INSTALL_INSTALL = -8,
  INSTALL_INSTALLED_FILES = -9
}

Functions

 GetInstallProperty (JSContext *cx, JSObject *obj, jsval id, jsval *vp)
 SetInstallProperty (JSContext *cx, JSObject *obj, jsval id, jsval *vp)
 FinalizeInstall (JSContext *cx, JSObject *obj)
void ConvertJSValToStr (nsString &aString, JSContext *aContext, jsval aValue)
void ConvertStrToJSVal (const nsString &aProp, JSContext *aContext, jsval *aReturn)
PRBool ConvertJSValToBool (PRBool *aProp, JSContext *aContext, jsval aValue)
PRBool ConvertJSValToObj (nsISupports **aSupports, REFNSIID aIID, JSClass *aClass, JSContext *aContext, jsval aValue)
void ConvertJSvalToVersionString (nsString &versionString, JSContext *cx, jsval argument)
 InstallAbortInstall (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallAddDirectory (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallAddSubcomponent (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallDeleteComponent (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallExecute (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallFinalizeInstall (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallGestalt (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallGetComponentFolder (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallGetFolder (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallGetLastError (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallGetWinProfile (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallGetWinRegistry (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallLoadResources (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallPatch (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallRegisterChrome (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallRefreshPlugins (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallResetError (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallSetPackageFolder (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallStartInstall (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallUninstall (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallTRACE (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallLogComment (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallAlert (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 InstallConfirm (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
JSObjectInitXPInstallObjects (JSContext *jscontext, nsIFile *jarfile, const PRUnichar *url, const PRUnichar *args, PRUint32 flags, CHROMEREG_IFACE *reg, nsIZipReader *theJARFile)

Variables

JSClass FileSpecObjectClass
JSClass FileOpClass
JSClass InstallClass
JSObjectgFileOpProto = nsnull
JSObjectgFileSpecProto = nsnull
JSObjectgFileOpObject = nsnull
static JSPropertySpec InstallProperties []
static JSConstDoubleSpec install_constants []
static JSFunctionSpec InstallMethods []

Enumeration Type Documentation

Enumerator:
INSTALL_PLATFORM 
INSTALL_JARFILE 
INSTALL_ARCHIVE 
INSTALL_ARGUMENTS 
INSTALL_URL 
INSTALL_FLAGS 
INSTALL_FINALSTATUS 
INSTALL_INSTALL 
INSTALL_INSTALLED_FILES 

Definition at line 98 of file nsJSInstall.cpp.


Function Documentation

PRBool ConvertJSValToBool ( PRBool aProp,
JSContext aContext,
jsval  aValue 
)

Definition at line 276 of file nsJSInstall.cpp.

{
  JSBool temp;
  if(JSVAL_IS_BOOLEAN(aValue) && JS_ValueToBoolean(aContext, aValue, &temp))
  {
    *aProp = (PRBool)temp;
  }
  else
  {
    JS_ReportError(aContext, "Parameter must be a boolean");
    return JS_FALSE;
  }

  return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool ConvertJSValToObj ( nsISupports **  aSupports,
REFNSIID  aIID,
JSClass aClass,
JSContext aContext,
jsval  aValue 
)

Definition at line 294 of file nsJSInstall.cpp.

{
  if (JSVAL_IS_NULL(aValue)) {
    *aSupports = nsnull;
    return JS_TRUE;
  }
  if (!JSVAL_IS_OBJECT(aValue)) {
    JS_ReportError(aContext, "Parameter must be an object");
    return JS_FALSE;
  }
  JSObject* jsobj = JSVAL_TO_OBJECT(aValue);
  JSClass* jsclass = JS_GetClass(aContext, jsobj);
  if (!jsclass ||
      !(jsclass->flags & JSCLASS_HAS_PRIVATE) ||
      !(jsclass->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS)) {
    JS_ReportError(aContext,
                   "Parameter isn't an object that implements nsISupports");
    return JS_FALSE;
  }
  if (!JS_InstanceOf(aContext,
                     jsobj,
                     aClass,
                     nsnull))
  {
    char buf[128];
    sprintf(buf, "Parameter isn't an instance of type %s", aClass->name);
    JS_ReportError(aContext, buf);
    return JS_FALSE;
  }
  nsISupports *supports = (nsISupports *)JS_GetPrivate(aContext, jsobj);
  if (!supports) {
    NS_ERROR("This should not happen.");
    JS_ReportError(aContext,
                   "JSObject has JSCLASS_PRIVATE_IS_NSISUPPORTS flag but has a null private slot, please file a bug.");
    return JS_FALSE;
  }
  if (NS_FAILED(supports->QueryInterface(aIID, (void **)aSupports))) {
    char buf[128];
    sprintf(buf, "Parameter must be of type %s", aClass->name);
    JS_ReportError(aContext, buf);
    return JS_FALSE;
  }

  return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ConvertJSValToStr ( nsString aString,
JSContext aContext,
jsval  aValue 
)

Definition at line 250 of file nsJSInstall.cpp.

{
  JSString *jsstring;

  if ( !JSVAL_IS_NULL(aValue) &&
       (jsstring = JS_ValueToString(aContext, aValue)) != nsnull)
  {
    aString.Assign(NS_REINTERPRET_CAST(const PRUnichar*, JS_GetStringChars(jsstring)));
  }
  else
  {
    aString.Truncate();
  }
}

Here is the call graph for this function:

void ConvertJSvalToVersionString ( nsString versionString,
JSContext cx,
jsval  argument 
)

Definition at line 345 of file nsJSInstall.cpp.

{
    versionString.SetLength(0);

    if( JSVAL_IS_OBJECT(argument) )
    {
        if(!JSVAL_IS_NULL(argument))
        {
            JSObject* jsobj   = JSVAL_TO_OBJECT(argument);
            JSClass*  jsclass = JS_GetClass(cx, jsobj);

            if ((nsnull != jsclass) && (jsclass->flags & JSCLASS_HAS_PRIVATE))
            {
                nsIDOMInstallVersion* version = (nsIDOMInstallVersion*)JS_GetPrivate(cx, jsobj);
                version->ToString(versionString);
            }
        }
    }
    else
    {
        ConvertJSValToStr(versionString, cx, argument);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ConvertStrToJSVal ( const nsString aProp,
JSContext aContext,
jsval aReturn 
)

Definition at line 267 of file nsJSInstall.cpp.

{
  JSString *jsstring = JS_NewUCStringCopyN(aContext, NS_REINTERPRET_CAST(const jschar*, aProp.get()), aProp.Length());
  // set the return value
  *aReturn = STRING_TO_JSVAL(jsstring);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void PR_CALLBACK FinalizeInstall ( JSContext cx,
JSObject obj 
)

Definition at line 241 of file nsJSInstall.cpp.

{
    nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
    delete nativeThis;
}

Here is the call graph for this function:

GetInstallProperty ( JSContext cx,
JSObject obj,
jsval  id,
jsval vp 
)

Definition at line 124 of file nsJSInstall.cpp.

{
  nsInstall *a = (nsInstall*)JS_GetPrivate(cx, obj);

  // If there's no private data, this must be the prototype, so ignore
  if (nsnull == a) {
    return JS_TRUE;
  }

  if (JSVAL_IS_INT(id))
  {
    switch(JSVAL_TO_INT(id)) {
      case INSTALL_PLATFORM:
      {
        nsCAutoString prop;
        a->GetInstallPlatform(prop);
        *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(cx, prop.get()) );
        break;
      }

      case INSTALL_ARCHIVE:
      case INSTALL_JARFILE:
      {
        nsInstallFolder* folder = new nsInstallFolder();
        if ( folder )
        {
          folder->Init(a->GetJarFileLocation(),EmptyString());
          JSObject* fileSpecObject =
              JS_NewObject(cx, &FileSpecObjectClass, gFileSpecProto, NULL);

          if (fileSpecObject)
          {
            JS_SetPrivate(cx, fileSpecObject, folder);
            *vp = OBJECT_TO_JSVAL(fileSpecObject);
          }
          else
              delete folder;
        }
        break;
      }

      case INSTALL_ARGUMENTS:
      {
        nsAutoString prop;

        a->GetInstallArguments(prop);
        *vp = STRING_TO_JSVAL( JS_NewUCStringCopyN(cx, NS_REINTERPRET_CAST(const jschar*, prop.get()), prop.Length()) );

        break;
      }

      case INSTALL_URL:
      {
        nsString prop;

        a->GetInstallURL(prop);
        *vp = STRING_TO_JSVAL( JS_NewUCStringCopyN(cx, NS_REINTERPRET_CAST(const jschar*, prop.get()), prop.Length()) );

        break;
      }

      case INSTALL_FLAGS:
          *vp = INT_TO_JSVAL( a->GetInstallFlags() );
          break;

      case INSTALL_FINALSTATUS:
          *vp = INT_TO_JSVAL( a->GetFinalStatus() );
          break;

      case INSTALL_INSTALL:
          *vp = OBJECT_TO_JSVAL(obj);
          break;

      case INSTALL_INSTALLED_FILES:
          *vp = BOOLEAN_TO_JSVAL( a->InInstallTransaction() );
          break;

      default:
        return JS_TRUE;
    }
  }
  else {
    return JS_TRUE;
  }

  return PR_TRUE;
}

Here is the call graph for this function:

JSObject* InitXPInstallObjects ( JSContext jscontext,
nsIFile jarfile,
const PRUnichar url,
const PRUnichar args,
PRUint32  flags,
CHROMEREG_IFACE reg,
nsIZipReader theJARFile 
)

Definition at line 1931 of file nsJSInstall.cpp.

{
  JSObject *installObject;
  nsInstall *nativeInstallObject;

  // new global object
  installObject = JS_NewObject(jscontext, &InstallClass, nsnull, nsnull);
  if (!installObject)
    return nsnull;

  if (!JS_DefineProperty(jscontext, installObject, InstallClass.name,
                         OBJECT_TO_JSVAL(installObject), NULL, NULL, 0))
    return nsnull;

  if (!JS_DefineProperties(jscontext, installObject, InstallProperties))
    return nsnull;

  if (!JS_DefineFunctions(jscontext, installObject, InstallMethods))
    return nsnull;

  if (!JS_DefineConstDoubles(jscontext, installObject, install_constants))
    return nsnull;

  nativeInstallObject = new nsInstall(theJARFile);
  if (!nativeInstallObject)
    return nsnull;

  nativeInstallObject->SetJarFileLocation(jarfile);
  nativeInstallObject->SetInstallArguments(nsAutoString(args));
  nativeInstallObject->SetInstallURL(nsAutoString(url));
  nativeInstallObject->SetInstallFlags(flags);
  nativeInstallObject->SetChromeRegistry(reg);

  JS_SetPrivate(jscontext, installObject, nativeInstallObject);
  nativeInstallObject->SetScriptObject(installObject);


  //
  // Initialize and create the FileOp object
  //
  if(NS_OK != InitXPFileOpObjectPrototype(jscontext, installObject, &gFileOpProto))
  {
    return nsnull;
  }

  gFileOpObject = JS_NewObject(jscontext, &FileOpClass, gFileOpProto, nsnull);
  if (gFileOpObject == nsnull)
    return nsnull;

  JS_SetPrivate(jscontext, gFileOpObject, nativeInstallObject);

  if (!JS_DefineProperty (jscontext,
                          installObject,
                          "File", 
                          OBJECT_TO_JSVAL(gFileOpObject),
                          JS_PropertyStub, 
                          JS_PropertyStub, 
                          JSPROP_READONLY | JSPROP_PERMANENT))
    return nsnull;

  //
  // Initialize the FileSpecObject
  //
  if(NS_OK != InitFileSpecObjectPrototype(jscontext, installObject, &gFileSpecProto))
  {
    return nsnull;
  }


  //
  // Initialize platform specific helper objects
  //
#ifdef _WINDOWS
  JSObject *winRegPrototype     = nsnull;
  JSObject *winProfilePrototype = nsnull;

  if(NS_OK != InitWinRegPrototype(jscontext, installObject, &winRegPrototype))
  {
    return nsnull;
  }
  nativeInstallObject->SaveWinRegPrototype(winRegPrototype);

  if(NS_OK != InitWinProfilePrototype(jscontext, installObject, &winProfilePrototype))
  {
    return nsnull;
  }
  nativeInstallObject->SaveWinProfilePrototype(winProfilePrototype);
#endif

  return installObject;
}

Here is the call graph for this function:

Here is the caller graph for this function:

InstallAbortInstall ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 375 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);

  int32   b0;

  *rval = JSVAL_VOID;

  // If there's no private data, this must be the prototype, so ignore
  if (nsnull == nativeThis) {
    return JS_TRUE;
  }

  if(argc >= 1)
  {
    //  public int AbortInstall(Number aErrorNumber);
    if(JS_ValueToInt32(cx, argv[0], &b0))
    {
      nativeThis->AbortInstall(b0);
    }
    else
    {
      JS_ReportError(cx, "Parameter must be a number");
    }
  }
  else if(argc == 0)
  {
    //  public int AbortInstall(void);
    nativeThis->AbortInstall(nsInstall::INSTALL_CANCELLED);
  }

  return JS_TRUE;
}

Here is the call graph for this function:

InstallAddDirectory ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 415 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);

  PRInt32 nativeRet;
  nsAutoString b0;
  nsAutoString b1;
  nsAutoString b2;
  nsAutoString b3;
  nsAutoString b4;
  JSObject *jsObj;
  nsInstallFolder *folder;
  PRInt32 flags;

  *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);

  // If there's no private data, this must be the prototype, so ignore
  if (nsnull == nativeThis) {
    return JS_TRUE;
  }

  if (argc == 1)
  {
    // public int AddDirectory (String jarSourcePath)

    ConvertJSValToStr(b0, cx, argv[0]);

    if(NS_OK == nativeThis->AddDirectory(b0, &nativeRet))
    {
      *rval = INT_TO_JSVAL(nativeRet);
    }
  }
  else if (argc == 4)
  {
    //  public int AddDirectory ( String registryName,
    //                            String jarSourcePath,
    //                            Object localDirSpec,
    //                            String relativeLocalPath);

    ConvertJSValToStr(b0, cx, argv[0]);
    ConvertJSValToStr(b1, cx, argv[1]);
    ConvertJSValToStr(b3, cx, argv[3]);
    if (argv[2] == JSVAL_NULL || !JSVAL_IS_OBJECT(argv[2])) //argv[2] MUST be a jsval
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    jsObj = JSVAL_TO_OBJECT(argv[2]);
    if (!JS_InstanceOf(cx, jsObj, &FileSpecObjectClass, nsnull))
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);

    if(NS_OK == nativeThis->AddDirectory(b0, b1, folder, b3, &nativeRet))
    {
      *rval = INT_TO_JSVAL(nativeRet);
    }
  }
  else if (argc == 5)
  {
    //  public int AddDirectory ( String registryName,
    //                            String version,  --OR-- VersionInfo version
    //                            String jarSourcePath,
    //                            Object localDirSpec,
    //                            String relativeLocalPath);

    ConvertJSValToStr(b0, cx, argv[0]);
    ConvertJSvalToVersionString(b1, cx, argv[1]);
    ConvertJSValToStr(b2, cx, argv[2]);
    ConvertJSValToStr(b4, cx, argv[4]);

    if ((argv[3] == JSVAL_NULL) || !JSVAL_IS_OBJECT(argv[3])) //argv[3] MUST be a jsval
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    jsObj = JSVAL_TO_OBJECT(argv[3]);
    if (!JS_InstanceOf(cx, jsObj, &FileSpecObjectClass, nsnull))
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);

    if(NS_OK == nativeThis->AddDirectory(b0, b1, b2, folder, b4, &nativeRet))
    {
      *rval = INT_TO_JSVAL(nativeRet);
    }
  }
  else if (argc >= 6)
  {
     //   public int AddDirectory (  String registryName,
     //                              String version,        --OR--     VersionInfo version,
     //                              String jarSourcePath,
     //                              Object localDirSpec,
     //                              String relativeLocalPath,
     //                              Int    flags);

    ConvertJSValToStr(b0, cx, argv[0]);
    ConvertJSvalToVersionString(b1, cx, argv[1]);
    ConvertJSValToStr(b2, cx, argv[2]);
    ConvertJSValToStr(b4, cx, argv[4]);

    if ((argv[3] == JSVAL_NULL) || !JSVAL_IS_OBJECT(argv[3])) //argv[3] MUST be a jsval
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    jsObj = JSVAL_TO_OBJECT(argv[3]);
    if (!JS_InstanceOf(cx, jsObj, &FileSpecObjectClass, nsnull))
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    if(JSVAL_IS_INT(argv[5]))
      flags = JSVAL_TO_INT(argv[5]);
    else
      flags = 0;

    folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);

    if(NS_OK == nativeThis->AddDirectory(b0, b1, b2, folder, b4, flags, &nativeRet))
    {
      *rval = INT_TO_JSVAL(nativeRet);
    }
  }
  else
  {
    JS_ReportError(cx, "Install.AddDirectory() parameters error");
  }

  return JS_TRUE;
}

Here is the call graph for this function:

InstallAddSubcomponent ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 569 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);

  PRInt32 nativeRet;
  nsAutoString b0;
  nsAutoString b1;
  nsAutoString b2;
  nsAutoString b3;
  nsAutoString b4;
  JSObject* jsObj;
  nsInstallFolder* folder;
  PRInt32 flags = 0;
  nsresult rv;

  *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);

  // If there's no private data, this must be the prototype, so ignore
  if (nsnull == nativeThis) {
    return JS_TRUE;
  }

  if(argc >= 6)
  {
    //  public int AddSubcomponent ( String registryName,
    //                               String version,        --OR--     VersionInfo version,
    //                               String jarSourcePath,
    //                               Object localDirSpec,
    //                               String relativeLocalPath,
    //                               Int    flags);

    ConvertJSValToStr(b0, cx, argv[0]);
    ConvertJSvalToVersionString(b1, cx, argv[1]);
    ConvertJSValToStr(b2, cx, argv[2]);
    ConvertJSValToStr(b4, cx, argv[4]);

    if ((argv[3] == JSVAL_NULL) || !JSVAL_IS_OBJECT(argv[3])) //argv[3] MUST be a jsval
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    jsObj = JSVAL_TO_OBJECT(argv[3]);
    if (!JS_InstanceOf(cx, jsObj, &FileSpecObjectClass, nsnull))
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    if(JSVAL_IS_INT(argv[5]))
      flags = JSVAL_TO_INT(argv[5]);
    else
      flags = 0;

    folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);

    jsrefcount saveDepth;
    saveDepth = JS_SuspendRequest(cx);//Need to suspend use of thread or deadlock occurs
    rv= nativeThis->AddSubcomponent(b0, b1, b2, folder, b4, flags, &nativeRet);
    JS_ResumeRequest(cx, saveDepth);

    if (NS_SUCCEEDED(rv))
      *rval = INT_TO_JSVAL(nativeRet);
  }
  else if(argc >= 5)
  {
    //  public int AddSubcomponent ( String registryName,
    //                               String version,  --OR-- VersionInfo version
    //                               String jarSourcePath,
    //                               Object localDirSpec,
    //                               String relativeLocalPath);

    ConvertJSValToStr(b0, cx, argv[0]);
    ConvertJSvalToVersionString(b1, cx, argv[1]);
    ConvertJSValToStr(b2, cx, argv[2]);
    ConvertJSValToStr(b4, cx, argv[4]);

    if ((argv[3] == JSVAL_NULL) || !JSVAL_IS_OBJECT(argv[3])) //argv[3] MUST be a jsval
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    jsObj = JSVAL_TO_OBJECT(argv[3]);

    if (!JS_InstanceOf(cx, jsObj, &FileSpecObjectClass, nsnull))
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);

    jsrefcount saveDepth;
    saveDepth = JS_SuspendRequest(cx);//Need to suspend use of thread or deadlock occurs
    rv = nativeThis->AddSubcomponent(b0, b1, b2, folder, b4, &nativeRet);
    JS_ResumeRequest(cx, saveDepth);

    if (NS_SUCCEEDED(rv))
      *rval = INT_TO_JSVAL(nativeRet);
  }
  else if(argc >= 4)
  {
    //  public int AddSubcomponent ( String registryName,
    //                               String jarSourcePath,
    //                               Object localDirSpec,
    //                               String relativeLocalPath);

    ConvertJSValToStr(b0, cx, argv[0]);
    ConvertJSValToStr(b1, cx, argv[1]);
    ConvertJSValToStr(b3, cx, argv[3]);

    if ((argv[2] == JSVAL_NULL) || !JSVAL_IS_OBJECT(argv[2])) //argv[2] MUST be a jsval
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    jsObj = JSVAL_TO_OBJECT(argv[2]);
    if (!JS_InstanceOf(cx, jsObj, &FileSpecObjectClass, nsnull))
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);

    if(NS_OK == nativeThis->AddSubcomponent(b0, b1, folder, b3, &nativeRet))
    {
      *rval = INT_TO_JSVAL(nativeRet);
    }
  }
  else if(argc >= 1)
  {
    //  public int AddSubcomponent ( String jarSourcePath);

    ConvertJSValToStr(b0, cx, argv[0]);

    if(NS_OK == nativeThis->AddSubcomponent(b0, &nativeRet))
    {
      *rval = INT_TO_JSVAL(nativeRet);
    }
  }
  else
  {
    JS_ReportError(cx, "Install.addFile parameter error");
  }

  return JS_TRUE;
}

Here is the call graph for this function:

InstallAlert ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 1617 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);
  if (!nativeThis)
    return JS_FALSE;

  nsAutoString b0;

  *rval = JSVAL_NULL;

  if(argc == 1)
  {
    //  public int InstallAlert (String aComment);

    ConvertJSValToStr(b0, cx, argv[0]);

    jsrefcount saveDepth = JS_SuspendRequest(cx);//Need to suspend use of thread or deadlock occurs

    nativeThis->Alert(b0);
    JS_ResumeRequest(cx, saveDepth);

  }
  else
  {
    JS_ReportError(cx, "Function Alert requires 1 parameter");
    return JS_FALSE;
  }

  return JS_TRUE;
}

Here is the call graph for this function:

InstallConfirm ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 1653 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);
  if (!nativeThis)
    return JS_FALSE;

  nsAutoString text;
  nsAutoString title;
  PRUint32 buttonFlags = nsIPromptService::STD_OK_CANCEL_BUTTONS;
  nsAutoString button0Title;
  nsAutoString button1Title;
  nsAutoString button2Title;
  nsAutoString checkMsg;
  JSObject* checkObj = 0;
  jsval jsCheckState = 0;
  PRBool checkState = PR_FALSE;
  PRInt32 nativeRet;

  *rval = JSVAL_FALSE;

  if(argc == 0)
  {
    JS_ReportError(cx, "Function Confirm requires at least 1 parameter");
    return JS_FALSE;
  }

  //  public int InstallConfirm (String aComment);
  ConvertJSValToStr(text, cx, argv[0]);

  //  Any additional parameters are optional.
  //  public int InstallConfirm (String aText,
  //                             String aDialogTitle,
  //                             Number aButtonFlags,
  //                             String aButton0Title,
  //                             String aButton1Title,
  //                             String aButton2Title,
  //                             String aCheckMsg,
  //                             Object aCheckState);
  if (argc > 1)
    ConvertJSValToStr(title, cx, argv[1]);

  if(argc > 2)
  {
    if(!JSVAL_IS_INT(argv[2]))
    {
      JS_ReportError(cx, "Parameter 'aButtonFlags' must be a number");
      return JS_FALSE;
    }
    buttonFlags = JSVAL_TO_INT(argv[2]);
  }

  if (argc > 3)
    ConvertJSValToStr(button0Title, cx, argv[3]);
  if (argc > 4)
    ConvertJSValToStr(button1Title, cx, argv[4]);
  if (argc > 5)
    ConvertJSValToStr(button2Title, cx, argv[5]);
  if (argc > 6)
    ConvertJSValToStr(checkMsg, cx, argv[6]);

  if (argc > 7 && !JSVAL_IS_PRIMITIVE(argv[7])) 
  {
    checkObj = JSVAL_TO_OBJECT(argv[7]);
    if (!JS_GetProperty(cx, checkObj, "value", &jsCheckState) ||
      !JSVAL_IS_BOOLEAN(jsCheckState))
    {
      JS_ReportError(cx, "Parameter 'aCheckState' must have a boolean 'value' property");
      return JS_FALSE;
    }
    JS_ValueToBoolean(cx, jsCheckState, &checkState);
  }

  jsrefcount saveDepth = JS_SuspendRequest(cx); //Need to suspend use of thread or deadlock occurs

  nativeThis->ConfirmEx(title, text, buttonFlags, button0Title, button1Title, button2Title, checkMsg, &checkState, &nativeRet);

  JS_ResumeRequest(cx, saveDepth);

  // Only save back checkState when an object was passed as 8th parameter
  if (checkObj)
  {
    jsCheckState = BOOLEAN_TO_JSVAL(checkState);
    JS_SetProperty(cx, checkObj, "value", &jsCheckState);
  }

  // To maintain compatibility with the classic one-arg confirm that returned 1
  // for OK and 0 for cancel/close, we have to swap 0 and 1 here, as confirmEx
  // always returns 0 for the first (i.e. OK) button.
  if (nativeRet == 0)
    nativeRet = 1; // 0 = first button = OK => true(1)
  else if (nativeRet == 1)
    nativeRet = 0; // 1 = second button or window closed = Cancel => false(0)

  *rval = INT_TO_JSVAL(nativeRet);

  return JS_TRUE;
}

Here is the call graph for this function:

InstallDeleteComponent ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 732 of file nsJSInstall.cpp.

{
  // this function was once documented but never supported. Return an error,
  // but don't remove which would kill scripts that reference this.
  *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
  return JS_TRUE;
}
InstallExecute ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 744 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);

  PRInt32 nativeRet;
  nsAutoString b0;
  nsAutoString b1;
  PRBool       blocking = PR_FALSE;

  *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);

  // If there's no private data, this must be the prototype, so ignore
  if (nsnull == nativeThis) {
    return JS_TRUE;
  }

  if(argc >= 3)
  {
    //  public int Execute ( String jarSourcePath,
    //                       String args,
    //                       Bool   blocking);

    ConvertJSValToStr(b1, cx, argv[1]);
    ConvertJSValToBool(&blocking, cx,argv[2]);
  }
  else if(argc >= 2)
  {
    if(JSVAL_IS_BOOLEAN(argv[1]))
    {
      //  public int Execute ( String jarSourcePath,
      //                       Bool   blocking);
      ConvertJSValToBool(&blocking, cx, argv[1]);
    }
    else
    {
      //  public int Execute ( String jarSourcePath,
      //                       String args);
      ConvertJSValToStr(b1, cx, argv[1]);
    }
  }

  if(argc >= 1)
  {
    //  public int Execute ( String jarSourcePath);
    ConvertJSValToStr(b0, cx, argv[0]);

    jsrefcount saveDepth;
    saveDepth = JS_SuspendRequest(cx);//Need to suspend use of thread or deadlock occurs
    nativeThis->Execute(b0, b1, blocking, &nativeRet);
    JS_ResumeRequest(cx, saveDepth);

    *rval = INT_TO_JSVAL(nativeRet);
  }
  else
  {
    JS_ReportWarning(cx, "Function Execute requires 1 parameter");
  }

  return JS_TRUE;
}

Here is the call graph for this function:

InstallFinalizeInstall ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 811 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);

  PRInt32 nativeRet;

  *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);

  // If there's no private data, this must be the prototype, so ignore
  if (nsnull == nativeThis) {
    return JS_TRUE;
  }

  jsrefcount saveDepth;
  saveDepth = JS_SuspendRequest(cx);//Need to suspend use of thread or deadlock occurs
  //  public int FinalizeInstall (void);
  nsresult rv = nativeThis->FinalizeInstall(&nativeRet);
  JS_ResumeRequest(cx, saveDepth);

  if (NS_SUCCEEDED(rv))
    *rval = INT_TO_JSVAL(nativeRet);

  return JS_TRUE;
}

Here is the call graph for this function:

InstallGestalt ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 842 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);

  PRInt32 nativeRet;
  nsAutoString b0;

  *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);

  // If there's no private data, this must be the prototype, so ignore
  if (nsnull == nativeThis) {
    return JS_TRUE;
  }

  if(argc >= 1)
  {
    //  public int Gestalt ( String selector,
    //                       long   *response);

    ConvertJSValToStr(b0, cx, argv[0]);

    if(NS_OK != nativeThis->Gestalt(b0, &nativeRet))
    {
      return JS_FALSE;
    }

    *rval = INT_TO_JSVAL(nativeRet);
  }
  else
  {
    JS_ReportError(cx, "Function Gestalt requires 1 parameters");
    return JS_FALSE;
  }

  return JS_TRUE;
}

Here is the call graph for this function:

InstallGetComponentFolder ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 885 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);

  nsInstallFolder* folder;
  nsAutoString b0;
  nsAutoString b1;

  *rval = JSVAL_NULL;

  // If there's no private data, this must be the prototype, so ignore
  if (nsnull == nativeThis) {
    return JS_TRUE;
  }

  if(argc >= 2)
  {
    //  public int GetComponentFolder ( String registryName,
    //                                  String subDirectory);
    ConvertJSValToStr(b0, cx, argv[0]);
    ConvertJSValToStr(b1, cx, argv[1]);

    if(NS_OK != nativeThis->GetComponentFolder(b0, b1, &folder))
    {
      // error!
      return JS_FALSE;
    }
  }
  else if(argc >= 1)
  {
    //  public int GetComponentFolder ( String registryName);

    ConvertJSValToStr(b0, cx, argv[0]);

    if(NS_OK != nativeThis->GetComponentFolder(b0, &folder))
    {
      // error!
      return JS_FALSE;
    }
  }
  else
  {
    JS_ReportError(cx, "Function GetComponentFolder requires 2 parameters");
    return JS_FALSE;
  }

  // if we couldn't find one return null rval from here
  if(nsnull == folder)
  {
    return JS_TRUE;
  }

  /* Now create the new JSObject */
  JSObject* fileSpecObject;

  fileSpecObject = JS_NewObject(cx, &FileSpecObjectClass, gFileSpecProto, NULL);
  if (fileSpecObject == NULL)
    return JS_FALSE;

  JS_SetPrivate(cx, fileSpecObject, folder);
  if (fileSpecObject == NULL)
    return JS_FALSE;

  *rval = OBJECT_TO_JSVAL(fileSpecObject);

  return JS_TRUE;
}

Here is the call graph for this function:

InstallGetFolder ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 959 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);

  JSObject *jsObj;
  nsAutoString b0;
  nsAutoString b1;
  nsInstallFolder *folder = nsnull;

  *rval = JSVAL_NULL;

  // If there's no private data, this must be the prototype, so ignore
  if (nsnull == nativeThis) {
    return JS_TRUE;
  }

  if(argc >= 2)
  {
    ConvertJSValToStr(b1, cx, argv[1]); // we know that the second param must be a string
    if(JSVAL_IS_STRING(argv[0])) // check if the first argument is a string
    {
      ConvertJSValToStr(b0, cx, argv[0]);
      if(NS_OK != nativeThis->GetFolder(b0, b1, &folder))
        return JS_TRUE;
    }
    else /* it must be an object */
    {

      if ((argv[0] == JSVAL_NULL) || !JSVAL_IS_OBJECT(argv[0])) //argv[0] MUST be a jsval
      {
        *rval = JSVAL_NULL;
        JS_ReportError(cx, "GetFolder:Invalid Parameter");
        return JS_TRUE;
      }

      jsObj = JSVAL_TO_OBJECT(argv[0]);
      if (!JS_InstanceOf(cx, jsObj, &FileSpecObjectClass, nsnull))
      {
        *rval = JSVAL_NULL;
        JS_ReportError(cx, "GetFolder:Invalid Parameter");
        return JS_TRUE;
      }

      folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);
      if (!folder)
      {
        JS_ReportError(cx, "GetFolder:Invalid Parameter");
        return JS_FALSE;
      }
      else if(NS_OK != nativeThis->GetFolder(*folder, b1, &folder))
        return JS_TRUE;
    }

    if(nsnull == folder)
      return JS_TRUE;
  }
  else if(argc >= 1)
  {
    //  public int GetFolder ( String folderName);

    ConvertJSValToStr(b0, cx, argv[0]);

    if(NS_OK != nativeThis->GetFolder(b0, &folder))
    {
      return JS_TRUE;
    }

    if(nsnull == folder)
      return JS_TRUE;
  }
  else
  {
    JS_ReportError(cx, "Function GetFolder requires at least 1 parameter");
    return JS_FALSE;
  }

  if ( folder )
  {
    /* Now create the new JSObject */
    JSObject* fileSpecObject;

    fileSpecObject = JS_NewObject(cx, &FileSpecObjectClass, gFileSpecProto, NULL);
    if (fileSpecObject == NULL)
      return JS_FALSE;

    JS_SetPrivate(cx, fileSpecObject, folder);
    if (fileSpecObject == NULL)
      return JS_FALSE;

    *rval = OBJECT_TO_JSVAL(fileSpecObject);
  }


  return JS_TRUE;
}

Here is the call graph for this function:

InstallGetLastError ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 1062 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);

  PRInt32 nativeRet;


  *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);

  // If there's no private data, this must be the prototype, so ignore
  if (nsnull == nativeThis) {
    return JS_TRUE;
  }

  //  public int GetLastError (void);

  if(NS_OK == nativeThis->GetLastError(&nativeRet)) {
    *rval = INT_TO_JSVAL(nativeRet);
  }

  return JS_TRUE;
}

Here is the call graph for this function:

InstallGetWinProfile ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 1091 of file nsJSInstall.cpp.

{
  *rval = JSVAL_NULL;

#ifdef _WINDOWS
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);
  if (!nativeThis)
    return JS_FALSE;

  nsAutoString b0;
  nsAutoString b1;

  if(argc >= 2)
  {
    //  public int GetWinProfile (Object folder,
    //                            String file);

    ConvertJSValToStr(b0, cx, argv[0]);
    ConvertJSValToStr(b1, cx, argv[1]);

    if(NS_OK != nativeThis->GetWinProfile(b0, b1, cx, &WinProfileClass, rval))
    {
      return JS_FALSE;
    }
  }
  else
  {
    JS_ReportError(cx, "Function GetWinProfile requires 0 parameters");
    return JS_FALSE;
  }
#endif

  return JS_TRUE;
}

Here is the call graph for this function:

InstallGetWinRegistry ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 1132 of file nsJSInstall.cpp.

{
  *rval = JSVAL_NULL;

#ifdef _WINDOWS

  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);
  if (!nativeThis)
    return JS_FALSE;

  //  public int GetWinRegistry (void);
  if(NS_OK != nativeThis->GetWinRegistry(cx, &WinRegClass, rval))
  {
    *rval = JSVAL_NULL;
    return JS_TRUE;
  }
#endif

  return JS_TRUE;
}

Here is the call graph for this function:

InstallLoadResources ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 1159 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);

  nsAutoString b0;

  *rval = JSVAL_NULL;

  // If there's no private data, this must be the prototype, so ignore
  if (nsnull == nativeThis) {
    return JS_TRUE;
  }

  if (argc >= 1)
  {
    ConvertJSValToStr(b0, cx, argv[0]);
    if (NS_OK != nativeThis->LoadResources(cx, b0, rval))
    {
      return JS_FALSE;
    }
  }
  else
  {
    JS_ReportError(cx, "Function LoadResources requires 1 parameter");
    return JS_FALSE;
  }

  return JS_TRUE;
}

Here is the call graph for this function:

InstallLogComment ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 1584 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);
  if (!nativeThis)
    return JS_FALSE;

  nsAutoString b0;

  *rval = JSVAL_NULL;

  if(argc >= 1)
  {
    //  public int LogComment (String aComment);

    ConvertJSValToStr(b0, cx, argv[0]);

    nativeThis->LogComment(b0);
  }
  else
  {
    JS_ReportError(cx, "Function LogComment requires 1 parameter");
    return JS_FALSE;
  }

  return JS_TRUE;
}

Here is the call graph for this function:

InstallPatch ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 1195 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);

  PRInt32 nativeRet;
  nsAutoString b0;
  nsAutoString b1;
  nsAutoString b2;
  nsAutoString b3;
  nsAutoString b4;

  JSObject *jsObj;

  nsInstallFolder *folder = nsnull;


  *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);

  // If there's no private data, this must be the prototype, so ignore
  if (nsnull == nativeThis) {
    return JS_TRUE;
  }

  if(argc >= 5)
  {
    //  public int Patch (String registryName,
    //                    String version,        --OR-- VersionInfo version,
    //                    String jarSourcePath,
    //                    Object localDirSpec,
    //                    String relativeLocalPath);

    ConvertJSValToStr(b0, cx, argv[0]);
    ConvertJSvalToVersionString(b1, cx, argv[1]);
    ConvertJSValToStr(b2, cx, argv[2]);
    ConvertJSValToStr(b3, cx, argv[4]);

    if ((argv[3] == JSVAL_NULL) || !JSVAL_IS_OBJECT(argv[3])) //argv[3] MUST be a jsval
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    jsObj = JSVAL_TO_OBJECT(argv[3]);
    if (!JS_InstanceOf(cx, jsObj, &FileSpecObjectClass, nsnull))
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);

    if(NS_OK != nativeThis->Patch(b0, b1, b2, folder, b3, &nativeRet))
    {
        return JS_FALSE;
    }

    *rval = INT_TO_JSVAL(nativeRet);
  }
  else if(argc >= 4)
  {
    //  public int Patch (String registryName,
    //                    String jarSourcePath,
    //                    Object localDirSpec,
    //                    String relativeLocalPath);

    ConvertJSValToStr(b0, cx, argv[0]);
    ConvertJSValToStr(b1, cx, argv[1]);
    ConvertJSValToStr(b2, cx, argv[3]);

    if ((argv[2] == JSVAL_NULL) || !JSVAL_IS_OBJECT(argv[2])) //argv[2] MUST be a jsval
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    jsObj = JSVAL_TO_OBJECT(argv[2]);
    if (!JS_InstanceOf(cx, jsObj, &FileSpecObjectClass, nsnull))
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);

    if(NS_OK != nativeThis->Patch(b0, b1, folder, b2, &nativeRet))
    {
      return JS_FALSE;
    }

    *rval = INT_TO_JSVAL(nativeRet);
  }
  else
  {
    JS_ReportError(cx, "Function Patch requires 5 parameters");
    return JS_FALSE;
  }

  return JS_TRUE;
}

Here is the call graph for this function:

InstallRefreshPlugins ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 1354 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);

  // If there's no private data, this must be the prototype, so ignore
  if (!nativeThis)
  {
    *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
  }
  else
  {
    PRBool reloadPages = PR_TRUE;
    if (argc >= 1)
      reloadPages = JSVAL_TO_BOOLEAN(argv[0]);

    *rval = INT_TO_JSVAL(nativeThis->RefreshPlugins(reloadPages));
  }
  return JS_TRUE;
}

Here is the call graph for this function:

InstallRegisterChrome ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 1308 of file nsJSInstall.cpp.

{
  // If there's no private data, this must be the prototype, so ignore
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);

  if (nsnull == nativeThis) {
    *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
    return JS_TRUE;
  }

  // Now validate the arguments
  uint32 chromeType = 0;
  nsIFile* chrome = nsnull;
  if ( argc >=2 )
  {
    JS_ValueToECMAUint32(cx, argv[0], &chromeType);

    if (argv[1] != JSVAL_NULL && JSVAL_IS_OBJECT(argv[1]))
    {
      JSObject* jsObj = JSVAL_TO_OBJECT(argv[1]);
      if (JS_InstanceOf(cx, jsObj, &FileSpecObjectClass, nsnull))
      {
        nsInstallFolder* folder = (nsInstallFolder*)JS_GetPrivate(cx,jsObj);
        if (folder)
        {
          chrome = folder->GetFileSpec();
        }
      }
    }
  }
  nsAutoString path;
  if (argc >= 3) {
    ConvertJSValToStr(path, cx, argv[2]);
  }

  *rval = INT_TO_JSVAL(nativeThis->RegisterChrome(chrome, chromeType, NS_ConvertUCS2toUTF8(path).get()));

  return JS_TRUE;
}

Here is the call graph for this function:

InstallResetError ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 1380 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);

  *rval = JSVAL_VOID;

  // If there's no private data, this must be the prototype, so ignore
  if (!nativeThis)
    return JS_TRUE;

  // Supported forms:
  //    void resetError()
  //    void resetError(int error)
  int32 val = 0;
  if ( argc >= 1 )
    JS_ValueToECMAInt32(cx, argv[0], &val);

  nativeThis->ResetError(val);
  return JS_TRUE;
}

Here is the call graph for this function:

InstallSetPackageFolder ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 1407 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);

  nsAutoString b0;
  JSObject *jsObj;
  nsInstallFolder *folder;

  *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);

  // If there's no private data, this must be the prototype, so ignore
  if (nsnull == nativeThis) {
    return JS_TRUE;
  }

  if(argc >= 1)
  {
    //  public int SetPackageFolder (Object folder);

    if ((argv[0] == JSVAL_NULL)  || !JSVAL_IS_OBJECT(argv[0])) //argv[0] MUST be a jsval
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    jsObj = JSVAL_TO_OBJECT(argv[0]);
    if (!JS_InstanceOf(cx, jsObj, &FileSpecObjectClass, nsnull))
    {
      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
      return JS_TRUE;
    }

    folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);
    if (!folder)
    {
      JS_ReportError(cx, "setPackageFolder:Invalid Parameter");
      return JS_FALSE;
    }
    else
      if(NS_OK != nativeThis->SetPackageFolder(*folder))
        return JS_FALSE;

    *rval = JSVAL_ZERO;
  }
  else
  {
    JS_ReportError(cx, "Function SetPackageFolder requires 1 parameters");
    return JS_FALSE;
  }

  return JS_TRUE;
}

Here is the call graph for this function:

InstallStartInstall ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 1467 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);

  PRInt32 nativeRet;
  nsAutoString b0;
  nsAutoString b1;
  nsAutoString b2;

  *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);

  // If there's no private data, this must be the prototype, so ignore
  if (nsnull == nativeThis) {
    return JS_TRUE;
  }

  if(argc == 3 || argc == 4)
  {
    //  public int StartInstall (String userPackageName,
    //                           String package,
    //                           String version); --OR-- VersionInfo version
    //                           flags?
    ConvertJSValToStr(b0, cx, argv[0]);
    ConvertJSValToStr(b1, cx, argv[1]);
    ConvertJSvalToVersionString(b2, cx, argv[2]);

    jsrefcount saveDepth;
    saveDepth = JS_SuspendRequest(cx);//Need to suspend use of thread or deadlock occurs

    nsresult rv = nativeThis->StartInstall(b0, b1, b2, &nativeRet);

    JS_ResumeRequest(cx, saveDepth); //Resume the suspened thread
    if (NS_FAILED(rv))
    {
        return JS_FALSE;
    }

    *rval = INT_TO_JSVAL(nativeRet);
  }
  else
  {
    JS_ReportError(cx, "Function StartInstall requires 3 parameters");
    return JS_FALSE;
  }

  return JS_TRUE;
}

Here is the call graph for this function:

InstallTRACE ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 1562 of file nsJSInstall.cpp.

{
  nsAutoString b0;

  ConvertJSValToStr(b0, cx, argv[0]);

  char *tempStr;
  tempStr = ToNewCString(b0);
  printf("Install:\t%s\n", tempStr);

  Recycle(tempStr);

  return JS_TRUE;
}

Here is the call graph for this function:

InstallUninstall ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 1521 of file nsJSInstall.cpp.

{
  nsInstall *nativeThis =
    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);

  PRInt32 nativeRet;
  nsAutoString b0;

  *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);

  // If there's no private data, this must be the prototype, so ignore
  if (nsnull == nativeThis) {
    return JS_TRUE;
  }

  if(argc >= 1)
  {
    //  public int Uninstall (String packageName);

    ConvertJSValToStr(b0, cx, argv[0]);

    if(NS_OK != nativeThis->Uninstall(b0, &nativeRet))
    {
      return JS_FALSE;
    }

    *rval = INT_TO_JSVAL(nativeRet);
  }
  else
  {
    JS_ReportError(cx, "Function Uninstall requires 1 parameters");
    return JS_FALSE;
  }

  return JS_TRUE;
}

Here is the call graph for this function:

SetInstallProperty ( JSContext cx,
JSObject obj,
jsval  id,
jsval vp 
)

Definition at line 217 of file nsJSInstall.cpp.

{
  nsInstall *a = (nsInstall*)JS_GetPrivate(cx, obj);

  // If there's no private data, this must be the prototype, so ignore
  if (nsnull == a) {
    return JS_TRUE;
  }

  if (JSVAL_IS_INT(id)) {
    switch(JSVAL_TO_INT(id)) {
      case 0:
      default:
          return JS_TRUE;
    }
  }
  else {
    return JS_TRUE;
  }

  return PR_TRUE;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 81 of file nsJSFile.cpp.

Definition at line 68 of file nsJSFileSpecObj.cpp.

Definition at line 118 of file nsJSInstall.cpp.

Definition at line 112 of file nsJSInstall.cpp.

Definition at line 115 of file nsJSInstall.cpp.

Definition at line 1770 of file nsJSInstall.cpp.

Definition at line 1867 of file nsJSInstall.cpp.