home *** CD-ROM | disk | FTP | other *** search
- package netscape.softupdate;
-
- import java.text.MessageFormat;
- import netscape.security.AppletSecurity;
- import netscape.security.PrivilegeManager;
- import netscape.security.Target;
-
- class InstallDelete extends InstallObject {
- private String finalFile;
- private String registryName;
- int FILE_DOES_NOT_EXIST;
- int FILE_READ_ONLY;
- int FILE_IS_DIRECTORY;
- int deleteStatus;
- static final int DELETE_FILE = 1;
- static final int DELETE_COMPONENT = 2;
-
- InstallDelete(SoftwareUpdate var1, FolderSpec var2, String var3) throws SoftUpdateException {
- super(var1);
- this.deleteStatus = 1;
- this.finalFile = var2.MakeFullPath(var3);
- this.FILE_DOES_NOT_EXIST = -214;
- this.FILE_READ_ONLY = -215;
- this.FILE_IS_DIRECTORY = -216;
- this.processInstallDelete();
- }
-
- InstallDelete(SoftwareUpdate var1, String var2) throws SoftUpdateException {
- super(var1);
- this.deleteStatus = 2;
- this.registryName = var2;
- this.FILE_DOES_NOT_EXIST = -214;
- this.FILE_READ_ONLY = -215;
- this.FILE_IS_DIRECTORY = -216;
- this.processInstallDelete();
- }
-
- private void processInstallDelete() throws SoftUpdateException {
- PrivilegeManager var2 = AppletSecurity.getPrivilegeManager();
- Target var3 = Target.findTarget("Impersonator");
- var2.enablePrivilege(var3);
- Target var4 = Target.findTarget("SoftwareInstall");
- var2.enablePrivilege(var4, super.softUpdate.GetPrincipal());
- if (this.deleteStatus == 2) {
- int var1 = VersionRegistry.inRegistry(this.registryName);
- if (var1 != 0) {
- throw new SoftUpdateException(Strings.error_NotInRegistry() + this.registryName, -213);
- }
-
- this.finalFile = VersionRegistry.componentPath(this.registryName);
- }
-
- if (this.finalFile != null) {
- int var5 = this.NativeCheckFileStatus();
- if (var5 != 0) {
- if (var5 == -214) {
- throw new SoftUpdateException(Strings.error_FileDoesNotExist() + this.finalFile, var5);
- }
-
- if (var5 == -215) {
- throw new SoftUpdateException(Strings.error_FileReadOnly() + this.finalFile, var5);
- }
-
- if (var5 == -216) {
- throw new SoftUpdateException(Strings.error_FileIsDirectory() + this.finalFile, var5);
- }
-
- throw new SoftUpdateException(Strings.error_Unexpected() + this.finalFile, var5);
- }
- }
-
- }
-
- protected void Prepare() throws SoftUpdateException {
- }
-
- protected void Complete() throws SoftUpdateException {
- int var1 = -1;
- PrivilegeManager var3 = AppletSecurity.getPrivilegeManager();
- Target var4 = Target.findTarget("Impersonator");
- var3.enablePrivilege(var4);
- Target var2 = Target.findTarget("SoftwareInstall");
- var3.enablePrivilege(var2, super.softUpdate.GetPrincipal());
- if (this.deleteStatus == 2) {
- var1 = VersionRegistry.deleteComponent(this.registryName);
- }
-
- if (this.deleteStatus != 1 && var1 != 0) {
- throw new SoftUpdateException(Strings.error_Unexpected() + this.finalFile, var1);
- } else {
- if (this.finalFile != null) {
- var1 = this.NativeComplete();
- if (var1 != 0 && var1 != -214) {
- var3.revertPrivilege(var2);
- throw new SoftUpdateException(Strings.error_Unexpected() + this.finalFile, var1);
- }
- }
-
- }
- }
-
- protected void Abort() {
- }
-
- private native int NativeComplete() throws SoftUpdateException;
-
- private native int NativeCheckFileStatus() throws SoftUpdateException;
-
- public String toString() {
- Object[] var1 = new Object[]{this.finalFile};
- Object[] var2 = new Object[]{this.registryName};
- return this.deleteStatus == 1 ? MessageFormat.format(Strings.details_DeleteFile(), var1) : MessageFormat.format(Strings.details_DeleteComponent(), var2);
- }
-
- protected boolean CanUninstall() {
- return false;
- }
-
- protected boolean RegisterPackageNode() {
- return false;
- }
- }
-