From 7f30e748365bc9c0c9b30fdff4ae062bc8d2ef5d Mon Sep 17 00:00:00 2001 From: "ssu%netscape.com" Date: Sun, 14 May 2000 03:07:05 +0000 Subject: [PATCH] added bit field in nsInstallFile for Windows Shared File and Do No Uninstall. added support in fileop for registering ole server files. changed the way logging is done in install.log to write to the log file *before* the attempt to complete() the file installation process. This helps with debugging because is shows what file the installation probably stopped on. git-svn-id: svn://10.0.0.236/trunk@69622 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpinstall/src/Makefile.in | 1 + mozilla/xpinstall/src/makefile.win | 1 + mozilla/xpinstall/src/nsInstall.cpp | 57 ++++++-- mozilla/xpinstall/src/nsInstall.h | 9 +- mozilla/xpinstall/src/nsInstallFile.cpp | 62 +++++++-- mozilla/xpinstall/src/nsInstallFileOpEnums.h | 25 ++-- mozilla/xpinstall/src/nsInstallFileOpItem.cpp | 129 +++++++++++++++++- mozilla/xpinstall/src/nsInstallFileOpItem.h | 3 + mozilla/xpinstall/src/nsInstallResources.cpp | 26 ++-- mozilla/xpinstall/src/nsJSFile.cpp | 48 +++++++ mozilla/xpinstall/src/nsJSInstall.cpp | 7 + 11 files changed, 321 insertions(+), 47 deletions(-) diff --git a/mozilla/xpinstall/src/Makefile.in b/mozilla/xpinstall/src/Makefile.in index 012a9598993..6b80e98fce5 100644 --- a/mozilla/xpinstall/src/Makefile.in +++ b/mozilla/xpinstall/src/Makefile.in @@ -68,6 +68,7 @@ CPPSRCS = \ nsInstallFileOpItem.cpp \ nsJSFileSpecObj.cpp \ nsInstallLogComment.cpp \ + nsInstallBitwise.cpp \ $(NULL) LOCAL_INCLUDES = -I$(srcdir)/../public diff --git a/mozilla/xpinstall/src/makefile.win b/mozilla/xpinstall/src/makefile.win index 49099d79fa5..9572990fcae 100644 --- a/mozilla/xpinstall/src/makefile.win +++ b/mozilla/xpinstall/src/makefile.win @@ -90,6 +90,7 @@ OBJS = \ .\$(OBJDIR)\nsJSFileSpecObj.obj \ .\$(OBJDIR)\nsInstallLogComment.obj \ # .\$(OBJDIR)\nsUpdateNotification.obj \ + .\$(OBJDIR)\nsInstallBitwise.obj \ $(NULL) WIN_LIBS= \ diff --git a/mozilla/xpinstall/src/nsInstall.cpp b/mozilla/xpinstall/src/nsInstall.cpp index d32c6076726..6f23f357446 100644 --- a/mozilla/xpinstall/src/nsInstall.cpp +++ b/mozilla/xpinstall/src/nsInstall.cpp @@ -828,6 +828,17 @@ nsInstall::FinalizeInstall(PRInt32* aReturn) if (ie == NULL) continue; + if (mListener) + { + char *objString = ie->toString(); + if (objString) + { + mListener->FinalizeProgress(NS_ConvertASCIItoUCS2(objString).GetUnicode(), + (i+1), mInstalledFiles->Count()); + delete [] objString; + } + } + result = ie->Complete(); if (result != nsInstall::SUCCESS) @@ -843,17 +854,6 @@ nsInstall::FinalizeInstall(PRInt32* aReturn) break; } } - - if (mListener) - { - char *objString = ie->toString(); - if (objString) - { - mListener->FinalizeProgress(NS_ConvertASCIItoUCS2(objString).GetUnicode(), - (i+1), mInstalledFiles->Count()); - delete [] objString; - } - } } if ( result == SUCCESS ) @@ -2028,6 +2028,41 @@ nsInstall::FileOpFileUnixLink(nsInstallFolder& aTarget, PRInt32 aFlags, PRInt32* return NS_OK; } +PRInt32 +nsInstall::FileOpWinRegisterServer(nsInstallFolder& aTarget, PRInt32* aReturn) +{ + nsCOMPtr localFile = aTarget.GetFileSpec(); + if (localFile == nsnull) + { + *aReturn = SaveError(nsInstall::OUT_OF_MEMORY); + return NS_OK; + } + + nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_WIN_REGISTER_SERVER, localFile, aReturn); + if (ifop == nsnull) + { + *aReturn = SaveError(nsInstall::OUT_OF_MEMORY); + return NS_OK; + } + + PRInt32 result = SanityCheck(); + if (result != nsInstall::SUCCESS) + { + delete ifop; + *aReturn = SaveError( result ); + return NS_OK; + } + + if (*aReturn == nsInstall::SUCCESS) + { + *aReturn = ScheduleForInstall( ifop ); + } + + SaveError(*aReturn); + + return NS_OK; +} + void nsInstall::LogComment(nsString& aComment) { diff --git a/mozilla/xpinstall/src/nsInstall.h b/mozilla/xpinstall/src/nsInstall.h index 8a57e6f5705..720e2a03a8e 100644 --- a/mozilla/xpinstall/src/nsInstall.h +++ b/mozilla/xpinstall/src/nsInstall.h @@ -154,6 +154,9 @@ class nsInstall SOURCE_IS_FILE = -234, INSUFFICIENT_DISK_SPACE = -235, FILENAME_TOO_LONG = -236, + + UNABLE_TO_LOCATE_LIB_FUNCTION = -237, + UNABLE_TO_LOAD_LIBRARY = -238, OUT_OF_MEMORY = -299, @@ -170,7 +173,10 @@ class nsInstall INSTALL_FILE_UNEXPECTED_MSG_ID = 0, DETAILS_REPLACE_FILE_MSG_ID = 1, - DETAILS_INSTALL_FILE_MSG_ID = 2 + DETAILS_INSTALL_FILE_MSG_ID = 2, + + DO_NOT_UNINSTALL = 2, + WIN_SHARED_FILE = 4 }; @@ -247,6 +253,7 @@ class nsInstall PRInt32 FileOpFileWindowsShortcut(nsIFile* aTarget, nsIFile* aShortcutPath, nsString& aDescription, nsIFile* aWorkingPath, nsString& aParams, nsIFile* aIcon, PRInt32 aIconId, PRInt32* aReturn); PRInt32 FileOpFileMacAlias(nsIFile *aSourceFile, nsIFile *aAliasFile, PRInt32* aReturn); PRInt32 FileOpFileUnixLink(nsInstallFolder& aTarget, PRInt32 aFlags, PRInt32* aReturn); + PRInt32 FileOpWinRegisterServer(nsInstallFolder& aTarget, PRInt32* aReturn); void LogComment(nsString& aComment); diff --git a/mozilla/xpinstall/src/nsInstallFile.cpp b/mozilla/xpinstall/src/nsInstallFile.cpp index dc7a63a8a26..3167d5fd382 100644 --- a/mozilla/xpinstall/src/nsInstallFile.cpp +++ b/mozilla/xpinstall/src/nsInstallFile.cpp @@ -32,6 +32,7 @@ #include "nsIDOMInstallVersion.h" #include "nsInstallResources.h" #include "nsInstallLogComment.h" +#include "nsInstallBitwise.h" /* Public Methods */ @@ -395,12 +396,12 @@ void nsInstallFile::Abort() mExtractedFile->Delete(PR_FALSE); } -#define RESBUFSIZE 1024 +#define RESBUFSIZE 4096 char* nsInstallFile::toString() { - char* buffer = new char[RESBUFSIZE]; + char* buffer = new char[RESBUFSIZE]; char* rsrcVal = nsnull; - char* fname = nsnull; + char* fname = nsnull; if (buffer == nsnull || !mInstall) return nsnull; @@ -409,23 +410,55 @@ char* nsInstallFile::toString() if (mReplaceFile) { - rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("ReplaceFile")); + if(mMode & nsInstall::WIN_SHARED_FILE) + { + rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("ReplaceSharedFile")); + } + else + { + rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("ReplaceFile")); + } } else if (mSkipInstall) { - rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("SkipFile")); + if(mMode & nsInstall::WIN_SHARED_FILE) + { + rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("SkipSharedFile")); + } + else + { + rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("SkipFile")); + } } else { - rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("InstallFile")); + if(mMode & nsInstall::WIN_SHARED_FILE) + { + rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("InstallSharedFile")); + } + else + { + rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("InstallFile")); + } } if (rsrcVal) { + char* interimCStr = nsnull; + nsString interimStr; + + if(mMode & nsInstall::DO_NOT_UNINSTALL) + interimStr.AssignWithConversion("(*dnu*) "); + + interimStr.AppendWithConversion(rsrcVal); + interimCStr = interimStr.ToNewCString(); + if(interimCStr == nsnull) + return interimCStr; + if (mFinalFile) mFinalFile->GetPath(&fname); - PR_snprintf( buffer, RESBUFSIZE, rsrcVal, fname ); + PR_snprintf( buffer, RESBUFSIZE, interimCStr, fname ); Recycle(rsrcVal); } @@ -436,7 +469,9 @@ char* nsInstallFile::toString() PRInt32 nsInstallFile::CompleteFileMove() { - int result = 0; + int result = 0; + char *temp; + PRBool bAlreadyExists = PR_FALSE; if (mExtractedFile == nsnull) { @@ -453,7 +488,16 @@ PRInt32 nsInstallFile::CompleteFileMove() result = ReplaceFileNowOrSchedule(mExtractedFile, mFinalFile ); } - return result; + if(mMode & nsInstall::WIN_SHARED_FILE) + { + if(mReplaceFile || mSkipInstall) + bAlreadyExists = PR_TRUE; + + mFinalFile->GetPath(&temp); + RegisterSharedFile(temp, bAlreadyExists); + } + + return result; } PRInt32 diff --git a/mozilla/xpinstall/src/nsInstallFileOpEnums.h b/mozilla/xpinstall/src/nsInstallFileOpEnums.h index f91f80a9b12..791fd9c1387 100644 --- a/mozilla/xpinstall/src/nsInstallFileOpEnums.h +++ b/mozilla/xpinstall/src/nsInstallFileOpEnums.h @@ -24,18 +24,19 @@ #define nsInstallFileOpEnums_h__ typedef enum nsInstallFileOpEnums { - NS_FOP_DIR_CREATE = 0, - NS_FOP_DIR_REMOVE = 1, - NS_FOP_DIR_RENAME = 2, - NS_FOP_FILE_COPY = 3, - NS_FOP_FILE_DELETE = 4, - NS_FOP_FILE_EXECUTE = 5, - NS_FOP_FILE_MOVE = 6, - NS_FOP_FILE_RENAME = 7, - NS_FOP_WIN_SHORTCUT = 8, - NS_FOP_MAC_ALIAS = 9, - NS_FOP_UNIX_LINK = 10, - NS_FOP_FILE_SET_STAT = 11 + NS_FOP_DIR_CREATE = 0, + NS_FOP_DIR_REMOVE = 1, + NS_FOP_DIR_RENAME = 2, + NS_FOP_FILE_COPY = 3, + NS_FOP_FILE_DELETE = 4, + NS_FOP_FILE_EXECUTE = 5, + NS_FOP_FILE_MOVE = 6, + NS_FOP_FILE_RENAME = 7, + NS_FOP_WIN_SHORTCUT = 8, + NS_FOP_MAC_ALIAS = 9, + NS_FOP_UNIX_LINK = 10, + NS_FOP_FILE_SET_STAT = 11, + NS_FOP_WIN_REGISTER_SERVER = 12 } nsInstallFileOpEnums; diff --git a/mozilla/xpinstall/src/nsInstallFileOpItem.cpp b/mozilla/xpinstall/src/nsInstallFileOpItem.cpp index feab551d722..bcb2414922d 100644 --- a/mozilla/xpinstall/src/nsInstallFileOpItem.cpp +++ b/mozilla/xpinstall/src/nsInstallFileOpItem.cpp @@ -27,6 +27,7 @@ #include "ScheduledTasks.h" #ifdef _WINDOWS +#include #include "nsWinShortcut.h" #endif @@ -262,6 +263,9 @@ PRInt32 nsInstallFileOpItem::Complete() case NS_FOP_UNIX_LINK: ret = NativeFileOpUnixLink(); break; + case NS_FOP_WIN_REGISTER_SERVER: + ret = NativeFileOpWindowsRegisterServerComplete(); + break; } if ( (ret != nsInstall::SUCCESS) && (ret < nsInstall::GESTALT_INVALID_ARGUMENT || ret > nsInstall::REBOOT_NEEDED) ) @@ -280,8 +284,6 @@ char* nsInstallFileOpItem::toString() char* srcPath; char* dstPath; - // XXX these hardcoded strings should be replaced by nsInstall::GetResourcedString(id) - // STRING USE WARNING: perhaps |result| should be an |nsCAutoString| to avoid all this double converting switch(mCommand) @@ -296,6 +298,7 @@ char* nsInstallFileOpItem::toString() if(rsrcVal != nsnull) PR_snprintf(resultCString, RESBUFSIZE, rsrcVal, srcPath, dstPath ); break; + case NS_FOP_FILE_DELETE: if(mTarget == nsnull) break; @@ -305,6 +308,7 @@ char* nsInstallFileOpItem::toString() if(rsrcVal != nsnull) PR_snprintf(resultCString, RESBUFSIZE, rsrcVal, dstPath ); break; + case NS_FOP_FILE_EXECUTE: if(mTarget == nsnull) break; @@ -329,6 +333,7 @@ char* nsInstallFileOpItem::toString() Recycle(temp); break; + case NS_FOP_FILE_MOVE: if((mSrc == nsnull) || (mTarget == nsnull)) break; @@ -339,6 +344,7 @@ char* nsInstallFileOpItem::toString() if(rsrcVal != nsnull) PR_snprintf(resultCString, RESBUFSIZE, rsrcVal, srcPath, dstPath ); break; + case NS_FOP_FILE_RENAME: if((mSrc == nsnull) || (mTarget == nsnull)) break; @@ -349,6 +355,7 @@ char* nsInstallFileOpItem::toString() if(rsrcVal != nsnull) PR_snprintf(resultCString, RESBUFSIZE, rsrcVal, srcPath, dstPath ); break; + case NS_FOP_DIR_CREATE: if(mTarget == nsnull) break; @@ -358,6 +365,7 @@ char* nsInstallFileOpItem::toString() if(rsrcVal != nsnull) PR_snprintf(resultCString, RESBUFSIZE, rsrcVal, dstPath ); break; + case NS_FOP_DIR_REMOVE: if(mTarget == nsnull) break; @@ -367,6 +375,7 @@ char* nsInstallFileOpItem::toString() if(rsrcVal != nsnull) PR_snprintf(resultCString, RESBUFSIZE, rsrcVal, dstPath ); break; + case NS_FOP_DIR_RENAME: if((mSrc == nsnull) || (mTarget == nsnull)) break; @@ -377,6 +386,7 @@ char* nsInstallFileOpItem::toString() if(rsrcVal != nsnull) PR_snprintf(resultCString, RESBUFSIZE, rsrcVal, srcPath, dstPath ); break; + case NS_FOP_WIN_SHORTCUT: rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("WindowsShortcut")); if(rsrcVal != nsnull) @@ -393,6 +403,7 @@ char* nsInstallFileOpItem::toString() } } break; + case NS_FOP_MAC_ALIAS: if(mTarget == nsnull) break; @@ -402,11 +413,23 @@ char* nsInstallFileOpItem::toString() if(rsrcVal != nsnull) PR_snprintf(resultCString, RESBUFSIZE, rsrcVal, dstPath ); break; + case NS_FOP_UNIX_LINK: break; + + case NS_FOP_WIN_REGISTER_SERVER: + if(mTarget == nsnull) + break; + + mTarget->GetPath(&dstPath); + rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("WindowsRegisterServer")); + if(rsrcVal != nsnull) + PR_snprintf(resultCString, RESBUFSIZE, rsrcVal, dstPath ); + break; + default: if(rsrcVal != nsnull) - rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("UnknownFileOpCommand")); + resultCString = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("UnknownFileOpCommand")); break; } @@ -453,6 +476,9 @@ PRInt32 nsInstallFileOpItem::Prepare() break; case NS_FOP_UNIX_LINK: break; + case NS_FOP_WIN_REGISTER_SERVER: + ret = NativeFileOpWindowsRegisterServerPrepare(); + break; default: break; } @@ -498,6 +524,9 @@ void nsInstallFileOpItem::Abort() break; case NS_FOP_UNIX_LINK: break; + case NS_FOP_WIN_REGISTER_SERVER: + NativeFileOpWindowsRegisterServerAbort(); + break; } } @@ -1287,3 +1316,97 @@ nsInstallFileOpItem::NativeFileOpUnixLink() return nsInstall::SUCCESS; } +PRInt32 +nsInstallFileOpItem::NativeFileOpWindowsRegisterServerPrepare() +{ + PRInt32 rv = nsInstall::SUCCESS; + +#ifdef _WINDOWS + char *file = nsnull; + FARPROC DllReg; + HINSTANCE hLib; + + mTarget->GetPath(&file); + if(file != nsnull) + { + if((hLib = LoadLibraryEx(file, NULL, LOAD_WITH_ALTERED_SEARCH_PATH)) != NULL) + { + if((DllReg = GetProcAddress(hLib, "DllRegisterServer")) == NULL) + rv = nsInstall::UNABLE_TO_LOCATE_LIB_FUNCTION; + + FreeLibrary(hLib); + } + else + rv = nsInstall::UNABLE_TO_LOAD_LIBRARY; + } + else + rv = nsInstall::UNEXPECTED_ERROR; +#endif + + return(rv); +} + +PRInt32 +nsInstallFileOpItem::NativeFileOpWindowsRegisterServerComplete() +{ + PRInt32 rv = nsInstall::SUCCESS; + +#ifdef _WINDOWS + char *file = nsnull; + FARPROC DllReg; + HINSTANCE hLib; + + mTarget->GetPath(&file); + if(file != nsnull) + { + if((hLib = LoadLibraryEx(file, NULL, LOAD_WITH_ALTERED_SEARCH_PATH)) != NULL) + { + if((DllReg = GetProcAddress(hLib, "DllRegisterServer")) != NULL) + DllReg(); + else + rv = nsInstall::UNABLE_TO_LOCATE_LIB_FUNCTION; + + FreeLibrary(hLib); + } + else + rv = nsInstall::UNABLE_TO_LOAD_LIBRARY; + } + else + rv = nsInstall::UNEXPECTED_ERROR; +#endif + + return(rv); +} + +PRInt32 +nsInstallFileOpItem::NativeFileOpWindowsRegisterServerAbort() +{ + PRInt32 rv = nsInstall::SUCCESS; + +#ifdef _WINDOWS + char *file = nsnull; + FARPROC DllUnReg; + HINSTANCE hLib; + + mTarget->GetPath(&file); + if(file != nsnull) + { + if((hLib = LoadLibraryEx(file, NULL, LOAD_WITH_ALTERED_SEARCH_PATH)) != NULL) + { + if((DllUnReg = GetProcAddress(hLib, "DllUnregisterServer")) != NULL) + DllUnReg(); + else + rv = nsInstall::UNABLE_TO_LOCATE_LIB_FUNCTION; + + FreeLibrary(hLib); + } + else + rv = nsInstall::UNABLE_TO_LOAD_LIBRARY; + } + else + rv = nsInstall::UNEXPECTED_ERROR; +#endif + + return(rv); +} + diff --git a/mozilla/xpinstall/src/nsInstallFileOpItem.h b/mozilla/xpinstall/src/nsInstallFileOpItem.h index 580b162380f..2b1a135e6b0 100644 --- a/mozilla/xpinstall/src/nsInstallFileOpItem.h +++ b/mozilla/xpinstall/src/nsInstallFileOpItem.h @@ -150,6 +150,9 @@ class nsInstallFileOpItem : public nsInstallObject PRInt32 NativeFileOpMacAliasComplete(); PRInt32 NativeFileOpMacAliasAbort(); PRInt32 NativeFileOpUnixLink(); + PRInt32 NativeFileOpWindowsRegisterServerPrepare(); + PRInt32 NativeFileOpWindowsRegisterServerComplete(); + PRInt32 NativeFileOpWindowsRegisterServerAbort(); }; diff --git a/mozilla/xpinstall/src/nsInstallResources.cpp b/mozilla/xpinstall/src/nsInstallResources.cpp index 3fc1ccf200c..ab1c541df44 100644 --- a/mozilla/xpinstall/src/nsInstallResources.cpp +++ b/mozilla/xpinstall/src/nsInstallResources.cpp @@ -34,8 +34,11 @@ static nsXPIResourceTableItem XPIResTable[] = * Install Actions *---------------------------------------------------------------------*/ { "InstallFile", "Installing: %s" }, + { "InstallSharedFile", "Installing Shared File: %s" }, { "ReplaceFile", "Replacing: %s" }, + { "ReplaceSharedFile", "Replacing Shared File: %s" }, { "SkipFile", "Skipping: %s" }, + { "SkipSharedFile", "Skipping Shared File: %s" }, { "DeleteFile", "Deleting file: %s" }, { "DeleteComponent", "Deleting component: %s" }, { "Execute", "Executing: %s" }, @@ -48,17 +51,18 @@ static nsXPIResourceTableItem XPIResTable[] = { "RegPackage", "Register Package: %s" }, - { "CopyFile", "Copy File: %s to %s" }, - { "ExecuteFile", "Execute File: %s" }, - { "ExecuteFileWithArgs", "Execute File: %s with argument: %s" }, - { "MoveFile", "Move File: %s to %s" }, - { "RenameFile", "Rename File: %s to %s" }, - { "CreateFolder", "Create Folder: %s" }, - { "RemoveFolder", "Remove Folder: %s" }, - { "RenameFolder", "Rename Folder: %s to %s" }, - { "WindowsShortcut", "Windows Shortcut: %s" }, - { "MacAlias", "Mac Alias: %s" }, - { "UnknownFileOpCommand", "Unkown file operation command!" }, + { "CopyFile", "Copy File: %s to %s" }, + { "ExecuteFile", "Execute File: %s" }, + { "ExecuteFileWithArgs", "Execute File: %s with argument: %s" }, + { "MoveFile", "Move File: %s to %s" }, + { "RenameFile", "Rename File: %s to %s" }, + { "CreateFolder", "Create Folder: %s" }, + { "RemoveFolder", "Remove Folder: %s" }, + { "RenameFolder", "Rename Folder: %s to %s" }, + { "WindowsShortcut", "Windows Shortcut: %s" }, + { "MacAlias", "Mac Alias: %s" }, + { "WindowsRegisterServer", "Windows Register Server: %s" }, + { "UnknownFileOpCommand", "Unkown file operation command!" }, // XXX FileOp*() action strings // XXX WinReg and WinProfile action strings diff --git a/mozilla/xpinstall/src/nsJSFile.cpp b/mozilla/xpinstall/src/nsJSFile.cpp index ca0115f4bff..5f9904d0313 100644 --- a/mozilla/xpinstall/src/nsJSFile.cpp +++ b/mozilla/xpinstall/src/nsJSFile.cpp @@ -1258,6 +1258,53 @@ InstallFileOpFileUnixLink(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, return JS_TRUE; } +// +// Native method WindowsRegisterServer +// +JSBool PR_CALLBACK +InstallFileOpWinRegisterServer(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj); + PRInt32 nativeRet; + JSObject *jsObj; + nsInstallFolder *folder; + + *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR); + + // If there's no private data, this must be the prototype, so ignore + if(nsnull == nativeThis) + { + return JS_TRUE; + } + + // public int WinRegisterServer (nsInstallFolder aNativeFolderPath); + + if ( argc == 0 || argv[0] == JSVAL_NULL || !JSVAL_IS_OBJECT(argv[0])) //argv[0] MUST be a jsval + { + *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS); + return JS_TRUE; + } + + jsObj = JSVAL_TO_OBJECT(argv[0]); + + if (!JS_InstanceOf(cx, jsObj, &FileSpecObjectClass, nsnull)) + { + *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS); + return JS_TRUE; + } + + folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj); + + if(!folder || NS_OK != nativeThis->FileOpWinRegisterServer(*folder, &nativeRet)) + { + return JS_TRUE; + } + + *rval = INT_TO_JSVAL(nativeRet); + return JS_TRUE; +} + + /***********************************************************************/ // // Install Properties Getter @@ -1324,6 +1371,7 @@ static JSFunctionSpec FileOpMethods[] = {"windowsShortcut", InstallFileOpFileWindowsShortcut, 7}, {"macAlias", InstallFileOpFileMacAlias, 2}, {"unixLink", InstallFileOpFileUnixLink, 2}, + {"windowsRegisterServer", InstallFileOpWinRegisterServer, 1}, {0} }; diff --git a/mozilla/xpinstall/src/nsJSInstall.cpp b/mozilla/xpinstall/src/nsJSInstall.cpp index 7b6f6b39ff8..188e0028e8b 100644 --- a/mozilla/xpinstall/src/nsJSInstall.cpp +++ b/mozilla/xpinstall/src/nsJSInstall.cpp @@ -1855,6 +1855,9 @@ static JSConstDoubleSpec install_constants[] = { nsInstall::INSUFFICIENT_DISK_SPACE, "INSUFFICIENT_DISK_SPACE" }, { nsInstall::FILENAME_TOO_LONG, "FILENAME_TOO_LONG" }, + { nsInstall::UNABLE_TO_LOCATE_LIB_FUNCTION, "UNABLE_TO_LOCATE_LIB_FUNCTION"}, + { nsInstall::UNABLE_TO_LOAD_LIBRARY, "UNABLE_TO_LOAD_LIBRARY" }, + { nsInstall::GESTALT_UNKNOWN_ERR, "GESTALT_UNKNOWN_ERR" }, { nsInstall::GESTALT_INVALID_ARGUMENT, "GESTALT_INVALID_ARGUMENT" }, @@ -1866,6 +1869,10 @@ static JSConstDoubleSpec install_constants[] = { nsInstall::NO_STATUS_DLG , "NO_STATUS_DLG" }, { nsInstall::NO_FINALIZE_DLG, "NO_FINALIZE_DLG" }, + // these are bitwise values supported by addFile + { nsInstall::DO_NOT_UNINSTALL, "DO_NOT_UNINSTALL" }, + { nsInstall::WIN_SHARED_FILE, "WIN_SHARED_FILE" }, + { CHROME_SKIN, "SKIN" }, { CHROME_LOCALE, "LOCALE" }, { CHROME_CONTENT, "CONTENT" },