Back to index

lightning-sunbird  0.9+nobinonly
Functions
ScheduledTasks.h File Reference
#include "NSReg.h"
#include "nsIFile.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

PR_BEGIN_EXTERN_C PRInt32 DeleteFileNowOrSchedule (nsIFile *filename)
PRInt32 ReplaceFileNowOrSchedule (nsIFile *tmpfile, nsIFile *target, PRInt32 aMode)
PRInt32 ScheduleFileForDeletion (nsIFile *filename)
char * GetRegFilePath ()
void PerformScheduledTasks (HREG reg)

Function Documentation

Definition at line 174 of file ScheduledTasks.cpp.

{
    PRBool flagExists;  
    PRInt32 result = nsInstall::SUCCESS;

    filename->Remove(PR_FALSE);
    filename->Exists(&flagExists);
    if (flagExists)
        result = ScheduleFileForDeletion(filename);
 
    return result;
} 

Here is the call graph for this function:

Here is the caller graph for this function:

char* GetRegFilePath ( )

Definition at line 39 of file InstallCleanup.cpp.

{
    int deleteComplete  = DONE;
    int replaceComplete = DONE;

    deleteComplete  = DeleteScheduledFiles( reg );
    replaceComplete = ReplaceScheduledFiles( reg );
    if ((deleteComplete == DONE) && (replaceComplete == DONE))
        return DONE;
    else
        return TRY_LATER;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 ReplaceFileNowOrSchedule ( nsIFile tmpfile,
nsIFile target,
PRInt32  aMode 
)

Definition at line 395 of file ScheduledTasks.cpp.

{
    PRInt32 result = ReplaceFileNow( aReplacementFile, aDoomedFile );

    if ( result == nsInstall::ACCESS_DENIED )
    {
        // if we couldn't replace the file schedule it for later
#ifdef _WINDOWS
        if ( (aMode & WIN_SYSTEM_FILE) && 
             (ReplaceWindowsSystemFile(aReplacementFile, aDoomedFile) == 0) )
                return nsInstall::REBOOT_NEEDED;
#endif

        RKEY    listkey;
        RKEY    filekey;
        HREG    reg;
        REGERR  err;

        nsCAutoString regFilePath;
        GetRegFilePath(regFilePath);
        if ( REGERR_OK == NR_RegOpen(NS_CONST_CAST(char*, regFilePath.get()), &reg) ) 
        {
            err = NR_RegAddKey( reg, ROOTKEY_PRIVATE, REG_REPLACE_LIST_KEY, &listkey );
            if ( err == REGERR_OK ) 
            {
                char     valname[20];
                REGERR   err2;

                err = NR_RegGetUniqueName( reg, valname, sizeof(valname) );
                if ( err == REGERR_OK )
                {
                    err = NR_RegAddKey( reg, listkey, valname, &filekey );
                    if ( REGERR_OK == err )
                    {
                        nsCAutoString srcowner;
                        nsCAutoString destowner;
                        nsresult rv = GetPersistentStringFromSpec(aReplacementFile, srcowner);
                        nsresult rv2 = GetPersistentStringFromSpec(aDoomedFile, destowner);
                        if ( NS_SUCCEEDED(rv) && NS_SUCCEEDED(rv2) )
                        {
                            const char *fsrc  = srcowner.get();
                            const char *fdest = destowner.get();
                            err = NR_RegSetEntry( reg, filekey, 
                                                  REG_REPLACE_SRCFILE,
                                                  REGTYPE_ENTRY_BYTES, 
                                                  (void*)fsrc, 
                                                  strlen(fsrc)+sizeof('\0'));

                            err2 = NR_RegSetEntry(reg, filekey,
                                                  REG_REPLACE_DESTFILE,
                                                  REGTYPE_ENTRY_BYTES,
                                                  (void*)fdest,
                                                  strlen(fdest)+sizeof('\0'));

                            if ( err == REGERR_OK && err2 == REGERR_OK )
                            {
                                result = nsInstall::REBOOT_NEEDED;
                                nsSoftwareUpdate::NeedCleanup();
                            }
                            else
                                NR_RegDeleteKey( reg, listkey, valname );
                        }
                    }
                }
            }
            NR_RegClose(reg);
        }
    }

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 187 of file ScheduledTasks.cpp.

{
    // could not delete, schedule it for later

    RKEY newkey;
    HREG reg;
    REGERR  err;
    PRInt32 result = nsInstall::UNEXPECTED_ERROR;

    nsCAutoString path;
    GetRegFilePath(path);
    err = NR_RegOpen(NS_CONST_CAST(char*, path.get()), &reg);

    if ( err == REGERR_OK )
    {
        err = NR_RegAddKey(reg,ROOTKEY_PRIVATE,REG_DELETE_LIST_KEY,&newkey);
        if ( err == REGERR_OK )
        {
            char    valname[20];

            err = NR_RegGetUniqueName( reg, valname, sizeof(valname) );
            if ( err == REGERR_OK )
            {
                nsCAutoString nameowner;
                nsresult rv = GetPersistentStringFromSpec(filename, nameowner);
                if ( NS_SUCCEEDED(rv) && !nameowner.IsEmpty() )
                {
                    const char *fnamestr = nameowner.get();
                    err = NR_RegSetEntry( reg, newkey, valname, 
                                          REGTYPE_ENTRY_BYTES, 
                                          (void*)fnamestr, 
                                          strlen(fnamestr)+sizeof('\0'));

                    if ( err == REGERR_OK )
                    {
                         result = nsInstall::REBOOT_NEEDED;
                         nsSoftwareUpdate::NeedCleanup();
                    }
                }
            }
        }

        NR_RegClose(reg);
    }

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function: