Converting Smartupdate code from Java to C++.

git-svn-id: svn://10.0.0.236/trunk@8347 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
raman%netscape.com
1998-08-21 23:46:11 +00:00
parent afea246aeb
commit 73df9e69d0
18 changed files with 2453 additions and 188 deletions

View File

@@ -93,7 +93,7 @@ private:
* NativePickDefaultDirectory
* Platform-specific implementation of GetDirectoryPath
*/
char* NativePickDefaultDirectory(char* *errorMsg);
char* NativePickDefaultDirectory(void);
PRBool NativeIsJavaDir();

View File

@@ -21,6 +21,7 @@
#include "prtypes.h"
#include "nsSoftwareUpdate.h"
#include "nsFolderSpec.h"
PR_BEGIN_EXTERN_C
@@ -62,7 +63,7 @@ private:
char* registryName; // final file to be deleted
/* Private Methods */
void processInstallDelete();
void processInstallDelete(char* *errorMsg);
int NativeComplete();
int NativeCheckFileStatus();

View File

@@ -43,15 +43,15 @@ public:
/* Prepare
* Extracts file out of the JAR archive into the temp directory
*/
char* Prepare();
char* Prepare(void);
/* Complete
* Completes the install by executing the file
* Security hazard: make sure we request the right permissions
*/
char* Complete();
char* Complete(void);
void Abort();
void Abort(void);
char* toString();
@@ -64,8 +64,8 @@ private:
char* cmdline; // constructed command-line
/* Private Methods */
void NativeComplete();
void NativeAbort();
char* NativeComplete(void);
void NativeAbort(void);
};

View File

@@ -16,8 +16,8 @@
* Reserved.
*/
#ifndef nsInstallPath_h__
#define nsInstallPath_h__
#ifndef nsInstallPatch_h__
#define nsInstallPatch_h__
#include "prtypes.h"
#include "nsSoftwareUpdate.h"
@@ -27,7 +27,7 @@
PR_BEGIN_EXTERN_C
struct nsInstallPath {
struct nsInstallPatch : public nsInstallObject {
public:
@@ -46,48 +46,51 @@ public:
nsInstallPatch(nsSoftwareUpdate* inSoftUpdate,
char* inVRName,
nsVersionInfo* inVInfo,
char* inJarLocation);
char* inJarLocation,
char* *errorMsg);
nsInstallPatch(nsSoftwareUpdate* inSoftUpdate,
char* inVRName,
nsVersionInfo* inVInfo,
char* inJarLocation,
nsFolderSpec* folderSpec,
char* inPartialPath);
char* inPartialPath,
char* *errorMsg);
~nsInstallPath();
virtual ~nsInstallPatch();
void Prepare();
char* Prepare(void);
/* Complete
* Completes the install:
* - move the patched file to the final location
* - updates the registry
*/
void Complete();
char* Complete(void);
void Abort();
void Abort(void);
char* toString();
char* toString(void);
private:
/* Private Fields */
char* vrName; // Registry name of the component
nsVersionInfo* versionInfo; // Version
char* jarLocation; // Location in the JAR
char* patchURL; // extracted location of diff (xpURL)
char* targetfile; // source and final file (native)
char* patchedfile; // temp name of patched file
char* vrName; // Registry name of the component
nsVersionInfo* versionInfo; // Version
char* jarLocation; // Location in the JAR
char* patchURL; // extracted location of diff (xpURL)
char* targetfile; // source and final file (native)
char* patchedfile; // temp name of patched file
/* Private Methods */
void checkPrivileges();
char* NativePatch( char* srcfile, char* diffURL );
PRInt32 NativeReplace( char* target, char* tmpfile );
void NativeDeleteFile( char* file );
char* checkPrivileges(void);
char* NativePatch( char* srcfile, char* diffURL, char* *errorMsg );
int NativeReplace( char* target, char* tmpfile );
void NativeDeleteFile( char* filename );
};
PR_END_EXTERN_C
#endif /* nsInstallPath_h__ */
#endif /* nsInstallPatch_h__ */

View File

@@ -58,10 +58,14 @@ typedef enum nsInstallType {
} nsInstallType;
typedef enum nsVersionEnum {
nsVersionEnum_MAJOR_DIFF = 4,
nsVersionEnum_MINOR_DIFF = 3,
nsVersionEnum_REL_DIFF = 2,
nsVersionEnum_BLD_DIFF = 1,
nsVersionEnum_MAJOR_DIFF = 4,
nsVersionEnum_MAJOR_DIFF_MINUS = -4,
nsVersionEnum_MINOR_DIFF = 3,
nsVersionEnum_MINOR_DIFF_MINUS = -3,
nsVersionEnum_REL_DIFF = 2,
nsVersionEnum_REL_DIFF_MINUS = -2,
nsVersionEnum_BLD_DIFF = 1,
nsVersionEnum_BLD_DIFF_MINUS = -1,
nsVersionEnum_EQUAL = 0
} nsVersionEnum;
@@ -112,25 +116,6 @@ typedef enum nsWinRegValueEnum {
} nsWinRegValueEnum;
typedef enum nsRegistryErrorsEnum {
REGERR_OK = 0,
REGERR_FAIL = 1,
REGERR_NOMORE = 2,
REGERR_NOFIND = 3,
REGERR_BADREAD = 4,
REGERR_BADLOCN = 5,
REGERR_PARAM = 6,
REGERR_BADMAGIC = 7,
REGERR_BADCHECK = 8,
REGERR_NOFILE = 9,
REGERR_MEMORY = 10,
REGERR_BUFTOOSMALL = 11,
REGERR_NAMETOOLONG = 12,
REGERR_REGVERSION = 13,
REGERR_DELETED = 14,
REGERR_BADTYPE = 15,
REGERR_NOPATH = 16,
REGERR_BADNAME = 17,
REGERR_READONLY = 18,
REGERR_BADUTF8 = 19,
REGERR_SECURITY = 99,

View File

@@ -291,11 +291,12 @@ public:
char* jarSource,
nsFolderSpec* folderSpec,
char* subdir,
PRBool forceInstall);
PRBool forceInstall,
char* *errorMsg);
/* Uninstall */
PRInt32 Uninstall(char* packageName);
PRInt32 Uninstall(char* packageName, char* *errorMsg);
/*******************************
@@ -308,9 +309,9 @@ public:
* altogether this makes more sense for now. Creating a new object
* would only lead to more JRI hell, especially on the Mac
*******************************/
void OpenProgressDialog();
void OpenProgressDialog(void);
void CloseProgressDialog();
void CloseProgressDialog(void);
void SetProgressDialogItem(char* message);
@@ -327,13 +328,14 @@ private:
nsProgressDetails* confdlg; /* Detail confirmation dialog */
PRInt32 userChoice; /* User feedback: -1 unknown, 0 is cancel, 1 is OK */
PRInt32 progwin; /* pointer to native progress window */
void* progwin; /* pointer to native progress window */
PRBool silent; /* Silent upgrade? */
PRBool force; /* Force install? */
PRInt32 lastError; /* the most recent non-zero error */
char* filesep; /* the platform-specific file separator */
char* installerJarName; /* Name of the installer file */
unsigned long installerJarNameLength; /* Length of Name of the installer file */
char* jarName; /* Name of the JAR file */
char* jarCharset; /* Charset for filenames in JAR */
void* zigPtr; /* Stores the pointer to ZIG * */
@@ -347,7 +349,7 @@ private:
/*
* Reads in the installer certificate, and creates its principal
*/
char* InitializeInstallerCertificate();
PRInt32 InitializeInstallerCertificate(char* *errorMsg);
/*
* checks if our principal has privileges for silent install
@@ -358,7 +360,7 @@ private:
/* Request the security privileges, so that the security dialogs
* pop up
*/
void RequestSecurityPrivileges();
PRInt32 RequestSecurityPrivileges(char* *errorMsg);
/**
@@ -393,11 +395,11 @@ private:
* Since SoftUpdate JSObject can only be created by C code
* we cannot be spoofed
*/
void VerifyJSObject(void* jsObj);
char* VerifyJSObject(void* jsObj);
/* Open/close the jar file
*/
char* OpenJARFile();
PRInt32 OpenJARFile(char* *errorMsg);
void CloseJARFile();
/* getCertificates
@@ -407,6 +409,8 @@ private:
*/
void* getCertificates(void* zigPtr, char* inJarLocation);
void freeCertificates(void* prins);
char* NativeExtractJARFile(char* inJarLocation, char* finalFile, char* *errorMsg);
PRInt32 NativeMakeDirectory(char* path);;
@@ -415,13 +419,13 @@ private:
char* NativeFileURLToNative(char* Dir, char* path);
char** ExtractDirEntries(char* Dir);
char** ExtractDirEntries(char* Dir, int *length);
PRInt32 NativeOpenProgDlg(char* packageName);
void NativeCloseProgDlg(PRInt32 progptr);
void NativeSetProgDlgItem(PRInt32 progptr, char* message);
void NativeSetProgDlgRange(PRInt32 progptr, PRInt32 max);
void NativeSetProgDlgThermo(PRInt32 progptr, PRInt32 value);
void* NativeOpenProgDlg(char* packageName);
void NativeCloseProgDlg(void* progptr);
void NativeSetProgDlgItem(void* progptr, char* message);
void NativeSetProgDlgRange(void* progptr, PRInt32 max);
void NativeSetProgDlgThermo(void* progptr, PRInt32 value);
PRBool UserWantsConfirm();
};

View File

@@ -53,7 +53,7 @@ public:
/**
* @return true if SmartUpdate is enabled
*/
static PRBool UpdateEnabled();
static PRBool UpdateEnabled(void);
/**
* @param componentName version registry name of the component
@@ -100,6 +100,10 @@ public:
nsVersionInfo* version,
PRInt32 flags);
static PRBool ConditionalSoftwareUpdate(char* url,
char* componentName,
char* version);
/**
* Validates existence and compares versions

View File

@@ -0,0 +1,64 @@
/* -*- 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 nsUninstallObject_h__
#define nsUninstallObject_h__
#include "prtypes.h"
#include "nsSoftwareUpdate.h"
PR_BEGIN_EXTERN_C
struct nsUninstallObject : public nsInstallObject {
public:
/* Public Fields */
/* Public Methods */
nsUninstallObject(nsSoftwareUpdate* inSoftUpdate, char* inRegName, char* *errorMsg);
virtual ~nsUninstallObject();
/* Complete
* Uninstalls the package
*/
char* Complete();
char* Prepare();
void Abort();
char* toString();
private:
/* Private Fields */
char* regName; // Registry name of package
char* userName; // User name of package
/* Private Methods */
char* NativeComplete(char* regname);
};
PR_END_EXTERN_C
#endif /* nsUninstallObject_h__ */