зеркало из https://github.com/mozilla/pjs.git
fixing bug 125106 - general nsIFile converter change hosed XPInstall intl filenames. r=dveditz, sr=alecf, a=sspitzer
This commit is contained in:
Родитель
6558b1085f
Коммит
b5214fa2f7
|
@ -90,6 +90,7 @@ EXPORTS = \
|
|||
nsStringIO.h \
|
||||
nsStringStream.h \
|
||||
nsStreamUtils.h \
|
||||
nsNativeCharsetUtils.h \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||
|
|
|
@ -30,7 +30,7 @@ interface nsIXPIListener : nsISupports
|
|||
{
|
||||
void onInstallStart(in wstring URL);
|
||||
void onInstallDone(in wstring URL, in long status);
|
||||
void onPackageNameSet(in wstring URL, in wstring UIPackageName);
|
||||
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);
|
||||
|
|
|
@ -58,6 +58,7 @@ REQUIRES = xpcom \
|
|||
dom \
|
||||
windowwatcher \
|
||||
plugin \
|
||||
unicharutil \
|
||||
$(ZLIB_REQUIRES) \
|
||||
$(NULL)
|
||||
|
||||
|
@ -99,7 +100,6 @@ CPPSRCS += \
|
|||
nsWinReg.cpp \
|
||||
nsJSWinReg.cpp \
|
||||
nsWinRegItem.cpp \
|
||||
nsWinRegValue.cpp \
|
||||
nsWinProfile.cpp \
|
||||
nsJSWinProfile.cpp \
|
||||
nsWinProfileItem.cpp \
|
||||
|
@ -117,6 +117,7 @@ EXTRA_DSO_LDOPTS = \
|
|||
$(MOZ_JS_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(MOZ_XPCOM_OBSOLETE_LIBS) \
|
||||
$(MOZ_UNICHARUTIL_LIBS) \
|
||||
$(ZLIB_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -25,14 +25,11 @@
|
|||
|
||||
#include "nscore.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "nsInstall.h" // for error codes
|
||||
#include "prmem.h"
|
||||
#include "ScheduledTasks.h"
|
||||
#include "InstallCleanupDefines.h"
|
||||
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsDirectoryService.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
|
@ -245,39 +242,41 @@ PRInt32 ReplaceFileNow(nsIFile* replacementFile, nsIFile* doomedFile )
|
|||
nsCOMPtr<nsIFile> renamedDoomedFile;
|
||||
nsCOMPtr<nsILocalFile> tmpLocalFile;
|
||||
nsCOMPtr<nsIFile> parent;
|
||||
nsCAutoString leafname;
|
||||
|
||||
doomedFile->Clone(getter_AddRefs(renamedDoomedFile));
|
||||
renamedDoomedFile->Exists(&flagExists);
|
||||
if ( flagExists )
|
||||
{
|
||||
#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.
|
||||
nsCOMPtr<nsILocalFile> doomedFileLocal(do_QueryInterface(doomedFile));
|
||||
nsCAutoString doomedFilePath;
|
||||
rv = doomedFileLocal->GetNativePath(doomedFilePath);
|
||||
if (NS_FAILED(rv))
|
||||
return nsInstall::UNEXPECTED_ERROR;
|
||||
// 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(doomedFile));
|
||||
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 leafname so we can convert its extension to .old
|
||||
nsAutoString leafname;
|
||||
nsCAutoString uniqueLeafName;
|
||||
tmpLocalFile->GetNativeLeafName(leafname);
|
||||
tmpLocalFile->GetLeafName(leafname);
|
||||
|
||||
// do not RFind on the native charset! UTF8 or Unicode are OK
|
||||
PRInt32 extpos = leafname.RFindChar('.');
|
||||
if (extpos != -1)
|
||||
{
|
||||
// We found the extension;
|
||||
leafname.Truncate(extpos + 1); //strip off the old extension
|
||||
}
|
||||
leafname.Append("old");
|
||||
leafname.Append(NS_LITERAL_STRING("old"));
|
||||
|
||||
//Now reset the leafname
|
||||
tmpLocalFile->SetNativeLeafName(leafname);
|
||||
tmpLocalFile->SetLeafName(leafname);
|
||||
tmpLocalFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0644);
|
||||
tmpLocalFile->GetParent(getter_AddRefs(parent)); //get the parent for later use in MoveTo
|
||||
tmpLocalFile->GetNativeLeafName(uniqueLeafName);//this is the new "unique" leafname
|
||||
|
@ -315,6 +314,7 @@ PRInt32 ReplaceFileNow(nsIFile* replacementFile, nsIFile* doomedFile )
|
|||
{
|
||||
nsCOMPtr<nsIFile> parentofFinalFile;
|
||||
nsCOMPtr<nsIFile> parentofReplacementFile;
|
||||
nsCAutoString leafname;
|
||||
|
||||
doomedFile->GetParent(getter_AddRefs(parentofFinalFile));
|
||||
replacementFile->GetParent(getter_AddRefs(parentofReplacementFile));
|
||||
|
@ -489,7 +489,8 @@ void DeleteScheduledFiles( HREG reg )
|
|||
{
|
||||
// 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?
|
||||
//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))
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
|
||||
|
||||
#include "NSReg.h"
|
||||
//#include "mozreg.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsIFile.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
|
||||
|
||||
#include "prio.h"
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
#define GDIFF_MAGIC "\xD1\xFF\xD1\xFF"
|
||||
#define GDIFF_MAGIC_LEN 4
|
||||
|
|
|
@ -30,15 +30,13 @@
|
|||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsHashtable.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "nsIFileChannel.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsDirectoryService.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
|
||||
|
@ -48,6 +46,7 @@
|
|||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "prprf.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
#include "VerReg.h"
|
||||
|
||||
|
@ -361,6 +360,8 @@ nsInstall::InternalAbort(PRInt32 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);
|
||||
|
@ -953,11 +954,10 @@ nsInstall::GetComponentFolder(const nsString& aComponentName, const nsString& aS
|
|||
{
|
||||
long err;
|
||||
char dir[MAXREGPATHLEN];
|
||||
nsFileSpec nsfsDir;
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if(!aNewFolder)
|
||||
return INVALID_ARGUMENTS;
|
||||
return INVALID_ARGUMENTS;
|
||||
|
||||
*aNewFolder = nsnull;
|
||||
|
||||
|
@ -973,45 +973,44 @@ nsInstall::GetComponentFolder(const nsString& aComponentName, const nsString& aS
|
|||
|
||||
if((err = VR_GetDefaultDirectory( NS_CONST_CAST(char *, componentCString.get()), sizeof(dir), dir )) != REGERR_OK)
|
||||
{
|
||||
if((err = VR_GetPath( NS_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( NS_CONST_CAST(char *, componentCString.get()), sizeof(dir), dir )) != REGERR_OK)
|
||||
{
|
||||
int i;
|
||||
// no path, either
|
||||
*dir = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
nsString dirStr; dirStr.AssignWithConversion(dir);
|
||||
if ( (i = dirStr.RFindChar(FILESEP)) > 0 )
|
||||
{
|
||||
// i is the index in the string, not the total number of
|
||||
// characters in the string. ToCString() requires the
|
||||
// total number of characters in the string to copy,
|
||||
// therefore add 1 to it.
|
||||
dirStr.Truncate(i + 1);
|
||||
dirStr.ToCString(dir, MAXREGPATHLEN);
|
||||
}
|
||||
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
|
||||
{
|
||||
*dir = '\0';
|
||||
*aNewFolder = folder;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*dir = '\0';
|
||||
}
|
||||
|
||||
if(*dir != '\0')
|
||||
{
|
||||
nsInstallFolder * folder = new nsInstallFolder();
|
||||
if (!folder) return NS_ERROR_OUT_OF_MEMORY;
|
||||
res = folder->Init(NS_ConvertASCIItoUCS2(dir), aSubdirectory);
|
||||
if (NS_FAILED(res))
|
||||
{
|
||||
delete folder;
|
||||
}
|
||||
else
|
||||
{
|
||||
*aNewFolder = folder;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -1253,11 +1252,12 @@ nsInstall::LoadResources(JSContext* cx, const nsString& aBaseName, jsval* aRetur
|
|||
if (NS_FAILED(ret))
|
||||
goto cleanup;
|
||||
|
||||
if (!pKey.IsEmpty() && !pKey.IsEmpty())
|
||||
if (!pKey.IsEmpty() && !pVal.IsEmpty())
|
||||
{
|
||||
JSString* propValJSStr = JS_NewUCStringCopyZ(cx, NS_REINTERPRET_CAST(const jschar*, pVal.get()));
|
||||
jsval propValJSVal = STRING_TO_JSVAL(propValJSStr);
|
||||
JS_SetProperty(cx, res, pKey.get(), &propValJSVal);
|
||||
nsString UCKey = NS_ConvertUTF8toUCS2(pKey);
|
||||
JS_SetUCProperty(cx, res, UCKey.get(), UCKey.Length(), &propValJSVal);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1474,11 +1474,14 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aRegis
|
|||
{
|
||||
// found one saved in the registry
|
||||
mPackageFolder = new nsInstallFolder();
|
||||
if (mPackageFolder)
|
||||
nsCOMPtr<nsILocalFile> packageDir;
|
||||
NS_NewNativeLocalFile(
|
||||
nsDependentCString(szRegPackagePath), // native path
|
||||
PR_FALSE, getter_AddRefs(packageDir) );
|
||||
|
||||
if (mPackageFolder && packageDir)
|
||||
{
|
||||
if (NS_FAILED( mPackageFolder->Init(
|
||||
NS_ConvertASCIItoUCS2(szRegPackagePath),
|
||||
nsAutoString() ) ))
|
||||
if (NS_FAILED( mPackageFolder->Init(packageDir, nsString()) ))
|
||||
{
|
||||
delete mPackageFolder;
|
||||
mPackageFolder = nsnull;
|
||||
|
@ -1493,7 +1496,7 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aRegis
|
|||
mStartInstallCompleted = PR_TRUE;
|
||||
mFinalStatus = MALFORMED_INSTALL;
|
||||
if (mListener)
|
||||
mListener->OnPackageNameSet(mInstallURL.get(), mUIName.get());
|
||||
mListener->OnPackageNameSet(mInstallURL.get(), mUIName.get(), aVersion.get());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1618,7 +1621,7 @@ nsInstall::FileOpDirGetParent(nsInstallFolder& aTarget, nsInstallFolder** thePar
|
|||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
folder->Init(parent);
|
||||
folder->Init(parent,nsString());
|
||||
*theParentFolder = folder;
|
||||
}
|
||||
else
|
||||
|
@ -2068,6 +2071,7 @@ nsInstall::FileOpFileWindowsGetShortName(nsInstallFolder& aTarget, nsString& aSh
|
|||
PRBool flagExists;
|
||||
nsString tmpNsString;
|
||||
nsCAutoString nativeTargetPath;
|
||||
nsAutoString unicodePath;
|
||||
char nativeShortPathName[MAX_PATH];
|
||||
nsCOMPtr<nsIFile> localTarget(aTarget.GetFileSpec());
|
||||
|
||||
|
@ -2091,21 +2095,30 @@ nsInstall::FileOpFileWindowsGetShortName(nsInstallFolder& aTarget, nsString& aSh
|
|||
return NS_OK;
|
||||
|
||||
err = GetShortPathName(nativeTargetPath.get(), nativeShortPathNameTmp, err + 1);
|
||||
// Is it 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 err is 0, it's not a buffer size problem. It's something else unexpected.
|
||||
// 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)
|
||||
aShortPathName.AssignWithConversion(nativeShortPathNameTmp);
|
||||
{
|
||||
// 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.
|
||||
aShortPathName.AssignWithConversion(nativeShortPathName);
|
||||
NS_CopyNativeToUnicode(nsDependentCString(nativeShortPathName), unicodePath);
|
||||
}
|
||||
}
|
||||
|
||||
if (!unicodePath.IsEmpty())
|
||||
aShortPathName = unicodePath;
|
||||
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "plevent.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "nsInstall.h" // for error codes
|
||||
#include "prmem.h"
|
||||
#include "nsInstallBitwise.h"
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#define __NSINSTALLBITWISE_H__
|
||||
|
||||
#include "NSReg.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsIFile.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
|
|
@ -25,10 +25,8 @@
|
|||
|
||||
|
||||
|
||||
#include "nsCRT.h"
|
||||
#include "prmem.h"
|
||||
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
#include "VerReg.h"
|
||||
#include "nsInstallExecute.h"
|
||||
#include "nsInstallResources.h"
|
||||
|
@ -56,14 +54,14 @@ MOZ_DECL_CTOR_COUNTER(nsInstallExecute)
|
|||
//
|
||||
// Returns the count of the number of command-line arguments actually
|
||||
// stored into the array aArgs or -1 if it fails.
|
||||
PRInt32 xpi_PrepareProcessArguments(char *aArgsString, char **aArgs, PRInt32 aArgsAvailable)
|
||||
PRInt32 xpi_PrepareProcessArguments(const char *aArgsString, char **aArgs, PRInt32 aArgsAvailable)
|
||||
{
|
||||
int argc;
|
||||
char *c;
|
||||
char *p; // look ahead
|
||||
PRBool quoted = PR_FALSE;
|
||||
|
||||
aArgs[0] = aArgsString;
|
||||
aArgs[0] = (char *)aArgsString;
|
||||
if (!aArgs[0])
|
||||
return -1;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "nsInstall.h"
|
||||
#include "nsIDOMInstallVersion.h"
|
||||
|
||||
PRInt32 xpi_PrepareProcessArguments(char *aArgsString, char **aArgs, PRInt32 aArgsAvailable);
|
||||
PRInt32 xpi_PrepareProcessArguments(const char *aArgsString, char **aArgs, PRInt32 aArgsAvailable);
|
||||
|
||||
|
||||
class nsInstallExecute : public nsInstallObject
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include "prprf.h"
|
||||
#include "nsInstallFile.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "VerReg.h"
|
||||
#include "ScheduledTasks.h"
|
||||
#include "nsInstall.h"
|
||||
|
@ -185,34 +184,46 @@ nsInstallFile::~nsInstallFile()
|
|||
|
||||
|
||||
|
||||
void nsInstallFile::CreateAllFolders(nsInstall *inInstall, nsIFile *inFolderPath, PRInt32 *error)
|
||||
void nsInstallFile::CreateAllFolders(nsInstall *aInstall, nsIFile *aFolder, PRInt32 *aError)
|
||||
{
|
||||
/* the nsFileSpecMac.cpp operator += requires "this" (the nsFileSpec)
|
||||
* to be an existing dir
|
||||
*/
|
||||
|
||||
nsCOMPtr<nsIFile> nsfsFolderPath;
|
||||
nsString nsStrFolder;
|
||||
PRBool flagExists;
|
||||
int result = 0;
|
||||
nsInstallLogComment *ilc = nsnull;
|
||||
|
||||
inFolderPath->Exists(&flagExists);
|
||||
if(!flagExists)
|
||||
nsresult rv = aFolder->Exists(&flagExists);
|
||||
if (NS_FAILED(rv))
|
||||
*aError = nsInstall::UNEXPECTED_ERROR;
|
||||
else if (flagExists)
|
||||
*aError = nsInstall::SUCCESS;
|
||||
else
|
||||
{
|
||||
inFolderPath->GetParent(getter_AddRefs(nsfsFolderPath));
|
||||
CreateAllFolders(inInstall, nsfsFolderPath, error);
|
||||
// Doesn't exist, work our way up trying to create each node above
|
||||
nsCOMPtr<nsIFile> parent;
|
||||
rv = aFolder->GetParent(getter_AddRefs(parent));
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
// we're already at the top -- give up
|
||||
*aError = nsInstall::ACCESS_DENIED;
|
||||
return;
|
||||
}
|
||||
|
||||
inFolderPath->Create(nsIFile::DIRECTORY_TYPE, 0755); //nsIFileXXX: What kind of permissions are required here?
|
||||
CreateAllFolders(aInstall, parent, aError);
|
||||
if (*aError != nsInstall::SUCCESS)
|
||||
return;
|
||||
|
||||
aFolder->Create(nsIFile::DIRECTORY_TYPE, 0755); //nsIFileXXX: What kind of permissions are required here?
|
||||
++mFolderCreateCount;
|
||||
|
||||
inFolderPath->GetPath(nsStrFolder);
|
||||
ilc = new nsInstallLogComment(inInstall, NS_LITERAL_STRING("CreateFolder"), nsStrFolder, error);
|
||||
nsAutoString folderPath;
|
||||
aFolder->GetPath(folderPath);
|
||||
ilc = new nsInstallLogComment(aInstall,
|
||||
NS_LITERAL_STRING("CreateFolder"),
|
||||
folderPath,
|
||||
aError);
|
||||
if(ilc == nsnull)
|
||||
*error = nsInstall::OUT_OF_MEMORY;
|
||||
*aError = nsInstall::OUT_OF_MEMORY;
|
||||
|
||||
if(*error == nsInstall::SUCCESS)
|
||||
*error = mInstall->ScheduleForInstall(ilc);
|
||||
if(*aError == nsInstall::SUCCESS)
|
||||
*aError = mInstall->ScheduleForInstall(ilc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "nsInstallFileOpItem.h"
|
||||
#include "ScheduledTasks.h"
|
||||
#include "nsProcess.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
#include "nsInstallExecute.h"
|
||||
|
||||
#ifdef _WINDOWS
|
||||
|
@ -80,12 +80,9 @@ nsInstallFileOpItem::nsInstallFileOpItem(nsInstall* aInstallObj,
|
|||
mCommand = aCommand;
|
||||
mFlags = aFlags;
|
||||
mSrc = nsnull;
|
||||
mParams = nsnull;
|
||||
mStrTarget = nsnull;
|
||||
mShortcutPath = nsnull;
|
||||
mDescription = nsnull;
|
||||
mWorkingPath = nsnull;
|
||||
mParams = nsnull;
|
||||
mIcon = nsnull;
|
||||
}
|
||||
|
||||
|
@ -104,13 +101,10 @@ nsInstallFileOpItem::nsInstallFileOpItem(nsInstall* aInstallObj,
|
|||
mIObj = aInstallObj;
|
||||
mCommand = aCommand;
|
||||
mFlags = 0;
|
||||
mParams = nsnull;
|
||||
mStrTarget = nsnull;
|
||||
mAction = ACTION_NONE;
|
||||
mShortcutPath = nsnull;
|
||||
mDescription = nsnull;
|
||||
mWorkingPath = nsnull;
|
||||
mParams = nsnull;
|
||||
mIcon = nsnull;
|
||||
}
|
||||
|
||||
|
@ -128,13 +122,10 @@ nsInstallFileOpItem::nsInstallFileOpItem(nsInstall* aInstallObj,
|
|||
mCommand = aCommand;
|
||||
mFlags = 0;
|
||||
mSrc = nsnull;
|
||||
mParams = nsnull;
|
||||
mStrTarget = nsnull;
|
||||
mAction = ACTION_NONE;
|
||||
mShortcutPath = nsnull;
|
||||
mDescription = nsnull;
|
||||
mWorkingPath = nsnull;
|
||||
mParams = nsnull;
|
||||
mIcon = nsnull;
|
||||
}
|
||||
|
||||
|
@ -154,9 +145,7 @@ nsInstallFileOpItem::nsInstallFileOpItem(nsInstall* aInstallObj,
|
|||
mFlags = 0;
|
||||
mAction = ACTION_NONE;
|
||||
mShortcutPath = nsnull;
|
||||
mDescription = nsnull;
|
||||
mWorkingPath = nsnull;
|
||||
mParams = nsnull;
|
||||
mIcon = nsnull;
|
||||
|
||||
switch(mCommand)
|
||||
|
@ -165,7 +154,6 @@ nsInstallFileOpItem::nsInstallFileOpItem(nsInstall* aInstallObj,
|
|||
case NS_FOP_FILE_RENAME:
|
||||
mSrc = a1;
|
||||
mTarget = nsnull;
|
||||
mParams = nsnull;
|
||||
mStrTarget = new nsString(a2);
|
||||
|
||||
if (mSrc == nsnull || mStrTarget == nsnull)
|
||||
|
@ -177,8 +165,8 @@ nsInstallFileOpItem::nsInstallFileOpItem(nsInstall* aInstallObj,
|
|||
mBlocking = aBlocking;
|
||||
default:
|
||||
mSrc = nsnull;
|
||||
mTarget = a1;
|
||||
mParams = new nsString(a2);
|
||||
mTarget = a1;
|
||||
mParams = a2;
|
||||
mStrTarget = nsnull;
|
||||
|
||||
}
|
||||
|
@ -198,7 +186,9 @@ nsInstallFileOpItem::nsInstallFileOpItem(nsInstall* aInstallObj,
|
|||
mTarget(aTarget),
|
||||
mShortcutPath(aShortcutPath),
|
||||
mWorkingPath(aWorkingPath),
|
||||
mIcon(aIcon)
|
||||
mIcon(aIcon),
|
||||
mDescription(aDescription),
|
||||
mParams(aParams)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsInstallFileOpItem);
|
||||
|
||||
|
@ -210,14 +200,6 @@ nsInstallFileOpItem::nsInstallFileOpItem(nsInstall* aInstallObj,
|
|||
mSrc = nsnull;
|
||||
mStrTarget = nsnull;
|
||||
mAction = ACTION_NONE;
|
||||
|
||||
mDescription = new nsString(aDescription);
|
||||
if(mDescription == nsnull)
|
||||
*aReturn = nsInstall::OUT_OF_MEMORY;
|
||||
|
||||
mParams = new nsString(aParams);
|
||||
if(mParams == nsnull)
|
||||
*aReturn = nsInstall::OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsInstallFileOpItem::~nsInstallFileOpItem()
|
||||
|
@ -228,12 +210,12 @@ nsInstallFileOpItem::~nsInstallFileOpItem()
|
|||
// delete mTarget;
|
||||
if(mStrTarget)
|
||||
delete mStrTarget;
|
||||
if(mParams)
|
||||
delete mParams;
|
||||
//if(mParams)
|
||||
// delete mParams;
|
||||
//if(mShortcutPath)
|
||||
// delete mShortcutPath;
|
||||
if(mDescription)
|
||||
delete mDescription;
|
||||
//if(mDescription)
|
||||
// delete mDescription;
|
||||
//if(mWorkingPath)
|
||||
// delete mWorkingPath;
|
||||
//if(mIcon)
|
||||
|
@ -337,7 +319,7 @@ char* nsInstallFileOpItem::toString()
|
|||
|
||||
mTarget->GetNativePath(dstPath);
|
||||
|
||||
temp = NS_ConvertUCS2toUTF8(*mParams);
|
||||
NS_CopyUnicodeToNative(mParams, temp);
|
||||
if(!temp.IsEmpty())
|
||||
{
|
||||
rsrcVal = mInstall->GetResourcedString(NS_LITERAL_STRING("ExecuteWithArgs"));
|
||||
|
@ -350,7 +332,6 @@ char* nsInstallFileOpItem::toString()
|
|||
if(rsrcVal != nsnull)
|
||||
PR_snprintf(resultCString, RESBUFSIZE, rsrcVal, dstPath.get());
|
||||
}
|
||||
temp.Truncate();
|
||||
break;
|
||||
|
||||
case NS_FOP_FILE_MOVE:
|
||||
|
@ -410,10 +391,12 @@ char* nsInstallFileOpItem::toString()
|
|||
rsrcVal = mInstall->GetResourcedString(NS_LITERAL_STRING("WindowsShortcut"));
|
||||
if(rsrcVal && mShortcutPath)
|
||||
{
|
||||
nsCAutoString description;
|
||||
|
||||
NS_CopyUnicodeToNative(mDescription, description);
|
||||
mShortcutPath->GetNativePath(temp);
|
||||
temp.Append(NS_LITERAL_CSTRING("\\") + NS_LossyConvertUCS2toASCII(*mDescription));
|
||||
temp.Append(NS_LITERAL_CSTRING("\\") + description);
|
||||
PR_snprintf(resultCString, RESBUFSIZE, rsrcVal, temp.get());
|
||||
temp.Truncate();
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -751,10 +734,9 @@ nsInstallFileOpItem::NativeFileOpFileRenameAbort()
|
|||
mSrc->GetParent(getter_AddRefs(parent));
|
||||
if(parent)
|
||||
{
|
||||
newFilename->Append(*mStrTarget);
|
||||
|
||||
mSrc->GetLeafName(leafName);
|
||||
|
||||
newFilename->Append(*mStrTarget);
|
||||
newFilename->MoveTo(parent, leafName);
|
||||
}
|
||||
else
|
||||
|
@ -974,12 +956,9 @@ nsInstallFileOpItem::NativeFileOpFileExecutePrepare()
|
|||
PRInt32
|
||||
nsInstallFileOpItem::NativeFileOpFileExecuteComplete()
|
||||
{
|
||||
//mTarget->Execute(*mParams);
|
||||
//mTarget->Spawn(NS_LossyConvertUCS2toASCII(*mParams).get(), 0);
|
||||
#define ARG_SLOTS 256
|
||||
|
||||
char *cParams[ARG_SLOTS];
|
||||
char *arguments = nsnull;
|
||||
int argcount = 0;
|
||||
|
||||
nsresult rv;
|
||||
|
@ -991,10 +970,12 @@ nsInstallFileOpItem::NativeFileOpFileExecuteComplete()
|
|||
|
||||
nsCOMPtr<nsIProcess> process = do_CreateInstance(kIProcessCID);
|
||||
|
||||
if (mParams && !mParams->IsEmpty())
|
||||
if (!mParams.IsEmpty())
|
||||
{
|
||||
arguments = ToNewCString(*mParams);
|
||||
argcount = xpi_PrepareProcessArguments(arguments, cParams, ARG_SLOTS);
|
||||
nsCAutoString temp;
|
||||
|
||||
NS_CopyUnicodeToNative(mParams, temp);
|
||||
argcount = xpi_PrepareProcessArguments(temp.get(), cParams, ARG_SLOTS);
|
||||
}
|
||||
if (argcount >= 0)
|
||||
{
|
||||
|
@ -1006,9 +987,6 @@ nsInstallFileOpItem::NativeFileOpFileExecuteComplete()
|
|||
else
|
||||
rv = nsInstall::UNEXPECTED_ERROR;
|
||||
|
||||
if(arguments)
|
||||
Recycle(arguments);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -1226,9 +1204,9 @@ nsInstallFileOpItem::NativeFileOpDirRenameAbort()
|
|||
mSrc->Exists(&flagExists);
|
||||
if(!flagExists)
|
||||
{
|
||||
mSrc->GetLeafName(leafName);
|
||||
mSrc->GetParent(getter_AddRefs(newDirName));
|
||||
newDirName->Append(*mStrTarget);
|
||||
mSrc->GetLeafName(leafName);
|
||||
mSrc->GetParent(getter_AddRefs(parent));
|
||||
ret = newDirName->MoveTo(parent, leafName);
|
||||
}
|
||||
|
@ -1282,20 +1260,19 @@ nsInstallFileOpItem::NativeFileOpWindowsShortcutComplete()
|
|||
PRInt32 ret = nsInstall::SUCCESS;
|
||||
|
||||
#ifdef _WINDOWS
|
||||
char *cDescription = nsnull;
|
||||
char *cParams = nsnull;
|
||||
nsresult rv1, rv2;
|
||||
nsCAutoString description;
|
||||
nsCAutoString params;
|
||||
nsCAutoString targetNativePathStr;
|
||||
nsCAutoString shortcutNativePathStr;
|
||||
nsCAutoString workingpathNativePathStr;
|
||||
nsCAutoString iconNativePathStr;
|
||||
|
||||
if(mDescription)
|
||||
cDescription = ToNewCString(*mDescription);
|
||||
if(mParams)
|
||||
cParams = ToNewCString(*mParams);
|
||||
rv1 = NS_CopyUnicodeToNative(mDescription, description);
|
||||
rv2 = NS_CopyUnicodeToNative(mParams, params);
|
||||
|
||||
if((cDescription == nsnull) || (cParams == nsnull))
|
||||
ret = nsInstall::OUT_OF_MEMORY;
|
||||
if(NS_FAILED(rv1) || NS_FAILED(rv2))
|
||||
ret = nsInstall::UNEXPECTED_ERROR;
|
||||
else
|
||||
{
|
||||
if(mTarget)
|
||||
|
@ -1309,19 +1286,14 @@ nsInstallFileOpItem::NativeFileOpWindowsShortcutComplete()
|
|||
|
||||
CreateALink(targetNativePathStr.get(),
|
||||
shortcutNativePathStr.get(),
|
||||
cDescription,
|
||||
description.get(),
|
||||
workingpathNativePathStr.get(),
|
||||
cParams,
|
||||
params.get(),
|
||||
iconNativePathStr.get(),
|
||||
mIconId);
|
||||
|
||||
mAction = nsInstallFileOpItem::ACTION_SUCCESS;
|
||||
}
|
||||
|
||||
if(cDescription)
|
||||
Recycle(cDescription);
|
||||
if(cParams)
|
||||
Recycle(cParams);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
@ -1331,19 +1303,16 @@ PRInt32
|
|||
nsInstallFileOpItem::NativeFileOpWindowsShortcutAbort()
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
nsString shortcutDescription;
|
||||
nsCOMPtr<nsIFile> shortcutTarget;
|
||||
|
||||
if(mShortcutPath && mDescription)
|
||||
if(mShortcutPath)
|
||||
{
|
||||
shortcutDescription = *mDescription;
|
||||
shortcutDescription.Append(NS_LITERAL_STRING(".lnk"));
|
||||
nsCOMPtr<nsIFile> shortcutTarget;
|
||||
nsAutoString shortcutDescription(mDescription + NS_LITERAL_STRING(".lnk"));
|
||||
|
||||
mShortcutPath->Clone(getter_AddRefs(shortcutTarget));
|
||||
shortcutTarget->Append(shortcutDescription);
|
||||
|
||||
NativeFileOpFileDeleteComplete(shortcutTarget);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return nsInstall::SUCCESS;
|
||||
|
|
|
@ -129,9 +129,9 @@ class nsInstallFileOpItem : public nsInstallObject
|
|||
nsCOMPtr<nsIFile> mShortcutPath;
|
||||
nsCOMPtr<nsIFile> mWorkingPath;
|
||||
nsCOMPtr<nsIFile> mIcon;
|
||||
nsString* mDescription;
|
||||
nsString mDescription;
|
||||
nsString* mStrTarget;
|
||||
nsString* mParams;
|
||||
nsString mParams;
|
||||
long mFStat;
|
||||
PRInt32 mFlags;
|
||||
PRInt32 mIconId;
|
||||
|
|
|
@ -31,16 +31,21 @@
|
|||
#include "nsIComponentManager.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsDirectoryService.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include <winbase.h>
|
||||
#include <winreg.h>
|
||||
#endif
|
||||
|
||||
struct DirectoryTable
|
||||
{
|
||||
|
@ -50,59 +55,70 @@ struct DirectoryTable
|
|||
|
||||
struct DirectoryTable DirectoryTable[] =
|
||||
{
|
||||
{"Plugins", 100 },
|
||||
{"Program", 101 },
|
||||
{"Communicator", 101 }, // "Communicator" is deprecated
|
||||
{"Plugins", PLUGIN_DIR },
|
||||
{"Program", PROGRAM_DIR },
|
||||
{"Communicator", PROGRAM_DIR }, // "Communicator" is deprecated
|
||||
|
||||
{"Temporary", 104 },
|
||||
{"Temporary", TEMP_DIR },
|
||||
{"OS Home", OS_HOME_DIR },
|
||||
{"Profile", PROFILE_DIR },
|
||||
{"Current User", PROFILE_DIR }, // "Current User" is deprecated
|
||||
{"Preferences", PREFERENCES_DIR },
|
||||
{"OS Drive", OS_DRIVE },
|
||||
{"file:///", FILE_TARGET },
|
||||
|
||||
{"Profile", 106 },
|
||||
{"Current User", 106 }, // "Current User" is deprecated
|
||||
{"Preferences", 107 },
|
||||
{"OS Drive", 108 },
|
||||
{"file:///", 109 },
|
||||
{"Components", COMPONENTS_DIR },
|
||||
{"Chrome", CHROME_DIR },
|
||||
|
||||
{"Components", 110 },
|
||||
{"Chrome", 111 },
|
||||
{"Win System", WIN_SYS_DIR },
|
||||
{"Windows", WINDOWS_DIR },
|
||||
{"Win Desktop", WIN_DESKTOP_DIR },
|
||||
{"Win Desktop Common", WIN_DESKTOP_COMMON },
|
||||
{"Win StartMenu", WIN_STARTMENU },
|
||||
{"Win StartMenu Common", WIN_STARTMENU_COMMON },
|
||||
{"Win Programs", WIN_PROGRAMS_DIR },
|
||||
{"Win Programs Common", WIN_PROGRAMS_COMMON },
|
||||
{"Win Startup", WIN_STARTUP_DIR },
|
||||
{"Win Startup Common", WIN_STARTUP_COMMON },
|
||||
{"Win AppData", WIN_APPDATA_DIR },
|
||||
{"Win Program Files", WIN_PROGRAM_FILES },
|
||||
{"Win Common Files", WIN_COMMON_FILES },
|
||||
|
||||
{"Win System", 200 },
|
||||
{"Windows", 201 },
|
||||
{"Mac System", MAC_SYSTEM },
|
||||
{"Mac Desktop", MAC_DESKTOP },
|
||||
{"Mac Trash", MAC_TRASH },
|
||||
{"Mac Startup", MAC_STARTUP },
|
||||
{"Mac Shutdown", MAC_SHUTDOWN },
|
||||
{"Mac Apple Menu", MAC_APPLE_MENU },
|
||||
{"Mac Control Panel", MAC_CONTROL_PANEL },
|
||||
{"Mac Extension", MAC_EXTENSION },
|
||||
{"Mac Fonts", MAC_FONTS },
|
||||
{"Mac Preferences", MAC_PREFERENCES },
|
||||
{"Mac Documents", MAC_DOCUMENTS },
|
||||
|
||||
{"Mac System", 300 },
|
||||
{"Mac Desktop", 301 },
|
||||
{"Mac Trash", 302 },
|
||||
{"Mac Startup", 303 },
|
||||
{"Mac Shutdown", 304 },
|
||||
{"Mac Apple Menu", 305 },
|
||||
{"Mac Control Panel", 306 },
|
||||
{"Mac Extension", 307 },
|
||||
{"Mac Fonts", 308 },
|
||||
{"Mac Preferences", 309 },
|
||||
{"Mac Documents", 310 },
|
||||
{"MacOSX Home", MACOSX_HOME },
|
||||
{"MacOSX Default Download", MACOSX_DEFAULT_DOWNLOAD },
|
||||
{"MacOSX User Desktop", MACOSX_USER_DESKTOP },
|
||||
{"MacOSX Local Desktop", MACOSX_LOCAL_DESKTOP },
|
||||
{"MacOSX User Applications", MACOSX_USER_APPLICATIONS },
|
||||
{"MacOSX Local Applications", MACOSX_LOCAL_APPLICATIONS },
|
||||
{"MacOSX User Documents", MACOSX_USER_DOCUMENTS },
|
||||
{"MacOSX Local Documents", MACOSX_LOCAL_DOCUMENTS },
|
||||
{"MacOSX User Internet PlugIn", MACOSX_USER_INTERNET_PLUGIN },
|
||||
{"MacOSX Local Internet PlugIn", MACOSX_LOCAL_INTERNET_PLUGIN },
|
||||
{"MacOSX User Frameworks", MACOSX_USER_FRAMEWORKS },
|
||||
{"MacOSX Local Frameworks", MACOSX_LOCAL_FRAMEWORKS },
|
||||
{"MacOSX User Preferences", MACOSX_USER_PREFERENCES },
|
||||
{"MacOSX Local Preferences", MACOSX_LOCAL_PREFERENCES },
|
||||
{"MacOSX Picture Documents", MACOSX_PICTURE_DOCUMENTS },
|
||||
{"MacOSX Movie Documents", MACOSX_MOVIE_DOCUMENTS },
|
||||
{"MacOSX Music Documents", MACOSX_MUSIC_DOCUMENTS },
|
||||
{"MacOSX Internet Sites", MACOSX_INTERNET_SITES },
|
||||
|
||||
{"MacOSX Home", 500 },
|
||||
{"MacOSX Default Download", 501 },
|
||||
{"MacOSX User Desktop", 502 },
|
||||
{"MacOSX Local Desktop", 503 },
|
||||
{"MacOSX User Applications", 504 },
|
||||
{"MacOSX Local Applications", 505 },
|
||||
{"MacOSX User Documents", 506 },
|
||||
{"MacOSX Local Documents", 507 },
|
||||
{"MacOSX User Internet PlugIn", 508 },
|
||||
{"MacOSX Local Internet PlugIn", 509 },
|
||||
{"MacOSX User Frameworks", 510 },
|
||||
{"MacOSX Local Frameworks", 511 },
|
||||
{"MacOSX User Preferences", 512 },
|
||||
{"MacOSX Local Preferences", 513 },
|
||||
{"MacOSX Picture Documents", 514 },
|
||||
{"MacOSX Movie Documents", 515 },
|
||||
{"MacOSX Music Documents", 516 },
|
||||
{"MacOSX Internet Sites", 517 },
|
||||
{"Unix Local", UNIX_LOCAL },
|
||||
{"Unix Lib", UNIX_LIB },
|
||||
|
||||
{"Unix Local", 400 },
|
||||
{"Unix Lib", 401 },
|
||||
|
||||
{"", -1 }
|
||||
{"", -1 }
|
||||
};
|
||||
|
||||
|
||||
|
@ -114,14 +130,18 @@ nsInstallFolder::nsInstallFolder()
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsInstallFolder::Init(nsIFile* rawIFile)
|
||||
nsInstallFolder::Init(nsIFile* rawIFile, const nsString& aRelativePath)
|
||||
{
|
||||
mFileSpec = rawIFile;
|
||||
|
||||
if (!aRelativePath.IsEmpty())
|
||||
AppendXPPath(aRelativePath);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsInstallFolder::Init(const nsString& aFolderID, const nsString& aRelativePath)
|
||||
nsInstallFolder::Init(const nsAString& aFolderID, const nsString& aRelativePath)
|
||||
{
|
||||
SetDirectoryPath( aFolderID, aRelativePath );
|
||||
|
||||
|
@ -178,100 +198,76 @@ nsInstallFolder::GetDirectoryPath(nsCString& aDirectoryPath)
|
|||
}
|
||||
|
||||
void
|
||||
nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRelativePath)
|
||||
nsInstallFolder::SetDirectoryPath(const nsAString& aFolderID, const nsString& aRelativePath)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// reset mFileSpec in case of error
|
||||
mFileSpec = nsnull;
|
||||
|
||||
switch ( MapNameToEnum(aFolderID) )
|
||||
{
|
||||
case 100: /////////////////////////////////////////////////////////// Plugins
|
||||
if (!nsSoftwareUpdate::GetProgramDirectory())
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID));
|
||||
if (!directoryService)
|
||||
return;
|
||||
|
||||
PRInt32 dirID = MapNameToEnum(aFolderID);
|
||||
switch ( dirID )
|
||||
{
|
||||
case PLUGIN_DIR:
|
||||
if (!nsSoftwareUpdate::GetProgramDirectory())
|
||||
directoryService->Get(NS_APP_PLUGINS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mFileSpec));
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = nsSoftwareUpdate::GetProgramDirectory()->Clone(getter_AddRefs(mFileSpec));
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
mFileSpec->AppendNative(INSTALL_PLUGINS_DIR);
|
||||
}
|
||||
else
|
||||
mFileSpec = nsnull;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 101: /////////////////////////////////////////////////////////// Program
|
||||
case PROGRAM_DIR:
|
||||
if (!nsSoftwareUpdate::GetProgramDirectory()) //Not in stub installer
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OS_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mFileSpec));
|
||||
}
|
||||
else //In stub installer. mProgram has been set so
|
||||
{
|
||||
rv = nsSoftwareUpdate::GetProgramDirectory()->Clone(getter_AddRefs(mFileSpec));
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 104: /////////////////////////////////////////////////////////// Temporary
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
case TEMP_DIR:
|
||||
directoryService->Get(NS_OS_TEMP_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mFileSpec));
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 106: /////////////////////////////////////////////////////////// Current User
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mFileSpec));
|
||||
}
|
||||
break;
|
||||
|
||||
case 107: /////////////////////////////////////////////////////////// Preferences
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
|
||||
case PROFILE_DIR:
|
||||
directoryService->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case OS_HOME_DIR:
|
||||
directoryService->Get(NS_OS_HOME_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case PREFERENCES_DIR:
|
||||
directoryService->Get(NS_APP_PREFS_50_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mFileSpec));
|
||||
}
|
||||
break;
|
||||
|
||||
case 108: /////////////////////////////////////////////////////////// OS Drive
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OS_DRIVE_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case OS_DRIVE:
|
||||
directoryService->Get(NS_OS_DRIVE_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 109: /////////////////////////////////////////////////////////// File URL
|
||||
case FILE_TARGET:
|
||||
{
|
||||
if (!aRelativePath.IsEmpty())
|
||||
{
|
||||
nsFileSpec tmpSpec;
|
||||
nsAutoString tmpPath(aFolderID);
|
||||
nsCAutoString tmpPath("file:///");
|
||||
nsCAutoString nativePath;
|
||||
nsCOMPtr<nsILocalFile> localFile;
|
||||
|
||||
tmpPath += aRelativePath;
|
||||
tmpSpec = nsFileURL(tmpPath);
|
||||
NS_CopyUnicodeToNative(aRelativePath, nativePath);
|
||||
tmpPath.Append(nativePath);
|
||||
tmpSpec = nsFileURL(tmpPath.get());
|
||||
|
||||
rv = NS_FileSpecToIFile( &tmpSpec, getter_AddRefs(localFile) );
|
||||
if (NS_SUCCEEDED(rv))
|
||||
|
@ -289,12 +285,9 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
|
|||
}
|
||||
break;
|
||||
|
||||
case 110: /////////////////////////////////////////////////////////// Components
|
||||
case COMPONENTS_DIR:
|
||||
if (!nsSoftwareUpdate::GetProgramDirectory())
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_XPCOM_COMPONENT_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
|
@ -304,401 +297,311 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
|
|||
rv = nsSoftwareUpdate::GetProgramDirectory()->Clone(getter_AddRefs(mFileSpec));
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
mFileSpec->AppendNative(INSTALL_COMPONENTS_DIR);
|
||||
}
|
||||
else
|
||||
mFileSpec = nsnull;
|
||||
mFileSpec = nsnull;
|
||||
}
|
||||
break;
|
||||
|
||||
case 111: /////////////////////////////////////////////////////////// Chrome
|
||||
case CHROME_DIR:
|
||||
if (!nsSoftwareUpdate::GetProgramDirectory())
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_APP_CHROME_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = nsSoftwareUpdate::GetProgramDirectory()->Clone(getter_AddRefs(mFileSpec));
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
mFileSpec->AppendNative(INSTALL_CHROME_DIR);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
#if defined(XP_WIN)
|
||||
case 200: /////////////////////////////////////////////////////////// Win System
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OS_SYSTEM_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
case WIN_SYS_DIR:
|
||||
directoryService->Get(NS_OS_SYSTEM_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 201: /////////////////////////////////////////////////////////// Windows
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_WIN_WINDOWS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
break;
|
||||
|
||||
case WINDOWS_DIR:
|
||||
directoryService->Get(NS_WIN_WINDOWS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case WIN_DESKTOP_DIR:
|
||||
directoryService->Get( NS_WIN_DESKTOP_DIRECTORY,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec) );
|
||||
break;
|
||||
|
||||
case WIN_DESKTOP_COMMON:
|
||||
directoryService->Get( NS_WIN_COMMON_DESKTOP_DIRECTORY,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec) );
|
||||
break;
|
||||
|
||||
case WIN_STARTMENU:
|
||||
directoryService->Get( NS_WIN_STARTMENU_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec) );
|
||||
break;
|
||||
|
||||
case WIN_STARTMENU_COMMON:
|
||||
directoryService->Get( NS_WIN_COMMON_STARTMENU_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec) );
|
||||
break;
|
||||
|
||||
case WIN_PROGRAMS_DIR:
|
||||
directoryService->Get( NS_WIN_PROGRAMS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec) );
|
||||
break;
|
||||
|
||||
case WIN_PROGRAMS_COMMON:
|
||||
directoryService->Get( NS_WIN_COMMON_PROGRAMS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec) );
|
||||
break;
|
||||
|
||||
case WIN_STARTUP_DIR:
|
||||
directoryService->Get( NS_WIN_STARTUP_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec) );
|
||||
break;
|
||||
|
||||
case WIN_STARTUP_COMMON:
|
||||
directoryService->Get( NS_WIN_COMMON_STARTUP_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec) );
|
||||
break;
|
||||
|
||||
case WIN_APPDATA_DIR:
|
||||
directoryService->Get( NS_WIN_APPDATA_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec) );
|
||||
break;
|
||||
|
||||
case WIN_PROGRAM_FILES:
|
||||
case WIN_COMMON_FILES:
|
||||
{
|
||||
HKEY key;
|
||||
LONG result = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
|
||||
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion",
|
||||
0, KEY_QUERY_VALUE, &key );
|
||||
|
||||
if ( result != ERROR_SUCCESS )
|
||||
break;
|
||||
|
||||
BYTE path[_MAX_PATH + 1] = { 0 };
|
||||
DWORD type;
|
||||
DWORD pathlen = sizeof(path);
|
||||
char *value = (dirID==WIN_PROGRAM_FILES) ?
|
||||
"ProgramFilesDir" :
|
||||
"CommonFilesDir";
|
||||
result = RegQueryValueEx( key, value, 0, &type, path, &pathlen );
|
||||
if ( result == ERROR_SUCCESS && type == REG_SZ )
|
||||
{
|
||||
nsCOMPtr<nsILocalFile> tmp;
|
||||
NS_NewNativeLocalFile( nsDependentCString((char*)path),
|
||||
PR_FALSE, getter_AddRefs(tmp) );
|
||||
mFileSpec = do_QueryInterface(tmp);
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined (XP_MACOSX)
|
||||
case 300: /////////////////////////////////////////////////////////// Mac System
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OS_SYSTEM_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MAC_SYSTEM:
|
||||
directoryService->Get(NS_OS_SYSTEM_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 301: /////////////////////////////////////////////////////////// Mac Desktop
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_MAC_DESKTOP_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MAC_DESKTOP:
|
||||
directoryService->Get(NS_MAC_DESKTOP_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 302: /////////////////////////////////////////////////////////// Mac Trash
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_MAC_TRASH_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MAC_TRASH:
|
||||
directoryService->Get(NS_MAC_TRASH_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 303: /////////////////////////////////////////////////////////// Mac Startup
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_MAC_STARTUP_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MAC_STARTUP:
|
||||
directoryService->Get(NS_MAC_STARTUP_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 304: /////////////////////////////////////////////////////////// Mac Shutdown
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_MAC_SHUTDOWN_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MAC_SHUTDOWN:
|
||||
directoryService->Get(NS_MAC_SHUTDOWN_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 305: /////////////////////////////////////////////////////////// Mac Apple Menu
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_MAC_APPLE_MENU_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MAC_APPLE_MENU:
|
||||
directoryService->Get(NS_MAC_APPLE_MENU_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 306: /////////////////////////////////////////////////////////// Mac Control Panel
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_MAC_CONTROL_PANELS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MAC_CONTROL_PANEL:
|
||||
directoryService->Get(NS_MAC_CONTROL_PANELS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 307: /////////////////////////////////////////////////////////// Mac Extension
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_MAC_EXTENSIONS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MAC_EXTENSION:
|
||||
directoryService->Get(NS_MAC_EXTENSIONS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 308: /////////////////////////////////////////////////////////// Mac Fonts
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_MAC_FONTS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MAC_FONTS:
|
||||
directoryService->Get(NS_MAC_FONTS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 309: /////////////////////////////////////////////////////////// Mac Preferences
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_MAC_PREFS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MAC_PREFERENCES:
|
||||
directoryService->Get(NS_MAC_PREFS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 310: /////////////////////////////////////////////////////////// Mac Documents
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_MAC_DOCUMENTS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MAC_DOCUMENTS:
|
||||
directoryService->Get(NS_MAC_DOCUMENTS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 500: /////////////////////////////////////////////////////////// MacOSX Home
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_HOME_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MACOSX_HOME:
|
||||
directoryService->Get(NS_OSX_HOME_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 501: /////////////////////////////////////////////////////////// MacOSX Default Download
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_DEFAULT_DOWNLOAD_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MACOSX_DEFAULT_DOWNLOAD:
|
||||
directoryService->Get(NS_OSX_DEFAULT_DOWNLOAD_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 502: /////////////////////////////////////////////////////////// MacOSX User Desktop
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_USER_DESKTOP_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MACOSX_USER_DESKTOP:
|
||||
directoryService->Get(NS_OSX_USER_DESKTOP_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 503: /////////////////////////////////////////////////////////// MacOSX Local Desktop
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_LOCAL_DESKTOP_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MACOSX_LOCAL_DESKTOP:
|
||||
directoryService->Get(NS_OSX_LOCAL_DESKTOP_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 504: /////////////////////////////////////////////////////////// MacOSX User Applications
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_USER_APPLICATIONS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MACOSX_USER_APPLICATIONS:
|
||||
directoryService->Get(NS_OSX_USER_APPLICATIONS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 505: /////////////////////////////////////////////////////////// MacOSX Local Applications
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_LOCAL_APPLICATIONS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MACOSX_LOCAL_APPLICATIONS:
|
||||
directoryService->Get(NS_OSX_LOCAL_APPLICATIONS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 506: /////////////////////////////////////////////////////////// MacOSX User Documents
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_USER_DOCUMENTS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MACOSX_USER_DOCUMENTS:
|
||||
directoryService->Get(NS_OSX_USER_DOCUMENTS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 507: /////////////////////////////////////////////////////////// MacOSX Local Documents
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_LOCAL_DOCUMENTS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MACOSX_LOCAL_DOCUMENTS:
|
||||
directoryService->Get(NS_OSX_LOCAL_DOCUMENTS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 508: /////////////////////////////////////////////////////////// MacOSX User Internet PlugIn
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_USER_INTERNET_PLUGIN_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MACOSX_USER_INTERNET_PLUGIN:
|
||||
directoryService->Get(NS_OSX_USER_INTERNET_PLUGIN_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 509: /////////////////////////////////////////////////////////// MacOSX Local Internet PlugIn
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_LOCAL_INTERNET_PLUGIN_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MACOSX_LOCAL_INTERNET_PLUGIN:
|
||||
directoryService->Get(NS_OSX_LOCAL_INTERNET_PLUGIN_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 510: /////////////////////////////////////////////////////////// MacOSX User Frameworks
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_USER_FRAMEWORKS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MACOSX_USER_FRAMEWORKS:
|
||||
directoryService->Get(NS_OSX_USER_FRAMEWORKS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 511: /////////////////////////////////////////////////////////// MacOSX Local Frameworks
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_LOCAL_FRAMEWORKS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MACOSX_LOCAL_FRAMEWORKS:
|
||||
directoryService->Get(NS_OSX_LOCAL_FRAMEWORKS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 512: /////////////////////////////////////////////////////////// MacOSX User Preferences
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_USER_PREFERENCES_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MACOSX_USER_PREFERENCES:
|
||||
directoryService->Get(NS_OSX_USER_PREFERENCES_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 513: /////////////////////////////////////////////////////////// MacOSX Local Preferences
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_LOCAL_PREFERENCES_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MACOSX_LOCAL_PREFERENCES:
|
||||
directoryService->Get(NS_OSX_LOCAL_PREFERENCES_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 514: /////////////////////////////////////////////////////////// MacOSX Picture Documents
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_PICTURE_DOCUMENTS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MACOSX_PICTURE_DOCUMENTS:
|
||||
directoryService->Get(NS_OSX_PICTURE_DOCUMENTS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 515: /////////////////////////////////////////////////////////// MacOSX Movie Documents
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_MOVIE_DOCUMENTS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MACOSX_MOVIE_DOCUMENTS:
|
||||
directoryService->Get(NS_OSX_MOVIE_DOCUMENTS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 516: /////////////////////////////////////////////////////////// MacOSX Music Documents
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_MUSIC_DOCUMENTS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case MACOSX_MUSIC_DOCUMENTS:
|
||||
directoryService->Get(NS_OSX_MUSIC_DOCUMENTS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
case 517: /////////////////////////////////////////////////////////// MacOSX Internet Sites
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_OSX_INTERNET_SITES_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
|
||||
case MACOSX_INTERNET_SITES:
|
||||
directoryService->Get(NS_OSX_INTERNET_SITES_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
case 400: /////////////////////////////////////////////////////////// Unix Local
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_UNIX_LOCAL_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case UNIX_LOCAL:
|
||||
directoryService->Get(NS_UNIX_LOCAL_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
|
||||
case 401: /////////////////////////////////////////////////////////// Unix Lib
|
||||
{
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return;
|
||||
directoryService->Get(NS_UNIX_LIB_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
}
|
||||
case UNIX_LIB:
|
||||
directoryService->Get(NS_UNIX_LIB_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mFileSpec));
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
@ -758,18 +661,17 @@ nsInstallFolder::AppendXPPath(const nsString& aRelativePath)
|
|||
/* MapNameToEnum
|
||||
* maps name from the directory table to its enum */
|
||||
PRInt32
|
||||
nsInstallFolder::MapNameToEnum(const nsString& name)
|
||||
nsInstallFolder::MapNameToEnum(const nsAString& name)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if ( name.IsEmpty())
|
||||
return -1;
|
||||
|
||||
// safe because all strings in DirectoryTable are ASCII
|
||||
NS_LossyConvertUCS2toASCII asciiName(name);
|
||||
while ( DirectoryTable[i].directoryName[0] != 0 )
|
||||
{
|
||||
if ( asciiName.EqualsIgnoreCase(DirectoryTable[i].directoryName) )
|
||||
// safe compare because all strings in DirectoryTable are ASCII
|
||||
if ( name.Equals(NS_ConvertASCIItoUCS2(DirectoryTable[i].directoryName), nsCaseInsensitiveStringComparator()) )
|
||||
return DirectoryTable[i].folderEnum;
|
||||
i++;
|
||||
}
|
||||
|
@ -800,9 +702,21 @@ nsInstallFolder::ToString(nsAutoString* outString)
|
|||
|
||||
nsresult rv = mFileSpec->GetPath(*outString);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
{
|
||||
// converters not present, most likely in wizard case;
|
||||
// do best we can with stock ASCII conversion
|
||||
|
||||
PRBool flagIsFile;
|
||||
// Since bug 100676 was fixed we should never get here
|
||||
|
||||
// XXX NOTE we can make sure our filenames are ASCII, but we have no
|
||||
// control over the directory name which might be localized!!!
|
||||
NS_ASSERTION(PR_FALSE, "Couldn't get Unicode path, using broken conversion!");
|
||||
nsCAutoString temp;
|
||||
rv = mFileSpec->GetNativePath(temp);
|
||||
outString->Assign(NS_ConvertASCIItoUCS2(temp));
|
||||
}
|
||||
|
||||
PRBool flagIsFile = PR_FALSE;
|
||||
mFileSpec->IsFile(&flagIsFile);
|
||||
if (!flagIsFile)
|
||||
{
|
||||
|
|
|
@ -31,8 +31,67 @@
|
|||
#include "prtypes.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
|
||||
#define PLUGIN_DIR 100
|
||||
#define PROGRAM_DIR 101
|
||||
|
||||
#define TEMP_DIR 104
|
||||
#define OS_HOME_DIR 105
|
||||
#define PROFILE_DIR 106
|
||||
#define PREFERENCES_DIR 107
|
||||
#define OS_DRIVE 108
|
||||
#define FILE_TARGET 109
|
||||
|
||||
#define COMPONENTS_DIR 110
|
||||
#define CHROME_DIR 111
|
||||
|
||||
#define WIN_SYS_DIR 200
|
||||
#define WINDOWS_DIR 201
|
||||
#define WIN_DESKTOP_DIR 202
|
||||
#define WIN_DESKTOP_COMMON 203
|
||||
#define WIN_STARTMENU 204
|
||||
#define WIN_STARTMENU_COMMON 205
|
||||
#define WIN_PROGRAMS_DIR 206
|
||||
#define WIN_PROGRAMS_COMMON 207
|
||||
#define WIN_STARTUP_DIR 208
|
||||
#define WIN_STARTUP_COMMON 209
|
||||
#define WIN_APPDATA_DIR 210
|
||||
#define WIN_PROGRAM_FILES 211
|
||||
#define WIN_COMMON_FILES 212
|
||||
|
||||
#define MAC_SYSTEM 300
|
||||
#define MAC_DESKTOP 301
|
||||
#define MAC_TRASH 302
|
||||
#define MAC_STARTUP 303
|
||||
#define MAC_SHUTDOWN 304
|
||||
#define MAC_APPLE_MENU 305
|
||||
#define MAC_CONTROL_PANEL 306
|
||||
#define MAC_EXTENSION 307
|
||||
#define MAC_FONTS 308
|
||||
#define MAC_PREFERENCES 309
|
||||
#define MAC_DOCUMENTS 310
|
||||
|
||||
#define MACOSX_HOME 500
|
||||
#define MACOSX_DEFAULT_DOWNLOAD 501
|
||||
#define MACOSX_USER_DESKTOP 502
|
||||
#define MACOSX_LOCAL_DESKTOP 503
|
||||
#define MACOSX_USER_APPLICATIONS 504
|
||||
#define MACOSX_LOCAL_APPLICATIONS 505
|
||||
#define MACOSX_USER_DOCUMENTS 506
|
||||
#define MACOSX_LOCAL_DOCUMENTS 507
|
||||
#define MACOSX_USER_INTERNET_PLUGIN 508
|
||||
#define MACOSX_LOCAL_INTERNET_PLUGIN 509
|
||||
#define MACOSX_USER_FRAMEWORKS 510
|
||||
#define MACOSX_LOCAL_FRAMEWORKS 511
|
||||
#define MACOSX_USER_PREFERENCES 512
|
||||
#define MACOSX_LOCAL_PREFERENCES 513
|
||||
#define MACOSX_PICTURE_DOCUMENTS 514
|
||||
#define MACOSX_MOVIE_DOCUMENTS 515
|
||||
#define MACOSX_MUSIC_DOCUMENTS 516
|
||||
#define MACOSX_INTERNET_SITES 517
|
||||
|
||||
#define UNIX_LOCAL 400
|
||||
#define UNIX_LIB 401
|
||||
|
||||
#ifdef XP_MAC
|
||||
#define INSTALL_PLUGINS_DIR NS_LITERAL_CSTRING("Plug-ins")
|
||||
|
@ -52,8 +111,8 @@ class nsInstallFolder
|
|||
virtual ~nsInstallFolder();
|
||||
|
||||
nsresult Init(nsInstallFolder& inFolder, const nsString& subString);
|
||||
nsresult Init(const nsString& aFolderID, const nsString& aRelativePath);
|
||||
nsresult Init(nsIFile* rawIFile);
|
||||
nsresult Init(const nsAString& aFolderID, const nsString& aRelativePath);
|
||||
nsresult Init(nsIFile* rawIFile, const nsString& aRelativePath);
|
||||
|
||||
void GetDirectoryPath(nsCString& aDirectoryPath);
|
||||
nsIFile* GetFileSpec();
|
||||
|
@ -63,9 +122,9 @@ class nsInstallFolder
|
|||
|
||||
nsCOMPtr<nsIFile> mFileSpec;
|
||||
|
||||
void SetDirectoryPath(const nsString& aFolderID, const nsString& aRelativePath);
|
||||
void SetDirectoryPath(const nsAString& aFolderID, const nsString& aRelativePath);
|
||||
void AppendXPPath(const nsString& aRelativePath);
|
||||
PRInt32 MapNameToEnum(const nsString& name);
|
||||
PRInt32 MapNameToEnum(const nsAString& name);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -24,11 +24,9 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "nsCRT.h"
|
||||
#include "prmem.h"
|
||||
#include "prprf.h"
|
||||
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
#include "VerReg.h"
|
||||
#include "ScheduledTasks.h"
|
||||
#include "nsInstallLogComment.h"
|
||||
|
@ -36,7 +34,7 @@
|
|||
|
||||
#include "nsInstall.h"
|
||||
#include "nsIDOMInstallVersion.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(nsInstallLogComment)
|
||||
|
||||
|
@ -49,6 +47,7 @@ nsInstallLogComment::nsInstallLogComment( nsInstall* inInstall,
|
|||
{
|
||||
MOZ_COUNT_CTOR(nsInstallLogComment);
|
||||
|
||||
*error = nsInstall::SUCCESS;
|
||||
if (inInstall == NULL)
|
||||
{
|
||||
*error = nsInstall::INVALID_ARGUMENTS;
|
||||
|
@ -90,25 +89,15 @@ char* nsInstallLogComment::toString()
|
|||
if (buffer == nsnull || !mInstall)
|
||||
return nsnull;
|
||||
|
||||
char* cstrFileOpCommand = ToNewCString(mFileOpCommand);
|
||||
char* cstrComment = ToNewCString(mComment);
|
||||
|
||||
if((cstrFileOpCommand == nsnull) || (cstrComment == nsnull))
|
||||
return nsnull;
|
||||
|
||||
rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2(cstrFileOpCommand));
|
||||
rsrcVal = mInstall->GetResourcedString(mFileOpCommand);
|
||||
if (rsrcVal)
|
||||
{
|
||||
PR_snprintf(buffer, 1024, rsrcVal, cstrComment);
|
||||
nsCAutoString comment;
|
||||
if ( NS_SUCCEEDED( NS_CopyUnicodeToNative(mComment, comment) ) )
|
||||
PR_snprintf(buffer, 1024, rsrcVal, comment.get());
|
||||
nsCRT::free(rsrcVal);
|
||||
}
|
||||
|
||||
if (cstrFileOpCommand)
|
||||
Recycle(cstrFileOpCommand);
|
||||
|
||||
if (cstrComment)
|
||||
Recycle(cstrComment);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "zlib.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsCRT.h"
|
||||
#include "prmem.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsInstall.h"
|
||||
|
@ -44,6 +44,7 @@
|
|||
#include "nsInstallResources.h"
|
||||
#include "nsIDOMInstallVersion.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
|
||||
#include "gdiff.h"
|
||||
|
||||
|
@ -105,7 +106,6 @@ nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
|
|||
*error = nsInstall::NO_SUCH_COMPONENT;
|
||||
return;
|
||||
}
|
||||
nsString folderSpec; folderSpec.AssignWithConversion(tempTargetFile);
|
||||
|
||||
nsCOMPtr<nsILocalFile> tmp;
|
||||
NS_NewNativeLocalFile(nsDependentCString(tempTargetFile), PR_TRUE, getter_AddRefs(tmp));
|
||||
|
@ -323,7 +323,7 @@ PRInt32 nsInstallPatch::Complete()
|
|||
nsCAutoString tempPath;
|
||||
mTargetFile->GetNativePath(tempPath);
|
||||
|
||||
// DO NOT propagate version registry errors, it will abort
|
||||
// DO NOT propogate version registry errors, it will abort
|
||||
// FinalizeInstall() leaving things hosed. These piddly errors
|
||||
// aren't worth that.
|
||||
VR_Install( NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(*mRegistryName).get()),
|
||||
|
@ -450,33 +450,39 @@ nsInstallPatch::NativePatch(nsIFile *sourceFile, nsIFile *patchFile, nsIFile **n
|
|||
if (( dd->bWin32BoundImage || dd->bMacAppleSingle) && (status == GDIFF_OK ))
|
||||
{
|
||||
// make an unique tmp file (FILENAME-src.EXT)
|
||||
nsAutoString tmpFileName;
|
||||
rv = sourceFile->GetLeafName(tmpFileName);
|
||||
nsAutoString leafName;
|
||||
rv = sourceFile->GetLeafName(leafName);
|
||||
|
||||
NS_NAMED_LITERAL_STRING(tmpName, "-src");
|
||||
|
||||
PRInt32 i;
|
||||
if ((i = tmpFileName.RFindChar('.')) > 0)
|
||||
if ((i = leafName.RFindChar('.')) > 0)
|
||||
{
|
||||
// build the temp filename for which to unbind the file to.
|
||||
// eg: if the filename is bind.dll, the temp src filename would
|
||||
// be bind-src.dll
|
||||
nsAutoString ext;
|
||||
nsAutoString fName;
|
||||
tmpFileName.Right(ext, (tmpFileName.Length() - i) );
|
||||
tmpFileName.Left(fName, (tmpFileName.Length() - (tmpFileName.Length() - i)));
|
||||
tmpFileName.Assign(fName + tmpName + ext);
|
||||
|
||||
// get the extension
|
||||
leafName.Right(ext, (leafName.Length() - i) );
|
||||
// get the filename - extension
|
||||
leafName.Left(fName, (leafName.Length() - (leafName.Length() - i)));
|
||||
// build the temp filename with '-src' at the end of filename,
|
||||
// but before extension
|
||||
leafName.Assign(fName);
|
||||
leafName.Append(tmpName);
|
||||
leafName.Append(ext);
|
||||
} else {
|
||||
tmpFileName += tmpName;
|
||||
// no extension found, just append '-src' to the end of filename
|
||||
leafName.Append(tmpName);
|
||||
}
|
||||
|
||||
|
||||
rv = sourceFile->Clone(getter_AddRefs(tempSrcFile)); //Clone the sourceFile
|
||||
tempSrcFile->SetLeafName(tmpFileName); //Append the new leafname
|
||||
tempSrcFile->SetLeafName(leafName); //Append the new leafname
|
||||
uniqueSrcFile = do_QueryInterface(tempSrcFile, &rv);
|
||||
uniqueSrcFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0644);
|
||||
|
||||
nsCAutoString realfile;
|
||||
sourceFile->GetNativePath(realfile);
|
||||
|
||||
#ifdef WIN32
|
||||
// unbind Win32 images
|
||||
|
||||
|
@ -485,7 +491,8 @@ nsInstallPatch::NativePatch(nsIFile *sourceFile, nsIFile *patchFile, nsIFile **n
|
|||
|
||||
if (su_unbind((char*)realfile.get(), (char*)unboundFile.get())) //
|
||||
{
|
||||
realfile = unboundFile;
|
||||
// un-binding worked, save the tmp name for later
|
||||
uniqueSrcFile->GetNativePath(realfile);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -590,7 +597,6 @@ nsInstallPatch::NativePatch(nsIFile *sourceFile, nsIFile *patchFile, nsIFile **n
|
|||
PR_Close( dd->fOut );
|
||||
dd->fOut = NULL;
|
||||
|
||||
|
||||
FSSpec outSpec;
|
||||
FSSpec anotherSpec;
|
||||
nsCOMPtr<nsILocalFileMac> outSpecMacSpecific;
|
||||
|
@ -619,15 +625,12 @@ nsInstallPatch::NativePatch(nsIFile *sourceFile, nsIFile *patchFile, nsIFile **n
|
|||
nsCOMPtr<nsIFile> parent;
|
||||
|
||||
outFileSpec->GetParent(getter_AddRefs(parent));
|
||||
|
||||
outFileSpec->Remove(PR_FALSE);
|
||||
|
||||
nsAutoString leaf;
|
||||
anotherName->GetLeafName(leaf);
|
||||
anotherName->CopyTo(parent, leaf);
|
||||
|
||||
anotherName->Clone(newFile);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
#include "nsInstallUninstall.h"
|
||||
#include "nsInstallResources.h"
|
||||
#include "VerReg.h"
|
||||
#include "nsCRT.h"
|
||||
#include "prmem.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "ScheduledTasks.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsILocalFile.h"
|
||||
|
@ -55,7 +55,7 @@ nsInstallUninstall::nsInstallUninstall( nsInstall* inInstall,
|
|||
mRegName.Assign(regName);
|
||||
|
||||
char* userName = (char*)PR_Malloc(MAXREGPATHLEN);
|
||||
PRInt32 err = VR_GetUninstallUserName( NS_CONST_CAST(char*, NS_LossyConvertUCS2toASCII(regName).get()),
|
||||
PRInt32 err = VR_GetUninstallUserName( NS_CONST_CAST(char*, NS_ConvertUCS2toUTF8(regName).get()),
|
||||
userName,
|
||||
MAXREGPATHLEN );
|
||||
|
||||
|
@ -89,7 +89,7 @@ PRInt32 nsInstallUninstall::Complete()
|
|||
if (mInstall == NULL)
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
|
||||
err = SU_Uninstall( NS_CONST_CAST(char*, NS_LossyConvertUCS2toASCII(mRegName).get()) );
|
||||
err = SU_Uninstall( NS_CONST_CAST(char*, NS_ConvertUCS2toUTF8(mRegName).get()) );
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -173,14 +173,16 @@ InstallFileOpDirGetParent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
JSObject *fileSpecObject;
|
||||
|
||||
fileSpecObject = JS_NewObject(cx, &FileSpecObjectClass, gFileSpecProto, NULL);
|
||||
if (fileSpecObject == NULL)
|
||||
return JS_FALSE;
|
||||
|
||||
JS_SetPrivate(cx, fileSpecObject, parentFolder);
|
||||
if (fileSpecObject == NULL)
|
||||
return JS_FALSE;
|
||||
if (fileSpecObject)
|
||||
{
|
||||
JS_SetPrivate(cx, fileSpecObject, parentFolder);
|
||||
|
||||
*rval = OBJECT_TO_JSVAL(fileSpecObject);
|
||||
if (fileSpecObject)
|
||||
{
|
||||
*rval = OBJECT_TO_JSVAL(fileSpecObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
|
|
@ -66,7 +66,7 @@ fso_ToString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
}
|
||||
|
||||
if(NS_FAILED( nativeThis->ToString(&stringReturned)))
|
||||
return JS_FALSE;
|
||||
return JS_TRUE;
|
||||
|
||||
|
||||
JSString *jsstring =
|
||||
|
|
|
@ -119,7 +119,7 @@ GetInstallProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
nsInstallFolder* folder = new nsInstallFolder();
|
||||
if ( folder )
|
||||
{
|
||||
folder->Init(a->GetJarFileLocation());
|
||||
folder->Init(a->GetJarFileLocation(),nsString());
|
||||
JSObject* fileSpecObject =
|
||||
JS_NewObject(cx, &FileSpecObjectClass, gFileSpecProto, NULL);
|
||||
|
||||
|
@ -333,7 +333,7 @@ PR_STATIC_CALLBACK(JSBool)
|
|||
InstallAbortInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
|
||||
PRInt32 b0;
|
||||
int32 b0;
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
|
||||
|
@ -345,35 +345,19 @@ InstallAbortInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
if(argc >= 1)
|
||||
{
|
||||
// public int AbortInstall(Number aErrorNumber);
|
||||
if(JSVAL_IS_NUMBER(argv[0]))
|
||||
if(JS_ValueToInt32(cx, argv[0], &b0))
|
||||
{
|
||||
b0 = JSVAL_TO_INT(argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->AbortInstall(b0))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
nativeThis->AbortInstall(b0);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
}
|
||||
else if(argc == 0)
|
||||
{
|
||||
// public int AbortInstall(void);
|
||||
|
||||
if(NS_OK != nativeThis->AbortInstall(nsInstall::INSTALL_CANCELLED))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "Function AbortInstall requires 0 or 1 parameter");
|
||||
return JS_FALSE;
|
||||
nativeThis->AbortInstall(nsInstall::INSTALL_CANCELLED);
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
@ -410,18 +394,16 @@ InstallAddDirectory(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->AddDirectory(b0, &nativeRet))
|
||||
if(NS_OK == nativeThis->AddDirectory(b0, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else if (argc == 4)
|
||||
{
|
||||
// public int AddDirectory ( String registryName,
|
||||
// String jarSourcePath,
|
||||
// String localDirSpec,
|
||||
// Object localDirSpec,
|
||||
// String relativeLocalPath);
|
||||
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
@ -444,12 +426,10 @@ InstallAddDirectory(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
|
||||
folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);
|
||||
|
||||
if(NS_OK != nativeThis->AddDirectory(b0, b1, folder, b3, &nativeRet))
|
||||
if(NS_OK == nativeThis->AddDirectory(b0, b1, folder, b3, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else if (argc == 5)
|
||||
{
|
||||
|
@ -483,13 +463,10 @@ InstallAddDirectory(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
|
||||
if(NS_OK != nativeThis->AddDirectory(b0, b1, b2, folder, b4, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
|
||||
}
|
||||
else if (argc == 6)
|
||||
else if (argc >= 6)
|
||||
{
|
||||
// public int AddDirectory ( String registryName,
|
||||
// String version, --OR-- VersionInfo version,
|
||||
|
@ -525,17 +502,14 @@ InstallAddDirectory(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
|
||||
folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);
|
||||
|
||||
if(NS_OK != nativeThis->AddDirectory(b0, b1, b2, folder, b4, flags, &nativeRet))
|
||||
if(NS_OK == nativeThis->AddDirectory(b0, b1, b2, folder, b4, flags, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "Install.AddDirectory() parameters error");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
@ -607,10 +581,9 @@ InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
saveDepth = JS_SuspendRequest(cx);//Need to suspend use of thread or deadlock occurs
|
||||
rv= nativeThis->AddSubcomponent(b0, b1, b2, folder, b4, flags, &nativeRet);
|
||||
JS_ResumeRequest(cx, saveDepth);
|
||||
if (NS_FAILED(rv))
|
||||
return JS_FALSE;
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else if(argc >= 5)
|
||||
{
|
||||
|
@ -647,10 +620,9 @@ InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
saveDepth = JS_SuspendRequest(cx);//Need to suspend use of thread or deadlock occurs
|
||||
rv = nativeThis->AddSubcomponent(b0, b1, b2, folder, b4, &nativeRet);
|
||||
JS_ResumeRequest(cx, saveDepth);
|
||||
if (NS_FAILED(rv))
|
||||
return JS_FALSE;
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else if(argc >= 4)
|
||||
{
|
||||
|
@ -680,12 +652,10 @@ InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
|
||||
folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);
|
||||
|
||||
if(NS_OK != nativeThis->AddSubcomponent(b0, b1, folder, b3, &nativeRet))
|
||||
if(NS_OK == nativeThis->AddSubcomponent(b0, b1, folder, b3, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else if(argc >= 1)
|
||||
{
|
||||
|
@ -693,17 +663,14 @@ InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->AddSubcomponent(b0, &nativeRet))
|
||||
if(NS_OK == nativeThis->AddSubcomponent(b0, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "Function AddSubcomponent requires 6 parameters");
|
||||
return JS_FALSE;
|
||||
JS_ReportError(cx, "Install.addFile parameter error");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
@ -748,7 +715,7 @@ InstallDiskSpaceAvailable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
|
||||
if(NS_OK != nativeThis->DiskSpaceAvailable(b0, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
double d;
|
||||
|
@ -760,7 +727,6 @@ InstallDiskSpaceAvailable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
else
|
||||
{
|
||||
JS_ReportError(cx, "Function DiskSpaceAvailable requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
@ -825,8 +791,7 @@ InstallExecute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
|
|||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "Function Execute requires 1 parameter");
|
||||
return JS_FALSE;
|
||||
JS_ReportWarning(cx, "Function Execute requires 1 parameter");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
|
|
@ -93,7 +93,7 @@ WinProfileGetString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
|
||||
if(argc >= 2)
|
||||
{
|
||||
// public int getString ( String section,
|
||||
// public string getString ( String section,
|
||||
// String key);
|
||||
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
@ -105,8 +105,7 @@ WinProfileGetString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "WinProfile.getString() parameters error");
|
||||
return JS_FALSE;
|
||||
JS_ReportWarning(cx, "WinProfile.getString() parameters error");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
@ -124,7 +123,7 @@ WinProfileWriteString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
|
|||
nsAutoString b1;
|
||||
nsAutoString b2;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
*rval = JSVAL_ZERO;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if(nsnull == nativeThis)
|
||||
|
@ -142,17 +141,14 @@ WinProfileWriteString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
|
|||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b2, cx, argv[2]);
|
||||
|
||||
if(NS_OK != nativeThis->WriteString(b0, b1, b2, &nativeRet))
|
||||
if(NS_OK == nativeThis->WriteString(b0, b1, b2, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "WinProfile.writeString() parameters error");
|
||||
return JS_FALSE;
|
||||
JS_ReportWarning(cx, "WinProfile.writeString() parameters error");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
|
|
@ -81,7 +81,6 @@ PR_STATIC_CALLBACK(JSBool)
|
|||
WinRegSetRootKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsWinReg *nativeThis = (nsWinReg*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
PRInt32 b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
@ -94,25 +93,19 @@ WinRegSetRootKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
|||
|
||||
if(argc >= 1)
|
||||
{
|
||||
// public int setRootKey(PRInt32 key);
|
||||
|
||||
if(!JS_ValueToInt32(cx, argv[0], (int32 *)&b0))
|
||||
// public void setRootKey(PRInt32 key);
|
||||
if(JS_ValueToInt32(cx, argv[0], (int32 *)&b0))
|
||||
{
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
nativeThis->SetRootKey(b0);
|
||||
}
|
||||
|
||||
if(NS_OK != nativeThis->SetRootKey(b0))
|
||||
else
|
||||
{
|
||||
return JS_FALSE;
|
||||
JS_ReportWarning(cx, "Parameter must be a number");
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "Function SetRootKey requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
JS_ReportWarning(cx, "Function SetRootKey requires 1 parameters");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
@ -126,7 +119,7 @@ PR_STATIC_CALLBACK(JSBool)
|
|||
WinRegKeyExists(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsWinReg *nativeThis = (nsWinReg*)JS_GetPrivate(cx, obj);
|
||||
PRInt32 nativeRet;
|
||||
PRBool nativeRet;
|
||||
nsAutoString b0;
|
||||
|
||||
*rval = JSVAL_FALSE;
|
||||
|
@ -139,20 +132,22 @@ WinRegKeyExists(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rv
|
|||
|
||||
if(argc >= 1)
|
||||
{
|
||||
// public int keyExists ( String subKey );
|
||||
// public boolean keyExists ( String subKey );
|
||||
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->KeyExists(b0, &nativeRet))
|
||||
if(NS_OK == nativeThis->KeyExists(b0, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
*rval = BOOLEAN_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_WARNING("WinReg.KeyExists() internal error");
|
||||
}
|
||||
|
||||
*rval = BOOLEAN_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "WinReg.KeyExists() parameters error");
|
||||
JS_ReportWarning(cx, "WinReg.KeyExists() parameters error");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
@ -165,7 +160,7 @@ PR_STATIC_CALLBACK(JSBool)
|
|||
WinRegValueExists(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsWinReg *nativeThis = (nsWinReg*)JS_GetPrivate(cx, obj);
|
||||
PRInt32 nativeRet;
|
||||
PRBool nativeRet;
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
|
||||
|
@ -179,22 +174,20 @@ WinRegValueExists(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
|||
|
||||
if(argc >= 2)
|
||||
{
|
||||
// public int valueExists ( String subKey,
|
||||
// public boolean valueExists ( String subKey,
|
||||
// String value );
|
||||
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(NS_OK != nativeThis->ValueExists(b0, b1, &nativeRet))
|
||||
if(NS_OK == nativeThis->ValueExists(b0, b1, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
*rval = BOOLEAN_TO_JSVAL(nativeRet);
|
||||
}
|
||||
|
||||
*rval = BOOLEAN_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "WinReg.ValueExists() parameters error");
|
||||
JS_ReportWarning(cx, "WinReg.ValueExists() parameters error");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
@ -220,20 +213,18 @@ WinRegIsKeyWritable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
|
||||
if(argc >= 1)
|
||||
{
|
||||
// public int isKeyWritable ( String subKey );
|
||||
// public boolean isKeyWritable ( String subKey );
|
||||
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->IsKeyWritable(b0, &nativeRet))
|
||||
if(NS_OK == nativeThis->IsKeyWritable(b0, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
*rval = BOOLEAN_TO_JSVAL(nativeRet);
|
||||
}
|
||||
|
||||
*rval = BOOLEAN_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "WinReg.IsKeyWritable() parameters error");
|
||||
JS_ReportWarning(cx, "WinReg.IsKeyWritable() parameters error");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
@ -250,7 +241,7 @@ WinRegCreateKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rv
|
|||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
*rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if(nsnull == nativeThis)
|
||||
|
@ -266,17 +257,14 @@ WinRegCreateKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rv
|
|||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(NS_OK != nativeThis->CreateKey(b0, b1, &nativeRet))
|
||||
if(NS_OK == nativeThis->CreateKey(b0, b1, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "WinReg.CreateKey() parameters error");
|
||||
return JS_FALSE;
|
||||
JS_ReportWarning(cx, "WinReg.CreateKey() parameters error");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
@ -292,7 +280,7 @@ WinRegDeleteKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rv
|
|||
PRInt32 nativeRet;
|
||||
nsAutoString b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
*rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if(nsnull == nativeThis)
|
||||
|
@ -306,17 +294,14 @@ WinRegDeleteKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rv
|
|||
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
|
||||
if(NS_OK != nativeThis->DeleteKey(b0, &nativeRet))
|
||||
if(NS_OK == nativeThis->DeleteKey(b0, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "WinReg.DeleteKey() parameters error");
|
||||
return JS_FALSE;
|
||||
JS_ReportWarning(cx, "WinReg.DeleteKey() parameters error");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
@ -334,7 +319,7 @@ WinRegDeleteValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
|||
nsString b0;
|
||||
nsString b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
*rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if(nsnull == nativeThis)
|
||||
|
@ -350,17 +335,14 @@ WinRegDeleteValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
|||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(NS_OK != nativeThis->DeleteValue(b0, b1, &nativeRet))
|
||||
if(NS_OK == nativeThis->DeleteValue(b0, b1, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "WinReg.DeleteValue() parameters error");
|
||||
return JS_FALSE;
|
||||
JS_ReportWarning(cx, "WinReg.DeleteValue() parameters error");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
@ -378,7 +360,7 @@ WinRegSetValueString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
|||
nsAutoString b1;
|
||||
nsAutoString b2;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
*rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if(nsnull == nativeThis)
|
||||
|
@ -396,17 +378,14 @@ WinRegSetValueString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
|||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
ConvertJSValToStr(b2, cx, argv[2]);
|
||||
|
||||
if(NS_OK != nativeThis->SetValueString(b0, b1, b2, &nativeRet))
|
||||
if(NS_OK == nativeThis->SetValueString(b0, b1, b2, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "WinReg.SetValueString() parameters error");
|
||||
return JS_FALSE;
|
||||
JS_ReportWarning(cx, "WinReg.SetValueString() parameters error");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
@ -433,23 +412,20 @@ WinRegGetValueString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
|||
|
||||
if(argc >= 2)
|
||||
{
|
||||
// public int getValueString ( String subKey,
|
||||
// public string getValueString ( String subKey,
|
||||
// String valueName);
|
||||
|
||||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(NS_OK != nativeThis->GetValueString(b0, b1, &nativeRet))
|
||||
if(NS_OK == nativeThis->GetValueString(b0, b1, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
ConvertStrToJSVal(nativeRet, cx, rval);
|
||||
}
|
||||
|
||||
ConvertStrToJSVal(nativeRet, cx, rval);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "WinReg.GetValueString() parameters error");
|
||||
return JS_FALSE;
|
||||
JS_ReportWarning(cx, "WinReg.GetValueString() parameters error");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
@ -559,9 +535,9 @@ WinRegSetValueNumber(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
|||
PRInt32 nativeRet;
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
PRInt32 ib2;
|
||||
int32 ib2;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
*rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if(nsnull == nativeThis)
|
||||
|
@ -578,27 +554,18 @@ WinRegSetValueNumber(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
|||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(JSVAL_IS_INT(argv[2]))
|
||||
if(!JS_ValueToInt32(cx, argv[2], &ib2))
|
||||
{
|
||||
ib2 = JSVAL_TO_INT(argv[2]);
|
||||
JS_ReportWarning(cx, "Parameter 3 must be a number");
|
||||
}
|
||||
else
|
||||
else if(NS_OK == nativeThis->SetValueNumber(b0, b1, ib2, &nativeRet))
|
||||
{
|
||||
JS_ReportError(cx, "Parameter 3 must be a number");
|
||||
return JS_FALSE;
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
|
||||
if(NS_OK != nativeThis->SetValueNumber(b0, b1, ib2, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "WinReg.SetValueNumber() parameters error");
|
||||
return JS_FALSE;
|
||||
JS_ReportWarning(cx, "WinReg.SetValueNumber() parameters error");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
@ -631,17 +598,14 @@ WinRegGetValueNumber(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
|||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(NS_OK != nativeThis->GetValueNumber(b0, b1, &nativeRet))
|
||||
if(NS_OK == nativeThis->GetValueNumber(b0, b1, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "WinReg.GetValueNumber() parameters error");
|
||||
return JS_FALSE;
|
||||
JS_ReportWarning(cx, "WinReg.GetValueNumber() parameters error");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
@ -654,12 +618,10 @@ PR_STATIC_CALLBACK(JSBool)
|
|||
WinRegSetValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsWinReg *nativeThis = (nsWinReg*)JS_GetPrivate(cx, obj);
|
||||
// PRInt32 nativeRet;
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
// nsWinRegItem *b2;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
*rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if(nsnull == nativeThis)
|
||||
|
@ -689,8 +651,7 @@ WinRegSetValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
|
|||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "WinReg.SetValue() parameters error");
|
||||
return JS_FALSE;
|
||||
JS_ReportWarning(cx, "WinReg.SetValue() parameters error");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
@ -723,17 +684,14 @@ WinRegGetValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
|
|||
ConvertJSValToStr(b0, cx, argv[0]);
|
||||
ConvertJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(NS_OK != nativeThis->GetValue(b0, b1, &nativeRet))
|
||||
if(NS_OK == nativeThis->GetValue(b0, b1, &nativeRet))
|
||||
{
|
||||
return JS_FALSE;
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "WinReg.GetValue() parameters error");
|
||||
return JS_FALSE;
|
||||
JS_ReportWarning(cx, "WinReg.GetValue() parameters error");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
|
||||
#include "nspr.h"
|
||||
|
||||
|
@ -229,20 +230,28 @@ nsLoggingProgressListener::OnInstallDone(const PRUnichar *aURL, PRInt32 aStatus)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoggingProgressListener::OnPackageNameSet(const PRUnichar *URL, const PRUnichar* UIPackageName)
|
||||
nsLoggingProgressListener::OnPackageNameSet(const PRUnichar *URL, const PRUnichar* UIPackageName, const PRUnichar* aVersion)
|
||||
{
|
||||
if (mLogStream == nsnull) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// char* time;
|
||||
// GetTime(&time);
|
||||
|
||||
nsCString name; name.AssignWithConversion(UIPackageName);
|
||||
nsCString name;
|
||||
nsCString version;
|
||||
nsCString uline;
|
||||
|
||||
nsAutoString autostrName(UIPackageName);
|
||||
nsAutoString autostrVersion(aVersion);
|
||||
|
||||
NS_CopyUnicodeToNative(autostrName, name);
|
||||
NS_CopyUnicodeToNative(autostrVersion, version);
|
||||
|
||||
uline.SetCapacity(name.Length());
|
||||
for ( unsigned int i=0; i < name.Length(); ++i)
|
||||
uline.Append('-');
|
||||
|
||||
*mLogStream << " " << name.get() << nsEndl;
|
||||
*mLogStream << " " << name.get() << " (version " << version.get() << ")" << nsEndl;
|
||||
*mLogStream << " " << uline.get() << nsEndl;
|
||||
|
||||
*mLogStream << nsEndl;
|
||||
|
|
|
@ -56,7 +56,6 @@
|
|||
#include "nsLoggingProgressNotifier.h"
|
||||
|
||||
#include "nsBuildID.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsProcess.h"
|
||||
|
||||
/* For Javascript Namespace Access */
|
||||
|
|
|
@ -32,9 +32,7 @@
|
|||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsProxiedService.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
@ -190,11 +188,6 @@ XPInstallErrorReporter(JSContext *cx, const char *message, JSErrorReport *report
|
|||
}
|
||||
}
|
||||
|
||||
if (!report)
|
||||
return;
|
||||
|
||||
nsIXPIListener *listener;
|
||||
|
||||
// lets set up an eventQ so that our xpcom/proxies will not have to:
|
||||
nsCOMPtr<nsISoftwareUpdate> softwareUpdate =
|
||||
do_GetService(kSoftwareUpdateCID, &rv);
|
||||
|
@ -205,18 +198,24 @@ XPInstallErrorReporter(JSContext *cx, const char *message, JSErrorReport *report
|
|||
return;
|
||||
}
|
||||
|
||||
softwareUpdate->GetMasterListener(&listener);
|
||||
nsCOMPtr<nsIXPIListener> listener;
|
||||
softwareUpdate->GetMasterListener(getter_AddRefs(listener));
|
||||
|
||||
if(listener)
|
||||
{
|
||||
nsAutoString logMessage;
|
||||
logMessage.Assign(NS_LITERAL_STRING("Line: "));
|
||||
logMessage.AppendInt(report->lineno, 10);
|
||||
logMessage.Append(NS_LITERAL_STRING("\t"));
|
||||
if (report->ucmessage)
|
||||
logMessage.Append( NS_REINTERPRET_CAST(const PRUnichar*, report->ucmessage) );
|
||||
if (report)
|
||||
{
|
||||
logMessage.Assign(NS_LITERAL_STRING("Line: "));
|
||||
logMessage.AppendInt(report->lineno, 10);
|
||||
logMessage.Append(NS_LITERAL_STRING("\t"));
|
||||
if (report->ucmessage)
|
||||
logMessage.Append( NS_REINTERPRET_CAST(const PRUnichar*, report->ucmessage) );
|
||||
else
|
||||
logMessage.AppendWithConversion( message );
|
||||
}
|
||||
else
|
||||
logMessage.AppendWithConversion( message );
|
||||
logMessage.AssignWithConversion( message );
|
||||
|
||||
listener->OnLogComment( logMessage.get() );
|
||||
}
|
||||
|
@ -247,7 +246,6 @@ GetInstallScriptFromJarfile(nsIZipReader* hZip, nsIFile* jarFile, nsIPrincipal*
|
|||
|
||||
nsIFile* jFile;
|
||||
nsresult rv =jarFile->Clone(&jFile);
|
||||
//NS_NewLocalFile(jarFile, PR_TRUE, getter_AddRefs(jFile));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = hZip->Init(jFile);
|
||||
|
||||
|
@ -273,17 +271,9 @@ GetInstallScriptFromJarfile(nsIZipReader* hZip, nsIFile* jarFile, nsIPrincipal*
|
|||
return nsInstall::INVALID_SIGNATURE;
|
||||
}
|
||||
|
||||
// Extract the install.js file to the temporary directory
|
||||
nsSpecialSystemDirectory installJSFileSpec(nsSpecialSystemDirectory::OS_TemporaryDirectory);
|
||||
installJSFileSpec += "install.js";
|
||||
installJSFileSpec.MakeUnique();
|
||||
|
||||
// Extract the install.js file.
|
||||
nsCOMPtr<nsILocalFile> iFile;
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(installJSFileSpec), PR_TRUE, getter_AddRefs(iFile));
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = hZip->Extract("install.js", iFile);
|
||||
nsCOMPtr<nsIInputStream> instream;
|
||||
rv = hZip->GetInputStream("install.js", getter_AddRefs(instream));
|
||||
if ( NS_SUCCEEDED(rv) )
|
||||
{
|
||||
// Read it into a buffer
|
||||
|
@ -292,12 +282,9 @@ GetInstallScriptFromJarfile(nsIZipReader* hZip, nsIFile* jarFile, nsIPrincipal*
|
|||
PRUint32 readLength;
|
||||
result = nsInstall::CANT_READ_ARCHIVE;
|
||||
|
||||
nsInputFileStream fileStream(installJSFileSpec);
|
||||
nsCOMPtr<nsIInputStream> instream = fileStream.GetIStream();
|
||||
|
||||
if ( instream )
|
||||
rv = instream->Available(&bufferLength);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
instream->Available(&bufferLength);
|
||||
buffer = new char[bufferLength + 1];
|
||||
|
||||
if (buffer != nsnull)
|
||||
|
@ -315,11 +302,8 @@ GetInstallScriptFromJarfile(nsIZipReader* hZip, nsIFile* jarFile, nsIPrincipal*
|
|||
delete [] buffer;
|
||||
}
|
||||
}
|
||||
|
||||
fileStream.close();
|
||||
}
|
||||
|
||||
installJSFileSpec.Delete(PR_FALSE);
|
||||
instream->Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -108,10 +108,10 @@ nsTopProgressListener::OnInstallStart(const PRUnichar *URL)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTopProgressListener::OnPackageNameSet(const PRUnichar *URL, const PRUnichar* UIPackageName)
|
||||
nsTopProgressListener::OnPackageNameSet(const PRUnichar *URL, const PRUnichar* UIPackageName, const PRUnichar* aVersion)
|
||||
{
|
||||
if (mActive)
|
||||
mActive->OnPackageNameSet(URL, UIPackageName);
|
||||
mActive->OnPackageNameSet(URL, UIPackageName, aVersion);
|
||||
|
||||
if (mListeners)
|
||||
{
|
||||
|
@ -120,7 +120,7 @@ nsTopProgressListener::OnPackageNameSet(const PRUnichar *URL, const PRUnichar* U
|
|||
{
|
||||
nsIXPIListener* element = (nsIXPIListener*)mListeners->ElementAt(i);
|
||||
if (element != NULL)
|
||||
element->OnPackageNameSet(URL, UIPackageName);
|
||||
element->OnPackageNameSet(URL, UIPackageName, aVersion);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
|
|
|
@ -539,7 +539,7 @@ nsXPINotifierImpl::OnEndLoad(nsIRDFXMLSink *aSink)
|
|||
nsMemory::Free(regkeyCString);
|
||||
|
||||
// check to see if this software title should be "flashed"
|
||||
if (IsNewerOrUninstalled(NS_LossyConvertUCS2toASCII(regKeyString).get(), NS_LossyConvertUCS2toASCII(versionString).get()))
|
||||
if (IsNewerOrUninstalled(NS_ConvertUCS2toUTF8(regKeyString).get(), NS_ConvertUCS2toUTF8(versionString).get()))
|
||||
{
|
||||
//assert into flash
|
||||
|
||||
|
|
|
@ -35,41 +35,34 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsWinReg.h"
|
||||
#include "nsWinProfile.h"
|
||||
#include "nsWinProfileItem.h"
|
||||
#include "nspr.h"
|
||||
#include <windows.h>
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
|
||||
/* Public Methods */
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(nsWinProfile)
|
||||
|
||||
nsWinProfile::nsWinProfile( nsInstall* suObj, const nsString& folder, const nsString& file )
|
||||
: mFilename(folder)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsWinProfile);
|
||||
|
||||
mFilename = new nsString(folder);
|
||||
|
||||
if (mFilename)
|
||||
if(mFilename.Last() != '\\')
|
||||
{
|
||||
if(mFilename->Last() != '\\')
|
||||
{
|
||||
mFilename->Append(NS_LITERAL_STRING("\\"));
|
||||
}
|
||||
mFilename->Append(file);
|
||||
mFilename.Append(NS_LITERAL_STRING("\\"));
|
||||
}
|
||||
mFilename.Append(file);
|
||||
|
||||
mInstallObject = suObj;
|
||||
}
|
||||
}
|
||||
|
||||
nsWinProfile::~nsWinProfile()
|
||||
{
|
||||
if (mFilename)
|
||||
delete mFilename;
|
||||
|
||||
MOZ_COUNT_DTOR(nsWinProfile);
|
||||
|
||||
}
|
||||
|
||||
PRInt32
|
||||
|
@ -106,7 +99,7 @@ nsWinProfile::WriteString(nsString section, nsString key, nsString value, PRInt3
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsString* nsWinProfile::GetFilename()
|
||||
nsString& nsWinProfile::GetFilename()
|
||||
{
|
||||
return mFilename;
|
||||
}
|
||||
|
@ -128,56 +121,56 @@ nsWinProfile::FinalWriteString( nsString section, nsString key, nsString value )
|
|||
#define STRBUFLEN 255
|
||||
|
||||
PRInt32
|
||||
nsWinProfile::NativeGetString(nsString section, nsString key, nsString* aReturn )
|
||||
nsWinProfile::NativeGetString(nsString aSection, nsString aKey, nsString* aReturn )
|
||||
{
|
||||
int numChars;
|
||||
int numChars = 0;
|
||||
char valbuf[STRBUFLEN];
|
||||
char* sectionCString;
|
||||
char* keyCString;
|
||||
char* filenameCString;
|
||||
|
||||
/* make sure conversions worked */
|
||||
if(section.First() != '\0' && key.First() != '\0' && mFilename->First() != '\0')
|
||||
if(aSection.First() != '\0' && aKey.First() != '\0' && mFilename.First() != '\0')
|
||||
{
|
||||
sectionCString = ToNewCString(section);
|
||||
keyCString = ToNewCString(key);
|
||||
filenameCString = ToNewCString(*mFilename);
|
||||
nsCAutoString section;
|
||||
nsCAutoString key;
|
||||
nsCAutoString filename;
|
||||
|
||||
numChars = GetPrivateProfileString(sectionCString, keyCString, "", valbuf, STRBUFLEN, filenameCString);
|
||||
if(NS_FAILED(NS_CopyUnicodeToNative(aSection, section)) ||
|
||||
NS_FAILED(NS_CopyUnicodeToNative(aKey, key)) ||
|
||||
NS_FAILED(NS_CopyUnicodeToNative(mFilename, filename)))
|
||||
return 0;
|
||||
|
||||
aReturn->AssignWithConversion(valbuf);
|
||||
valbuf[0] = 0;
|
||||
numChars = GetPrivateProfileString( section.get(), key.get(), "", valbuf,
|
||||
STRBUFLEN, filename.get());
|
||||
|
||||
if (sectionCString) Recycle(sectionCString);
|
||||
if (keyCString) Recycle(keyCString);
|
||||
if (filenameCString) Recycle(filenameCString);
|
||||
nsCAutoString cStrValue(valbuf);
|
||||
nsAutoString value;
|
||||
if(NS_SUCCEEDED(NS_CopyNativeToUnicode(cStrValue, value)))
|
||||
aReturn->Assign(value);
|
||||
}
|
||||
|
||||
return numChars;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsWinProfile::NativeWriteString( nsString section, nsString key, nsString value )
|
||||
nsWinProfile::NativeWriteString( nsString aSection, nsString aKey, nsString aValue )
|
||||
{
|
||||
char* sectionCString;
|
||||
char* keyCString;
|
||||
char* valueCString;
|
||||
char* filenameCString;
|
||||
int success = 0;
|
||||
|
||||
/* make sure conversions worked */
|
||||
if(section.First() != '\0' && key.First() != '\0' && mFilename->First() != '\0')
|
||||
if(aSection.First() != '\0' && aKey.First() != '\0' && mFilename.First() != '\0')
|
||||
{
|
||||
sectionCString = ToNewCString(section);
|
||||
keyCString = ToNewCString(key);
|
||||
valueCString = ToNewCString(value);
|
||||
filenameCString = ToNewCString(*mFilename);
|
||||
nsCAutoString section;
|
||||
nsCAutoString key;
|
||||
nsCAutoString value;
|
||||
nsCAutoString filename;
|
||||
|
||||
success = WritePrivateProfileString( sectionCString, keyCString, valueCString, filenameCString );
|
||||
if(NS_FAILED(NS_CopyUnicodeToNative(aSection, section)) ||
|
||||
NS_FAILED(NS_CopyUnicodeToNative(aKey, key)) ||
|
||||
NS_FAILED(NS_CopyUnicodeToNative(aValue, value)) ||
|
||||
NS_FAILED(NS_CopyUnicodeToNative(mFilename, filename)))
|
||||
return 0;
|
||||
|
||||
if (sectionCString) Recycle(sectionCString);
|
||||
if (keyCString) Recycle(keyCString);
|
||||
if (valueCString) Recycle(valueCString);
|
||||
if (filenameCString) Recycle(filenameCString);
|
||||
success = WritePrivateProfileString( section.get(), key.get(), value.get(), filename.get() );
|
||||
}
|
||||
|
||||
return success;
|
||||
|
|
|
@ -71,7 +71,7 @@ class nsWinProfile
|
|||
*/
|
||||
PRInt32 GetString( nsString section, nsString key, nsString* aReturn );
|
||||
|
||||
nsString* GetFilename();
|
||||
nsString& GetFilename();
|
||||
nsInstall* InstallObject();
|
||||
|
||||
PRInt32 FinalWriteString( nsString section, nsString key, nsString value );
|
||||
|
@ -80,7 +80,7 @@ class nsWinProfile
|
|||
private:
|
||||
|
||||
/* Private Fields */
|
||||
nsString* mFilename;
|
||||
nsString mFilename;
|
||||
nsInstall* mInstallObject;
|
||||
|
||||
/* Private Methods */
|
||||
|
|
|
@ -88,7 +88,7 @@ char* nsWinProfileItem::toString()
|
|||
{
|
||||
char* resultCString;
|
||||
|
||||
nsString* filename = new nsString(*mProfile->GetFilename());
|
||||
nsString* filename = new nsString(mProfile->GetFilename());
|
||||
nsString* result = new nsString;
|
||||
result->Assign(NS_LITERAL_STRING("Write "));
|
||||
|
||||
|
|
|
@ -37,8 +37,9 @@
|
|||
|
||||
#include "nsWinReg.h"
|
||||
#include "nsWinRegItem.h"
|
||||
#include <windows.h> /* is this needed? */
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
/* Public Methods */
|
||||
|
||||
|
@ -171,8 +172,7 @@ nsWinReg::SetValueString(const nsAString& subkey, const nsAString& valname, cons
|
|||
PRInt32
|
||||
nsWinReg::GetValueString(const nsString& subkey, const nsString& valname, nsString* aReturn)
|
||||
{
|
||||
NativeGetValueString(subkey, valname, aReturn);
|
||||
return NS_OK;
|
||||
return NativeGetValueString(subkey, valname, aReturn);
|
||||
}
|
||||
|
||||
PRInt32
|
||||
|
@ -183,30 +183,26 @@ nsWinReg::EnumValueNames(const nsString& aSubkey, PRInt32 aIndex, nsString &aRet
|
|||
HKEY newkey;
|
||||
LONG result;
|
||||
DWORD namesize = sizeof(namebuf);
|
||||
char subkeyCString[MAX_BUF];
|
||||
WCHAR returnBuf[MAX_BUF];
|
||||
PRInt32 rv = NS_ERROR_FAILURE;
|
||||
PRInt32 rv = nsInstall::UNEXPECTED_ERROR;
|
||||
|
||||
subkeyCString[0] = 0;
|
||||
returnBuf[0] = 0;
|
||||
namebuf[0] = 0;
|
||||
|
||||
::WideCharToMultiByte(CP_ACP, 0,
|
||||
aSubkey.get(), -1,
|
||||
subkeyCString, sizeof subkeyCString, NULL, NULL);
|
||||
nsCAutoString subkey;
|
||||
if ( NS_FAILED ( NS_CopyUnicodeToNative(aSubkey, subkey) ) )
|
||||
return nsInstall::UNEXPECTED_ERROR;
|
||||
|
||||
root = (HKEY) mRootKey;
|
||||
result = RegOpenKeyEx( root, subkeyCString, 0, KEY_READ, &newkey );
|
||||
result = RegOpenKeyEx( root, subkey.get(), 0, KEY_READ, &newkey );
|
||||
|
||||
if ( ERROR_SUCCESS == result ) {
|
||||
result = RegEnumValue( newkey, aIndex, namebuf, &namesize, nsnull, 0, 0, 0 );
|
||||
RegCloseKey( newkey );
|
||||
|
||||
if ( ERROR_SUCCESS == result ) {
|
||||
if ( ::MultiByteToWideChar(CP_ACP, 0, namebuf, -1, returnBuf, MAX_BUF) )
|
||||
nsCAutoString cstrName(namebuf);
|
||||
nsAutoString name;
|
||||
if(NS_SUCCEEDED(NS_CopyNativeToUnicode(cstrName, name)))
|
||||
{
|
||||
aReturn.Assign(returnBuf);
|
||||
rv = NS_OK;
|
||||
aReturn.Assign(name);
|
||||
rv = nsInstall::SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -222,30 +218,26 @@ nsWinReg::EnumKeys(const nsString& aSubkey, PRInt32 aIndex, nsString &aReturn)
|
|||
HKEY newkey;
|
||||
LONG result;
|
||||
DWORD type = REG_SZ;
|
||||
char subkeyCString[MAX_BUF];
|
||||
WCHAR returnBuf[MAX_BUF];
|
||||
PRInt32 rv = NS_ERROR_FAILURE;
|
||||
PRInt32 rv = nsInstall::UNEXPECTED_ERROR;
|
||||
|
||||
subkeyCString[0] = 0;
|
||||
returnBuf[0] = 0;
|
||||
keybuf[0] = 0;
|
||||
|
||||
::WideCharToMultiByte(CP_ACP, 0,
|
||||
aSubkey.get(), -1,
|
||||
subkeyCString, sizeof subkeyCString, NULL, NULL);
|
||||
nsCAutoString subkey;
|
||||
if ( NS_FAILED(NS_CopyUnicodeToNative(aSubkey, subkey) ) )
|
||||
return nsInstall::UNEXPECTED_ERROR;
|
||||
|
||||
root = (HKEY) mRootKey;
|
||||
result = RegOpenKeyEx( root, subkeyCString, 0, KEY_READ, &newkey );
|
||||
result = RegOpenKeyEx( root, subkey.get(), 0, KEY_READ, &newkey );
|
||||
|
||||
if ( ERROR_SUCCESS == result ) {
|
||||
result = RegEnumKey( newkey, aIndex, keybuf, sizeof keybuf );
|
||||
RegCloseKey( newkey );
|
||||
|
||||
if ( ERROR_SUCCESS == result ) {
|
||||
if ( ::MultiByteToWideChar(CP_ACP, 0, keybuf, -1, returnBuf, MAX_BUF) )
|
||||
nsCAutoString cstrKey(keybuf);
|
||||
nsAutoString key;
|
||||
if (NS_SUCCEEDED(NS_CopyNativeToUnicode(cstrKey, key) ) )
|
||||
{
|
||||
aReturn.Assign(returnBuf);
|
||||
rv = NS_OK;
|
||||
aReturn.Assign(key);
|
||||
rv = nsInstall::SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -282,8 +274,7 @@ nsWinReg::SetValueNumber(const nsString& subkey, const nsString& valname, PRInt3
|
|||
PRInt32
|
||||
nsWinReg::GetValueNumber(const nsString& subkey, const nsString& valname, PRInt32* aReturn)
|
||||
{
|
||||
NativeGetValueNumber(subkey, valname, aReturn);
|
||||
return NS_OK;
|
||||
return NativeGetValueNumber(subkey, valname, aReturn);
|
||||
}
|
||||
|
||||
PRInt32
|
||||
|
@ -315,7 +306,7 @@ nsInstall* nsWinReg::InstallObject()
|
|||
|
||||
PRInt32
|
||||
nsWinReg::KeyExists(const nsString& subkey,
|
||||
PRInt32* aReturn)
|
||||
PRBool* aReturn)
|
||||
{
|
||||
*aReturn = NativeKeyExists(subkey);
|
||||
return NS_OK;
|
||||
|
@ -324,7 +315,7 @@ nsWinReg::KeyExists(const nsString& subkey,
|
|||
PRInt32
|
||||
nsWinReg::ValueExists(const nsString& subkey,
|
||||
const nsString& valname,
|
||||
PRInt32* aReturn)
|
||||
PRBool* aReturn)
|
||||
{
|
||||
*aReturn = NativeValueExists(subkey, valname);
|
||||
return NS_OK;
|
||||
|
@ -332,7 +323,7 @@ nsWinReg::ValueExists(const nsString& subkey,
|
|||
|
||||
PRInt32
|
||||
nsWinReg::IsKeyWritable(const nsString& subkey,
|
||||
PRInt32* aReturn)
|
||||
PRBool* aReturn)
|
||||
{
|
||||
*aReturn = NativeIsKeyWritable(subkey);
|
||||
return NS_OK;
|
||||
|
@ -489,17 +480,21 @@ nsWinReg::FinalSetValue(PRInt32 root, const nsString& subkey, const nsString& va
|
|||
|
||||
/* Private Methods */
|
||||
|
||||
PRInt32
|
||||
nsWinReg::NativeKeyExists(const nsString& subkey)
|
||||
PRBool
|
||||
nsWinReg::NativeKeyExists(const nsString& aSubkey)
|
||||
{
|
||||
HKEY root, newkey;
|
||||
LONG result;
|
||||
PRInt32 keyExists = PR_FALSE;
|
||||
char* subkeyCString = ToNewCString(subkey);
|
||||
PRBool keyExists = PR_FALSE;
|
||||
|
||||
#ifdef WIN32
|
||||
nsCAutoString subkey;
|
||||
|
||||
if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) )
|
||||
return PR_FALSE;
|
||||
|
||||
root = (HKEY)mRootKey;
|
||||
result = RegOpenKeyEx(root, subkeyCString, 0, KEY_READ, &newkey);
|
||||
result = RegOpenKeyEx(root, subkey.get(), 0, KEY_READ, &newkey);
|
||||
switch(result)
|
||||
{
|
||||
case ERROR_SUCCESS:
|
||||
|
@ -514,31 +509,34 @@ nsWinReg::NativeKeyExists(const nsString& subkey)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (subkeyCString) Recycle(subkeyCString);
|
||||
|
||||
return keyExists;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsWinReg::NativeValueExists(const nsString& subkey, const nsString& valname)
|
||||
PRBool
|
||||
nsWinReg::NativeValueExists(const nsString& aSubkey, const nsString& aValname)
|
||||
{
|
||||
HKEY root;
|
||||
HKEY newkey;
|
||||
LONG result;
|
||||
PRInt32 valueExists = PR_FALSE;
|
||||
PRBool valueExists = PR_FALSE;
|
||||
DWORD length = _MAXKEYVALUE_;
|
||||
unsigned char valbuf[_MAXKEYVALUE_];
|
||||
char* subkeyCString = ToNewCString(subkey);
|
||||
char* valnameCString = ToNewCString(valname);
|
||||
|
||||
#ifdef WIN32
|
||||
nsCAutoString subkey;
|
||||
nsCAutoString valname;
|
||||
|
||||
if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
|
||||
NS_FAILED( NS_CopyUnicodeToNative(aValname, valname) ) )
|
||||
return PR_FALSE;
|
||||
|
||||
root = (HKEY) mRootKey;
|
||||
result = RegOpenKeyEx(root, subkeyCString, 0, KEY_READ, &newkey);
|
||||
result = RegOpenKeyEx(root, subkey.get(), 0, KEY_READ, &newkey);
|
||||
switch(result)
|
||||
{
|
||||
case ERROR_SUCCESS:
|
||||
result = RegQueryValueEx(newkey,
|
||||
valnameCString,
|
||||
valname.get(),
|
||||
0,
|
||||
NULL,
|
||||
valbuf,
|
||||
|
@ -564,20 +562,16 @@ nsWinReg::NativeValueExists(const nsString& subkey, const nsString& valname)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (subkeyCString) Recycle(subkeyCString);
|
||||
if (valnameCString) Recycle(valnameCString);
|
||||
|
||||
return valueExists;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsWinReg::NativeIsKeyWritable(const nsString& subkey)
|
||||
PRBool
|
||||
nsWinReg::NativeIsKeyWritable(const nsString& aSubkey)
|
||||
{
|
||||
HKEY root;
|
||||
HKEY newkey;
|
||||
LONG result;
|
||||
char* subkeyCString;
|
||||
nsString subkeyParent = subkey;
|
||||
nsString subkeyParent = aSubkey;
|
||||
PRInt32 index;
|
||||
PRInt32 rv = PR_FALSE;
|
||||
|
||||
|
@ -604,14 +598,15 @@ nsWinReg::NativeIsKeyWritable(const nsString& subkey)
|
|||
|
||||
if(rv)
|
||||
{
|
||||
rv = PR_FALSE;
|
||||
subkeyCString = ToNewCString(subkeyParent);
|
||||
if(!subkeyCString)
|
||||
result = nsInstall::OUT_OF_MEMORY;
|
||||
nsCAutoString subkey;
|
||||
|
||||
if ( NS_FAILED( NS_CopyUnicodeToNative(subkeyParent, subkey) ) )
|
||||
result = nsInstall::UNEXPECTED_ERROR;
|
||||
else
|
||||
{
|
||||
rv = PR_FALSE;
|
||||
root = (HKEY)mRootKey;
|
||||
result = RegOpenKeyEx(root, subkeyCString, 0, KEY_WRITE, &newkey);
|
||||
result = RegOpenKeyEx(root, subkey.get(), 0, KEY_WRITE, &newkey);
|
||||
switch(result)
|
||||
{
|
||||
case ERROR_SUCCESS:
|
||||
|
@ -624,8 +619,6 @@ nsWinReg::NativeIsKeyWritable(const nsString& subkey)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if(subkeyCString)
|
||||
Recycle(subkeyCString);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -633,17 +626,23 @@ nsWinReg::NativeIsKeyWritable(const nsString& subkey)
|
|||
}
|
||||
|
||||
PRInt32
|
||||
nsWinReg::NativeCreateKey(const nsString& subkey, const nsString& classname)
|
||||
nsWinReg::NativeCreateKey(const nsString& aSubkey, const nsString& aClassname)
|
||||
{
|
||||
HKEY root, newkey;
|
||||
LONG result;
|
||||
ULONG disposition;
|
||||
char* subkeyCString = ToNewCString(subkey);
|
||||
char* classnameCString = ToNewCString(classname);
|
||||
|
||||
#ifdef WIN32
|
||||
nsCAutoString subkey;
|
||||
nsCAutoString classname;
|
||||
|
||||
if (NS_FAILED(NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
|
||||
NS_FAILED(NS_CopyUnicodeToNative(aClassname, classname) ) )
|
||||
return nsInstall::UNEXPECTED_ERROR;
|
||||
|
||||
root = (HKEY)mRootKey;
|
||||
result = RegCreateKeyEx(root, subkeyCString, 0, classnameCString, REG_OPTION_NON_VOLATILE, KEY_WRITE, nsnull, &newkey, &disposition);
|
||||
result = RegCreateKeyEx(root, subkey.get(), 0, (char*)classname.get(),
|
||||
REG_OPTION_NON_VOLATILE, KEY_WRITE, nsnull, &newkey, &disposition);
|
||||
|
||||
if(ERROR_SUCCESS == result)
|
||||
{
|
||||
|
@ -651,50 +650,49 @@ nsWinReg::NativeCreateKey(const nsString& subkey, const nsString& classname)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (subkeyCString) Recycle(subkeyCString);
|
||||
if (classnameCString) Recycle(classnameCString);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsWinReg::NativeDeleteKey(const nsString& subkey)
|
||||
nsWinReg::NativeDeleteKey(const nsString& aSubkey)
|
||||
{
|
||||
HKEY root;
|
||||
LONG result;
|
||||
char* subkeyCString = ToNewCString(subkey);
|
||||
|
||||
#ifdef WIN32
|
||||
root = (HKEY) mRootKey;
|
||||
result = RegDeleteKey( root, subkeyCString );
|
||||
#endif
|
||||
nsCAutoString subkey;
|
||||
|
||||
if (subkeyCString) Recycle(subkeyCString);
|
||||
if (NS_FAILED(NS_CopyUnicodeToNative(aSubkey, subkey) ) )
|
||||
return nsInstall::UNEXPECTED_ERROR;
|
||||
|
||||
root = (HKEY) mRootKey;
|
||||
result = RegDeleteKey( root, subkey.get() );
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsWinReg::NativeDeleteValue(const nsString& subkey, const nsString& valname)
|
||||
nsWinReg::NativeDeleteValue(const nsString& aSubkey, const nsString& aValname)
|
||||
{
|
||||
#if defined (WIN32) || defined (XP_OS2)
|
||||
HKEY root, newkey;
|
||||
LONG result;
|
||||
char* subkeyCString = ToNewCString(subkey);
|
||||
char* valnameCString = ToNewCString(valname);
|
||||
nsCAutoString subkey;
|
||||
nsCAutoString valname;
|
||||
|
||||
if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
|
||||
NS_FAILED( NS_CopyUnicodeToNative(aValname, valname) ) )
|
||||
return nsInstall::UNEXPECTED_ERROR;
|
||||
root = (HKEY) mRootKey;
|
||||
result = RegOpenKeyEx( root, subkeyCString, 0, KEY_WRITE, &newkey);
|
||||
result = RegOpenKeyEx( root, subkey.get(), 0, KEY_WRITE, &newkey);
|
||||
|
||||
if ( ERROR_SUCCESS == result )
|
||||
{
|
||||
result = RegDeleteValue( newkey, valnameCString );
|
||||
result = RegDeleteValue( newkey, valname.get() );
|
||||
RegCloseKey( newkey );
|
||||
}
|
||||
|
||||
if (subkeyCString) Recycle(subkeyCString);
|
||||
if (valnameCString) Recycle(valnameCString);
|
||||
|
||||
return result;
|
||||
#else
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
@ -702,95 +700,108 @@ nsWinReg::NativeDeleteValue(const nsString& subkey, const nsString& valname)
|
|||
}
|
||||
|
||||
PRInt32
|
||||
nsWinReg::NativeSetValueString(const nsString& subkey, const nsString& valname, const nsString& value)
|
||||
nsWinReg::NativeSetValueString(const nsString& aSubkey, const nsString& aValname, const nsString& aValue)
|
||||
{
|
||||
HKEY root;
|
||||
HKEY newkey;
|
||||
LONG result;
|
||||
DWORD length;
|
||||
|
||||
char* subkeyCString = ToNewCString(subkey);
|
||||
char* valnameCString = ToNewCString(valname);
|
||||
char* valueCString = ToNewCString(value);
|
||||
nsCAutoString subkey;
|
||||
nsCAutoString valname;
|
||||
nsCAutoString value;
|
||||
|
||||
if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
|
||||
NS_FAILED( NS_CopyUnicodeToNative(aValname, valname) ) ||
|
||||
NS_FAILED( NS_CopyUnicodeToNative(aValue, value) ) )
|
||||
return nsInstall::UNEXPECTED_ERROR;
|
||||
|
||||
length = value.Length();
|
||||
|
||||
root = (HKEY) mRootKey;
|
||||
result = RegOpenKeyEx( root, subkeyCString, 0, KEY_WRITE, &newkey);
|
||||
result = RegOpenKeyEx( root, subkey.get(), 0, KEY_WRITE, &newkey);
|
||||
|
||||
if(ERROR_SUCCESS == result)
|
||||
{
|
||||
result = RegSetValueEx( newkey, valnameCString, 0, REG_SZ, (unsigned char*)valueCString, length );
|
||||
result = RegSetValueEx( newkey, valname.get(), 0, REG_SZ, (unsigned char*)value.get(), length );
|
||||
RegCloseKey( newkey );
|
||||
}
|
||||
|
||||
if (subkeyCString) Recycle(subkeyCString);
|
||||
if (valnameCString) Recycle(valnameCString);
|
||||
if (valueCString) Recycle(valueCString);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#define STRBUFLEN 255
|
||||
|
||||
void
|
||||
nsWinReg::NativeGetValueString(const nsString& subkey, const nsString& valname, nsString* aReturn)
|
||||
PRInt32
|
||||
nsWinReg::NativeGetValueString(const nsString& aSubkey, const nsString& aValname, nsString* aReturn)
|
||||
{
|
||||
unsigned char valbuf[_MAXKEYVALUE_];
|
||||
HKEY root;
|
||||
HKEY newkey;
|
||||
LONG result;
|
||||
DWORD type = REG_SZ;
|
||||
DWORD length = _MAXKEYVALUE_;
|
||||
char* subkeyCString = ToNewCString(subkey);
|
||||
char* valnameCString = ToNewCString(valname);
|
||||
DWORD length = sizeof(valbuf);
|
||||
nsCAutoString subkey;
|
||||
nsCAutoString valname;
|
||||
|
||||
if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
|
||||
NS_FAILED( NS_CopyUnicodeToNative(aValname, valname) ) )
|
||||
return nsInstall::UNEXPECTED_ERROR;
|
||||
|
||||
root = (HKEY) mRootKey;
|
||||
result = RegOpenKeyEx( root, subkeyCString, 0, KEY_READ, &newkey );
|
||||
result = RegOpenKeyEx( root, subkey.get(), 0, KEY_READ, &newkey );
|
||||
|
||||
if ( ERROR_SUCCESS == result ) {
|
||||
result = RegQueryValueEx( newkey, valnameCString, nsnull, &type, valbuf, &length );
|
||||
result = RegQueryValueEx( newkey, valname.get(), nsnull, &type, valbuf, &length );
|
||||
|
||||
RegCloseKey( newkey );
|
||||
|
||||
if(type == REG_SZ)
|
||||
aReturn->AssignWithConversion((char*)valbuf);
|
||||
if( result == ERROR_SUCCESS && type == REG_SZ)
|
||||
{
|
||||
// this cast is ok until mozilla is compiled in UNICODE, then this
|
||||
// will break.
|
||||
nsAutoString value;
|
||||
if (NS_SUCCEEDED( NS_CopyNativeToUnicode(nsDependentCString(NS_REINTERPRET_CAST(const char *, valbuf)), value) ) )
|
||||
aReturn->Assign(value);
|
||||
else
|
||||
result = nsInstall::UNEXPECTED_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if(ERROR_ACCESS_DENIED == result)
|
||||
result = nsInstall::ACCESS_DENIED;
|
||||
|
||||
if (subkeyCString) Recycle(subkeyCString);
|
||||
if (valnameCString) Recycle(valnameCString);
|
||||
return result;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsWinReg::NativeSetValueNumber(const nsString& subkey, const nsString& valname, PRInt32 value)
|
||||
nsWinReg::NativeSetValueNumber(const nsString& aSubkey, const nsString& aValname, PRInt32 aValue)
|
||||
{
|
||||
HKEY root;
|
||||
HKEY newkey;
|
||||
LONG result;
|
||||
nsCAutoString subkey;
|
||||
nsCAutoString valname;
|
||||
|
||||
char* subkeyCString = ToNewCString(subkey);
|
||||
char* valnameCString = ToNewCString(valname);
|
||||
if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
|
||||
NS_FAILED( NS_CopyUnicodeToNative(aValname, valname) ) )
|
||||
return nsInstall::UNEXPECTED_ERROR;
|
||||
|
||||
root = (HKEY) mRootKey;
|
||||
result = RegOpenKeyEx( root, subkeyCString, 0, KEY_WRITE, &newkey);
|
||||
result = RegOpenKeyEx( root, subkey.get(), 0, KEY_WRITE, &newkey);
|
||||
|
||||
if(ERROR_SUCCESS == result)
|
||||
{
|
||||
result = RegSetValueEx( newkey, valnameCString, 0, REG_DWORD, (LPBYTE)&value, sizeof(PRInt32));
|
||||
result = RegSetValueEx( newkey, valname.get(), 0, REG_DWORD, (LPBYTE)&aValue, sizeof(PRInt32));
|
||||
RegCloseKey( newkey );
|
||||
}
|
||||
|
||||
if (subkeyCString) Recycle(subkeyCString);
|
||||
if (valnameCString) Recycle(valnameCString);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
nsWinReg::NativeGetValueNumber(const nsString& subkey, const nsString& valname, PRInt32* aReturn)
|
||||
PRInt32
|
||||
nsWinReg::NativeGetValueNumber(const nsString& aSubkey, const nsString& aValname, PRInt32* aReturn)
|
||||
|
||||
{
|
||||
PRInt32 valbuf;
|
||||
PRInt32 valbuflen;
|
||||
|
@ -799,15 +810,19 @@ nsWinReg::NativeGetValueNumber(const nsString& subkey, const nsString& valname,
|
|||
LONG result;
|
||||
DWORD type = REG_DWORD;
|
||||
DWORD length = _MAXKEYVALUE_;
|
||||
char* subkeyCString = ToNewCString(subkey);
|
||||
char* valnameCString = ToNewCString(valname);
|
||||
nsCAutoString subkey;
|
||||
nsCAutoString valname;
|
||||
|
||||
if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
|
||||
NS_FAILED( NS_CopyUnicodeToNative(aValname, valname) ) )
|
||||
return nsInstall::UNEXPECTED_ERROR;
|
||||
|
||||
valbuflen = sizeof(PRInt32);
|
||||
root = (HKEY) mRootKey;
|
||||
result = RegOpenKeyEx( root, subkeyCString, 0, KEY_READ, &newkey );
|
||||
result = RegOpenKeyEx( root, subkey.get(), 0, KEY_READ, &newkey );
|
||||
|
||||
if ( ERROR_SUCCESS == result ) {
|
||||
result = RegQueryValueEx( newkey, valnameCString, nsnull, &type, (LPBYTE)&valbuf, (LPDWORD)&valbuflen);
|
||||
result = RegQueryValueEx( newkey, valname.get(), nsnull, &type, (LPBYTE)&valbuf, (LPDWORD)&valbuflen);
|
||||
|
||||
RegCloseKey( newkey );
|
||||
|
||||
|
@ -816,14 +831,15 @@ nsWinReg::NativeGetValueNumber(const nsString& subkey, const nsString& valname,
|
|||
}
|
||||
|
||||
if(ERROR_ACCESS_DENIED == result)
|
||||
result = nsInstall::ACCESS_DENIED;
|
||||
return nsInstall::ACCESS_DENIED;
|
||||
else if (result != ERROR_SUCCESS)
|
||||
return nsInstall::UNEXPECTED_ERROR;
|
||||
|
||||
if (subkeyCString) Recycle(subkeyCString);
|
||||
if (valnameCString) Recycle(valnameCString);
|
||||
return nsInstall::SUCCESS;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsWinReg::NativeSetValue(const nsString& subkey, const nsString& valname, nsWinRegValue* value)
|
||||
nsWinReg::NativeSetValue(const nsString& aSubkey, const nsString& aValname, nsWinRegValue* aValue)
|
||||
{
|
||||
#if defined (WIN32) || defined (XP_OS2)
|
||||
HKEY root;
|
||||
|
@ -831,27 +847,27 @@ nsWinReg::NativeSetValue(const nsString& subkey, const nsString& valname, nsWinR
|
|||
LONG result;
|
||||
DWORD length;
|
||||
DWORD type;
|
||||
unsigned char* data;
|
||||
char* subkeyCString = ToNewCString(subkey);
|
||||
char* valnameCString = ToNewCString(valname);
|
||||
unsigned char* data;
|
||||
nsCAutoString subkey;
|
||||
nsCAutoString valname;
|
||||
|
||||
if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
|
||||
NS_FAILED( NS_CopyUnicodeToNative(aValname, valname) ) )
|
||||
return nsnull;
|
||||
|
||||
root = (HKEY) mRootKey;
|
||||
result = RegOpenKeyEx( root, subkeyCString, 0, KEY_WRITE, &newkey );
|
||||
result = RegOpenKeyEx( root, subkey.get(), 0, KEY_WRITE, &newkey );
|
||||
|
||||
if(ERROR_SUCCESS == result)
|
||||
{
|
||||
type = (DWORD)value->type;
|
||||
data = (unsigned char*)value->data;
|
||||
length = (DWORD)value->data_length;
|
||||
type = (DWORD)aValue->type;
|
||||
data = (unsigned char*)aValue->data;
|
||||
length = (DWORD)aValue->data_length;
|
||||
|
||||
result = RegSetValueEx( newkey, valnameCString, 0, type, data, length);
|
||||
result = RegSetValueEx( newkey, valname.get(), 0, type, data, length);
|
||||
RegCloseKey( newkey );
|
||||
}
|
||||
|
||||
if (subkeyCString) Recycle(subkeyCString);
|
||||
if (valnameCString) Recycle(valnameCString);
|
||||
|
||||
return result;
|
||||
#else
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
@ -859,7 +875,7 @@ nsWinReg::NativeSetValue(const nsString& subkey, const nsString& valname, nsWinR
|
|||
}
|
||||
|
||||
nsWinRegValue*
|
||||
nsWinReg::NativeGetValue(const nsString& subkey, const nsString& valname)
|
||||
nsWinReg::NativeGetValue(const nsString& aSubkey, const nsString& aValname)
|
||||
{
|
||||
#if defined (WIN32) || defined (XP_OS2)
|
||||
unsigned char valbuf[STRBUFLEN];
|
||||
|
@ -870,15 +886,19 @@ nsWinReg::NativeGetValue(const nsString& subkey, const nsString& valname)
|
|||
DWORD type;
|
||||
nsString* data;
|
||||
nsWinRegValue* value = nsnull;
|
||||
char* subkeyCString = ToNewCString(subkey);
|
||||
char* valnameCString = ToNewCString(valname);
|
||||
nsCAutoString subkey;
|
||||
nsCAutoString valname;
|
||||
|
||||
if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
|
||||
NS_FAILED( NS_CopyUnicodeToNative(aValname, valname) ) )
|
||||
return nsnull;
|
||||
|
||||
root = (HKEY) mRootKey;
|
||||
result = RegOpenKeyEx( root, subkeyCString, 0, KEY_READ, &newkey );
|
||||
result = RegOpenKeyEx( root, subkey.get(), 0, KEY_READ, &newkey );
|
||||
|
||||
if(ERROR_SUCCESS == result)
|
||||
{
|
||||
result = RegQueryValueEx( newkey, valnameCString, nsnull, &type, valbuf, &length );
|
||||
result = RegQueryValueEx( newkey, valname.get(), nsnull, &type, valbuf, &length );
|
||||
|
||||
if ( ERROR_SUCCESS == result ) {
|
||||
data = new nsString;
|
||||
|
@ -890,9 +910,6 @@ nsWinReg::NativeGetValue(const nsString& subkey, const nsString& valname)
|
|||
RegCloseKey( newkey );
|
||||
}
|
||||
|
||||
if (subkeyCString) Recycle(subkeyCString);
|
||||
if (valnameCString) Recycle(valnameCString);
|
||||
|
||||
return value;
|
||||
#else
|
||||
return nsnull;
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
#include "plevent.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsHashtable.h"
|
||||
|
||||
#include "nsSoftwareUpdate.h"
|
||||
|
@ -123,17 +122,17 @@ class nsWinReg
|
|||
nsInstall* mInstallObject;
|
||||
|
||||
/* Private Methods */
|
||||
PRInt32 NativeKeyExists(const nsString& subkey);
|
||||
PRInt32 NativeValueExists(const nsString& subkey, const nsString& valname);
|
||||
PRInt32 NativeIsKeyWritable(const nsString& subkey);
|
||||
PRBool NativeKeyExists(const nsString& subkey);
|
||||
PRBool NativeValueExists(const nsString& subkey, const nsString& valname);
|
||||
PRBool NativeIsKeyWritable(const nsString& subkey);
|
||||
PRInt32 NativeCreateKey(const nsString& subkey, const nsString& classname);
|
||||
PRInt32 NativeDeleteKey(const nsString& subkey);
|
||||
PRInt32 NativeDeleteValue(const nsString& subkey, const nsString& valname);
|
||||
|
||||
PRInt32 NativeSetValueString(const nsString& subkey, const nsString& valname, const nsString& value);
|
||||
void NativeGetValueString(const nsString& subkey, const nsString& valname, nsString* aReturn);
|
||||
PRInt32 NativeGetValueString(const nsString& subkey, const nsString& valname, nsString* aReturn);
|
||||
PRInt32 NativeSetValueNumber(const nsString& subkey, const nsString& valname, PRInt32 value);
|
||||
void NativeGetValueNumber(const nsString& subkey, const nsString& valname, PRInt32* aReturn);
|
||||
PRInt32 NativeGetValueNumber(const nsString& subkey, const nsString& valname, PRInt32* aReturn);
|
||||
|
||||
PRInt32 NativeSetValue(const nsString& subkey, const nsString& valname, nsWinRegValue* value);
|
||||
nsWinRegValue* NativeGetValue(const nsString& subkey, const nsString& valname);
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "nsVoidArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
//#include "nsIXPINotifier.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIOutputStream.h"
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "pratom.h"
|
||||
#include "prmem.h"
|
||||
|
||||
|
@ -49,7 +48,6 @@
|
|||
#include "nsXPInstallManager.h"
|
||||
#include "nsInstallTrigger.h"
|
||||
#include "nsInstallResources.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
|
@ -843,7 +841,6 @@ nsXPInstallManager::OnStopRequest(nsIRequest *request, nsISupports *ctxt,
|
|||
if ( mItem->mFile )
|
||||
{
|
||||
PRBool flagExists;
|
||||
nsFileSpec fspec;
|
||||
nsresult rv2 ;
|
||||
rv2 = mItem->mFile->Exists(&flagExists);
|
||||
if (NS_SUCCEEDED(rv2) && flagExists)
|
||||
|
@ -977,7 +974,7 @@ nsXPInstallManager::OnInstallStart(const PRUnichar *URL)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPInstallManager::OnPackageNameSet(const PRUnichar *URL, const PRUnichar *UIPackageName)
|
||||
nsXPInstallManager::OnPackageNameSet(const PRUnichar *URL, const PRUnichar *UIPackageName, const PRUnichar *aVersion)
|
||||
{
|
||||
// Don't need to do anything
|
||||
return NS_OK;
|
||||
|
|
|
@ -46,7 +46,7 @@ nsStubListener::OnInstallStart(const PRUnichar *URL)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStubListener::OnPackageNameSet(const PRUnichar *URL, const PRUnichar* UIPackageName)
|
||||
nsStubListener::OnPackageNameSet(const PRUnichar *URL, const PRUnichar* UIPackageName, const PRUnichar* aVersion)
|
||||
{
|
||||
// we're not interested in this one
|
||||
return NS_OK;
|
||||
|
|
Загрузка…
Ссылка в новой задаче