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.
This commit is contained in:
ssu%netscape.com 2000-05-14 03:07:05 +00:00
Родитель 90ec2e2dc0
Коммит f8042621b9
11 изменённых файлов: 321 добавлений и 47 удалений

Просмотреть файл

@ -68,6 +68,7 @@ CPPSRCS = \
nsInstallFileOpItem.cpp \
nsJSFileSpecObj.cpp \
nsInstallLogComment.cpp \
nsInstallBitwise.cpp \
$(NULL)
LOCAL_INCLUDES = -I$(srcdir)/../public

Просмотреть файл

@ -90,6 +90,7 @@ OBJS = \
.\$(OBJDIR)\nsJSFileSpecObj.obj \
.\$(OBJDIR)\nsInstallLogComment.obj \
# .\$(OBJDIR)\nsUpdateNotification.obj \
.\$(OBJDIR)\nsInstallBitwise.obj \
$(NULL)
WIN_LIBS= \

Просмотреть файл

@ -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<nsIFile> localFile = aTarget.GetFileSpec();
if (localFile == nsnull)
{
*aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
return NS_OK;
}
nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_WIN_REGISTER_SERVER, localFile, aReturn);
if (ifop == nsnull)
{
*aReturn = SaveError(nsInstall::OUT_OF_MEMORY);
return NS_OK;
}
PRInt32 result = SanityCheck();
if (result != nsInstall::SUCCESS)
{
delete ifop;
*aReturn = SaveError( result );
return NS_OK;
}
if (*aReturn == nsInstall::SUCCESS)
{
*aReturn = ScheduleForInstall( ifop );
}
SaveError(*aReturn);
return NS_OK;
}
void
nsInstall::LogComment(nsString& aComment)
{

Просмотреть файл

@ -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);

Просмотреть файл

@ -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

Просмотреть файл

@ -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;

Просмотреть файл

@ -27,6 +27,7 @@
#include "ScheduledTasks.h"
#ifdef _WINDOWS
#include <windows.h>
#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);
}

Просмотреть файл

@ -150,6 +150,9 @@ class nsInstallFileOpItem : public nsInstallObject
PRInt32 NativeFileOpMacAliasComplete();
PRInt32 NativeFileOpMacAliasAbort();
PRInt32 NativeFileOpUnixLink();
PRInt32 NativeFileOpWindowsRegisterServerPrepare();
PRInt32 NativeFileOpWindowsRegisterServerComplete();
PRInt32 NativeFileOpWindowsRegisterServerAbort();
};

Просмотреть файл

@ -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

Просмотреть файл

@ -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}
};

Просмотреть файл

@ -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" },