зеркало из https://github.com/mozilla/pjs.git
bug 28896 register file versions r=ssu,sr=mscott
bug 45939 File.remove() returns bogus error,r=sgehani,sr=alecf bug 7022 make platform/build info available to XPInstall script r=sgehani,sr=mscott bug 47258 more detailed error reporting failing to install file, r=sgehani,sr=mscott bug 62916 refresh plugins from install script r=ssu,sr=mscott
This commit is contained in:
Родитель
ae7b14dd08
Коммит
b2ac4648b7
|
@ -50,7 +50,6 @@ CPPSRCS = \
|
|||
nsSoftwareUpdate.cpp \
|
||||
nsSoftwareUpdateRun.cpp \
|
||||
nsInstallFile.cpp \
|
||||
nsInstallDelete.cpp \
|
||||
nsInstallExecute.cpp \
|
||||
nsInstallPatch.cpp \
|
||||
nsInstallUninstall.cpp \
|
||||
|
@ -60,6 +59,7 @@ CPPSRCS = \
|
|||
nsLoggingProgressNotifier.cpp \
|
||||
ScheduledTasks.cpp \
|
||||
nsInstallProgressDialog.cpp \
|
||||
nsXPIProxy.cpp \
|
||||
nsXPITriggerInfo.cpp \
|
||||
nsXPInstallManager.cpp \
|
||||
nsInstallFileOpItem.cpp \
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
|
@ -46,7 +45,6 @@ LLIBS = \
|
|||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\js3250.lib \
|
||||
$(DIST)\lib\zlib.lib \
|
||||
$(DIST)\lib\strres.lib \
|
||||
$(LIBNSPR) \
|
||||
$(DIST)\lib\mozreg.lib \
|
||||
$(NULL)
|
||||
|
@ -64,7 +62,6 @@ OBJS = \
|
|||
.\$(OBJDIR)\nsSoftwareUpdate.obj \
|
||||
.\$(OBJDIR)\nsSoftwareUpdateRun.obj \
|
||||
.\$(OBJDIR)\nsInstallFile.obj \
|
||||
.\$(OBJDIR)\nsInstallDelete.obj \
|
||||
.\$(OBJDIR)\nsInstallExecute.obj \
|
||||
.\$(OBJDIR)\nsInstallPatch.obj \
|
||||
.\$(OBJDIR)\nsInstallUninstall.obj \
|
||||
|
@ -81,6 +78,7 @@ OBJS = \
|
|||
.\$(OBJDIR)\nsJSWinProfile.obj \
|
||||
.\$(OBJDIR)\nsWinProfileItem.obj \
|
||||
.\$(OBJDIR)\nsInstallProgressDialog.obj \
|
||||
.\$(OBJDIR)\nsXPIProxy.obj \
|
||||
.\$(OBJDIR)\nsXPITriggerInfo.obj \
|
||||
.\$(OBJDIR)\nsXPInstallManager.obj \
|
||||
.\$(OBJDIR)\nsInstallFileOpItem.obj \
|
||||
|
|
|
@ -52,14 +52,15 @@
|
|||
#include "nsInstallFolder.h"
|
||||
#include "nsInstallVersion.h"
|
||||
#include "nsInstallFile.h"
|
||||
#include "nsInstallDelete.h"
|
||||
#include "nsInstallExecute.h"
|
||||
#include "nsInstallPatch.h"
|
||||
#include "nsInstallUninstall.h"
|
||||
#include "nsInstallResources.h"
|
||||
#include "nsXPIProxy.h"
|
||||
#include "nsRegisterItem.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsProxiedService.h"
|
||||
#include "nsICommonDialogs.h"
|
||||
#include "nsIPrompt.h"
|
||||
|
@ -81,8 +82,17 @@
|
|||
#include "nsILocalFile.h"
|
||||
#include "nsIURL.h"
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_BEOS)
|
||||
#include <sys/utsname.h>
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
#if defined(XP_PC) && !defined(XP_OS2)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
||||
static NS_DEFINE_IID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
|
||||
|
||||
static NS_DEFINE_CID(kCommonDialogsCID, NS_CommonDialog_CID);
|
||||
|
||||
|
@ -226,18 +236,91 @@ nsInstall::RetrieveWinProfilePrototype()
|
|||
|
||||
|
||||
PRInt32
|
||||
nsInstall::GetUserPackageName(nsString& aUserPackageName)
|
||||
nsInstall::GetInstallPlatform(nsCString& aPlatform)
|
||||
{
|
||||
aUserPackageName = mUIName;
|
||||
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_OS2)
|
||||
mInstallPlatform = "OS/2";
|
||||
#elif defined(XP_PC)
|
||||
mInstallPlatform = "Windows";
|
||||
#elif defined(RHAPSODY)
|
||||
mInstallPlatform = "Macintosh";
|
||||
#elif defined (XP_UNIX)
|
||||
mInstallPlatform = "X11";
|
||||
#elif defined(XP_BEOS)
|
||||
mInstallPlatform = "BeOS";
|
||||
#elif defined(XP_MAC)
|
||||
mInstallPlatform = "Macintosh";
|
||||
#endif
|
||||
|
||||
mInstallPlatform += "; ";
|
||||
|
||||
// Gather OS/CPU.
|
||||
#if 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 ???";
|
||||
|
||||
#elif defined(XP_PC)
|
||||
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_MAC)
|
||||
mInstallPlatform += "PPC";
|
||||
#endif
|
||||
}
|
||||
|
||||
aPlatform = mInstallPlatform;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstall::GetRegPackageName(nsString& aRegPackageName)
|
||||
{
|
||||
aRegPackageName = mRegistryPackageName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsInstall::InternalAbort(PRInt32 errcode)
|
||||
|
@ -385,6 +468,7 @@ nsInstall::AddDirectory(const nsString& aRegName,
|
|||
aFolder,
|
||||
newSubDir,
|
||||
aMode,
|
||||
(i == 0), // register the first one only
|
||||
&result);
|
||||
|
||||
if (ie == nsnull)
|
||||
|
@ -530,6 +614,7 @@ nsInstall::AddSubcomponent(const nsString& aRegName,
|
|||
aFolder,
|
||||
tempTargetName,
|
||||
aMode,
|
||||
PR_TRUE,
|
||||
&errcode );
|
||||
|
||||
if (ie == nsnull)
|
||||
|
@ -636,77 +721,6 @@ nsInstall::AddSubcomponent(const nsString& aJarSource,
|
|||
aReturn);
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstall::DeleteComponent(const nsString& aRegistryName, PRInt32* aReturn)
|
||||
{
|
||||
PRInt32 result = SanityCheck();
|
||||
|
||||
if (result != nsInstall::SUCCESS)
|
||||
{
|
||||
*aReturn = SaveError( result );
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsString qualifiedRegName;
|
||||
|
||||
*aReturn = GetQualifiedRegName( aRegistryName, qualifiedRegName);
|
||||
|
||||
if (*aReturn != SUCCESS)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsInstallDelete* id = new nsInstallDelete(this, qualifiedRegName, &result);
|
||||
|
||||
if (id == nsnull)
|
||||
{
|
||||
*aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (result == nsInstall::SUCCESS)
|
||||
{
|
||||
result = ScheduleForInstall( id );
|
||||
}
|
||||
|
||||
*aReturn = SaveError(result);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstall::DeleteFile(nsInstallFolder* aFolder, const nsString& aRelativeFileName, PRInt32* aReturn)
|
||||
{
|
||||
PRInt32 result = SanityCheck();
|
||||
|
||||
if (result != nsInstall::SUCCESS)
|
||||
{
|
||||
*aReturn = SaveError( result );
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsInstallDelete* id = new nsInstallDelete(this, aFolder, aRelativeFileName, &result);
|
||||
|
||||
if (id == nsnull)
|
||||
{
|
||||
*aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (result == nsInstall::SUCCESS)
|
||||
{
|
||||
result = ScheduleForInstall( id );
|
||||
}
|
||||
|
||||
if (result == nsInstall::DOES_NOT_EXIST)
|
||||
{
|
||||
result = nsInstall::SUCCESS;
|
||||
}
|
||||
|
||||
*aReturn = SaveError(result);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstall::DiskSpaceAvailable(const nsString& aFolder, PRInt64* aReturn)
|
||||
|
@ -1368,6 +1382,24 @@ nsInstall::RegisterChrome(nsIFile* chrome, PRUint32 chromeType, const char* path
|
|||
}
|
||||
|
||||
|
||||
PRInt32
|
||||
nsInstall::RefreshPlugins()
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE( nsIProxyObjectManager, pmgr, kProxyObjectManagerCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr<nsPIXPIProxy> tmp = do_QueryInterface(new nsXPIProxy());
|
||||
nsCOMPtr<nsPIXPIProxy> proxy;
|
||||
rv = pmgr->GetProxyForObject( NS_UI_THREAD_EVENTQ, NS_GET_IID(nsPIXPIProxy),
|
||||
tmp, PROXY_SYNC | PROXY_ALWAYS, getter_AddRefs(proxy) );
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = proxy->RefreshPlugins(GetParentDOMWindow());
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
PRInt32
|
||||
nsInstall::ResetError()
|
||||
{
|
||||
|
@ -2577,7 +2609,12 @@ nsInstall::ExtractFileFromJar(const nsString& aJarfile, nsIFile* aSuggestedName,
|
|||
rv = mJarFileData->Extract(nsAutoCString(aJarfile), extractHereSpec);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
return EXTRACTION_FAILED;
|
||||
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_MAC
|
||||
|
|
|
@ -202,9 +202,6 @@ class nsInstall
|
|||
JSObject* RetrieveWinRegPrototype(void);
|
||||
JSObject* RetrieveWinProfilePrototype(void);
|
||||
|
||||
PRInt32 GetUserPackageName(nsString& aUserPackageName);
|
||||
PRInt32 GetRegPackageName(nsString& aRegPackageName);
|
||||
|
||||
PRInt32 AbortInstall(PRInt32 aErrorNumber);
|
||||
|
||||
PRInt32 AddDirectory(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aSubdir, PRInt32 aMode, PRInt32* aReturn);
|
||||
|
@ -217,8 +214,6 @@ class nsInstall
|
|||
PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aJarSource, nsInstallFolder *aFolder, const nsString& aTargetName, PRInt32* aReturn);
|
||||
PRInt32 AddSubcomponent(const nsString& aJarSource, PRInt32* aReturn);
|
||||
|
||||
PRInt32 DeleteComponent(const nsString& aRegistryName, PRInt32* aReturn);
|
||||
PRInt32 DeleteFile(nsInstallFolder* aFolder, const nsString& aRelativeFileName, 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);
|
||||
|
@ -238,6 +233,7 @@ class nsInstall
|
|||
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();
|
||||
PRInt32 ResetError();
|
||||
PRInt32 SetPackageFolder(nsInstallFolder& aFolder);
|
||||
PRInt32 StartInstall(const nsString& aUserPackageName, const nsString& aPackageName, const nsString& aVersion, PRInt32* aReturn);
|
||||
|
@ -284,6 +280,8 @@ class nsInstall
|
|||
|
||||
PRUint32 GetInstallFlags() { return mInstallFlags; }
|
||||
void SetInstallFlags(PRUint32 aFlags) { mInstallFlags = aFlags; }
|
||||
|
||||
PRInt32 GetInstallPlatform(nsCString& aPlatform);
|
||||
|
||||
nsIChromeRegistry* GetChromeRegistry() { return mChromeRegistry; }
|
||||
void SetChromeRegistry(nsIChromeRegistry* reg)
|
||||
|
@ -317,6 +315,7 @@ class nsInstall
|
|||
nsString mInstallArguments;
|
||||
nsString mInstallURL;
|
||||
PRUint32 mInstallFlags;
|
||||
nsCString mInstallPlatform;
|
||||
nsIChromeRegistry* mChromeRegistry; // we don't own it, it outlives us
|
||||
nsIDOMWindowInternal* mParent;
|
||||
nsInstallFolder* mPackageFolder;
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#define KEY_SHARED_DLLS "Software\\Microsoft\\Windows\\CurrentVersion\\SharedDlls"
|
||||
|
||||
PRInt32 RegisterSharedFile(char *file, PRBool bAlreadyExists)
|
||||
PRInt32 RegisterSharedFile(const char *file, PRBool bAlreadyExists)
|
||||
{
|
||||
PRInt32 rv = nsInstall::SUCCESS;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
PRInt32 RegisterSharedFile(char *file, PRBool bAlreadyExists);
|
||||
PRInt32 RegisterSharedFile(const char *file, PRBool bAlreadyExists);
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "nsInstallResources.h"
|
||||
#include "nsInstallLogComment.h"
|
||||
#include "nsInstallBitwise.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
/* Public Methods */
|
||||
|
||||
|
@ -53,6 +54,7 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
|
|||
nsInstallFolder *folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
PRInt32 mode,
|
||||
PRBool aRegister,
|
||||
PRInt32 *error)
|
||||
: nsInstallObject(inInstall),
|
||||
mVersionInfo(nsnull),
|
||||
|
@ -61,9 +63,7 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
|
|||
mFinalFile(nsnull),
|
||||
mVersionRegistryName(nsnull),
|
||||
mReplaceFile(PR_FALSE),
|
||||
mChildFile(PR_TRUE),
|
||||
mUpgradeFile(PR_FALSE),
|
||||
mSkipInstall(PR_FALSE),
|
||||
mRegister(aRegister),
|
||||
mMode(mode)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsInstallFile);
|
||||
|
@ -159,23 +159,6 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
|
|||
*error = nsInstall::OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
|
||||
nsString regPackageName;
|
||||
mInstall->GetRegPackageName(regPackageName);
|
||||
|
||||
// determine Child status
|
||||
if ( regPackageName.IsEmpty() )
|
||||
{
|
||||
// in the "current communicator package" absolute pathnames (start
|
||||
// with slash) indicate shared files -- all others are children
|
||||
mChildFile = ( mVersionRegistryName->CharAt(0) != '/' );
|
||||
}
|
||||
else
|
||||
{
|
||||
mChildFile = mVersionRegistryName->EqualsWithConversion( regPackageName,
|
||||
PR_FALSE,
|
||||
regPackageName.Length() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -274,9 +257,6 @@ PRInt32 nsInstallFile::Prepare()
|
|||
{
|
||||
PRInt32 error = nsInstall::SUCCESS;
|
||||
|
||||
if (mSkipInstall)
|
||||
return nsInstall::SUCCESS;
|
||||
|
||||
if (mInstall == nsnull || mFinalFile == nsnull || mJarLocation == nsnull )
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
|
||||
|
@ -309,17 +289,16 @@ PRInt32 nsInstallFile::Complete()
|
|||
return nsInstall::INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
if (mSkipInstall)
|
||||
return nsInstall::SUCCESS;
|
||||
|
||||
err = CompleteFileMove();
|
||||
|
||||
if ( 0 == err || nsInstall::REBOOT_NEEDED == err )
|
||||
if ( mRegister && (0 == err || nsInstall::REBOOT_NEEDED == err) )
|
||||
{
|
||||
// XXX Don't register individual files for now -- crucial performance
|
||||
// speed up on the Mac, and we'll switch uninstall schemes after beta
|
||||
|
||||
// RegisterInVersionRegistry();
|
||||
nsXPIDLCString path;
|
||||
mFinalFile->GetPath(getter_Copies(path));
|
||||
VR_Install( NS_ConvertUCS2toUTF8(*mVersionRegistryName),
|
||||
(char*)(const char*)path, // DO NOT CHANGE THIS.
|
||||
NS_ConvertUCS2toUTF8(*mVersionInfo),
|
||||
PR_FALSE );
|
||||
}
|
||||
|
||||
return err;
|
||||
|
@ -337,7 +316,6 @@ char* nsInstallFile::toString()
|
|||
{
|
||||
char* buffer = new char[RESBUFSIZE];
|
||||
char* rsrcVal = nsnull;
|
||||
char* fname = nsnull;
|
||||
|
||||
if (buffer == nsnull || !mInstall)
|
||||
return nsnull;
|
||||
|
@ -355,17 +333,6 @@ char* nsInstallFile::toString()
|
|||
rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("ReplaceFile"));
|
||||
}
|
||||
}
|
||||
else if (mSkipInstall)
|
||||
{
|
||||
if(mMode & nsInstall::WIN_SHARED_FILE)
|
||||
{
|
||||
rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("SkipSharedFile"));
|
||||
}
|
||||
else
|
||||
{
|
||||
rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("SkipFile"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mMode & nsInstall::WIN_SHARED_FILE)
|
||||
|
@ -388,14 +355,16 @@ char* nsInstallFile::toString()
|
|||
|
||||
interimStr.AppendWithConversion(rsrcVal);
|
||||
interimCStr = interimStr.ToNewCString();
|
||||
if(interimCStr == nsnull)
|
||||
return interimCStr;
|
||||
|
||||
if (mFinalFile)
|
||||
mFinalFile->GetPath(&fname);
|
||||
|
||||
PR_snprintf( buffer, RESBUFSIZE, interimCStr, fname );
|
||||
if(interimCStr)
|
||||
{
|
||||
nsXPIDLCString fname;
|
||||
if (mFinalFile)
|
||||
mFinalFile->GetPath(getter_Copies(fname));
|
||||
|
||||
PR_snprintf( buffer, RESBUFSIZE, interimCStr, fname );
|
||||
Recycle(interimCStr);
|
||||
}
|
||||
Recycle(rsrcVal);
|
||||
}
|
||||
|
||||
|
@ -406,8 +375,6 @@ char* nsInstallFile::toString()
|
|||
PRInt32 nsInstallFile::CompleteFileMove()
|
||||
{
|
||||
int result = 0;
|
||||
char *temp;
|
||||
PRBool bAlreadyExists = PR_FALSE;
|
||||
PRBool bIsEqual = PR_FALSE;
|
||||
|
||||
if (mExtractedFile == nsnull)
|
||||
|
@ -429,103 +396,14 @@ PRInt32 nsInstallFile::CompleteFileMove()
|
|||
|
||||
if(mMode & nsInstall::WIN_SHARED_FILE)
|
||||
{
|
||||
if(mReplaceFile || mSkipInstall)
|
||||
bAlreadyExists = PR_TRUE;
|
||||
|
||||
mFinalFile->GetPath(&temp);
|
||||
RegisterSharedFile(temp, bAlreadyExists);
|
||||
nsXPIDLCString path;
|
||||
mFinalFile->GetPath(getter_Copies(path));
|
||||
RegisterSharedFile(path, mReplaceFile);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstallFile::RegisterInVersionRegistry()
|
||||
{
|
||||
int refCount;
|
||||
nsString regPackageName;
|
||||
mInstall->GetRegPackageName(regPackageName);
|
||||
|
||||
|
||||
// Register file and log for Uninstall
|
||||
|
||||
if (!mChildFile)
|
||||
{
|
||||
int found;
|
||||
if (!regPackageName.IsEmpty())
|
||||
{
|
||||
found = VR_UninstallFileExistsInList( (char*)(const char*)nsAutoCString(regPackageName) ,
|
||||
(char*)(const char*)nsAutoCString(*mVersionRegistryName));
|
||||
}
|
||||
else
|
||||
{
|
||||
found = VR_UninstallFileExistsInList( "", (char*)(const char*)nsAutoCString(*mVersionRegistryName) );
|
||||
}
|
||||
|
||||
if (found != REGERR_OK)
|
||||
mUpgradeFile = PR_FALSE;
|
||||
else
|
||||
mUpgradeFile = PR_TRUE;
|
||||
}
|
||||
else if (REGERR_OK == VR_InRegistry( (char*)(const char*)nsAutoCString(*mVersionRegistryName)))
|
||||
{
|
||||
mUpgradeFile = PR_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mUpgradeFile = PR_FALSE;
|
||||
}
|
||||
|
||||
if ( REGERR_OK != VR_GetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), &refCount ))
|
||||
{
|
||||
refCount = 0;
|
||||
}
|
||||
|
||||
char* temp;
|
||||
mFinalFile->GetPath(&temp);
|
||||
VR_Install( (char*)(const char*)nsAutoCString(*mVersionRegistryName),
|
||||
(char*)(const char*)temp, // DO NOT CHANGE THIS.
|
||||
(char*)(const char*)nsAutoCString(*mVersionInfo),
|
||||
PR_FALSE );
|
||||
|
||||
if (mUpgradeFile)
|
||||
{
|
||||
if (refCount == 0)
|
||||
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), 1 );
|
||||
else
|
||||
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), refCount ); //FIX?? what should the ref count be/
|
||||
}
|
||||
else
|
||||
{
|
||||
if (refCount != 0)
|
||||
{
|
||||
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), refCount + 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mReplaceFile)
|
||||
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), 2 );
|
||||
else
|
||||
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), 1 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !mChildFile && !mUpgradeFile )
|
||||
{
|
||||
if (!regPackageName.IsEmpty())
|
||||
{
|
||||
VR_UninstallAddFileToList( (char*)(const char*)nsAutoCString(regPackageName),
|
||||
(char*)(const char*)nsAutoCString(*mVersionRegistryName));
|
||||
}
|
||||
else
|
||||
{
|
||||
VR_UninstallAddFileToList( "", (char*)(const char*)nsAutoCString(*mVersionRegistryName) );
|
||||
}
|
||||
}
|
||||
|
||||
return nsInstall::SUCCESS;
|
||||
}
|
||||
|
||||
/* CanUninstall
|
||||
* InstallFile() installs files which can be uninstalled,
|
||||
* hence this function returns true.
|
||||
|
|
|
@ -63,6 +63,7 @@ class nsInstallFile : public nsInstallObject
|
|||
nsInstallFolder *folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
PRInt32 mode,
|
||||
PRBool bRegister,
|
||||
PRInt32 *error);
|
||||
|
||||
virtual ~nsInstallFile();
|
||||
|
@ -87,18 +88,14 @@ class nsInstallFile : public nsInstallObject
|
|||
|
||||
nsString* mVersionRegistryName; /* full version path */
|
||||
|
||||
PRBool mForceInstall; /* whether install is forced */
|
||||
PRBool mReplaceFile; /* whether file exists */
|
||||
PRBool mChildFile; /* whether file is a child */
|
||||
PRBool mUpgradeFile; /* whether file is an upgrade */
|
||||
PRBool mSkipInstall; /* if true don't install this file */
|
||||
PRBool mRegister; /* if true register this file */
|
||||
PRUint32 mFolderCreateCount; /* int to keep count of the number of folders created for a given path */
|
||||
|
||||
PRInt32 mMode; /* an integer used like a bitfield to control *
|
||||
* how a file is installed or registered */
|
||||
|
||||
PRInt32 CompleteFileMove();
|
||||
PRInt32 RegisterInVersionRegistry();
|
||||
void CreateAllFolders(nsInstall *inInstall, nsIFile *inFolderPath, PRInt32 *error);
|
||||
|
||||
|
||||
|
|
|
@ -919,7 +919,8 @@ nsInstallFileOpItem::NativeFileOpFileDeleteComplete(nsIFile *aTarget)
|
|||
return nsInstall::IS_DIRECTORY;
|
||||
}
|
||||
|
||||
return nsInstall::DOES_NOT_EXIST;
|
||||
// file went away on its own, not a problem
|
||||
return nsInstall::SUCCESS;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
#include "nsBuildID.h"
|
||||
#include "nsString.h"
|
||||
#include "nsInstall.h"
|
||||
#include "nsInstallFile.h"
|
||||
|
@ -52,8 +53,8 @@ extern JSClass FileOpClass;
|
|||
//
|
||||
enum Install_slots
|
||||
{
|
||||
INSTALL_USERPACKAGENAME = -1,
|
||||
INSTALL_REGPACKAGENAME = -2,
|
||||
INSTALL_PLATFORM = -1,
|
||||
INSTALL_BUILDID = -2,
|
||||
INSTALL_JARFILE = -3,
|
||||
INSTALL_ARCHIVE = -4,
|
||||
INSTALL_ARGUMENTS = -5,
|
||||
|
@ -90,33 +91,17 @@ GetInstallProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
if (JSVAL_IS_INT(id))
|
||||
{
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case INSTALL_USERPACKAGENAME:
|
||||
case INSTALL_PLATFORM:
|
||||
{
|
||||
nsAutoString prop;
|
||||
if (NS_OK == a->GetUserPackageName(prop))
|
||||
{
|
||||
*vp = STRING_TO_JSVAL( JS_NewUCStringCopyN(cx, NS_REINTERPRET_CAST(const jschar*, prop.GetUnicode()), prop.Length()) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
nsCAutoString prop;
|
||||
a->GetInstallPlatform(prop);
|
||||
*vp = STRING_TO_JSVAL( JS_NewStringCopyZ(cx, prop.get()) );
|
||||
break;
|
||||
}
|
||||
|
||||
case INSTALL_REGPACKAGENAME:
|
||||
{
|
||||
nsAutoString prop;
|
||||
if (NS_OK == a->GetRegPackageName(prop))
|
||||
{
|
||||
*vp = STRING_TO_JSVAL( JS_NewUCStringCopyN(cx, NS_REINTERPRET_CAST(const jschar*, prop.GetUnicode()), prop.Length()) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
case INSTALL_BUILDID:
|
||||
*vp = INT_TO_JSVAL(NS_BUILD_ID);
|
||||
break;
|
||||
}
|
||||
|
||||
case INSTALL_ARCHIVE:
|
||||
case INSTALL_JARFILE:
|
||||
|
@ -720,95 +705,9 @@ InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
PR_STATIC_CALLBACK(JSBool)
|
||||
InstallDeleteComponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
|
||||
PRInt32 nativeRet;
|
||||
nsAutoString b0;
|
||||
|
||||
// this function was once documented but never supported. Return an error,
|
||||
// but don't remove which would kill scripts that reference this.
|
||||
*rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if(argc >= 1)
|
||||
{
|
||||
// public int DeleteComponent ( String registryName);
|
||||
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->DeleteComponent(b0, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "Function DeleteComponent requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method DeleteFile
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
InstallDeleteFile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
|
||||
PRInt32 nativeRet;
|
||||
JSObject* jsObj;
|
||||
nsAutoString b1;
|
||||
nsInstallFolder* folder;
|
||||
|
||||
*rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if(argc >= 2)
|
||||
{
|
||||
// public int DeleteFile ( Object folder,
|
||||
// String relativeFileName);
|
||||
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
if ((argv[0] == JSVAL_NULL) || !JSVAL_IS_OBJECT(argv[0])) //argv[0] MUST be a jsval
|
||||
{
|
||||
*rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
|
||||
nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
jsObj = JSVAL_TO_OBJECT(argv[0]);
|
||||
if (!JS_InstanceOf(cx, jsObj, &FileSpecObjectClass, nsnull))
|
||||
{
|
||||
*rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);
|
||||
nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);
|
||||
|
||||
if(NS_OK != nativeThis->DeleteFile(folder, b1, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "Function DeleteFile requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1432,6 +1331,10 @@ InstallPatch(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
//
|
||||
// Native method RegisterChrome
|
||||
//
|
||||
// int registerChrome(
|
||||
// int type,
|
||||
// FileSpecObject chrome,
|
||||
// String extraPath)
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
InstallRegisterChrome(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
|
@ -1473,6 +1376,24 @@ InstallRegisterChrome(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
|
|||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method RefreshPlugins
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
InstallRefreshPlugins(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
|
||||
if (!nativeThis) {
|
||||
*rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
|
||||
}
|
||||
else {
|
||||
*rval = INT_TO_JSVAL(nativeThis->RefreshPlugins());
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ResetError
|
||||
//
|
||||
|
@ -1783,8 +1704,8 @@ JSClass InstallClass = {
|
|||
//
|
||||
static JSPropertySpec InstallProperties[] =
|
||||
{
|
||||
{"userPackageName", INSTALL_USERPACKAGENAME, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"regPackageName", INSTALL_REGPACKAGENAME, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"platform", INSTALL_PLATFORM, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"buildID", INSTALL_BUILDID, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"jarfile", INSTALL_JARFILE, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"archive", INSTALL_ARCHIVE, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"arguments", INSTALL_ARGUMENTS, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
|
@ -1877,7 +1798,6 @@ static JSFunctionSpec InstallMethods[] =
|
|||
{"alert", InstallAlert, 1},
|
||||
{"cancelInstall", InstallAbortInstall, 1},
|
||||
{"confirm", InstallConfirm, 2},
|
||||
{"deleteRegisteredFile", InstallDeleteComponent, 1},
|
||||
{"execute", InstallExecute, 2},
|
||||
{"gestalt", InstallGestalt, 1},
|
||||
{"getComponentFolder", InstallGetComponentFolder, 2},
|
||||
|
@ -1891,7 +1811,9 @@ static JSFunctionSpec InstallMethods[] =
|
|||
{"patch", InstallPatch, 5},
|
||||
{"performInstall", InstallFinalizeInstall, 0},
|
||||
{"registerChrome", InstallRegisterChrome, 2},
|
||||
{"refreshPlugins", InstallRefreshPlugins, 0},
|
||||
{"resetError", InstallResetError, 0},
|
||||
// {"selectChrome", InstallSelectChrome, 2},
|
||||
{"setPackageFolder", InstallSetPackageFolder, 1},
|
||||
{"uninstall", InstallUninstall, 1},
|
||||
|
||||
|
@ -1917,6 +1839,9 @@ static JSFunctionSpec InstallMethods[] =
|
|||
{"fileMacAlias", InstallFileOpFileMacAlias, 2},
|
||||
{"fileUnixLink", InstallFileOpFileUnixLink, 2},
|
||||
|
||||
// -- documented but never supported --
|
||||
{"deleteRegisteredFile", InstallDeleteComponent, 1},
|
||||
|
||||
// -- obsolete forms for temporary compatibility --
|
||||
{"abortInstall", InstallAbortInstall, 1},
|
||||
{"finalizeInstall", InstallFinalizeInstall, 0},
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsXPIProxy.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIDOMNavigator.h"
|
||||
#include "nsIDOMPluginArray.h"
|
||||
|
||||
nsXPIProxy::nsXPIProxy()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsXPIProxy::~nsXPIProxy()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsXPIProxy, nsPIXPIProxy);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPIProxy::RefreshPlugins(nsISupports *aWindow)
|
||||
{
|
||||
if (!aWindow)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> win(do_QueryInterface(aWindow));
|
||||
if (!win)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMNavigator> nav;
|
||||
nsresult rv = win->GetNavigator(getter_AddRefs(nav));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMPluginArray> plugins;
|
||||
rv = nav->GetPlugins(getter_AddRefs(plugins));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = plugins->Refresh(PR_TRUE);
|
||||
return rv;
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.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/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef nsXPIProxy_h__
|
||||
#define nsXPIProxy_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsPIXPIProxy.h"
|
||||
|
||||
class nsXPIProxy : public nsPIXPIProxy
|
||||
{
|
||||
public:
|
||||
|
||||
nsXPIProxy();
|
||||
virtual ~nsXPIProxy();
|
||||
|
||||
NS_DECL_ISUPPORTS;
|
||||
NS_DECL_NSPIXPIPROXY;
|
||||
};
|
||||
|
||||
#endif /* nsXPIProxy_h__ */
|
Загрузка…
Ссылка в новой задаче