--- a/toolkit/toolkit-makefiles.sh
+++ b/toolkit/toolkit-makefiles.sh
@@ -514,19 +514,17 @@ MAKEFILES_xpcom_tests="
xpcom/tests/dynamic/Makefile
xpcom/tests/services/Makefile
xpcom/tests/windows/Makefile
"
MAKEFILES_xpinstall="
xpinstall/Makefile
xpinstall/public/Makefile
- xpinstall/res/Makefile
xpinstall/src/Makefile
- xpinstall/stub/Makefile
"
MAKEFILES_xpfe="
widget/src/xremoteclient/Makefile
toolkit/components/remote/Makefile
xpfe/Makefile
xpfe/browser/Makefile
xpfe/browser/public/Makefile
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -124,20 +124,16 @@
#include "nsAppDirectoryServiceDefs.h"
#include "nsXULAppAPI.h"
#include "nsXREDirProvider.h"
#include "nsToolkitCompsCID.h"
#include "nsINIParser.h"
-#ifdef MOZ_XPINSTALL
-#include "InstallCleanupDefines.h"
-#endif
-
#include <stdlib.h>
#ifdef XP_UNIX
#include <sys/stat.h>
#include <unistd.h>
#endif
#ifdef XP_BEOS
@@ -1153,79 +1149,16 @@ DumpHelp()
#endif
// this works, but only after the components have registered. so if you drop in a new command line handler, -help
// won't not until the second run.
// out of the bug, because we ship a component.reg file, it works correctly.
DumpArbitraryHelp();
}
-#ifdef MOZ_XPINSTALL
-// don't modify aAppDir directly... clone it first
-static int
-VerifyInstallation(nsIFile* aAppDir)
-{
- static const char lastResortMessage[] =
- "A previous install did not complete correctly. Finishing install.";
-
- // Maximum allowed / used length of alert message is 255 chars, due to restrictions on Mac.
- // Please make sure that file contents and fallback_alert_text are at most 255 chars.
-
- char message[256];
- PRInt32 numRead = 0;
- const char *messageToShow = lastResortMessage;
-
- nsresult rv;
- nsCOMPtr<nsIFile> messageFile;
- rv = aAppDir->Clone(getter_AddRefs(messageFile));
- if (NS_SUCCEEDED(rv)) {
- messageFile->AppendNative(NS_LITERAL_CSTRING("res"));
- messageFile->AppendNative(CLEANUP_MESSAGE_FILENAME);
- PRFileDesc* fd = 0;
-
- nsCOMPtr<nsILocalFile> lf (do_QueryInterface(messageFile));
- if (lf) {
- rv = lf->OpenNSPRFileDesc(PR_RDONLY, 0664, &fd);
- if (NS_SUCCEEDED(rv)) {
- numRead = PR_Read(fd, message, sizeof(message)-1);
- if (numRead > 0) {
- message[numRead] = 0;
- messageToShow = message;
- }
- }
- }
- }
-
- ShowOSAlert(messageToShow);
-
- nsCOMPtr<nsIFile> cleanupUtility;
- aAppDir->Clone(getter_AddRefs(cleanupUtility));
- if (!cleanupUtility) return 1;
-
- cleanupUtility->AppendNative(CLEANUP_UTIL);
-
- ScopedXPCOMStartup xpcom;
- rv = xpcom.Initialize();
- if (NS_FAILED(rv)) return 1;
-
- { // extra scoping needed to release things before xpcom shutdown
- //Create the process framework to run the cleanup utility
- nsCOMPtr<nsIProcess> cleanupProcess
- (do_CreateInstance(NS_PROCESS_CONTRACTID));
- rv = cleanupProcess->Init(cleanupUtility);
- if (NS_FAILED(rv)) return 1;
-
- rv = cleanupProcess->Run(PR_FALSE,nsnull, 0, nsnull);
- if (NS_FAILED(rv)) return 1;
- }
-
- return 0;
-}
-#endif
-
#ifdef DEBUG_warren
#ifdef XP_WIN
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#endif
#endif
#if defined(FREEBSD)
@@ -2871,43 +2804,16 @@ XRE_main(int argc, char* argv[], const n
return 1;
PRBool canRun = PR_FALSE;
rv = nativeApp->Start(&canRun);
if (NS_FAILED(rv) || !canRun) {
return 1;
}
-#ifdef MOZ_XPINSTALL
- //----------------------------------------------------------------
- // We need to check if a previous installation occured and
- // if so, make sure it finished and cleaned up correctly.
- //
- // If there is an xpicleanup.dat file left around, that means the
- // previous installation did not finish correctly. We must cleanup
- // before a valid mozilla can run.
- //
- // Show the user a platform-specific Alert message, then spawn the
- // xpicleanup utility, then exit.
- //----------------------------------------------------------------
- {
- nsCOMPtr<nsIFile> registryFile;
- rv = dirProvider.GetAppDir()->Clone(getter_AddRefs(registryFile));
- if (NS_SUCCEEDED(rv)) {
- registryFile->AppendNative(CLEANUP_REGISTRY);
-
- PRBool exists;
- rv = registryFile->Exists(&exists);
- if (NS_SUCCEEDED(rv) && exists) {
- return VerifyInstallation(dirProvider.GetAppDir());
- }
- }
- }
-#endif
-
#ifdef MOZ_ENABLE_XREMOTE
// handle -remote now that xpcom is fired up
const char* xremotearg;
ar = CheckArg("remote", PR_TRUE, &xremotearg);
if (ar == ARG_BAD) {
PR_fprintf(PR_STDERR, "Error: -remote requires an argument\n");
return 1;
--- a/xpinstall/Makefile.in
+++ b/xpinstall/Makefile.in
@@ -19,16 +19,17 @@
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Daniel Veditz <dveditz@netscape.com>
# Douglas Turner <dougt@netscape.com>
# Samir Gehani <sgehani@netscape.com>
+# Dave Townsend <dtownsend@oxymoronical.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
@@ -42,19 +43,11 @@
DEPTH = ..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = xpinstall
-DIRS = public src cleanup
-
-ifndef MOZ_ENABLE_LIBXUL
-DIRS += stub
-endif
-
-ifndef MOZ_XUL_APP
-DIRS += res
-endif
+DIRS = public src
include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/xpinstall/cleanup/InstallCleanup.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Navigator.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corp.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Don Bragg <dbragg@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-#include "InstallCleanup.h"
-
-int PerformScheduledTasks(HREG reg)
-{
- int deleteComplete = DONE;
- int replaceComplete = DONE;
-
- deleteComplete = DeleteScheduledFiles( reg );
- replaceComplete = ReplaceScheduledFiles( reg );
- if ((deleteComplete == DONE) && (replaceComplete == DONE))
- return DONE;
- else
- return TRY_LATER;
-}
-
-
-//----------------------------------------------------------------------------
-// ReplaceScheduledFiles
-//----------------------------------------------------------------------------
-int ReplaceScheduledFiles( HREG reg )
-{
- RKEY key;
- int rv = DONE;
-
- /* replace files if any listed */
- if (REGERR_OK == NR_RegGetKey(reg,ROOTKEY_PRIVATE,REG_REPLACE_LIST_KEY,&key))
- {
- char keyname[MAXREGNAMELEN];
- char doomedFile[MAXREGPATHLEN];
- char srcFile[MAXREGPATHLEN];
-
- uint32 bufsize;
- REGENUM state = 0;
- while (REGERR_OK == NR_RegEnumSubkeys( reg, key, &state,
- keyname, sizeof(keyname), REGENUM_CHILDREN))
- {
- bufsize = sizeof(srcFile);
- REGERR err1 = NR_RegGetEntry( reg, (RKEY)state,
- REG_REPLACE_SRCFILE, &srcFile, &bufsize);
-
- bufsize = sizeof(doomedFile);
- REGERR err2 = NR_RegGetEntry( reg, (RKEY)state,
- REG_REPLACE_DESTFILE, &doomedFile, &bufsize);
-
- if ( err1 == REGERR_OK && err2 == REGERR_OK )
- {
- int result = NativeReplaceFile( srcFile, doomedFile );
- if (result == DONE)
- {
- // This one is done
- NR_RegDeleteKey( reg, key, keyname );
- }
- }
- }
-
- /* delete list node if empty */
- state = 0;
- if (REGERR_NOMORE == NR_RegEnumSubkeys( reg, key, &state, keyname,
- sizeof(keyname), REGENUM_CHILDREN ))
- {
- NR_RegDeleteKey(reg, ROOTKEY_PRIVATE, REG_REPLACE_LIST_KEY);
- rv = DONE;
- }
- else
- {
- rv = TRY_LATER;
- }
- }
- return rv;
-}
-
-//----------------------------------------------------------------------------
-// DeleteScheduledFiles
-//----------------------------------------------------------------------------
-int DeleteScheduledFiles( HREG reg )
-{
- REGERR err;
- RKEY key;
- REGENUM state = 0;
- int rv = DONE;
-
- /* perform scheduled file deletions */
- if (REGERR_OK == NR_RegGetKey(reg,ROOTKEY_PRIVATE,REG_DELETE_LIST_KEY,&key))
- {
- // the delete key exists, so we loop through its children
- // and try to delete all the listed files
-
- char namebuf[MAXREGNAMELEN];
- char valbuf[MAXREGPATHLEN];
-
- while (REGERR_OK == NR_RegEnumEntries( reg, key, &state, namebuf,
- sizeof(namebuf), 0 ) )
- {
- uint32 bufsize = sizeof(valbuf); // gets changed, must reset
- err = NR_RegGetEntry( reg, key, namebuf, valbuf, &bufsize );
- if ( err == REGERR_OK )
- {
- rv = NativeDeleteFile(valbuf);
- if (rv == DONE)
- NR_RegDeleteEntry( reg, key, namebuf);
- }
- }
-
- /* delete list node if empty */
- state = 0;
- err = NR_RegEnumEntries(reg, key, &state, namebuf, sizeof(namebuf), 0);
- if ( err == REGERR_NOMORE )
- {
- NR_RegDeleteKey(reg, ROOTKEY_PRIVATE, REG_DELETE_LIST_KEY);
- rv = DONE;
- }
- else
- {
- rv = TRY_LATER;
- }
- }
- return rv;
-}
-
deleted file mode 100644
--- a/xpinstall/cleanup/InstallCleanup.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Navigator.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corp.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Don Bragg <dbragg@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-#ifndef INSTALL_CLEANUP_H
-#define INSTALL_CLEANUP_H
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "prtypes.h"
-#include "VerReg.h"
-
-#define DONE 0
-#define TRY_LATER -1
-
-int PerformScheduledTasks(HREG);
-int DeleteScheduledFiles(HREG);
-int ReplaceScheduledFiles(HREG);
-int NativeReplaceFile(const char* replacementFile, const char* doomedFile );
-int NativeDeleteFile(const char* aFileToDelete);
-
-#endif //INSTALL_CLEANUP_H
-
deleted file mode 100644
--- a/xpinstall/cleanup/InstallCleanupDefines.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef INSTALLCLEANUPDEFINES_H
-#define INSTALLCLEANUPDEFINES_H
-
-// simple hack for xpicleanup.exe
-#ifndef NS_LITERAL_CSTRING
-#define NS_LITERAL_CSTRING(x) (x)
-#endif
-
-#define CLEANUP_MESSAGE_FILENAME NS_LITERAL_CSTRING("cmessage.txt")
-
-#define CLEANUP_REGISTRY NS_LITERAL_CSTRING("xpicleanup.dat")
-
-#if defined (XP_WIN)
-#define CLEANUP_UTIL NS_LITERAL_CSTRING("xpicleanup.exe")
-
-#elif defined (XP_OS2)
-#define CLEANUP_UTIL NS_LITERAL_CSTRING("xpicleanup.exe")
-
-#else
-#define CLEANUP_UTIL NS_LITERAL_CSTRING("xpicleanup")
-
-#endif
-
-
-#endif
deleted file mode 100644
--- a/xpinstall/cleanup/InstallCleanupMac.cpp
+++ /dev/null
@@ -1,558 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Don Bragg <dbragg@netscape.com>
- * Samir Gehani <sgehani@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <MacTypes.h>
-#include "MoreFiles.h"
-#include "MoreFilesExtras.h"
-#include "FullPath.h"
-#include <AppleEvents.h>
-#include <Gestalt.h>
-#include <TextUtils.h>
-#include <Folders.h>
-#include <Processes.h>
-#include <Resources.h>
-#include <Aliases.h>
-
-#include "InstallCleanup.h"
-#include "InstallCleanupDefines.h"
-
-#define kSleepMax 60 // sleep 1 second
-
-Boolean gAppleEventsFlag, gQuitFlag;
-long gSleepVal;
-
-
-int strcasecmp(const char *str1, const char *str2);
-OSErr GetFSSpecFromPath(char *aPath, FSSpec *aSpec);
-void my_c2pstrcpy(Str255 aDstPStr, const char *aSrcCStr);
-OSErr GetCWD(short *aVRefNum, long *aDirID);
-OSErr GetCleanupReg(FSSpec *aCleanupReg);
-
-int strcasecmp(const char *str1, const char *str2)
-{
- char currentChar1, currentChar2;
-
- while (1) {
-
- currentChar1 = *str1;
- currentChar2 = *str2;
-
- if ((currentChar1 >= 'a') && (currentChar1 <= 'z'))
- currentChar1 += ('A' - 'a');
-
- if ((currentChar2 >= 'a') && (currentChar2 <= 'z'))
- currentChar2 += ('A' - 'a');
-
- if (currentChar1 == '\0')
- break;
-
- if (currentChar1 != currentChar2)
- return currentChar1 - currentChar2;
-
- str1++;
- str2++;
-
- }
-
- return currentChar1 - currentChar2;
-}
-
-OSErr GetFSSpecFromPath(const char *aPath, FSSpec *aSpec)
-{
- if (!aPath || !aSpec)
- return paramErr;
-
- // 1> verify path is not an empty string
- // 2> verify path has leaf
- // 3> verify path does not start with leading ':'
-
- if ((!*aPath) ||
- (*(aPath + strlen(aPath) - 1) == ':') ||
- (*aPath == ':'))
- {
- return paramErr;
- }
-
- // path is kosher: get FSSpec for it
- return FSpLocationFromFullPath(strlen(aPath), (const void *) aPath, aSpec);
-}
-
-void
-my_c2pstrcpy(Str255 aDstPStr, const char *aSrcCStr)
-{
- if (!aSrcCStr)
- return;
-
- memcpy(&aDstPStr[1], aSrcCStr, strlen(aSrcCStr) > 255 ? 255 : strlen(aSrcCStr));
- aDstPStr[0] = strlen(aSrcCStr);
-}
-
-OSErr
-GetCWD(short *aVRefNum, long *aDirID)
-{
- OSErr err = noErr;
- ProcessSerialNumber psn;
- ProcessInfoRec pInfo;
- FSSpec tmp;
-
- if (!aVRefNum || !aDirID)
- return paramErr;
-
- *aVRefNum = 0;
- *aDirID = 0;
-
- /* get cwd based on curr ps info */
- if (!(err = GetCurrentProcess(&psn)))
- {
- pInfo.processName = nil;
- pInfo.processAppSpec = &tmp;
- pInfo.processInfoLength = (sizeof(ProcessInfoRec));
-
- if(!(err = GetProcessInformation(&psn, &pInfo)))
- {
- *aVRefNum = pInfo.processAppSpec->vRefNum;
- *aDirID = pInfo.processAppSpec->parID;
- }
- }
-
- return err;
-}
-
-OSErr
-GetCleanupReg(FSSpec *aCleanupReg)
-{
- OSErr err = noErr;
- short efVRefNum = 0;
- long efDirID = 0;
-
- if (!aCleanupReg)
- return paramErr;
-
- err = GetCWD(&efVRefNum, &efDirID);
- if (err == noErr)
- {
- Str255 pCleanupReg;
- my_c2pstrcpy(pCleanupReg, CLEANUP_REGISTRY);
- err = FSMakeFSSpec(efVRefNum, efDirID, pCleanupReg, aCleanupReg);
- }
-
- return err;
-}
-
-
-#pragma mark -
-
-//----------------------------------------------------------------------------
-// Native Mac file deletion function
-//----------------------------------------------------------------------------
-int NativeDeleteFile(const char* aFileToDelete)
-{
- OSErr err;
- FSSpec delSpec;
-
- if (!aFileToDelete)
- return DONE;
-
- // stat the file
- err = GetFSSpecFromPath(aFileToDelete, &delSpec);
- if (err != noErr)
- {
- // return fine if it doesn't exist
- return DONE;
- }
-
- // else try to delete it
- err = FSpDelete(&delSpec);
- if (err != noErr)
- {
- // tell user to try again later if deletion failed
- return TRY_LATER;
- }
-
- return DONE;
-}
-
-//----------------------------------------------------------------------------
-// Native Mac file replacement function
-//----------------------------------------------------------------------------
-int NativeReplaceFile(const char* aReplacementFile, const char* aDoomedFile )
-{
- OSErr err;
- FSSpec replSpec, doomSpec, tgtDirSpec;
- long dirID;
- Boolean isDir;
-
- if (!aReplacementFile || !aDoomedFile)
- return DONE;
-
- err = GetFSSpecFromPath(aReplacementFile, &replSpec);
- if (err != noErr)
- return DONE;
-
- // stat replacement file
- err = FSpGetDirectoryID(&replSpec, &dirID, &isDir);
- if (err != noErr || isDir)
- {
- // return fine if it doesn't exist
- return DONE;
- }
-
- // check if the replacement file and doomed file are the same
- if (strcasecmp(aReplacementFile, aDoomedFile) == 0)
- {
- // return fine if they are the same
- return DONE;
- }
-
- // try and delete doomed file (NOTE: this call also stats)
- err = GetFSSpecFromPath(aDoomedFile, &doomSpec);
- if (err == noErr)
- {
- // (will even try to delete a dir with this name)
- err = FSpDelete(&doomSpec);
-
- // if deletion failed tell user to try again later
- if (err != noErr)
- return TRY_LATER;
- }
-
- // get the target dir spec (parent directory of doomed file)
- err = FSMakeFSSpec(doomSpec.vRefNum, doomSpec.parID, "\p", &tgtDirSpec);
- if (err == noErr)
- {
- // now try and move replacment file to path of doomed file
- err = FSpMoveRename(&replSpec, &tgtDirSpec, doomSpec.name);
- if (err != noErr)
- {
- // if move failed tell user to try agian later
- return TRY_LATER;
- }
- }
-
- return DONE;
-}
-
-
-#pragma mark -
-
-//----------------------------------------------------------------------------
-// Routines for recovery on reboot
-//----------------------------------------------------------------------------
-OSErr
-GetProgramSpec(FSSpecPtr aProgSpec)
-{
- OSErr err = noErr;
- ProcessSerialNumber psn;
- ProcessInfoRec pInfo;
-
- if (!aProgSpec)
- return paramErr;
-
- /* get cwd based on curr ps info */
- if (!(err = GetCurrentProcess(&psn)))
- {
- pInfo.processName = nil;
- pInfo.processAppSpec = aProgSpec;
- pInfo.processInfoLength = (sizeof(ProcessInfoRec));
-
- err = GetProcessInformation(&psn, &pInfo);
- }
-
- return err;
-}
-
-void
-PutAliasInStartupItems(FSSpecPtr aAlias)
-{
- OSErr err;
- FSSpec fsProg, fsAlias;
- long strtDirID = 0;
- short strtVRefNum = 0;
- FInfo info;
- AliasHandle aliasH;
-
- if (!aAlias)
- return;
-
- // find cwd
- err = GetProgramSpec(&fsProg);
- if (err != noErr)
- return; // fail silently
-
- // get startup items folder
- err = FindFolder(kOnSystemDisk, kStartupFolderType, kCreateFolder,
- &strtVRefNum, &strtDirID);
- if (err != noErr)
- return;
-
- // check that an alias to ourselves doesn't already
- // exist in the Startup Items folder
- err = FSMakeFSSpec(strtVRefNum, strtDirID, fsProg.name, &fsAlias);
- if (err == noErr)
- {
- // one's already there; not sure it's us so delete and recreate
- // (being super paranoid; but hey it's a mac)
- err = FSpDelete(&fsAlias);
- if (err != noErr)
- return; // fail silently
- }
-
- // create the alias file
- err = NewAliasMinimal(&fsProg, &aliasH);
- if (err != noErr)
- return;
-
- FSpGetFInfo(&fsProg, &info);
- FSpCreateResFile(&fsAlias, info.fdCreator, info.fdType, smRoman);
- short refNum = FSpOpenResFile(&fsAlias, fsRdWrPerm);
- if (refNum != -1)
- {
- UseResFile(refNum);
- AddResource((Handle)aliasH, rAliasType, 0, fsAlias.name);
- ReleaseResource((Handle)aliasH);
- UpdateResFile(refNum);
- CloseResFile(refNum);
- }
- else
- {
- ReleaseResource((Handle)aliasH);
- FSpDelete(&fsAlias);
- return; // non-fatal error
- }
-
- // mark newly created file as an alias file
- FSpGetFInfo(&fsAlias, &info);
- info.fdFlags |= kIsAlias;
- FSpSetFInfo(&fsAlias, &info);
-
- *aAlias = fsAlias;
-}
-
-void
-RemoveAliasFromStartupItems(FSSpecPtr aAlias)
-{
- // try to delete the alias
- FSpDelete(aAlias);
-}
-
-
-#pragma mark -
-
-//----------------------------------------------------------------------------
-// Apple event handlers to be installed
-//----------------------------------------------------------------------------
-
-static pascal OSErr DoAEOpenApplication(const AppleEvent * theAppleEvent, AppleEvent * replyAppleEvent, long refCon)
-{
-#pragma unused (theAppleEvent, replyAppleEvent, refCon)
- return noErr;
-}
-
-static pascal OSErr DoAEOpenDocuments(const AppleEvent * theAppleEvent, AppleEvent * replyAppleEvent, long refCon)
-{
-#pragma unused (theAppleEvent, replyAppleEvent, refCon)
- return errAEEventNotHandled;
-}
-
-static pascal OSErr DoAEPrintDocuments(const AppleEvent * theAppleEvent, AppleEvent * replyAppleEvent, long refCon)
-{
-#pragma unused (theAppleEvent, replyAppleEvent, refCon)
- return errAEEventNotHandled;
-}
-
-static pascal OSErr DoAEQuitApplication(const AppleEvent * theAppleEvent, AppleEvent * replyAppleEvent, long refCon)
-{
-#pragma unused (theAppleEvent, replyAppleEvent, refCon)
- gQuitFlag = true;
- return noErr;
-}
-
-
-//----------------------------------------------------------------------------
-// install Apple event handlers
-//----------------------------------------------------------------------------
-
-static void InitAppleEventsStuff(void)
-{
- OSErr retCode;
-
- if (gAppleEventsFlag) {
-
- retCode = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
- NewAEEventHandlerUPP(DoAEOpenApplication), 0, false);
-
- if (retCode == noErr)
- retCode = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
- NewAEEventHandlerUPP(DoAEOpenDocuments), 0, false);
-
- if (retCode == noErr)
- retCode = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
- NewAEEventHandlerUPP(DoAEPrintDocuments), 0, false);
- if (retCode == noErr)
- retCode = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
- NewAEEventHandlerUPP(DoAEQuitApplication), 0, false);
-
- if (retCode != noErr) DebugStr("\pInstall event handler failed");
- // a better way to indicate an error is to post a notification
- }
-}
-
-
-//----------------------------------------------------------------------------
-// high-level event dispatching
-//----------------------------------------------------------------------------
-
-static void DoHighLevelEvent(EventRecord * theEventRecPtr)
-{
- (void) AEProcessAppleEvent(theEventRecPtr);
-}
-
-
-#pragma mark -
-
-void main(void)
-{
- OSErr retCode;
- long gestResponse;
- FSSpec aliasToSelf;
- FSSpec fsCleanupReg;
-
- EventRecord mainEventRec;
- Boolean eventFlag, bDone = false, bHaveCleanupReg = false;
-
- HREG reg;
- int rv = DONE;
-
-#if !TARGET_CARBON
- // initialize QuickDraw globals
- InitGraf(&qd.thePort);
-#endif
-
- // initialize application globals
- gQuitFlag = false;
- gSleepVal = kSleepMax;
-
- // is the Apple Event Manager available?
- retCode = Gestalt(gestaltAppleEventsAttr, &gestResponse);
- if (retCode == noErr &&
- (gestResponse & (1 << gestaltAppleEventsPresent)) != 0)
- gAppleEventsFlag = true;
- else gAppleEventsFlag = false;
-
- // install Apple event handlers
- InitAppleEventsStuff();
-
- // put an alias to ourselves in the Startup Items folder
- // so that if we are shutdown before finishing we do our
- // tasks at startup
- FSMakeFSSpec(0, 0, "\p", &aliasToSelf); // initialize
- PutAliasInStartupItems(&aliasToSelf);
-
- if ( REGERR_OK == NR_StartupRegistry() )
- {
- char *regName = "";
- Boolean regNameAllocd = false;
- Handle pathH = 0;
- short pathLen = 0;
-
- // check if XPICleanup data file exists
- retCode = GetCleanupReg(&fsCleanupReg);
- if (retCode == noErr)
- {
- bHaveCleanupReg = true;
-
- // get full path to give to libreg open routine
- retCode = FSpGetFullPath(&fsCleanupReg, &pathLen, &pathH);
- if (retCode == noErr && pathH)
- {
- HLock(pathH);
- if (*pathH)
- {
- regName = (char *) malloc(sizeof(char) * (pathLen + 1));
- if (regName)
- regNameAllocd = true;
- else
- retCode = memFullErr;
- strncpy(regName, *pathH, pathLen);
- *(regName + pathLen) = 0;
- }
- HUnlock(pathH);
- DisposeHandle(pathH);
- }
- }
-
- if ( (retCode == noErr) && (REGERR_OK == NR_RegOpen(regName, ®)) )
- {
- // main event loop
-
- while (!gQuitFlag)
- {
- eventFlag = WaitNextEvent(everyEvent, &mainEventRec, gSleepVal, nil);
-
- if (mainEventRec.what == kHighLevelEvent)
- DoHighLevelEvent(&mainEventRec);
-
- rv = PerformScheduledTasks(reg);
- if (rv == DONE)
- {
- bDone = true;
- gQuitFlag = true;
- }
- }
- NR_RegClose(®);
- NR_ShutdownRegistry();
- }
-
- if (regNameAllocd)
- free(regName);
- }
-
- // clean up the alias to ouselves since we have
- // completed our tasks successfully
- if (bDone)
- {
- if (bHaveCleanupReg)
- FSpDelete(&fsCleanupReg);
- RemoveAliasFromStartupItems(&aliasToSelf);
- }
-}
-
deleted file mode 100644
--- a/xpinstall/cleanup/InstallCleanupOS2.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- *
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Don Bragg <dbragg@netscape.com>
- * IBM Corp.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "InstallCleanup.h"
-#include "InstallCleanupDefines.h"
-#define INCL_DOSERRORS
-#define INCL_DOS
-#include <os2.h>
-#include <string.h>
-#include <sys/stat.h>
-//----------------------------------------------------------------------------
-// Native OS/2 file deletion function
-//----------------------------------------------------------------------------
-int NativeDeleteFile(const char* aFileToDelete)
-{
- struct stat st;
- if (stat(aFileToDelete, &st) != 0)
- {
- return DONE;// No file to delete, do nothing.
- }
- else
- {
- if(DosDelete(aFileToDelete) != NO_ERROR)
- return TRY_LATER;
- }
- return DONE;
-}
-
-//----------------------------------------------------------------------------
-// Native OS/2 file replacement function
-//----------------------------------------------------------------------------
-int NativeReplaceFile(const char* replacementFile, const char* doomedFile )
-{
- // replacement file must exist, doomed file doesn't have to
- struct stat st;
- if (stat(replacementFile, &st) != 0)
- return DONE;
-
- // don't have to do anything if the files are the same
- if (stricmp(replacementFile, doomedFile) == 0)
- return DONE;
-
- if (DosDelete(doomedFile) != NO_ERROR)
- {
- if (stat(doomedFile, &st) == 0)
- return TRY_LATER;
- }
-
- // doomedFile is gone move new file into place
- if (DosMove(replacementFile, doomedFile) != NO_ERROR)
- return TRY_LATER; // this shouldn't happen
-
- return DONE;
-}
-
-int main(int argc, char *argv[], char *envp[])
-{
- HREG reg;
- BOOL foundSpecialFile = FALSE;
- struct stat st;
-
- int status = DONE;
-
- if ( REGERR_OK == NR_StartupRegistry())
- {
- char regFilePath[CCHMAXPATH];
-
- strcpy(regFilePath, argv[0]);
- char* lastSlash = strrchr(regFilePath, '\\');
- if (lastSlash) {
- // path does contain backslash
- lastSlash++;
- *lastSlash = 0; // strip off the executable name
- } else {
- // no backslash in path, just strip off everything
- *regFilePath = 0;
- }
- strcat(regFilePath, CLEANUP_REGISTRY); // append reg file name
-
- if (stat(regFilePath, &st) != 0)
- strcpy(regFilePath, ""); // an empty reg file tells RegOpen to get the "default"
- else
- foundSpecialFile = TRUE;
-
- if ( REGERR_OK == NR_RegOpen(regFilePath, ®) )
- {
- int numAttempts = 0;
- do
- {
- status = PerformScheduledTasks(reg);
- if (status != DONE) {
- DosSleep(1000); // Sleep for 1 second
- numAttempts++;
- }
- } while ((status == TRY_LATER) && numAttempts <= 5);
-
- NR_RegClose(®);
- }
- NR_ShutdownRegistry();
- if (status == DONE) {
- DosDelete(regFilePath);
- }
- }
- return(0);
-}
-
deleted file mode 100644
--- a/xpinstall/cleanup/InstallCleanupUnix.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Don Bragg <dbragg@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-#include "InstallCleanup.h"
-#include <sys/stat.h>
-#include <unistd.h>
-#include <string.h>
-
-//----------------------------------------------------------------------------
-// Native Unix file deletion function
-//----------------------------------------------------------------------------
-int NativeDeleteFile(const char* aFileToDelete)
-{
- struct stat fileStack;
- if (stat(aFileToDelete, &fileStack) != 0)
- {
- return DONE;// No file to delete, do nothing.
- }
- else
- {
- if(unlink(aFileToDelete) != 0)
- return TRY_LATER;
- }
- return DONE;
-}
-
-//----------------------------------------------------------------------------
-// Native Unix file replacement function
-//----------------------------------------------------------------------------
-int NativeReplaceFile(const char* replacementFile, const char* doomedFile )
-{
- struct stat fileStack;
-
- // replacement file must exist, doomed file doesn't have to
- if (stat(replacementFile, &fileStack) != 0)
- return DONE;
-
- // don't have to do anything if the files are the same
- if (strcmp(replacementFile, doomedFile) == 0)
- return DONE;
-
- if (unlink(doomedFile) != 0)
- {
- if (stat(doomedFile, &fileStack) == 0)
- return TRY_LATER;
- }
- else
- {
- // doomedFile is gone move new file into place
- if (rename(replacementFile, doomedFile) != 0)
- return TRY_LATER; // this shouldn't happen
- }
-
- return DONE;
-}
-
-int main(int argc,char* argv[])
-{
- HREG reg;
- int status = DONE;
- struct stat fileStack;
-
- if ( REGERR_OK == NR_StartupRegistry())
- {
- char regFilePath[256];
- strcpy(regFilePath, argv[0]);
- strcat(regFilePath, ".dat");
- if ( stat(regFilePath, &fileStack) != 0)
- regFilePath[0] = '\0';
- if ( REGERR_OK == NR_RegOpen(regFilePath, ®) )
- {
- do {
- status = PerformScheduledTasks(reg);
- if (status != DONE)
- sleep(1);
- } while (status == TRY_LATER);
- NR_RegClose(®);
- }
- NR_ShutdownRegistry();
- unlink(regFilePath);
- }
- return(0);
-}
-
deleted file mode 100644
--- a/xpinstall/cleanup/InstallCleanupWin.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Navigator.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corp.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Don Bragg <dbragg@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "InstallCleanup.h"
-#include "InstallCleanupDefines.h"
-#include <windows.h>
-#include <string.h>
-//----------------------------------------------------------------------------
-// Native Windows file deletion function
-//----------------------------------------------------------------------------
-int NativeDeleteFile(const char* aFileToDelete)
-{
- if (GetFileAttributes(aFileToDelete) == 0xFFFFFFFF)
- {
- return DONE;// No file to delete, do nothing.
- }
- else
- {
- if(!DeleteFile(aFileToDelete))
- return TRY_LATER;
- }
- return DONE;
-}
-
-//----------------------------------------------------------------------------
-// Native Windows file replacement function
-//----------------------------------------------------------------------------
-int NativeReplaceFile(const char* replacementFile, const char* doomedFile )
-{
- // replacement file must exist, doomed file doesn't have to
- if (GetFileAttributes(replacementFile) == 0xFFFFFFFF)
- return DONE;
-
- // don't have to do anything if the files are the same
- if (CompareString(LOCALE_SYSTEM_DEFAULT,
- NORM_IGNORECASE | SORT_STRINGSORT,
- replacementFile, -1,
- doomedFile, -1) == CSTR_EQUAL)
- return DONE;
-
- if (!DeleteFile(doomedFile))
- {
- if (GetFileAttributes(doomedFile) != 0xFFFFFFFF) // file exists
- return TRY_LATER;
- }
-
- // doomedFile is gone move new file into place
- if (!MoveFile(replacementFile, doomedFile))
- return TRY_LATER; // this shouldn't happen
-
- return DONE;
-}
-
-
-int WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR args, int)
-{
- HREG reg;
- HKEY hkRunOnceHandle;
- DWORD dwDisp;
- bool foundSpecialFile = FALSE;
-
- int status = DONE;
-
- if ( REGERR_OK == NR_StartupRegistry())
- {
- DWORD charsWritten;
- char appPath[_MAX_PATH];
- charsWritten = GetModuleFileName(NULL, appPath, _MAX_PATH);
- if (charsWritten > 0)
- {
- char regFilePath[_MAX_PATH];
-
- strcpy(regFilePath, appPath);
- char* lastSlash = strrchr(regFilePath, '\\');
- if (lastSlash) {
- // path does contain backslash
- lastSlash++;
- *lastSlash = 0; // strip off the executable name
- } else {
- // no backslash in path, just strip off everything
- *regFilePath = 0;
- }
- strcat(regFilePath, CLEANUP_REGISTRY); //append reg file name
-
- if ( GetFileAttributes(regFilePath) == 0xFFFFFFFF ) // file doesn't exist
- strcpy(regFilePath, ""); // an empty reg file tells RegOpen to get the "default"
- else
- foundSpecialFile = TRUE;
-
- if ( REGERR_OK == NR_RegOpen(regFilePath, ®) )
- {
- RegCreateKeyEx(HKEY_CURRENT_USER,
- "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce",
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- KEY_WRITE,
- NULL,
- &hkRunOnceHandle,
- &dwDisp);
-
- LPCTSTR cleanupKeyName = "mozilla_cleanup";
-
- RegSetValueEx(hkRunOnceHandle,
- cleanupKeyName,
- 0,
- REG_SZ,
- (const unsigned char*)appPath,
- strlen(appPath));
-
- do
- {
- status = PerformScheduledTasks(reg);
- if (status != DONE)
- Sleep(1000); // Sleep for 1 second
- } while (status == TRY_LATER);
-
- RegDeleteValue(hkRunOnceHandle, cleanupKeyName);
- NR_RegClose(®);
- }
- NR_ShutdownRegistry();
- DeleteFile(regFilePath);
- }
- }
- return(0);
-}
-
deleted file mode 100644
--- a/xpinstall/cleanup/Makefile.in
+++ /dev/null
@@ -1,96 +0,0 @@
-#
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is Mozilla Communicator client code, released
-# March 31, 1998.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Samir Gehani <sgehani@netscape.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either of the GNU General Public License Version 2 or later (the "GPL"),
-# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-DEPTH = ../..
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE = xpinstall
-PROGRAM = xpicleanup$(BIN_SUFFIX)
-GRE_MODULE = 1
-REQUIRES = libreg \
- $(NULL)
-
-CPPSRCS = \
- InstallCleanup.cpp \
- $(NULL)
-
-EXPORTS = InstallCleanupDefines.h \
- $(NULL)
-
-ifeq ($(OS_ARCH),OS2)
-CPPSRCS += InstallCleanupOS2.cpp
-else
-ifeq ($(OS_ARCH),WINNT)
-CPPSRCS += InstallCleanupWin.cpp
-MOZ_WINCONSOLE = 0
-USE_STATIC_LIBS = 1
-else
-CPPSRCS += InstallCleanupUnix.cpp
-endif
-endif
-
-LIBS = \
- $(DEPTH)/modules/libreg/standalone/$(LIB_PREFIX)mozregsa_s.$(LIB_SUFFIX) \
- $(NULL)
-
-DEFINES += -DSTANDALONE_REGISTRY
-
-include $(topsrcdir)/config/rules.mk
-
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
-LIBS += $(DEPTH)/xpcom/MoreFiles/$(LIB_PREFIX)macmorefiles_s.$(LIB_SUFFIX)
-LDFLAGS += $(TK_LIBS)
-endif
-
-ifeq ($(OS_ARCH),WINNT)
-ifndef GNU_CC
-LDFLAGS += /SUBSYSTEM:WINDOWS
-endif
-endif
-
-libs::
- $(INSTALL) $(srcdir)/cmessage.txt $(DIST)/bin/res
-
-install::
- $(SYSINSTALL) $(IFLAGS1) $(srcdir)/cmessage.txt $(DESTDIR)$(mozappdir)/res
-
deleted file mode 100644
--- a/xpinstall/cleanup/cmessage.txt
+++ /dev/null
@@ -1,1 +0,0 @@
-The program must close to allow a previous installation attempt to complete. Please restart.
\ No newline at end of file
--- a/xpinstall/public/Makefile.in
+++ b/xpinstall/public/Makefile.in
@@ -18,16 +18,17 @@
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Daniel Veditz <dveditz@netscape.com>
# Douglas Turner <dougt@netscape.com>
+# Dave Townsend <dtownsend@oxymoronical.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
@@ -46,26 +47,21 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = xpinstall
GRE_MODULE = 1
XPIDLSRCS = \
nsIXPIDialogService.idl \
nsIXPIProgressDialog.idl \
- nsIXPINotifier.idl \
nsIXPInstallManager.idl \
nsIXPIInstallInfo.idl \
- nsPIXPIProxy.idl \
- nsPIXPIStubHook.idl \
nsPICertNotification.idl \
$(NULL)
EXPORTS = \
nsIDOMInstallTriggerGlobal.h \
- nsIDOMInstallVersion.h \
nsSoftwareUpdateIIDs.h \
- nsISoftwareUpdate.h \
$(NULL)
PREF_JS_EXPORTS = $(srcdir)/xpinstall.js
include $(topsrcdir)/config/rules.mk
--- a/xpinstall/public/nsIDOMInstallTriggerGlobal.h
+++ b/xpinstall/public/nsIDOMInstallTriggerGlobal.h
@@ -15,16 +15,17 @@
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
+ * Dave Townsend <dtownsend@oxymoronical.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
@@ -41,18 +42,18 @@
#include "nsISupports.h"
#include "nsString.h"
#include "nsIScriptContext.h"
#include "nsXPITriggerInfo.h"
#include "nsIXPIInstallInfo.h"
#define NS_IDOMINSTALLTRIGGERGLOBAL_IID \
- { 0xe8c7941c, 0xaaa0, 0x4faf, \
- {0x83, 0xe8, 0x01, 0xbe, 0x8b, 0xbe, 0x8a, 0x57}}
+ { 0x23bb93a4, 0xdaee, 0x4a47, \
+ {0x87, 0xe76, 0xb1, 0x72, 0x35, 0x86, 0x2d, 0xac}}
class nsIDOMInstallTriggerGlobal : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMINSTALLTRIGGERGLOBAL_IID)
enum {
NOT_FOUND = -5,
MAJOR_DIFF = 4,
MINOR_DIFF = 3,
@@ -64,28 +65,16 @@ public:
NS_IMETHOD GetOriginatingURI(nsIScriptGlobalObject* aGlobalObject, nsIURI * *aUri)=0;
NS_IMETHOD UpdateEnabled(nsIScriptGlobalObject* aGlobalObject, PRBool aUseWhitelist, PRBool* aReturn)=0;
NS_IMETHOD UpdateEnabled(nsIURI* aURI, PRBool aUseWhitelist, PRBool* aReturn)=0;
NS_IMETHOD StartInstall(nsIXPIInstallInfo* aInstallInfo, PRBool* aReturn)=0;
- NS_IMETHOD Install(nsIScriptGlobalObject* globalObject, nsXPITriggerInfo* aInfo, PRBool* aReturn)=0;
-
- NS_IMETHOD InstallChrome(nsIScriptGlobalObject* globalObject, PRUint32 aType, nsXPITriggerItem* aItem, PRBool* aReturn)=0;
-
- NS_IMETHOD StartSoftwareUpdate(nsIScriptGlobalObject* globalObject, const nsString& aURL, PRInt32 aFlags, PRBool* aReturn)=0;
-
- NS_IMETHOD CompareVersion(const nsString& aRegName, PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild, PRInt32* aReturn)=0;
- NS_IMETHOD CompareVersion(const nsString& aRegName, const nsString& aVersion, PRInt32* aReturn)=0;
- NS_IMETHOD CompareVersion(const nsString& aRegName, nsIDOMInstallVersion* aVersion, PRInt32* aReturn)=0;
-
- NS_IMETHOD GetVersion(const nsString& component, nsString& version)=0;
-
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMInstallTriggerGlobal,
NS_IDOMINSTALLTRIGGERGLOBAL_IID)
extern nsresult NS_InitInstallTriggerGlobalClass(nsIScriptContext *aContext, void **aPrototype);
extern "C" nsresult NS_NewScriptInstallTriggerGlobal(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
deleted file mode 100644
--- a/xpinstall/public/nsIDOMInstallVersion.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-/* AUTO-GENERATED. DO NOT EDIT!!! */
-
-#ifndef nsIDOMInstallVersion_h__
-#define nsIDOMInstallVersion_h__
-
-#include "nsISupports.h"
-#include "nsString.h"
-#include "nsIScriptContext.h"
-
-class nsIDOMInstallVersion;
-
-#define NS_IDOMINSTALLVERSION_IID \
- { 0x18c2f986, 0xb09f, 0x11d2, \
- {0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53}}
-
-class nsIDOMInstallVersion : public nsISupports {
-public:
- NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMINSTALLVERSION_IID)
- enum {
- EQUAL = 0,
- BLD_DIFF = 1,
- BLD_DIFF_MINUS = -1,
- REL_DIFF = 2,
- REL_DIFF_MINUS = -2,
- MINOR_DIFF = 3,
- MINOR_DIFF_MINUS = -3,
- MAJOR_DIFF = 4,
- MAJOR_DIFF_MINUS = -4
- };
-
- NS_IMETHOD GetMajor(PRInt32* aMajor)=0;
- NS_IMETHOD SetMajor(PRInt32 aMajor)=0;
-
- NS_IMETHOD GetMinor(PRInt32* aMinor)=0;
- NS_IMETHOD SetMinor(PRInt32 aMinor)=0;
-
- NS_IMETHOD GetRelease(PRInt32* aRelease)=0;
- NS_IMETHOD SetRelease(PRInt32 aRelease)=0;
-
- NS_IMETHOD GetBuild(PRInt32* aBuild)=0;
- NS_IMETHOD SetBuild(PRInt32 aBuild)=0;
-
- NS_IMETHOD Init(const nsString& aVersionString)=0;
-
- NS_IMETHOD ToString(nsString& aReturn)=0;
-
- NS_IMETHOD CompareTo(nsIDOMInstallVersion* aVersionObject, PRInt32* aReturn)=0;
- NS_IMETHOD CompareTo(const nsString& aString, PRInt32* aReturn)=0;
- NS_IMETHOD CompareTo(PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild, PRInt32* aReturn)=0;
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMInstallVersion, NS_IDOMINSTALLVERSION_IID)
-
-#define NS_DECL_IDOMINSTALLVERSION \
- NS_IMETHOD GetMajor(PRInt32* aMajor); \
- NS_IMETHOD SetMajor(PRInt32 aMajor); \
- NS_IMETHOD GetMinor(PRInt32* aMinor); \
- NS_IMETHOD SetMinor(PRInt32 aMinor); \
- NS_IMETHOD GetRelease(PRInt32* aRelease); \
- NS_IMETHOD SetRelease(PRInt32 aRelease); \
- NS_IMETHOD GetBuild(PRInt32* aBuild); \
- NS_IMETHOD SetBuild(PRInt32 aBuild); \
- NS_IMETHOD Init(const nsString& aVersionString); \
- NS_IMETHOD ToString(nsString& aReturn); \
- NS_IMETHOD CompareTo(nsIDOMInstallVersion* aVersionObject, PRInt32* aReturn); \
- NS_IMETHOD CompareTo(const nsString& aString, PRInt32* aReturn); \
- NS_IMETHOD CompareTo(PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild, PRInt32* aReturn); \
-
-
-
-#define NS_FORWARD_IDOMINSTALLVERSION(_to) \
- NS_IMETHOD GetMajor(PRInt32* aMajor) { return _to##GetMajor(aMajor); } \
- NS_IMETHOD SetMajor(PRInt32 aMajor) { return _to##SetMajor(aMajor); } \
- NS_IMETHOD GetMinor(PRInt32* aMinor) { return _to##GetMinor(aMinor); } \
- NS_IMETHOD SetMinor(PRInt32 aMinor) { return _to##SetMinor(aMinor); } \
- NS_IMETHOD GetRelease(PRInt32* aRelease) { return _to##GetRelease(aRelease); } \
- NS_IMETHOD SetRelease(PRInt32 aRelease) { return _to##SetRelease(aRelease); } \
- NS_IMETHOD GetBuild(PRInt32* aBuild) { return _to##GetBuild(aBuild); } \
- NS_IMETHOD SetBuild(PRInt32 aBuild) { return _to##SetBuild(aBuild); } \
- NS_IMETHOD Init(const nsString& aVersionString) { return _to##Init(aVersionString); } \
- NS_IMETHOD ToString(nsString& aReturn) { return _to##ToString(aReturn); } \
- NS_IMETHOD CompareTo(nsIDOMInstallVersion* aVersionObject, PRInt32* aReturn) { return _to##CompareTo(aVersionObject, aReturn); } \
- NS_IMETHOD CompareTo(const nsString& aString, PRInt32* aReturn) { return _to##CompareTo(aString, aReturn); } \
- NS_IMETHOD CompareTo(PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild, PRInt32* aReturn) { return _to##CompareTo(aMajor, aMinor, aRelease, aBuild, aReturn); } \
-
-
-extern nsresult NS_InitInstallVersionClass(nsIScriptContext *aContext, void **aPrototype);
-
-extern "C" nsresult NS_NewScriptInstallVersion(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
-
-#endif // nsIDOMInstallVersion_h__
deleted file mode 100644
--- a/xpinstall/public/nsISoftwareUpdate.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Daniel Veditz <dveditz@netscape.com>
- * Douglas Turner <dougt@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef nsISoftwareUpdate_h__
-#define nsISoftwareUpdate_h__
-
-#include "nsISupports.h"
-#include "nsIFactory.h"
-
-#include "nsIXPINotifier.h"
-#include "nsCOMPtr.h"
-#include "nsIModule.h"
-#include "nsIGenericFactory.h"
-#include "nsILocalFile.h"
-#include "nsDirectoryServiceUtils.h"
-#include "nsDirectoryServiceDefs.h"
-
-#define NS_IXPINSTALLCOMPONENT_CONTRACTID "@mozilla.org/xpinstall;1"
-#define NS_IXPINSTALLCOMPONENT_CLASSNAME "Mozilla XPInstall Component"
-
-#define XPINSTALL_ENABLE_PREF "xpinstall.enabled"
-#define XPINSTALL_WHITELIST_ADD "xpinstall.whitelist.add"
-#define XPINSTALL_WHITELIST_ADD_103 "xpinstall.whitelist.add.103"
-#define XPINSTALL_WHITELIST_REQUIRED "xpinstall.whitelist.required"
-#define XPINSTALL_BLACKLIST_ADD "xpinstall.blacklist.add"
-
-
-#define XPI_NO_NEW_THREAD 0x1000
-
-#define NS_ISOFTWAREUPDATE_IID \
-{ 0xfc7c086f, \
- 0xdae0, \
- 0x45e0, \
- {0x99, 0x10, 0xd5, 0xda, 0x91, 0xc8, 0x27, 0x46}\
-}
-
-class nsIPrincipal;
-
-class nsISoftwareUpdate : public nsISupports
-{
- public:
- NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISOFTWAREUPDATE_IID)
-
- NS_IMETHOD InstallJar(nsIFile* localFile,
- const PRUnichar* URL,
- const PRUnichar* arguments,
- nsIPrincipal* aPrincipalDisplayed,
- PRUint32 flags,
- nsIXPIListener* aListener = 0) = 0;
-
- NS_IMETHOD InstallChrome(PRUint32 aType,
- nsIFile* aFile,
- const PRUnichar* URL,
- const PRUnichar* aName,
- PRBool aSelect,
- nsIXPIListener* aListener = 0) = 0;
-
- NS_IMETHOD RegisterListener(nsIXPIListener *aListener) = 0;
-
- /* FIX: these should be in a private interface */
- virtual void InstallJarCallBack() = 0;
- NS_IMETHOD GetMasterListener(nsIXPIListener **aListener) = 0;
- NS_IMETHOD SetActiveListener(nsIXPIListener *aListener) = 0;
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsISoftwareUpdate, NS_ISOFTWAREUPDATE_IID)
-
-#endif // nsISoftwareUpdate_h__
-
deleted file mode 100644
--- a/xpinstall/public/nsIUpdateNotification.idl
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsISupports.idl"
-
-[uuid(6cb61472-042c-11d4-ac85-00c04fa0d26b)]
-interface nsIUpdateNotification : nsISupports
-{
- void displayUpdateDialog();
-};
deleted file mode 100644
--- a/xpinstall/public/nsIXPINotifier.idl
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2000
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Douglas Turner <dougt@netscape.com>
- * Daniel Veditz <dveditz@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsISupports.idl"
-
-[uuid(eea90d40-b059-11d2-915e-c12b696c9333)]
-interface nsIXPIListener : nsISupports
-{
- void onInstallStart(in wstring URL);
- void onInstallDone(in wstring URL, in long status);
- void onPackageNameSet(in wstring URL, in wstring UIPackageName, in wstring version);
- void onItemScheduled(in wstring message );
- void onFinalizeProgress(in wstring message, in long itemNum, in long totNum );
- void onLogComment(in wstring comment);
-};
deleted file mode 100644
--- a/xpinstall/public/nsPIXPIProxy.idl
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998-2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Daniel Veditz <dveditz@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsISupports.idl"
-
-/**
- * nsPIXPIProxy
- *
- * Used to handle miscellaneous things that XPInstall needs to perform
- * over on the main UI thread.
- */
-[scriptable,uuid(6F9D2890-167D-11d5-8DAF-000064657374)]
-interface nsPIXPIProxy : nsISupports
-{
- void refreshPlugins(in boolean reloadPages);
- void notifyRestartNeeded();
-
- /**
- * Puts up an alert dialog with an OK button.
- *
- * @param title
- * Text to appear in the title of the dialog.
- * @param text
- * Text to appear in the body of the dialog.
- */
- void alert(in wstring title, in wstring text);
-
- /**
- * Puts up a dialog with up to 3 buttons and an optional, labeled checkbox.
- *
- * @param aDialogTitle
- * Text to appear in the title of the dialog.
- * @param aText
- * Text to appear in the body of the dialog.
- * @param aButtonFlags
- * A combination of Button Flags.
- * @param aButton0Title
- * Used when button 0 uses TITLE_IS_STRING
- * @param aButton1Title
- * Used when button 1 uses TITLE_IS_STRING
- * @param aButton2Title
- * Used when button 2 uses TITLE_IS_STRING
- * @param aCheckMsg
- * Text to appear with the checkbox. Null if no checkbox.
- * @param aCheckState
- * Contains the initial checked state of the checkbox when this method
- * is called and the final checked state after this method returns.
- *
- * @return index of the button pressed.
- *
- * Buttons are numbered 0 - 2. The implementation can decide whether the
- * sequence goes from right to left or left to right. Button 0 is the
- * default button unless one of the Button Default Flags is specified.
- *
- * The value for aButtonFlags is constructed using the constants defined by
- * nsIPromptService.
- *
- * @see nsIPromptService
- */
- PRInt32 confirmEx(in wstring aDialogTitle,
- in wstring aText,
- in unsigned long aButtonFlags,
- in wstring aButton0Title,
- in wstring aButton1Title,
- in wstring aButton2Title,
- in wstring aCheckMsg,
- inout boolean aCheckState);
-};
deleted file mode 100644
--- a/xpinstall/public/nsPIXPIStubHook.idl
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Daniel Veditz <dveditz@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsISupports.idl"
-
-interface nsIFile;
-
-/**
- * nsPIXPIStubHook
- *
- * Used by the Install Wizard to point at the eventual target dir and
- * override the default assumption that the wizard itself is the program.
- */
-[uuid(089929F0-4ED9-11d3-ABDD-000064657374)]
-interface nsPIXPIStubHook : nsISupports
-{
- void StubInitialize(in nsIFile dir, in string logName);
-};
--- a/xpinstall/public/nsSoftwareUpdateIIDs.h
+++ b/xpinstall/public/nsSoftwareUpdateIIDs.h
@@ -17,16 +17,17 @@
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Daniel Veditz <dveditz@netscape.com>
* Douglas Turner <dougt@netscape.com>
+ * Dave Townsend <dtownsend@oxymoronical.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
@@ -35,48 +36,24 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsSoftwareUpdateIIDs_h___
#define nsSoftwareUpdateIIDs_h___
-#define NS_SoftwareUpdate_CID \
-{ /* 18c2f989-b09f-11d2-bcde-00805f0e1353 */ \
- 0x18c2f989, \
- 0xb09f, \
- 0x11d2, \
- {0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
-}
-
-#define NS_SoftwareUpdateInstall_CID \
-{ /* 18c2f98b-b09f-11d2-bcde-00805f0e1353 */ \
- 0x18c2f98b, \
- 0xb09f, \
- 0x11d2, \
- {0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
-}
-
#define NS_SoftwareUpdateInstallTrigger_CID \
{ /* 18c2f98d-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f98d, \
0xb09f, \
0x11d2, \
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
-#define NS_SoftwareUpdateInstallVersion_CID \
-{ /* 18c2f98f-b09f-11d2-bcde-00805f0e1353 */ \
- 0x18c2f98f, \
- 0xb09f, \
- 0x11d2, \
- {0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
-}
-
#define NS_XPInstallManager_CID \
{ /* {6a4d4c1e-a74a-4320-8124-16233a0183d6} */ \
0x6a4d4c1e, \
0xa74a, \
0x4320, \
{ 0x81, 0x24, 0x16, 0x23, 0x3a, 0x1, 0x83, 0xd6} \
}
deleted file mode 100644
--- a/xpinstall/res/Makefile.in
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either of the GNU General Public License Version 2 or later (the "GPL"),
-# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-DEPTH = ../..
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-include $(topsrcdir)/config/rules.mk
-
deleted file mode 100644
--- a/xpinstall/res/content/SoftwareUpdate-Source-1.rdf
+++ /dev/null
@@ -1,64 +0,0 @@
-<?xml version="1.0"?> <!-- -*- Mode: SGML -*- -->
-<!-- ***** BEGIN LICENSE BLOCK *****
- - Version: MPL 1.1/GPL 2.0/LGPL 2.1
- -
- - The contents of this file are subject to the Mozilla Public License Version
- - 1.1 (the "License"); you may not use this file except in compliance with
- - the License. You may obtain a copy of the License at
- - http://www.mozilla.org/MPL/
- -
- - Software distributed under the License is distributed on an "AS IS" basis,
- - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- - for the specific language governing rights and limitations under the
- - License.
- -
- - The Original Code is Mozilla Communicator.
- -
- - The Initial Developer of the Original Code is
- - Netscape Communications Corp.
- - Portions created by the Initial Developer are Copyright (C) 1999
- - the Initial Developer. All Rights Reserved.
- -
- - Contributor(s):
- - Doug Turner <dougt@netscape.com>
- - Chris Waterson <waterson@netscape.com>
- -
- - Alternatively, the contents of this file may be used under the terms of
- - either of the GNU General Public License Version 2 or later (the "GPL"),
- - or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- - in which case the provisions of the GPL or the LGPL are applicable instead
- - of those above. If you wish to allow use of your version of this file only
- - under the terms of either the GPL or the LGPL, and not to allow others to
- - use your version of this file under the terms of the MPL, indicate your
- - decision by deleting the provisions above and replace them with the notice
- - and other provisions required by the GPL or the LGPL. If you do not delete
- - the provisions above, a recipient may use your version of this file under
- - the terms of any one of the MPL, the GPL or the LGPL.
- -
- - ***** END LICENSE BLOCK ***** -->
-
-<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:NC="http://home.netscape.com/NC-rdf#">
-
- <RDF:Bag about="http://home.netscape.com/NC-rdf#SoftwareUpdateRoot">
- <RDF:li>
- <RDF:Bag about="http://home.netscape.com/NC-rdf#SoftwarePackages" NC:title="Test Updates" NC:url="http://www.netscape.com/people/dougt">
-
- <RDF:li>
- <RDF:Description ID="Update344">
- <NC:version>3.4.1.12</NC:version>
- <NC:registryKey>/AOL/</NC:registryKey>
- </RDF:Description>
- </RDF:li>
-
- <RDF:li>
- <RDF:Description ID="PGPPlugin345">
- <NC:version>1.1.2.0</NC:version>
- <NC:registryKey>/PGP/ROCKS/</NC:registryKey>
- </RDF:Description>
- </RDF:li>
-
- </RDF:Bag>
- </RDF:li>
- </RDF:Bag>
-</RDF:RDF>
deleted file mode 100644
--- a/xpinstall/res/content/SoftwareUpdates.rdf
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0"?> <!-- -*- Mode: SGML -*- -->
-<!-- ***** BEGIN LICENSE BLOCK *****
- - Version: MPL 1.1/GPL 2.0/LGPL 2.1
- -
- - The contents of this file are subject to the Mozilla Public License Version
- - 1.1 (the "License"); you may not use this file except in compliance with
- - the License. You may obtain a copy of the License at
- - http://www.mozilla.org/MPL/
- -
- - Software distributed under the License is distributed on an "AS IS" basis,
- - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- - for the specific language governing rights and limitations under the
- - License.
- -
- - The Original Code is Mozilla Communicator.
- -
- - The Initial Developer of the Original Code is
- - Netscape Communications Corp.
- - Portions created by the Initial Developer are Copyright (C) 1999
- - the Initial Developer. All Rights Reserved.
- -
- - Contributor(s):
- - Doug Turner <dougt@netscape.com>
- - Chris Waterson <waterson@netscape.com>
- -
- - Alternatively, the contents of this file may be used under the terms of
- - either of the GNU General Public License Version 2 or later (the "GPL"),
- - or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- - in which case the provisions of the GPL or the LGPL are applicable instead
- - of those above. If you wish to allow use of your version of this file only
- - under the terms of either the GPL or the LGPL, and not to allow others to
- - use your version of this file under the terms of the MPL, indicate your
- - decision by deleting the provisions above and replace them with the notice
- - and other provisions required by the GPL or the LGPL. If you do not delete
- - the provisions above, a recipient may use your version of this file under
- - the terms of any one of the MPL, the GPL or the LGPL.
- -
- - ***** END LICENSE BLOCK ***** -->
-
-<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:NC="http://home.netscape.com/NC-rdf#">
-
- <RDF:Bag about="http://home.netscape.com/NC-rdf#SoftwareUpdateDataSources">
- <RDF:li resource="chrome://communicator/content/xpinstall/SoftwareUpdate-Source-1.rdf" />
- </RDF:Bag>
-</RDF:RDF>
deleted file mode 100644
--- a/xpinstall/res/content/institems.js
+++ /dev/null
@@ -1,140 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- *
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-// dialog param block
-var gParam;
-var gBundle;
-
-function addTreeItem(num, aName, aUrl, aCertName)
-{
- // first column is the package name
- var item = document.createElement("description");
- item.setAttribute("value", aName);
- item.setAttribute("tooltiptext", aName);
- item.setAttribute("class", "confirmName");
- item.setAttribute("crop", "center");
-
- // second column is for the cert name
- var certName = document.createElement("description");
- var certNameValue = aCertName ? aCertName : gBundle.getString("Unsigned");
- certName.setAttribute("value", certNameValue);
- certName.setAttribute("tooltiptext", certNameValue);
- certName.setAttribute("crop", "center");
-
- // third column is the host serving the file
- var urltext = aUrl.replace(/^([^:]*:\/*[^\/]+).*/, "$1");
- var url = document.createElement("description");
- url.setAttribute("value", aUrl);
- url.setAttribute("tooltiptext", aUrl);
- url.setAttribute("class", "confirmURL");
- url.setAttribute("crop", "center");
-
- // create row and add it to the grid
- var row = document.createElement("row");
- row.appendChild(item);
- row.appendChild(certName);
- row.appendChild(url);
-
- document.getElementById("xpirows").appendChild(row);
-}
-
-function onLoad()
-{
- var row = 0;
- var moduleName, URL, IconURL, certName, numberOfDialogTreeElements;
-
- gBundle = document.getElementById("xpinstallBundle");
- gParam = window.arguments[0].QueryInterface(Components.interfaces.nsIDialogParamBlock);
-
- gParam.SetInt(0, 1); // Set the default return to Cancel
-
- numberOfDialogTreeElements = gParam.GetInt(1);
-
- for (var i=0; i < numberOfDialogTreeElements; i++)
- {
- moduleName = gParam.GetString(i);
- URL = gParam.GetString(++i);
- IconURL = gParam.GetString(++i); // Advance the enumeration, parameter is unused just now.
- certName = gParam.GetString(++i);
-
- addTreeItem(row++, moduleName, URL, certName);
- }
-
- // Move default+focus from |accept| to |cancel| button.
- var aButton = document.documentElement.getButton("accept");
- aButton.setAttribute("default", false);
- aButton.setAttribute("label", gBundle.getString("OK"));
- aButton.setAttribute("disabled", true);
-
- aButton = document.documentElement.getButton("cancel");
- aButton.focus();
- aButton.setAttribute("default", true);
-
- // start timer to re-enable buttons
- var delayInterval = 2000;
- try {
- var prefs = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch);
- delayInterval = prefs.getIntPref("security.dialog_enable_delay");
- } catch (e) {}
- setTimeout(reenableInstallButtons, delayInterval);
-}
-
-function reenableInstallButtons()
-{
- document.documentElement.getButton("accept").setAttribute("disabled", false);
-}
-
-function onAccept()
-{
- // set the accept button in the param block
- if (gParam)
- gParam.SetInt(0, 0);
-
- return true;
-}
-
-function onCancel()
-{
- // set the cancel button in the param block
- if (gParam)
- gParam.SetInt(0, 1);
-
- return true;
-}
deleted file mode 100644
--- a/xpinstall/res/content/institems.xul
+++ /dev/null
@@ -1,87 +0,0 @@
-<?xml version="1.0"?>
-
-<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is Mozilla Communicator client code.
-
- The Initial Developer of the Original Code is
- Netscape Communications Corporation.
- Portions created by the Initial Developer are Copyright (C) 1998-1999
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Don Bragg <dbragg@netscape.com>
- Dan Veditz <dveditz@netscape.com>
- Blake Ross <blakeross@telocity.com>
- HÃ¥kan Waara <hwaara@chello.se>
-
- Alternatively, the contents of this file may be used under the terms of
- either of the GNU General Public License Version 2 or later (the "GPL"),
- or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the GPL or the LGPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
-
-<?xml-stylesheet href="chrome://communicator/skin/xpinstall/xpinstall.css" type="text/css"?>
-<!DOCTYPE dialog SYSTEM "chrome://communicator/locale/xpinstall/institems.dtd">
-
-<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- onload="onLoad()"
- title="&dialog.title;"
- id="confirmDlg"
- style="width: 60em"
- buttons="accept,cancel"
- ondialogaccept="return onAccept();"
- ondialogcancel="return onCancel();">
-
- <script src="chrome://communicator/content/xpinstall/institems.js"/>
- <stringbundle id="xpinstallBundle" src="chrome://global/locale/xpinstall/xpinstall.properties"/>
-
- <hbox flex="1" align="center">
- <hbox align="center">
- <image id="alert-image" class="alert-icon"/>
- </hbox>
-
- <vbox id="confirmBox" flex="1">
- <description id="warn1" flex="1">
- &warningText.label;
- </description>
-
- <separator class="confirmSeparator"/>
-
- <grid id="confirmGrid" flex="1">
- <columns>
- <column id="xpiColumn" flex="1"/>
- <column id="certColumn" flex="1"/>
- <column id="urlColumn" flex="1"/>
- </columns>
- <rows id="xpirows">
- </rows>
- </grid>
-
- <separator class="confirmSeparator"/>
-
- <description id="warn2" flex="1">
- &warningText2.label;
- </description>
- </vbox>
- </hbox>
-</dialog>
deleted file mode 100644
--- a/xpinstall/res/content/updateNotification.xul
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0"?>
-
-<!DOCTYPE overlay SYSTEM "chrome://global/locale/updateNotification.dtd" >
-
-<overlay id="updateNotificationMenuID"
-xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
-<script type="application/x-javascript">
-
-function ShowUpdateFromResource( node )
-{
- var url = node.getAttribute('updateURL');
- dump (url + '\n' );
- //window.open( url );
-}
-
-</script>
-
-
-<menupopup id="taskPopup">
- <menu label="&updateNotification.label;" datasources="rdf:xpinstall-update-notifier" ref="http://home.netscape.com/NC-rdf#SoftwareNotificationRoot">
- <template>
- <rule>
- <menupopup>
- <menuitem uri="rdf:*" label="rdf:http://home.netscape.com/NC-rdf#name" updateURL="rdf:http://home.netscape.com/NC-rdf#url" oncommand="ShowUpdateFromResource( event.target )"/>
- </menupopup>
- </rule>
- </template>
- </menu>
- <menuseparator/>
-</menupopup>
-
-</overlay>
deleted file mode 100644
--- a/xpinstall/res/content/xpistatus.js
+++ /dev/null
@@ -1,190 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-var gManager;
-var gBundle;
-var gCanClose = false;
-var gCancelled = false;
-
-// implements nsIXPIProgressDialog
-var progressHooks =
-{
- onStateChange: function( aIndex, aState, aValue )
- {
- const state = Components.interfaces.nsIXPIProgressDialog;
- var status = document.getElementById("status"+aIndex);
- var progress = document.getElementById("progress"+aIndex);
-
- switch( aState ) {
- case state.DOWNLOAD_START:
- status.setAttribute("value",
- gBundle.getString("progress.downloading"));
- progress.setAttribute("value","0%");
- break;
-
- case state.DOWNLOAD_DONE:
- status.setAttribute("value",
- gBundle.getString("progress.downloaded"));
- progress.setAttribute("value","100%");
- break;
-
- case state.INSTALL_START:
- status.setAttribute("value",
- gBundle.getString("progress.installing"));
- progress.setAttribute("mode","undetermined");
- break;
-
- case state.INSTALL_DONE:
- progress.setAttribute("mode","determined");
- progress.hidden = true;
- var msg;
- try
- {
- msg = gBundle.getString("error"+aValue);
- }
- catch (e)
- {
- msg = gBundle.stringBundle.formatStringFromName(
- "unknown.error", [aValue], 1 );
- }
- status.setAttribute("value",msg);
- break;
-
- case state.DIALOG_CLOSE:
- // nsXPInstallManager is done with us, but we'll let users
- // dismiss the dialog themselves so they can see the status
- // (unless we're closing because the user cancelled)
- document.documentElement.getButton("accept").disabled = false;
- document.documentElement.getButton("cancel").disabled = true;
- document.documentElement.getButton("accept").focus();
- gCanClose = true;
-
- if (gCancelled)
- window.close();
-
- break;
- }
- },
-
- onProgress: function( aIndex, aValue, aMaxValue )
- {
- var percent = Math.round( 100 * (aValue/aMaxValue) );
- var node = document.getElementById("progress"+aIndex);
- node.setAttribute("value", percent);
- },
-
- QueryInterface: function( iid )
- {
- if (iid.equals(Components.interfaces.nsISupports) ||
- iid.equals(Components.interfaces.nsIXPIProgressDialog))
- return this;
-
- Components.returnCode = Components.results.NS_ERROR_NO_INTERFACE;
- return null;
- }
-}
-
-
-function onLoad()
-{
- document.documentElement.getButton("accept").disabled = true;
- document.documentElement.getButton("cancel").focus();
- gBundle = document.getElementById("xpinstallBundle");
-
- var param = window.arguments[0].QueryInterface(
- Components.interfaces.nsIDialogParamBlock );
- if ( !param )
- dump (" error getting param block interface \n");
-
- var i = 0;
- var row = 0;
- var numElements = param.GetInt(1);
- while ( i < numElements )
- {
- var moduleName = param.GetString(i++);
- var URL = param.GetString(i++);
- var IconURL = param.GetString(i++); // Advance the enumeration, parameter is unused just now.
- var certName = param.GetString(i++);
- addTreeItem(row++, moduleName, URL);
- }
-
- gManager = window.arguments[1];
-
- // inform nsXPInstallManager we're open for business
- gManager.observe( progressHooks, "xpinstall-progress", "open" );
-}
-
-function addTreeItem(aRow, aName, aUrl)
-{
- // first column is the package name
- var item = document.createElement("description");
- item.setAttribute("class", "packageName");
- item.setAttribute("id", "package"+aRow);
- item.setAttribute("value", aName);
- item.setAttribute("tooltiptext", aUrl);
-
- // second column is the status
- var status = document.createElement('description');
- status.setAttribute("class", "packageStatus");
- status.setAttribute("id", "status"+aRow);
- status.setAttribute("value", gBundle.getString("progress.queued"));
-
- // third row is a progress meter
- var progress = document.createElement("progressmeter");
- progress.setAttribute("class", "packageProgress");
- progress.setAttribute("id", "progress"+aRow);
- progress.setAttribute("value", "0%");
-
- // create row and add it to the grid
- var row = document.createElement("row");
- row.appendChild(item);
- row.appendChild(status);
- row.appendChild(progress);
- document.getElementById("xpirows").appendChild(row);
-}
-
-function onCancel()
-{
- gCancelled = true;
- if (gManager)
- gManager.observe( progressHooks, "xpinstall-progress", "cancel");
-
- // window is closed by native impl after cleanup
- return gCanClose;
-}
deleted file mode 100644
--- a/xpinstall/res/content/xpistatus.xul
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0"?>
-
-<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is Mozilla Communicator client code.
-
- The Initial Developer of the Original Code is
- Netscape Communications Corporation.
- Portions created by the Initial Developer are Copyright (C) 1998-2002
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Don Bragg (dbragg@netscape.com) 12/08/1999
- Blake Ross (BlakeR1234@aol.com) 7/05/2000
- Daniel Veditz <dveditz@netscape.com> 1/2002
-
- Alternatively, the contents of this file may be used under the terms of
- either of the GNU General Public License Version 2 or later (the "GPL"),
- or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the GPL or the LGPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
-
-<?xml-stylesheet href="chrome://communicator/skin/xpinstall/xpinstall.css" type="text/css"?>
-
-<!DOCTYPE dialog SYSTEM "chrome://communicator/locale/xpinstall/xpistatus.dtd">
-
-<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- title="&progressTitle.label;"
- onload="onLoad()"
- onclose="return gCanClose"
- id="statusDlg"
- style="width: 50em"
- ondialogcancel="return onCancel();"
->
-
- <script src="chrome://communicator/content/xpinstall/xpistatus.js"/>
-
- <stringbundle id="xpinstallBundle" src="chrome://global/locale/xpinstall/xpinstall.properties"/>
-
- <vbox id="mainProgressBox" flex="1">
- <groupbox id="progressGroup" orient="vertical" flex="1">
- <caption id="progressCaption" label="&group.caption;"/>
- <grid id="progressGrid" flex="1">
- <columns>
- <column id="xpiColumn" flex="3"/>
- <column id="statusColumn" flex="2"/>
- <column id="progressColumn"/>
- </columns>
- <rows id="xpirows">
- </rows>
- </grid>
- </groupbox>
- </vbox>
-
-</dialog>
deleted file mode 100644
--- a/xpinstall/res/jar.mn
+++ /dev/null
@@ -1,10 +0,0 @@
-comm.jar:
- content/communicator/xpinstall/xpistatus.xul (content/xpistatus.xul)
- content/communicator/xpinstall/xpistatus.js (content/xpistatus.js)
- content/communicator/xpinstall/institems.xul (content/institems.xul)
- content/communicator/xpinstall/institems.js (content/institems.js)
-
-en-US.jar:
- locale/en-US/global/xpinstall/xpinstall.properties (/toolkit/locales/en-US/chrome/global/xpinstall/xpinstall.properties)
- locale/en-US/communicator/xpinstall/xpistatus.dtd (locale/en-US/xpistatus.dtd)
- locale/en-US/communicator/xpinstall/institems.dtd (locale/en-US/institems.dtd)
deleted file mode 100644
--- a/xpinstall/res/locale/en-US/institems.dtd
+++ /dev/null
@@ -1,5 +0,0 @@
-<!-- extracted from institems.xul -->
-
-<!ENTITY dialog.title "Software Installation">
-<!ENTITY warningText.label "A web site is requesting permission to install">
-<!ENTITY warningText2.label "Malicious software can damage your computer or violate your privacy. You should only install software from sources that you trust.">
deleted file mode 100644
--- a/xpinstall/res/locale/en-US/xpistatus.dtd
+++ /dev/null
@@ -1,2 +0,0 @@
-<!ENTITY progressTitle.label "Software Installation">
-<!ENTITY group.caption "Download and installation status">
\ No newline at end of file
--- a/xpinstall/src/Makefile.in
+++ b/xpinstall/src/Makefile.in
@@ -18,16 +18,17 @@
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Daniel Veditz <dveditz@netscape.com>
# Douglas Turner <dougt@netscape.com>
+# Dave Townsend <dtownsend@oxymoronical.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
@@ -65,109 +66,52 @@ LIBXUL_LIBRARY = 1
PACKAGE_FILE = base.pkg
REQUIRES = xpcom \
string \
jar \
caps \
content \
necko \
- intl \
- locale \
- libreg \
js \
pref \
widget \
uriloader \
xpconnect \
dom \
windowwatcher \
- plugin \
- unicharutil \
appshell \
docshell \
layout \
chrome \
extensions \
- embed_base \
pipnss \
pipboot \
$(ZLIB_REQUIRES) \
$(NULL)
# XXX shouldn't need to export this
EXPORTS = nsXPITriggerInfo.h
CPPSRCS = \
CertReader.cpp \
- nsInstall.cpp \
nsInstallTrigger.cpp \
- nsInstallVersion.cpp \
- nsInstallFolder.cpp \
- nsJSInstall.cpp \
- nsJSFile.cpp \
nsJSInstallTriggerGlobal.cpp \
- nsJSInstallVersion.cpp \
nsSoftwareUpdate.cpp \
- nsSoftwareUpdateRun.cpp \
- nsInstallFile.cpp \
- nsInstallExecute.cpp \
- nsInstallPatch.cpp \
- nsInstallUninstall.cpp \
- nsInstallResources.cpp \
- nsRegisterItem.cpp \
- nsTopProgressNotifier.cpp \
- nsLoggingProgressNotifier.cpp \
- ScheduledTasks.cpp \
- nsXPIProxy.cpp \
nsXPITriggerInfo.cpp \
nsXPInstallManager.cpp \
- nsInstallFileOpItem.cpp \
- nsJSFileSpecObj.cpp \
- nsInstallLogComment.cpp \
- nsInstallBitwise.cpp \
nsXPIInstallInfo.cpp \
$(NULL)
-ifeq ($(OS_ARCH),WINNT)
-CPPSRCS += \
- nsWinReg.cpp \
- nsJSWinReg.cpp \
- nsWinRegItem.cpp \
- nsWinProfile.cpp \
- nsJSWinProfile.cpp \
- nsWinProfileItem.cpp \
- nsWinShortcut.cpp \
- $(NULL)
-
-OS_LIBS += $(call EXPAND_LIBNAME,ole32 version uuid)
-endif
-
-# Support AppleSingle decoding on Mac OS X
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
-REQUIRES += macmorefiles
-
-CPPSRCS += \
- nsAppleSingleDecoder.cpp \
- $(NULL)
-endif
-
LOCAL_INCLUDES = -I$(srcdir)/../public
EXTRA_DSO_LDOPTS = \
- $(DEPTH)/modules/libreg/src/$(LIB_PREFIX)mozreg_s.$(LIB_SUFFIX) \
$(MOZ_JS_LIBS) \
$(MOZ_UNICHARUTIL_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(ZLIB_LIBS) \
$(NULL)
-ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
-EXTRA_DSO_LDOPTS += \
- $(TK_LIBS) \
- $(NULL)
-endif
-
include $(topsrcdir)/config/rules.mk
ifeq ($(OS_ARCH)$(MOZ_ENABLE_LIBXUL),WINNT)
DEFINES += -DZLIB_DLL
endif
deleted file mode 100644
--- a/xpinstall/src/PatchableAppleSingle.cpp
+++ /dev/null
@@ -1,940 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Douglas Turner <dougt@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-#include "PatchableAppleSingle.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-OSErr PAS_EncodeFile(FSSpec *inSpec, FSSpec *outSpec);
-OSErr PAS_DecodeFile(FSSpec *inSpec, FSSpec *outSpec);
-
-OSErr PAS_encodeResource(FSSpec *inFile, short outRefNum);
-OSErr PAS_decodeResource(PASEntry *entry, FSSpec *outFile, short inRefNum);
-
-OSErr PAS_encodeMisc(FSSpec *inFile, short outRefNum);
-OSErr PAS_decodeMisc(PASEntry *entry, FSSpec *outFile, short inRefNum);
-
-OSErr PAS_encodeData(FSSpec *inFile, short outRefNum);
-OSErr PAS_decodeData(PASEntry *entry, FSSpec *outFile, short inRefNum);
-
-OSErr PAS_encodeHeader(short refnum);
-OSErr PAS_decodeHeader(short refNum, PASHeader *header);
-
-
-unsigned long PAS_getDataSize(FSSpec *spec);
-short PAS_getResourceID(Handle resource);
-
-OSErr PAS_flattenResource(ResType type, short *ids, long count, short source, short dest);
-OSErr PAS_unflattenResource(PASResource *pasRes, Ptr buffer);
-
-void PAS_sortTypes(short sourceRefNum, ResType **resTypePtr, long *count);
-void PAS_sortIDs(short sourceRefNum, OSType theType, short **IdPtr, long *count);
-void PAS_bubbleSortResType(ResType *types, long count);
-void PAS_bubbleSortIDS(short *ids, long count);
-
-OSErr PAS_EncodeFile(FSSpec *inSpec, FSSpec *outSpec)
-{
- OSErr err;
- short outRefNum;
-
- PASEntry dataEntry, miscEntry, resourceEntry;
- long sizeOfEntry;
-
-
- if (inSpec == NULL || outSpec == NULL)
- return paramErr;
-
-
- memset(&dataEntry, 0, sizeof(PASEntry));
- memset(&miscEntry, 0, sizeof(PASEntry));
- memset(&resourceEntry, 0, sizeof(PASEntry));
-
- FSpDelete( outSpec ) ;
-
- err = FSpCreate( outSpec, kCreator, kType ,smSystemScript );
-
- if (err != noErr) return err;
-
-
- err = FSpOpenDF(outSpec, fsRdWrPerm, &outRefNum);
-
- if (err != noErr) goto error;
-
-
- // Write Out Header
-
- err = PAS_encodeHeader(outRefNum);
- if (err != noErr) goto error;
-
- /* Why am I using three (3)?
-
- E stand for entry.
-
- The data for the entry is after the THREE headers
-
- |---------|----|----|----|---------------------->
- header E E E
-
- */
-
-
- // Write Out Data Entry
- dataEntry.entryID = ePas_Data;
- dataEntry.entryLength = PAS_getDataSize(inSpec);
- dataEntry.entryOffset = sizeof(PASHeader) + (3 * sizeof(PASEntry));
-
- sizeOfEntry = sizeof(PASEntry);
- if(dataEntry.entryLength < 0)
- {
- err = dataEntry.entryLength;
- goto error;
- }
-
- err = FSWrite(outRefNum, &sizeOfEntry, &dataEntry);
- if (err != noErr) goto error;
-
-
-
- // Write Out Misc Entry
- miscEntry.entryID = ePas_Misc;
- miscEntry.entryLength = sizeof(PASMiscInfo);
- miscEntry.entryOffset = sizeof(PASHeader) + (3 * sizeof(PASEntry)) + dataEntry.entryLength;
-
- sizeOfEntry = sizeof(PASEntry);
- err = FSWrite(outRefNum, &sizeOfEntry, &miscEntry);
- if (err != noErr) goto error;
-
-
- // Write Out Resource Entry
- resourceEntry.entryID = ePas_Resource;
- resourceEntry.entryLength = -1;
- resourceEntry.entryOffset = sizeof(PASHeader) + (3 * sizeof(PASEntry)) + dataEntry.entryLength + miscEntry.entryLength;
-
-
- sizeOfEntry = sizeof(PASEntry);
- err = FSWrite(outRefNum, &sizeOfEntry, &resourceEntry);
- if (err != noErr) goto error;
-
- err = PAS_encodeData(inSpec, outRefNum);
- if (err != noErr) goto error;
-
-
- err = PAS_encodeMisc(inSpec, outRefNum);
- if (err != noErr) goto error;
-
- err = PAS_encodeResource(inSpec, outRefNum);
-
- if (err == kResFileNotOpened)
- {
- // there was no resource fork
- err = noErr;
- }
- else if (err != noErr)
- {
- goto error;
- }
-
- FSClose(outRefNum);
-
- return noErr;
-
-
-
-error:
-
-
- if (outRefNum != kResFileNotOpened)
- {
- FSClose(outRefNum);
- }
-
- FSpDelete( outSpec ) ;
-
- return err;
-
-}
-
-
-
-OSErr PAS_DecodeFile(FSSpec *inSpec, FSSpec *outSpec)
-{
- OSErr err;
- short inRefNum;
-
- PASHeader header;
-
- PASEntry dataEntry, miscEntry, resourceEntry;
- long sizeOfEntry;
-
- if (inSpec == NULL || outSpec == NULL)
- return paramErr;
-
-
- FSpDelete( outSpec ) ;
-
- err = FSpCreate( outSpec, kCreator, kType ,smSystemScript );
-
- if (err != noErr) return err;
-
-
-
- err = FSpOpenDF(inSpec, fsRdPerm, &inRefNum);
-
- if (err != noErr) goto error;
-
-
- // Read Header
-
- err = PAS_decodeHeader(inRefNum, &header);
- if (err != noErr) goto error;
-
- if( header.magicNum != PAS_MAGIC_NUM ||
- header.versionNum != PAS_VERSION)
- {
- err = -1;
- goto error;
- }
-
-
-
- // Read Data Entry
-
-
- err = SetFPos(inRefNum, fsFromStart, sizeof(PASHeader));
- if (err != noErr) goto error;
-
- sizeOfEntry = sizeof(PASEntry);
-
- err = FSRead(inRefNum, &sizeOfEntry, &dataEntry);
- if (err != noErr) goto error;
-
-
-
-
- // Read Misc Entry
-
-
- err = SetFPos(inRefNum, fsFromStart, (sizeof(PASHeader) + sizeof(PASEntry)));
- if (err != noErr) goto error;
-
- sizeOfEntry = sizeof(PASEntry);
-
- err = FSRead(inRefNum, &sizeOfEntry, &miscEntry);
- if (err != noErr) goto error;
-
-
- // Read Resource Entry
-
-
- err = SetFPos(inRefNum, fsFromStart, (sizeof(PASHeader) + (2 * sizeof(PASEntry)))) ;
- if (err != noErr) goto error;
-
- sizeOfEntry = sizeof(PASEntry);
-
- err = FSRead(inRefNum, &sizeOfEntry, &resourceEntry);
- if (err != noErr) goto error;
-
-
-
-
-
- err = PAS_decodeData(&dataEntry, outSpec, inRefNum);
- if (err != noErr) goto error;
-
- err = PAS_decodeMisc(&miscEntry, outSpec, inRefNum);
- if (err != noErr) goto error;
-
- err = PAS_decodeResource(&resourceEntry, outSpec, inRefNum);
- if (err == kResFileNotOpened)
- {
- // there was no resource fork
- err = noErr;
- }
- else if (err != noErr)
- {
- goto error;
- }
-
-
- FSClose(inRefNum);
-
- return noErr;
-
-
-
-error:
-
- if (inRefNum != kResFileNotOpened)
- {
- FSClose(inRefNum);
- }
-
- FSpDelete( outSpec ) ;
-
- return err;
-
-}
-
-
-
-
-#pragma mark -
-
-
-OSErr PAS_encodeResource(FSSpec *inFile, short outRefNum)
-{
- OSErr err;
- short inRefNum;
- PASResFork resInfo;
- SInt32 currentWrite;
-
- ResType *resTypes;
- long typeCount;
-
- short *ids;
- long idCount;
-
- short oldResFile;
-
- oldResFile=CurResFile();
- inRefNum = FSpOpenResFile(inFile, fsRdPerm);
- if (inRefNum < noErr) return inRefNum;
-
- UseResFile(inRefNum);
-
- memset(&resInfo, 0, sizeof(PASResFork));
-
- PAS_sortTypes(inRefNum, &resTypes, &typeCount);
-
- resInfo.NumberOfTypes = typeCount;
-
- currentWrite = sizeof(PASResFork);
-
- err = FSWrite(outRefNum, ¤tWrite, &resInfo);
- if (err != noErr) return err;
-
- for (typeCount = 0; ((typeCount < resInfo.NumberOfTypes) && (err == noErr)); typeCount++)
- {
- PAS_sortIDs(inRefNum, resTypes[typeCount], &ids, &idCount);
- err = PAS_flattenResource(resTypes[typeCount], ids, idCount, inRefNum, outRefNum);
- DisposePtr((Ptr)ids);
- }
-
- DisposePtr((Ptr)resTypes);
-
-
- UseResFile(oldResFile);
- CloseResFile(inRefNum);
-
- return err;
-}
-
-OSErr PAS_decodeResource(PASEntry *entry, FSSpec *outFile, short inRefNum)
-{
- OSErr err = noErr;
- short outRefNum;
- PASResFork info;
- SInt32 infoSize;
- short oldResFile;
-
- PASResource pasRes;
- SInt32 pasResSize;
-
- long bufSize;
- Handle buffer;
- long counter=0;
-
- infoSize = sizeof(PASResFork);
-
- err = SetFPos(inRefNum, fsFromStart, (*entry).entryOffset );
- if (err != noErr) return err;
-
- err = FSRead( inRefNum, &infoSize, &info);
- if (err != noErr) return err;
-
- if(infoSize != sizeof(PASResFork))
- {
- err = -1;
- goto error;
- }
-
- oldResFile=CurResFile();
-
- outRefNum = FSpOpenResFile(outFile, fsRdWrPerm);
- if (outRefNum < noErr) return outRefNum;
-
- UseResFile(outRefNum);
-
-
- while (1)
- {
- pasResSize = sizeof(PASResource);
- err = FSRead( inRefNum, &pasResSize, &pasRes);
-
- if (err != noErr)
- {
- if(err == eofErr)
- err = noErr;
-
- break;
- }
-
- bufSize = pasRes.length;
- buffer = NewHandle(bufSize);
- HLock(buffer);
-
- if(buffer == NULL)
- {
- // if we did not get our memory, try updateresfile
-
- HUnlock(buffer);
-
-
- UpdateResFile(outRefNum);
- counter=0;
-
- buffer = NewHandle(bufSize);
- HLock(buffer);
-
- if(buffer == NULL)
- {
- err = memFullErr;
- break;
- }
- }
-
- err = FSRead( inRefNum, &bufSize, &(**buffer));
- if (err != noErr && err != eofErr) break;
-
- AddResource(buffer, pasRes.attrType, pasRes.attrID, pasRes.attrName);
- WriteResource(buffer);
-
- SetResAttrs(buffer, pasRes.attr);
- ChangedResource(buffer);
- WriteResource(buffer);
-
- ReleaseResource(buffer);
-
- if (counter++ > 100)
- {
- UpdateResFile(outRefNum);
- counter=0;
- }
-
- }
-
-error:
-
- UseResFile(oldResFile);
- CloseResFile(outRefNum);
-
- return err;
-}
-
-#pragma mark -
-
-OSErr PAS_encodeMisc(FSSpec *inFile, short outRefNum)
-{
- OSErr err;
- short inRefNum;
- PASMiscInfo infoBlock;
- FInfo fInfo;
- SInt32 currentRead;
-
- err = FSpOpenDF(inFile, fsRdPerm, &inRefNum);
- if (err != noErr) return err;
-
- memset(&infoBlock, 0, sizeof(PASMiscInfo));
-
- err = FSpGetFInfo(inFile, &fInfo);
- if (err != noErr) return err;
-
- infoBlock.fileType = fInfo.fdType;
- infoBlock.fileCreator = fInfo.fdCreator;
- infoBlock.fileFlags = fInfo.fdFlags;
-
-
- FSClose(inRefNum);
-
-
- inRefNum = FSpOpenResFile(inFile, fsRdPerm);
- if (inRefNum > noErr)
- {
- infoBlock.fileHasResFork = 1;
- infoBlock.fileResAttrs = GetResFileAttrs(inRefNum);
- FSClose(inRefNum);
- }
- else
- {
- infoBlock.fileHasResFork = 0;
- infoBlock.fileResAttrs = 0;
- }
- currentRead = sizeof(PASMiscInfo);
-
- err = FSWrite(outRefNum, ¤tRead, &infoBlock);
- if (err != noErr) return err;
-
- CloseResFile(inRefNum);
-
- return noErr;
-}
-
-
-OSErr PAS_decodeMisc(PASEntry *entry, FSSpec *outFile, short inRefNum)
-{
- OSErr err = noErr;
- short outRefNum;
- PASMiscInfo info;
- SInt32 infoSize;
- FInfo theFInfo;
-
-
- infoSize = sizeof(PASMiscInfo);
-
- err = SetFPos(inRefNum, fsFromStart, (*entry).entryOffset );
- if (err != noErr) return err;
-
- err = FSRead( inRefNum, &infoSize, &info);
- if (err != noErr) return err;
-
- if(infoSize != sizeof(PASMiscInfo))
- {
- return -1;
- }
-
- err = FSpOpenDF(outFile, fsRdWrPerm, &outRefNum);
- if (err != noErr) return err;
-
- memset(&theFInfo, 0, sizeof(FInfo));
-
- theFInfo.fdType = info.fileType;
- theFInfo.fdCreator = info.fileCreator;
- theFInfo.fdFlags = info.fileFlags;
-
- err = FSpSetFInfo(outFile, &theFInfo);
- if (err != noErr) return err;
-
- FSClose(outRefNum);
-
- if (info.fileHasResFork)
- {
- outRefNum = FSpOpenResFile(outFile, fsRdWrPerm);
- if (outRefNum < noErr)
- {
- // maybe it does not have one!
-
- FSpCreateResFile(outFile, info.fileCreator, info.fileType, smSystemScript);
-
- outRefNum = FSpOpenResFile(outFile, fsRdWrPerm);
- if (outRefNum < noErr)
- {
- return outRefNum;
- }
- }
-
- SetResFileAttrs(outRefNum, info.fileResAttrs);
-
-
- CloseResFile(outRefNum);
- }
-
-
- if(info.fileType == 'APPL')
- {
- // we need to add applications to the desktop database.
-
-/* FIX :: need to find DTSetAPPL() function
- err = DTSetAPPL( NULL,
- outFile->vRefNum,
- info.fileCreator,
- outFile->parID,
- outFile->name);
-*/ }
-
-
- return err;
-
-
-
-}
-
-#pragma mark -
-
-OSErr PAS_encodeData(FSSpec *inFile, short outRefNum)
-{
- OSErr err;
- short inRefNum;
- Ptr buffer;
- SInt32 currentRead = PAS_BUFFER_SIZE;
-
- buffer = NewPtr(currentRead);
-
- err = FSpOpenDF(inFile, fsRdPerm, &inRefNum);
- if (err != noErr) return err;
-
- while ( currentRead > 0 )
- {
- err = FSRead( inRefNum, ¤tRead, buffer);
- if (err != noErr && err != eofErr) return err;
-
- err = FSWrite(outRefNum, ¤tRead, buffer);
- if (err != noErr) return err;
- }
-
- FSClose(inRefNum);
-
- DisposePtr(buffer);
-
- return noErr;
-}
-
-OSErr PAS_decodeData(PASEntry *entry, FSSpec *outFile, short inRefNum)
-{
- OSErr err;
- short outRefNum;
- Ptr buffer;
- SInt32 currentWrite = PAS_BUFFER_SIZE;
- SInt32 totalSize;
-
-
- buffer = NewPtr(currentWrite);
-
-
- err = FSpOpenDF(outFile, fsRdWrPerm, &outRefNum);
- if (err != noErr) return err;
-
-
- err = SetFPos(inRefNum, fsFromStart, (*entry).entryOffset );
- if (err != noErr) return err;
-
- err = SetFPos(outRefNum, fsFromStart, 0 );
- if (err != noErr) return err;
-
- totalSize = (*entry).entryLength;
-
- while(totalSize > 0)
- {
- currentWrite = PAS_BUFFER_SIZE;
-
- if (totalSize < currentWrite)
- {
- currentWrite = totalSize;
- }
-
- err = FSRead( inRefNum, ¤tWrite, buffer);
- if (err != noErr && err != eofErr) return err;
-
- err = FSWrite(outRefNum, ¤tWrite, buffer);
- if (err != noErr) return err;
-
- totalSize = totalSize - currentWrite;
-
- }
-
- FSClose(outRefNum);
-
- DisposePtr(buffer);
-
- return noErr;
-
-}
-
-#pragma mark -
-
-OSErr PAS_encodeHeader(short refnum)
-{
- PASHeader header;
- long sizeOfHeader;
- OSErr err;
-
-
- sizeOfHeader = sizeof(PASHeader);
-
- memset(&header, 0, sizeOfHeader);
-
- header.magicNum = PAS_MAGIC_NUM;
- header.versionNum = PAS_VERSION;
- header.numEntries = 3;
-
- // Write Out Header
- err = FSWrite(refnum, &sizeOfHeader, &header);
-
- return err;
-
-}
-
-OSErr PAS_decodeHeader(short refNum, PASHeader *header)
-{
- OSErr err;
- long sizeOfHeader = sizeof(PASHeader);
-
- memset(header, 0, sizeOfHeader);
-
- err = FSRead(refNum, &sizeOfHeader, header);
-
- return err;
-}
-
-#pragma mark -
-
-
-unsigned long PAS_getDataSize(FSSpec *spec)
-{
- short refNum;
- OSErr err;
- Str255 temp;
- CInfoPBRec cbrec;
- err = FSpOpenDF(spec, fsRdPerm, &refNum);
-
- memcpy( temp, spec->name, spec->name[0] + 1);
-
- cbrec.hFileInfo.ioNamePtr = temp;
- cbrec.hFileInfo.ioDirID = spec->parID;
- cbrec.hFileInfo.ioVRefNum = spec->vRefNum;
- cbrec.hFileInfo.ioFDirIndex = 0;
-
- err = PBGetCatInfoSync(&cbrec);
- FSClose(refNum);
-
- if(err != noErr)
- {
- cbrec.hFileInfo.ioFlLgLen = err;
- }
-
- return (cbrec.hFileInfo.ioFlLgLen);
-}
-
-short PAS_getResourceID(Handle resource)
-{
- ResType theType;
- Str255 name;
- short theID;
-
- memset(&name, 0, sizeof(Str255));
-
- GetResInfo(resource, &theID, &theType, name);
-
- return theID;
-}
-
-
-#pragma mark -
-OSErr PAS_flattenResource(ResType type, short *ids, long count, short source, short dest)
-{
- long idIndex;
-
-
- Handle resToCopy;
- long handleLength;
-
- PASResource pasResource;
- long pasResLen;
-
- OSErr err;
-
- for (idIndex=0; idIndex < count; idIndex++)
- {
- if( (type == 'SIZE') && ( ids[idIndex] == 1 || ids[idIndex] == 0 ) )
- {
- /*
- We do not want to encode/flatten SIZE 0 or 1 because this
- is the resource that the user can modify. Most applications
- will not be affected if we remove these resources
- */
- }
- else
- {
- resToCopy=Get1Resource(type,ids[idIndex]);
-
- if(!resToCopy)
- {
- return resNotFound;
- }
-
- memset(&pasResource, 0, sizeof(PASResource));
-
- GetResInfo( resToCopy,
- &pasResource.attrID,
- &pasResource.attrType,
- pasResource.attrName);
-
- pasResource.attr = GetResAttrs(resToCopy);
-
- DetachResource(resToCopy);
- HLock(resToCopy);
-
- pasResource.length = GetHandleSize(resToCopy);
- handleLength = pasResource.length;
-
- pasResLen = sizeof(PASResource);
-
- err = FSWrite(dest, &pasResLen, &pasResource);
-
- if(err != noErr)
- {
- return err;
- }
-
- err = FSWrite(dest, &handleLength, &(**resToCopy));
-
- if(err != noErr)
- {
- return err;
- }
-
- HUnlock(resToCopy);
- DisposeHandle(resToCopy);
- }
- }
-
-
- return noErr;
-}
-
-
-#pragma mark -
-
-void PAS_sortTypes(short sourceRefNum, ResType **resTypePtr, long *count)
-{
- short oldRef;
- short typeIndex;
- short numberOfTypes;
-
- *count = -1;
-
- oldRef = CurResFile();
-
- UseResFile(sourceRefNum);
-
- numberOfTypes = Count1Types();
-
- *resTypePtr = (ResType*) NewPtrClear( numberOfTypes * sizeof(OSType) );
-
- for (typeIndex=1; typeIndex <= numberOfTypes; typeIndex++)
- {
- Get1IndType(&(*resTypePtr)[typeIndex-1], typeIndex);
- }
-
- UseResFile(oldRef);
-
- PAS_bubbleSortResType(*resTypePtr, numberOfTypes);
-
- *count = numberOfTypes;
-}
-
-
-void PAS_sortIDs(short sourceRefNum, OSType theType, short **IdPtr, long *count)
-{
- short oldRef;
- Handle theHandle;
- short resCount;
- short resIndex;
-
- *count = -1;
-
- oldRef = CurResFile();
-
- UseResFile(sourceRefNum);
-
- resCount = Count1Resources(theType);
-
- *IdPtr = (short*) NewPtrClear( resCount * sizeof(short) );
-
- for (resIndex=1; resIndex <= resCount; resIndex++)
- {
- theHandle = Get1IndResource(theType, resIndex);
-
- if(theHandle == NULL) return;
-
- (*IdPtr)[resIndex-1] = PAS_getResourceID(theHandle);
-
- ReleaseResource(theHandle);
- }
-
- UseResFile(oldRef);
-
- PAS_bubbleSortIDS(*IdPtr, resCount);
-
-
- *count = resCount;
-}
-
-#pragma mark -
-
-void
-PAS_bubbleSortResType(ResType *types, long count)
-{
- long x, y;
- OSType temp;
-
- for (x=0; x < count-1; x++)
- {
- for (y=0; y < count-x-1; y++)
- {
- if (types[y] > types[y+1])
- {
- temp=types[y];
- types[y]=types[y+1];
- types[y+1]=temp;
- }
- }
- }
-}
-
-void
-PAS_bubbleSortIDS(short *ids, long count)
-{
- long x, y;
- short temp;
-
- for (x=0; x < count-1; x++)
- {
- for (y=0; y < count-x-1; y++)
- {
- if (ids[y] > ids[y+1])
- {
- temp=ids[y];
- ids[y]=ids[y+1];
- ids[y+1]=temp;
- }
- }
- }
-}
-
deleted file mode 100644
--- a/xpinstall/src/PatchableAppleSingle.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Douglas Turner <dougt@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef SU_PAS_H
-#define SU_PAS_H
-
-
-#include <Errors.h>
-#include <Types.h>
-#include <Files.h>
-#include <Script.h>
-#include <Resources.h>
-
-typedef struct PASHeader /* header portion of Patchable AppleSingle */
-{
- UInt32 magicNum; /* internal file type tag = 0x00244200*/
- UInt32 versionNum; /* format version: 1 = 0x00010000 */
- UInt8 filler[16]; /* filler */
- UInt16 numEntries; /* number of entries which follow */
-} PASHeader ;
-
-
-typedef struct PASEntry /* one Patchable AppleSingle entry descriptor */
-{
- UInt32 entryID; /* entry type: see list, 0 invalid */
- UInt32 entryOffset; /* offset, in bytes, from beginning */
- /* of file to this entry's data */
- UInt32 entryLength; /* length of data in octets */
-
-} PASEntry;
-
-
-typedef struct PASMiscInfo
-{
- short fileHasResFork;
- short fileResAttrs;
- OSType fileType;
- OSType fileCreator;
- UInt32 fileFlags;
-
-} PASMiscInfo;
-
-
-typedef struct PASResFork
-{
- short NumberOfTypes;
-
-} PASResFork;
-
-
-typedef struct PASResource
-{
- short attr;
- short attrID;
- OSType attrType;
- Str255 attrName;
- unsigned long length;
-
-} PASResource;
-
-
-
-#if PRAGMA_STRUCT_ALIGN
-#pragma options align=reset
-#endif
-
-
-#define kCreator 'MOSS'
-#define kType 'PASf'
-#define PAS_BUFFER_SIZE (1024*512)
-
-#define PAS_MAGIC_NUM (0x00244200)
-#define PAS_VERSION (0x00010000)
-
-enum
-{
- ePas_Data = 1,
- ePas_Misc,
- ePas_Resource
-};
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Prototypes */
-OSErr PAS_EncodeFile(FSSpec *inSpec, FSSpec *outSpec);
-OSErr PAS_DecodeFile(FSSpec *inSpec, FSSpec *outSpec);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SU_PAS_H */
deleted file mode 100644
--- a/xpinstall/src/ScheduledTasks.cpp
+++ /dev/null
@@ -1,609 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Daniel Veditz <dveditz@netscape.com>
- * Douglas Turner <dougt@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nscore.h"
-#include "nsXPIDLString.h"
-#include "nsInstall.h" // for error codes
-#include "prmem.h"
-#include "ScheduledTasks.h"
-#include "InstallCleanupDefines.h"
-
-#include "nsDirectoryService.h"
-#include "nsDirectoryServiceDefs.h"
-#include "nsAppDirectoryServiceDefs.h"
-
-static nsresult
-GetPersistentStringFromSpec(nsIFile* inSpec, nsACString &string)
-{
- nsresult rv;
-
- nsCOMPtr<nsILocalFile> LocalFile = do_QueryInterface(inSpec, &rv);
-
- if (NS_SUCCEEDED(rv)) {
- rv = LocalFile->GetNativePath(string);
- }
- else {
- string.Truncate();
- }
- return rv;
-}
-
-
-
-
-
-#ifdef _WINDOWS
-#include <sys/stat.h>
-#include <windows.h>
-
-PRInt32 ReplaceWindowsSystemFile(nsIFile* currentSpec, nsIFile* finalSpec)
-{
- PRInt32 err = -1;
-
- // Get OS version info
- DWORD dwVersion = GetVersion();
-
- nsCAutoString final;
- nsCAutoString current;
-
- finalSpec->GetNativePath(final);
- currentSpec->GetNativePath(current);
-
- // Get build numbers for Windows NT or Win32s
-
- if (dwVersion > 0x80000000)
- {
- // Windows 95 or Win16
-
- // Place an entry in the WININIT.INI file in the Windows directory
- // to delete finalName and rename currentName to be finalName at reboot
-
- int strlen;
- char Src[_MAX_PATH]; // 8.3 name
- char Dest[_MAX_PATH]; // 8.3 name
-
- strlen = GetShortPathName( (LPCTSTR)current.get(), (LPTSTR)Src, (DWORD)sizeof(Src) );
- if ( strlen > 0 )
- {
- current = Src;
- }
-
- strlen = GetShortPathName( (LPCTSTR) final.get(), (LPTSTR) Dest, (DWORD) sizeof(Dest));
- if ( strlen > 0 )
- {
- final = Dest;
- }
-
- // NOTE: use OEM filenames! Even though it looks like a Windows
- // .INI file, WININIT.INI is processed under DOS
-
- AnsiToOem( final.BeginWriting(), final.BeginWriting() );
- AnsiToOem( current.BeginWriting(), current.BeginWriting() );
-
- if ( WritePrivateProfileString( "Rename", final.get(), current.get(), "WININIT.INI" ) )
- err = 0;
- }
- else
- {
- // Windows NT
- if ( MoveFileEx(final.get(), current.get(), MOVEFILE_DELAY_UNTIL_REBOOT) )
- err = 0;
- }
-
- return err;
-}
-#endif
-
-nsresult GetRegFilePath(nsACString ®FilePath)
-{
- nsresult rv;
- nsCOMPtr<nsILocalFile> iFileUtilityPath;
- //Get the program directory
- nsCOMPtr<nsIProperties> directoryService =
- do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
- if (NS_FAILED(rv))
- return nsnull;
-
- if (nsSoftwareUpdate::GetProgramDirectory()) // In the stub installer
- {
- nsCOMPtr<nsIFile> tmp;
- rv = nsSoftwareUpdate::GetProgramDirectory()->Clone(getter_AddRefs(tmp));
-
- if (NS_FAILED(rv) || !tmp)
- return nsnull;
-
- iFileUtilityPath = do_QueryInterface(tmp);
- }
- else
- {
- rv = directoryService->Get(NS_APP_INSTALL_CLEANUP_DIR,
- NS_GET_IID(nsIFile),
- getter_AddRefs(iFileUtilityPath));
- }
- if (NS_FAILED(rv) || !iFileUtilityPath)
- return nsnull;
-
- iFileUtilityPath->AppendNative(CLEANUP_REGISTRY);
-
- //Yes, we know using GetPath is buggy on the Mac.
- //When libreg is fixed to accept nsIFiles we'll change this to match.
- return iFileUtilityPath->GetNativePath(regFilePath);
-}
-
-
-PRInt32 DeleteFileNowOrSchedule(nsIFile* filename)
-{
- PRBool flagExists;
- PRInt32 result = nsInstall::SUCCESS;
-
- filename->Remove(PR_FALSE);
- filename->Exists(&flagExists);
- if (flagExists)
- result = ScheduleFileForDeletion(filename);
-
- return result;
-}
-
-PRInt32 ScheduleFileForDeletion(nsIFile *filename)
-{
- // could not delete, schedule it for later
-
- RKEY newkey;
- HREG reg;
- REGERR err;
- PRInt32 result = nsInstall::UNEXPECTED_ERROR;
-
- nsCAutoString path;
- GetRegFilePath(path);
- err = NR_RegOpen(const_cast<char*>(path.get()), ®);
-
- if ( err == REGERR_OK )
- {
- err = NR_RegAddKey(reg,ROOTKEY_PRIVATE,REG_DELETE_LIST_KEY,&newkey);
- if ( err == REGERR_OK )
- {
- char valname[20];
-
- err = NR_RegGetUniqueName( reg, valname, sizeof(valname) );
- if ( err == REGERR_OK )
- {
- nsCAutoString nameowner;
- nsresult rv = GetPersistentStringFromSpec(filename, nameowner);
- if ( NS_SUCCEEDED(rv) && !nameowner.IsEmpty() )
- {
- const char *fnamestr = nameowner.get();
- err = NR_RegSetEntry( reg, newkey, valname,
- REGTYPE_ENTRY_BYTES,
- (void*)fnamestr,
- strlen(fnamestr)+sizeof('\0'));
-
- if ( err == REGERR_OK )
- {
- result = nsInstall::REBOOT_NEEDED;
- nsSoftwareUpdate::NeedCleanup();
- }
- }
- }
- }
-
- NR_RegClose(reg);
- }
-
- return result;
-}
-
-
-
-
-PRInt32 ReplaceFileNow(nsIFile* aReplacementFile, nsIFile* aDoomedFile )
-{
- PRBool flagExists, flagRenamedDoomedFileExists, flagIsEqual;
- nsCOMPtr<nsIFile> replacementFile;
- nsresult rv;
-
- // make a clone of aReplacement file so we touch affect callers
- aReplacementFile->Clone(getter_AddRefs(replacementFile));
-
- // replacement file must exist, doomed file doesn't have to
- replacementFile->Exists(&flagExists);
- if ( !flagExists )
- return nsInstall::DOES_NOT_EXIST;
-
- // don't have to do anything if the files are the same
- replacementFile->Equals(aDoomedFile, &flagIsEqual);
- if ( flagIsEqual )
- return nsInstall::SUCCESS;
-
-
- PRInt32 result = nsInstall::ACCESS_DENIED;
-
- // first try to rename the doomed file out of the way (if it exists)
- nsCOMPtr<nsIFile> renamedDoomedFile;
- nsCOMPtr<nsILocalFile> tmpLocalFile;
-
- aDoomedFile->Clone(getter_AddRefs(renamedDoomedFile));
- renamedDoomedFile->Exists(&flagRenamedDoomedFileExists);
- if ( flagRenamedDoomedFileExists )
- {
-#ifdef XP_MACOSX
- // If we clone an nsIFile, and move the clone, the FSRef of the *original*
- // file is not what you would expect - it points to the moved file. This
- // is despite the fact that the two FSRefs are independent objects. Until
- // the OS X file impl is changed to not use FSRefs, need to do this (see
- // bug 200024).
- nsCOMPtr<nsILocalFile> doomedFileLocal = do_QueryInterface(aDoomedFile);
- nsCAutoString doomedFilePath;
- rv = doomedFileLocal->GetNativePath(doomedFilePath);
- if (NS_FAILED(rv))
- return nsInstall::UNEXPECTED_ERROR;
-#endif
-
- tmpLocalFile = do_QueryInterface(renamedDoomedFile, &rv); // Convert to an nsILocalFile
-
- //get the doomedLeafname so we can convert its extension to .old
- nsAutoString doomedLeafname;
- nsCAutoString uniqueLeafName;
- tmpLocalFile->GetLeafName(doomedLeafname);
-
- // do not RFind on the native charset! UTF8 or Unicode are OK
- PRInt32 extpos = doomedLeafname.RFindChar('.');
- if (extpos != -1)
- {
- // We found the extension;
- doomedLeafname.Truncate(extpos + 1); //strip off the old extension
- }
- doomedLeafname.AppendLiteral("old");
-
- //Now reset the doomedLeafname
- tmpLocalFile->SetLeafName(doomedLeafname);
- tmpLocalFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0644);
- tmpLocalFile->GetNativeLeafName(uniqueLeafName);//this is the new "unique" doomedLeafname
-
- rv = aDoomedFile->Clone(getter_AddRefs(renamedDoomedFile));// Reset renamedDoomed file so aDoomedfile
- // isn't changed during the MoveTo call
- if (NS_FAILED(rv))
- result = nsInstall::UNEXPECTED_ERROR;
- else
- {
- rv = renamedDoomedFile->MoveToNative(nsnull, uniqueLeafName);
- if (NS_FAILED(rv))
- {
- // MoveToNative() failing is OK. It simply means that the file
- // was locked in memory and needs to be replaced on browser
- // shutdown or system reboot.
- //
- // Since renamedDoomedFile->MoveToNative() failed, it created a
- // 0 byte '-old' file that needs to be cleaned up.
- tmpLocalFile->Remove(PR_FALSE);
- }
- else
- {
- // The implementation of MoveToNative() on some platforms (osx and win32) resets
- // the object to the 'moved to' filename. This is incorrect behavior. This
- // implementation will be fixed in the future. We need to take into account that
- // fix by setting renamedDoomedFile to the filename that it was moved to above.
- // See bug 200024.
- //
- // renamedDoomedFile needs to be reset because it's used later on in this
- // function.
- rv = renamedDoomedFile->SetNativeLeafName(uniqueLeafName);
- if (NS_FAILED(rv))
- result = nsInstall::UNEXPECTED_ERROR;
- }
- }
-
-#ifdef XP_MACOSX
- rv = doomedFileLocal->InitWithNativePath(doomedFilePath);
- if (NS_FAILED(rv))
- result = nsInstall::UNEXPECTED_ERROR;
-#endif
-
- if (result == nsInstall::UNEXPECTED_ERROR)
- return result;
- }
-
-
- // if aDoomedFile is still in the way, give up and return result.
- aDoomedFile->Exists(&flagExists);
- if ( flagExists )
- return result;
-
- nsCOMPtr<nsIFile> parentofDoomedFile;
- nsCAutoString doomedLeafname;
-
- rv = aDoomedFile->GetParent(getter_AddRefs(parentofDoomedFile));
- if ( NS_SUCCEEDED(rv) )
- rv = aDoomedFile->GetNativeLeafName(doomedLeafname);
- if ( NS_SUCCEEDED(rv) )
- {
- rv = replacementFile->MoveToNative(parentofDoomedFile, doomedLeafname);
- // The implementation of MoveToNative() on some platforms (osx and win32) resets
- // the object to the 'moved to' filename. This is incorrect behavior. This
- // implementation will be fixed in the future. We need to take into account that
- // fix by setting replacementFile to the filename that it was moved to above.
- // See bug 200024.
- //
- // However, since replacementFile is a clone of aReplacementFile and is also
- // not used beyond here, there's no need to set the path+leafname to what
- // it was MoveToNative()'ed to.
- }
-
- if (NS_SUCCEEDED(rv))
- {
- if (flagRenamedDoomedFileExists)
- {
- // we replaced the old file OK, now we have to
- // get rid of it if it was renamed out of the way
- result = DeleteFileNowOrSchedule( renamedDoomedFile );
- }
- }
- else
- {
- // couldn't rename file, try to put old file back
- renamedDoomedFile->MoveToNative(nsnull, doomedLeafname);
- // No need to reset remanedDoomedFile after a MoveToNative() call
- // because renamedDoomedFile is not used beyond here.
- }
-
- return result;
-}
-
-
-
-
-
-PRInt32 ReplaceFileNowOrSchedule(nsIFile* aReplacementFile, nsIFile* aDoomedFile, PRInt32 aMode)
-{
- PRInt32 result = ReplaceFileNow( aReplacementFile, aDoomedFile );
-
- if ( result == nsInstall::ACCESS_DENIED )
- {
- // if we couldn't replace the file schedule it for later
-#ifdef _WINDOWS
- if ( (aMode & WIN_SYSTEM_FILE) &&
- (ReplaceWindowsSystemFile(aReplacementFile, aDoomedFile) == 0) )
- return nsInstall::REBOOT_NEEDED;
-#endif
-
- RKEY listkey;
- RKEY filekey;
- HREG reg;
- REGERR err;
-
- nsCAutoString regFilePath;
- GetRegFilePath(regFilePath);
- if ( REGERR_OK == NR_RegOpen(const_cast<char*>(regFilePath.get()), ®) )
- {
- err = NR_RegAddKey( reg, ROOTKEY_PRIVATE, REG_REPLACE_LIST_KEY, &listkey );
- if ( err == REGERR_OK )
- {
- char valname[20];
- REGERR err2;
-
- err = NR_RegGetUniqueName( reg, valname, sizeof(valname) );
- if ( err == REGERR_OK )
- {
- err = NR_RegAddKey( reg, listkey, valname, &filekey );
- if ( REGERR_OK == err )
- {
- nsCAutoString srcowner;
- nsCAutoString destowner;
- nsresult rv = GetPersistentStringFromSpec(aReplacementFile, srcowner);
- nsresult rv2 = GetPersistentStringFromSpec(aDoomedFile, destowner);
- if ( NS_SUCCEEDED(rv) && NS_SUCCEEDED(rv2) )
- {
- const char *fsrc = srcowner.get();
- const char *fdest = destowner.get();
- err = NR_RegSetEntry( reg, filekey,
- REG_REPLACE_SRCFILE,
- REGTYPE_ENTRY_BYTES,
- (void*)fsrc,
- strlen(fsrc)+sizeof('\0'));
-
- err2 = NR_RegSetEntry(reg, filekey,
- REG_REPLACE_DESTFILE,
- REGTYPE_ENTRY_BYTES,
- (void*)fdest,
- strlen(fdest)+sizeof('\0'));
-
- if ( err == REGERR_OK && err2 == REGERR_OK )
- {
- result = nsInstall::REBOOT_NEEDED;
- nsSoftwareUpdate::NeedCleanup();
- }
- else
- NR_RegDeleteKey( reg, listkey, valname );
- }
- }
- }
- }
- NR_RegClose(reg);
- }
- }
-
- return result;
-}
-
-
-
-
-//-----------------------------------------------------------------------------
-//
-// STARTUP: DO SCHEDULED ACTIONS
-//
-//-----------------------------------------------------------------------------
-
-void DeleteScheduledFiles(HREG);
-void ReplaceScheduledFiles(HREG);
-
-void PerformScheduledTasks(HREG reg)
-{
- DeleteScheduledFiles( reg );
- ReplaceScheduledFiles( reg );
-}
-
-
-
-void DeleteScheduledFiles( HREG reg )
-{
- REGERR err;
- RKEY key;
- REGENUM state = 0;
- nsresult rv = NS_OK;
-
- // perform scheduled file deletions
- if (REGERR_OK == NR_RegGetKey(reg,ROOTKEY_PRIVATE,REG_DELETE_LIST_KEY,&key))
- {
- // the delete key exists, so we loop through its children
- // and try to delete all the listed files
-
- char namebuf[MAXREGNAMELEN];
- char valbuf[MAXREGPATHLEN];
-
- nsCOMPtr<nsIFile> doomedFile;
- nsCOMPtr<nsILocalFile> spec;
-
- if (NS_SUCCEEDED(rv))
- {
- while (REGERR_OK == NR_RegEnumEntries( reg, key, &state, namebuf,
- sizeof(namebuf), 0 ) )
- {
- uint32 bufsize = sizeof(valbuf); // gets changed, must reset
- err = NR_RegGetEntry( reg, key, namebuf, valbuf, &bufsize );
- if ( err == REGERR_OK )
- {
- // no need to check return value of
- // SetPersistentDescriptorString, it's always NS_OK
- //spec->SetPersistentDescriptorString(valbuf);
- //nsIFileXXX: Do we still need this instead of InitWithPath?
- NS_NewNativeLocalFile(nsDependentCString(valbuf), PR_TRUE, getter_AddRefs(spec));
- spec->Clone(getter_AddRefs(doomedFile));
- if (NS_SUCCEEDED(rv))
- {
- PRBool flagExists;
- doomedFile->Remove(PR_FALSE);
- doomedFile->Exists(&flagExists);
- if ( !flagExists )
- {
- // deletion successful, don't have to retry
- NR_RegDeleteEntry( reg, key, namebuf );
- }
- }
- }
- }
-
- // delete list node if empty
- state = 0;
- err = NR_RegEnumEntries(reg, key, &state, namebuf, sizeof(namebuf), 0);
- if ( err == REGERR_NOMORE )
- {
- NR_RegDeleteKey(reg, ROOTKEY_PRIVATE, REG_DELETE_LIST_KEY);
- }
- }
- }
-}
-
-
-
-void ReplaceScheduledFiles( HREG reg )
-{
- RKEY key;
-
- // replace files if any listed
- if (REGERR_OK == NR_RegGetKey(reg,ROOTKEY_PRIVATE,REG_REPLACE_LIST_KEY,&key))
- {
- char keyname[MAXREGNAMELEN];
- char doomedFile[MAXREGPATHLEN];
- char srcFile[MAXREGPATHLEN];
-
- nsCOMPtr<nsIFile> doomedSpec;
- nsCOMPtr<nsIFile> srcSpec;
- nsCOMPtr<nsILocalFile> src;
- nsCOMPtr<nsILocalFile> dest;
- nsresult rv1, rv2;
-
- uint32 bufsize;
- REGENUM state = 0;
- while (REGERR_OK == NR_RegEnumSubkeys( reg, key, &state,
- keyname, sizeof(keyname), REGENUM_CHILDREN))
- {
- bufsize = sizeof(srcFile);
- REGERR err1 = NR_RegGetEntry( reg, (RKEY)state,
- REG_REPLACE_SRCFILE, srcFile, &bufsize);
-
- bufsize = sizeof(doomedFile);
- REGERR err2 = NR_RegGetEntry( reg, (RKEY)state,
- REG_REPLACE_DESTFILE, doomedFile, &bufsize);
-
- if ( err1 == REGERR_OK && err2 == REGERR_OK )
- {
- rv1 = NS_NewNativeLocalFile(nsDependentCString(srcFile), PR_TRUE, getter_AddRefs(src));
- rv1 = src->Clone(getter_AddRefs(srcSpec));
-
- rv2 = NS_NewNativeLocalFile(nsDependentCString(doomedFile), PR_TRUE, getter_AddRefs(dest));
- rv2 = dest->Clone(getter_AddRefs(doomedSpec));
-
- if (NS_SUCCEEDED(rv1) && NS_SUCCEEDED(rv2))
- {
- // finally now try to do the replace
- PRInt32 result = ReplaceFileNow( srcSpec, doomedSpec );
-
- if ( result == nsInstall::DOES_NOT_EXIST ||
- result == nsInstall::SUCCESS )
- {
- // This one is done
- NR_RegDeleteKey( reg, key, keyname );
- }
- }
- }
- }
-
-
- // delete list node if empty
- state = 0;
- if (REGERR_NOMORE == NR_RegEnumSubkeys( reg, key, &state, keyname,
- sizeof(keyname), REGENUM_CHILDREN ))
- {
- NR_RegDeleteKey(reg, ROOTKEY_PRIVATE, REG_REPLACE_LIST_KEY);
- }
- }
-}
-
-
deleted file mode 100644
--- a/xpinstall/src/ScheduledTasks.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Daniel Veditz <dveditz@netscape.com>
- * Douglas Turner <dougt@netscape.com>
- * Samir Gehani <sgehani@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef __SCHEDULEDTASKS_H__
-#define __SCHEDULEDTASKS_H__
-
-
-#include "NSReg.h"
-#include "nsIFile.h"
-
-PR_BEGIN_EXTERN_C
-
-PRInt32 DeleteFileNowOrSchedule(nsIFile* filename);
-PRInt32 ReplaceFileNowOrSchedule(nsIFile* tmpfile, nsIFile* target, PRInt32 aMode);
-PRInt32 ScheduleFileForDeletion(nsIFile* filename);
-char* GetRegFilePath();
-
-
-void PerformScheduledTasks(HREG reg);
-
-PR_END_EXTERN_C
-
-#endif
deleted file mode 100644
--- a/xpinstall/src/gdiff.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-/*--------------------------------------------------------------
- * GDIFF.H
- *
- * Constants used in processing the GDIFF format
- *--------------------------------------------------------------*/
-
-
-#include "prio.h"
-
-#define GDIFF_MAGIC "\xD1\xFF\xD1\xFF"
-#define GDIFF_MAGIC_LEN 4
-#define GDIFF_VER 5
-#define GDIFF_EOF "\0"
-
-#define GDIFF_VER_POS 4
-#define GDIFF_CS_POS 5
-#define GDIFF_CSLEN_POS 6
-
-#define GDIFF_HEADERSIZE 7
-#define GDIFF_APPDATALEN 4
-
-#define GDIFF_CS_NONE 0
-#define GDIFF_CS_MD5 1
-#define GDIFF_CS_SHA 2
-#define GDIFF_CS_CRC32 32
-
-#define CRC32_LEN 4
-
-/*--------------------------------------
- * GDIFF opcodes
- *------------------------------------*/
-#define ENDDIFF 0
-#define ADD8MAX 246
-#define ADD16 247
-#define ADD32 248
-#define COPY16BYTE 249
-#define COPY16SHORT 250
-#define COPY16LONG 251
-#define COPY32BYTE 252
-#define COPY32SHORT 253
-#define COPY32LONG 254
-#define COPY64 255
-
-/* instruction sizes */
-#define ADD16SIZE 2
-#define ADD32SIZE 4
-#define COPY16BYTESIZE 3
-#define COPY16SHORTSIZE 4
-#define COPY16LONGSIZE 6
-#define COPY32BYTESIZE 5
-#define COPY32SHORTSIZE 6
-#define COPY32LONGSIZE 8
-#define COPY64SIZE 12
-
-
-/*--------------------------------------
- * error codes
- *------------------------------------*/
-#define GDIFF_OK 0
-#define GDIFF_ERR_UNKNOWN -1
-#define GDIFF_ERR_ARGS -2
-#define GDIFF_ERR_ACCESS -3
-#define GDIFF_ERR_MEM -4
-#define GDIFF_ERR_HEADER -5
-#define GDIFF_ERR_BADDIFF -6
-#define GDIFF_ERR_OPCODE -7
-#define GDIFF_ERR_OLDFILE -8
-#define GDIFF_ERR_CHKSUMTYPE -9
-#define GDIFF_ERR_CHECKSUM -10
-#define GDIFF_ERR_CHECKSUM_TARGET -11
-#define GDIFF_ERR_CHECKSUM_RESULT -12
-
-
-/*--------------------------------------
- * types
- *------------------------------------*/
-#ifndef AIX
-#ifdef OSF1
-#include <sys/types.h>
-#else
-typedef unsigned char uchar;
-#endif
-#endif
-
-typedef struct _diffdata {
- PRFileDesc* fSrc;
- PRFileDesc* fOut;
- PRFileDesc* fDiff;
- uint8 checksumType;
- uint8 checksumLength;
- uchar* oldChecksum;
- uchar* newChecksum;
- PRBool bMacAppleSingle;
- PRBool bWin32BoundImage;
- uchar* databuf;
- uint32 bufsize;
-} DIFFDATA;
-
-typedef DIFFDATA* pDIFFDATA;
-
-
-/*--------------------------------------
- * miscellaneous
- *------------------------------------*/
-
-#define APPFLAG_W32BOUND "autoinstall:Win32PE"
-#define APPFLAG_APPLESINGLE "autoinstall:AppleSingle"
-
-#ifndef TRUE
- #define TRUE 1
-#endif
-
-#ifndef FALSE
- #define FALSE 0
-#endif
-
-
deleted file mode 100644
--- a/xpinstall/src/nsAppleSingleDecoder.cpp
+++ /dev/null
@@ -1,713 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Samir Gehani <sgehani@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-#ifndef _NS_APPLESINGLEDECODER_H_
- #include "nsAppleSingleDecoder.h"
-#endif
-
-#include "MoreFilesX.h"
-
-#ifdef STANDALONE_ASD
-#include <iostream>
-using namespace std;
-#undef MOZILLA_CLIENT
-#endif
-
-#ifdef MOZILLA_CLIENT
- #include "nsISupportsUtils.h"
-#endif
-
-/*----------------------------------------------------------------------*
- * Constructors/Destructor
- *----------------------------------------------------------------------*/
-
-nsAppleSingleDecoder::nsAppleSingleDecoder(const FSRef *inRef, FSRef *outRef)
-: mInRef(NULL),
- mOutRef(NULL),
- mInRefNum(0),
- mRenameReqd(false)
-{
-#ifdef MOZILLA_CLIENT
- MOZ_COUNT_CTOR(nsAppleSingleDecoder);
-#endif
-
- if (inRef && outRef)
- {
- /* merely point to FSRefs, not own 'em */
- mInRef = inRef;
- mOutRef = outRef;
- }
-}
-
-nsAppleSingleDecoder::nsAppleSingleDecoder()
-: mInRef(NULL),
- mOutRef(NULL),
- mInRefNum(0),
- mRenameReqd(false)
-{
-#ifdef MOZILLA_CLIENT
- MOZ_COUNT_CTOR(nsAppleSingleDecoder);
-#endif
-}
-
-nsAppleSingleDecoder::~nsAppleSingleDecoder()
-{
- /* not freeing FSRefs since we don't own 'em */
-
-#ifdef MOZILLA_CLIENT
- MOZ_COUNT_DTOR(nsAppleSingleDecoder);
-#endif
-}
-
-#pragma mark -
-
-/*----------------------------------------------------------------------*
- * Public methods
- *----------------------------------------------------------------------*/
-OSErr
-nsAppleSingleDecoder::Decode()
-{
- OSErr err = noErr;
- ASHeader header;
- UInt32 bytesRead = sizeof(header);
- HFSUniStr255 nameInRef;
-
- // param check
- if (!mInRef || !mOutRef)
- return paramErr;
-
- // check for existence (and get leaf name for later renaming of decoded file)
- err = FSGetCatalogInfo(mInRef, kFSCatInfoNone, NULL, &nameInRef, NULL, NULL);
- if (err == fnfErr)
- return err;
-
- HFSUniStr255 dataForkName;
- MAC_ERR_CHECK(FSGetDataForkName( &dataForkName ));
- MAC_ERR_CHECK(FSOpenFork( mInRef, dataForkName.length, dataForkName.unicode,
- fsRdPerm, &mInRefNum ));
- MAC_ERR_CHECK(FSRead( mInRefNum, (long *)&bytesRead, &header ));
-
- if ( (bytesRead != sizeof(header)) ||
- (header.magicNum != APPLESINGLE_MAGIC) ||
- (header.versionNum != APPLESINGLE_VERSION) ||
- (header.numEntries == 0) ) // empty file?
- return -1;
-
- // create the outSpec which we'll rename correctly later
- FSRef parentRef;
- MAC_ERR_CHECK(FSGetParentRef( mInRef, &parentRef ));
- MAC_ERR_CHECK(FSMakeUnique( &parentRef, mOutRef ));
- MAC_ERR_CHECK(FSCreateFork( mOutRef, dataForkName.length,
- dataForkName.unicode ));
-
- /* Loop through the entries, processing each.
- ** Set the time/date stamps last, because otherwise they'll
- ** be destroyed when we write.
- */
- {
- Boolean hasDateEntry = false;
- ASEntry dateEntry;
- long offset;
- ASEntry entry;
-
- for ( int i=0; i < header.numEntries; i++ )
- {
- offset = sizeof( ASHeader ) + sizeof( ASEntry ) * i;
- MAC_ERR_CHECK(SetFPos( mInRefNum, fsFromStart, offset ));
-
- bytesRead = sizeof(entry);
- MAC_ERR_CHECK(FSRead( mInRefNum, (long *) &bytesRead, &entry ));
- if (bytesRead != sizeof(entry))
- return -1;
-
- if ( entry.entryID == AS_FILEDATES )
- {
- hasDateEntry = true;
- dateEntry = entry;
- }
- else
- MAC_ERR_CHECK(ProcessASEntry( entry ));
- }
- if ( hasDateEntry )
- MAC_ERR_CHECK(ProcessASEntry( dateEntry ));
- }
-
- // close the inSpec
- FSClose( mInRefNum );
-
- // rename if need be
- if (mRenameReqd)
- {
- // delete encoded version of target file
- MAC_ERR_CHECK(FSDeleteObject( mInRef ));
- MAC_ERR_CHECK(FSRenameUnicode( mOutRef, nameInRef.length,
- nameInRef.unicode, kTextEncodingUnknown, mOutRef ));
- mRenameReqd = false;
- }
-
- return err;
-}
-
-OSErr
-nsAppleSingleDecoder::Decode(const FSRef *inRef, FSRef *outRef)
-{
- OSErr err = noErr;
-
- // param check
- if (inRef && outRef)
- {
- mInRef = inRef; // reinit
- mOutRef = outRef;
- mRenameReqd = false;
- }
- else
- return paramErr;
-
- err = Decode();
-
- return err;
-}
-
-Boolean
-DecodeDirIterateFilter(Boolean containerChanged, ItemCount currentLevel,
- const FSCatalogInfo *catalogInfo, const FSRef *ref,
- const FSSpec *spec, const HFSUniStr255 *name, void *yourDataPtr)
-{
- FSRef outRef;
- nsAppleSingleDecoder *thisObj;
- Boolean isDir;
-
- // param check
- if (!yourDataPtr || !ref)
- return false;
-
- // extract 'this' -- an nsAppleSingleDecoder instance
- thisObj = (nsAppleSingleDecoder*) yourDataPtr;
-
- isDir = nsAppleSingleDecoder::IsDirectory(ref);
-
- // if current FSRef is file
- if (!isDir)
- {
- // if file is in AppleSingle format
- if (nsAppleSingleDecoder::IsAppleSingleFile(ref))
- {
- // decode file
- thisObj->Decode(ref, &outRef);
- }
- }
-
- // else current FSRef is folder
- else
- {
- thisObj->DecodeFolder(ref);
- }
-
- return false; // always continue iteration
-}
-
-OSErr
-nsAppleSingleDecoder::DecodeFolder(const FSRef *aFolder)
-{
- OSErr err;
- Boolean isDir = false;
-
- // check that FSSpec is folder
- if (aFolder)
- {
- isDir = IsDirectory((const FSRef *) aFolder);
- if (!isDir)
- return dirNFErr;
- }
-
- // recursively enumerate contents of folder
- // (maxLevels=0 means recurse all)
- err = FSIterateContainer(aFolder, 0, kFSCatInfoNone, false,
- false, DecodeDirIterateFilter, (void*)this);
-
- // XXX do we really want to return err?
- return err;
-}
-
-Boolean
-nsAppleSingleDecoder::IsAppleSingleFile(const FSRef *inRef)
-{
- OSErr err;
- SInt16 inRefNum;
- UInt32 magic;
- long bytesRead = sizeof(magic);
-
- // param checks
- if (!inRef)
- return false;
-
- // check for existence
- err = FSGetCatalogInfo(inRef, kFSCatInfoNone, NULL, NULL, NULL, NULL);
- if (err!=noErr)
- return false;
-
- // open and read the magic number len bytes
- HFSUniStr255 dataForkName;
- err = FSGetDataForkName( &dataForkName );
- if (err!=noErr)
- return false;
-
- err = FSOpenFork( inRef, dataForkName.length, dataForkName.unicode,
- fsRdPerm, &inRefNum );
- if (err!=noErr)
- return false;
-
- err = FSRead( inRefNum, &bytesRead, &magic );
- if (err!=noErr)
- return false;
-
- FSClose(inRefNum);
- if (bytesRead != sizeof(magic))
- return false;
-
- // check if bytes read match magic number
- return (magic == APPLESINGLE_MAGIC);
-}
-
-#pragma mark -
-
-/*----------------------------------------------------------------------*
- * Private methods
- *----------------------------------------------------------------------*/
-OSErr
-nsAppleSingleDecoder::ProcessASEntry(ASEntry inEntry)
-{
- switch (inEntry.entryID)
- {
- case AS_DATA:
- return ProcessDataFork( inEntry );
- break;
- case AS_RESOURCE:
- return ProcessResourceFork( inEntry );
- break;
- case AS_REALNAME:
- ProcessRealName( inEntry );
- break;
- case AS_FILEDATES:
- return ProcessFileDates( inEntry );
- break;
- case AS_FINDERINFO:
- return ProcessFinderInfo( inEntry );
- break;
- case AS_MACINFO:
- case AS_COMMENT:
- case AS_ICONBW:
- case AS_ICONCOLOR:
- case AS_PRODOSINFO:
- case AS_MSDOSINFO:
- case AS_AFPNAME:
- case AS_AFPINFO:
- case AS_AFPDIRID:
- default:
- return 0;
- }
- return 0;
-}
-
-OSErr
-nsAppleSingleDecoder::ProcessDataFork(ASEntry inEntry)
-{
- OSErr err = noErr;
- SInt16 refNum;
-
- /* Setup the files */
- HFSUniStr255 dataForkName;
- err = FSGetDataForkName( &dataForkName );
- if (err != noErr)
- return err;
-
- err = FSOpenFork( mOutRef, dataForkName.length, dataForkName.unicode,
- fsWrPerm, &refNum );
-
- if ( err == noErr )
- err = EntryToMacFile( inEntry, refNum );
-
- FSClose( refNum );
- return err;
-}
-
-OSErr
-nsAppleSingleDecoder::ProcessResourceFork(ASEntry inEntry)
-{
- OSErr err = noErr;
- SInt16 refNum;
-
- HFSUniStr255 rsrcForkName;
- err = FSGetResourceForkName( &rsrcForkName );
- if (err != noErr)
- return err;
-
- err = FSOpenFork( mOutRef, rsrcForkName.length, rsrcForkName.unicode,
- fsWrPerm, &refNum );
-
- if ( err == noErr )
- err = EntryToMacFile( inEntry, refNum );
-
- FSClose( refNum );
- return err;
-}
-
-OSErr
-nsAppleSingleDecoder::ProcessRealName(ASEntry inEntry)
-{
- OSErr err = noErr;
- Str255 newName;
- HFSUniStr255 newNameUni;
- UInt32 bytesRead;
- FSRef parentOfOutRef;
-
- MAC_ERR_CHECK(SetFPos(mInRefNum, fsFromStart, inEntry.entryOffset));
-
- bytesRead = inEntry.entryLength;
- MAC_ERR_CHECK(FSRead(mInRefNum, (long *) &bytesRead, &newName[1]));
- if (bytesRead != inEntry.entryLength)
- return -1;
-
- newName[0] = inEntry.entryLength;
- MAC_ERR_CHECK(FSGetParentRef(mOutRef, &parentOfOutRef));
- MAC_ERR_CHECK(HFSNameGetUnicodeName(newName, kTextEncodingUnknown,
- &newNameUni));
- err = FSRenameUnicode(mOutRef, newNameUni.length, newNameUni.unicode,
- kTextEncodingUnknown, mOutRef);
- if (err == dupFNErr)
- {
- HFSUniStr255 inRefName;
- MAC_ERR_CHECK(FSGetCatalogInfo(mInRef, kFSCatInfoNone, NULL, &inRefName,
- NULL, NULL));
-
- // if we are trying to rename temp decode file to src name, rename later
- if (nsAppleSingleDecoder::UCstrcmp(&newNameUni, &inRefName))
- {
- mRenameReqd = true;
- return noErr;
- }
-
- // otherwise replace file in the way
- FSRef inTheWayRef;
-
- // delete file in the way
- MAC_ERR_CHECK(FSMakeFSRefUnicode( &parentOfOutRef, newNameUni.length,
- newNameUni.unicode, kTextEncodingUnknown, &inTheWayRef ));
- MAC_ERR_CHECK(FSDeleteObject( &inTheWayRef ));
-
- // rename decoded file to ``newName''
- MAC_ERR_CHECK(FSRenameUnicode( mOutRef, newNameUni.length,
- newNameUni.unicode, kTextEncodingUnknown, mOutRef ));
- }
-
- return err;
-}
-
-OSErr
-nsAppleSingleDecoder::ProcessFileDates(ASEntry inEntry)
-{
- OSErr err = noErr;
- ASFileDates dates;
- UInt32 bytesRead;
- FSCatalogInfo catInfo;
-
- if ( inEntry.entryLength != sizeof(dates) )
- return -1;
-
- MAC_ERR_CHECK(SetFPos(mInRefNum, fsFromStart, inEntry.entryOffset));
-
- bytesRead = inEntry.entryLength;
- MAC_ERR_CHECK(FSRead(mInRefNum, (long *) &bytesRead, &dates));
- if (bytesRead != inEntry.entryLength)
- return -1;
-
-#define YR_2000_SECONDS 3029529600
- LocalDateTime local = (LocalDateTime) {0, 0, 0};
-
- // set creation date
- local.lowSeconds = dates.create + YR_2000_SECONDS;
- ConvertLocalToUTCDateTime(&local, &catInfo.createDate);
-
- // set content modification date
- local.lowSeconds = dates.modify + YR_2000_SECONDS;
- ConvertLocalToUTCDateTime(&local, &catInfo.contentModDate);
-
- // set last access date
- local.lowSeconds = dates.access + YR_2000_SECONDS;
- ConvertLocalToUTCDateTime(&local, &catInfo.accessDate);
-
- // set backup date
- local.lowSeconds = dates.backup + YR_2000_SECONDS;
- ConvertLocalToUTCDateTime(&local, &catInfo.backupDate);
-
- // set attribute modification date
- GetUTCDateTime(&catInfo.attributeModDate, kUTCDefaultOptions);
-
- MAC_ERR_CHECK(FSSetCatalogInfo(mOutRef,
- kFSCatInfoCreateDate |
- kFSCatInfoContentMod |
- kFSCatInfoAttrMod |
- kFSCatInfoAccessDate |
- kFSCatInfoBackupDate,
- &catInfo));
-
- return err;
-}
-
-OSErr
-nsAppleSingleDecoder::ProcessFinderInfo(ASEntry inEntry)
-{
- OSErr err = noErr;
- ASFinderInfo info;
- UInt32 bytesRead;
- FSCatalogInfo catInfo;
-
- if (inEntry.entryLength != sizeof( ASFinderInfo ))
- return -1;
-
- MAC_ERR_CHECK(SetFPos(mInRefNum, fsFromStart, inEntry.entryOffset));
-
- bytesRead = sizeof(info);
- MAC_ERR_CHECK(FSRead(mInRefNum, (long *) &bytesRead, &info));
- if (bytesRead != inEntry.entryLength)
- return -1;
-
- MAC_ERR_CHECK(FSGetCatalogInfo(mOutRef, kFSCatInfoGettableInfo, &catInfo,
- NULL, NULL, NULL));
-
- BlockMoveData((const void *) &info.ioFlFndrInfo,
- (void *) &catInfo.finderInfo, sizeof(FInfo));
- BlockMoveData((const void *) &info.ioFlXFndrInfo,
- (void *) &catInfo.extFinderInfo, sizeof(FXInfo));
-
- MAC_ERR_CHECK(FSSetCatalogInfo(mOutRef,
- kFSCatInfoFinderInfo |
- kFSCatInfoFinderXInfo,
- &catInfo));
-
- return err;
-}
-
-OSErr
-nsAppleSingleDecoder::EntryToMacFile(ASEntry inEntry, UInt16 inTargetSpecRefNum)
-{
-#define BUFFER_SIZE 8192
-
- OSErr err = noErr;
- char buffer[BUFFER_SIZE];
- UInt32 totalRead = 0, bytesRead, bytesToWrite;
-
- MAC_ERR_CHECK(SetFPos( mInRefNum, fsFromStart, inEntry.entryOffset ));
-
- while ( totalRead < inEntry.entryLength )
- {
-// Should we yield in here?
- bytesRead = BUFFER_SIZE;
- err = FSRead( mInRefNum, (long *) &bytesRead, buffer );
- if (err!=noErr && err!=eofErr)
- return err;
-
- if ( bytesRead <= 0 )
- return -1;
- bytesToWrite = totalRead + bytesRead > inEntry.entryLength ?
- inEntry.entryLength - totalRead :
- bytesRead;
-
- totalRead += bytesRead;
- MAC_ERR_CHECK(FSWrite(inTargetSpecRefNum, (long *) &bytesToWrite,
- buffer));
- }
-
- return err;
-}
-
-#pragma mark -
-
-Boolean
-nsAppleSingleDecoder::IsDirectory(const FSRef *inRef)
-{
- OSErr err;
- Boolean isDir;
-
- if (!inRef)
- return false;
-
- err = FSGetFinderInfo(inRef, NULL, NULL, &isDir);
- if (err != noErr)
- return false;
-
- return isDir;
-}
-
-OSErr
-nsAppleSingleDecoder::FSMakeUnique(const FSRef *inParentRef, FSRef *outRef)
-{
-/*
-** This function has descended from Apple Sample Code, but we have
-** made changes. Specifically, this function descends from the
-** GenerateUniqueHFSUniStr() function in MoreFilesX.c, version 1.0.1.
-*/
-
- OSErr result = noErr;
- long i, startSeed = 0x4a696d4c; /* a fine unlikely filename */
- FSRefParam pb;
- unsigned char hexStr[17] = "0123456789ABCDEF";
- HFSUniStr255 uniqueName;
-
- /* set up the parameter block */
- pb.name = uniqueName.unicode;
- pb.nameLength = 8; /* always 8 characters */
- pb.textEncodingHint = kTextEncodingUnknown;
- pb.newRef = outRef;
- pb.ref = inParentRef;
-
- /* loop until we get fnfErr with a filename in both directories */
- result = noErr;
- while ( fnfErr != result )
- {
- /* convert startSeed to 8 character Unicode string */
- uniqueName.length = 8;
- for ( i = 0; i < 8; ++i )
- {
- uniqueName.unicode[i] = hexStr[((startSeed >> ((7-i)*4)) & 0xf)];
- }
-
- result = PBMakeFSRefUnicodeSync(&pb);
- if ( fnfErr == result )
- {
- OSErr err;
- MAC_ERR_CHECK(FSCreateFileUnicode(inParentRef, uniqueName.length,
- uniqueName.unicode, kFSCatInfoNone, NULL, outRef, NULL));
-
- return noErr;
- }
- else if ( noErr != result)
- {
- /* exit if anything other than noErr or fnfErr */
- return result;
- }
-
- /* increment seed for next pass through loop */
- ++(startSeed);
- }
-
- return result;
-}
-
-/*----------------------------------------------------------------------*
- * Utilities
- *----------------------------------------------------------------------*/
-Boolean
-nsAppleSingleDecoder::UCstrcmp(const HFSUniStr255 *str1,
- const HFSUniStr255 *str2)
-{
- OSStatus status;
- Boolean bEqual;
-
- status = UCCompareTextDefault(kUCCollateStandardOptions, str1->unicode,
- str1->length, str2->unicode, str2->length,
- &bEqual, NULL);
- if (status != noErr)
- return false;
-
- return bEqual;
-}
-
-#ifdef STANDALONE_ASD
-int
-main(int argc, char **argv)
-{
- OSErr err;
- FSRef encoded, decoded;
- nsAppleSingleDecoder *decoder = new nsAppleSingleDecoder;
- Boolean isDir;
-
- if (argc < 2)
- {
- cout << "usage: " << argv[0] << " <file/folder>" << endl
- << "\t\tAppleSingle encoded file path" << endl
- << "\t\tor" << endl
- << "\t\tfolder path containing AppleSingle encoded files." << endl;
- exit(-1);
- }
-
- err = FSPathMakeRef((const UInt8 *)argv[1], &encoded, &isDir);
- if (err != noErr)
- return 1;
-
- // handle AppleSingle encoded files
- if (!isDir)
- {
- Boolean isEncoded = nsAppleSingleDecoder::IsAppleSingleFile(&encoded);
- cout << "IsAppleSingleFile returned: " << (isEncoded ? "true" : "false")
- << endl;
-
- if (isEncoded)
- {
- err = decoder->Decode(&encoded, &decoded);
- cout << "Decode returned: " << err << endl;
- }
- }
-
- // handle folders containing AppleSingle encoded files
- else
- {
- err = decoder->DecodeFolder(&encoded);
- cout << "DecodeFolder returned: " << err << endl;
- }
-
- // verify out file (n/a for folders)
- if (!isDir)
- {
- err = FSGetCatalogInfo(&decoded, kFSCatInfoNone, NULL, NULL, NULL, NULL);
- if (err == noErr)
- {
- cout << "Decoded file appears to exist" << endl;
- char path[1024];
- FSRefMakePath(&decoded, (UInt8 *)path, 1024);
- cout << "Decoded file path: " << path << endl;
- }
- else
- cout << "Decoded file doesn't appear to exist: " << err << endl;
- }
-
- return 0;
-}
-#endif /* STANDALONE_ASD */
deleted file mode 100644
--- a/xpinstall/src/nsAppleSingleDecoder.h
+++ /dev/null
@@ -1,237 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Samir Gehani <sgehani@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-/*----------------------------------------------------------------------*
- * Implements a simple AppleSingle decoder, as described in RFC1740
- * http://andrew2.andrew.cmu.edu/rfc/rfc1740.html
- *----------------------------------------------------------------------*/
-
-#pragma options align=mac68k
-
-#ifndef _NS_APPLESINGLEDECODER_H_
-#define _NS_APPLESINGLEDECODER_H_
-
-#include <stdlib.h>
-#include <string.h>
-#include <Carbon/Carbon.h>
-
-
-/*----------------------------------------------------------------------*
- * Struct definitions from RFC1740
- *----------------------------------------------------------------------*/
-#define APPLESINGLE_MAGIC 0x00051600L
-#define APPLESINGLE_VERSION 0x00020000L
-
-typedef struct ASHeader /* header portion of AppleSingle */
-{
- /* AppleSingle = 0x00051600; AppleDouble = 0x00051607 */
- UInt32 magicNum; /* internal file type tag */
- UInt32 versionNum; /* format version: 2 = 0x00020000 */
- UInt8 filler[16]; /* filler, currently all bits 0 */
- UInt16 numEntries; /* number of entries which follow */
-} ASHeader ; /* ASHeader */
-
-typedef struct ASEntry /* one AppleSingle entry descriptor */
-{
- UInt32 entryID; /* entry type: see list, 0 invalid */
- UInt32 entryOffset; /* offset, in octets, from beginning */
- /* of file to this entry's data */
- UInt32 entryLength; /* length of data in octets */
-} ASEntry; /* ASEntry */
-
-typedef struct ASFinderInfo
-{
- FInfo ioFlFndrInfo; /* PBGetFileInfo() or PBGetCatInfo() */
- FXInfo ioFlXFndrInfo; /* PBGetCatInfo() (HFS only) */
-} ASFinderInfo; /* ASFinderInfo */
-
-typedef struct ASMacInfo /* entry ID 10, Macintosh file information */
-{
- UInt8 filler[3]; /* filler, currently all bits 0 */
- UInt8 ioFlAttrib; /* PBGetFileInfo() or PBGetCatInfo() */
-} ASMacInfo;
-
-typedef struct ASFileDates /* entry ID 8, file dates info */
-{
- SInt32 create; /* file creation date/time */
- SInt32 modify; /* last modification date/time */
- SInt32 backup; /* last backup date/time */
- SInt32 access; /* last access date/time */
-} ASFileDates; /* ASFileDates */
-
-/* entryID list */
-#define AS_DATA 1 /* data fork */
-#define AS_RESOURCE 2 /* resource fork */
-#define AS_REALNAME 3 /* File's name on home file system */
-#define AS_COMMENT 4 /* standard Mac comment */
-#define AS_ICONBW 5 /* Mac black & white icon */
-#define AS_ICONCOLOR 6 /* Mac color icon */
-/* 7 not used */
-#define AS_FILEDATES 8 /* file dates; create, modify, etc */
-#define AS_FINDERINFO 9 /* Mac Finder info & extended info */
-#define AS_MACINFO 10 /* Mac file info, attributes, etc */
-#define AS_PRODOSINFO 11 /* Pro-DOS file info, attrib., etc */
-#define AS_MSDOSINFO 12 /* MS-DOS file info, attributes, etc */
-#define AS_AFPNAME 13 /* Short name on AFP server */
-#define AS_AFPINFO 14 /* AFP file info, attrib., etc */
-
-#define AS_AFPDIRID 15 /* AFP directory ID */
-
-
-/*----------------------------------------------------------------------*
- * Macros
- *----------------------------------------------------------------------*/
-#define MAC_ERR_CHECK(_funcCall) \
- err = _funcCall; \
- if (err!=noErr) \
- return err;
-
-
-
-class nsAppleSingleDecoder
-{
-
-public:
- nsAppleSingleDecoder(const FSRef *inRef, FSRef *outRef);
- nsAppleSingleDecoder();
- ~nsAppleSingleDecoder();
-
- /**
- * Decode
- *
- * Takes an "in" FSSpec for the source file in AppleSingle
- * format to decode and write out to an "out" FSSpec.
- * This form is used when the Decode(void) method has already
- * been invoked once and this object is reused to decode
- * another AppleSingled file: useful in iteration to avoid
- * nsAppleSingleDecoder object instantiation per file.
- *
- * @param inRef the AppleSingled file to decode
- * @param outRef the destination file in which the decoded
- * data was written out (empty when passed in
- * and filled on return)
- * @return err a standard MacOS OSErr where noErr means OK
- */
- OSErr Decode(const FSRef *inRef, FSRef *outRef);
-
- /**
- * Decode
- *
- * Decodes the AppleSingled file passed in to the constructor
- * and writes out the decoded data to the outSpec passed to the
- * constructor.
- *
- * @return err a standard MacOS OSErr where noErr = OK
- */
- OSErr Decode();
-
- /**
- * DecodeFolder
- *
- * Traverses arbitrarily nested subdirs decoding any files
- * in AppleSingle format and leaving other files alone.
- *
- * @param aFolder the folder whose contents to decode
- * @return err a standard MacOS err
- * (dirNFErr if invalid dir, noErr = OK)
- */
- OSErr DecodeFolder(const FSRef *aFolder);
-
- /**
- * IsAppleSingleFile
- *
- * Checks the file header to see whether this is an AppleSingle
- * version 2 file by matching the magicNum field in the header.
- *
- * @param inRef the file to check
- * @return bAppleSingle a Boolean where true indicates this is
- * in fact an AppleSingle file
- */
- static Boolean IsAppleSingleFile(const FSRef *inRef);
-
- /**
- * IsDirectory
- *
- * Check whether the supplied FSSpec points to a directory.
- *
- * @param inRef the file/directory spec
- * @return bDir true iff this spec is a valid directory
- */
- static Boolean IsDirectory(const FSRef *inRef);
-
- /**
- * String utility wrapper to compare to Unicode filenames.
- */
- static Boolean UCstrcmp(const HFSUniStr255 *str1, const HFSUniStr255 *str2);
-
-private:
- const FSRef *mInRef;
- FSRef *mOutRef;
- // cache since it's used through the life of one Decode cycle:
- SInt16 mInRefNum;
- Boolean mRenameReqd;
-
- OSErr ProcessASEntry(ASEntry inEntry);
- OSErr ProcessDataFork(ASEntry inEntry);
- OSErr ProcessResourceFork(ASEntry inEntry);
- OSErr ProcessRealName(ASEntry inEntry);
- OSErr ProcessFileDates(ASEntry inEntry);
- OSErr ProcessFinderInfo(ASEntry inEntry);
- OSErr EntryToMacFile(ASEntry inEntry, UInt16 inTargetSpecRefNum);
-
- OSErr FSMakeUnique(const FSRef *inParentRef, FSRef *outRef);
-};
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-Boolean
-DecodeDirIterateFilter(Boolean containerChanged, ItemCount currentLevel,
- const FSCatalogInfo *catalogInfo, const FSRef *ref,
- const FSSpec *spec, const HFSUniStr255 *name, void *yourDataPtr);
-
-#ifdef __cplusplus
-}
-#endif
-
-#pragma options align=reset
-
-#endif /* _NS_APPLESINGLEDECODER_H_ */
deleted file mode 100644
--- a/xpinstall/src/nsInstall.cpp
+++ /dev/null
@@ -1,2785 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Daniel Veditz <dveditz@netscape.com>
- * Douglas Turner <dougt@netscape.com>
- * Jens Bannmann <jens.b@web.de>
- * Pierre Phaneuf <pp@ludusdesign.com>
- * Sean Su <ssu@netscape.com>
- * Samir Gehani <sgehani@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nscore.h"
-#include "nsIFactory.h"
-#include "nsISupports.h"
-#include "nsNativeCharsetUtils.h"
-#include "nsStringEnumerator.h"
-
-#include "nsIComponentManager.h"
-#include "nsIServiceManager.h"
-
-#include "nsHashtable.h"
-#include "nsIFileChannel.h"
-#include "nsDirectoryService.h"
-#include "nsDirectoryServiceDefs.h"
-#include "nsAppDirectoryServiceDefs.h"
-#include "nsDirectoryServiceUtils.h"
-#include "nsThreadUtils.h"
-
-#include "nsNetUtil.h"
-
-#include "nsIPrefBranch.h"
-#include "nsIPrefService.h"
-
-#include "prmem.h"
-#include "plstr.h"
-#include "prprf.h"
-#include "nsCRT.h"
-
-#include "VerReg.h"
-
-#include "nsInstall.h"
-#include "nsInstallFolder.h"
-#include "nsInstallVersion.h"
-#include "nsInstallFile.h"
-#include "nsInstallExecute.h"
-#include "nsInstallPatch.h"
-#include "nsInstallUninstall.h"
-#include "nsInstallResources.h"
-#include "nsXPIProxy.h"
-#include "nsRegisterItem.h"
-#include "nsNetUtil.h"
-#include "ScheduledTasks.h"
-#include "nsIPersistentProperties2.h"
-
-#include "nsIProxyObjectManager.h"
-#include "nsProxiedService.h"
-
-#ifdef _WINDOWS
-#include "nsWinReg.h"
-#include "nsWinProfile.h"
-#endif
-
-#include "nsInstallFileOpEnums.h"
-#include "nsInstallFileOpItem.h"
-
-#ifdef XP_MACOSX
-#include <Gestalt.h>
-#include "nsAppleSingleDecoder.h"
-#include "nsILocalFileMac.h"
-#endif
-
-#include "nsILocalFile.h"
-#include "nsIURL.h"
-
-#if defined(XP_UNIX) || defined(XP_BEOS)
-#include <sys/utsname.h>
-#endif
-
-#if defined(XP_WIN)
-#include <windows.h>
-#endif
-
-#if defined(XP_OS2)
-#define INCL_DOSMISC
-#include <os2.h>
-#endif
-
-#define kInstallLocaleProperties "chrome://global/locale/commonDialogs.properties"
-
-/**
- * Request that XPCOM perform an autoreg at startup. (Used
- * internally by XPI.) This basically drops a file next to the
- * application. The next time the application launches, XPCOM
- * sees the file, deletes it and autoregisters components.
- */
-static void
-NS_SoftwareUpdateRequestAutoReg()
-{
- nsresult rv;
- nsCOMPtr<nsIFile> file;
-
- if (nsSoftwareUpdate::GetProgramDirectory())
- // xpistub case, use target directory instead
- nsSoftwareUpdate::GetProgramDirectory()->Clone(getter_AddRefs(file));
- else
- NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
- getter_AddRefs(file));
-
- if (!file) {
- NS_WARNING("Getting NS_XPCOM_CURRENT_PROCESS_DIR failed");
- return;
- }
-
- file->AppendNative(nsDependentCString(".autoreg"));
-#ifdef DEBUG_timeless
- PRBool condition;
- if (NS_SUCCEEDED(file->IsDirectory(&condition)) && condition) {
- /* someone did this intentionally, no point in complaining */
- return;
- }
-#endif
-
- // Remove and recreate the file to update its timestamp.
- // .autoreg must be newer than compreg.dat for component registration
- // to occur.
-
- file->Remove(PR_FALSE);
- rv = file->Create(nsIFile::NORMAL_FILE_TYPE, 0666);
-
- if (NS_FAILED(rv)) {
- NS_WARNING("creating file failed");
- return;
- }
-}
-
-
-
-nsInstallInfo::nsInstallInfo(PRUint32 aInstallType,
- nsIFile* aFile,
- const PRUnichar* aURL,
- const PRUnichar* aArgs,
- nsIPrincipal* aPrincipal,
- PRUint32 flags,
- nsIXPIListener* aListener)
-: mPrincipal(aPrincipal),
- mError(0),
- mType(aInstallType),
- mFlags(flags),
- mURL(aURL),
- mArgs(aArgs),
- mFile(aFile),
- mListener(aListener)
-{
- MOZ_COUNT_CTOR(nsInstallInfo);
-
- nsresult rv;
-
- // Failure is an option, and will occur in the stub installer.
-
- nsCOMPtr<nsIThread> thread = do_GetMainThread();
-
- NS_WITH_ALWAYS_PROXIED_SERVICE(CHROMEREG_IFACE, cr,
- NS_CHROMEREGISTRY_CONTRACTID,
- thread, &rv);
- if (NS_SUCCEEDED(rv)) {
- mChromeRegistry = cr;
-
-#ifndef MOZ_XUL_APP
- nsCAutoString spec;
- rv = NS_GetURLSpecFromFile(aFile, spec);
- if (NS_SUCCEEDED(rv)) {
- spec.Insert(NS_LITERAL_CSTRING("jar:"), 0);
- spec.AppendLiteral("!/");
- mFileJARSpec.Assign(spec);
- }
-#endif
- }
-
-#ifdef MOZ_XUL_APP
- NS_WITH_ALWAYS_PROXIED_SERVICE(nsIExtensionManager, em,
- "@mozilla.org/extensions/manager;1",
- thread, &rv);
- if (NS_SUCCEEDED(rv))
- mExtensionManager = em;
-#endif
-}
-
-
-nsInstallInfo::~nsInstallInfo()
-{
- MOZ_COUNT_DTOR(nsInstallInfo);
-}
-
-static NS_DEFINE_IID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID);
-
-
-nsInstall::nsInstall(nsIZipReader * theJARFile)
-{
- MOZ_COUNT_CTOR(nsInstall);
-
- mScriptObject = nsnull; // this is the jsobject for our context
- mVersionInfo = nsnull; // this is the version information passed to us in StartInstall()
- mInstalledFiles = nsnull; // the list of installed objects
-// mRegistryPackageName = ""; // this is the name that we will add into the registry for the component we are installing
-// mUIName = ""; // this is the name that will be displayed in UI.
- mPatchList = nsnull;
- mUninstallPackage = PR_FALSE;
- mRegisterPackage = PR_FALSE;
- mFinalStatus = SUCCESS;
- mStartInstallCompleted = PR_FALSE;
- mJarFileLocation = nsnull;
- //mInstallArguments = "";
- mPackageFolder = nsnull;
-
- // mJarFileData is an opaque handle to the jarfile.
- mJarFileData = theJARFile;
-
- nsISoftwareUpdate *su;
- nsresult rv = CallGetService(kSoftwareUpdateCID, &su);
-
- if (NS_SUCCEEDED(rv))
- {
- su->GetMasterListener( getter_AddRefs(mListener) );
- }
-
- su->Release();
-
- nsCOMPtr<nsIThread> thread = do_GetMainThread();
-
- // get the resourced xpinstall string bundle
- mStringBundle = nsnull;
- NS_WITH_PROXIED_SERVICE( nsIStringBundleService,
- service,
- NS_STRINGBUNDLE_CONTRACTID,
- thread,
- &rv );
-
- if (NS_SUCCEEDED(rv) && service)
- {
- rv = service->CreateBundle( XPINSTALL_BUNDLE_URL,
- getter_AddRefs(mStringBundle) );
- }
-}
-
-nsInstall::~nsInstall()
-{
- if (mVersionInfo != nsnull)
- delete mVersionInfo;
-
- if (mPackageFolder)
- delete mPackageFolder;
-
- MOZ_COUNT_DTOR(nsInstall);
-}
-
-PRInt32
-nsInstall::SetScriptObject(void *aScriptObject)
-{
- mScriptObject = (JSObject*) aScriptObject;
- return NS_OK;
-}
-
-#ifdef _WINDOWS
-PRInt32
-nsInstall::SaveWinRegPrototype(void *aScriptObject)
-{
- mWinRegObject = (JSObject*) aScriptObject;
- return NS_OK;
-}
-PRInt32
-nsInstall::SaveWinProfilePrototype(void *aScriptObject)
-{
- mWinProfileObject = (JSObject*) aScriptObject;
- return NS_OK;
-}
-
-JSObject*
-nsInstall::RetrieveWinRegPrototype()
-{
- return mWinRegObject;
-}
-
-JSObject*
-nsInstall::RetrieveWinProfilePrototype()
-{
- return mWinProfileObject;
-}
-#endif
-
-
-PRInt32
-nsInstall::GetInstallPlatform(nsCString& aPlatform)
-{
- if (mInstallPlatform.IsEmpty())
- {
- // Duplicated from mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp
- // which is not yet available in a wizard install
-
- // Gather platform.
-#if defined(XP_WIN)
- mInstallPlatform = "Windows";
-#elif defined(XP_MACOSX)
- mInstallPlatform = "Macintosh";
-#elif defined (XP_UNIX)
- mInstallPlatform = "X11";
-#elif defined(XP_BEOS)
- mInstallPlatform = "BeOS";
-#elif defined(XP_OS2)
- mInstallPlatform = "OS/2";
-#endif
-
- mInstallPlatform += "; ";
-
- // Gather OS/CPU.
-#if defined(XP_WIN)
- OSVERSIONINFO info = { sizeof(OSVERSIONINFO) };
- if (GetVersionEx(&info)) {
- if ( info.dwPlatformId == VER_PLATFORM_WIN32_NT ) {
- if (info.dwMajorVersion == 3) {
- mInstallPlatform += "WinNT3.51";
- }
- else if (info.dwMajorVersion == 4) {
- mInstallPlatform += "WinNT4.0";
- }
- else if (info.dwMajorVersion == 5) {
- mInstallPlatform += "Windows NT 5.0";
- }
- else {
- mInstallPlatform += "WinNT";
- }
- } else if (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
- if (info.dwMinorVersion == 90)
- mInstallPlatform += "Win 9x 4.90";
- else if (info.dwMinorVersion > 0)
- mInstallPlatform += "Win98";
- else
- mInstallPlatform += "Win95";
- }
- }
-#elif defined (XP_UNIX) || defined (XP_BEOS)
- struct utsname name;
-
- int ret = uname(&name);
- if (ret >= 0) {
- mInstallPlatform += (char*)name.sysname;
- mInstallPlatform += ' ';
- mInstallPlatform += (char*)name.release;
- mInstallPlatform += ' ';
- mInstallPlatform += (char*)name.machine;
- }
-#elif defined(XP_MACOSX)
- mInstallPlatform += "PPC";
-#elif defined(XP_OS2)
- ULONG os2ver = 0;
- DosQuerySysInfo(QSV_VERSION_MINOR, QSV_VERSION_MINOR,
- &os2ver, sizeof(os2ver));
- if (os2ver == 11)
- mInstallPlatform += "2.11";
- else if (os2ver == 30)
- mInstallPlatform += "Warp 3";
- else if (os2ver == 40)
- mInstallPlatform += "Warp 4";
- else if (os2ver == 45)
- mInstallPlatform += "Warp 4.5";
- else
- mInstallPlatform += "Warp ???";
-#endif
- }
-
- aPlatform = mInstallPlatform;
- return NS_OK;
-}
-
-
-void
-nsInstall::InternalAbort(PRInt32 errcode)
-{
- mFinalStatus = errcode;
-
- nsInstallObject* ie;
- if (mInstalledFiles != nsnull)
- {
- // abort must work backwards through the list so cleanup can
- // happen in the correct order
- for (PRInt32 i = mInstalledFiles->Count()-1; i >= 0; i--)
- {
- ie = (nsInstallObject *)mInstalledFiles->ElementAt(i);
- if (ie)
- ie->Abort();
- }
- }
-
- CleanUp();
-}
-
-PRInt32
-nsInstall::AbortInstall(PRInt32 aErrorNumber)
-{
- InternalAbort(aErrorNumber);
- return NS_OK;
-}
-
-PRInt32
-nsInstall::AddDirectory(const nsString& aRegName,
- const nsString& aVersion,
- const nsString& aJarSource,
- nsInstallFolder *aFolder,
- const nsString& aSubdir,
- PRInt32 aMode,
- PRInt32* aReturn)
-{
- nsInstallFile* ie = nsnull;
- PRInt32 result;
-
- if ( aJarSource.IsEmpty() || aFolder == nsnull )
- {
- *aReturn = SaveError(nsInstall::INVALID_ARGUMENTS);
- return NS_OK;
- }
-
- result = SanityCheck();
-
- if (result != nsInstall::SUCCESS)
- {
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- // Default subName = location in jar file
- nsString qualifiedRegName;
- result = GetQualifiedRegName( aRegName.IsEmpty() ? aJarSource : aRegName,
- qualifiedRegName);
-
- if (result != nsInstall::SUCCESS)
- {
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- nsString qualifiedVersion = aVersion;
- if (qualifiedVersion.IsEmpty())
- {
- // assume package version for overriden forms that don't take version info
- *aReturn = mVersionInfo->ToString(qualifiedVersion);
-
- if (NS_FAILED(*aReturn))
- {
- SaveError( nsInstall::UNEXPECTED_ERROR );
- return NS_OK;
- }
- }
-
- nsAutoString subdirectory(aSubdir);
- if (!subdirectory.IsEmpty())
- subdirectory.AppendLiteral("/");
-
- nsAutoString prefix(aJarSource + NS_LITERAL_STRING("/"));
- const PRInt32 prefix_length = prefix.Length();
- NS_LossyConvertUTF16toASCII pattern(prefix + NS_LITERAL_STRING("*"));
-
- nsCOMPtr<nsIUTF8StringEnumerator> jarEnum;
- nsresult rv = mJarFileData->FindEntries(pattern.get(),
- getter_AddRefs(jarEnum) );
- if (NS_FAILED(rv) || !jarEnum)
- {
- *aReturn = SaveError( nsInstall::EXTRACTION_FAILED );
- return NS_OK;
- }
-
- PRInt32 count = 0;
- PRBool bMore = PR_FALSE;
- while (NS_SUCCEEDED(jarEnum->HasMore(&bMore)) && bMore)
- {
- nsCAutoString name;
- rv = jarEnum->GetNext(name);
- if (NS_FAILED(rv))
- {
- result = nsInstall::EXTRACTION_FAILED;
- break;
- }
-
- if ( name.Last() == '/' )
- {
- // Skip the directory entries
- continue;
- }
- const PRInt32 namelen = name.Length();
- NS_ASSERTION( prefix_length <= namelen, "Match must be longer than pattern!" );
- NS_ConvertASCIItoUTF16 fileName(Substring(name,
- prefix_length,
- namelen - prefix_length));
- nsAutoString newJarSource(prefix + fileName);
- nsAutoString newSubDir(subdirectory + fileName);
-
- ie = new nsInstallFile( this,
- qualifiedRegName,
- qualifiedVersion,
- newJarSource,
- aFolder,
- newSubDir,
- aMode,
- (count == 0), // register the first one only
- &result);
-
- if (ie == nsnull)
- {
- result = nsInstall::OUT_OF_MEMORY;
- }
- else if (result != nsInstall::SUCCESS)
- {
- delete ie;
- }
- else
- {
- result = ScheduleForInstall( ie );
- count++;
- }
- }
-
- if (result == nsInstall::SUCCESS && count == 0)
- result = nsInstall::DOES_NOT_EXIST;
-
- *aReturn = SaveError( result );
- return NS_OK;
-}
-
-PRInt32
-nsInstall::AddDirectory(const nsString& aRegName,
- const nsString& aVersion,
- const nsString& aJarSource,
- nsInstallFolder *aFolder,
- const nsString& aSubdir,
- PRInt32* aReturn)
-{
- return AddDirectory(aRegName,
- aVersion,
- aJarSource,
- aFolder,
- aSubdir,
- INSTALL_NO_COMPARE,
- aReturn);
-}
-
-PRInt32
-nsInstall::AddDirectory(const nsString& aRegName,
- const nsString& aJarSource,
- nsInstallFolder *aFolder,
- const nsString& aSubdir,
- PRInt32* aReturn)
-{
- return AddDirectory(aRegName,
- EmptyString(),
- aJarSource,
- aFolder,
- aSubdir,
- INSTALL_NO_COMPARE,
- aReturn);
-}
-
-PRInt32
-nsInstall::AddDirectory(const nsString& aJarSource,
- PRInt32* aReturn)
-{
- if(mPackageFolder == nsnull)
- {
- *aReturn = SaveError( nsInstall::PACKAGE_FOLDER_NOT_SET );
- return NS_OK;
- }
-
- return AddDirectory(EmptyString(),
- EmptyString(),
- aJarSource,
- mPackageFolder,
- EmptyString(),
- INSTALL_NO_COMPARE,
- aReturn);
-}
-
-PRInt32
-nsInstall::AddSubcomponent(const nsString& aRegName,
- const nsString& aVersion,
- const nsString& aJarSource,
- nsInstallFolder *aFolder,
- const nsString& aTargetName,
- PRInt32 aMode,
- PRInt32* aReturn)
-{
- nsInstallFile* ie;
- nsString qualifiedRegName;
- nsString qualifiedVersion = aVersion;
- nsString tempTargetName = aTargetName;
-
- PRInt32 errcode = nsInstall::SUCCESS;
-
-
- if(aJarSource.IsEmpty() || aFolder == nsnull )
- {
- *aReturn = SaveError( nsInstall::INVALID_ARGUMENTS );
- return NS_OK;
- }
-
- PRInt32 result = SanityCheck();
-
- if (result != nsInstall::SUCCESS)
- {
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- if( aTargetName.IsEmpty() )
- {
- PRInt32 pos = aJarSource.RFindChar('/');
-
- if ( pos == kNotFound )
- tempTargetName = aJarSource;
- else
- aJarSource.Right(tempTargetName, aJarSource.Length() - (pos+1));
- }
-
- if (qualifiedVersion.IsEmpty())
- qualifiedVersion.AssignLiteral("0.0.0.0");
-
- // Default subName = location in jar file
- result = GetQualifiedRegName( aRegName.IsEmpty() ? aJarSource : aRegName,
- qualifiedRegName);
-
- if (result != nsInstall::SUCCESS)
- {
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
-
- ie = new nsInstallFile( this,
- qualifiedRegName,
- qualifiedVersion,
- aJarSource,
- aFolder,
- tempTargetName,
- aMode,
- PR_TRUE,
- &errcode );
-
- if (ie == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- if (errcode == nsInstall::SUCCESS)
- {
- errcode = ScheduleForInstall( ie );
- }
- else
- {
- delete ie;
- }
-
- *aReturn = SaveError( errcode );
- return NS_OK;
-}
-
-PRInt32
-nsInstall::AddSubcomponent(const nsString& aRegName,
- const nsString& aVersion,
- const nsString& aJarSource,
- nsInstallFolder* aFolder,
- const nsString& aTargetName,
- PRInt32* aReturn)
-{
- return AddSubcomponent(aRegName,
- aVersion,
- aJarSource,
- aFolder,
- aTargetName,
- INSTALL_NO_COMPARE,
- aReturn);
-}
-
-PRInt32
-nsInstall::AddSubcomponent(const nsString& aRegName,
- const nsString& aJarSource,
- nsInstallFolder* aFolder,
- const nsString& aTargetName,
- PRInt32* aReturn)
-{
- PRInt32 result = SanityCheck();
-
- if (result != nsInstall::SUCCESS)
- {
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- nsString version;
- *aReturn = mVersionInfo->ToString(version);
-
- if (NS_FAILED(*aReturn))
- {
- SaveError( nsInstall::UNEXPECTED_ERROR );
- return NS_OK;
- }
-
- return AddSubcomponent(aRegName,
- version,
- aJarSource,
- aFolder,
- aTargetName,
- INSTALL_NO_COMPARE,
- aReturn);
-}
-
-PRInt32
-nsInstall::AddSubcomponent(const nsString& aJarSource,
- PRInt32* aReturn)
-{
- if(mPackageFolder == nsnull)
- {
- *aReturn = SaveError( nsInstall::PACKAGE_FOLDER_NOT_SET );
- return NS_OK;
- }
- PRInt32 result = SanityCheck();
-
- if (result != nsInstall::SUCCESS)
- {
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- nsString version;
- *aReturn = mVersionInfo->ToString(version);
-
- if (NS_FAILED(*aReturn))
- {
- SaveError( nsInstall::UNEXPECTED_ERROR );
- return NS_OK;
- }
-
- return AddSubcomponent(EmptyString(),
- version,
- aJarSource,
- mPackageFolder,
- EmptyString(),
- INSTALL_NO_COMPARE,
- aReturn);
-}
-
-
-PRInt32
-nsInstall::DiskSpaceAvailable(const nsString& aFolder, PRInt64* aReturn)
-{
- PRInt32 result = SanityCheck();
-
- if (result != nsInstall::SUCCESS)
- {
- double d = SaveError( result );
- LL_L2D(d, *aReturn);
- return NS_OK;
- }
- nsCOMPtr<nsILocalFile> folder;
- NS_NewLocalFile(aFolder, PR_TRUE, getter_AddRefs(folder));
-
- result = folder->GetDiskSpaceAvailable(aReturn);
- return NS_OK;
-}
-
-PRInt32
-nsInstall::Execute(const nsString& aJarSource, const nsString& aArgs, PRBool aBlocking, PRInt32* aReturn)
-{
- PRInt32 result = SanityCheck();
-
- if (result != nsInstall::SUCCESS)
- {
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- nsInstallExecute* ie = new nsInstallExecute(this, aJarSource, aArgs, aBlocking, &result);
-
- if (ie == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- if (result == nsInstall::SUCCESS)
- {
- result = ScheduleForInstall( ie );
- }
-
- *aReturn = SaveError(result);
- return NS_OK;
-}
-
-
-PRInt32
-nsInstall::FinalizeInstall(PRInt32* aReturn)
-{
- PRInt32 result = SUCCESS;
- PRBool rebootNeeded = PR_FALSE;
-
- *aReturn = SanityCheck();
-
- if (*aReturn != nsInstall::SUCCESS)
- {
- SaveError( *aReturn );
- mFinalStatus = *aReturn;
- return NS_OK;
- }
-
-
- if ( mInstalledFiles->Count() > 0 )
- {
- if ( mUninstallPackage )
- {
- VR_UninstallCreateNode( const_cast<char *>(NS_ConvertUTF16toUTF8(mRegistryPackageName).get()),
- const_cast<char *>(NS_ConvertUTF16toUTF8(mUIName).get()));
- }
-
- // Install the Component into the Version Registry.
- if (mVersionInfo)
- {
- nsString versionString;
- nsCString path;
-
- mVersionInfo->ToString(versionString);
- nsCAutoString versionCString;
- versionCString.AssignWithConversion(versionString);
-
- if (mPackageFolder)
- mPackageFolder->GetDirectoryPath(path);
-
- VR_Install( const_cast<char *>(NS_ConvertUTF16toUTF8(mRegistryPackageName).get()),
- const_cast<char *>(path.get()),
- const_cast<char *>(versionCString.get()),
- PR_TRUE );
- }
-
- nsInstallObject* ie = nsnull;
-
- for (PRInt32 i=0; i < mInstalledFiles->Count(); i++)
- {
- ie = (nsInstallObject*)mInstalledFiles->ElementAt(i);
- NS_ASSERTION(ie, "NULL object in install queue!");
- if (ie == NULL)
- continue;
-
- if (mListener)
- {
- char *objString = ie->toString();
- if (objString)
- {
- mListener->OnFinalizeProgress(
- NS_ConvertASCIItoUTF16(objString).get(),
- (i+1), mInstalledFiles->Count());
- delete [] objString;
- }
- }
-
- result = ie->Complete();
-
- if (result != nsInstall::SUCCESS)
- {
- if ( result == REBOOT_NEEDED )
- {
- rebootNeeded = PR_TRUE;
- result = SUCCESS;
- }
- else
- {
- InternalAbort( result );
- break;
- }
- }
- }
-
- if ( result == SUCCESS )
- {
- if ( rebootNeeded )
- *aReturn = SaveError( REBOOT_NEEDED );
-
- if ( nsSoftwareUpdate::mNeedCleanup )
- {
- // Broadcast the fact that we have an incomplete install so
- // parts of Mozilla can take defensive action if necessary.
- //
- // This notification turns off turbo/server mode, for example
- nsPIXPIProxy* proxy = GetUIThreadProxy();
- if (proxy)
- proxy->NotifyRestartNeeded();
- }
-
- // XXX for now all successful installs will trigger an Autoreg.
- // We eventually want to do this only when flagged.
- NS_SoftwareUpdateRequestAutoReg();
- }
- else
- *aReturn = SaveError( result );
-
- mFinalStatus = *aReturn;
- }
- else
- {
- // no actions queued: don't register the package version
- // and no need for user confirmation
-
- mFinalStatus = *aReturn;
- }
-
- CleanUp();
-
- return NS_OK;
-}
-
-#ifdef XP_MACOSX
-#define GESTALT_CHAR_CODE(x) (((unsigned long) ((x[0]) & 0x000000FF)) << 24) \
- | (((unsigned long) ((x[1]) & 0x000000FF)) << 16) \
- | (((unsigned long) ((x[2]) & 0x000000FF)) << 8) \
- | (((unsigned long) ((x[3]) & 0x000000FF)))
-#endif
-
-PRInt32
-nsInstall::Gestalt(const nsString& aSelector, PRInt32* aReturn)
-{
- *aReturn = nsnull;
-
- PRInt32 result = SanityCheck();
-
- if (result != nsInstall::SUCCESS)
- {
- *aReturn = SaveError( result );
- return NS_OK;
- }
-#ifdef XP_MACOSX
-
- long response = 0;
- char selectorChars[4];
- int i;
- OSErr err = noErr;
- OSType selector;
-
- if (aSelector.IsEmpty())
- {
- return NS_OK;
- }
-
- for (i=0; i<4; i++)
- selectorChars[i] = aSelector.CharAt(i);
- selector = GESTALT_CHAR_CODE(selectorChars);
-
- err = ::Gestalt(selector, &response);
-
- if (err != noErr)
- *aReturn = err;
- else
- *aReturn = response;
-
-#endif /* XP_MACOSX */
- return NS_OK;
-}
-
-PRInt32
-nsInstall::GetComponentFolder(const nsString& aComponentName, const nsString& aSubdirectory, nsInstallFolder** aNewFolder)
-{
- long err;
- char dir[MAXREGPATHLEN];
- nsresult res = NS_OK;
-
- if(!aNewFolder)
- return INVALID_ARGUMENTS;
-
- *aNewFolder = nsnull;
-
-
- nsString tempString;
-
- if ( GetQualifiedPackageName(aComponentName, tempString) != SUCCESS )
- {
- return NS_OK;
- }
-
- NS_ConvertUTF16toUTF8 componentCString(tempString);
-
- if((err = VR_GetDefaultDirectory( const_cast<char *>(componentCString.get()), sizeof(dir), dir )) != REGERR_OK)
- {
- // if there's not a default directory, try to see if the component
- // // is registered as a file and then strip the filename off the path
- if((err = VR_GetPath( const_cast<char *>(componentCString.get()), sizeof(dir), dir )) != REGERR_OK)
- {
- // no path, either
- *dir = '\0';
- }
- }
-
- nsCOMPtr<nsILocalFile> componentDir;
- nsCOMPtr<nsIFile> componentIFile;
- if(*dir != '\0')
- NS_NewNativeLocalFile( nsDependentCString(dir), PR_FALSE, getter_AddRefs(componentDir) );
-
- if ( componentDir )
- {
- PRBool isFile;
-
- res = componentDir->IsFile(&isFile);
- if (NS_SUCCEEDED(res) && isFile)
- componentDir->GetParent(getter_AddRefs(componentIFile));
- else
- componentIFile = do_QueryInterface(componentDir);
-
- nsInstallFolder * folder = new nsInstallFolder();
- if (!folder)
- return NS_ERROR_OUT_OF_MEMORY;
-
- res = folder->Init(componentIFile, aSubdirectory);
- if (NS_FAILED(res))
- {
- delete folder;
- }
- else
- {
- *aNewFolder = folder;
- }
- }
-
- return res;
-}
-
-PRInt32
-nsInstall::GetComponentFolder(const nsString& aComponentName, nsInstallFolder** aNewFolder)
-{
- return GetComponentFolder(aComponentName, EmptyString(), aNewFolder);
-}
-
-PRInt32
-nsInstall::GetFolder(const nsString& targetFolder, const nsString& aSubdirectory, nsInstallFolder** aNewFolder)
-{
- /* This version of GetFolder takes an nsString object as the first param */
- if (!aNewFolder)
- return INVALID_ARGUMENTS;
-
- * aNewFolder = nsnull;
-
- nsInstallFolder* folder = new nsInstallFolder();
- if (folder == nsnull)
- {
- return NS_ERROR_OUT_OF_MEMORY;
- }
- nsresult res = folder->Init(targetFolder, aSubdirectory);
-
- if (NS_FAILED(res))
- {
- delete folder;
- return res;
- }
- *aNewFolder = folder;
- return NS_OK;
-}
-
-PRInt32
-nsInstall::GetFolder(const nsString& targetFolder, nsInstallFolder** aNewFolder)
-{
- /* This version of GetFolder takes an nsString object as the only param */
- return GetFolder(targetFolder, EmptyString(), aNewFolder);
-}
-
-PRInt32
-nsInstall::GetFolder( nsInstallFolder& aTargetFolderObj, const nsString& aSubdirectory, nsInstallFolder** aNewFolder )
-{
- /* This version of GetFolder takes an nsString object as the first param */
- if (!aNewFolder)
- return INVALID_ARGUMENTS;
-
- * aNewFolder = nsnull;
-
- nsInstallFolder* folder = new nsInstallFolder();
- if (folder == nsnull)
- {
- return NS_ERROR_OUT_OF_MEMORY;
- }
- nsresult res = folder->Init(aTargetFolderObj, aSubdirectory);
-
- if (NS_FAILED(res))
- {
- delete folder;
- return res;
- }
- *aNewFolder = folder;
- return NS_OK;
-}
-
-
-
-
-PRInt32
-nsInstall::GetLastError(PRInt32* aReturn)
-{
- *aReturn = mLastError;
- return NS_OK;
-}
-
-PRInt32
-nsInstall::GetWinProfile(const nsString& aFolder, const nsString& aFile, JSContext* jscontext, JSClass* WinProfileClass, jsval* aReturn)
-{
- *aReturn = JSVAL_NULL;
-
- if (SanityCheck() != nsInstall::SUCCESS)
- {
- return NS_OK;
- }
-
-#ifdef _WINDOWS
- JSObject* winProfileObject;
- nsWinProfile* nativeWinProfileObject = new nsWinProfile(this, aFolder, aFile);
-
- if (nativeWinProfileObject == nsnull)
- return NS_OK;
-
- JSObject* winProfilePrototype = this->RetrieveWinProfilePrototype();
-
- winProfileObject = JS_NewObject(jscontext, WinProfileClass, winProfilePrototype, NULL);
- if(winProfileObject == NULL)
- return NS_OK;
-
- JS_SetPrivate(jscontext, winProfileObject, nativeWinProfileObject);
-
- *aReturn = OBJECT_TO_JSVAL(winProfileObject);
-#endif /* _WINDOWS */
-
- return NS_OK;
-}
-
-PRInt32
-nsInstall::GetWinRegistry(JSContext* jscontext, JSClass* WinRegClass, jsval* aReturn)
-{
- *aReturn = JSVAL_NULL;
-
- if (SanityCheck() != nsInstall::SUCCESS)
- {
- return NS_OK;
- }
-
-#ifdef _WINDOWS
- JSObject* winRegObject;
- nsWinReg* nativeWinRegObject = new nsWinReg(this);
-
- if (nativeWinRegObject == nsnull)
- return NS_OK;
-
- JSObject* winRegPrototype = this->RetrieveWinRegPrototype();
-
- winRegObject = JS_NewObject(jscontext, WinRegClass, winRegPrototype, NULL);
- if(winRegObject == NULL)
- return NS_OK;
-
- JS_SetPrivate(jscontext, winRegObject, nativeWinRegObject);
-
- *aReturn = OBJECT_TO_JSVAL(winRegObject);
-#endif /* _WINDOWS */
-
- return NS_OK;
-}
-
-PRInt32
-nsInstall::LoadResources(JSContext* cx, const nsString& aBaseName, jsval* aReturn)
-{
- *aReturn = JSVAL_NULL;
-
- if (SanityCheck() != nsInstall::SUCCESS)
- {
- return NS_OK;
- }
- nsresult ret;
- nsCOMPtr<nsIFile> resFile;
- nsIURI *url = nsnull;
- nsIStringBundleService* service = nsnull;
- nsIStringBundle* bundle = nsnull;
- nsCOMPtr<nsISimpleEnumerator> propEnum;
- jsval v = JSVAL_NULL;
-
- // set up JSObject to return
- JS_GetProperty( cx, JS_GetGlobalObject( cx ), "Object", &v );
- if (!v)
- {
- return NS_ERROR_NULL_POINTER;
- }
- JSClass *objclass = JS_GetClass( cx, JSVAL_TO_OBJECT(v) );
- JSObject *res = JS_NewObject( cx, objclass, JSVAL_TO_OBJECT(v), 0 );
-
- // extract properties file
- // XXX append locale info: lang code, country code, .properties suffix to aBaseName
- PRInt32 err = ExtractFileFromJar(aBaseName, nsnull, getter_AddRefs(resFile));
- if ( (!resFile) || (err != nsInstall::SUCCESS) )
- {
- SaveError( err );
- return NS_OK;
- }
-
- // initialize string bundle and related services
- ret = CallGetService(NS_STRINGBUNDLE_CONTRACTID, &service);
- if (NS_FAILED(ret))
- goto cleanup;
-
- // get the string bundle using the extracted properties file
-#if 1
- {
- nsCAutoString spec;
- ret = NS_GetURLSpecFromFile(resFile, spec);
- if (NS_FAILED(ret)) {
- NS_WARNING("cannot get url spec\n");
- NS_RELEASE(service);
- return ret;
- }
- ret = service->CreateBundle(spec.get(), &bundle);
- }
-#else
- ret = service->CreateBundle(url, &bundle);
-#endif
- if (NS_FAILED(ret))
- goto cleanup;
- ret = bundle->GetSimpleEnumeration(getter_AddRefs(propEnum));
- if (NS_FAILED(ret))
- goto cleanup;
-
- // set the variables of the JSObject to return using the StringBundle's
- // enumeration service
- PRBool hasMore;
- while (NS_SUCCEEDED(propEnum->HasMoreElements(&hasMore)) && hasMore)
- {
- nsCOMPtr<nsISupports> nextProp;
- ret = propEnum->GetNext(getter_AddRefs(nextProp));
- if (NS_FAILED(ret))
- goto cleanup;
-
- nsCOMPtr<nsIPropertyElement> propElem =
- do_QueryInterface(nextProp);
- if (!propElem)
- continue;
-
- nsAutoString pVal;
- nsCAutoString pKey;
- ret = propElem->GetKey(pKey);
- if (NS_FAILED(ret))
- goto cleanup;
- ret = propElem->GetValue(pVal);
- if (NS_FAILED(ret))
- goto cleanup;
-
- if (!pKey.IsEmpty() && !pVal.IsEmpty())
- {
- JSString* propValJSStr = JS_NewUCStringCopyZ(cx, reinterpret_cast<const jschar*>(pVal.get()));
- jsval propValJSVal = STRING_TO_JSVAL(propValJSStr);
- NS_ConvertUTF8toUTF16 UCKey(pKey);
- JS_SetUCProperty(cx, res, (jschar*)UCKey.get(), UCKey.Length(), &propValJSVal);
- }
- }
-
- *aReturn = OBJECT_TO_JSVAL(res);
- ret = nsInstall::SUCCESS;
-
-cleanup:
- SaveError( ret );
-
- // release services
- NS_IF_RELEASE( service );
-
- // release file, URL, StringBundle, Enumerator
- NS_IF_RELEASE( url );
- NS_IF_RELEASE( bundle );
-
- return NS_OK;
-}
-
-PRInt32
-nsInstall::Patch(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aTargetName, PRInt32* aReturn)
-{
- PRInt32 result = SanityCheck();
-
- if (result != nsInstall::SUCCESS)
- {
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- nsString qualifiedRegName;
-
- *aReturn = GetQualifiedRegName( aRegName, qualifiedRegName);
-
- if (*aReturn != SUCCESS)
- {
- return NS_OK;
- }
-
- if (!mPatchList)
- {
- mPatchList = new nsHashtable();
- if (mPatchList == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
- }
-
- nsInstallPatch* ip = new nsInstallPatch( this,
- qualifiedRegName,
- aVersion,
- aJarSource,
- aFolder,
- aTargetName,
- &result);
-
- if (ip == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- if (result == nsInstall::SUCCESS)
- {
- result = ScheduleForInstall( ip );
- }
-
- *aReturn = SaveError(result);
- return NS_OK;
-}
-
-PRInt32
-nsInstall::Patch(const nsString& aRegName, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aTargetName, PRInt32* aReturn)
-{
- return Patch(aRegName, EmptyString(), aJarSource, aFolder, aTargetName, aReturn);
-}
-
-PRInt32
-nsInstall::RegisterChrome(nsIFile* chrome, PRUint32 chromeType, const char* path)
-{
- PRInt32 result = SanityCheck();
- if (result != SUCCESS)
- return SaveError( result );
-
- if (!chrome || !chromeType)
- return SaveError( INVALID_ARGUMENTS );
-
- nsRegisterItem* ri = new nsRegisterItem(this, chrome, chromeType, path);
- if (ri == nsnull)
- return SaveError(OUT_OF_MEMORY);
- else
- return SaveError(ScheduleForInstall( ri ));
-}
-
-nsPIXPIProxy* nsInstall::GetUIThreadProxy()
-{
- if (!mUIThreadProxy)
- {
- nsresult rv;
- nsCOMPtr<nsPIXPIProxy> tmp(do_QueryInterface(new nsXPIProxy()));
- rv = NS_GetProxyForObject( NS_PROXY_TO_MAIN_THREAD,
- NS_GET_IID(nsPIXPIProxy), tmp,
- NS_PROXY_SYNC | NS_PROXY_ALWAYS,
- getter_AddRefs(mUIThreadProxy) );
- }
-
- return mUIThreadProxy;
-}
-
-PRInt32
-nsInstall::RefreshPlugins(PRBool aReloadPages)
-{
- nsPIXPIProxy* proxy = GetUIThreadProxy();
- if (!proxy)
- return UNEXPECTED_ERROR;
-
- return proxy->RefreshPlugins(aReloadPages);
-}
-
-
-PRInt32
-nsInstall::ResetError(PRInt32 aError)
-{
- mLastError = aError;
- return SUCCESS;
-}
-
-PRInt32
-nsInstall::SetPackageFolder(nsInstallFolder& aFolder)
-{
- if (mPackageFolder)
- delete mPackageFolder;
-
- nsInstallFolder* folder = new nsInstallFolder();
- if (folder == nsnull)
- {
- return OUT_OF_MEMORY;
- }
- nsresult res = folder->Init(aFolder, EmptyString());
-
- if (NS_FAILED(res))
- {
- delete folder;
- return UNEXPECTED_ERROR;
- }
- mPackageFolder = folder;
- return SUCCESS;
-}
-
-
-PRInt32
-nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aRegistryPackageName, const nsString& aVersion, PRInt32* aReturn)
-{
- if ( aUserPackageName.IsEmpty() )
- {
- // There must be some pretty name for the UI and the uninstall list
- *aReturn = SaveError(INVALID_ARGUMENTS);
- return NS_OK;
- }
-
- char szRegPackagePath[MAXREGPATHLEN];
-
- *szRegPackagePath = '0';
- *aReturn = nsInstall::SUCCESS;
-
- ResetError(nsInstall::SUCCESS);
-
- mUserCancelled = PR_FALSE;
-
- mUIName = aUserPackageName;
-
- *aReturn = GetQualifiedPackageName( aRegistryPackageName, mRegistryPackageName );
-
- if (*aReturn != nsInstall::SUCCESS)
- {
- SaveError( *aReturn );
- return NS_OK;
- }
-
- // initialize default version
- if (mVersionInfo != nsnull)
- delete mVersionInfo;
-
- mVersionInfo = new nsInstallVersion();
- if (mVersionInfo == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
- mVersionInfo->Init(aVersion);
-
- // initialize item queue
- mInstalledFiles = new nsVoidArray();
-
- if (mInstalledFiles == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- // initialize default folder if any (errors are OK)
- if (mPackageFolder != nsnull)
- delete mPackageFolder;
-
- mPackageFolder = nsnull;
- if(REGERR_OK == VR_GetDefaultDirectory(
- const_cast<char *>(NS_ConvertUTF16toUTF8(mRegistryPackageName).get()),
- sizeof(szRegPackagePath), szRegPackagePath))
- {
- // found one saved in the registry
- mPackageFolder = new nsInstallFolder();
- nsCOMPtr<nsILocalFile> packageDir;
- NS_NewNativeLocalFile(
- nsDependentCString(szRegPackagePath), // native path
- PR_FALSE, getter_AddRefs(packageDir) );
-
- if (mPackageFolder && packageDir)
- {
- if (NS_FAILED( mPackageFolder->Init(packageDir, EmptyString()) ))
- {
- delete mPackageFolder;
- mPackageFolder = nsnull;
- }
- }
- }
-
- // We've correctly initialized an install transaction
- // - note that for commands that are only valid within one
- // - save error in case script doesn't call performInstall or cancelInstall
- // - broadcast to listeners
- mStartInstallCompleted = PR_TRUE;
- mFinalStatus = MALFORMED_INSTALL;
- if (mListener)
- mListener->OnPackageNameSet(mInstallURL.get(), mUIName.get(), aVersion.get());
-
- return NS_OK;
-}
-
-
-PRInt32
-nsInstall::Uninstall(const nsString& aRegistryPackageName, PRInt32* aReturn)
-{
- PRInt32 result = SanityCheck();
-
- if (result != nsInstall::SUCCESS)
- {
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- nsString qualifiedPackageName;
-
- *aReturn = GetQualifiedPackageName( aRegistryPackageName, qualifiedPackageName );
-
- if (*aReturn != SUCCESS)
- {
- return NS_OK;
- }
-
- nsInstallUninstall *ie = new nsInstallUninstall( this,
- qualifiedPackageName,
- &result );
-
- if (ie == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- if (result == nsInstall::SUCCESS)
- {
- result = ScheduleForInstall( ie );
- }
- else
- {
- delete ie;
- }
-
- *aReturn = SaveError(result);
-
- return NS_OK;
-}
-
-////////////////////////////////////////
-
-
-void
-nsInstall::AddPatch(nsHashKey *aKey, nsIFile* fileName)
-{
- if (mPatchList != nsnull)
- {
- mPatchList->Put(aKey, fileName);
- }
-}
-
-void
-nsInstall::GetPatch(nsHashKey *aKey, nsIFile** fileName)
-{
- if (!fileName)
- return;
- else
- *fileName = nsnull;
-
- if (mPatchList)
- {
- NS_IF_ADDREF(*fileName = (nsIFile*) mPatchList->Get(aKey));
- }
-}
-
-PRInt32
-nsInstall::FileOpDirCreate(nsInstallFolder& aTarget, PRInt32* aReturn)
-{
- nsCOMPtr<nsIFile> localFile = aTarget.GetFileSpec();
- if (localFile == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_DIR_CREATE, localFile, aReturn);
- if (ifop == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- PRInt32 result = SanityCheck();
- if (result != nsInstall::SUCCESS)
- {
- delete ifop;
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- if (*aReturn == nsInstall::SUCCESS)
- {
- *aReturn = ScheduleForInstall( ifop );
- }
-
- SaveError(*aReturn);
-
- return NS_OK;
-}
-
-PRInt32
-nsInstall::FileOpDirGetParent(nsInstallFolder& aTarget, nsInstallFolder** theParentFolder)
-{
- nsCOMPtr<nsIFile> parent;
- nsCOMPtr<nsIFile> localFile = aTarget.GetFileSpec();
-
- nsresult rv = localFile->GetParent(getter_AddRefs(parent));
- if (NS_SUCCEEDED(rv) && parent)
- {
- nsInstallFolder* folder = new nsInstallFolder();
- if (folder == nsnull)
- {
- return NS_ERROR_OUT_OF_MEMORY;
- }
- folder->Init(parent, EmptyString());
- *theParentFolder = folder;
- }
- else
- theParentFolder = nsnull;
-
- return NS_OK;
-}
-
-PRInt32
-nsInstall::FileOpDirRemove(nsInstallFolder& aTarget, PRInt32 aFlags, PRInt32* aReturn)
-{
- nsCOMPtr<nsIFile> localFile = aTarget.GetFileSpec();
- if (localFile == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_DIR_REMOVE, localFile, aFlags, aReturn);
- if (ifop == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- PRInt32 result = SanityCheck();
- if (result != nsInstall::SUCCESS)
- {
- delete ifop;
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- if (*aReturn == nsInstall::SUCCESS)
- {
- *aReturn = ScheduleForInstall( ifop );
- }
-
- SaveError(*aReturn);
-
- return NS_OK;
-}
-
-PRInt32
-nsInstall::FileOpDirRename(nsInstallFolder& aSrc, nsString& aTarget, PRInt32* aReturn)
-{
- nsCOMPtr<nsIFile> localFile = aSrc.GetFileSpec();
- if (localFile == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_DIR_RENAME, localFile, aTarget, PR_FALSE, aReturn);
- if (ifop == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- PRInt32 result = SanityCheck();
- if (result != nsInstall::SUCCESS)
- {
- delete ifop;
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- if (*aReturn == nsInstall::SUCCESS)
- {
- *aReturn = ScheduleForInstall( ifop );
- }
-
- SaveError(*aReturn);
-
- return NS_OK;
-}
-
-PRInt32
-nsInstall::FileOpFileCopy(nsInstallFolder& aSrc, nsInstallFolder& aTarget, PRInt32* aReturn)
-{
- nsCOMPtr<nsIFile> localSrcFile = aSrc.GetFileSpec();
- if (localSrcFile == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- nsCOMPtr<nsIFile>localTargetFile = aTarget.GetFileSpec();
- if (localTargetFile == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_FILE_COPY, localSrcFile, localTargetFile, aReturn);
- if (ifop == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- PRInt32 result = SanityCheck();
- if (result != nsInstall::SUCCESS)
- {
- delete ifop;
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- if (*aReturn == nsInstall::SUCCESS)
- {
- *aReturn = ScheduleForInstall( ifop );
- }
-
- SaveError(*aReturn);
-
- return NS_OK;
-}
-
-PRInt32
-nsInstall::FileOpFileDelete(nsInstallFolder& aTarget, PRInt32 aFlags, PRInt32* aReturn)
-{
- nsCOMPtr<nsIFile> localFile = aTarget.GetFileSpec();
- if (localFile == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_FILE_DELETE, localFile, aFlags, aReturn);
- if (ifop == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- PRInt32 result = SanityCheck();
- if (result != nsInstall::SUCCESS)
- {
- delete ifop;
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- if (*aReturn == nsInstall::SUCCESS)
- {
- *aReturn = ScheduleForInstall( ifop );
- }
-
- SaveError(*aReturn);
-
- return NS_OK;
-}
-
-PRInt32
-nsInstall::FileOpFileExecute(nsInstallFolder& aTarget, nsString& aParams, PRBool aBlocking, PRInt32* aReturn)
-{
- nsCOMPtr<nsIFile> localFile = aTarget.GetFileSpec();
- if (localFile == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_FILE_EXECUTE, localFile, aParams, aBlocking, aReturn);
- if (ifop == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- PRInt32 result = SanityCheck();
- if (result != nsInstall::SUCCESS)
- {
- delete ifop;
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- if (*aReturn == nsInstall::SUCCESS)
- {
- *aReturn = ScheduleForInstall( ifop );
- }
-
- SaveError(*aReturn);
-
- return NS_OK;
-}
-
-PRInt32
-nsInstall::FileOpFileExists(nsInstallFolder& aTarget, PRBool* aReturn)
-{
- nsCOMPtr<nsIFile> localFile = aTarget.GetFileSpec();
-
- localFile->Exists(aReturn);
- return NS_OK;
-}
-
-#ifdef XP_WIN
-#include <winver.h>
-#endif
-
-PRInt32
-nsInstall::FileOpFileGetNativeVersion(nsInstallFolder& aTarget, nsString* aReturn)
-{
- PRInt32 rv = NS_OK;
-
-#ifdef XP_WIN
- PRBool flagExists;
- nsCOMPtr<nsILocalFile> localTarget(do_QueryInterface(aTarget.GetFileSpec()));
- UINT uLen;
- UINT dwLen;
- DWORD dwHandle;
- LPVOID lpData;
- LPVOID lpBuffer;
- VS_FIXEDFILEINFO *lpBuffer2;
- DWORD dwMajor = 0;
- DWORD dwMinor = 0;
- DWORD dwRelease = 0;
- DWORD dwBuild = 0;
- nsCAutoString nativeTargetPath;
- char *nativeVersionString = nsnull;
-
- if(localTarget == nsnull)
- return(rv);
-
- flagExists = PR_FALSE;
- localTarget->Exists(&flagExists);
- if(flagExists)
- {
- localTarget->GetNativePath(nativeTargetPath);
- uLen = 0;
- /* GetFileVersionInfoSize() requires a char *, but the api doesn't
- * indicate that it will modify it */
- dwLen = GetFileVersionInfoSize((char *)nativeTargetPath.get(), &dwHandle);
- lpData = (LPVOID)PR_Malloc(sizeof(long)*dwLen);
- if(!lpData)
- return(nsInstall::OUT_OF_MEMORY);
-
- /* GetFileVersionInfo() requires a char *, but the api doesn't
- * indicate that it will modify it */
- if(GetFileVersionInfo((char *)nativeTargetPath.get(), dwHandle, dwLen, lpData) != 0)
- {
- if(VerQueryValue(lpData, "\\", &lpBuffer, &uLen) != 0)
- {
- lpBuffer2 = (VS_FIXEDFILEINFO *)lpBuffer;
- dwMajor = HIWORD(lpBuffer2->dwFileVersionMS);
- dwMinor = LOWORD(lpBuffer2->dwFileVersionMS);
- dwRelease = HIWORD(lpBuffer2->dwFileVersionLS);
- dwBuild = LOWORD(lpBuffer2->dwFileVersionLS);
- }
- }
-
- nativeVersionString = PR_smprintf("%d.%d.%d.%d", dwMajor, dwMinor, dwRelease, dwBuild);
- if(!nativeVersionString)
- rv = nsInstall::OUT_OF_MEMORY;
- else
- {
- aReturn->AssignASCII(nativeVersionString);
- PR_smprintf_free(nativeVersionString);
- }
-
- PR_FREEIF(lpData);
- }
-#endif
-
- return(rv);
-}
-
-PRInt32
-nsInstall::FileOpFileGetDiskSpaceAvailable(nsInstallFolder& aTarget, PRInt64* aReturn)
-{
- nsresult rv;
- nsCOMPtr<nsIFile> file = aTarget.GetFileSpec();
- nsCOMPtr<nsILocalFile> localFile = do_QueryInterface(file, &rv);
-
- localFile->GetDiskSpaceAvailable(aReturn); //nsIFileXXX: need to figure out how to call GetDiskSpaceAvailable
- return NS_OK;
-}
-
-//nsIFileXXX: need to get nsIFile equivalent to GetModDate
-PRInt32
-nsInstall::FileOpFileGetModDate(nsInstallFolder& aTarget, double* aReturn)
-{
- * aReturn = 0;
-
- nsCOMPtr<nsIFile> localFile = aTarget.GetFileSpec();
-
- if (localFile)
- {
- double newStamp;
- PRInt64 lastModDate = LL_ZERO;
- localFile->GetLastModifiedTime(&lastModDate);
-
- LL_L2D(newStamp, lastModDate);
-
- *aReturn = newStamp;
- }
-
- return NS_OK;
-}
-
-PRInt32
-nsInstall::FileOpFileGetSize(nsInstallFolder& aTarget, PRInt64* aReturn)
-{
- nsCOMPtr<nsIFile> localFile = aTarget.GetFileSpec();
-
- localFile->GetFileSize(aReturn);
- return NS_OK;
-}
-
-PRInt32
-nsInstall::FileOpFileIsDirectory(nsInstallFolder& aTarget, PRBool* aReturn)
-{
- nsCOMPtr<nsIFile> localFile = aTarget.GetFileSpec();
-
- localFile->IsDirectory(aReturn);
- return NS_OK;
-}
-
-PRInt32
-nsInstall::FileOpFileIsWritable(nsInstallFolder& aTarget, PRBool* aReturn)
-{
- nsCOMPtr<nsIFile> localFile = aTarget.GetFileSpec();
-
- localFile->IsWritable(aReturn);
- return NS_OK;
-}
-
-PRInt32
-nsInstall::FileOpFileIsFile(nsInstallFolder& aTarget, PRBool* aReturn)
-{
- nsCOMPtr<nsIFile> localFile = aTarget.GetFileSpec();
-
- localFile->IsFile(aReturn);
- return NS_OK;
-}
-
-//nsIFileXXX: need to get the ModDateChanged equivalent for nsIFile
-PRInt32
-nsInstall::FileOpFileModDateChanged(nsInstallFolder& aTarget, double aOldStamp, PRBool* aReturn)
-{
- *aReturn = PR_TRUE;
-
- nsCOMPtr<nsIFile> localFile = aTarget.GetFileSpec();
- if (localFile)
- {
- double newStamp;
- PRInt64 lastModDate = LL_ZERO;
- localFile->GetLastModifiedTime(&lastModDate);
-
- LL_L2D(newStamp, lastModDate);
-
- *aReturn = !(newStamp == aOldStamp);
- }
- return NS_OK;
-}
-
-PRInt32
-nsInstall::FileOpFileMove(nsInstallFolder& aSrc, nsInstallFolder& aTarget, PRInt32* aReturn)
-{
- nsCOMPtr<nsIFile> localSrcFile = aSrc.GetFileSpec();
- if (localSrcFile == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
- nsCOMPtr<nsIFile> localTargetFile = aTarget.GetFileSpec();
- if (localTargetFile == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_FILE_MOVE, localSrcFile, localTargetFile, aReturn);
- if (ifop == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- PRInt32 result = SanityCheck();
- if (result != nsInstall::SUCCESS)
- {
- delete ifop;
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- if (*aReturn == nsInstall::SUCCESS)
- {
- *aReturn = ScheduleForInstall( ifop );
- }
-
- SaveError(*aReturn);
-
- return NS_OK;
-}
-
-PRInt32
-nsInstall::FileOpFileRename(nsInstallFolder& aSrc, nsString& aTarget, PRInt32* aReturn)
-{
- nsCOMPtr<nsIFile> localFile = aSrc.GetFileSpec();
- if (localFile == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_FILE_RENAME, localFile, aTarget, PR_FALSE, aReturn);
- if (ifop == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- PRInt32 result = SanityCheck();
- if (result != nsInstall::SUCCESS)
- {
- delete ifop;
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- if (*aReturn == nsInstall::SUCCESS)
- {
- *aReturn = ScheduleForInstall( ifop );
- }
-
- SaveError(*aReturn);
-
- return NS_OK;
-}
-
-#ifdef _WINDOWS
-#include <winbase.h>
-#endif
-
-
-PRInt32
-nsInstall::FileOpFileWindowsGetShortName(nsInstallFolder& aTarget, nsString& aShortPathName)
-{
-#ifdef _WINDOWS
-
- PRInt32 err;
- PRBool flagExists;
- nsString tmpNsString;
- nsCAutoString nativeTargetPath;
- nsAutoString unicodePath;
- char nativeShortPathName[MAX_PATH];
- nsCOMPtr<nsIFile> localTarget(aTarget.GetFileSpec());
-
- if(localTarget == nsnull)
- return NS_OK;
-
- localTarget->Exists(&flagExists);
- if(flagExists)
- {
- memset(nativeShortPathName, 0, MAX_PATH);
- localTarget->GetNativePath(nativeTargetPath);
-
- err = GetShortPathName(nativeTargetPath.get(), nativeShortPathName, MAX_PATH);
- if((err > 0) && (*nativeShortPathName == '\0'))
- {
- // NativeShortPathName buffer not big enough.
- // Reallocate and try again.
- // err will have the required size.
- char *nativeShortPathNameTmp = new char[err + 1];
- if(nativeShortPathNameTmp == nsnull)
- return NS_OK;
-
- err = GetShortPathName(nativeTargetPath.get(), nativeShortPathNameTmp, err + 1);
- // It is safe to assume that the second time around the buffer is big
- // enough and not to worry about it unless it's a different problem. If
- // it failed the first time because of buffer size being too small, err
- // will be the buffer size required. If it's any other error, err will
- // be 0 and GetLastError() will have the actual error.
- if(err != 0)
- {
- // if err is 0, it's not a buffer size problem. It's something else unexpected.
- NS_CopyNativeToUnicode(nsDependentCString(nativeShortPathNameTmp), unicodePath);
- }
-
- if(nativeShortPathNameTmp)
- delete [] nativeShortPathNameTmp;
- }
- else if(err != 0)
- {
- // if err is 0, it's not a buffer size problem. It's something else unexpected.
- NS_CopyNativeToUnicode(nsDependentCString(nativeShortPathName), unicodePath);
- }
- }
-
- if (!unicodePath.IsEmpty())
- aShortPathName = unicodePath;
-
-#endif
-
- return NS_OK;
-}
-
-PRInt32
-nsInstall::FileOpFileWindowsShortcut(nsIFile* aTarget, nsIFile* aShortcutPath, nsString& aDescription, nsIFile* aWorkingPath, nsString& aParams, nsIFile* aIcon, PRInt32 aIconId, PRInt32* aReturn)
-{
-
- nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_WIN_SHORTCUT, aTarget, aShortcutPath, aDescription, aWorkingPath, aParams, aIcon, aIconId, aReturn);
- if (ifop == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- PRInt32 result = SanityCheck();
- if (result != nsInstall::SUCCESS)
- {
- delete ifop;
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- if (*aReturn == nsInstall::SUCCESS)
- {
- *aReturn = ScheduleForInstall( ifop );
- }
-
- SaveError(*aReturn);
-
- return NS_OK;
-}
-
-PRInt32
-nsInstall::FileOpFileMacAlias(nsIFile *aSourceFile, nsIFile *aAliasFile, PRInt32* aReturn)
-{
-
- *aReturn = nsInstall::SUCCESS;
-
-#ifdef XP_MACOSX
-
- nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_MAC_ALIAS, aSourceFile, aAliasFile, aReturn);
- if (!ifop)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- PRInt32 result = SanityCheck();
- if (result != nsInstall::SUCCESS)
- {
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- if (ifop == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- if (*aReturn == nsInstall::SUCCESS)
- {
- *aReturn = ScheduleForInstall( ifop );
- }
-
- SaveError(*aReturn);
-
-#endif /* XP_MACOSX */
-
- return NS_OK;
-}
-
-PRInt32
-nsInstall::FileOpFileUnixLink(nsInstallFolder& aTarget, PRInt32 aFlags, PRInt32* aReturn)
-{
- return NS_OK;
-}
-
-PRInt32
-nsInstall::FileOpWinRegisterServer(nsInstallFolder& aTarget, PRInt32* aReturn)
-{
- nsCOMPtr<nsIFile> localFile = aTarget.GetFileSpec();
- if (localFile == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_WIN_REGISTER_SERVER, localFile, aReturn);
- if (ifop == nsnull)
- {
- *aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
- return NS_OK;
- }
-
- PRInt32 result = SanityCheck();
- if (result != nsInstall::SUCCESS)
- {
- delete ifop;
- *aReturn = SaveError( result );
- return NS_OK;
- }
-
- if (*aReturn == nsInstall::SUCCESS)
- {
- *aReturn = ScheduleForInstall( ifop );
- }
-
- SaveError(*aReturn);
-
- return NS_OK;
-}
-
-void
-nsInstall::LogComment(const nsAString& aComment)
-{
- if(mListener)
- mListener->OnLogComment(PromiseFlatString(aComment).get());
-}
-
-/////////////////////////////////////////////////////////////////////////
-// Private Methods
-/////////////////////////////////////////////////////////////////////////
-
-/**
- * ScheduleForInstall
- * call this to put an InstallObject on the install queue
- * Do not call installedFiles.addElement directly, because this routine also
- * handles progress messages
- */
-PRInt32
-nsInstall::ScheduleForInstall(nsInstallObject* ob)
-{
- PRInt32 error = nsInstall::SUCCESS;
-
- char *objString = ob->toString();
-
- // flash current item
-
- if (mListener)
- mListener->OnItemScheduled(NS_ConvertASCIItoUTF16(objString).get());
-
-
- // do any unpacking or other set-up
- error = ob->Prepare();
-
- if (error == nsInstall::SUCCESS)
- {
- // Add to installation list
- mInstalledFiles->AppendElement( ob );
-
- // turn on flags for creating the uninstall node and
- // the package node for each InstallObject
-
- if (ob->CanUninstall())
- mUninstallPackage = PR_TRUE;
-
- if (ob->RegisterPackageNode())
- mRegisterPackage = PR_TRUE;
- }
- else if ( mListener )
- {
- // error in preparation step -- log it
- char* errRsrc = GetResourcedString(NS_LITERAL_STRING("ERROR"));
- if (errRsrc)
- {
- char* errprefix = PR_smprintf("%s (%d): ", errRsrc, error);
- nsString errstr; errstr.AssignWithConversion(errprefix);
- errstr.AppendWithConversion(objString);
-
- mListener->OnLogComment( errstr.get() );
-
- PR_smprintf_free(errprefix);
- nsCRT::free(errRsrc);
- }
- }
-
- if (error != SUCCESS)
- SaveError(error);
-
- if (objString)
- delete [] objString;
-
- return error;
-}
-
-
-/**
- * SanityCheck
- *
- * This routine checks if the packageName is null. It also checks the flag if the user cancels
- * the install progress dialog is set and acccordingly aborts the install.
- */
-PRInt32
-nsInstall::SanityCheck(void)
-{
- if ( mInstalledFiles == nsnull || mStartInstallCompleted == PR_FALSE )
- {
- return INSTALL_NOT_STARTED;
- }
-
- if (mUserCancelled)
- {
- InternalAbort(USER_CANCELLED);
- return USER_CANCELLED;
- }
-
- return 0;
-}
-
-/**
- * GetQualifiedPackageName
- *
- * This routine converts a package-relative component registry name
- * into a full name that can be used in calls to the version registry.
- */
-
-PRInt32
-nsInstall::GetQualifiedPackageName( const nsString& name, nsString& qualifiedName )
-{
- nsString startOfName;
- name.Left(startOfName, 7);
-
- if ( startOfName.EqualsLiteral("=USER=/") )
- {
- CurrentUserNode(qualifiedName);
- qualifiedName += name;
- }
- else
- {
- qualifiedName = name;
- }
-
- if (BadRegName(qualifiedName))
- {
- return BAD_PACKAGE_NAME;
- }
-
-
- /* Check to see if the PackageName ends in a '/'. If it does nuke it. */
-
- if (qualifiedName.Last() == '/')
- {
- PRInt32 index = qualifiedName.Length();
- qualifiedName.Truncate(--index);
- }
-
- return SUCCESS;
-}
-
-
-/**
- * GetQualifiedRegName
- *
- * This routine converts a package-relative component registry name
- * into a full name that can be used in calls to the version registry.
- */
-PRInt32
-nsInstall::GetQualifiedRegName(const nsString& name, nsString& qualifiedRegName )
-{
- nsString startOfName;
- name.Left(startOfName, 7);
-
- if ( startOfName.EqualsLiteral("=COMM=/") || startOfName.EqualsLiteral("=USER=/"))
- {
- qualifiedRegName = startOfName;
- }
- else if (name.CharAt(0) != '/' &&
- !mRegistryPackageName.IsEmpty())
- {
- qualifiedRegName = mRegistryPackageName
- + NS_LITERAL_STRING("/")
- + name;
- }
- else
- {
- qualifiedRegName = name;
- }
-
- if (BadRegName(qualifiedRegName))
- {
- return BAD_PACKAGE_NAME;
- }
-
- return SUCCESS;
-}
-
-
-void
-nsInstall::CurrentUserNode(nsString& userRegNode)
-{
- nsXPIDLCString profname;
- nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
-
- if ( prefBranch )
- {
- prefBranch->GetCharPref("profile.name", getter_Copies(profname));
- }
-
- userRegNode.AssignLiteral("/Netscape/Users/");
- if ( !profname.IsEmpty() )
- {
- userRegNode.AppendWithConversion(profname);
- userRegNode.AppendLiteral("/");
- }
-}
-
-// catch obvious registry name errors proactively
-// rather than returning some cryptic libreg error
-PRBool
-nsInstall::BadRegName(const nsString& regName)
-{
- if ( regName.IsEmpty() )
- return PR_TRUE;
-
- if ((regName.First() == ' ' ) || (regName.Last() == ' ' ))
- return PR_TRUE;
-
- if ( regName.Find("//") != -1 )
- return PR_TRUE;
-
- if ( regName.Find(" /") != -1 )
- return PR_TRUE;
-
- if ( regName.Find("/ ") != -1 )
- return PR_TRUE;
-
- return PR_FALSE;
-}
-
-PRInt32
-nsInstall::SaveError(PRInt32 errcode)
-{
- if ( errcode != nsInstall::SUCCESS )
- mLastError = errcode;
-
- return errcode;
-}
-
-
-/*
- * CleanUp
- * call it when done with the install
- *
- */
-void
-nsInstall::CleanUp(void)
-{
- nsInstallObject* ie;
-
- if ( mInstalledFiles != nsnull )
- {
- for (PRInt32 i=0; i < mInstalledFiles->Count(); i++)
- {
- ie = (nsInstallObject*)mInstalledFiles->ElementAt(i);
- if (ie)
- delete ie;
- }
-
- mInstalledFiles->Clear();
- delete (mInstalledFiles);
- mInstalledFiles = nsnull;
- }
-
- if (mPatchList != nsnull)
- {
- mPatchList->Reset();
- delete mPatchList;
- mPatchList = nsnull;
- }
-
- if (mPackageFolder != nsnull)
- {
- delete (mPackageFolder);
- mPackageFolder = nsnull;
- }
-
- mRegistryPackageName.SetLength(0); // used to see if StartInstall() has been called
- mStartInstallCompleted = PR_FALSE;
-}
-
-
-void
-nsInstall::SetJarFileLocation(nsIFile* aFile)
-{
- mJarFileLocation = aFile;
-}
-
-void
-nsInstall::GetInstallArguments(nsString& args)
-{
- args = mInstallArguments;
-}
-
-void
-nsInstall::SetInstallArguments(const nsString& args)
-{
- mInstallArguments = args;
-}
-
-
-void nsInstall::GetInstallURL(nsString& url) { url = mInstallURL; }
-void nsInstall::SetInstallURL(const nsString& url) { mInstallURL = url; }
-
-//-----------------------------------------------------------------------------
-// GetTranslatedString :
-// This is a utility function that translates "Alert" or
-// "Confirm" to pass as the title to the PromptService Alert and Confirm
-// functions as the title. If you pass nsnull as the title, you get garbage
-// instead of a blank title.
-//-----------------------------------------------------------------------------
-PRUnichar *GetTranslatedString(const PRUnichar* aString)
-{
- nsCOMPtr<nsIStringBundleService> stringService = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
- nsCOMPtr<nsIStringBundle> stringBundle;
- PRUnichar* translatedString;
-
- nsresult rv = stringService->CreateBundle(kInstallLocaleProperties, getter_AddRefs(stringBundle));
- if (NS_FAILED(rv)) return nsnull;
-
- rv = stringBundle->GetStringFromName(aString, &translatedString);
- if (NS_FAILED(rv)) return nsnull;
-
- return translatedString;
-}
-
-PRInt32
-nsInstall::Alert(nsString& string)
-{
- nsPIXPIProxy *ui = GetUIThreadProxy();
- if (!ui)
- return UNEXPECTED_ERROR;
-
- nsAutoString title;
- title.AssignLiteral("Alert");
- if (!mUIName.IsEmpty())
- {
- title = mUIName;
- }
- else
- {
- PRUnichar *t = GetTranslatedString(title.get());
- if (t)
- title.Adopt(t);
- }
- return ui->Alert( title.get(), string.get());
-}
-
-PRInt32
-nsInstall::ConfirmEx(nsString& aDialogTitle, nsString& aText, PRUint32 aButtonFlags, nsString& aButton0Title, nsString& aButton1Title, nsString& aButton2Title, nsString& aCheckMsg, PRBool* aCheckState, PRInt32* aReturn)
-{
- *aReturn = -1; /* default value */
-
- nsPIXPIProxy *ui = GetUIThreadProxy();
- if (!ui)
- return UNEXPECTED_ERROR;
-
- nsAutoString title;
- title.AssignLiteral("Confirm");
- if (!aDialogTitle.IsEmpty())
- {
- title = aDialogTitle;
- }
- else if (!mUIName.IsEmpty())
- {
- title = mUIName;
- }
- else
- {
- PRUnichar *t = GetTranslatedString(title.get());
- if (t)
- title.Adopt(t);
- }
- return ui->ConfirmEx( title.get(),
- aText.get(),
- aButtonFlags,
- aButton0Title.get(),
- aButton1Title.get(),
- aButton2Title.get(),
- aCheckMsg.get(),
- aCheckState,
- aReturn);
-}
-
-
-// aJarFile - This is the filepath within the jar file.
-// aSuggestedName - This is the name that we should try to extract to. If we can, we will create a new temporary file.
-// aRealName - This is the name that we did extract to. This will be allocated by use and should be disposed by the caller.
-
-PRInt32
-nsInstall::ExtractFileFromJar(const nsString& aJarfile, nsIFile* aSuggestedName, nsIFile** aRealName)
-{
- PRInt32 extpos = 0;
- nsCOMPtr<nsIFile> extractHereSpec;
- nsCOMPtr<nsILocalFile> tempFile;
- nsresult rv;
-
- if (aSuggestedName == nsnull)
- {
- nsCOMPtr<nsIProperties> directoryService =
- do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
-
- directoryService->Get(NS_OS_TEMP_DIR, NS_GET_IID(nsIFile), getter_AddRefs(tempFile));
-
- nsAutoString tempFileName(NS_LITERAL_STRING("xpinstall"));
-
- // Get the extension of the file in the JAR
- extpos = aJarfile.RFindChar('.');
- if (extpos != -1)
- {
- // We found the extension; add it to the tempFileName string
- nsString extension;
- aJarfile.Right(extension, (aJarfile.Length() - extpos) );
- tempFileName += extension;
- }
- tempFile->Append(tempFileName);
- tempFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0664);
- tempFile->Clone(getter_AddRefs(extractHereSpec));
-
- if (extractHereSpec == nsnull)
- return nsInstall::OUT_OF_MEMORY;
- }
- else
- {
- nsCOMPtr<nsIFile> temp;
- aSuggestedName->Clone(getter_AddRefs(temp));
-
- PRBool exists;
- temp->Exists(&exists);
- if (exists)
- {
- PRBool writable;
- temp->IsWritable(&writable);
- if (!writable) // Can't extract. Target is readonly.
- return nsInstall::READ_ONLY;
-
- tempFile = do_QueryInterface(temp, &rv); //convert to an nsILocalFile
- if (tempFile == nsnull)
- return nsInstall::OUT_OF_MEMORY;
-
- //get the leafname so we can convert its extension to .new
- nsAutoString newLeafName;
- tempFile->GetLeafName(newLeafName);
-
- PRInt32 extpos = newLeafName.RFindChar('.');
- if (extpos != -1)
- {
- // We found the extension;
- newLeafName.Truncate(extpos + 1); //strip off the old extension
- }
- newLeafName.AppendLiteral("new");
-
- //Now reset the leafname
- tempFile->SetLeafName(newLeafName);
- tempFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0644);
- extractHereSpec = tempFile;
- }
- extractHereSpec = temp;
- }
-
- rv = mJarFileData->Extract(NS_LossyConvertUTF16toASCII(aJarfile).get(),
- extractHereSpec);
- if (NS_FAILED(rv))
- {
- switch (rv) {
- case NS_ERROR_FILE_ACCESS_DENIED: return ACCESS_DENIED;
- case NS_ERROR_FILE_DISK_FULL: return INSUFFICIENT_DISK_SPACE;
- case NS_ERROR_FILE_TARGET_DOES_NOT_EXIST: return DOES_NOT_EXIST;
- default: return EXTRACTION_FAILED;
- }
- }
-
-#ifdef XP_MACOSX
- FSRef finalRef, extractedRef;
-
- nsCOMPtr<nsILocalFileMac> tempExtractHereSpec;
- tempExtractHereSpec = do_QueryInterface(extractHereSpec, &rv);
- tempExtractHereSpec->GetFSRef(&extractedRef);
-
- if ( nsAppleSingleDecoder::IsAppleSingleFile(&extractedRef) )
- {
- nsAppleSingleDecoder *asd =
- new nsAppleSingleDecoder(&extractedRef, &finalRef);
- OSErr decodeErr = fnfErr;
-
- if (asd)
- decodeErr = asd->Decode();
-
- if (decodeErr != noErr)
- {
- if (asd)
- delete asd;
- return EXTRACTION_FAILED;
- }
-
- if (noErr != FSCompareFSRefs(&extractedRef, &finalRef))
- {
- // delete the unique extracted file that got renamed in AS decoding
- FSDeleteObject(&extractedRef);
-
- // "real name" in AppleSingle entry may cause file rename
- tempExtractHereSpec->InitWithFSRef(&finalRef);
- extractHereSpec = do_QueryInterface(tempExtractHereSpec, &rv);
- }
- }
-#endif /* XP_MACOSX */
-
- extractHereSpec->Clone(aRealName);
-
- return nsInstall::SUCCESS;
-}
-
-/**
- * GetResourcedString
- *
- * Obtains the string resource for actions and messages that are displayed
- * in user interface confirmation and progress dialogs.
- *
- * @param aResName - property name/identifier of string resource
- * @return rscdStr - corresponding resourced value in the string bundle
- */
-char*
-nsInstall::GetResourcedString(const nsAString& aResName)
-{
- if (mStringBundle)
- {
- nsXPIDLString ucRscdStr;
- nsresult rv = mStringBundle->GetStringFromName(PromiseFlatString(aResName).get(),
- getter_Copies(ucRscdStr));
- if (NS_SUCCEEDED(rv))
- return ToNewCString(ucRscdStr);
- }
-
- /*
- ** We don't have a string bundle, the necessary libs, or something went wrong
- ** so we failover to hardcoded english strings so we log something rather
- ** than nothing due to failure above: always the case for the Install Wizards.
- */
- return nsCRT::strdup(nsInstallResources::GetDefaultVal(
- NS_LossyConvertUTF16toASCII(aResName).get()));
-}
--- a/xpinstall/src/nsInstall.h
+++ b/xpinstall/src/nsInstall.h
@@ -18,16 +18,17 @@
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Daniel Veditz <dveditz@netscape.com>
* Douglas Turner <dougt@netscape.com>
* Jens Bannmann <jens.b@web.de>
+ * Dave Townsend <dtownsend@oxymoronical.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
@@ -36,135 +37,18 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __NS_INSTALL_H__
#define __NS_INSTALL_H__
-#include "nscore.h"
-#include "nsISupports.h"
-
-#include "jsapi.h"
-
-#include "nsString.h"
-#include "nsVoidArray.h"
-#include "nsHashtable.h"
-#include "nsCOMPtr.h"
-#include "nsILocalFile.h"
-#include "nsIURI.h"
-
-#include "nsSoftwareUpdate.h"
-
-#include "nsInstallObject.h"
-#include "nsInstallVersion.h"
-#include "nsInstallFolder.h"
-
-#include "nsIXPINotifier.h"
-#include "nsPIXPIProxy.h"
-
-#include "nsIStringBundle.h"
-#include "nsILocale.h"
-#include "nsIServiceManager.h"
-#include "nsIComponentManager.h"
-#include "nsIEnumerator.h"
-#include "nsIZipReader.h"
-#include "nsIExtensionManager.h"
-#include "nsIPrincipal.h"
-
-#ifdef MOZ_XUL_APP
-#include "nsIToolkitChromeRegistry.h"
-#define CHROMEREG_IFACE nsIToolkitChromeRegistry
-#else
-#include "nsIChromeRegistrySea.h"
-#define CHROMEREG_IFACE nsIChromeRegistrySea
-#endif
-
-#define XPINSTALL_BUNDLE_URL "chrome://global/locale/xpinstall/xpinstall.properties"
-
-//file and directory name length maximums
-#ifdef XP_MAC
-#define MAX_FILENAME 31
-#elif defined (XP_WIN) || defined(XP_OS2)
-#define MAX_FILENAME 128
-#else
-#define MAX_FILENAME 1024
-#endif
-
-class nsInstallInfo
-{
- public:
-
- nsInstallInfo( PRUint32 aInstallType,
- nsIFile* aFile,
- const PRUnichar* aURL,
- const PRUnichar* aArgs,
- nsIPrincipal* mPrincipal,
- PRUint32 aFlags,
- nsIXPIListener* aListener);
-
- virtual ~nsInstallInfo();
-
- nsIFile* GetFile() { return mFile.get(); }
- const PRUnichar* GetURL() { return mURL.get(); }
- const PRUnichar* GetArguments() { return mArgs.get(); }
- PRUint32 GetFlags() { return mFlags; }
- PRUint32 GetType() { return mType; }
- nsIXPIListener* GetListener() { return mListener.get(); }
- CHROMEREG_IFACE* GetChromeRegistry() { return mChromeRegistry; }
-
-#ifdef MOZ_XUL_APP
- nsIExtensionManager* GetExtensionManager() { return mExtensionManager; }
-#else
- const nsCString& GetFileJARSpec() { return mFileJARSpec; }
-#endif
-
- nsCOMPtr<nsIPrincipal> mPrincipal;
-
- private:
-
- nsresult mError;
-
- PRUint32 mType;
- PRUint32 mFlags;
- nsString mURL;
- nsString mArgs;
-
- nsCOMPtr<nsIFile> mFile;
- nsCOMPtr<nsIXPIListener> mListener;
- nsCOMPtr<CHROMEREG_IFACE> mChromeRegistry;
-
-#ifdef MOZ_XUL_APP
- nsCOMPtr<nsIExtensionManager> mExtensionManager;
-#else
- nsCString mFileJARSpec;
-#endif
-};
-
-#if defined(XP_WIN) || defined(XP_OS2)
-#define FILESEP '\\'
-#elif defined XP_MAC
-#define FILESEP ':'
-#elif defined XP_BEOS
-#define FILESEP '/'
-#else
-#define FILESEP '/'
-#endif
-
-// not using 0x1 in this bitfield because it causes problems with legacy code
-#define DO_NOT_UNINSTALL 0x2
-#define WIN_SHARED_FILE 0x4
-#define WIN_SYSTEM_FILE 0x8
-
class nsInstall
{
- friend class nsWinReg;
- friend class nsWinProfile;
-
public:
enum
{
BAD_PACKAGE_NAME = -200,
UNEXPECTED_ERROR = -201,
ACCESS_DENIED = -202,
EXECUTION_ERROR = -203,
@@ -223,176 +107,11 @@ class nsInstall
OUT_OF_MEMORY = -299,
GESTALT_UNKNOWN_ERR = -5550,
GESTALT_INVALID_ARGUMENT = -5551,
SUCCESS = 0,
REBOOT_NEEDED = 999
};
-
-
- nsInstall(nsIZipReader * theJARFile);
- virtual ~nsInstall();
-
- PRInt32 SetScriptObject(void* aScriptObject);
-
- PRInt32 SaveWinRegPrototype(void* aScriptObject);
- PRInt32 SaveWinProfilePrototype(void* aScriptObject);
-
- JSObject* RetrieveWinRegPrototype(void);
- JSObject* RetrieveWinProfilePrototype(void);
-
- PRInt32 AbortInstall(PRInt32 aErrorNumber);
-
- PRInt32 AddDirectory(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aSubdir, PRInt32 aMode, PRInt32* aReturn);
- PRInt32 AddDirectory(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aSubdir, PRInt32* aReturn);
- PRInt32 AddDirectory(const nsString& aRegName, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aSubdir, PRInt32* aReturn);
- PRInt32 AddDirectory(const nsString& aJarSource, PRInt32* aReturn);
-
- PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder *aFolder, const nsString& aTargetName, PRInt32 aMode, PRInt32* aReturn);
- PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder *aFolder, const nsString& aTargetName, PRInt32* aReturn);
- PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aJarSource, nsInstallFolder *aFolder, const nsString& aTargetName, PRInt32* aReturn);
- PRInt32 AddSubcomponent(const nsString& aJarSource, PRInt32* aReturn);
-
- PRInt32 DiskSpaceAvailable(const nsString& aFolder, PRInt64* aReturn);
- PRInt32 Execute(const nsString& aJarSource, const nsString& aArgs, PRBool aBlocking, PRInt32* aReturn);
- PRInt32 FinalizeInstall(PRInt32* aReturn);
- PRInt32 Gestalt(const nsString& aSelector, PRInt32* aReturn);
-
- PRInt32 GetComponentFolder(const nsString& aComponentName, const nsString& aSubdirectory, nsInstallFolder** aFolder);
- PRInt32 GetComponentFolder(const nsString& aComponentName, nsInstallFolder** aFolder);
-
- PRInt32 GetFolder(nsInstallFolder& aTargetFolder, const nsString& aSubdirectory, nsInstallFolder** aFolder);
- PRInt32 GetFolder(const nsString& aTargetFolder, const nsString& aSubdirectory, nsInstallFolder** aFolder);
- PRInt32 GetFolder(const nsString& aTargetFolder, nsInstallFolder** aFolder);
-
- PRInt32 GetLastError(PRInt32* aReturn);
- PRInt32 GetWinProfile(const nsString& aFolder, const nsString& aFile, JSContext* jscontext, JSClass* WinProfileClass, jsval* aReturn);
- PRInt32 GetWinRegistry(JSContext* jscontext, JSClass* WinRegClass, jsval* aReturn);
- PRInt32 LoadResources(JSContext* cx, const nsString& aBaseName, jsval* aReturn);
- PRInt32 Patch(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aTargetName, PRInt32* aReturn);
- PRInt32 Patch(const nsString& aRegName, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aTargetName, PRInt32* aReturn);
- PRInt32 RegisterChrome(nsIFile* chrome, PRUint32 chromeType, const char* path);
- PRInt32 RefreshPlugins(PRBool aReloadPages);
- PRInt32 ResetError(PRInt32 aError);
- PRInt32 SetPackageFolder(nsInstallFolder& aFolder);
- PRInt32 StartInstall(const nsString& aUserPackageName, const nsString& aPackageName, const nsString& aVersion, PRInt32* aReturn);
- PRInt32 Uninstall(const nsString& aPackageName, PRInt32* aReturn);
-
- PRInt32 FileOpDirCreate(nsInstallFolder& aTarget, PRInt32* aReturn);
- PRInt32 FileOpDirGetParent(nsInstallFolder& aTarget, nsInstallFolder** theParentFolder);
- PRInt32 FileOpDirRemove(nsInstallFolder& aTarget, PRInt32 aFlags, PRInt32* aReturn);
- PRInt32 FileOpDirRename(nsInstallFolder& aSrc, nsString& aTarget, PRInt32* aReturn);
- PRInt32 FileOpFileCopy(nsInstallFolder& aSrc, nsInstallFolder& aTarget, PRInt32* aReturn);
- PRInt32 FileOpFileDelete(nsInstallFolder& aTarget, PRInt32 aFlags, PRInt32* aReturn);
- PRInt32 FileOpFileExists(nsInstallFolder& aTarget, PRBool* aReturn);
- PRInt32 FileOpFileExecute(nsInstallFolder& aTarget, nsString& aParams, PRBool aBlocking, PRInt32* aReturn);
- PRInt32 FileOpFileGetNativeVersion(nsInstallFolder& aTarget, nsString* aReturn);
- PRInt32 FileOpFileGetDiskSpaceAvailable(nsInstallFolder& aTarget, PRInt64* aReturn);
- PRInt32 FileOpFileGetModDate(nsInstallFolder& aTarget, double* aReturn);
- PRInt32 FileOpFileGetSize(nsInstallFolder& aTarget, PRInt64* aReturn);
- PRInt32 FileOpFileIsDirectory(nsInstallFolder& aTarget, PRBool* aReturn);
- PRInt32 FileOpFileIsWritable(nsInstallFolder& aTarget, PRBool* aReturn);
- PRInt32 FileOpFileIsFile(nsInstallFolder& aTarget, PRBool* aReturn);
- PRInt32 FileOpFileModDateChanged(nsInstallFolder& aTarget, double aOldStamp, PRBool* aReturn);
- PRInt32 FileOpFileMove(nsInstallFolder& aSrc, nsInstallFolder& aTarget, PRInt32* aReturn);
- PRInt32 FileOpFileRename(nsInstallFolder& aSrc, nsString& aTarget, PRInt32* aReturn);
- PRInt32 FileOpFileWindowsGetShortName(nsInstallFolder& aTarget, nsString& aShortPathName);
- PRInt32 FileOpFileWindowsShortcut(nsIFile* aTarget, nsIFile* aShortcutPath, nsString& aDescription, nsIFile* aWorkingPath, nsString& aParams, nsIFile* aIcon, PRInt32 aIconId, PRInt32* aReturn);
- PRInt32 FileOpFileMacAlias(nsIFile *aSourceFile, nsIFile *aAliasFile, PRInt32* aReturn);
- PRInt32 FileOpFileUnixLink(nsInstallFolder& aTarget, PRInt32 aFlags, PRInt32* aReturn);
- PRInt32 FileOpWinRegisterServer(nsInstallFolder& aTarget, PRInt32* aReturn);
-
- void LogComment(const nsAString& aComment);
-
- PRInt32 ExtractFileFromJar(const nsString& aJarfile, nsIFile* aSuggestedName, nsIFile** aRealName);
- char* GetResourcedString(const nsAString& aResName);
- void AddPatch(nsHashKey *aKey, nsIFile* fileName);
- void GetPatch(nsHashKey *aKey, nsIFile** fileName);
-
- nsIFile* GetJarFileLocation() { return mJarFileLocation; }
- void SetJarFileLocation(nsIFile* aFile);
-
- void GetInstallArguments(nsString& args);
- void SetInstallArguments(const nsString& args);
-
- void GetInstallURL(nsString& url);
- void SetInstallURL(const nsString& url);
-
- PRUint32 GetInstallFlags() { return mInstallFlags; }
- void SetInstallFlags(PRUint32 aFlags) { mInstallFlags = aFlags; }
-
- PRInt32 GetInstallPlatform(nsCString& aPlatform);
-
- CHROMEREG_IFACE* GetChromeRegistry() { return mChromeRegistry; }
- void SetChromeRegistry(CHROMEREG_IFACE* reg)
- { mChromeRegistry = reg; }
-
- PRInt32 GetFinalStatus() { return mFinalStatus; }
- PRBool InInstallTransaction(void) { return mInstalledFiles != nsnull; }
-
- PRInt32 Alert(nsString& string);
- PRInt32 ConfirmEx(nsString& aDialogTitle, nsString& aText, PRUint32 aButtonFlags, nsString& aButton0Title, nsString& aButton1Title, nsString& aButton2Title, nsString& aCheckMsg, PRBool* aCheckState, PRInt32* aReturn);
- void InternalAbort(PRInt32 errcode);
-
- PRInt32 ScheduleForInstall(nsInstallObject* ob);
-
- PRInt32 SaveError(PRInt32 errcode);
-
- private:
- JSObject* mScriptObject;
-
- JSObject* mWinRegObject;
- JSObject* mWinProfileObject;
-
-
- nsCOMPtr<nsIFile> mJarFileLocation;
- nsIZipReader* mJarFileData;
-
- nsString mInstallArguments;
- nsString mInstallURL;
- PRUint32 mInstallFlags;
- nsCString mInstallPlatform;
- CHROMEREG_IFACE* mChromeRegistry; // we don't own it, it outlives us
- nsInstallFolder* mPackageFolder;
-
- PRBool mUserCancelled;
- PRInt32 mFinalStatus;
-
- PRBool mUninstallPackage;
- PRBool mRegisterPackage;
- PRBool mStartInstallCompleted;
-
- nsString mRegistryPackageName; /* Name of the package we are installing */
- nsString mUIName; /* User-readable package name */
- nsInstallVersion* mVersionInfo; /* Component version info */
-
- nsVoidArray* mInstalledFiles;
- //nsCOMPtr<nsISupportsArray> mInstalledFiles;
- nsHashtable* mPatchList;
-
- nsCOMPtr<nsIXPIListener> mListener;
- nsCOMPtr<nsPIXPIProxy> mUIThreadProxy;
-
- nsCOMPtr<nsIStringBundle> mStringBundle;
-
- PRInt32 mLastError;
-
- void ParseFlags(int flags);
- PRInt32 SanityCheck(void);
- void GetTime(nsString &aString);
-
- nsPIXPIProxy* GetUIThreadProxy();
-
- PRInt32 GetQualifiedRegName(const nsString& name, nsString& qualifiedRegName );
- PRInt32 GetQualifiedPackageName( const nsString& name, nsString& qualifiedName );
-
- void CurrentUserNode(nsString& userRegNode);
- PRBool BadRegName(const nsString& regName);
-
- void CleanUp();
-
};
-nsresult MakeUnique(nsILocalFile* file);
-
#endif
deleted file mode 100644
--- a/xpinstall/src/nsInstallBitwise.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released March 31,
- * 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Sean Su <ssu@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nscore.h"
-#include "nsInstall.h" // for error codes
-#include "prmem.h"
-#include "nsInstallBitwise.h"
-
-#ifdef _WINDOWS
-#include <windows.h>
-#include <winreg.h>
-#endif
-
-#define KEY_SHARED_DLLS "Software\\Microsoft\\Windows\\CurrentVersion\\SharedDlls"
-
-PRInt32 RegisterSharedFile(const char *file, PRBool bAlreadyExists)
-{
- PRInt32 rv = nsInstall::SUCCESS;
-
-#ifdef WIN32
- HKEY root;
- HKEY keyHandle = 0;
- LONG result;
- DWORD type = REG_DWORD;
- DWORD dwDisposition;
- PRUint32 valbuf = 0;
- PRUint32 valbufsize;
-
- valbufsize = sizeof(PRUint32);
- root = HKEY_LOCAL_MACHINE;
- result = RegCreateKeyEx(root, KEY_SHARED_DLLS, 0, nsnull, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, nsnull, &keyHandle, &dwDisposition);
- if(ERROR_SUCCESS == result)
- {
- result = RegQueryValueEx(keyHandle, file, nsnull, &type, (LPBYTE)&valbuf, (LPDWORD)&valbufsize);
-
- if((ERROR_SUCCESS == result) && (type == REG_DWORD))
- ++valbuf;
- else
- {
- valbuf = 1;
- if(bAlreadyExists == PR_TRUE)
- ++valbuf;
- }
-
- RegSetValueEx(keyHandle, file, 0, REG_DWORD, (LPBYTE)&valbuf, valbufsize);
- RegCloseKey(keyHandle);
- }
- else
- rv = nsInstall::UNEXPECTED_ERROR;
-
-#endif
-
- return(rv);
-}
-
deleted file mode 100644
--- a/xpinstall/src/nsInstallBitwise.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Sean Su <ssu@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef __NSINSTALLBITWISE_H__
-#define __NSINSTALLBITWISE_H__
-
-#include "NSReg.h"
-#include "nsIFile.h"
-
-PR_BEGIN_EXTERN_C
-
-PRInt32 RegisterSharedFile(const char *file, PRBool bAlreadyExists);
-
-PR_END_EXTERN_C
-
-#endif
deleted file mode 100644
--- a/xpinstall/src/nsInstallExecute.cpp
+++ /dev/null
@@ -1,311 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Daniel Veditz <dveditz@netscape.com>
- * Douglas Turner <dougt@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-
-#include "nsCRT.h"
-#include "prmem.h"
-#include "prprf.h"
-#include "VerReg.h"
-#include "nsInstallExecute.h"
-#include "nsInstallResources.h"
-#include "ScheduledTasks.h"
-
-#include "nsInstall.h"
-#include "nsIDOMInstallVersion.h"
-#include "nsProcess.h"
-#include "nsReadableUtils.h"
-
-// Chop the command-line up in place into an array of arguments
-// by replacing spaces in the command-line string with null
-// terminators and pointing the array elements to the
-// characters following the null terminators.
-//
-// aArgsString is a string containing the complete command-line.
-// aArgs points to an array which will be filled with the
-// individual arguments from the command-line.
-// aArgsAvailable is the size of aArgs, i.e. the maximum number of
-// individual command-line arguments which can be stored in the array.
-//
-// Returns the count of the number of command-line arguments actually
-// stored into the array aArgs or -1 if it fails.
-PRInt32 xpi_PrepareProcessArguments(const char *aArgsString, char **aArgs, PRInt32 aArgsAvailable)
-{
- int argc;
- char *c;
- char *p; // look ahead
- PRBool quoted = PR_FALSE;
-
- aArgs[0] = (char *)aArgsString;
- if (!aArgs[0])
- return -1;
-
- // Strip leading spaces from command-line string.
- argc = 0;
- c = aArgs[argc];
- while (*c == ' ') ++c;
- aArgs[argc++] = c;
-
- for (; *c && argc < aArgsAvailable; ++c)
- {
- switch(*c) {
-
- // Only handle escaped double quote and escaped backslash.
- case '\\':
- // See if next character is backslash or dquote
- if ( *(c+1) == '\\' || *(c+1) == '\"' )
- {
- // Eat escape character (i.e., backslash) by
- // shifting all characters to the left one.
- for (p=c; *p != 0; ++p)
- *p = *(p+1);
- }
- break;
-
- case '\"':
- *c = 0; // terminate current arg
- if (quoted)
- {
- p = c+1; // look ahead
- while (*p == ' ')
- ++p; // eat spaces
- if (*p)
- aArgs[argc++] = p; //not at end, set next arg
- c = p-1;
-
- quoted = PR_FALSE;
- }
- else
- {
- quoted = PR_TRUE;
-
- if (aArgs[argc-1] == c)
- // Quote is at beginning so
- // start current argument after the quote.
- aArgs[argc-1] = c+1;
- else
- // Quote is embedded so
- // start a new argument after the quote.
- aArgs[argc++] = c+1;
- }
- break;
-
- case ' ':
- if (!quoted)
- {
- *c = 0; // terminate current arg
- p = c+1; // look ahead
- while (*p == ' ')
- ++p; // eat spaces
- if (*p)
- aArgs[argc++] = p; //not at end, set next arg
- c = p-1;
- }
- break;
-