mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 08:12:05 +00:00
Checking bug fixes for SmartUpdate. It is not part of the build system
This commit is contained in:
parent
1088a3e974
commit
b571f8fe11
@ -83,7 +83,6 @@ private:
|
||||
nsString* finalFile; /* final file destination */
|
||||
nsString* regPackageName; /* Name of the package we are installing */
|
||||
nsString* userPackageName; /* User-readable package name */
|
||||
nsTarget* target; /* security target */
|
||||
PRBool force; /* whether install is forced */
|
||||
PRBool bJavaDir; /* whether file is installed to a Java directory */
|
||||
PRBool replace; /* whether file exists */
|
||||
|
@ -89,8 +89,8 @@ typedef enum su_SecurityLevel {
|
||||
struct su_DirectoryTable
|
||||
{
|
||||
char * directoryName; /* The formal directory name */
|
||||
su_SecurityLevel securityLevel; /* Security level */
|
||||
su_DirSpecID folderEnum; /* Directory ID */
|
||||
XP_Bool bJavaDir; /* TRUE is a Java-capable directory */
|
||||
};
|
||||
|
||||
extern struct su_DirectoryTable DirectoryTable[];
|
||||
|
@ -25,7 +25,7 @@ MODULE = softupdate
|
||||
LIBRARY_NAME = softupdate
|
||||
|
||||
REQUIRES = softupdt js java net dbm nspr img util layer pref \
|
||||
jar security lay style libreg network progress base xpcom caps zlib
|
||||
jar security lay style libreg network progress base xpcom caps zlib plugin oji ojiimpl
|
||||
|
||||
INCLUDES += -I$(DEPTH)/base/src
|
||||
|
||||
|
@ -30,7 +30,7 @@ MODULE = softupdate
|
||||
LIBRARY_NAME = softupdate
|
||||
|
||||
REQUIRES = softupdt js java net dbm nspr img util layer pref \
|
||||
jar security lay style libreg network progress base xpcom caps zlib
|
||||
jar security lay style libreg network progress base xpcom caps zlib plugin oji ojiimpl
|
||||
|
||||
INCLUDES += -I$(topsrcdir)/base/src
|
||||
|
||||
|
@ -136,6 +136,9 @@ LINCS= $(LINCS) \
|
||||
-I$(PUBLIC)/rdf \
|
||||
-I$(PUBLIC)/network \
|
||||
-I$(PUBLIC)/zlib \
|
||||
-I$(PUBLIC)/plugin \
|
||||
-I$(PUBLIC)/oji \
|
||||
-I$(PUBLIC)/ojiimpl \
|
||||
$(NULL)
|
||||
!endif
|
||||
|
||||
|
@ -71,6 +71,12 @@ PR_BEGIN_EXTERN_C
|
||||
nsFolderSpec::nsFolderSpec(char* inFolderID , char* inVRPath, char* inPackageName)
|
||||
{
|
||||
urlPath = folderID = versionRegistryPath = userPackageName = NULL;
|
||||
|
||||
/* May be we should return an error message */
|
||||
if ((inFolderID == NULL) || (inVRPath == NULL) || (inPackageName == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
folderID = XP_STRDUP(inFolderID);
|
||||
versionRegistryPath = XP_STRDUP(inVRPath);
|
||||
userPackageName = XP_STRDUP(inPackageName);
|
||||
@ -91,9 +97,18 @@ nsFolderSpec::~nsFolderSpec(void)
|
||||
/*
|
||||
* GetDirectoryPath
|
||||
* returns full path to the directory in the standard URL form
|
||||
*
|
||||
* Caller shouldn't free the returned value. It returns it copy.
|
||||
*
|
||||
*/
|
||||
char* nsFolderSpec::GetDirectoryPath(char* *errorMsg)
|
||||
{
|
||||
if ((folderID == NULL) || (versionRegistryPath == NULL)) {
|
||||
*errorMsg = SU_GetErrorMsg3("Invalid arguments to the constructor",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (urlPath == NULL) {
|
||||
if (XP_STRCMP(folderID, "User Pick") == 0) {
|
||||
// Default package folder
|
||||
@ -143,15 +158,19 @@ char* nsFolderSpec::MakeFullPath(char* relativePath, char* *errorMsg)
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
/* The caller is not supposed to free the memory.
|
||||
* XXX: Should we give a copy of the string??
|
||||
/*
|
||||
* The caller is supposed to free the memory.
|
||||
*/
|
||||
char* nsFolderSpec::toString()
|
||||
{
|
||||
char *errorMsg = NULL;
|
||||
char* path = GetDirectoryPath(&errorMsg);
|
||||
if (errorMsg != NULL)
|
||||
if (errorMsg != NULL) {
|
||||
path = NULL;
|
||||
} else {
|
||||
PR_ASSERT(path != NULL);
|
||||
XP_STRDUP(path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
@ -305,16 +324,14 @@ PRBool nsFolderSpec::NativeIsJavaDir()
|
||||
/* Get the name of the package to prompt for */
|
||||
folderName = folderID;
|
||||
|
||||
#ifdef XXX
|
||||
PR_ASSERT( folderName );
|
||||
if ( folderName != NULL) {
|
||||
int i;
|
||||
for (i=0; DirectoryTable[i].directoryName[0] != 0; i++ ) {
|
||||
if ( strcmp(folderName, DirectoryTable[i].directoryName) == 0 )
|
||||
if ( XP_STRCMP(folderName, DirectoryTable[i].directoryName) == 0 )
|
||||
return DirectoryTable[i].bJavaDir;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
@ -59,6 +59,12 @@ nsInstallDelete::nsInstallDelete(nsSoftwareUpdate* inSoftUpdate,
|
||||
FILE_READ_ONLY = nsSoftUpdateError_FILE_READ_ONLY;
|
||||
FILE_IS_DIRECTORY = nsSoftUpdateError_FILE_IS_DIRECTORY;
|
||||
|
||||
if ((inFolder == NULL) || (inSoftUpdate == NULL)) {
|
||||
*errorMsg = SU_GetErrorMsg3("Invalid arguments to the constructor",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
return;
|
||||
}
|
||||
|
||||
finalFile = inFolder->MakeFullPath(inRelativeFileName, errorMsg);
|
||||
if (*errorMsg != NULL) {
|
||||
return;
|
||||
@ -78,6 +84,13 @@ nsInstallDelete::nsInstallDelete(nsSoftwareUpdate* inSoftUpdate,
|
||||
FILE_DOES_NOT_EXIST = nsSoftUpdateError_FILE_DOES_NOT_EXIST;
|
||||
FILE_READ_ONLY = nsSoftUpdateError_FILE_READ_ONLY;
|
||||
FILE_IS_DIRECTORY = nsSoftUpdateError_FILE_IS_DIRECTORY;
|
||||
|
||||
if ((inRegistryName == NULL) || (inSoftUpdate == NULL)) {
|
||||
*errorMsg = SU_GetErrorMsg3("Invalid arguments to the constructor",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
return;
|
||||
}
|
||||
|
||||
registryName = XP_STRDUP(inRegistryName);
|
||||
processInstallDelete(errorMsg);
|
||||
}
|
||||
@ -104,13 +117,15 @@ char* nsInstallDelete::Complete()
|
||||
int err = -1;
|
||||
nsTarget* execTarget = NULL;
|
||||
|
||||
if (softUpdate == NULL) {
|
||||
return SU_GetErrorMsg3("Invalid arguments to the constructor",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
}
|
||||
|
||||
nsPrivilegeManager* privMgr = nsPrivilegeManager::getPrivilegeManager();
|
||||
nsTarget* impersonation = nsTarget::findTarget(IMPERSONATOR);
|
||||
|
||||
if ((privMgr != NULL) && (impersonation != NULL)) {
|
||||
/* XXX: We should get the SystemPrincipal and enablePrivilege on that.
|
||||
* Or may be we should get rid of impersonation
|
||||
*/
|
||||
privMgr->enablePrivilege(impersonation, 1);
|
||||
execTarget = nsTarget::findTarget(INSTALL_PRIV);
|
||||
if (execTarget != NULL) {
|
||||
@ -139,7 +154,7 @@ char* nsInstallDelete::Complete()
|
||||
}
|
||||
if (msg != NULL) {
|
||||
errorMsg = SU_GetErrorMsg3(msg, err);
|
||||
PR_FREEIF(msg);
|
||||
XP_FREE(msg);
|
||||
}
|
||||
return errorMsg;
|
||||
}
|
||||
@ -169,9 +184,6 @@ void nsInstallDelete::processInstallDelete(char* *errorMsg)
|
||||
nsTarget* impersonation = nsTarget::findTarget(IMPERSONATOR);
|
||||
|
||||
if ((privMgr != NULL) && (impersonation != NULL)) {
|
||||
/* XXX: We should get the SystemPrincipal and enablePrivilege on that.
|
||||
* Or may be we should get rid of impersonation
|
||||
*/
|
||||
privMgr->enablePrivilege(impersonation, 1);
|
||||
target = nsTarget::findTarget(INSTALL_PRIV);
|
||||
if (target != NULL) {
|
||||
@ -190,7 +202,7 @@ void nsInstallDelete::processInstallDelete(char* *errorMsg)
|
||||
char *msg = NULL;
|
||||
msg = SU_GetString1(SU_ERROR_NOT_IN_REGISTRY, registryName);
|
||||
*errorMsg = SU_GetErrorMsg3(msg, nsSoftUpdateError_NO_SUCH_COMPONENT);
|
||||
PR_FREEIF(msg);
|
||||
XP_FREEIF(msg);
|
||||
return;
|
||||
} else {
|
||||
finalFile = nsVersionRegistry::componentPath(registryName);
|
||||
@ -214,7 +226,7 @@ void nsInstallDelete::processInstallDelete(char* *errorMsg)
|
||||
}
|
||||
if (msg != NULL) {
|
||||
*errorMsg = SU_GetErrorMsg3(msg, err);
|
||||
PR_FREEIF(msg);
|
||||
XP_FREE(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -229,7 +241,7 @@ int nsInstallDelete::NativeComplete()
|
||||
if (fileName != NULL)
|
||||
{
|
||||
char * temp = XP_STRDUP(&fileName[7]);
|
||||
XP_FREEIF(fileName);
|
||||
XP_FREE(fileName);
|
||||
fileName = temp;
|
||||
if (fileName)
|
||||
{
|
||||
@ -284,7 +296,7 @@ int nsInstallDelete::NativeCheckFileStatus()
|
||||
if (fileName != NULL)
|
||||
{
|
||||
char * temp = XP_STRDUP(&fileName[7]);
|
||||
XP_FREEIF(fileName);
|
||||
XP_FREE(fileName);
|
||||
fileName = temp;
|
||||
|
||||
if (fileName)
|
||||
|
@ -51,6 +51,13 @@ nsInstallExecute::nsInstallExecute(nsSoftwareUpdate* inSoftUpdate,
|
||||
args = NULL;
|
||||
cmdline = NULL;
|
||||
|
||||
if ((inArgs == NULL) || (inJarLocation == NULL) ||
|
||||
(inSoftUpdate == NULL)) {
|
||||
*errorMsg = SU_GetErrorMsg3("Invalid arguments to the constructor",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Request impersonation privileges */
|
||||
nsTarget* target = NULL;
|
||||
|
||||
@ -59,9 +66,6 @@ nsInstallExecute::nsInstallExecute(nsSoftwareUpdate* inSoftUpdate,
|
||||
nsTarget* impersonation = nsTarget::findTarget(IMPERSONATOR);
|
||||
|
||||
if ((privMgr != NULL) && (impersonation != NULL)) {
|
||||
/* XXX: We should get the SystemPrincipal and enablePrivilege on that.
|
||||
* Or may be we should get rid of impersonation
|
||||
*/
|
||||
privMgr->enablePrivilege(impersonation, 1);
|
||||
|
||||
/* check the security permissions */
|
||||
@ -95,13 +99,14 @@ char* nsInstallExecute::Prepare(void)
|
||||
char *errorMsg = NULL;
|
||||
nsTarget* execTarget = NULL;
|
||||
|
||||
if (softUpdate == NULL) {
|
||||
return SU_GetErrorMsg3("Invalid arguments to the constructor",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
}
|
||||
nsPrivilegeManager* privMgr = nsPrivilegeManager::getPrivilegeManager();
|
||||
nsTarget* impersonation = nsTarget::findTarget(IMPERSONATOR);
|
||||
|
||||
if ((privMgr != NULL) && (impersonation != NULL)) {
|
||||
/* XXX: We should get the SystemPrincipal and enablePrivilege on that.
|
||||
* Or may be we should get rid of impersonation
|
||||
*/
|
||||
privMgr->enablePrivilege(impersonation, 1);
|
||||
execTarget = nsTarget::findTarget(INSTALL_PRIV);
|
||||
if (execTarget != NULL) {
|
||||
@ -112,9 +117,15 @@ char* nsInstallExecute::Prepare(void)
|
||||
}
|
||||
|
||||
tempFile = softUpdate->ExtractJARFile( jarLocation, NULL, &errorMsg );
|
||||
if (errorMsg != NULL)
|
||||
if (errorMsg != NULL) {
|
||||
PR_ASSERT(tempFile == NULL);
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
if (tempFile == NULL) {
|
||||
return SU_GetErrorMsg3("Extraction of JAR file failed", nsSoftUpdateError_ACCESS_DENIED);
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
cmdline = XP_STRDUP(tempFile);
|
||||
#else
|
||||
@ -123,6 +134,7 @@ char* nsInstallExecute::Prepare(void)
|
||||
else
|
||||
cmdline = XP_Cat(tempFile, " ", args);
|
||||
#endif /* XP_MAC */
|
||||
XP_FREE(tempFile);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -135,13 +147,14 @@ char* nsInstallExecute::Complete(void)
|
||||
char* errorMsg = NULL;
|
||||
nsTarget* execTarget = NULL;
|
||||
|
||||
if (softUpdate == NULL) {
|
||||
return SU_GetErrorMsg3("Invalid arguments to the constructor",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
}
|
||||
nsPrivilegeManager* privMgr = nsPrivilegeManager::getPrivilegeManager();
|
||||
nsTarget* impersonation = nsTarget::findTarget(IMPERSONATOR);
|
||||
|
||||
if ((privMgr != NULL) && (impersonation != NULL)) {
|
||||
/* XXX: We should get the SystemPrincipal and enablePrivilege on that.
|
||||
* Or may be we should get rid of impersonation
|
||||
*/
|
||||
privMgr->enablePrivilege(impersonation, 1);
|
||||
execTarget = nsTarget::findTarget(INSTALL_PRIV);
|
||||
if (execTarget != NULL) {
|
||||
@ -174,7 +187,7 @@ char* nsInstallExecute::toString()
|
||||
} else {
|
||||
ret_val = SU_GetString1(SU_DETAILS_EXECUTE_PROGRESS2, msg);
|
||||
}
|
||||
XP_FREEIF(msg);
|
||||
XP_FREE(msg);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
@ -197,6 +210,9 @@ void nsInstallExecute::NativeAbort(void)
|
||||
char * currentName;
|
||||
int result;
|
||||
|
||||
if (tempFile == NULL)
|
||||
return;
|
||||
|
||||
/* Get the names */
|
||||
currentName = (char*)tempFile;
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "nsPrivilegeManager.h"
|
||||
#include "nsTarget.h"
|
||||
#include "jvmmgr.h"
|
||||
|
||||
extern int SU_ERROR_INSTALL_FILE_UNEXPECTED;
|
||||
extern int SU_DETAILS_REPLACE_FILE_MSG_ID;
|
||||
@ -40,6 +41,21 @@ XP_Bool utilityScheduled = FALSE;
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
static PRBool endsWith(nsString* str, char* string_to_find);
|
||||
|
||||
static PRBool endsWith(nsString* str, char* string_to_find)
|
||||
{
|
||||
PRBool found = PR_FALSE;
|
||||
if (str) {
|
||||
int len = strlen(".zip");
|
||||
int size = str->Length();
|
||||
int offset = str->RFind(string_to_find, PR_FALSE);
|
||||
if (offset == (size - len))
|
||||
found = PR_TRUE;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
/* Public Methods */
|
||||
|
||||
/* Constructor
|
||||
@ -65,20 +81,27 @@ nsInstallFile::nsInstallFile(nsSoftwareUpdate* inSoftUpdate,
|
||||
finalFile = NULL;
|
||||
regPackageName = NULL;
|
||||
userPackageName = NULL;
|
||||
target = NULL;
|
||||
force = PR_FALSE;
|
||||
bJavaDir = PR_FALSE;
|
||||
replace = PR_FALSE;
|
||||
bChild = PR_FALSE;
|
||||
bUpgrade = PR_FALSE;
|
||||
|
||||
if ((inVRName == NULL) || (inJarLocation == NULL) ||
|
||||
(folderSpec == NULL) || (inSoftUpdate == NULL) ||
|
||||
(inVInfo == NULL)) {
|
||||
*errorMsg = SU_GetErrorMsg3("Invalid arguments to the constructor",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
return;
|
||||
}
|
||||
vrName = new nsString(inVRName);
|
||||
versionInfo = inVInfo;
|
||||
versionInfo = inVInfo; /* XXX: Who owns and who free's this object. Is it nsSoftwareUpdate?? */
|
||||
jarLocation = new nsString(inJarLocation);
|
||||
force = forceInstall;
|
||||
char* temp = folderSpec->MakeFullPath( inPartialPath, errorMsg );
|
||||
if (temp != NULL) {
|
||||
finalFile = new nsString(temp);
|
||||
XP_FREE(temp);
|
||||
}
|
||||
bJavaDir = folderSpec->IsJavaCapable();
|
||||
|
||||
@ -87,15 +110,12 @@ nsInstallFile::nsInstallFile(nsSoftwareUpdate* inSoftUpdate,
|
||||
nsPrivilegeManager* privMgr = nsPrivilegeManager::getPrivilegeManager();
|
||||
|
||||
if ((privMgr != NULL) && (impersonation != NULL)) {
|
||||
/* XXX: We should get the SystemPrincipal and enablePrivilege on that.
|
||||
* Or may be we should get rid of impersonation
|
||||
*/
|
||||
privMgr->enablePrivilege(impersonation, 1);
|
||||
|
||||
/* check the security permissions */
|
||||
target = nsTarget::findTarget(INSTALL_PRIV);
|
||||
if (target != NULL) {
|
||||
if (!privMgr->enablePrivilege(target, softUpdate->GetPrincipal(), 1)) {
|
||||
nsTarget* install_target = nsTarget::findTarget(INSTALL_PRIV);
|
||||
if (install_target != NULL) {
|
||||
if (!privMgr->enablePrivilege(install_target, softUpdate->GetPrincipal(), 1)) {
|
||||
*errorMsg = SU_GetErrorMsg3("Permssion was denied", nsSoftUpdateError_ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
@ -132,14 +152,14 @@ nsInstallFile::~nsInstallFile()
|
||||
{
|
||||
delete vrName;
|
||||
delete jarLocation;
|
||||
if (finalFile)
|
||||
delete finalFile;
|
||||
if (userPackageName)
|
||||
delete userPackageName;
|
||||
if (regPackageName)
|
||||
delete regPackageName;
|
||||
if (tempFile)
|
||||
delete tempFile;
|
||||
if (finalFile)
|
||||
delete finalFile;
|
||||
if (regPackageName)
|
||||
delete regPackageName;
|
||||
if (userPackageName)
|
||||
delete userPackageName;
|
||||
}
|
||||
|
||||
/* Prepare
|
||||
@ -149,6 +169,22 @@ char* nsInstallFile::Prepare()
|
||||
{
|
||||
char *errorMsg = NULL;
|
||||
|
||||
if (softUpdate == NULL) {
|
||||
errorMsg = SU_GetErrorMsg3("nsSoftwareUpdate object is null",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
return errorMsg;
|
||||
}
|
||||
if (jarLocation == NULL) {
|
||||
errorMsg = SU_GetErrorMsg3("JAR file is null",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
return errorMsg;
|
||||
}
|
||||
if (finalFile == NULL) {
|
||||
errorMsg = SU_GetErrorMsg3("folderSpec's full path (finalFile) was null",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
// XXX: Make the following security code into a function.
|
||||
|
||||
/* Request impersonation privileges */
|
||||
@ -156,9 +192,6 @@ char* nsInstallFile::Prepare()
|
||||
nsPrivilegeManager* privMgr = nsPrivilegeManager::getPrivilegeManager();
|
||||
|
||||
if ((privMgr != NULL) && (impersonation != NULL)) {
|
||||
/* XXX: We should get the SystemPrincipal and enablePrivilege on that.
|
||||
* Or may be we should get rid of impersonation
|
||||
*/
|
||||
PRBool allowed = privMgr->enablePrivilege(impersonation, 1);
|
||||
if (allowed == PR_FALSE) {
|
||||
errorMsg = SU_GetErrorMsg3("Permssion was denied", nsSoftUpdateError_ACCESS_DENIED);
|
||||
@ -166,8 +199,9 @@ char* nsInstallFile::Prepare()
|
||||
}
|
||||
|
||||
/* check the security permissions */
|
||||
if (target != NULL) {
|
||||
PRBool allowed = privMgr->enablePrivilege(target, softUpdate->GetPrincipal(), 1);
|
||||
nsTarget* install_target = nsTarget::findTarget(INSTALL_PRIV);
|
||||
if (install_target != NULL) {
|
||||
PRBool allowed = privMgr->enablePrivilege(install_target, softUpdate->GetPrincipal(), 1);
|
||||
if (allowed == PR_FALSE) {
|
||||
errorMsg = SU_GetErrorMsg3("Permssion was denied", nsSoftUpdateError_ACCESS_DENIED);
|
||||
return errorMsg;
|
||||
@ -181,6 +215,7 @@ char* nsInstallFile::Prepare()
|
||||
delete jarLocationCharPtr;
|
||||
delete finalFileCharPtr;
|
||||
if (errorMsg != NULL) {
|
||||
PR_ASSERT(temp == NULL);
|
||||
return errorMsg;
|
||||
}
|
||||
if (temp != NULL) {
|
||||
@ -201,48 +236,56 @@ char* nsInstallFile::Complete()
|
||||
int refCount;
|
||||
int rc;
|
||||
|
||||
if (softUpdate == NULL) {
|
||||
return SU_GetErrorMsg3("nsSoftwareUpdate object is null",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
}
|
||||
if (vrName == NULL) {
|
||||
return SU_GetErrorMsg3("version registry name is null",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
}
|
||||
if (finalFile == NULL) {
|
||||
return SU_GetErrorMsg3("folderSpec's full path (finalFile) is null",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
}
|
||||
|
||||
/* Check the security for our target */
|
||||
// XXX: Make the following security code into a function.
|
||||
|
||||
/* Request impersonation privileges */
|
||||
nsTarget* impersonation = nsTarget::findTarget(IMPERSONATOR);
|
||||
nsPrivilegeManager* privMgr = nsPrivilegeManager::getPrivilegeManager();
|
||||
nsTarget* install_target = NULL;
|
||||
|
||||
if ((privMgr != NULL) && (impersonation != NULL)) {
|
||||
/* XXX: We should get the SystemPrincipal and enablePrivilege on that.
|
||||
* Or may be we should get rid of impersonation
|
||||
*/
|
||||
privMgr->enablePrivilege(impersonation, 1);
|
||||
|
||||
/* check the security permissions */
|
||||
if (target != NULL) {
|
||||
if (!privMgr->enablePrivilege(target, softUpdate->GetPrincipal(), 1)) {
|
||||
return SU_GetErrorMsg3("Permssion was denied", nsSoftUpdateError_ACCESS_DENIED);
|
||||
install_target = nsTarget::findTarget(INSTALL_PRIV);
|
||||
if (install_target != NULL) {
|
||||
if (!privMgr->enablePrivilege(install_target,
|
||||
softUpdate->GetPrincipal(), 1)) {
|
||||
return SU_GetErrorMsg3("Permssion was denied",
|
||||
nsSoftUpdateError_ACCESS_DENIED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = NativeComplete();
|
||||
|
||||
if ((privMgr != NULL) && (target != NULL)) {
|
||||
privMgr->revertPrivilege(target, 1);
|
||||
if ((privMgr != NULL) && (install_target != NULL)) {
|
||||
privMgr->revertPrivilege(install_target, 1);
|
||||
}
|
||||
|
||||
|
||||
char *vr_name = vrName->ToNewCString();
|
||||
char *final_file = finalFile->ToNewCString();
|
||||
|
||||
// Add java archives to the classpath. Don't add if we're
|
||||
// replacing an existing file -- it'll already be there.
|
||||
|
||||
if ( bJavaDir && !replace ) {
|
||||
PRBool found_zip = PR_FALSE;
|
||||
PRBool found_jar = PR_FALSE;
|
||||
int len = strlen(".zip");
|
||||
int size = finalFile->Length();
|
||||
int offset = finalFile->RFind(".zip", PR_FALSE);
|
||||
if (offset == (size - len))
|
||||
found_zip = PR_TRUE;
|
||||
offset = finalFile->RFind(".jar", PR_FALSE);
|
||||
if (offset == (size - len))
|
||||
found_jar = PR_TRUE;
|
||||
PRBool found_zip = endsWith(finalFile, ".zip");
|
||||
PRBool found_jar = endsWith(finalFile, ".jar");;
|
||||
if (found_zip || found_jar) {
|
||||
AddToClasspath( finalFile );
|
||||
}
|
||||
@ -256,41 +299,54 @@ char* nsInstallFile::Complete()
|
||||
// important enough to abort an otherwise OK install.
|
||||
if (!bChild) {
|
||||
int found;
|
||||
/* XXX: Fix it. memeory leak */
|
||||
found = nsVersionRegistry::uninstallFileExists(regPackageName->ToNewCString(), vrName->ToNewCString());
|
||||
if (regPackageName) {
|
||||
char *reg_package_name = regPackageName->ToNewCString();
|
||||
found = nsVersionRegistry::uninstallFileExists(reg_package_name, vr_name);
|
||||
delete reg_package_name;
|
||||
} else {
|
||||
found = nsVersionRegistry::uninstallFileExists("", vr_name);
|
||||
}
|
||||
if (found != REGERR_OK)
|
||||
bUpgrade = PR_FALSE;
|
||||
else
|
||||
bUpgrade = PR_TRUE;
|
||||
} else if (REGERR_OK == nsVersionRegistry::inRegistry(vrName->ToNewCString())) {
|
||||
} else if (REGERR_OK == nsVersionRegistry::inRegistry(vr_name)) {
|
||||
bUpgrade = PR_TRUE;
|
||||
} else {
|
||||
bUpgrade = PR_FALSE;
|
||||
}
|
||||
|
||||
refCount = nsVersionRegistry::getRefCount(vrName->ToNewCString());
|
||||
refCount = nsVersionRegistry::getRefCount(vr_name);
|
||||
if (!bUpgrade) {
|
||||
if (refCount != 0) {
|
||||
rc = 1 + refCount;
|
||||
nsVersionRegistry::installComponent(vrName->ToNewCString(), finalFile->ToNewCString(), versionInfo, rc );
|
||||
nsVersionRegistry::installComponent(vr_name, final_file, versionInfo, rc );
|
||||
} else {
|
||||
if (replace)
|
||||
nsVersionRegistry::installComponent(vrName->ToNewCString(), finalFile->ToNewCString(), versionInfo, 2);
|
||||
nsVersionRegistry::installComponent(vr_name, final_file, versionInfo, 2);
|
||||
else
|
||||
nsVersionRegistry::installComponent(vrName->ToNewCString(), finalFile->ToNewCString(), versionInfo, 1);
|
||||
nsVersionRegistry::installComponent(vr_name, final_file, versionInfo, 1);
|
||||
}
|
||||
} else if (bUpgrade) {
|
||||
if (refCount == 0) {
|
||||
nsVersionRegistry::installComponent(vrName->ToNewCString(), finalFile->ToNewCString(), versionInfo, 1);
|
||||
nsVersionRegistry::installComponent(vr_name, final_file, versionInfo, 1);
|
||||
} else {
|
||||
nsVersionRegistry::installComponent(vrName->ToNewCString(), finalFile->ToNewCString(), versionInfo );
|
||||
nsVersionRegistry::installComponent(vr_name, final_file, versionInfo );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !bChild && !bUpgrade ) {
|
||||
nsVersionRegistry::uninstallAddFile(regPackageName->ToNewCString(), vrName->ToNewCString());
|
||||
if (regPackageName) {
|
||||
char *reg_package_name = regPackageName->ToNewCString();
|
||||
nsVersionRegistry::uninstallAddFile(reg_package_name, vr_name);
|
||||
delete reg_package_name;
|
||||
} else {
|
||||
nsVersionRegistry::uninstallAddFile("", vr_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
delete vr_name;
|
||||
delete final_file;
|
||||
|
||||
if ( err != 0 ) {
|
||||
return SU_GetErrorMsg2(SU_ERROR_INSTALL_FILE_UNEXPECTED, finalFile, err);
|
||||
@ -322,6 +378,8 @@ void nsInstallFile::NativeAbort()
|
||||
int result;
|
||||
|
||||
/* Get the names */
|
||||
if (tempFile == NULL)
|
||||
return;
|
||||
currentName = tempFile->ToNewCString();
|
||||
|
||||
result = XP_FileRemove(currentName, xpURL);
|
||||
@ -335,14 +393,18 @@ void nsInstallFile::NativeAbort()
|
||||
*/
|
||||
int nsInstallFile::NativeComplete()
|
||||
{
|
||||
char* currentName;
|
||||
char* currentName = NULL;
|
||||
char* finalName = NULL;
|
||||
char* finalNamePlatform;
|
||||
int result = 0;
|
||||
|
||||
if (tempFile == NULL) {
|
||||
return -1;
|
||||
}
|
||||
/* Get the names */
|
||||
currentName = tempFile->ToNewCString();
|
||||
|
||||
|
||||
PR_ASSERT(finalFile != NULL);
|
||||
finalNamePlatform = finalFile->ToNewCString();
|
||||
finalName = XP_PlatformFileToURL(finalNamePlatform);
|
||||
|
||||
@ -431,6 +493,7 @@ PRBool nsInstallFile::NativeDoesFileExist()
|
||||
XP_StatStruct statinfo;
|
||||
XP_Bool exists = FALSE;
|
||||
|
||||
PR_ASSERT(finalFile != NULL);
|
||||
fileNamePlatform = finalFile->ToNewCString();
|
||||
fileName = XP_PlatformFileToURL(fileNamePlatform);
|
||||
if (fileName != NULL) {
|
||||
@ -454,9 +517,9 @@ PRBool nsInstallFile::NativeDoesFileExist()
|
||||
void nsInstallFile::AddToClasspath(nsString* file)
|
||||
{
|
||||
if ( file != NULL ) {
|
||||
/* XXX: What should we do?
|
||||
LJ_AddToClassPath((PRUnichar*)file);
|
||||
*/
|
||||
char *final_file = file->ToNewCString();
|
||||
JVM_AddToClassPath(final_file);
|
||||
delete final_file;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,11 +72,19 @@ nsInstallPatch::nsInstallPatch(nsSoftwareUpdate* inSoftUpdate,
|
||||
return;
|
||||
targetfile = nsVersionRegistry::componentPath( vrName );
|
||||
if ( targetfile == NULL ) {
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_NO_SUCH_COMPONENT, nsSoftUpdateError_NO_SUCH_COMPONENT);
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_NO_SUCH_COMPONENT,
|
||||
nsSoftUpdateError_NO_SUCH_COMPONENT);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((inVRName == NULL) || (inJarLocation == NULL)) {
|
||||
*errorMsg = SU_GetErrorMsg3("Invalid arguments to the constructor",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
return;
|
||||
}
|
||||
|
||||
vrName = XP_STRDUP(inVRName);
|
||||
versionInfo = inVInfo;
|
||||
versionInfo = inVInfo; /* Who owns this object? May be we should make a copy of it */
|
||||
jarLocation = XP_STRDUP(inJarLocation);
|
||||
}
|
||||
|
||||
@ -95,9 +103,17 @@ nsInstallPatch::nsInstallPatch(nsSoftwareUpdate* inSoftUpdate,
|
||||
patchURL = NULL;
|
||||
targetfile = NULL;
|
||||
patchedfile = NULL;
|
||||
|
||||
if ((inVRName == NULL) || (inJarLocation == NULL) || (folderSpec == NULL)) {
|
||||
*errorMsg = SU_GetErrorMsg3("Invalid arguments to the constructor",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
return;
|
||||
}
|
||||
|
||||
*errorMsg = checkPrivileges();
|
||||
if (*errorMsg != NULL)
|
||||
return;
|
||||
|
||||
targetfile = folderSpec->MakeFullPath( inPartialPath, errorMsg );
|
||||
if ( errorMsg != NULL ) {
|
||||
return;
|
||||
@ -113,8 +129,8 @@ nsInstallPatch::~nsInstallPatch()
|
||||
XP_FREEIF(vrName);
|
||||
XP_FREEIF(jarLocation);
|
||||
XP_FREEIF(patchURL);
|
||||
XP_FREEIF(patchedfile);
|
||||
XP_FREEIF(targetfile);
|
||||
XP_FREEIF(patchedfile);
|
||||
/* Raman: Fix it. How do we delete versionInfo. If we have copy on our side it is easy. */
|
||||
// ?? delete versionInfo;
|
||||
}
|
||||
@ -124,9 +140,13 @@ char* nsInstallPatch::Prepare(void)
|
||||
char* errorMsg = NULL;
|
||||
char* srcname;
|
||||
PRBool deleteOldSrc;
|
||||
|
||||
nsTarget* priv = NULL;
|
||||
|
||||
if ((softUpdate == NULL) || (jarLocation == NULL) || (targetfile == NULL)) {
|
||||
return SU_GetErrorMsg3("Invalid arguments to the constructor",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
}
|
||||
|
||||
nsPrivilegeManager* privMgr = nsPrivilegeManager::getPrivilegeManager();
|
||||
nsTarget* impersonation = nsTarget::findTarget(IMPERSONATOR);
|
||||
|
||||
@ -162,7 +182,7 @@ char* nsInstallPatch::Prepare(void)
|
||||
softUpdate->patchList->Put( &ikey, patchedfile );
|
||||
} else {
|
||||
char *msg = XP_Cat(targetfile, " not patched");
|
||||
errorMsg = SU_GetErrorMsg3(msg, nsSoftUpdateError_UNEXPECTED_ERROR);
|
||||
errorMsg = SU_GetErrorMsg3(msg, nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
}
|
||||
|
||||
if ( deleteOldSrc ) {
|
||||
@ -181,12 +201,18 @@ char* nsInstallPatch::Complete(void)
|
||||
int err;
|
||||
char* errorMsg = NULL;
|
||||
|
||||
if ((softUpdate == NULL) || (targetfile == NULL) ||
|
||||
(patchedfile == NULL) || (vrName == NULL)) {
|
||||
return SU_GetErrorMsg3("Invalid arguments to the complete method",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
}
|
||||
|
||||
if ((errorMsg = checkPrivileges()) != NULL)
|
||||
return errorMsg;
|
||||
|
||||
IntegerKey ikey(PL_HashString(targetfile));
|
||||
char* tmp = (char *)softUpdate->patchList->Get( &ikey );
|
||||
if ( XP_STRCMP(tmp, patchedfile ) == 0 ) {
|
||||
if (tmp && ( XP_STRCMP(tmp, patchedfile ) == 0 )) {
|
||||
|
||||
// the patch has not been superceded--do final replacement
|
||||
|
||||
@ -217,10 +243,15 @@ void nsInstallPatch::Abort(void)
|
||||
// clean up patched file unless it has been already
|
||||
// deleted by a superceding patch
|
||||
|
||||
if ((softUpdate == NULL) || (targetfile == NULL) ||
|
||||
(patchedfile == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
IntegerKey ikey(PL_HashString(targetfile));
|
||||
|
||||
char* tmp = (char *)softUpdate->patchList->Get( &ikey );
|
||||
if ( XP_STRCMP(tmp, patchedfile ) == 0 ) {
|
||||
if (tmp && ( XP_STRCMP(tmp, patchedfile ) == 0 )) {
|
||||
NativeDeleteFile( patchedfile );
|
||||
}
|
||||
}
|
||||
@ -272,7 +303,8 @@ char* nsInstallPatch::NativePatch( char* srcfile, char* diffURL, char* *errorMsg
|
||||
|
||||
if ( srcfile != NULL && diffURL != NULL ) {
|
||||
fullSrcURL = XP_PlatformFileToURL( srcfile );
|
||||
if ( fullSrcURL != NULL ) {
|
||||
/* skip "file://" part */
|
||||
if ( ( fullSrcURL != NULL ) && (XP_STRLEN(fullSrcURL) > 7)) {
|
||||
char ch;
|
||||
char *p;
|
||||
|
||||
@ -294,7 +326,7 @@ char* nsInstallPatch::NativePatch( char* srcfile, char* diffURL, char* *errorMsg
|
||||
err = SU_PatchFile( srcURL, xpURL, diffURL, xpURL, newfileURL, xpURL );
|
||||
} else {
|
||||
/* String conversions failed -- probably out of memory */
|
||||
err = nsSoftUpdateError_UNEXPECTED_ERROR;
|
||||
err = nsSoftUpdateError_INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,43 +29,53 @@ extern "C" {
|
||||
|
||||
char * SU_GetErrorMsg1(int id, char* arg1)
|
||||
{
|
||||
char* errorMsg=NULL;
|
||||
char* errorMsg;
|
||||
char* tag = XP_GetString(id);
|
||||
PR_ASSERT(tag != NULL);
|
||||
errorMsg = PR_sprintf_append(errorMsg, "%s %s", tag, arg1);
|
||||
errorMsg = XP_Cat(tag, arg1);
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
char * SU_GetErrorMsg2(int id, nsString* arg1, int reason)
|
||||
{
|
||||
char* errorMsg=NULL;
|
||||
char* errorMsg;
|
||||
char* ptr;
|
||||
char* tag = XP_GetString(id);
|
||||
PR_ASSERT(tag != NULL);
|
||||
char* argMsg = arg1->ToNewCString();
|
||||
errorMsg = PR_sprintf_append(errorMsg, "%s %s %d", tag, argMsg, reason);
|
||||
char* argMsg = "";
|
||||
if (argMsg)
|
||||
argMsg = arg1->ToNewCString();
|
||||
ptr = PR_sprintf_append(errorMsg, "%s %s %d", tag, argMsg, reason);
|
||||
delete argMsg;
|
||||
errorMsg = XP_STRDUP(ptr);
|
||||
delete ptr;
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
char * SU_GetErrorMsg3(char *str, int err)
|
||||
{
|
||||
char* errorMsg=NULL;
|
||||
char* errorMsg;
|
||||
char* ptr;
|
||||
PR_ASSERT(str != NULL);
|
||||
errorMsg = PR_sprintf_append(errorMsg, "%s %d", str, err);
|
||||
ptr = PR_sprintf_append(errorMsg, "%s %d", str, err);
|
||||
errorMsg = XP_STRDUP(ptr);
|
||||
delete ptr;
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
char * SU_GetErrorMsg4(int id, int reason)
|
||||
{
|
||||
char* msg=NULL;
|
||||
char* msg;
|
||||
char* ptr;
|
||||
char* tag = XP_GetString(id);
|
||||
PR_ASSERT(tag != NULL);
|
||||
msg = PR_sprintf_append(msg, "%s %d", tag, reason);
|
||||
ptr = PR_sprintf_append(msg, "%s %d", tag, reason);
|
||||
msg = XP_STRDUP(ptr);
|
||||
delete ptr;
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char * SU_GetString(int id)
|
||||
{
|
||||
char *str = XP_GetString(id);
|
||||
@ -78,7 +88,11 @@ char * SU_GetString1(int id, char* arg1)
|
||||
char* msg=NULL;
|
||||
char* tag = XP_GetString(id);
|
||||
PR_ASSERT(tag != NULL);
|
||||
msg = PR_sprintf_append(msg, "%s %s", tag, arg1);
|
||||
if (arg1) {
|
||||
msg = XP_Cat(msg, tag, arg1);
|
||||
} else {
|
||||
msg = XP_Cat(msg, tag);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
@ -87,8 +101,10 @@ char * SU_GetString2(int id, nsString* arg1)
|
||||
char* msg=NULL;
|
||||
char* tag = XP_GetString(id);
|
||||
PR_ASSERT(tag != NULL);
|
||||
char* argMsg = arg1->ToNewCString();
|
||||
msg = PR_sprintf_append(msg, "%s %s", tag, argMsg);
|
||||
char* argMsg = "";
|
||||
if (arg1)
|
||||
argMsg = arg1->ToNewCString();
|
||||
msg = XP_Cat(msg, tag, argMsg);
|
||||
delete argMsg;
|
||||
return msg;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "nsInstallDelete.h"
|
||||
#include "nsInstallExecute.h"
|
||||
#include "nsInstallPatch.h"
|
||||
#include "nsUninstallObject.h"
|
||||
#include "nsVersionRegistry.h"
|
||||
#include "nsSUError.h"
|
||||
#include "nsWinProfile.h"
|
||||
@ -85,7 +86,8 @@ PR_BEGIN_EXTERN_C
|
||||
static PRBool su_PathEndsWithSeparator(char* path, char* sep);
|
||||
|
||||
#ifdef XP_PC
|
||||
extern char * WH_TempFileName(int type, const char * prefix, const char * extension);
|
||||
extern char * WH_TempFileName(int type, const char * prefix,
|
||||
const char * extension);
|
||||
#endif
|
||||
|
||||
extern uint32 FE_DiskSpaceAvailable (MWContext *context, const char *lpszPath );
|
||||
@ -94,8 +96,10 @@ extern uint32 FE_DiskSpaceAvailable (MWContext *context, const char *lpszPath );
|
||||
/* Public Methods */
|
||||
|
||||
/**
|
||||
* @param env JavaScript environment (this inside the installer). Contains installer directives
|
||||
* @param inUserPackageName Name of tha package installed. This name is displayed to the user
|
||||
* @param env JavaScript environment (this inside the installer).
|
||||
* Contains installer directives
|
||||
* @param inUserPackageName Name of tha package installed.
|
||||
* This name is displayed to the user
|
||||
*/
|
||||
nsSoftwareUpdate::nsSoftwareUpdate(void* env, char* inUserPackageName)
|
||||
{
|
||||
@ -108,6 +112,7 @@ nsSoftwareUpdate::nsSoftwareUpdate(void* env, char* inUserPackageName)
|
||||
progwin = NULL;
|
||||
patchList = new nsHashtable();
|
||||
zigPtr = NULL;
|
||||
versionInfo = NULL;
|
||||
userChoice = -1;
|
||||
lastError = 0;
|
||||
silent = PR_FALSE;
|
||||
@ -135,19 +140,29 @@ nsSoftwareUpdate::nsSoftwareUpdate(void* env, char* inUserPackageName)
|
||||
|
||||
nsSoftwareUpdate::~nsSoftwareUpdate()
|
||||
{
|
||||
if (patchList)
|
||||
delete patchList;
|
||||
if (packageFolder)
|
||||
delete packageFolder;
|
||||
if (versionInfo)
|
||||
delete versionInfo;
|
||||
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
/* Gives its internal copy. Don't free the returned value */
|
||||
nsPrincipal* nsSoftwareUpdate::GetPrincipal()
|
||||
{
|
||||
return installPrincipal;
|
||||
}
|
||||
|
||||
/* Gives its internal copy. Don't free the returned value */
|
||||
char* nsSoftwareUpdate::GetUserPackageName()
|
||||
{
|
||||
return userPackageName;
|
||||
}
|
||||
|
||||
/* Gives its internal copy. Don't free the returned value */
|
||||
char* nsSoftwareUpdate::GetRegPackageName()
|
||||
{
|
||||
return packageName;
|
||||
@ -200,8 +215,10 @@ nsFolderSpec* nsSoftwareUpdate::GetFolder(char* folderID, char* *errorMsg)
|
||||
if (XP_STRCMP(folderID, "User Pick") == 0) {
|
||||
// Force the prompt
|
||||
char * ignore = spec->GetDirectoryPath(errorMsg);
|
||||
if (*errorMsg != NULL)
|
||||
if (*errorMsg != NULL) {
|
||||
delete spec;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return spec;
|
||||
@ -214,7 +231,6 @@ nsFolderSpec* nsSoftwareUpdate::GetFolder(char* folderID, char* *errorMsg)
|
||||
*/
|
||||
nsFolderSpec* nsSoftwareUpdate::GetComponentFolder(char* component)
|
||||
{
|
||||
char* allocatedStr=NULL;
|
||||
char* dir;
|
||||
nsFolderSpec* spec = NULL;
|
||||
|
||||
@ -227,9 +243,9 @@ nsFolderSpec* nsSoftwareUpdate::GetComponentFolder(char* component)
|
||||
|
||||
nsString dirStr(dir);
|
||||
if ((i = dirStr.RFind(filesep)) > 0) {
|
||||
allocatedStr = new char[i];
|
||||
allocatedStr = dirStr.ToCString(allocatedStr, i);
|
||||
dir = allocatedStr;
|
||||
XP_FREE(dir);
|
||||
dir = (char*)XP_ALLOC(i);
|
||||
dir = dirStr.ToCString(dir, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -237,15 +253,19 @@ nsFolderSpec* nsSoftwareUpdate::GetComponentFolder(char* component)
|
||||
if ( dir != NULL ) {
|
||||
/* We have a directory */
|
||||
spec = new nsFolderSpec("Installed", dir, userPackageName);
|
||||
XP_FREE(dir);
|
||||
}
|
||||
if (allocatedStr != NULL)
|
||||
delete allocatedStr;
|
||||
return spec;
|
||||
}
|
||||
|
||||
nsFolderSpec* nsSoftwareUpdate::GetComponentFolder(char* component, char* subdir, char* *errorMsg)
|
||||
nsFolderSpec* nsSoftwareUpdate::GetComponentFolder(char* component,
|
||||
char* subdir,
|
||||
char* *errorMsg)
|
||||
{
|
||||
return GetFolder( GetComponentFolder( component ), subdir, errorMsg );
|
||||
nsFolderSpec* spec = GetComponentFolder( component );
|
||||
nsFolderSpec* ret_val = GetFolder( spec, subdir, errorMsg );
|
||||
if (spec) delete spec;
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -261,14 +281,17 @@ void nsSoftwareUpdate::SetPackageFolder(nsFolderSpec* folder)
|
||||
* Returns a Windows Profile object if you're on windows,
|
||||
* null if you're not or if there's a security error
|
||||
*/
|
||||
void* nsSoftwareUpdate::GetWinProfile(nsFolderSpec* folder, char* file, char* *errorMsg)
|
||||
void* nsSoftwareUpdate::GetWinProfile(nsFolderSpec* folder,
|
||||
char* file,
|
||||
char* *errorMsg)
|
||||
{
|
||||
#ifdef XP_PC
|
||||
nsWinProfile* profile = NULL;
|
||||
*errorMsg = NULL;
|
||||
|
||||
if ( packageName == NULL ) {
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_WIN_PROFILE_MUST_CALL_START, nsSoftUpdateError_INSTALL_NOT_STARTED );
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_WIN_PROFILE_MUST_CALL_START,
|
||||
nsSoftUpdateError_INSTALL_NOT_STARTED );
|
||||
return NULL;
|
||||
}
|
||||
profile = new nsWinProfile(this, folder, file);
|
||||
@ -289,7 +312,8 @@ void* nsSoftwareUpdate::GetWinRegistry(char* *errorMsg)
|
||||
nsWinReg* registry = NULL;
|
||||
|
||||
if ( packageName == NULL ) {
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_WIN_PROFILE_MUST_CALL_START, nsSoftUpdateError_INSTALL_NOT_STARTED );
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_WIN_PROFILE_MUST_CALL_START,
|
||||
nsSoftUpdateError_INSTALL_NOT_STARTED );
|
||||
return NULL;
|
||||
}
|
||||
registry = new nsWinReg(this);
|
||||
@ -310,10 +334,13 @@ void* nsSoftwareUpdate::GetWinRegistry(char* *errorMsg)
|
||||
*
|
||||
* @param inJarLocation file name inside the JAR file
|
||||
*/
|
||||
char* nsSoftwareUpdate::ExtractJARFile(char* inJarLocation, char* finalFile, char* *errorMsg)
|
||||
char* nsSoftwareUpdate::ExtractJARFile(char* inJarLocation,
|
||||
char* finalFile,
|
||||
char* *errorMsg)
|
||||
{
|
||||
if (zigPtr == NULL) {
|
||||
*errorMsg = SU_GetErrorMsg3("JAR file has not been opened", nsSoftUpdateError_UNKNOWN_JAR_FILE );
|
||||
*errorMsg = SU_GetErrorMsg3("JAR file has not been opened",
|
||||
nsSoftUpdateError_UNKNOWN_JAR_FILE );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -334,7 +361,8 @@ char* nsSoftwareUpdate::ExtractJARFile(char* inJarLocation, char* finalFile, cha
|
||||
{
|
||||
PRUint32 i;
|
||||
PRBool haveMatch = PR_FALSE;
|
||||
nsPrincipalArray* prinArray = (nsPrincipalArray*)getCertificates( zigPtr, inJarLocation );
|
||||
nsPrincipalArray* prinArray =
|
||||
(nsPrincipalArray*)getCertificates(zigPtr, inJarLocation);
|
||||
if ((prinArray == NULL) || (prinArray->GetSize() == 0)) {
|
||||
char *msg = NULL;
|
||||
msg = PR_sprintf_append(msg, "Missing certificate for %s", inJarLocation);
|
||||
@ -354,7 +382,8 @@ char* nsSoftwareUpdate::ExtractJARFile(char* inJarLocation, char* finalFile, cha
|
||||
if (haveMatch == PR_FALSE) {
|
||||
char *msg = NULL;
|
||||
msg = PR_sprintf_append(msg, "Missing certificate for %s", inJarLocation);
|
||||
*errorMsg = SU_GetErrorMsg3(msg, nsSoftUpdateError_NO_MATCHING_CERTIFICATE);
|
||||
*errorMsg = SU_GetErrorMsg3(msg,
|
||||
nsSoftUpdateError_NO_MATCHING_CERTIFICATE);
|
||||
PR_FREEIF(msg);
|
||||
}
|
||||
|
||||
@ -365,7 +394,8 @@ char* nsSoftwareUpdate::ExtractJARFile(char* inJarLocation, char* finalFile, cha
|
||||
}
|
||||
|
||||
/* Extract the file */
|
||||
char* outExtractLocation = NativeExtractJARFile(inJarLocation, finalFile, errorMsg);
|
||||
char* outExtractLocation = NativeExtractJARFile(inJarLocation, finalFile,
|
||||
errorMsg);
|
||||
return outExtractLocation;
|
||||
}
|
||||
|
||||
@ -378,20 +408,25 @@ char* nsSoftwareUpdate::ExtractJARFile(char* inJarLocation, char* finalFile, cha
|
||||
* NULL or empty package names are errors
|
||||
* @param inVInfo version of the package installed.
|
||||
* Can be NULL, in which case package is installed
|
||||
* without a version. Having a NULL version, this package is
|
||||
* automatically updated in the future (ie. no version check is performed).
|
||||
* without a version. Having a NULL version, this
|
||||
* package is automatically updated in the future
|
||||
* (ie. no version check is performed).
|
||||
* @param securityLevel ignored (was LIMITED_INSTALL or FULL_INSTALL)
|
||||
*/
|
||||
PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName, nsVersionInfo* inVInfo, PRInt32 securityLevel, char* *errorMsg)
|
||||
PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName,
|
||||
nsVersionInfo* inVInfo,
|
||||
PRInt32 securityLevel, char* *errorMsg)
|
||||
{
|
||||
// ignore securityLevel
|
||||
return StartInstall( vrPackageName, inVInfo, errorMsg);
|
||||
return StartInstall( vrPackageName, inVInfo, errorMsg );
|
||||
}
|
||||
|
||||
/**
|
||||
* An new form that doesn't require the security level
|
||||
*/
|
||||
PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName, nsVersionInfo* inVInfo, char* *errorMsg)
|
||||
PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName,
|
||||
nsVersionInfo* inVInfo,
|
||||
char* *errorMsg)
|
||||
{
|
||||
int errcode= nsSoftwareUpdate_SUCCESS;
|
||||
*errorMsg = NULL;
|
||||
@ -399,25 +434,31 @@ PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName, nsVersionInfo* inVIn
|
||||
|
||||
|
||||
if ( (vrPackageName == NULL) ) {
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_BAD_PACKAGE_NAME, nsSoftUpdateError_INVALID_ARGUMENTS );
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_BAD_PACKAGE_NAME,
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS );
|
||||
return nsSoftUpdateError_INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
packageName = XP_STRDUP(vrPackageName);
|
||||
|
||||
int len = XP_STRLEN(vrPackageName);
|
||||
int last_pos = len-1;
|
||||
char* packageName = new char[len+1];
|
||||
XP_STRCPY(packageName, vrPackageName);
|
||||
while ((last_pos >= 0) && (packageName[last_pos] == '/')) {
|
||||
char* tmpPackageName = new char[len+1];
|
||||
XP_STRCPY(tmpPackageName, vrPackageName);
|
||||
while ((last_pos >= 0) && (tmpPackageName[last_pos] == '/')) {
|
||||
// Make sure that package name does not end with '/'
|
||||
char* ptr = new char[last_pos+1];
|
||||
memcpy(packageName, ptr, last_pos);
|
||||
packageName[last_pos] = '\0';
|
||||
delete packageName;
|
||||
packageName = ptr;
|
||||
memcpy(tmpPackageName, ptr, last_pos);
|
||||
ptr[last_pos] = '\0';
|
||||
delete tmpPackageName;
|
||||
tmpPackageName = ptr;
|
||||
last_pos = last_pos - 1;
|
||||
}
|
||||
packageName = XP_STRDUP(tmpPackageName);
|
||||
delete tmpPackageName;
|
||||
|
||||
if (versionInfo) {
|
||||
/* delete the old nsVersionInfo object. */
|
||||
delete versionInfo;
|
||||
}
|
||||
versionInfo = inVInfo;
|
||||
installedFiles = new nsVector();
|
||||
|
||||
@ -430,8 +471,6 @@ PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName, nsVersionInfo* inVIn
|
||||
if (*errorMsg != NULL)
|
||||
return errcode;
|
||||
CheckSilentPrivileges();
|
||||
if (*errorMsg != NULL)
|
||||
return errcode;
|
||||
errcode = RequestSecurityPrivileges(errorMsg);
|
||||
if (*errorMsg != NULL)
|
||||
return errcode;
|
||||
@ -442,6 +481,7 @@ PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName, nsVersionInfo* inVIn
|
||||
char* path = nsVersionRegistry::getDefaultDirectory( packageName );
|
||||
if ( path != NULL ) {
|
||||
packageFolder = new nsFolderSpec("Installed", path, userPackageName);
|
||||
XP_FREE(path);
|
||||
}
|
||||
|
||||
saveError( errcode );
|
||||
@ -451,8 +491,12 @@ PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName, nsVersionInfo* inVIn
|
||||
/**
|
||||
* another StartInstall() simplification -- version as char*
|
||||
*/
|
||||
PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName, char* inVer, char* *errorMsg)
|
||||
PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName, char* inVer,
|
||||
char* *errorMsg)
|
||||
{
|
||||
/* StartInstall saves the nsVersionInfo and it deletes the object when
|
||||
* nsSoftwareUpdate is deleted.
|
||||
*/
|
||||
return StartInstall( vrPackageName, new nsVersionInfo( inVer ), errorMsg );
|
||||
}
|
||||
|
||||
@ -484,8 +528,9 @@ PRInt32 nsSoftwareUpdate::FinalizeInstall(char* *errorMsg)
|
||||
|
||||
if (packageName == NULL) {
|
||||
// probably didn't call StartInstall()
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_WIN_PROFILE_MUST_CALL_START, nsSoftUpdateError_INSTALL_NOT_STARTED);
|
||||
return nsSoftUpdateError_UNEXPECTED_ERROR;
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_WIN_PROFILE_MUST_CALL_START,
|
||||
nsSoftUpdateError_INSTALL_NOT_STARTED);
|
||||
return nsSoftUpdateError_INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
if ( installedFiles == NULL || installedFiles->GetSize() == 0 ) {
|
||||
@ -498,7 +543,7 @@ PRInt32 nsSoftwareUpdate::FinalizeInstall(char* *errorMsg)
|
||||
|
||||
// Wait for user approval
|
||||
if ( !silent && UserWantsConfirm() ) {
|
||||
#ifdef XXX /* FIX IT */
|
||||
#ifdef XXX /* XXX: RAMAN FIX IT */
|
||||
confdlg = new nsProgressDetails(this);
|
||||
|
||||
/* XXX What is this?
|
||||
@ -519,7 +564,10 @@ PRInt32 nsSoftwareUpdate::FinalizeInstall(char* *errorMsg)
|
||||
|
||||
// Register default package folder if set
|
||||
if ( packageFolder != NULL ) {
|
||||
nsVersionRegistry::setDefaultDirectory( packageName, packageFolder->toString() );
|
||||
char* packageFolderStr = packageFolder->toString();
|
||||
nsVersionRegistry::setDefaultDirectory( packageName,
|
||||
packageFolderStr );
|
||||
XP_FREEIF(packageFolderStr);
|
||||
}
|
||||
|
||||
/* call Complete() on all the elements */
|
||||
@ -544,7 +592,8 @@ PRInt32 nsSoftwareUpdate::FinalizeInstall(char* *errorMsg)
|
||||
}
|
||||
// add overall version for package
|
||||
if ( versionInfo != NULL) {
|
||||
result = nsVersionRegistry::installComponent(packageName, NULL, versionInfo);
|
||||
result = nsVersionRegistry::installComponent(packageName, NULL,
|
||||
versionInfo);
|
||||
}
|
||||
CleanUp();
|
||||
|
||||
@ -579,14 +628,18 @@ void nsSoftwareUpdate::AbortInstall()
|
||||
/**
|
||||
* ScheduleForInstall
|
||||
* call this to put an InstallObject on the install queue
|
||||
* Do not call installedFiles.addElement directly, because this routine also handles
|
||||
* progress messages
|
||||
* Do not call installedFiles.addElement directly, because this routine also
|
||||
* handles progress messages
|
||||
*/
|
||||
char* nsSoftwareUpdate::ScheduleForInstall(nsInstallObject* ob)
|
||||
{
|
||||
char *errorMsg = NULL;
|
||||
char *objString = ob->toString();
|
||||
|
||||
// flash current item
|
||||
SetProgressDialogItem( ob->toString() );
|
||||
SetProgressDialogItem( objString );
|
||||
|
||||
XP_FREEIF(objString);
|
||||
|
||||
// do any unpacking or other set-up
|
||||
errorMsg = ob->Prepare();
|
||||
@ -603,17 +656,18 @@ char* nsSoftwareUpdate::ScheduleForInstall(nsInstallObject* ob)
|
||||
|
||||
/**
|
||||
* Extract a file from JAR archive to the disk, and update the
|
||||
* version registry. Actually, keep a record of elements to be installed. FinalizeInstall()
|
||||
* does the real installation. Install elements are accepted if they meet one of the
|
||||
* following criteria:
|
||||
* version registry. Actually, keep a record of elements to be installed.
|
||||
* FinalizeInstall() does the real installation. Install elements are accepted
|
||||
* if they meet one of the following criteria:
|
||||
* 1) There is no entry for this subcomponnet in the registry
|
||||
* 2) The subcomponent version info is newer than the one installed
|
||||
* 3) The subcomponent version info is NULL
|
||||
*
|
||||
* @param name path of the package in the registry. Can be:
|
||||
* absolute: "/Plugins/Adobe/Acrobat/Drawer.exe"
|
||||
* relative: "Drawer.exe". Relative paths are relative to main package name
|
||||
* NULL: if NULL jarLocation is assumed to be the relative path
|
||||
* relative: "Drawer.exe". Relative paths are relative to
|
||||
* main package name NULL: if NULL jarLocation is assumed
|
||||
* to be the relative path
|
||||
* @param version version of the subcomponent. Can be NULL
|
||||
* @param jarSource location of the file to be installed inside JAR
|
||||
* @param folderSpec one of the predefined folder locations
|
||||
@ -634,27 +688,32 @@ PRInt32 nsSoftwareUpdate::AddSubcomponent(char* name,
|
||||
nsInstallFile* ie;
|
||||
int result = nsSoftwareUpdate_SUCCESS;
|
||||
*errorMsg = NULL;
|
||||
char *new_name;
|
||||
|
||||
if ( jarSource == NULL || (XP_STRLEN(jarSource) == 0) ) {
|
||||
*errorMsg = SU_GetErrorMsg3("No Jar Source", nsSoftUpdateError_INVALID_ARGUMENTS );
|
||||
*errorMsg = SU_GetErrorMsg3("No Jar Source",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS );
|
||||
return nsSoftUpdateError_INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
if ( folderSpec == NULL ) {
|
||||
*errorMsg = SU_GetErrorMsg3("folderSpec is NULL ", nsSoftUpdateError_INVALID_ARGUMENTS );
|
||||
*errorMsg = SU_GetErrorMsg3("folderSpec is NULL ",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS );
|
||||
return nsSoftUpdateError_INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
if (packageName == NULL) {
|
||||
// probably didn't call StartInstall()
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_BAD_PACKAGE_NAME_AS, nsSoftUpdateError_BAD_PACKAGE_NAME );
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_BAD_PACKAGE_NAME_AS,
|
||||
nsSoftUpdateError_BAD_PACKAGE_NAME );
|
||||
return nsSoftUpdateError_BAD_PACKAGE_NAME;
|
||||
}
|
||||
|
||||
if ((name == NULL) || (XP_STRLEN(name) == 0)) {
|
||||
// Default subName = location in jar file
|
||||
name = GetQualifiedRegName( jarSource );
|
||||
new_name = GetQualifiedRegName( jarSource );
|
||||
} else {
|
||||
name = GetQualifiedRegName( name );
|
||||
new_name = GetQualifiedRegName( name );
|
||||
}
|
||||
|
||||
if ( (relativePath == NULL) || (XP_STRLEN(relativePath) == 0) ) {
|
||||
@ -666,16 +725,17 @@ PRInt32 nsSoftwareUpdate::AddSubcomponent(char* name,
|
||||
PRBool versionNewer = PR_FALSE;
|
||||
if ( (forceInstall == PR_FALSE ) &&
|
||||
(version != NULL) &&
|
||||
( nsVersionRegistry::validateComponent( name ) == 0 ) ) {
|
||||
nsVersionInfo* oldVersion = nsVersionRegistry::componentVersion(name);
|
||||
( nsVersionRegistry::validateComponent( new_name ) == 0 ) ) {
|
||||
nsVersionInfo* oldVersion = nsVersionRegistry::componentVersion(new_name);
|
||||
if ( version->compareTo( oldVersion ) != nsVersionEnum_EQUAL )
|
||||
versionNewer = PR_TRUE;
|
||||
delete oldVersion;
|
||||
} else {
|
||||
versionNewer = PR_TRUE;
|
||||
}
|
||||
|
||||
if (versionNewer) {
|
||||
ie = new nsInstallFile( this, name, version, jarSource,
|
||||
ie = new nsInstallFile( this, new_name, version, jarSource,
|
||||
folderSpec, relativePath, forceInstall,
|
||||
errorMsg );
|
||||
if (errorMsg == NULL) {
|
||||
@ -685,7 +745,8 @@ PRInt32 nsSoftwareUpdate::AddSubcomponent(char* name,
|
||||
if (*errorMsg != NULL) {
|
||||
result = nsSoftUpdateError_UNEXPECTED_ERROR;
|
||||
}
|
||||
|
||||
|
||||
delete new_name;
|
||||
saveError( result );
|
||||
return result;
|
||||
}
|
||||
@ -726,7 +787,8 @@ PRInt32 nsSoftwareUpdate::Execute(char* jarSource, char* *errorMsg, char* args)
|
||||
* @param errorMsg Error message
|
||||
* @return an integer corresponding to response from Gestalt
|
||||
*/
|
||||
PRInt32 nsSoftwareUpdate::Gestalt(char* selectorStr, int* os_err, char* *errorMsg)
|
||||
PRInt32 nsSoftwareUpdate::Gestalt(char* selectorStr, int* os_err,
|
||||
char* *errorMsg)
|
||||
{
|
||||
*errorMsg = NULL;
|
||||
|
||||
@ -760,19 +822,27 @@ fail:
|
||||
/**
|
||||
* Patch
|
||||
*
|
||||
* nsVersionInfo object shouldn't be free'ed. nsSoftwareUpdate object
|
||||
* deletes it.
|
||||
*
|
||||
*/
|
||||
PRInt32 nsSoftwareUpdate::Patch(char* regName, nsVersionInfo* version, char* patchname, char* *errorMsg)
|
||||
PRInt32 nsSoftwareUpdate::Patch(char* regName,
|
||||
nsVersionInfo* version,
|
||||
char* patchname,
|
||||
char* *errorMsg)
|
||||
{
|
||||
int errcode = nsSoftwareUpdate_SUCCESS;
|
||||
|
||||
if ( regName == NULL || patchname == NULL ) {
|
||||
*errorMsg = SU_GetErrorMsg3("regName or patchName is NULL ", nsSoftUpdateError_INVALID_ARGUMENTS );
|
||||
*errorMsg = SU_GetErrorMsg3("regName or patchName is NULL ",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS );
|
||||
return saveError( nsSoftUpdateError_INVALID_ARGUMENTS );
|
||||
}
|
||||
|
||||
char* rname = GetQualifiedRegName( regName );
|
||||
|
||||
nsInstallPatch* ip = new nsInstallPatch(this, rname, version, patchname, errorMsg);
|
||||
nsInstallPatch* ip = new nsInstallPatch(this, rname, version, patchname,
|
||||
errorMsg);
|
||||
if (*errorMsg != NULL) {
|
||||
errcode = nsSoftUpdateError_ACCESS_DENIED;
|
||||
} else {
|
||||
@ -781,15 +851,28 @@ PRInt32 nsSoftwareUpdate::Patch(char* regName, nsVersionInfo* version, char* pat
|
||||
errcode = nsSoftUpdateError_UNEXPECTED_ERROR;
|
||||
}
|
||||
}
|
||||
delete rname;
|
||||
saveError( errcode );
|
||||
return errcode;
|
||||
}
|
||||
|
||||
PRInt32 nsSoftwareUpdate::Patch(char* regName, nsVersionInfo* version, char* patchname,
|
||||
nsFolderSpec* folder, char* filename, char* *errorMsg)
|
||||
/* Patch
|
||||
*
|
||||
* nsVersionInfo object shouldn't be free'ed. nsSoftwareUpdate object
|
||||
* deletes it.
|
||||
*
|
||||
*/
|
||||
PRInt32 nsSoftwareUpdate::Patch(char* regName,
|
||||
nsVersionInfo* version,
|
||||
char* patchname,
|
||||
nsFolderSpec* folder,
|
||||
char* filename,
|
||||
char* *errorMsg)
|
||||
{
|
||||
if ( folder == NULL || regName == NULL || XP_STRLEN(regName) == 0 || patchname == NULL ) {
|
||||
*errorMsg = SU_GetErrorMsg3("folder or regName or patchName is NULL ", nsSoftUpdateError_INVALID_ARGUMENTS );
|
||||
if ( folder == NULL || regName == NULL ||
|
||||
XP_STRLEN(regName) == 0 || patchname == NULL ) {
|
||||
*errorMsg = SU_GetErrorMsg3("folder or regName or patchName is NULL ",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS );
|
||||
return saveError( nsSoftUpdateError_INVALID_ARGUMENTS );
|
||||
}
|
||||
|
||||
@ -798,7 +881,8 @@ PRInt32 nsSoftwareUpdate::Patch(char* regName, nsVersionInfo* version, char* pat
|
||||
char* rname = GetQualifiedRegName( regName );
|
||||
|
||||
nsInstallPatch* ip = new nsInstallPatch( this, rname, version,
|
||||
patchname, folder, filename, errorMsg );
|
||||
patchname, folder, filename,
|
||||
errorMsg );
|
||||
if (*errorMsg != NULL) {
|
||||
errcode = nsSoftUpdateError_ACCESS_DENIED;
|
||||
} else {
|
||||
@ -807,6 +891,7 @@ PRInt32 nsSoftwareUpdate::Patch(char* regName, nsVersionInfo* version, char* pat
|
||||
errcode = nsSoftUpdateError_UNEXPECTED_ERROR;
|
||||
}
|
||||
}
|
||||
delete rname;
|
||||
saveError( errcode );
|
||||
return errcode;
|
||||
}
|
||||
@ -817,11 +902,14 @@ PRInt32 nsSoftwareUpdate::Patch(char* regName, nsVersionInfo* version, char* pat
|
||||
* reference counting. Its main purpose is to delete files installed or
|
||||
* created outside of SmartUpdate.
|
||||
*/
|
||||
PRInt32 nsSoftwareUpdate::DeleteFile(nsFolderSpec* folder, char* relativeFileName, char* *errorMsg)
|
||||
PRInt32 nsSoftwareUpdate::DeleteFile(nsFolderSpec* folder,
|
||||
char* relativeFileName,
|
||||
char* *errorMsg)
|
||||
{
|
||||
int errcode = nsSoftwareUpdate_SUCCESS;
|
||||
|
||||
nsInstallDelete* id = new nsInstallDelete(this, folder, relativeFileName, errorMsg);
|
||||
nsInstallDelete* id = new nsInstallDelete(this, folder, relativeFileName,
|
||||
errorMsg);
|
||||
if (*errorMsg != NULL) {
|
||||
errcode = nsSoftUpdateError_ACCESS_DENIED;
|
||||
} else {
|
||||
@ -840,10 +928,11 @@ PRInt32 nsSoftwareUpdate::DeleteFile(nsFolderSpec* folder, char* relativeFileNam
|
||||
|
||||
/**
|
||||
* This method finds named registry component and deletes both the file and the
|
||||
* entry in the Client VR. registryName is the name of the component in the registry.
|
||||
* Returns usual errors codes + code to indicate item doesn't exist in registry, registry
|
||||
* item wasn't a file item, or the related file doesn't exist. If the file is in use we will
|
||||
* store the name and to try to delete it on subsequent start-ups until we're successful.
|
||||
* entry in the Client VR. registryName is the name of the component in the
|
||||
* registry. Returns usual errors codes + code to indicate item doesn't exist
|
||||
* in registry, registry item wasn't a file item, or the related file doesn't
|
||||
* exist. If the file is in use we will store the name and to try to delete it
|
||||
* on subsequent start-ups until we're successful.
|
||||
*/
|
||||
PRInt32 nsSoftwareUpdate::DeleteComponent(char* registryName, char* *errorMsg)
|
||||
{
|
||||
@ -866,6 +955,7 @@ PRInt32 nsSoftwareUpdate::DeleteComponent(char* registryName, char* *errorMsg)
|
||||
return errcode;
|
||||
}
|
||||
|
||||
|
||||
static PRBool su_PathEndsWithSeparator(char* path, char* sep)
|
||||
{
|
||||
PRBool ends_with_filesep = PR_FALSE;
|
||||
@ -873,14 +963,17 @@ static PRBool su_PathEndsWithSeparator(char* path, char* sep)
|
||||
PRInt32 filesep_len = XP_STRLEN(sep);
|
||||
PRInt32 path_len = XP_STRLEN(path);
|
||||
if (path_len >= filesep_len) {
|
||||
ends_with_filesep = (XP_STRSTR(&path[path_len - filesep_len], sep) ? PR_TRUE : PR_FALSE);
|
||||
ends_with_filesep = (XP_STRSTR(&path[path_len - filesep_len], sep)
|
||||
? PR_TRUE : PR_FALSE);
|
||||
}
|
||||
}
|
||||
return ends_with_filesep;
|
||||
}
|
||||
|
||||
|
||||
nsFolderSpec* nsSoftwareUpdate::GetFolder(char* targetFolder, char* subdirectory, char* *errorMsg)
|
||||
nsFolderSpec* nsSoftwareUpdate::GetFolder(char* targetFolder,
|
||||
char* subdirectory,
|
||||
char* *errorMsg)
|
||||
{
|
||||
if (XP_STRCMP(targetFolder, FOLDER_FILE_URL) == 0) {
|
||||
char* newPath = NULL;
|
||||
@ -899,15 +992,22 @@ nsFolderSpec* nsSoftwareUpdate::GetFolder(char* targetFolder, char* subdirectory
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
return GetFolder( GetFolder(targetFolder, NULL, errorMsg), subdirectory, errorMsg );
|
||||
nsFolderSpec* spec = GetFolder(targetFolder, errorMsg);
|
||||
nsFolderSpec* ret_val = GetFolder( spec, subdirectory, errorMsg );
|
||||
if (spec) {
|
||||
delete spec;
|
||||
}
|
||||
return ret_val;
|
||||
}
|
||||
}
|
||||
|
||||
nsFolderSpec* nsSoftwareUpdate::GetFolder(nsFolderSpec* folder, char* subdir, char* *errorMsg)
|
||||
nsFolderSpec* nsSoftwareUpdate::GetFolder(nsFolderSpec* folder,
|
||||
char* subdir,
|
||||
char* *errorMsg)
|
||||
{
|
||||
nsFolderSpec* spec = NULL;
|
||||
char* path = NULL;
|
||||
char* newPath = NULL;
|
||||
char* path = NULL;
|
||||
char* newPath = NULL;
|
||||
|
||||
if ( subdir == NULL || (XP_STRLEN(subdir) == 0 )) {
|
||||
// no subdir, return what we were passed
|
||||
@ -928,8 +1028,8 @@ nsFolderSpec* nsSoftwareUpdate::GetFolder(nsFolderSpec* folder, char* subdir, ch
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns true if there is enough free diskspace, false if there isn't.
|
||||
* The drive containg the folder is checked for # of free bytes.
|
||||
* This method returns true if there is enough free diskspace, false if there
|
||||
* isn't. The drive containg the folder is checked for # of free bytes.
|
||||
*/
|
||||
long nsSoftwareUpdate::DiskSpaceAvailable(nsFolderSpec* folder)
|
||||
{
|
||||
@ -958,19 +1058,21 @@ PRInt32 nsSoftwareUpdate::AddDirectory(char* name,
|
||||
PRBool forceInstall,
|
||||
char* *errorMsg)
|
||||
{
|
||||
nsInstallFile* ie;
|
||||
nsInstallFile* ie = NULL;
|
||||
int result = nsSoftwareUpdate_SUCCESS;
|
||||
char *qualified_name = NULL;
|
||||
*errorMsg = NULL;
|
||||
|
||||
if ( jarSource == NULL || XP_STRLEN(jarSource) == 0 || folderSpec == NULL ) {
|
||||
*errorMsg = SU_GetErrorMsg3("folder or Jarsource is NULL ", nsSoftUpdateError_INVALID_ARGUMENTS );
|
||||
*errorMsg = SU_GetErrorMsg3("folder or Jarsource is NULL ",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS );
|
||||
return saveError(nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
}
|
||||
|
||||
if (packageName == NULL) {
|
||||
// probably didn't call StartInstall()
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_BAD_PACKAGE_NAME_AS, nsSoftUpdateError_BAD_PACKAGE_NAME );
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_BAD_PACKAGE_NAME_AS,
|
||||
nsSoftUpdateError_BAD_PACKAGE_NAME );
|
||||
return saveError(nsSoftUpdateError_BAD_PACKAGE_NAME);
|
||||
}
|
||||
|
||||
@ -999,16 +1101,17 @@ PRInt32 nsSoftwareUpdate::AddDirectory(char* name,
|
||||
char** matchingFiles = ExtractDirEntries( jarSource, &length );
|
||||
int i;
|
||||
PRBool bInstall;
|
||||
nsVersionInfo* oldVer;
|
||||
|
||||
for (i=0; i < length; i++) {
|
||||
/* XP_Cat allocates a new string and returns it */
|
||||
char* fullRegName = XP_Cat(qualified_name, "/", matchingFiles[i]);
|
||||
|
||||
if ( (forceInstall == PR_FALSE) && (version != NULL) &&
|
||||
(nsVersionRegistry::validateComponent(fullRegName) == 0) ) {
|
||||
// Only install if newer
|
||||
oldVer = nsVersionRegistry::componentVersion(fullRegName);
|
||||
nsVersionInfo* oldVer = nsVersionRegistry::componentVersion(fullRegName);
|
||||
bInstall = ( version->compareTo(oldVer) > 0 );
|
||||
delete oldVer;
|
||||
} else {
|
||||
// file doesn't exist or "forced" install
|
||||
bInstall = PR_TRUE;
|
||||
@ -1032,6 +1135,11 @@ PRInt32 nsSoftwareUpdate::AddDirectory(char* name,
|
||||
errorMsg);
|
||||
if (*errorMsg == NULL) {
|
||||
ScheduleForInstall( ie );
|
||||
} else {
|
||||
/* We have an error and we haven't scheduled,
|
||||
* thus we can delete it
|
||||
*/
|
||||
delete ie;
|
||||
}
|
||||
XP_FREEIF(newJarSource);
|
||||
XP_FREEIF(newSubDir);
|
||||
@ -1040,7 +1148,6 @@ PRInt32 nsSoftwareUpdate::AddDirectory(char* name,
|
||||
}
|
||||
XP_FREEIF(subdir);
|
||||
XP_FREEIF(qualified_name);
|
||||
/* XXX: I think we should free nsInstallFile object */
|
||||
if (errorMsg != NULL) {
|
||||
result = nsSoftUpdateError_UNEXPECTED_ERROR;
|
||||
}
|
||||
@ -1054,15 +1161,12 @@ PRInt32 nsSoftwareUpdate::Uninstall(char* packageName, char* *errorMsg)
|
||||
{
|
||||
int errcode = nsSoftwareUpdate_SUCCESS;
|
||||
|
||||
#ifdef XXX
|
||||
/* XXX: Fix it, after having Uninstall object */
|
||||
nsUninstallObject* u = new nsUninstallObject( this, packageName, errorMsg );
|
||||
if (*errorMsg != NULL) {
|
||||
errcode = nsSoftUpdateError_UNEXPECTED_ERROR;
|
||||
} else {
|
||||
ScheduleForInstall( u );
|
||||
}
|
||||
#endif
|
||||
|
||||
saveError( errcode );
|
||||
return errcode;
|
||||
@ -1123,7 +1227,8 @@ PRInt32 nsSoftwareUpdate::InitializeInstallerCertificate(char* *errorMsg)
|
||||
{
|
||||
PRInt32 errcode;
|
||||
nsPrincipal *prin = NULL;
|
||||
nsPrincipalArray* prinArray = (nsPrincipalArray*)getCertificates(zigPtr, installerJarName);
|
||||
nsPrincipalArray* prinArray =
|
||||
(nsPrincipalArray*)getCertificates(zigPtr, installerJarName);
|
||||
if ((prinArray == NULL) || (prinArray->GetSize() == 0)) {
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_NO_CERTIFICATE,
|
||||
nsSoftUpdateError_NO_INSTALLER_CERTIFICATE);
|
||||
@ -1169,9 +1274,6 @@ PRBool nsSoftwareUpdate::CheckSilentPrivileges()
|
||||
nsTarget* impersonation = nsTarget::findTarget(IMPERSONATOR);
|
||||
nsPrivilegeManager* privMgr = nsPrivilegeManager::getPrivilegeManager();
|
||||
if ((privMgr != NULL) && (impersonation != NULL)) {
|
||||
/* XXX: We should get the SystemPrincipal and enablePrivilege on that.
|
||||
* Or may be we should get rid of impersonation
|
||||
*/
|
||||
privMgr->enablePrivilege(impersonation, 1);
|
||||
|
||||
nsTarget* target = nsTarget::findTarget(SILENT_PRIV);
|
||||
@ -1196,9 +1298,6 @@ PRInt32 nsSoftwareUpdate::RequestSecurityPrivileges(char* *errorMsg)
|
||||
nsTarget* impersonation = nsTarget::findTarget(IMPERSONATOR);
|
||||
nsPrivilegeManager* privMgr = nsPrivilegeManager::getPrivilegeManager();
|
||||
if ((privMgr != NULL) && (impersonation != NULL)) {
|
||||
/* XXX: We should get the SystemPrincipal and enablePrivilege on that.
|
||||
* Or may be we should get rid of impersonation
|
||||
*/
|
||||
privMgr->enablePrivilege(impersonation, 1);
|
||||
|
||||
nsTarget* target = nsTarget::findTarget(INSTALL_PRIV);
|
||||
@ -1246,8 +1345,10 @@ void nsSoftwareUpdate::CleanUp()
|
||||
delete ie;
|
||||
}
|
||||
installedFiles->RemoveAll();
|
||||
delete installedFiles;
|
||||
installedFiles = NULL;
|
||||
}
|
||||
installedFiles = NULL;
|
||||
XP_FREEIF(packageName);
|
||||
packageName = NULL; // used to see if StartInstall() has been called
|
||||
|
||||
CloseProgressDialog();
|
||||
@ -1286,7 +1387,6 @@ char* nsSoftwareUpdate::GetQualifiedRegName(char* name)
|
||||
if (XP_STRLEN(packageName) != 0) {
|
||||
packagePrefix = XP_Cat(packageName, "/");
|
||||
name = XP_AppendStr(packagePrefix, name);
|
||||
XP_FREE(packagePrefix);
|
||||
} else {
|
||||
name = XP_STRDUP(name);
|
||||
}
|
||||
@ -1335,27 +1435,30 @@ PRInt32 nsSoftwareUpdate::OpenJARFile(char* *errorMsg)
|
||||
PREF_GetBoolPref( AUTOUPDATE_ENABLE_PREF, &enabled);
|
||||
|
||||
if (!enabled) {
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_BAD_JS_ARGUMENT, nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_BAD_JS_ARGUMENT,
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
return nsSoftUpdateError_INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
jarFile = jarName;
|
||||
if (jarFile == NULL) {
|
||||
/* error already signaled */
|
||||
*errorMsg = SU_GetErrorMsg3("No Jar Source", nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
*errorMsg = SU_GetErrorMsg3("No Jar Source",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
return nsSoftUpdateError_INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
/* Open and initialize the JAR archive */
|
||||
jarData = SOB_new();
|
||||
if ( jarData == NULL ) {
|
||||
*errorMsg = SU_GetErrorMsg3("No Jar Source", nsSoftUpdateError_UNEXPECTED_ERROR);
|
||||
*errorMsg = SU_GetErrorMsg3("No Jar Source",
|
||||
nsSoftUpdateError_UNEXPECTED_ERROR);
|
||||
return nsSoftUpdateError_UNEXPECTED_ERROR;
|
||||
}
|
||||
err = SOB_pass_archive( ZIG_F_GUESS,
|
||||
jarFile,
|
||||
NULL, /* realStream->fURL->address, */
|
||||
jarData);
|
||||
jarData );
|
||||
if ( err != 0 ) {
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_VERIFICATION_FAILED, err);
|
||||
return err;
|
||||
@ -1412,7 +1515,9 @@ void nsSoftwareUpdate::freeCertificates(void* prins)
|
||||
|
||||
|
||||
/* Caller should free the returned string */
|
||||
char* nsSoftwareUpdate::NativeExtractJARFile(char* inJarLocation, char* finalFile, char* *errorMsg)
|
||||
char* nsSoftwareUpdate::NativeExtractJARFile(char* inJarLocation,
|
||||
char* finalFile,
|
||||
char* *errorMsg)
|
||||
{
|
||||
char * tempName = NULL;
|
||||
char * target = NULL;
|
||||
@ -1426,7 +1531,8 @@ char* nsSoftwareUpdate::NativeExtractJARFile(char* inJarLocation, char* finalFil
|
||||
jarPath = (char*)inJarLocation;
|
||||
if (jarPath == NULL) {
|
||||
/* out-of-memory error already signaled */
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_OUT_OF_MEMORY, nsSoftUpdateError_UNEXPECTED_ERROR);
|
||||
*errorMsg = SU_GetErrorMsg4(SU_ERROR_OUT_OF_MEMORY,
|
||||
nsSoftUpdateError_UNEXPECTED_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1471,7 +1577,8 @@ char* nsSoftwareUpdate::NativeExtractJARFile(char* inJarLocation, char* finalFil
|
||||
char * encodingName;
|
||||
unsigned long encodingNameLength;
|
||||
XP_Bool isApplesingle = FALSE;
|
||||
result = SOB_get_metainfo( jar, NULL, CONTENT_ENCODING_HEADER, (void**)&encodingName, &encodingNameLength);
|
||||
result = SOB_get_metainfo( jar, NULL, CONTENT_ENCODING_HEADER,
|
||||
(void**)&encodingName, &encodingNameLength);
|
||||
|
||||
#ifdef APPLESINGLE_MAGIC_HACK
|
||||
if (result != 0) {
|
||||
@ -1485,7 +1592,8 @@ char* nsSoftwareUpdate::NativeExtractJARFile(char* inJarLocation, char* finalFil
|
||||
}
|
||||
#else
|
||||
isApplesingle = (( result == 0 ) &&
|
||||
(XP_STRNCMP(APPLESINGLE_MIME_TYPE, encodingName, XP_STRLEN( APPLESINGLE_MIME_TYPE ) == 0)));
|
||||
(XP_STRNCMP(APPLESINGLE_MIME_TYPE, encodingName,
|
||||
XP_STRLEN( APPLESINGLE_MIME_TYPE ) == 0)));
|
||||
#endif
|
||||
if ( isApplesingle ) {
|
||||
/* We have an AppleSingle file */
|
||||
@ -1625,15 +1733,16 @@ bail:
|
||||
return StrArray;
|
||||
}
|
||||
|
||||
void* nsSoftwareUpdate::NativeOpenProgDlg(char* packageName)
|
||||
void* nsSoftwareUpdate::NativeOpenProgDlg(char* name)
|
||||
{
|
||||
pw_ptr prgwin = NULL;
|
||||
char buf[TITLESIZE];
|
||||
|
||||
prgwin = PW_Create( XP_FindContextOfType(NULL, MWContextBookmarks), pwStandard );
|
||||
prgwin = PW_Create( XP_FindContextOfType(NULL, MWContextBookmarks),
|
||||
pwStandard );
|
||||
|
||||
if ( prgwin != NULL ) {
|
||||
PR_snprintf( buf, TITLESIZE, XP_GetString(SU_INSTALLWIN_TITLE), packageName );
|
||||
PR_snprintf(buf, TITLESIZE, XP_GetString(SU_INSTALLWIN_TITLE), name);
|
||||
|
||||
PW_SetWindowTitle( prgwin, buf );
|
||||
PW_SetLine2( prgwin, NULL );
|
||||
|
@ -52,7 +52,8 @@ PRBool nsTrigger::UpdateEnabled(void)
|
||||
|
||||
/**
|
||||
* @param componentName version registry name of the component
|
||||
* @return version of the package. null if not installed, or SmartUpdate disabled
|
||||
* @return version of the package. null if not installed, or
|
||||
* SmartUpdate disabled
|
||||
*/
|
||||
nsVersionInfo* nsTrigger::GetVersionInfo( char* componentName )
|
||||
{
|
||||
@ -72,15 +73,15 @@ PRBool nsTrigger::StartSoftwareUpdate( char* url, PRInt32 flags )
|
||||
{
|
||||
if (url != NULL) {
|
||||
/* This is a potential problem */
|
||||
/* We are grabbing any context, but we really need ours */
|
||||
/* We are grabbing any context, but we really need ours */
|
||||
/* The problem is that Java does not have access to MWContext */
|
||||
MWContext * cx;
|
||||
cx = XP_FindSomeContext();
|
||||
if (cx)
|
||||
return SU_StartSoftwareUpdate(cx, url, NULL, NULL, NULL, flags);
|
||||
else
|
||||
return PR_FALSE;
|
||||
}
|
||||
MWContext * cx;
|
||||
cx = XP_FindSomeContext();
|
||||
if (cx)
|
||||
return SU_StartSoftwareUpdate(cx, url, NULL, NULL, NULL, flags);
|
||||
else
|
||||
return PR_FALSE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
@ -114,12 +115,12 @@ PRBool
|
||||
nsTrigger::ConditionalSoftwareUpdate(char* url,
|
||||
char* componentName,
|
||||
PRInt32 diffLevel,
|
||||
nsVersionInfo* version,
|
||||
nsVersionInfo* versionInfo,
|
||||
PRInt32 flags)
|
||||
{
|
||||
PRBool needJar = PR_FALSE;
|
||||
|
||||
if ((version == NULL) || (componentName == NULL))
|
||||
if ((versionInfo == NULL) || (componentName == NULL))
|
||||
needJar = PR_TRUE;
|
||||
else {
|
||||
int stat = nsVersionRegistry::validateComponent( componentName );
|
||||
@ -135,9 +136,10 @@ nsTrigger::ConditionalSoftwareUpdate(char* url,
|
||||
if ( oldVer == NULL )
|
||||
needJar = PR_TRUE;
|
||||
else if ( diffLevel < 0 )
|
||||
needJar = (version->compareTo( oldVer ) <= diffLevel);
|
||||
needJar = (versionInfo->compareTo( oldVer ) <= diffLevel);
|
||||
else
|
||||
needJar = (version->compareTo( oldVer ) >= diffLevel);
|
||||
needJar = (versionInfo->compareTo( oldVer ) >= diffLevel);
|
||||
delete oldVer;
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,10 +154,14 @@ nsTrigger::ConditionalSoftwareUpdate(char* url,
|
||||
char* componentName,
|
||||
char* version)
|
||||
{
|
||||
return ConditionalSoftwareUpdate( url, componentName,
|
||||
BLD_DIFF,
|
||||
new nsVersionInfo(version),
|
||||
DEFAULT_MODE );
|
||||
nsVersionInfo* versionInfo = new nsVersionInfo(version);
|
||||
PRBool ret_val = ConditionalSoftwareUpdate( url,
|
||||
componentName,
|
||||
BLD_DIFF,
|
||||
versionInfo,
|
||||
DEFAULT_MODE );
|
||||
delete versionInfo;
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -171,6 +177,7 @@ nsTrigger::ConditionalSoftwareUpdate(char* url,
|
||||
*/
|
||||
PRInt32 nsTrigger::CompareVersion( char* regName, nsVersionInfo* version )
|
||||
{
|
||||
PRInt32 ret_val;
|
||||
if (!UpdateEnabled())
|
||||
return EQUAL;
|
||||
|
||||
@ -179,15 +186,23 @@ PRInt32 nsTrigger::CompareVersion( char* regName, nsVersionInfo* version )
|
||||
if ( regVersion == NULL ||
|
||||
nsVersionRegistry::validateComponent( regName ) == REGERR_NOFILE ) {
|
||||
|
||||
if (regVersion) delete regVersion;
|
||||
regVersion = new nsVersionInfo(0,0,0,0,0);
|
||||
}
|
||||
|
||||
return regVersion->compareTo( version );
|
||||
PR_ASSERT(regVersion != NULL);
|
||||
|
||||
ret_val = regVersion->compareTo( version );
|
||||
delete regVersion;
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
PRInt32 nsTrigger::CompareVersion( char* regName, char* version )
|
||||
{
|
||||
return CompareVersion( regName, new nsVersionInfo( version ) );
|
||||
nsVersionInfo* versionInfo = new nsVersionInfo( version );
|
||||
PRInt32 ret_val = CompareVersion( regName, versionInfo );
|
||||
delete versionInfo;
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
@ -195,7 +210,10 @@ nsTrigger::CompareVersion( char* regName, PRInt32 maj,
|
||||
PRInt32 min, PRInt32 rel,
|
||||
PRInt32 bld )
|
||||
{
|
||||
return CompareVersion( regName, new nsVersionInfo(maj, min, rel, bld, 0) );
|
||||
nsVersionInfo* versionInfo = new nsVersionInfo(maj, min, rel, bld, 0);
|
||||
PRInt32 ret_val = CompareVersion( regName, versionInfo );
|
||||
delete versionInfo;
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
@ -41,10 +41,17 @@ nsUninstallObject::nsUninstallObject(nsSoftwareUpdate* inSoftUpdate,
|
||||
{
|
||||
regName = NULL;
|
||||
userName = NULL;
|
||||
if ( regName == NULL || XP_STRLEN(regName) == 0 ) {
|
||||
if ( (inRegName == NULL) || (XP_STRLEN(inRegName) == 0) ) {
|
||||
*errorMsg = SU_GetErrorMsg3("RegName is NULL ", nsSoftUpdateError_INVALID_ARGUMENTS );
|
||||
return;
|
||||
}
|
||||
|
||||
if (inSoftUpdate == NULL) {
|
||||
*errorMsg = SU_GetErrorMsg3("SoftwareUpdate object is NULL ",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
return;
|
||||
}
|
||||
|
||||
regName = XP_STRDUP(inRegName);
|
||||
|
||||
/* Request impersonation privileges */
|
||||
@ -91,6 +98,12 @@ char* nsUninstallObject::Complete()
|
||||
{
|
||||
nsTarget* execTarget = NULL;
|
||||
|
||||
if ((softUpdate == NULL) || (regName == NULL)) {
|
||||
*errorMsg = SU_GetErrorMsg3("Invalid arguments to UninstallObject ",
|
||||
nsSoftUpdateError_INVALID_ARGUMENTS);
|
||||
return;
|
||||
}
|
||||
|
||||
nsPrivilegeManager* privMgr = nsPrivilegeManager::getPrivilegeManager();
|
||||
nsTarget* impersonation = nsTarget::findTarget(IMPERSONATOR);
|
||||
|
||||
|
@ -41,6 +41,9 @@ nsVersionInfo::nsVersionInfo(PRInt32 maj, PRInt32 min, PRInt32 rel, PRInt32 bld,
|
||||
nsVersionInfo::nsVersionInfo(char* versionArg)
|
||||
{
|
||||
PRInt32 errorCode;
|
||||
if (versionArg == NULL) {
|
||||
versionArg = "0.0.0.0";
|
||||
}
|
||||
nsString version(versionArg);
|
||||
int dot = version.Find('.', 0);
|
||||
|
||||
@ -140,12 +143,18 @@ nsVersionEnum nsVersionInfo::compareTo(nsVersionInfo* vi)
|
||||
|
||||
nsVersionEnum nsVersionInfo::compareTo(char* version)
|
||||
{
|
||||
return compareTo(new nsVersionInfo(version));
|
||||
nsVersionInfo* versionInfo = new nsVersionInfo(version);
|
||||
nsVersionEnum ret_val = compareTo(versionInfo);
|
||||
delete versionInfo;
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
nsVersionEnum nsVersionInfo::compareTo(PRInt32 maj, PRInt32 min, PRInt32 rel, PRInt32 bld)
|
||||
{
|
||||
return compareTo(new nsVersionInfo(maj, min, rel, bld, 0));
|
||||
nsVersionInfo* versionInfo = new nsVersionInfo(maj, min, rel, bld, 0);
|
||||
nsVersionEnum ret_val = compareTo(versionInfo);
|
||||
delete versionInfo;
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
@ -30,6 +30,9 @@ PR_BEGIN_EXTERN_C
|
||||
|
||||
/**
|
||||
* Return the physical disk path for the specified component.
|
||||
*
|
||||
* Caller should free the returned string
|
||||
*
|
||||
* @param component Registry path of the item to look up in the Registry
|
||||
* @return The disk path for the specified component; NULL indicates error
|
||||
* @see VersionRegistry#checkComponent
|
||||
@ -56,7 +59,8 @@ char* nsVersionRegistry::componentPath( char* component )
|
||||
/**
|
||||
* Return the version information for the specified component.
|
||||
* @param component Registry path of the item to look up in the Registry
|
||||
* @return A VersionInfo object for the specified component; NULL indicates error
|
||||
* @return A VersionInfo object for the specified component;
|
||||
* NULL indicates error
|
||||
* @see VersionRegistry#checkComponent
|
||||
*/
|
||||
nsVersionInfo* nsVersionRegistry::componentVersion( char* component )
|
||||
@ -82,6 +86,12 @@ nsVersionInfo* nsVersionRegistry::componentVersion( char* component )
|
||||
return verInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default directory.
|
||||
*
|
||||
* Caller should free the returned string
|
||||
*
|
||||
*/
|
||||
char* nsVersionRegistry::getDefaultDirectory( char* component )
|
||||
{
|
||||
char pathbuf[MAXREGPATHLEN];
|
||||
@ -101,7 +111,8 @@ char* nsVersionRegistry::getDefaultDirectory( char* component )
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
PRInt32 nsVersionRegistry::setDefaultDirectory( char* component, char* directory )
|
||||
PRInt32 nsVersionRegistry::setDefaultDirectory( char* component,
|
||||
char* directory )
|
||||
{
|
||||
REGERR status = REGERR_FAIL;
|
||||
|
||||
@ -114,7 +125,9 @@ PRInt32 nsVersionRegistry::setDefaultDirectory( char* component, char* directory
|
||||
return (status);
|
||||
}
|
||||
|
||||
PRInt32 nsVersionRegistry::installComponent( char* component, char* path, nsVersionInfo* version )
|
||||
PRInt32 nsVersionRegistry::installComponent( char* component,
|
||||
char* path,
|
||||
nsVersionInfo* version )
|
||||
{
|
||||
char * szVersion = NULL;
|
||||
REGERR status = REGERR_FAIL;
|
||||
@ -133,7 +146,10 @@ PRInt32 nsVersionRegistry::installComponent( char* component, char* path, nsVers
|
||||
return (status);
|
||||
}
|
||||
|
||||
PRInt32 nsVersionRegistry::installComponent( char* name, char* path, nsVersionInfo* version, PRInt32 refCount )
|
||||
PRInt32 nsVersionRegistry::installComponent( char* name,
|
||||
char* path,
|
||||
nsVersionInfo* version,
|
||||
PRInt32 refCount )
|
||||
{
|
||||
int err = installComponent( name, path, version );
|
||||
|
||||
@ -256,7 +272,8 @@ PRInt32 nsVersionRegistry::getRefCount( char* component )
|
||||
* @return userPackagename User-readable package name
|
||||
* @return Error code
|
||||
*/
|
||||
PRInt32 nsVersionRegistry::uninstallCreate( char* regPackageName, char* userPackageName )
|
||||
PRInt32 nsVersionRegistry::uninstallCreate( char* regPackageName,
|
||||
char* userPackageName )
|
||||
{
|
||||
char* temp = convertPackageName(regPackageName);
|
||||
regPackageName = temp;
|
||||
@ -342,8 +359,7 @@ char* nsVersionRegistry::getUninstallUserName( char* regName )
|
||||
char* ret_val = NULL;
|
||||
|
||||
if ( regName != NULL ) {
|
||||
/* XXX: uncomment the following code, when we merge Nav 4.5 into 5.0 */
|
||||
//status = VR_GetUninstallUserName( regName, buf, sizeof(buf) );
|
||||
status = VR_GetUninstallUserName( regName, buf, sizeof(buf) );
|
||||
PR_ASSERT(PR_FALSE);
|
||||
|
||||
if ( status == REGERR_OK )
|
||||
@ -371,6 +387,8 @@ nsVersionRegistry::nsVersionRegistry()
|
||||
*/
|
||||
char* nsVersionRegistry::convertPackageName( char* regPackageName )
|
||||
{
|
||||
if (regPackageName == NULL)
|
||||
return regPackageName;
|
||||
char* convertedPackageName;
|
||||
PRBool bSharedUninstall = PR_FALSE;
|
||||
PRUint32 i=0;
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include "VerReg.h"
|
||||
#include "libi18n.h"
|
||||
|
||||
#include "jvmmgr.h"
|
||||
|
||||
extern int MK_OUT_OF_MEMORY;
|
||||
|
||||
#define MOCHA_CONTEXT_PREFIX "autoinstall:"
|
||||
@ -851,7 +853,7 @@ void su_HandleCompleteJavaScript (su_DownloadStream* realStream)
|
||||
/* add installer .JAR to the classpath */
|
||||
nativeJar = WH_FileName( realStream->fJarFile, xpURL );
|
||||
if ( nativeJar != NULL ) {
|
||||
LJ_AddToClassPath( nativeJar );
|
||||
JVM_AddToClassPath( nativeJar );
|
||||
XP_FREE( nativeJar );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user