Fixed Reported Bugs: 5577, 5579, 5580, 6116, 6620, 6621, 6707, 6709, 6714.
Fixed overloading Fixed calls to version registry removed nsInstallInfo from the stream listener.
This commit is contained in:
Родитель
a4fe073c7a
Коммит
531f981465
|
@ -29,8 +29,162 @@
|
|||
#include "nsFileStream.h"
|
||||
#include "nsInstall.h" // for error codes
|
||||
#include "prmem.h"
|
||||
#include "ScheduledTasks.h"
|
||||
|
||||
REGERR DeleteFileLater(nsFileSpec& filename)
|
||||
#ifdef _WINDOWS
|
||||
#include <sys/stat.h>
|
||||
#include <windows.h>
|
||||
|
||||
BOOL WIN32_IsMoveFileExBroken()
|
||||
{
|
||||
/* the NT option MOVEFILE_DELAY_UNTIL_REBOOT is broken on
|
||||
* Windows NT 3.51 Service Pack 4 and NT 4.0 before Service Pack 2
|
||||
*/
|
||||
BOOL broken = FALSE;
|
||||
OSVERSIONINFO osinfo;
|
||||
|
||||
// they *all* appear broken--better to have one way that works.
|
||||
return TRUE;
|
||||
|
||||
osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
if (GetVersionEx(&osinfo) && osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
||||
{
|
||||
if ( osinfo.dwMajorVersion == 3 && osinfo.dwMinorVersion == 51 )
|
||||
{
|
||||
if ( 0 == stricmp(osinfo.szCSDVersion,"Service Pack 4"))
|
||||
{
|
||||
broken = TRUE;
|
||||
}
|
||||
}
|
||||
else if ( osinfo.dwMajorVersion == 4 )
|
||||
{
|
||||
if (osinfo.szCSDVersion[0] == '\0' ||
|
||||
(0 == stricmp(osinfo.szCSDVersion,"Service Pack 1")))
|
||||
{
|
||||
broken = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return broken;
|
||||
}
|
||||
|
||||
|
||||
PRInt32 DoWindowsReplaceExistingFileStuff(const char* currentName, const char* finalName)
|
||||
{
|
||||
PRInt32 err = 0;
|
||||
|
||||
char* final = strdup(finalName);
|
||||
char* current = strdup(currentName);
|
||||
|
||||
/* couldn't delete, probably in use. Schedule for later */
|
||||
DWORD dwVersion, dwWindowsMajorVersion;
|
||||
|
||||
/* Get OS version info */
|
||||
dwVersion = GetVersion();
|
||||
dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
||||
|
||||
/* Get build numbers for Windows NT or Win32s */
|
||||
|
||||
if (dwVersion < 0x80000000) // Windows NT
|
||||
{
|
||||
/* On Windows NT */
|
||||
if ( WIN32_IsMoveFileExBroken() )
|
||||
{
|
||||
/* the MOVEFILE_DELAY_UNTIL_REBOOT option doesn't work on
|
||||
* NT 3.51 SP4 or on NT 4.0 until SP2
|
||||
*/
|
||||
struct stat statbuf;
|
||||
PRBool nameFound = PR_FALSE;
|
||||
char tmpname[_MAX_PATH];
|
||||
|
||||
strncpy( tmpname, finalName, _MAX_PATH );
|
||||
int len = strlen(tmpname);
|
||||
while (!nameFound && len < _MAX_PATH )
|
||||
{
|
||||
tmpname[len-1] = '~';
|
||||
tmpname[len] = '\0';
|
||||
if ( stat(tmpname, &statbuf) != 0 )
|
||||
nameFound = TRUE;
|
||||
else
|
||||
len++;
|
||||
}
|
||||
|
||||
if ( nameFound )
|
||||
{
|
||||
if ( MoveFile( finalName, tmpname ) )
|
||||
{
|
||||
if ( MoveFile( currentName, finalName ) )
|
||||
{
|
||||
DeleteFileNowOrSchedule(nsFileSpec(tmpname));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 2nd move failed, put old file back */
|
||||
MoveFile( tmpname, finalName );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* non-executable in use; schedule for later */
|
||||
return -1; // let the start registry stuff do our work!
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( MoveFileEx(currentName, finalName, MOVEFILE_DELAY_UNTIL_REBOOT) )
|
||||
{
|
||||
err = 0;
|
||||
}
|
||||
}
|
||||
else // Windows 95 or Win16
|
||||
{
|
||||
/*
|
||||
* Place an entry in the WININIT.INI file in the Windows directory
|
||||
* to delete finalName and rename currentName to be finalName at reboot
|
||||
*/
|
||||
|
||||
int strlen;
|
||||
char Src[_MAX_PATH]; // 8.3 name
|
||||
char Dest[_MAX_PATH]; // 8.3 name
|
||||
|
||||
strlen = GetShortPathName( (LPCTSTR)currentName, (LPTSTR)Src, (DWORD)sizeof(Src) );
|
||||
if ( strlen > 0 )
|
||||
{
|
||||
free(current);
|
||||
current = strdup(Src);
|
||||
}
|
||||
|
||||
strlen = GetShortPathName( (LPCTSTR) finalName, (LPTSTR) Dest, (DWORD) sizeof(Dest));
|
||||
if ( strlen > 0 )
|
||||
{
|
||||
free(final);
|
||||
final = strdup(Dest);
|
||||
}
|
||||
|
||||
/* NOTE: use OEM filenames! Even though it looks like a Windows
|
||||
* .INI file, WININIT.INI is processed under DOS
|
||||
*/
|
||||
|
||||
AnsiToOem( final, final );
|
||||
AnsiToOem( current, current );
|
||||
|
||||
if ( WritePrivateProfileString( "Rename", final, current, "WININIT.INI" ) )
|
||||
err = 0;
|
||||
}
|
||||
|
||||
free(final);
|
||||
free(current);
|
||||
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
REGERR DeleteFileNowOrSchedule(nsFileSpec& filename)
|
||||
{
|
||||
|
||||
REGERR result = 0;
|
||||
|
@ -45,12 +199,9 @@ REGERR DeleteFileLater(nsFileSpec& filename)
|
|||
{
|
||||
if (REGERR_OK == NR_RegAddKey( reg, ROOTKEY_PRIVATE, REG_DELETE_LIST_KEY, &newkey) )
|
||||
{
|
||||
nsPersistentFileDescriptor savethis(filename);
|
||||
char* buffer = nsnull;
|
||||
nsOutputStringStream s(buffer);
|
||||
s << savethis;
|
||||
// FIX should be using nsPersistentFileDescriptor!!!
|
||||
|
||||
result = NR_RegSetEntry( reg, newkey, "", REGTYPE_ENTRY_BYTES, buffer, strlen(buffer));
|
||||
result = NR_RegSetEntry( reg, newkey, (char*)(const char*)filename.GetNativePathCString(), REGTYPE_ENTRY_FILE, nsnull, 0);
|
||||
if (result == REGERR_OK)
|
||||
result = nsInstall::REBOOT_NEEDED;
|
||||
}
|
||||
|
@ -63,7 +214,7 @@ REGERR DeleteFileLater(nsFileSpec& filename)
|
|||
}
|
||||
/* tmp file is the bad one that we want to replace with target. */
|
||||
|
||||
REGERR ReplaceFileLater(nsFileSpec& replacementFile, nsFileSpec& doomedFile )
|
||||
REGERR ReplaceFileNowOrSchedule(nsFileSpec& replacementFile, nsFileSpec& doomedFile )
|
||||
{
|
||||
REGERR result = 0;
|
||||
|
||||
|
@ -82,13 +233,20 @@ REGERR ReplaceFileLater(nsFileSpec& replacementFile, nsFileSpec& doomedFile )
|
|||
|
||||
doomedFile.GetParent(parentofFinalFile);
|
||||
result = replacementFile.Move(parentofFinalFile);
|
||||
|
||||
char* leafName = doomedFile.GetLeafName();
|
||||
replacementFile.Rename(leafName);
|
||||
nsCRT::free(leafName);
|
||||
if ( NS_SUCCEEDED(result) )
|
||||
{
|
||||
char* leafName = doomedFile.GetLeafName();
|
||||
replacementFile.Rename(leafName);
|
||||
nsCRT::free(leafName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
if (DoWindowsReplaceExistingFileStuff(replacementFile.GetNativePathCString(), doomedFile.GetNativePathCString()) == 0)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
RKEY newkey;
|
||||
HREG reg;
|
||||
|
||||
|
@ -97,22 +255,10 @@ REGERR ReplaceFileLater(nsFileSpec& replacementFile, nsFileSpec& doomedFile )
|
|||
result = NR_RegAddKey( reg, ROOTKEY_PRIVATE, REG_REPLACE_LIST_KEY, &newkey);
|
||||
if ( result == REGERR_OK )
|
||||
{
|
||||
nsPersistentFileDescriptor tempDesc(replacementFile);
|
||||
nsPersistentFileDescriptor targDesc(doomedFile);
|
||||
|
||||
char* tempBuffer = nsnull;
|
||||
char* targBuffer = nsnull;
|
||||
|
||||
nsOutputStringStream tempStream(tempBuffer);
|
||||
nsOutputStringStream targStream(targBuffer);
|
||||
|
||||
tempStream << tempDesc;
|
||||
targStream << targDesc;
|
||||
|
||||
result = NR_RegSetEntry( reg, newkey, tempBuffer, REGTYPE_ENTRY_BYTES, targBuffer, strlen(targBuffer));
|
||||
char* replacementFileName = (char*)(const char*)replacementFile.GetNativePathCString();
|
||||
result = NR_RegSetEntry( reg, newkey, (char*)(const char*)doomedFile.GetNativePathCString(), REGTYPE_ENTRY_FILE, replacementFileName, strlen(replacementFileName));
|
||||
if (result == REGERR_OK)
|
||||
result = nsInstall::REBOOT_NEEDED;
|
||||
|
||||
}
|
||||
|
||||
NR_RegClose(reg);
|
||||
|
@ -144,16 +290,11 @@ void DeleteScheduledFiles(void)
|
|||
/* perform scheduled file deletions and replacements (PC only) */
|
||||
if (REGERR_OK == NR_RegGetKey(reg, ROOTKEY_PRIVATE, REG_DELETE_LIST_KEY,&key))
|
||||
{
|
||||
char buf[MAXREGNAMELEN]; // what about the mac? FIX
|
||||
char buf[MAXREGNAMELEN];
|
||||
|
||||
while (REGERR_OK == NR_RegEnumEntries(reg, key, &state, buf, sizeof(buf), NULL ))
|
||||
{
|
||||
|
||||
nsPersistentFileDescriptor doomedDesc;
|
||||
nsInputStringStream tempStream(buf);
|
||||
tempStream >> doomedDesc;
|
||||
|
||||
nsFileSpec doomedFile(doomedDesc);
|
||||
nsFileSpec doomedFile(buf);
|
||||
|
||||
doomedFile.Delete(PR_FALSE);
|
||||
|
||||
|
@ -193,12 +334,7 @@ void ReplaceScheduledFiles(void)
|
|||
while (REGERR_OK == NR_RegEnumEntries(reg, key, &state, tmpfile, sizeof(tmpfile), NULL ))
|
||||
{
|
||||
|
||||
|
||||
nsPersistentFileDescriptor doomedDesc;
|
||||
nsInputStringStream tempStream(tmpfile);
|
||||
tempStream >> doomedDesc;
|
||||
|
||||
nsFileSpec replaceFile(doomedDesc);
|
||||
nsFileSpec replaceFile(tmpfile);
|
||||
|
||||
if (! replaceFile.Exists() )
|
||||
{
|
||||
|
@ -211,11 +347,7 @@ void ReplaceScheduledFiles(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
nsPersistentFileDescriptor targetDesc;
|
||||
nsInputStringStream anotherStream(target);
|
||||
anotherStream >> targetDesc;
|
||||
|
||||
nsFileSpec targetFile(targetDesc);
|
||||
nsFileSpec targetFile(target);
|
||||
|
||||
targetFile.Delete(PR_FALSE);
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
#include "nsFileSpec.h"
|
||||
|
||||
|
||||
REGERR DeleteFileLater(nsFileSpec& filename);
|
||||
REGERR ReplaceFileLater(nsFileSpec& tmpfile, nsFileSpec& target );
|
||||
REGERR DeleteFileNowOrSchedule(nsFileSpec& filename);
|
||||
REGERR ReplaceFileNowOrSchedule(nsFileSpec& tmpfile, nsFileSpec& target );
|
||||
|
||||
|
||||
extern "C" void PerformScheduledTasks(void *data);
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -135,31 +135,29 @@ class nsInstall
|
|||
nsInstall();
|
||||
virtual ~nsInstall();
|
||||
|
||||
PRInt32 SetScriptObject(void* aScriptObject);
|
||||
PRInt32 SetScriptObject(void* aScriptObject);
|
||||
|
||||
|
||||
PRInt32 SaveWinRegPrototype(void* aScriptObject);
|
||||
PRInt32 SaveWinProfilePrototype(void* aScriptObject);
|
||||
|
||||
JSObject* RetrieveWinRegPrototype(void);
|
||||
JSObject* RetrieveWinProfilePrototype(void);
|
||||
|
||||
|
||||
PRInt32 GetUserPackageName(nsString& aUserPackageName);
|
||||
PRInt32 GetRegPackageName(nsString& aRegPackageName);
|
||||
|
||||
PRInt32 AbortInstall();
|
||||
|
||||
PRInt32 AddDirectory(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aSubdir, PRBool aForceMode, PRInt32* aReturn);
|
||||
PRInt32 AddDirectory(const nsString& aRegName, nsIDOMInstallVersion* aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aSubdir, PRBool aForceMode, PRInt32* aReturn);
|
||||
PRInt32 AddDirectory(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aSubdir, PRInt32* aReturn);
|
||||
PRInt32 AddDirectory(const nsString& aRegName, nsIDOMInstallVersion* aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aSubdir, PRInt32* aReturn);
|
||||
PRInt32 AddDirectory(const nsString& aRegName, const nsString& aJarSource, const nsString& aFolder, const nsString& aSubdir, PRInt32* aReturn);
|
||||
PRInt32 AddDirectory(const nsString& aJarSource, PRInt32* aReturn);
|
||||
|
||||
PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRBool aForceMode, PRInt32* aReturn);
|
||||
PRInt32 AddSubcomponent(const nsString& aRegName, nsIDOMInstallVersion* aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRBool aForceMode, PRInt32* aReturn);
|
||||
PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRInt32* aReturn);
|
||||
PRInt32 AddSubcomponent(const nsString& aRegName, nsIDOMInstallVersion* aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRInt32* aReturn);
|
||||
PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRInt32* aReturn);
|
||||
PRInt32 AddSubcomponent(const nsString& aJarSource, PRInt32* aReturn);
|
||||
|
||||
PRInt32 DeleteComponent(const nsString& aRegistryName, PRInt32* aReturn);
|
||||
PRInt32 DeleteFile(const nsString& aFolder, const nsString& aRelativeFileName, PRInt32* aReturn);
|
||||
PRInt32 DiskSpaceAvailable(const nsString& aFolder, PRInt32* aReturn);
|
||||
|
@ -175,18 +173,13 @@ class nsInstall
|
|||
PRInt32 GetWinProfile(const nsString& aFolder, const nsString& aFile, JSContext* jscontext, JSClass* WinProfileClass, jsval* aReturn);
|
||||
PRInt32 GetWinRegistry(JSContext* jscontext, JSClass* WinRegClass, jsval* aReturn);
|
||||
PRInt32 Patch(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRInt32* aReturn);
|
||||
PRInt32 Patch(const nsString& aRegName, nsIDOMInstallVersion* aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRInt32* aReturn);
|
||||
PRInt32 Patch(const nsString& aRegName, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRInt32* aReturn);
|
||||
PRInt32 ResetError();
|
||||
PRInt32 SetPackageFolder(const nsString& aFolder);
|
||||
PRInt32 StartInstall(const nsString& aUserPackageName, const nsString& aPackageName, const nsString& aVersion, PRInt32 aFlags, PRInt32* aReturn);
|
||||
PRInt32 StartInstall(const nsString& aUserPackageName, const nsString& aPackageName, nsIDOMInstallVersion* aVersion, PRInt32 aFlags, PRInt32* aReturn);
|
||||
PRInt32 StartInstall(const nsString& aUserPackageName, const nsString& aPackageName, const nsString& aVersion, PRInt32* aReturn);
|
||||
PRInt32 StartInstall(const nsString& aUserPackageName, const nsString& aPackageName, nsIDOMInstallVersion* aVersion, PRInt32* aReturn);
|
||||
PRInt32 Uninstall(const nsString& aPackageName, PRInt32* aReturn);
|
||||
|
||||
|
||||
|
||||
PRInt32 ExtractFileFromJar(const nsString& aJarfile, nsFileSpec* aSuggestedName, nsFileSpec** aRealName);
|
||||
void AddPatch(nsHashKey *aKey, nsFileSpec* fileName);
|
||||
void GetPatch(nsHashKey *aKey, nsFileSpec* fileName);
|
||||
|
@ -230,10 +223,12 @@ class nsInstall
|
|||
PRInt32 SanityCheck(void);
|
||||
void GetTime(nsString &aString);
|
||||
|
||||
nsString * GetQualifiedRegName( const nsString& name );
|
||||
nsString* GetQualifiedPackageName( const nsString& name );
|
||||
nsString* CurrentUserNode();
|
||||
PRBool BadRegName(nsString* regName);
|
||||
|
||||
PRInt32 GetQualifiedRegName(const nsString& name, nsString& qualifiedRegName );
|
||||
PRInt32 GetQualifiedPackageName( const nsString& name, nsString& qualifiedName );
|
||||
|
||||
void CurrentUserNode(nsString& userRegNode);
|
||||
PRBool BadRegName(const nsString& regName);
|
||||
PRInt32 SaveError(PRInt32 errcode);
|
||||
|
||||
void CleanUp();
|
||||
|
|
|
@ -222,7 +222,7 @@ PRInt32 nsInstallDelete::NativeComplete()
|
|||
{
|
||||
if (mFinalFile->IsFile())
|
||||
{
|
||||
return DeleteFileLater(*mFinalFile);
|
||||
return DeleteFileNowOrSchedule(*mFinalFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -87,7 +87,7 @@ PRInt32 nsInstallExecute::Complete()
|
|||
|
||||
PRInt32 result = app.Execute( mArgs );
|
||||
|
||||
DeleteFileLater( app );
|
||||
DeleteFileNowOrSchedule( app );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -98,15 +98,25 @@ void nsInstallExecute::Abort()
|
|||
if (mExecutableFile == nsnull)
|
||||
return;
|
||||
|
||||
DeleteFileLater(*mExecutableFile);
|
||||
DeleteFileNowOrSchedule(*mExecutableFile);
|
||||
}
|
||||
|
||||
char* nsInstallExecute::toString()
|
||||
{
|
||||
char* buffer = new char[1024];
|
||||
|
||||
sprintf( buffer, nsInstallResources::GetExecuteString(), mExecutableFile->GetCString());
|
||||
|
||||
// if the FileSpec is NULL, just us the in jar file name.
|
||||
|
||||
if (mExecutableFile == nsnull)
|
||||
{
|
||||
char *tempString = mJarLocation.ToNewCString();
|
||||
sprintf( buffer, nsInstallResources::GetExecuteString(), tempString);
|
||||
delete [] tempString;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( buffer, nsInstallResources::GetExecuteString(), mExecutableFile->GetCString());
|
||||
}
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "VerReg.h"
|
||||
#include "ScheduledTasks.h"
|
||||
#include "nsInstall.h"
|
||||
#include "nsInstallVersion.h"
|
||||
#include "nsIDOMInstallVersion.h"
|
||||
#include "nsInstallResources.h"
|
||||
|
||||
/* Public Methods */
|
||||
|
@ -40,9 +40,11 @@
|
|||
inJarLocation - location inside the JAR file
|
||||
inFinalFileSpec - final location on disk
|
||||
*/
|
||||
|
||||
|
||||
nsInstallFile::nsInstallFile(nsInstall* inInstall,
|
||||
const nsString& inComponentName,
|
||||
nsIDOMInstallVersion* inVInfo,
|
||||
const nsString& inVInfo,
|
||||
const nsString& inJarLocation,
|
||||
const nsString& folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
|
@ -50,30 +52,79 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
|
|||
PRInt32 *error)
|
||||
: nsInstallObject(inInstall)
|
||||
{
|
||||
mExtracedFile= nsnull;
|
||||
mFinalFile = nsnull;
|
||||
mUpgradeFile = PR_FALSE;
|
||||
mVersionRegistryName = nsnull;
|
||||
mJarLocation = nsnull;
|
||||
mExtracedFile = nsnull;
|
||||
mFinalFile = nsnull;
|
||||
mVersionInfo = nsnull;
|
||||
|
||||
if ((folderSpec == "null") || (inInstall == NULL) || (inVInfo == NULL))
|
||||
mUpgradeFile = PR_FALSE;
|
||||
|
||||
if ((folderSpec == "null") || (inInstall == NULL))
|
||||
{
|
||||
*error = nsInstall::INVALID_ARGUMENTS;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check for existence of the newer version */
|
||||
|
||||
PRBool versionNewer = PR_FALSE; // Is this a newer version
|
||||
char* qualifiedRegNameString = inComponentName.ToNewCString();
|
||||
|
||||
if ( (forceInstall == PR_FALSE ) && (inVInfo != "") && ( VR_ValidateComponent( qualifiedRegNameString ) == 0 ) )
|
||||
{
|
||||
nsInstallVersion *newVersion = new nsInstallVersion();
|
||||
newVersion->Init(inVInfo);
|
||||
|
||||
VERSION versionStruct;
|
||||
|
||||
VR_GetVersion( qualifiedRegNameString, &versionStruct );
|
||||
|
||||
nsInstallVersion* oldVersion = new nsInstallVersion();
|
||||
|
||||
oldVersion->Init(versionStruct.major,
|
||||
versionStruct.minor,
|
||||
versionStruct.release,
|
||||
versionStruct.build);
|
||||
|
||||
PRInt32 areTheyEqual;
|
||||
newVersion->CompareTo(oldVersion, &areTheyEqual);
|
||||
|
||||
delete oldVersion;
|
||||
delete newVersion;
|
||||
|
||||
if (areTheyEqual == nsIDOMInstallVersion::MAJOR_DIFF_MINUS ||
|
||||
areTheyEqual == nsIDOMInstallVersion::MINOR_DIFF_MINUS ||
|
||||
areTheyEqual == nsIDOMInstallVersion::REL_DIFF_MINUS ||
|
||||
areTheyEqual == nsIDOMInstallVersion::BLD_DIFF_MINUS )
|
||||
{
|
||||
// the file to be installed is OLDER than what is on disk. Return error
|
||||
delete qualifiedRegNameString;
|
||||
*error = areTheyEqual;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
delete qualifiedRegNameString;
|
||||
|
||||
|
||||
mFinalFile = new nsFileSpec(folderSpec);
|
||||
*mFinalFile += inPartialPath;
|
||||
|
||||
mReplaceFile = mFinalFile->Exists();
|
||||
mReplaceFile = mFinalFile->Exists();
|
||||
|
||||
if (mReplaceFile == PR_FALSE)
|
||||
{
|
||||
nsFileSpec parent;
|
||||
mFinalFile->GetParent(parent);
|
||||
nsFileSpec makeDirs(parent.GetCString(), PR_TRUE);
|
||||
}
|
||||
|
||||
mForceInstall = forceInstall;
|
||||
|
||||
mVersionRegistryName = new nsString(inComponentName);
|
||||
mJarLocation = new nsString(inJarLocation);
|
||||
mVersionInfo = new nsInstallVersion();
|
||||
|
||||
nsString tempString;
|
||||
inVInfo->ToString(tempString);
|
||||
mVersionInfo->Init(tempString);
|
||||
mVersionInfo = new nsString(inVInfo);
|
||||
|
||||
nsString regPackageName;
|
||||
mInstall->GetRegPackageName(regPackageName);
|
||||
|
@ -87,9 +138,12 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
|
|||
}
|
||||
else
|
||||
{
|
||||
//mChildFile = mVersionRegistryName.startsWith(regPackageName);
|
||||
/* Because nsString doesn't support startWith, implemented the following. Waiting for approval */
|
||||
if (mVersionRegistryName->Find(regPackageName) == 0)
|
||||
|
||||
// there is no "starts with" api in nsString. LAME!
|
||||
nsString startsWith;
|
||||
mVersionRegistryName->Left(startsWith, regPackageName.Length());
|
||||
|
||||
if (startsWith.Equals(regPackageName))
|
||||
{
|
||||
mChildFile = true;
|
||||
}
|
||||
|
@ -98,8 +152,6 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
|
|||
mChildFile = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -202,7 +254,7 @@ PRInt32 nsInstallFile::CompleteFileMove()
|
|||
}
|
||||
else
|
||||
{
|
||||
result = ReplaceFileLater(*mExtracedFile, *mFinalFile );
|
||||
result = ReplaceFileNowOrSchedule(*mExtracedFile, *mFinalFile );
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -251,11 +303,18 @@ nsInstallFile::RegisterInVersionRegistry()
|
|||
}
|
||||
|
||||
VR_Install( (char*)(const char*)nsAutoCString(*mVersionRegistryName),
|
||||
(char*)(const char*)nsNSPRPath(*mFinalFile),
|
||||
(char*)(const char*)nsAutoCString(regPackageName),
|
||||
(char*)(const char*)mFinalFile->GetNativePathCString(), // DO NOT CHANGE THIS.
|
||||
(char*)(const char*)nsAutoCString(*mVersionInfo),
|
||||
PR_FALSE );
|
||||
|
||||
if (!mUpgradeFile)
|
||||
if (mUpgradeFile)
|
||||
{
|
||||
if (refCount == 0)
|
||||
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), 1 );
|
||||
else
|
||||
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), refCount ); //FIX?? what should the ref count be/
|
||||
}
|
||||
else
|
||||
{
|
||||
if (refCount != 0)
|
||||
{
|
||||
|
@ -263,18 +322,11 @@ nsInstallFile::RegisterInVersionRegistry()
|
|||
}
|
||||
else
|
||||
{
|
||||
if (mFinalFile->Exists())
|
||||
if (mReplaceFile)
|
||||
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), 2 );
|
||||
else
|
||||
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (refCount == 0)
|
||||
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), 1 );
|
||||
else
|
||||
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), 0 );
|
||||
}
|
||||
|
||||
if ( !mChildFile && !mUpgradeFile )
|
||||
|
|
|
@ -51,7 +51,7 @@ class nsInstallFile : public nsInstallObject
|
|||
*************************************************************/
|
||||
nsInstallFile( nsInstall* inInstall,
|
||||
const nsString& inVRName,
|
||||
nsIDOMInstallVersion* inVInfo,
|
||||
const nsString& inVInfo,
|
||||
const nsString& inJarLocation,
|
||||
const nsString& folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
|
@ -72,7 +72,7 @@ class nsInstallFile : public nsInstallObject
|
|||
private:
|
||||
|
||||
/* Private Fields */
|
||||
nsInstallVersion* mVersionInfo; /* Version info for this file*/
|
||||
nsString* mVersionInfo; /* Version info for this file*/
|
||||
|
||||
nsString* mJarLocation; /* Location in the JAR */
|
||||
nsFileSpec* mExtracedFile; /* temporary file location */
|
||||
|
|
|
@ -28,11 +28,15 @@
|
|||
|
||||
#include "nscore.h"
|
||||
#include "prtypes.h"
|
||||
#include "nsRepository.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
|
||||
#include "nsFileLocations.h"
|
||||
#include "nsIFileLocator.h"
|
||||
|
||||
struct DirectoryTable
|
||||
{
|
||||
char * directoryName; /* The formal directory name */
|
||||
|
@ -48,9 +52,12 @@ struct DirectoryTable DirectoryTable[] =
|
|||
{"Temporary", 104 },
|
||||
{"Installed", 105 },
|
||||
{"Current User", 106 },
|
||||
{"NetHelp", 107 },
|
||||
{"Preferences", 107 },
|
||||
{"OS Drive", 108 },
|
||||
{"File URL", 109 },
|
||||
{"file:///", 109 },
|
||||
|
||||
{"Components", 110 },
|
||||
{"Chrome", 111 },
|
||||
|
||||
{"Win System", 200 },
|
||||
{"Windows", 201 },
|
||||
|
@ -77,13 +84,34 @@ struct DirectoryTable DirectoryTable[] =
|
|||
|
||||
nsInstallFolder::nsInstallFolder(const nsString& aFolderID)
|
||||
{
|
||||
nsInstallFolder(aFolderID, "");
|
||||
mFileSpec = nsnull;
|
||||
SetDirectoryPath( aFolderID, "");
|
||||
}
|
||||
|
||||
nsInstallFolder::nsInstallFolder(const nsString& aFolderID, const nsString& aRelativePath)
|
||||
{
|
||||
mFileSpec = nsnull;
|
||||
SetDirectoryPath( aFolderID, aRelativePath);
|
||||
|
||||
/*
|
||||
aFolderID can be either a Folder enum in which case we merely pass it to SetDirectoryPath, or
|
||||
it can be a Directory. If it is the later, it must already exist and of course be a directory
|
||||
not a file.
|
||||
*/
|
||||
|
||||
nsFileSpec dirCheck(aFolderID);
|
||||
if ( (dirCheck.Error() == NS_OK) && (dirCheck.IsDirectory()) && (dirCheck.Exists()))
|
||||
{
|
||||
nsString tempString = aFolderID;
|
||||
tempString += aRelativePath;
|
||||
mFileSpec = new nsFileSpec(tempString);
|
||||
|
||||
// make sure that the directory is created.
|
||||
nsFileSpec(mFileSpec->GetCString(), PR_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDirectoryPath( aFolderID, aRelativePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -96,7 +124,7 @@ nsInstallFolder::~nsInstallFolder()
|
|||
void
|
||||
nsInstallFolder::GetDirectoryPath(nsString& aDirectoryPath)
|
||||
{
|
||||
aDirectoryPath.SetLength(0);
|
||||
aDirectoryPath = "";
|
||||
|
||||
if (mFileSpec != nsnull)
|
||||
{
|
||||
|
@ -125,108 +153,123 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
|
|||
switch (folderDirSpecID)
|
||||
{
|
||||
case 100: /////////////////////////////////////////////////////////// Plugins
|
||||
// FIX
|
||||
SetAppShellDirectory(nsSpecialFileSpec::App_PluginsDirectory );
|
||||
break;
|
||||
|
||||
case 101: /////////////////////////////////////////////////////////// Program
|
||||
*this = nsSpecialSystemDirectory::OS_CurrentProcessDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::OS_CurrentProcessDirectory ));
|
||||
break;
|
||||
|
||||
case 102: /////////////////////////////////////////////////////////// Communicator
|
||||
*this = nsSpecialSystemDirectory::OS_CurrentProcessDirectory; // FIX?
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::OS_CurrentProcessDirectory ));
|
||||
break;
|
||||
|
||||
case 103: /////////////////////////////////////////////////////////// User Pick
|
||||
// we should never be here.
|
||||
mFileSpec = nsnull;
|
||||
break;
|
||||
|
||||
case 104: /////////////////////////////////////////////////////////// Temporary
|
||||
*this = nsSpecialSystemDirectory::OS_TemporaryDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::OS_TemporaryDirectory ));
|
||||
break;
|
||||
|
||||
case 105: /////////////////////////////////////////////////////////// Installed
|
||||
// we should never be here.
|
||||
mFileSpec = nsnull;
|
||||
break;
|
||||
|
||||
case 106: /////////////////////////////////////////////////////////// Current User
|
||||
// FIX
|
||||
SetAppShellDirectory(nsSpecialFileSpec::App_UserProfileDirectory50 );
|
||||
break;
|
||||
|
||||
case 107: /////////////////////////////////////////////////////////// NetHelp
|
||||
// FIX
|
||||
case 107: /////////////////////////////////////////////////////////// Preferences
|
||||
SetAppShellDirectory(nsSpecialFileSpec::App_PrefsDirectory50 );
|
||||
break;
|
||||
|
||||
case 108: /////////////////////////////////////////////////////////// OS Drive
|
||||
*this = nsSpecialSystemDirectory::OS_DriveDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::OS_DriveDirectory ));
|
||||
break;
|
||||
|
||||
case 109: /////////////////////////////////////////////////////////// File URL
|
||||
// we should never be here.
|
||||
{
|
||||
nsString tempFileURLString = aFolderID;
|
||||
tempFileURLString += aRelativePath;
|
||||
mFileSpec = new nsFileSpec( nsFileURL(tempFileURLString) );
|
||||
}
|
||||
break;
|
||||
|
||||
case 110: /////////////////////////////////////////////////////////// Components
|
||||
SetAppShellDirectory(nsSpecialFileSpec::App_ComponentsDirectory );
|
||||
break;
|
||||
|
||||
case 111: /////////////////////////////////////////////////////////// Chrome
|
||||
SetAppShellDirectory(nsSpecialFileSpec::App_ChromeDirectory );
|
||||
break;
|
||||
|
||||
case 200: /////////////////////////////////////////////////////////// Win System
|
||||
*this = nsSpecialSystemDirectory::Win_SystemDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Win_SystemDirectory ));
|
||||
break;
|
||||
|
||||
case 201: /////////////////////////////////////////////////////////// Windows
|
||||
*this = nsSpecialSystemDirectory::Win_WindowsDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Win_WindowsDirectory ));
|
||||
break;
|
||||
|
||||
case 300: /////////////////////////////////////////////////////////// Mac System
|
||||
*this = nsSpecialSystemDirectory::Mac_SystemDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_SystemDirectory ));
|
||||
break;
|
||||
|
||||
case 301: /////////////////////////////////////////////////////////// Mac Desktop
|
||||
*this = nsSpecialSystemDirectory::Mac_DesktopDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_DesktopDirectory ));
|
||||
break;
|
||||
|
||||
case 302: /////////////////////////////////////////////////////////// Mac Trash
|
||||
*this = nsSpecialSystemDirectory::Mac_TrashDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_TrashDirectory ));
|
||||
break;
|
||||
|
||||
case 303: /////////////////////////////////////////////////////////// Mac Startup
|
||||
*this = nsSpecialSystemDirectory::Mac_StartupDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_StartupDirectory ));
|
||||
break;
|
||||
|
||||
case 304: /////////////////////////////////////////////////////////// Mac Shutdown
|
||||
*this = nsSpecialSystemDirectory::Mac_StartupDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_StartupDirectory ));
|
||||
break;
|
||||
|
||||
case 305: /////////////////////////////////////////////////////////// Mac Apple Menu
|
||||
*this = nsSpecialSystemDirectory::Mac_AppleMenuDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_AppleMenuDirectory ));
|
||||
break;
|
||||
|
||||
case 306: /////////////////////////////////////////////////////////// Mac Control Panel
|
||||
*this = nsSpecialSystemDirectory::Mac_ControlPanelDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_ControlPanelDirectory ));
|
||||
break;
|
||||
|
||||
case 307: /////////////////////////////////////////////////////////// Mac Extension
|
||||
*this = nsSpecialSystemDirectory::Mac_ExtensionDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_ExtensionDirectory ));
|
||||
break;
|
||||
|
||||
case 308: /////////////////////////////////////////////////////////// Mac Fonts
|
||||
*this = nsSpecialSystemDirectory::Mac_FontsDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_FontsDirectory ));
|
||||
break;
|
||||
|
||||
case 309: /////////////////////////////////////////////////////////// Mac Preferences
|
||||
*this = nsSpecialSystemDirectory::Mac_PreferencesDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_PreferencesDirectory ));
|
||||
break;
|
||||
|
||||
case 310: /////////////////////////////////////////////////////////// Mac Documents
|
||||
*this = nsSpecialSystemDirectory::Mac_DocumentsDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_DocumentsDirectory ));
|
||||
break;
|
||||
|
||||
case 400: /////////////////////////////////////////////////////////// Unix Local
|
||||
*this = nsSpecialSystemDirectory::Unix_LocalDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Unix_LocalDirectory ));
|
||||
break;
|
||||
|
||||
case 401: /////////////////////////////////////////////////////////// Unix Lib
|
||||
*this = nsSpecialSystemDirectory::Unix_LibDirectory;
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Unix_LibDirectory ));
|
||||
break;
|
||||
|
||||
|
||||
case -1:
|
||||
default:
|
||||
mFileSpec = nsnull;
|
||||
return;
|
||||
}
|
||||
#ifndef XP_MAC
|
||||
|
@ -271,11 +314,23 @@ nsInstallFolder::MapNameToEnum(const nsString& name)
|
|||
}
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kFileLocatorIID, NS_IFILELOCATOR_IID);
|
||||
static NS_DEFINE_IID(kFileLocatorCID, NS_FILELOCATOR_CID);
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsInstallFolder::operator = (enum nsSpecialSystemDirectory::SystemDirectories aSystemSystemDirectory)
|
||||
//----------------------------------------------------------------------------------------
|
||||
void
|
||||
nsInstallFolder::SetAppShellDirectory(PRUint32 value)
|
||||
{
|
||||
nsSpecialSystemDirectory temp(aSystemSystemDirectory);
|
||||
mFileSpec = new nsFileSpec(temp);
|
||||
}
|
||||
nsIFileLocator * appShellLocator;
|
||||
|
||||
nsresult rv = nsComponentManager::CreateInstance(kFileLocatorCID,
|
||||
nsnull,
|
||||
kFileLocatorIID,
|
||||
(void**) &appShellLocator);
|
||||
|
||||
if ( NS_SUCCEEDED(rv) )
|
||||
{
|
||||
mFileSpec = new nsFileSpec();
|
||||
appShellLocator->GetFileLocation(value, mFileSpec);
|
||||
NS_RELEASE(appShellLocator);
|
||||
}
|
||||
}
|
|
@ -51,8 +51,7 @@ class nsInstallFolder
|
|||
void SetDirectoryPath(const nsString& aFolderID, const nsString& aRelativePath);
|
||||
void PickDefaultDirectory();
|
||||
PRInt32 MapNameToEnum(const nsString& name);
|
||||
|
||||
void operator = (enum nsSpecialSystemDirectory::SystemDirectories aSystemSystemDirectory);
|
||||
void SetAppShellDirectory(PRUint32 value);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ static int32 gdiff_validateFile( pDIFFDATA dd, int file );
|
|||
|
||||
nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
|
||||
const nsString& inVRName,
|
||||
nsIDOMInstallVersion* inVInfo,
|
||||
const nsString& inVInfo,
|
||||
const nsString& inJarLocation,
|
||||
PRInt32 *error)
|
||||
|
||||
|
@ -87,21 +87,18 @@ nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
|
|||
mPatchedFile = nsnull;
|
||||
mRegistryName = new nsString(inVRName);
|
||||
mJarLocation = new nsString(inJarLocation);
|
||||
|
||||
nsString tempString;
|
||||
inVInfo->ToString(tempString);
|
||||
mVersionInfo = new nsInstallVersion();
|
||||
mVersionInfo->Init(tempString);
|
||||
mTargetFile = new nsFileSpec(folderSpec);
|
||||
|
||||
|
||||
mTargetFile = new nsFileSpec(folderSpec);
|
||||
mVersionInfo = new nsInstallVersion();
|
||||
|
||||
mVersionInfo->Init(inVInfo);
|
||||
|
||||
}
|
||||
|
||||
|
||||
nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
|
||||
const nsString& inVRName,
|
||||
nsIDOMInstallVersion* inVInfo,
|
||||
const nsString& inVInfo,
|
||||
const nsString& inJarLocation,
|
||||
const nsString& folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
|
@ -120,15 +117,12 @@ nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
|
|||
mPatchedFile = nsnull;
|
||||
mRegistryName = new nsString(inVRName);
|
||||
mJarLocation = new nsString(inJarLocation);
|
||||
|
||||
nsString tempString;
|
||||
inVInfo->ToString(tempString);
|
||||
mVersionInfo = new nsInstallVersion();
|
||||
mVersionInfo->Init(tempString);
|
||||
mVersionInfo = new nsInstallVersion();
|
||||
|
||||
|
||||
mTargetFile = new nsFileSpec(folderSpec);
|
||||
if(inPartialPath != "null")
|
||||
mVersionInfo->Init(inVInfo);
|
||||
|
||||
mTargetFile = new nsFileSpec(folderSpec);
|
||||
if(inPartialPath != "null")
|
||||
*mTargetFile += inPartialPath;
|
||||
}
|
||||
|
||||
|
@ -216,7 +210,7 @@ PRInt32 nsInstallPatch::Prepare()
|
|||
|
||||
if ( deleteOldSrc )
|
||||
{
|
||||
DeleteFileLater(*fileName );
|
||||
DeleteFileNowOrSchedule(*fileName );
|
||||
}
|
||||
|
||||
return err;
|
||||
|
@ -239,7 +233,7 @@ PRInt32 nsInstallPatch::Complete()
|
|||
if (fileName != nsnull && (*fileName == *mPatchedFile) )
|
||||
{
|
||||
// the patch has not been superceded--do final replacement
|
||||
err = ReplaceFileLater( *mTargetFile, *mPatchedFile);
|
||||
err = ReplaceFileNowOrSchedule( *mTargetFile, *mPatchedFile);
|
||||
if ( 0 == err || nsInstall::REBOOT_NEEDED == err )
|
||||
{
|
||||
nsString tempVersionString;
|
||||
|
@ -280,7 +274,7 @@ void nsInstallPatch::Abort()
|
|||
|
||||
if (fileName != nsnull && (*fileName == *mPatchedFile) )
|
||||
{
|
||||
DeleteFileLater( *mPatchedFile );
|
||||
DeleteFileNowOrSchedule( *mPatchedFile );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include "nsInstall.h"
|
||||
#include "nsInstallFolder.h"
|
||||
#include "nsIDOMInstallVersion.h"
|
||||
#include "nsInstallVersion.h"
|
||||
|
||||
|
||||
class nsInstallPatch : public nsInstallObject
|
||||
|
@ -35,7 +35,7 @@ class nsInstallPatch : public nsInstallObject
|
|||
|
||||
nsInstallPatch( nsInstall* inInstall,
|
||||
const nsString& inVRName,
|
||||
nsIDOMInstallVersion* inVInfo,
|
||||
const nsString& inVInfo,
|
||||
const nsString& inJarLocation,
|
||||
const nsString& folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
|
@ -43,7 +43,7 @@ class nsInstallPatch : public nsInstallObject
|
|||
|
||||
nsInstallPatch( nsInstall* inInstall,
|
||||
const nsString& inVRName,
|
||||
nsIDOMInstallVersion* inVInfo,
|
||||
const nsString& inVInfo,
|
||||
const nsString& inJarLocation,
|
||||
PRInt32 *error);
|
||||
|
||||
|
|
|
@ -136,10 +136,8 @@ nsInstallTrigger::StartSoftwareUpdate(const nsString& aURL, PRInt32 aFlags, PRIn
|
|||
nsString localFile;
|
||||
CreateTempFileFromURL(aURL, localFile);
|
||||
|
||||
nsInstallInfo *nextInstall = new nsInstallInfo( aURL, localFile, aFlags);
|
||||
|
||||
// start the download (this will clean itself up)
|
||||
nsSoftwareUpdateListener *downloader = new nsSoftwareUpdateListener(nextInstall);
|
||||
nsSoftwareUpdateListener *downloader = new nsSoftwareUpdateListener(aURL, localFile, aFlags);
|
||||
|
||||
*aReturn = NS_OK; // maybe we should do something more.
|
||||
return NS_OK;
|
||||
|
@ -151,10 +149,8 @@ nsInstallTrigger::StartSoftwareUpdate(const nsString& aURL, PRInt32* aReturn)
|
|||
nsString localFile;
|
||||
CreateTempFileFromURL(aURL, localFile);
|
||||
|
||||
nsInstallInfo *nextInstall = new nsInstallInfo( aURL, localFile, 0);
|
||||
|
||||
// start the download (this will clean itself up)
|
||||
nsSoftwareUpdateListener *downloader = new nsSoftwareUpdateListener(nextInstall);
|
||||
nsSoftwareUpdateListener *downloader = new nsSoftwareUpdateListener(aURL, localFile, 0);
|
||||
|
||||
*aReturn = NS_OK; // maybe we should do something more.
|
||||
return NS_OK;
|
||||
|
|
|
@ -182,14 +182,14 @@ REGERR su_UninstallProcessItem(char *component_path)
|
|||
else
|
||||
{
|
||||
err = VR_Remove(component_path);
|
||||
DeleteFileLater(nsFileSpec(filepath));
|
||||
DeleteFileNowOrSchedule(nsFileSpec(filepath));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* delete node and file */
|
||||
err = VR_Remove(component_path);
|
||||
DeleteFileLater(nsFileSpec(filepath));
|
||||
DeleteFileNowOrSchedule(nsFileSpec(filepath));
|
||||
}
|
||||
}
|
||||
return err;
|
||||
|
|
|
@ -158,7 +158,10 @@ static void PR_CALLBACK FinalizeInstall(JSContext *cx, JSObject *obj)
|
|||
delete nativeThis;
|
||||
}
|
||||
|
||||
void nsCvrtJSValToStr(nsString& aString,
|
||||
/***********************************************************************/
|
||||
/* JS Utilities */
|
||||
/***********************************************************************/
|
||||
void ConvertJSValToStr(nsString& aString,
|
||||
JSContext* aContext,
|
||||
jsval aValue)
|
||||
{
|
||||
|
@ -169,11 +172,11 @@ void nsCvrtJSValToStr(nsString& aString,
|
|||
}
|
||||
else
|
||||
{
|
||||
aString.Truncate();
|
||||
aString = "";
|
||||
}
|
||||
}
|
||||
|
||||
void nsCvrtStrToJSVal(const nsString& aProp,
|
||||
void ConvertStrToJSVal(const nsString& aProp,
|
||||
JSContext* aContext,
|
||||
jsval* aReturn)
|
||||
{
|
||||
|
@ -182,7 +185,7 @@ void nsCvrtStrToJSVal(const nsString& aProp,
|
|||
*aReturn = STRING_TO_JSVAL(jsstring);
|
||||
}
|
||||
|
||||
PRBool nsCvrtJSValToBool(PRBool* aProp,
|
||||
PRBool ConvertJSValToBool(PRBool* aProp,
|
||||
JSContext* aContext,
|
||||
jsval aValue)
|
||||
{
|
||||
|
@ -200,7 +203,7 @@ PRBool nsCvrtJSValToBool(PRBool* aProp,
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
PRBool nsCvrtJSValToObj(nsISupports** aSupports,
|
||||
PRBool ConvertJSValToObj(nsISupports** aSupports,
|
||||
REFNSIID aIID,
|
||||
const nsString& aTypeName,
|
||||
JSContext* aContext,
|
||||
|
@ -237,6 +240,33 @@ PRBool nsCvrtJSValToObj(nsISupports** aSupports,
|
|||
}
|
||||
|
||||
|
||||
void ConvertJSvalToVersionString(nsString& versionString, JSContext* cx, jsval argument)
|
||||
{
|
||||
versionString = "";
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
/***********************************************************************/
|
||||
/***********************************************************************/
|
||||
|
||||
|
||||
//
|
||||
// Native method AbortInstall
|
||||
//
|
||||
|
@ -301,7 +331,7 @@ InstallAddDirectory(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
{
|
||||
// public int AddDirectory (String jarSourcePath)
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->AddDirectory(b0, &nativeRet))
|
||||
{
|
||||
|
@ -317,10 +347,10 @@ InstallAddDirectory(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
// String localDirSpec,
|
||||
// String relativeLocalPath);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
nsCvrtJSValToStr(b2, cx, argv[2]);
|
||||
nsCvrtJSValToStr(b3, cx, argv[3]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b2, cx, argv[2]);
|
||||
ConvertJSValToStr(b3, cx, argv[3]);
|
||||
|
||||
if(NS_OK != nativeThis->AddDirectory(b0, b1, b2, b3, &nativeRet))
|
||||
{
|
||||
|
@ -337,38 +367,19 @@ InstallAddDirectory(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
// Object localDirSpec,
|
||||
// String relativeLocalPath);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b2, cx, argv[2]);
|
||||
nsCvrtJSValToStr(b3, cx, argv[3]);
|
||||
nsCvrtJSValToStr(b4, cx, argv[4]);
|
||||
|
||||
if(JSVAL_IS_OBJECT(argv[1]))
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSvalToVersionString(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b2, cx, argv[2]);
|
||||
ConvertJSValToStr(b3, cx, argv[3]);
|
||||
ConvertJSValToStr(b4, cx, argv[4]);
|
||||
|
||||
if(NS_OK != nativeThis->AddDirectory(b0, b1, b2, b3, b4, &nativeRet))
|
||||
{
|
||||
if(!JSVAL_IS_NULL(argv[1]))
|
||||
{
|
||||
JSObject* jsobj = JSVAL_TO_OBJECT(argv[1]);
|
||||
JSClass* jsclass = JS_GetClass(cx, jsobj);
|
||||
if ((nsnull != jsclass) && (jsclass->flags & JSCLASS_HAS_PRIVATE))
|
||||
{
|
||||
nsIDOMInstallVersion* version = (nsIDOMInstallVersion*)JS_GetPrivate(cx, jsobj);
|
||||
|
||||
if(NS_OK != nativeThis->AddDirectory(b0, version, b2, b3, b4, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return JS_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
if(NS_OK != nativeThis->AddDirectory(b0, b1, b2, b3, b4, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
|
||||
}
|
||||
else if (argc == 6)
|
||||
{
|
||||
|
@ -379,42 +390,22 @@ InstallAddDirectory(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
// String relativeLocalPath,
|
||||
// Boolean forceUpdate);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b2, cx, argv[2]);
|
||||
nsCvrtJSValToStr(b3, cx, argv[3]);
|
||||
nsCvrtJSValToStr(b4, cx, argv[4]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSvalToVersionString(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b2, cx, argv[2]);
|
||||
ConvertJSValToStr(b3, cx, argv[3]);
|
||||
ConvertJSValToStr(b4, cx, argv[4]);
|
||||
|
||||
if(!nsCvrtJSValToBool(&b5, cx, argv[5]))
|
||||
if(!ConvertJSValToBool(&b5, cx, argv[5]))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if(JSVAL_IS_OBJECT(argv[1]))
|
||||
if(NS_OK != nativeThis->AddDirectory(b0, b1, b2, b3, b4, b5, &nativeRet))
|
||||
{
|
||||
if(!JSVAL_IS_NULL(argv[1]))
|
||||
{
|
||||
JSObject* jsobj = JSVAL_TO_OBJECT(argv[1]);
|
||||
JSClass* jsclass = JS_GetClass(cx, jsobj);
|
||||
if ((nsnull != jsclass) && (jsclass->flags & JSCLASS_HAS_PRIVATE))
|
||||
{
|
||||
nsIDOMInstallVersion* version = (nsIDOMInstallVersion*)JS_GetPrivate(cx, jsobj);
|
||||
|
||||
if(NS_OK != nativeThis->AddDirectory(b0, version, b2, b3, b4, b5, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return JS_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
if(NS_OK != nativeThis->AddDirectory(b0, b1, b2, b3, b4, b5, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
|
@ -459,40 +450,20 @@ InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
// String relativeLocalPath,
|
||||
// Boolean forceUpdate);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b2, cx, argv[2]);
|
||||
nsCvrtJSValToStr(b3, cx, argv[3]);
|
||||
nsCvrtJSValToStr(b4, cx, argv[4]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSvalToVersionString(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b2, cx, argv[2]);
|
||||
ConvertJSValToStr(b3, cx, argv[3]);
|
||||
ConvertJSValToStr(b4, cx, argv[4]);
|
||||
|
||||
if(!nsCvrtJSValToBool(&b5, cx, argv[5]))
|
||||
if(!ConvertJSValToBool(&b5, cx, argv[5]))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if(JSVAL_IS_OBJECT(argv[1]))
|
||||
if(NS_OK != nativeThis->AddSubcomponent(b0, b1, b2, b3, b4, b5, &nativeRet))
|
||||
{
|
||||
if(!JSVAL_IS_NULL(argv[1]))
|
||||
{
|
||||
JSObject* jsobj = JSVAL_TO_OBJECT(argv[1]);
|
||||
JSClass* jsclass = JS_GetClass(cx, jsobj);
|
||||
if ((nsnull != jsclass) && (jsclass->flags & JSCLASS_HAS_PRIVATE))
|
||||
{
|
||||
nsIDOMInstallVersion* version = (nsIDOMInstallVersion*)JS_GetPrivate(cx, jsobj);
|
||||
|
||||
if(NS_OK != nativeThis->AddSubcomponent(b0, version, b2, b3, b4, b5, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
if(NS_OK != nativeThis->AddSubcomponent(b0, b1, b2, b3, b4, b5, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
|
@ -505,37 +476,17 @@ InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
// Object localDirSpec,
|
||||
// String relativeLocalPath);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b2, cx, argv[2]);
|
||||
nsCvrtJSValToStr(b3, cx, argv[3]);
|
||||
nsCvrtJSValToStr(b4, cx, argv[4]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSvalToVersionString(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b2, cx, argv[2]);
|
||||
ConvertJSValToStr(b3, cx, argv[3]);
|
||||
ConvertJSValToStr(b4, cx, argv[4]);
|
||||
|
||||
if(JSVAL_IS_OBJECT(argv[1]))
|
||||
if(NS_OK != nativeThis->AddSubcomponent(b0, b1, b2, b3, b4, &nativeRet))
|
||||
{
|
||||
if(!JSVAL_IS_NULL(argv[1]))
|
||||
{
|
||||
JSObject* jsobj = JSVAL_TO_OBJECT(argv[1]);
|
||||
JSClass* jsclass = JS_GetClass(cx, jsobj);
|
||||
if ((nsnull != jsclass) && (jsclass->flags & JSCLASS_HAS_PRIVATE))
|
||||
{
|
||||
nsIDOMInstallVersion* version = (nsIDOMInstallVersion*)JS_GetPrivate(cx, jsobj);
|
||||
|
||||
if(NS_OK != nativeThis->AddSubcomponent(b0, version, b2, b3, b4, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
if(NS_OK != nativeThis->AddSubcomponent(b0, b1, b2, b3, b4, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else if(argc >= 4)
|
||||
|
@ -545,10 +496,10 @@ InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
// Object localDirSpec,
|
||||
// String relativeLocalPath);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
nsCvrtJSValToStr(b2, cx, argv[2]);
|
||||
nsCvrtJSValToStr(b3, cx, argv[3]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b2, cx, argv[2]);
|
||||
ConvertJSValToStr(b3, cx, argv[3]);
|
||||
|
||||
if(NS_OK != nativeThis->AddSubcomponent(b0, b1, b2, b3, &nativeRet))
|
||||
{
|
||||
|
@ -561,7 +512,7 @@ InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
{
|
||||
// public int AddSubcomponent ( String jarSourcePath);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->AddSubcomponent(b0, &nativeRet))
|
||||
{
|
||||
|
@ -602,7 +553,7 @@ InstallDeleteComponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
{
|
||||
// public int DeleteComponent ( String registryName);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->DeleteComponent(b0, &nativeRet))
|
||||
{
|
||||
|
@ -645,8 +596,8 @@ InstallDeleteFile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
|||
// public int DeleteFile ( Object folder,
|
||||
// String relativeFileName);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(NS_OK != nativeThis->DeleteFile(b0, b1, &nativeRet))
|
||||
{
|
||||
|
@ -687,7 +638,7 @@ InstallDiskSpaceAvailable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
{
|
||||
// public int DiskSpaceAvailable ( Object localDirSpec);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->DiskSpaceAvailable(b0, &nativeRet))
|
||||
{
|
||||
|
@ -730,8 +681,8 @@ InstallExecute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
|
|||
// public int Execute ( String jarSourcePath,
|
||||
// String args);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(NS_OK != nativeThis->Execute(b0, b1, &nativeRet))
|
||||
{
|
||||
|
@ -744,7 +695,7 @@ InstallExecute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
|
|||
{
|
||||
// public int Execute ( String jarSourcePath);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->Execute(b0, &nativeRet))
|
||||
{
|
||||
|
@ -824,7 +775,7 @@ InstallGestalt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
|
|||
// public int Gestalt ( String selector,
|
||||
// long *response);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->Gestalt(b0, &nativeRet))
|
||||
{
|
||||
|
@ -867,8 +818,8 @@ InstallGetComponentFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
// public int GetComponentFolder ( String registryName,
|
||||
// String subDirectory);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(NS_OK != nativeThis->GetComponentFolder(b0, b1, &nativeRet))
|
||||
{
|
||||
|
@ -878,13 +829,13 @@ InstallGetComponentFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
if(nsnull == nativeRet)
|
||||
*rval = JSVAL_NULL;
|
||||
else
|
||||
nsCvrtStrToJSVal(*nativeRet, cx, rval);
|
||||
ConvertStrToJSVal(*nativeRet, cx, rval);
|
||||
}
|
||||
else if(argc >= 1)
|
||||
{
|
||||
// public int GetComponentFolder ( String registryName);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->GetComponentFolder(b0, &nativeRet))
|
||||
{
|
||||
|
@ -894,7 +845,7 @@ InstallGetComponentFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
if(nsnull == nativeRet)
|
||||
*rval = JSVAL_NULL;
|
||||
else
|
||||
nsCvrtStrToJSVal(*nativeRet, cx, rval);
|
||||
ConvertStrToJSVal(*nativeRet, cx, rval);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -930,8 +881,8 @@ InstallGetFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
|||
// public int GetFolder ( String folderName, --OR-- Object localDirSpec,
|
||||
// String subDirectory);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(NS_OK != nativeThis->GetFolder(b0, b1, &nativeRet))
|
||||
{
|
||||
|
@ -941,13 +892,13 @@ InstallGetFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
|||
if(nsnull == nativeRet)
|
||||
*rval = JSVAL_NULL;
|
||||
else
|
||||
nsCvrtStrToJSVal(*nativeRet, cx, rval);
|
||||
ConvertStrToJSVal(*nativeRet, cx, rval);
|
||||
}
|
||||
else if(argc >= 1)
|
||||
{
|
||||
// public int GetFolder ( String folderName);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->GetFolder(b0, &nativeRet))
|
||||
{
|
||||
|
@ -957,7 +908,7 @@ InstallGetFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
|||
if(nsnull == nativeRet)
|
||||
*rval = JSVAL_NULL;
|
||||
else
|
||||
nsCvrtStrToJSVal(*nativeRet, cx, rval);
|
||||
ConvertStrToJSVal(*nativeRet, cx, rval);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1033,8 +984,8 @@ InstallGetWinProfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
|||
// public int GetWinProfile (Object folder,
|
||||
// String file);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(NS_OK != nativeThis->GetWinProfile(b0, b1, cx, &WinProfileClass, rval))
|
||||
{
|
||||
|
@ -1119,35 +1070,15 @@ InstallPatch(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
// Object localDirSpec,
|
||||
// String relativeLocalPath);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b2, cx, argv[2]);
|
||||
nsCvrtJSValToStr(b3, cx, argv[3]);
|
||||
nsCvrtJSValToStr(b4, cx, argv[4]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSvalToVersionString(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b2, cx, argv[2]);
|
||||
ConvertJSValToStr(b3, cx, argv[3]);
|
||||
ConvertJSValToStr(b4, cx, argv[4]);
|
||||
|
||||
if(JSVAL_IS_OBJECT(argv[1]))
|
||||
if(NS_OK != nativeThis->Patch(b0, b1, b2, b3, b4, &nativeRet))
|
||||
{
|
||||
if(!JSVAL_IS_NULL(argv[1]))
|
||||
{
|
||||
JSObject* jsobj = JSVAL_TO_OBJECT(argv[1]);
|
||||
JSClass* jsclass = JS_GetClass(cx, jsobj);
|
||||
if ((nsnull != jsclass) && (jsclass->flags & JSCLASS_HAS_PRIVATE))
|
||||
{
|
||||
nsIDOMInstallVersion* version = (nsIDOMInstallVersion*)JS_GetPrivate(cx, jsobj);
|
||||
|
||||
if(NS_OK != nativeThis->Patch(b0, version, b2, b3, b4, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
if(NS_OK != nativeThis->Patch(b0, b1, b2, b3, b4, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
|
@ -1159,10 +1090,10 @@ InstallPatch(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
// Object localDirSpec,
|
||||
// String relativeLocalPath);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
nsCvrtJSValToStr(b2, cx, argv[2]);
|
||||
nsCvrtJSValToStr(b3, cx, argv[3]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b2, cx, argv[2]);
|
||||
ConvertJSValToStr(b3, cx, argv[3]);
|
||||
|
||||
if(NS_OK != nativeThis->Patch(b0, b1, b2, b3, &nativeRet))
|
||||
{
|
||||
|
@ -1239,7 +1170,7 @@ InstallSetPackageFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||
{
|
||||
// public int SetPackageFolder (Object folder);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->SetPackageFolder(b0))
|
||||
{
|
||||
|
@ -1269,7 +1200,6 @@ InstallStartInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
nsAutoString b2;
|
||||
PRInt32 b3;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
|
@ -1278,90 +1208,27 @@ InstallStartInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if(argc >= 4)
|
||||
{
|
||||
// public int StartInstall (String userPackageName,
|
||||
// String package,
|
||||
// String version, --OR-- VersionInfo version,
|
||||
// int flags);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(!JS_ValueToInt32(cx, argv[3], (int32 *)&b3))
|
||||
{
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if(JSVAL_IS_OBJECT(argv[2]))
|
||||
{
|
||||
if(!JSVAL_IS_NULL(argv[2]))
|
||||
{
|
||||
JSObject* jsobj = JSVAL_TO_OBJECT(argv[2]);
|
||||
JSClass* jsclass = JS_GetClass(cx, jsobj);
|
||||
if ((nsnull != jsclass) && (jsclass->flags & JSCLASS_HAS_PRIVATE))
|
||||
{
|
||||
nsIDOMInstallVersion* version = (nsIDOMInstallVersion*)JS_GetPrivate(cx, jsobj);
|
||||
|
||||
if(NS_OK != nativeThis->StartInstall(b0, b1, version, b3, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCvrtJSValToStr(b2, cx, argv[2]);
|
||||
if(NS_OK != nativeThis->StartInstall(b0, b1, b2, b3, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else if(argc >= 3)
|
||||
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]);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(JSVAL_IS_OBJECT(argv[2]))
|
||||
if(NS_OK != nativeThis->StartInstall(b0, b1, b2, &nativeRet))
|
||||
{
|
||||
if(!JSVAL_IS_NULL(argv[2]))
|
||||
{
|
||||
JSObject* jsobj = JSVAL_TO_OBJECT(argv[2]);
|
||||
JSClass* jsclass = JS_GetClass(cx, jsobj);
|
||||
if ((nsnull != jsclass) && (jsclass->flags & JSCLASS_HAS_PRIVATE))
|
||||
{
|
||||
nsIDOMInstallVersion* version = (nsIDOMInstallVersion*)JS_GetPrivate(cx, jsobj);
|
||||
|
||||
if(NS_OK != nativeThis->StartInstall(b0, b1, version, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCvrtJSValToStr(b2, cx, argv[2]);
|
||||
if(NS_OK != nativeThis->StartInstall(b0, b1, b2, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "Function StartInstall requires 4 parameters");
|
||||
JS_ReportError(cx, "Function StartInstall requires 3 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1391,7 +1258,7 @@ InstallUninstall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
|||
{
|
||||
// public int Uninstall (String packageName);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->Uninstall(b0, &nativeRet))
|
||||
{
|
||||
|
@ -1417,7 +1284,7 @@ InstallTRACE(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
{
|
||||
nsAutoString b0;
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
char *tempStr;
|
||||
tempStr = b0.ToNewCString();
|
||||
|
|
|
@ -29,19 +29,19 @@
|
|||
#include "nsIDOMInstallVersion.h"
|
||||
#include "nsIDOMInstallTriggerGlobal.h"
|
||||
|
||||
extern void nsCvrtJSValToStr(nsString& aString,
|
||||
extern void ConvertJSValToStr(nsString& aString,
|
||||
JSContext* aContext,
|
||||
jsval aValue);
|
||||
|
||||
extern void nsCvrtStrToJSVal(const nsString& aProp,
|
||||
extern void ConvertStrToJSVal(const nsString& aProp,
|
||||
JSContext* aContext,
|
||||
jsval* aReturn);
|
||||
|
||||
extern PRBool nsCvrtJSValToBool(PRBool* aProp,
|
||||
extern PRBool ConvertJSValToBool(PRBool* aProp,
|
||||
JSContext* aContext,
|
||||
jsval aValue);
|
||||
|
||||
extern PRBool nsCvrtJSValToObj(nsISupports** aSupports,
|
||||
extern PRBool ConvertJSValToObj(nsISupports** aSupports,
|
||||
REFNSIID aIID,
|
||||
const nsString& aTypeName,
|
||||
JSContext* aContext,
|
||||
|
@ -199,7 +199,7 @@ InstallTriggerGlobalStartSoftwareUpdate(JSContext *cx, JSObject *obj, uintN argc
|
|||
// public int StartSoftwareUpdate(String url,
|
||||
// int flag);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(!JS_ValueToInt32(cx, argv[1], (int32 *)&b1))
|
||||
{
|
||||
|
@ -218,7 +218,7 @@ InstallTriggerGlobalStartSoftwareUpdate(JSContext *cx, JSObject *obj, uintN argc
|
|||
{
|
||||
// public int StartSoftwareUpdate(String url);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->StartSoftwareUpdate(b0, &nativeRet))
|
||||
{
|
||||
|
@ -269,8 +269,8 @@ InstallTriggerGlobalConditionalSoftwareUpdate(JSContext *cx, JSObject *obj, uint
|
|||
// String version, --OR-- VersionInfo version
|
||||
// int mode);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(!JS_ValueToInt32(cx, argv[2], (int32 *)&b2int))
|
||||
{
|
||||
|
@ -283,7 +283,7 @@ InstallTriggerGlobalConditionalSoftwareUpdate(JSContext *cx, JSObject *obj, uint
|
|||
JS_ReportError(cx, "5th parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
if(JSVAL_IS_OBJECT(argv[3]))
|
||||
{
|
||||
JSObject* jsobj = JSVAL_TO_OBJECT(argv[3]);
|
||||
|
@ -300,7 +300,7 @@ InstallTriggerGlobalConditionalSoftwareUpdate(JSContext *cx, JSObject *obj, uint
|
|||
}
|
||||
else
|
||||
{
|
||||
nsCvrtJSValToStr(b3str, cx, argv[3]);
|
||||
ConvertJSValToStr(b3str, cx, argv[3]);
|
||||
if(NS_OK != nativeThis->ConditionalSoftwareUpdate(b0, b1, b2int, b3str, b4, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
|
@ -316,8 +316,8 @@ InstallTriggerGlobalConditionalSoftwareUpdate(JSContext *cx, JSObject *obj, uint
|
|||
// String version, --OR-- VersionInfo version
|
||||
// int mode);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(!JS_ValueToInt32(cx, argv[3], (int32 *)&b3int))
|
||||
{
|
||||
|
@ -341,7 +341,7 @@ InstallTriggerGlobalConditionalSoftwareUpdate(JSContext *cx, JSObject *obj, uint
|
|||
}
|
||||
else
|
||||
{
|
||||
nsCvrtJSValToStr(b2str, cx, argv[2]);
|
||||
ConvertJSValToStr(b2str, cx, argv[2]);
|
||||
if(NS_OK != nativeThis->ConditionalSoftwareUpdate(b0, b1, b2str, b3int, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
|
@ -356,8 +356,8 @@ InstallTriggerGlobalConditionalSoftwareUpdate(JSContext *cx, JSObject *obj, uint
|
|||
// String registryName,
|
||||
// String version); --OR-- VersionInfo version
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(JSVAL_IS_OBJECT(argv[2]))
|
||||
{
|
||||
|
@ -375,7 +375,7 @@ InstallTriggerGlobalConditionalSoftwareUpdate(JSContext *cx, JSObject *obj, uint
|
|||
}
|
||||
else
|
||||
{
|
||||
nsCvrtJSValToStr(b2str, cx, argv[2]);
|
||||
ConvertJSValToStr(b2str, cx, argv[2]);
|
||||
if(NS_OK != nativeThis->ConditionalSoftwareUpdate(b0, b1, b2str, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
|
@ -425,7 +425,7 @@ InstallTriggerGlobalCompareVersion(JSContext *cx, JSObject *obj, uintN argc, jsv
|
|||
// int release,
|
||||
// int build);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(!JS_ValueToInt32(cx, argv[1], (int32 *)&b1int))
|
||||
{
|
||||
|
@ -460,7 +460,7 @@ InstallTriggerGlobalCompareVersion(JSContext *cx, JSObject *obj, uintN argc, jsv
|
|||
// public int CompareVersion(String registryName,
|
||||
// String version); --OR-- VersionInfo version
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(JSVAL_IS_OBJECT(argv[1]))
|
||||
{
|
||||
|
@ -478,7 +478,7 @@ InstallTriggerGlobalCompareVersion(JSContext *cx, JSObject *obj, uintN argc, jsv
|
|||
}
|
||||
else
|
||||
{
|
||||
nsCvrtJSValToStr(b1str, cx, argv[1]);
|
||||
ConvertJSValToStr(b1str, cx, argv[1]);
|
||||
if(NS_OK != nativeThis->CompareVersion(b0, b1str, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
|
|
|
@ -31,24 +31,26 @@
|
|||
#include "nsRepository.h"
|
||||
#include "nsDOMCID.h"
|
||||
|
||||
extern void nsCvrtJSValToStr(nsString& aString,
|
||||
extern void ConvertJSValToStr(nsString& aString,
|
||||
JSContext* aContext,
|
||||
jsval aValue);
|
||||
|
||||
extern void nsCvrtStrToJSVal(const nsString& aProp,
|
||||
extern void ConvertStrToJSVal(const nsString& aProp,
|
||||
JSContext* aContext,
|
||||
jsval* aReturn);
|
||||
|
||||
extern PRBool nsCvrtJSValToBool(PRBool* aProp,
|
||||
extern PRBool ConvertJSValToBool(PRBool* aProp,
|
||||
JSContext* aContext,
|
||||
jsval aValue);
|
||||
|
||||
extern PRBool nsCvrtJSValToObj(nsISupports** aSupports,
|
||||
extern PRBool ConvertJSValToObj(nsISupports** aSupports,
|
||||
REFNSIID aIID,
|
||||
const nsString& aTypeName,
|
||||
JSContext* aContext,
|
||||
jsval aValue);
|
||||
|
||||
void ConvertJSvalToVersionString(nsString& versionString, JSContext* cx, jsval* argument);
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
|
@ -399,7 +401,7 @@ InstallVersionCompareTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||
|
||||
if(JSVAL_IS_OBJECT(argv[0]))
|
||||
{
|
||||
if(JS_FALSE == nsCvrtJSValToObj((nsISupports **)&versionObj,
|
||||
if(JS_FALSE == ConvertJSValToObj((nsISupports **)&versionObj,
|
||||
kIInstallVersionIID,
|
||||
"InstallVersion",
|
||||
cx,
|
||||
|
@ -415,7 +417,7 @@ InstallVersionCompareTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||
}
|
||||
else
|
||||
{
|
||||
nsCvrtJSValToStr(b0str, cx, argv[0]);
|
||||
ConvertJSValToStr(b0str, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->CompareTo(b0str, &nativeRet))
|
||||
{
|
||||
|
|
|
@ -25,19 +25,19 @@
|
|||
#include "nsWinProfile.h"
|
||||
#include "nsJSWinProfile.h"
|
||||
|
||||
extern void nsCvrtJSValToStr(nsString& aString,
|
||||
extern void ConvertJSValToStr(nsString& aString,
|
||||
JSContext* aContext,
|
||||
jsval aValue);
|
||||
|
||||
extern void nsCvrtStrToJSVal(const nsString& aProp,
|
||||
extern void ConvertStrToJSVal(const nsString& aProp,
|
||||
JSContext* aContext,
|
||||
jsval* aReturn);
|
||||
|
||||
extern PRBool nsCvrtJSValToBool(PRBool* aProp,
|
||||
extern PRBool ConvertJSValToBool(PRBool* aProp,
|
||||
JSContext* aContext,
|
||||
jsval aValue);
|
||||
|
||||
extern PRBool nsCvrtJSValToObj(nsISupports** aSupports,
|
||||
extern PRBool ConvertJSValToObj(nsISupports** aSupports,
|
||||
REFNSIID aIID,
|
||||
const nsString& aTypeName,
|
||||
JSContext* aContext,
|
||||
|
@ -77,12 +77,12 @@ WinProfileGetString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
// public int getString ( String section,
|
||||
// String key);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
nativeThis->getString(b0, b1, &nativeRet);
|
||||
|
||||
nsCvrtStrToJSVal(nativeRet, cx, rval);
|
||||
ConvertStrToJSVal(nativeRet, cx, rval);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -119,9 +119,9 @@ WinProfileWriteString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
|
|||
// String key,
|
||||
// String value);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
nsCvrtJSValToStr(b2, cx, argv[2]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b2, cx, argv[2]);
|
||||
|
||||
if(NS_OK != nativeThis->writeString(b0, b1, b2, &nativeRet))
|
||||
{
|
||||
|
|
|
@ -27,19 +27,19 @@
|
|||
|
||||
static void PR_CALLBACK WinRegCleanup(JSContext *cx, JSObject *obj);
|
||||
|
||||
extern void nsCvrtJSValToStr(nsString& aString,
|
||||
extern void ConvertJSValToStr(nsString& aString,
|
||||
JSContext* aContext,
|
||||
jsval aValue);
|
||||
|
||||
extern void nsCvrtStrToJSVal(const nsString& aProp,
|
||||
extern void ConvertStrToJSVal(const nsString& aProp,
|
||||
JSContext* aContext,
|
||||
jsval* aReturn);
|
||||
|
||||
extern PRBool nsCvrtJSValToBool(PRBool* aProp,
|
||||
extern PRBool ConvertJSValToBool(PRBool* aProp,
|
||||
JSContext* aContext,
|
||||
jsval aValue);
|
||||
|
||||
extern PRBool nsCvrtJSValToObj(nsISupports** aSupports,
|
||||
extern PRBool ConvertJSValToObj(nsISupports** aSupports,
|
||||
REFNSIID aIID,
|
||||
const nsString& aTypeName,
|
||||
JSContext* aContext,
|
||||
|
@ -124,8 +124,8 @@ WinRegCreateKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rv
|
|||
// public int createKey ( String subKey,
|
||||
// String className);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(NS_OK != nativeThis->createKey(b0, b1, &nativeRet))
|
||||
{
|
||||
|
@ -165,7 +165,7 @@ WinRegDeleteKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rv
|
|||
{
|
||||
// public int deleteKey ( String subKey);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->deleteKey(b0, &nativeRet))
|
||||
{
|
||||
|
@ -208,8 +208,8 @@ WinRegDeleteValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
|||
// public int deleteValue ( String subKey,
|
||||
// String valueName);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(NS_OK != nativeThis->deleteValue(b0, b1, &nativeRet))
|
||||
{
|
||||
|
@ -253,9 +253,9 @@ WinRegSetValueString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
|||
// String valueName,
|
||||
// String value);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
nsCvrtJSValToStr(b2, cx, argv[2]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b2, cx, argv[2]);
|
||||
|
||||
if(NS_OK != nativeThis->setValueString(b0, b1, b2, &nativeRet))
|
||||
{
|
||||
|
@ -297,8 +297,8 @@ WinRegGetValueString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
|||
// public int getValueString ( String subKey,
|
||||
// String valueName);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(NS_OK != nativeThis->getValueString(b0, b1, &nativeRet))
|
||||
{
|
||||
|
@ -342,12 +342,12 @@ WinRegSetValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
|
|||
// String valueName,
|
||||
// nsWinRegItem *value);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
// fix: this parameter is an object, not a string.
|
||||
// A way needs to be figured out to convert the JSVAL to this object type
|
||||
// nsCvrtJSValToStr(b2, cx, argv[2]);
|
||||
// ConvertJSValToStr(b2, cx, argv[2]);
|
||||
|
||||
// if(NS_OK != nativeThis->setValue(b0, b1, b2, &nativeRet))
|
||||
// {
|
||||
|
@ -389,8 +389,8 @@ WinRegGetValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
|
|||
// public int getValue ( String subKey,
|
||||
// String valueName);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(NS_OK != nativeThis->getValue(b0, b1, &nativeRet))
|
||||
{
|
||||
|
|
|
@ -35,22 +35,20 @@
|
|||
|
||||
nsLoggingProgressNotifier::nsLoggingProgressNotifier()
|
||||
{
|
||||
nsSpecialSystemDirectory logFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
|
||||
logFile += "Install.log";
|
||||
|
||||
mLogStream = new nsOutputFileStream(logFile, PR_WRONLY | PR_CREATE_FILE | PR_APPEND, 0744 );
|
||||
mLogStream->seek(logFile.GetFileSize());
|
||||
}
|
||||
|
||||
nsLoggingProgressNotifier::~nsLoggingProgressNotifier()
|
||||
{
|
||||
mLogStream->close();
|
||||
delete mLogStream;
|
||||
}
|
||||
|
||||
void
|
||||
nsLoggingProgressNotifier::BeforeJavascriptEvaluation(void)
|
||||
{
|
||||
nsSpecialSystemDirectory logFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
|
||||
logFile += "Install.log";
|
||||
|
||||
mLogStream = new nsOutputFileStream(logFile, PR_WRONLY | PR_CREATE_FILE | PR_APPEND, 0744 );
|
||||
mLogStream->seek(logFile.GetFileSize());
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -63,11 +61,17 @@ nsLoggingProgressNotifier::AfterJavascriptEvaluation(void)
|
|||
*mLogStream << " Finished Installation " << time << nsEndl << nsEndl;
|
||||
|
||||
PL_strfree(time);
|
||||
|
||||
mLogStream->close();
|
||||
delete mLogStream;
|
||||
mLogStream = nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
nsLoggingProgressNotifier::InstallStarted(const char* UIPackageName)
|
||||
{
|
||||
if (mLogStream == nsnull) return;
|
||||
|
||||
char* time;
|
||||
GetTime(&time);
|
||||
|
||||
|
@ -91,12 +95,16 @@ nsLoggingProgressNotifier::ItemScheduled(const char* message )
|
|||
void
|
||||
nsLoggingProgressNotifier::InstallFinalization(const char* message, long itemNum, long totNum )
|
||||
{
|
||||
*mLogStream << " " << message << nsEndl;
|
||||
if (mLogStream == nsnull) return;
|
||||
|
||||
*mLogStream << " Item [" << (itemNum+1) << "/" << totNum << "]\t" << message << nsEndl;
|
||||
}
|
||||
|
||||
void
|
||||
nsLoggingProgressNotifier::InstallAborted(void)
|
||||
{
|
||||
if (mLogStream == nsnull) return;
|
||||
|
||||
char* time;
|
||||
GetTime(&time);
|
||||
|
||||
|
|
|
@ -1,163 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "nsSoftwareUpdateStream.h"
|
||||
#include "nscore.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsVector.h"
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsIURL.h"
|
||||
#include "nsINetlibURL.h"
|
||||
#include "nsINetService.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIStreamListener.h"
|
||||
|
||||
#include "nsISoftwareUpdate.h"
|
||||
#include "nsSoftwareUpdateIIDs.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kISoftwareUpdateIID, NS_ISOFTWAREUPDATE_IID);
|
||||
static NS_DEFINE_IID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID);
|
||||
|
||||
|
||||
nsSoftwareUpdateListener::nsSoftwareUpdateListener(nsInstallInfo *nextInstall)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
mInstallInfo = nextInstall;
|
||||
mOutFileDesc = PR_Open(nsAutoCString(nextInstall->GetLocalFile()), PR_CREATE_FILE | PR_RDWR, 0744);
|
||||
|
||||
if(mOutFileDesc == NULL)
|
||||
{
|
||||
mResult = -1;
|
||||
};
|
||||
|
||||
mResult = nsServiceManager::GetService( kSoftwareUpdateCID,
|
||||
kISoftwareUpdateIID,
|
||||
(nsISupports**)&mSoftwareUpdate);
|
||||
|
||||
if (NS_FAILED(mResult))
|
||||
return;
|
||||
|
||||
nsIURL *pURL = nsnull;
|
||||
mResult = NS_NewURL(&pURL, nextInstall->GetFromURL());
|
||||
|
||||
if (NS_FAILED(mResult))
|
||||
return;
|
||||
|
||||
mResult = NS_OpenURL(pURL, this);
|
||||
}
|
||||
|
||||
nsSoftwareUpdateListener::~nsSoftwareUpdateListener()
|
||||
{
|
||||
delete mInstallInfo;
|
||||
mSoftwareUpdate->Release();
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS( nsSoftwareUpdateListener, kIStreamListenerIID )
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSoftwareUpdateListener::GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* info)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSoftwareUpdateListener::OnProgress( nsIURL* aURL,
|
||||
PRUint32 Progress,
|
||||
PRUint32 ProgressMax)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSoftwareUpdateListener::OnStatus(nsIURL* aURL,
|
||||
const PRUnichar* aMsg)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSoftwareUpdateListener::OnStartBinding(nsIURL* aURL,
|
||||
const char *aContentType)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSoftwareUpdateListener::OnStopBinding(nsIURL* aURL,
|
||||
nsresult status,
|
||||
const PRUnichar* aMsg)
|
||||
{
|
||||
switch( status )
|
||||
{
|
||||
|
||||
case NS_BINDING_SUCCEEDED:
|
||||
PR_Close(mOutFileDesc);
|
||||
// Add to the XPInstall Queue. Yes this is a bit redunant. I be you are asking, why I have a nsInstallInfo, am
|
||||
// creating a new one. well, if I pull this out into its own dll, I would not want to pass a class around.
|
||||
|
||||
mSoftwareUpdate->InstallJar(mInstallInfo->GetFromURL(),
|
||||
mInstallInfo->GetLocalFile(),
|
||||
mInstallInfo->GetFlags() );
|
||||
break;
|
||||
|
||||
case NS_BINDING_FAILED:
|
||||
case NS_BINDING_ABORTED:
|
||||
mResult = status;
|
||||
PR_Close(mOutFileDesc);
|
||||
break;
|
||||
|
||||
default:
|
||||
mResult = NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
return mResult;
|
||||
}
|
||||
|
||||
#define BUF_SIZE 1024
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSoftwareUpdateListener::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRUint32 length)
|
||||
{
|
||||
PRUint32 len;
|
||||
nsresult err;
|
||||
char buffer[BUF_SIZE];
|
||||
|
||||
do
|
||||
{
|
||||
err = pIStream->Read(buffer, BUF_SIZE, &len);
|
||||
|
||||
if (mResult == 0 && err == 0)
|
||||
{
|
||||
if ( PR_Write(mOutFileDesc, buffer, len) == -1 )
|
||||
{
|
||||
/* Error */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
} while (len > 0 && err == NS_OK);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _NS_SOFTWAREUPDATESTREAM_H__
|
||||
#define _NS_SOFTWAREUPDATESTREAM_H__
|
||||
|
||||
#include "nsInstall.h"
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsIURL.h"
|
||||
#include "nsINetlibURL.h"
|
||||
#include "nsINetService.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIStreamListener.h"
|
||||
|
||||
#include "nsISoftwareUpdate.h"
|
||||
|
||||
static NS_DEFINE_IID(kInetServiceIID, NS_INETSERVICE_IID);
|
||||
static NS_DEFINE_IID(kInetServiceCID, NS_NETSERVICE_CID);
|
||||
static NS_DEFINE_IID(kInetLibURLIID, NS_INETLIBURL_IID);
|
||||
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
||||
|
||||
|
||||
extern "C" nsresult DownloadJar(nsInstallInfo *nextInstall);
|
||||
|
||||
|
||||
class nsSoftwareUpdateListener : public nsIStreamListener
|
||||
{
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsSoftwareUpdateListener(nsInstallInfo *nextInstall);
|
||||
|
||||
NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* info);
|
||||
NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 Progress, PRUint32 ProgressMax);
|
||||
NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg);
|
||||
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
|
||||
NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRUint32 length);
|
||||
NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg);
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
virtual ~nsSoftwareUpdateListener();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
nsISoftwareUpdate *mSoftwareUpdate;
|
||||
PRFileDesc *mOutFileDesc;
|
||||
nsInstallInfo *mInstallInfo;
|
||||
PRInt32 mResult;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -36,8 +36,8 @@
|
|||
#include "nsSoftwareUpdateIIDs.h"
|
||||
|
||||
static nsISoftwareUpdate *softwareUpdate= NULL;
|
||||
static NS_DEFINE_IID(kISoftwareUpdateIID, NS_ISOFTWAREUPDATE_IID);
|
||||
static NS_DEFINE_IID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID);
|
||||
static NS_DEFINE_IID(kFileLocatorIID, NS_IFILELOCATOR_IID);
|
||||
static NS_DEFINE_IID(kFileLocatorCID, NS_FILELOCATOR_CID);
|
||||
/*********************************************/
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче