Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsInstallUninstall.cpp File Reference
#include "nsInstall.h"
#include "nsInstallUninstall.h"
#include "nsInstallResources.h"
#include "VerReg.h"
#include "nsCRT.h"
#include "prmem.h"
#include "ScheduledTasks.h"
#include "nsReadableUtils.h"
#include "nsILocalFile.h"

Go to the source code of this file.

Functions

NS_EXPORT PRInt32 SU_Uninstall (char *regPackageName)
REGERR su_UninstallProcessItem (char *component_path)

Function Documentation

NS_EXPORT PRInt32 SU_Uninstall ( char *  regPackageName)

Definition at line 156 of file nsInstallUninstall.cpp.

{
    REGERR status = REGERR_FAIL;
    char pathbuf[MAXREGPATHLEN+1] = {0};
    char sharedfilebuf[MAXREGPATHLEN+1] = {0};
    REGENUM state = 0;
    int32 length;
    int32 err;

    if (regPackageName == NULL)
        return REGERR_PARAM;

    if (pathbuf == NULL)
        return REGERR_PARAM;

    /* Get next path from Registry */
    status = VR_Enum( regPackageName, &state, pathbuf, MAXREGPATHLEN );

    /* if we got a good path */
    while (status == REGERR_OK)
    {
        char component_path[2*MAXREGPATHLEN+1] = {0};
        strcat(component_path, regPackageName);
        length = strlen(regPackageName);
        if (component_path[length - 1] != '/')
            strcat(component_path, "/");
        strcat(component_path, pathbuf);
        err = su_UninstallProcessItem(component_path);
        status = VR_Enum( regPackageName, &state, pathbuf, MAXREGPATHLEN );  
    }
    
    err = VR_Remove(regPackageName);
    // there is a problem here.  It looks like if the file is refcounted, we still blow away the reg key
    // FIX!
    state = 0;
    status = VR_UninstallEnumSharedFiles( regPackageName, &state, sharedfilebuf, MAXREGPATHLEN );
    while (status == REGERR_OK)
    {
        err = su_UninstallProcessItem(sharedfilebuf);
        err = VR_UninstallDeleteFileFromList(regPackageName, sharedfilebuf);
        status = VR_UninstallEnumSharedFiles( regPackageName, &state, sharedfilebuf, MAXREGPATHLEN );
    }

    err = VR_UninstallDeleteSharedFilesKey(regPackageName);
    err = VR_UninstallDestroy(regPackageName);
    return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

REGERR su_UninstallProcessItem ( char *  component_path)

Definition at line 204 of file nsInstallUninstall.cpp.

{
    int refcount;
    int err;
    char filepath[MAXREGPATHLEN];
    nsCOMPtr<nsILocalFile> nsLFPath;
    nsCOMPtr<nsIFile> nsFPath;

    err = VR_GetPath(component_path, sizeof(filepath), filepath);
    if ( err == REGERR_OK )
    {
        NS_NewNativeLocalFile(nsDependentCString(filepath), PR_TRUE, getter_AddRefs(nsLFPath));
        nsFPath = nsLFPath;
        err = VR_GetRefCount(component_path, &refcount);  
        if ( err == REGERR_OK )
        {
            --refcount;
            if (refcount > 0)
                err = VR_SetRefCount(component_path, refcount);  
            else 
            {
                err = VR_Remove(component_path);
                DeleteFileNowOrSchedule(nsFPath);
            }
        }
        else
        {
            /* delete node and file */
            err = VR_Remove(component_path);
            DeleteFileNowOrSchedule(nsFPath);
        }
    }
    return err;
}

Here is the call graph for this function:

Here is the caller graph for this function: