Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
nsSoftwareUpdateRun.cpp File Reference
#include "nsSoftwareUpdate.h"
#include "nsSoftwareUpdateRun.h"
#include "nsSoftwareUpdateIIDs.h"
#include "nsInstall.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsProxiedService.h"
#include "nsIURI.h"
#include "nsIFileURL.h"
#include "nsNetUtil.h"
#include "nspr.h"
#include "jsapi.h"
#include "nsIEventQueueService.h"
#include "nsIEnumerator.h"
#include "nsIZipReader.h"
#include "nsIJSRuntimeService.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsILocalFile.h"
#include "nsIChromeRegistry.h"
#include "nsInstallTrigger.h"
#include "nsIConsoleService.h"
#include "nsIScriptError.h"
#include "nsIJAR.h"
#include "nsIPrincipal.h"
#include "nsIExtensionManager.h"

Go to the source code of this file.

Functions

static NS_DEFINE_CID (kSoftwareUpdateCID, NS_SoftwareUpdate_CID)
static NS_DEFINE_CID (kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID)
JSObjectInitXPInstallObjects (JSContext *jscontext, nsIFile *jarfile, const PRUnichar *url, const PRUnichar *args, PRUint32 flags, CHROMEREG_IFACE *registry, nsIZipReader *hZip)
nsresult InitInstallVersionClass (JSContext *jscontext, JSObject *global, void **prototype)
nsresult InitInstallTriggerGlobalClass (JSContext *jscontext, JSObject *global, void **prototype)
 PR_STATIC_CALLBACK (void) XPInstallErrorReporter(JSContext *cx
static PRInt32 GetInstallScriptFromJarfile (nsIZipReader *hZip, char **scriptBuffer, PRUint32 *scriptLength)
static PRInt32 OpenAndValidateArchive (nsIZipReader *hZip, nsIFile *jarFile, nsIPrincipal *aPrincipal)
static nsresult SetupInstallContext (nsIZipReader *hZip, nsIFile *jarFile, const PRUnichar *url, const PRUnichar *args, PRUint32 flags, CHROMEREG_IFACE *reg, JSRuntime *jsRT, JSContext **jsCX, JSObject **jsGlob)
void RunInstallOnThread (void *data)
nsresult VerifySigning (nsIZipReader *hZip, nsIPrincipal *aPrincipal)
static void XPInstallErrorReporter (JSContext *cx, const char *message, JSErrorReport *report)
PRInt32 RunInstall (nsInstallInfo *installInfo)
void RunChromeInstallOnThread (void *data)

Variables

const char * message
const char JSErrorReportreport

Function Documentation

static PRInt32 GetInstallScriptFromJarfile ( nsIZipReader hZip,
char **  scriptBuffer,
PRUint32 scriptLength 
) [static]

Definition at line 300 of file nsSoftwareUpdateRun.cpp.

{
    PRInt32 result = NS_OK;

    *scriptBuffer = nsnull;
    *scriptLength = 0;

    // Extract the install.js file.
    nsCOMPtr<nsIInputStream> instream;
    nsresult rv = hZip->GetInputStream("install.js", getter_AddRefs(instream));
    if ( NS_SUCCEEDED(rv) )
    {
        // Read it into a buffer
        char* buffer;
        PRUint32 bufferLength;
        PRUint32 readLength;
        result = nsInstall::CANT_READ_ARCHIVE;

        rv = instream->Available(&bufferLength);
        if (NS_SUCCEEDED(rv))
        {
            buffer = new char[bufferLength + 1];

            if (buffer != nsnull)
            {
                rv = instream->Read(buffer, bufferLength, &readLength);

                if (NS_SUCCEEDED(rv) && readLength > 0)
                {
                    *scriptBuffer = buffer;
                    *scriptLength = readLength;
                    result = NS_OK;
                }
                else
                {
                    delete [] buffer;
                }
            }
        }
        instream->Close();
    }
    else
    {
        result = nsInstall::NO_INSTALL_SCRIPT;
    }

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult InitInstallTriggerGlobalClass ( JSContext jscontext,
JSObject global,
void **  prototype 
)

Definition at line 777 of file nsJSInstallTriggerGlobal.cpp.

{
  JSObject *proto = nsnull;

  if (prototype != nsnull)
    *prototype = nsnull;

    proto = JS_InitClass(jscontext,                       // context
                         global,                          // global object
                         nsnull,                          // parent proto
                         &InstallTriggerGlobalClass,      // JSClass
                         nsnull,                          // JSNative ctor
                         nsnull,                          // ctor args
                         nsnull,                          // proto props
                         nsnull,                          // proto funcs
                         nsnull,                          // ctor props (static)
                         InstallTriggerGlobalMethods);    // ctor funcs (static)


    if (nsnull == proto) return NS_ERROR_FAILURE;

    if ( PR_FALSE == JS_DefineConstDoubles(jscontext, proto, diff_constants) )
            return NS_ERROR_FAILURE;

    if (prototype != nsnull)
      *prototype = proto;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult InitInstallVersionClass ( JSContext jscontext,
JSObject global,
void **  prototype 
)

Definition at line 583 of file nsJSInstallVersion.cpp.

{
  JSObject *proto = nsnull;

  if (prototype != nsnull)
    *prototype = nsnull;

  proto = JS_InitClass(jscontext,     // context
                       global,        // global object
                       nsnull,  // parent proto 
                       &InstallVersionClass,      // JSClass
                       InstallVersion,            // JSNative ctor
                       0,             // ctor args
                       InstallVersionProperties,  // proto props
                       InstallVersionMethods,     // proto funcs
                       nsnull,        // ctor props (static)
                       nsnull);       // ctor funcs (static)
  
  if (nsnull == proto)
      return NS_ERROR_FAILURE;
  
  
  if ( PR_FALSE == JS_DefineConstDoubles(jscontext, proto, version_constants) )
            return NS_ERROR_FAILURE;
  
  if (prototype != nsnull)
      *prototype = proto;
  
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

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:

static NS_DEFINE_CID ( kSoftwareUpdateCID  ,
NS_SoftwareUpdate_CID   
) [static]
static PRInt32 OpenAndValidateArchive ( nsIZipReader hZip,
nsIFile jarFile,
nsIPrincipal aPrincipal 
) [static]

Definition at line 256 of file nsSoftwareUpdateRun.cpp.

{
    if (!jarFile)
        return nsInstall::DOWNLOAD_ERROR;

    nsCOMPtr<nsIFile> jFile;
    nsresult rv =jarFile->Clone(getter_AddRefs(jFile));
    if (NS_SUCCEEDED(rv))
        rv = hZip->Init(jFile);

    if (NS_FAILED(rv))
        return nsInstall::CANT_READ_ARCHIVE;

    rv = hZip->Open();
    if (NS_FAILED(rv))
        return nsInstall::CANT_READ_ARCHIVE;
 
    // CRC check the integrity of all items in this archive
    rv = hZip->Test(nsnull);
    if (NS_FAILED(rv))
    {
        NS_WARNING("CRC check of archive failed!");
        return nsInstall::CANT_READ_ARCHIVE;
    }

    rv = VerifySigning(hZip, aPrincipal);
    if (NS_FAILED(rv))
    {
        NS_WARNING("Signing check of archive failed!");
        return nsInstall::INVALID_SIGNATURE;
    }
 
    return nsInstall::SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 102 of file TestIPCLocks.cpp.

{
  const char *lockName = (const char *) arg;

  LOG("entering TestThread [lock=%s]\n", lockName);

  nsresult rv;

  RandomSleep(1000, 1100);

  //LOG("done sleeping\n");

  rv = gLockService->AcquireLock(lockName, PR_TRUE);
  if (NS_SUCCEEDED(rv))
  {
    //LOG("acquired lock \"%s\"\n", lockName);
    RandomSleep(500, 1000);
    //LOG("releasing lock \"%s\"\n", lockName);
    rv = gLockService->ReleaseLock(lockName);
    if (NS_FAILED(rv))
    {
      LOG("failed to release lock [rv=%x]\n", rv);
      NS_ERROR("failed to release lock");
    }
  }
  else
  {
    LOG("failed to acquire lock [rv=%x]\n", rv);
    NS_NOTREACHED("failed to acquire lock");
  }

  LOG("exiting TestThread [lock=%s rv=%x]\n", lockName, rv);
}

Here is the call graph for this function:

Definition at line 626 of file nsSoftwareUpdateRun.cpp.

{
    nsresult rv;

    NS_ASSERTION(data, "No nsInstallInfo passed to Chrome Install");
    nsInstallInfo *info = (nsInstallInfo*)data;
    nsIXPIListener* listener = info->GetListener();

    if (listener)
        listener->OnInstallStart(info->GetURL());

    // make sure we've got a chrome registry -- can't proceed if not
    CHROMEREG_IFACE* reg = info->GetChromeRegistry();
    NS_ASSERTION(reg, "We shouldn't get here without a chrome registry.");

    if (reg)
    {
#ifdef MOZ_XUL_APP
        if (info->GetType() == CHROME_SKIN) {
            static NS_DEFINE_CID(kZipReaderCID,  NS_ZIPREADER_CID);
            nsCOMPtr<nsIZipReader> hZip = do_CreateInstance(kZipReaderCID, &rv);
            if (hZip)
                rv = hZip->Init(info->GetFile());
            if (NS_SUCCEEDED(rv))
                rv = hZip->Open();

            if (NS_SUCCEEDED(rv))
            {
                rv = hZip->Test("install.rdf");
                nsIExtensionManager* em = info->GetExtensionManager();
                if (NS_SUCCEEDED(rv) && em) {
                    rv = em->InstallItemFromFile(info->GetFile(), 
                                                 NS_INSTALL_LOCATION_APPPROFILE);
                }
            }
            hZip->Close();
            // Extension Manager copies the theme .jar file to 
            // a different location, so remove the temporary file.
            info->GetFile()->Remove(PR_FALSE);
        }
#else
        PRBool isSkin    = (info->GetType() & CHROME_SKIN);
        PRBool isLocale  = (info->GetType() & CHROME_LOCALE);
        PRBool isContent = (info->GetType() & CHROME_CONTENT);
        PRBool selected  = (info->GetFlags() != 0);

        const nsCString& spec = info->GetFileJARSpec();

        if ( isContent )
            rv = reg->InstallPackage(spec.get(), PR_TRUE);

        if ( isSkin )
        {
            rv = reg->InstallSkin(spec.get(), PR_TRUE, PR_FALSE);
                
            if (NS_SUCCEEDED(rv) && selected)
            {
                NS_ConvertUCS2toUTF8 utf8Args(info->GetArguments());
                rv = reg->SelectSkin(utf8Args, PR_TRUE);
            }
        }

        if ( isLocale )
        {
            rv = reg->InstallLocale(spec.get(), PR_TRUE);

            if (NS_SUCCEEDED(rv) && selected)
            {
                NS_ConvertUCS2toUTF8 utf8Args(info->GetArguments());
                rv = reg->SelectLocale(utf8Args, PR_TRUE);
            }
        }

        // now that all types are registered try to activate
        if ( isSkin && selected )
            reg->RefreshSkins();

#ifdef RELOAD_CHROME_WORKS
// XXX ReloadChrome() crashes right now
            if ( isContent || (isLocale && selected) )
                reg->ReloadChrome();
#endif
#endif
    }

    if (listener)
        listener->OnInstallDone(info->GetURL(), nsInstall::SUCCESS);

    delete info;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 RunInstall ( nsInstallInfo installInfo)

Definition at line 420 of file nsSoftwareUpdateRun.cpp.

{
    if (installInfo->GetFlags() & XPI_NO_NEW_THREAD)
    {
        RunInstallOnThread((void *)installInfo);
    }
    else
    {
        PR_CreateThread(PR_USER_THREAD,
                        RunInstallOnThread,
                        (void*)installInfo,
                        PR_PRIORITY_NORMAL,
                        PR_GLOBAL_THREAD,
                        PR_UNJOINABLE_THREAD,
                        0);
    }
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 448 of file nsSoftwareUpdateRun.cpp.

{
    nsInstallInfo *installInfo = (nsInstallInfo*)data;

    char        *scriptBuffer = nsnull;
    PRUint32    scriptLength;

    JSRuntime   *rt;
    JSContext   *cx;
    JSObject    *glob;

    static NS_DEFINE_IID(kZipReaderCID,  NS_ZIPREADER_CID);

    nsresult rv;
    nsCOMPtr<nsIZipReader> hZip = do_CreateInstance(kZipReaderCID, &rv);
    if (NS_FAILED(rv))
        return;

    // we will plan on sending a failure status back from here unless we
    // find positive acknowledgement that the script sent the status
    PRInt32     finalStatus;

    nsCOMPtr<nsIXPIListener> listener;

    // lets set up an eventQ so that our xpcom/proxies will not have to:
    nsCOMPtr<nsIEventQueue> eventQ;
    nsCOMPtr<nsIEventQueueService> eventQService =
             do_GetService(kEventQueueServiceCID, &rv);
    if (NS_SUCCEEDED(rv))
    {
        eventQService->CreateMonitoredThreadEventQueue();
        eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(eventQ));
    }

    nsCOMPtr<nsISoftwareUpdate> softwareUpdate =
             do_GetService(kSoftwareUpdateCID, &rv);

    if (NS_FAILED(rv))
    {
        NS_WARNING("shouldn't have RunInstall() if we can't get SoftwareUpdate");
        return;
    }

    softwareUpdate->SetActiveListener( installInfo->GetListener() );
    softwareUpdate->GetMasterListener(getter_AddRefs(listener));

    if(listener)
        listener->OnInstallStart( installInfo->GetURL() );

    nsCOMPtr<nsIFile> jarpath = installInfo->GetFile();

    finalStatus = OpenAndValidateArchive( hZip,
                                          jarpath,
                                          installInfo->mPrincipal);

    if (finalStatus == nsInstall::SUCCESS)
    {
#ifdef MOZ_XUL_APP
        if (NS_SUCCEEDED(hZip->Test("install.rdf")) && !(nsSoftwareUpdate::GetProgramDirectory()))
        {
            hZip->Close();
            // appears to be an Extension Manager install
            nsIExtensionManager* em = installInfo->GetExtensionManager();
            if (em)
            {
                rv = em->InstallItemFromFile(jarpath, 
                                             NS_INSTALL_LOCATION_APPPROFILE);
                if (NS_FAILED(rv))
                    finalStatus = nsInstall::EXECUTION_ERROR;
            } else {
                finalStatus = nsInstall::UNEXPECTED_ERROR;
            }
            // If install.rdf exists, but the install failed, we don't want
            // to try an install.js install.
        } else
#endif
        {
            // If we're the suite, or there is no install.rdf,
            // try original XPInstall
            finalStatus = GetInstallScriptFromJarfile( hZip,
                                                       &scriptBuffer,
                                                       &scriptLength);
            if ( finalStatus == NS_OK && scriptBuffer )
            {
                // create our runtime
                rt = JS_NewRuntime(4L * 1024L * 1024L);

                rv = SetupInstallContext( hZip, jarpath,
                                          installInfo->GetURL(),
                                          installInfo->GetArguments(),
                                          installInfo->GetFlags(),
                                          installInfo->GetChromeRegistry(),
                                          rt, &cx, &glob);

                if (NS_SUCCEEDED(rv))
                {
                    // Go ahead and run!!
                    jsval rval;
                    jsval installedFiles;
                    JS_BeginRequest(cx); //Increment JS thread counter associated
                                        //with this context
                    PRBool ok = JS_EvaluateScript(  cx,
                                                    glob,
                                                    scriptBuffer,
                                                    scriptLength,
                                                    nsnull,
                                                    0,
                                                    &rval);


                    if(!ok)
                    {
                        // problem compiling or running script -- a true SCRIPT_ERROR
                        if(JS_GetProperty(cx, glob, "_installedFiles", &installedFiles) &&
                          JSVAL_TO_BOOLEAN(installedFiles))
                        {
                            nsInstall *a = (nsInstall*)JS_GetPrivate(cx, glob);
                            a->InternalAbort(nsInstall::SCRIPT_ERROR);
                        }

                        finalStatus = nsInstall::SCRIPT_ERROR;
                    }
                    else
                    {
                        // check to make sure the script sent back a status -- if
                        // not the install may have been syntactically correct but
                        // left the init/(perform|cancel) transaction open

                        if(JS_GetProperty(cx, glob, "_installedFiles", &installedFiles) &&
                          JSVAL_TO_BOOLEAN(installedFiles))
                        {
                            // install items remain in queue, must clean up!
                            nsInstall *a = (nsInstall*)JS_GetPrivate(cx, glob);
                            a->InternalAbort(nsInstall::MALFORMED_INSTALL);
                        }

                        jsval sent;
                        if ( JS_GetProperty( cx, glob, "_finalStatus", &sent ) )
                            finalStatus = JSVAL_TO_INT(sent);
                        else
                            finalStatus = nsInstall::UNEXPECTED_ERROR;
                    }
                    JS_EndRequest(cx); //Decrement JS thread counter
                    JS_DestroyContextMaybeGC(cx);
                }
                else
                {
                    // couldn't initialize install context
                    finalStatus = nsInstall::UNEXPECTED_ERROR;
                }

                // Clean up after ourselves.
                JS_DestroyRuntime(rt);
            }
        }
        // force zip archive closed before other cleanup
        hZip = 0;
    }

    if(listener)
        listener->OnInstallDone( installInfo->GetURL(), finalStatus );

    if (scriptBuffer) delete [] scriptBuffer;

    softwareUpdate->SetActiveListener(0);
    softwareUpdate->InstallJarCallBack();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult SetupInstallContext ( nsIZipReader hZip,
nsIFile jarFile,
const PRUnichar url,
const PRUnichar args,
PRUint32  flags,
CHROMEREG_IFACE reg,
JSRuntime jsRT,
JSContext **  jsCX,
JSObject **  jsGlob 
) [static]

Definition at line 363 of file nsSoftwareUpdateRun.cpp.

{
    JSContext   *cx;
    JSObject    *glob;

    *jsCX   = nsnull;
    *jsGlob = nsnull;

    if (!rt)
        return NS_ERROR_OUT_OF_MEMORY;

    cx = JS_NewContext(rt, 8192);
    if (!cx)
    {
        return NS_ERROR_OUT_OF_MEMORY;
    }

    JS_SetErrorReporter(cx, XPInstallErrorReporter);

    JS_BeginRequest(cx);
    glob = InitXPInstallObjects(cx, jarFile, url, args, flags, reg, hZip);
    if (!glob)
    {
        JS_DestroyContext(cx);
        return NS_ERROR_OUT_OF_MEMORY;
    }

    // Init standard classes
    JS_InitStandardClasses(cx, glob);

    // Add our Install class to this context
    InitInstallVersionClass(cx, glob, nsnull);
    InitInstallTriggerGlobalClass(cx, glob, nsnull);
    JS_EndRequest(cx);
    *jsCX   = cx;
    *jsGlob = glob;

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult VerifySigning ( nsIZipReader hZip,
nsIPrincipal aPrincipal 
)

Definition at line 99 of file nsSoftwareUpdateRun.cpp.

{
    if (!aPrincipal) 
        return NS_OK; // not signed, but not an error

    PRBool hasCert;
    aPrincipal->GetHasCertificate(&hasCert);
    if (!hasCert)
        return NS_ERROR_FAILURE;

    nsCOMPtr<nsIJAR> jar(do_QueryInterface(hZip));
    if (!jar)
        return NS_ERROR_FAILURE;

    // See if the archive is signed at all first
    nsCOMPtr<nsIPrincipal> principal;
    nsresult rv = jar->GetCertificatePrincipal(nsnull, getter_AddRefs(principal));
    if (NS_FAILED(rv) || !principal)
        return NS_ERROR_FAILURE;
    
    PRUint32 entryCount = 0;

    // first verify all files in the jar are also in the manifest.
    nsCOMPtr<nsISimpleEnumerator> entries;
    rv = hZip->FindEntries("*", getter_AddRefs(entries));
    if (NS_FAILED(rv))
        return rv;

    PRBool more;
    nsXPIDLCString name;
    while (NS_SUCCEEDED(entries->HasMoreElements(&more)) && more)
    {
        nsCOMPtr<nsIZipEntry> file;
        rv = entries->GetNext(getter_AddRefs(file));
        if (NS_FAILED(rv)) return rv;
        
        file->GetName(getter_Copies(name));

        if ( PL_strncasecmp("META-INF/", name.get(), 9) == 0)
            continue;

        // we only count the entries not in the meta-inf directory
        entryCount++;

        // Each entry must be signed
        PRBool equal;
        rv = jar->GetCertificatePrincipal(name, getter_AddRefs(principal));
        if (NS_FAILED(rv) || !principal) return NS_ERROR_FAILURE;

        rv = principal->Equals(aPrincipal, &equal);
        if (NS_FAILED(rv) || !equal) return NS_ERROR_FAILURE;
    }

    // next verify all files in the manifest are in the archive.
    PRUint32 manifestEntryCount;
    rv = jar->GetManifestEntriesCount(&manifestEntryCount);
    if (NS_FAILED(rv))
        return rv;

    if (entryCount != manifestEntryCount)
        return NS_ERROR_FAILURE;  // some files were deleted from archive

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void XPInstallErrorReporter ( JSContext cx,
const char *  message,
JSErrorReport report 
) [static]

Definition at line 173 of file nsSoftwareUpdateRun.cpp.

{
    nsresult rv;

    /* Use the console service to register the error. */
    nsCOMPtr<nsIConsoleService> consoleService
        (do_GetService("@mozilla.org/consoleservice;1"));

    /*
     * Make an nsIScriptError, populate it with information from this
     * error, then log it with the console service.
     */
    nsCOMPtr<nsIScriptError>
        errorObject(do_CreateInstance("@mozilla.org/scripterror;1"));

    if (consoleService != nsnull && errorObject != nsnull && report != nsnull) {
        /*
         * Got an error object; prepare appropriate-width versions of
         * various arguments to it.
         */

        PRUint32 column = report->uctokenptr - report->uclinebuf;

        rv = errorObject->Init(NS_REINTERPRET_CAST(const PRUnichar*, report->ucmessage),
                               NS_ConvertASCIItoUCS2(report->filename).get(),
                               NS_REINTERPRET_CAST(const PRUnichar*, report->uclinebuf),
                               report->lineno, column, report->flags,
                               "XPInstall JavaScript");
        if (NS_SUCCEEDED(rv)) {
            rv = consoleService->LogMessage(errorObject);
            if (NS_SUCCEEDED(rv)) {
              // We're done!
              // For now, always also print out the error to stderr.
              // return;
            }
        }
    }

    // lets set up an eventQ so that our xpcom/proxies will not have to:
    nsCOMPtr<nsISoftwareUpdate> softwareUpdate =
             do_GetService(kSoftwareUpdateCID, &rv);

    if (NS_FAILED(rv))
    {
        NS_WARNING("shouldn't have RunInstall() if we can't get SoftwareUpdate");
        return;
    }

    nsCOMPtr<nsIXPIListener> listener;
    softwareUpdate->GetMasterListener(getter_AddRefs(listener));

    if(listener)
    {
        nsAutoString logMessage;
        if (report)
        {
            logMessage.AssignLiteral("Line: ");
            logMessage.AppendInt(report->lineno, 10);
            logMessage.AppendLiteral("\t");
            if (report->ucmessage)
                logMessage.Append( NS_REINTERPRET_CAST(const PRUnichar*, report->ucmessage) );
            else
                logMessage.AppendWithConversion( message );
        }
        else
            logMessage.AssignWithConversion( message );

        listener->OnLogComment( logMessage.get() );
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

const char* message

Definition at line 89 of file nsSoftwareUpdateRun.cpp.

Definition at line 89 of file nsSoftwareUpdateRun.cpp.