This commit is contained in:
dveditz%netscape.com 2000-04-24 13:53:38 +00:00
Родитель 15bbd2c7a4
Коммит 64d77c0aef
18 изменённых файлов: 329 добавлений и 172 удалений

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

@ -48,6 +48,8 @@ public:
NS_IMETHOD Install(nsXPITriggerInfo* aInfo, PRBool* aReturn)=0;
NS_IMETHOD InstallChrome(PRUint32 aType, nsXPITriggerItem* aItem, PRBool* aReturn)=0;
NS_IMETHOD StartSoftwareUpdate(const nsString& aURL, PRInt32 aFlags, PRBool* aReturn)=0;
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, PRInt32 aDiffLevel, const nsString& aVersion, PRInt32 aMode, PRInt32* aReturn)=0;

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

@ -28,14 +28,5 @@ include $(DEPTH)/config/autoconf.mk
DIRS = locale content skin
EXPORT_RESOURCE_XPINSTALL = \
$(srcdir)/progress.xul \
$(srcdir)/progress.html \
$(srcdir)/progress.css \
$(NULL)
include $(topsrcdir)/config/rules.mk
install::
$(INSTALL) $(EXPORT_RESOURCE_XPINSTALL) $(DIST)/bin/res/xpinstall

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

@ -19,6 +19,7 @@ Rights Reserved.
Contributor(s):
Don Bragg (dbragg@netscape.com)
Dan Veditz <dveditz@netscape.com>
-->
<?xml-stylesheet href="chrome://communicator/skin/xpinstall/xpinstall.css" type="text/css"?>
@ -30,7 +31,7 @@ Contributor(s):
<window xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="onLoad()"
title="&items.label;"
title="&dialog.title;"
class = "dialog"
align = "vertical"
>

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

@ -1,4 +1,3 @@
xpinstall.properties
progress.dtd
xpistatus.dtd
institems.dtd

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

@ -28,7 +28,6 @@ include $(DEPTH)/config/autoconf.mk
EXPORT_RESOURCE_XPINSTALL = \
$(srcdir)/xpinstall.properties \
$(srcdir)/progress.dtd \
$(srcdir)/xpistatus.dtd \
$(srcdir)/institems.dtd \
$(NULL)

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

@ -3,6 +3,7 @@
<!ENTITY dialogCancel.label "Cancel">
<!ENTITY dialogOk.label "Ok">
<!ENTITY items.label "Items to install">
<!ENTITY componentList.label "The following components will be installed:">
<!ENTITY dialog.title "Software Installation">
<!ENTITY componentList.label "The following packages will be installed:">
<!ENTITY moduleName.label "Module name">
<!ENTITY moduleSource.label "Location">

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

@ -26,14 +26,12 @@ DEPTH=..\..\..\..
include <$(DEPTH)\config\rules.mak>
install::
$(MAKE_INSTALL) progress.dtd $(DIST)\bin\chrome\communicator\locale\xpinstall
$(MAKE_INSTALL) xpistatus.dtd $(DIST)\bin\chrome\communicator\locale\xpinstall
$(MAKE_INSTALL) xpinstall.properties $(DIST)\bin\chrome\communicator\locale\xpinstall
$(MAKE_INSTALL) institems.dtd $(DIST)\bin\chrome\communicator\locale\xpinstall
clobber::
rm -f $(DIST)\bin\chrome\communicator\locale\xpinstall\progress.dtd
rm -f $(DIST)\bin\chrome\communicator\locale\xpinstall\xpistatus.dtd
rm -f $(DIST)\bin\chrome\communicator\locale\xpinstall\xpinstall.properties
rm -f $(DIST)\bin\chrome\communicator\locale\xpinstall\institems.dtd

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

@ -46,6 +46,12 @@ Uninstall=Uninstalling: %s
FinishingInstallMsg=Finishing install... please wait.
ApplyNowSkin=Use this theme
ApplyNowLocale=Use this locale
ConfirmSkin=Install the theme "%1$S" from %2$S?
ConfirmLocale=Install the locale "%1$S" from %2$S?
#--------------------------------------------------------------------
# Miscellaneous

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

@ -24,13 +24,3 @@ DEPTH=..\..
DIRS = locale content skin
include <$(DEPTH)\config\rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) progress.xul $(DIST)\bin\res\xpinstall
$(MAKE_INSTALL) progress.css $(DIST)\bin\res\xpinstall
$(MAKE_INSTALL) progress.html $(DIST)\bin\res\xpinstall
clobber::
rm -f $(DIST)\res\xpinstall\progress.xul
rm -f $(DIST)\res\xpinstall\progress.css
rm -f $(DIST)\res\xpinstall\progress.html

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

@ -87,8 +87,6 @@ static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
static NS_DEFINE_IID(kIStringBundleServiceIID, NS_ISTRINGBUNDLESERVICE_IID);
#define XPINSTALL_BUNDLE_URL "chrome://communicator/locale/xpinstall/xpinstall.properties"
// filename length maximums
#ifdef XP_MAC
#define MAX_NAME_LENGTH 31
@ -105,7 +103,7 @@ MOZ_DECL_CTOR_COUNTER(nsInstallInfo);
nsInstallInfo::nsInstallInfo(nsIFile* aFile,
const PRUnichar* aURL,
const PRUnichar* aArgs,
long flags,
PRUint32 flags,
nsIXPINotifier* aNotifier)
: mError(0),
mFlags(flags),

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

@ -58,6 +58,8 @@
#include "nsIEnumerator.h"
#include "nsIZipReader.h"
#define XPINSTALL_BUNDLE_URL "chrome://communicator/locale/xpinstall/xpinstall.properties"
class nsInstallInfo
{
public:
@ -65,7 +67,7 @@ class nsInstallInfo
nsInstallInfo( nsIFile* aFile,
const PRUnichar* aURL,
const PRUnichar* aArgs,
long aFlags,
PRUint32 aFlags,
nsIXPINotifier* aNotifier);
virtual ~nsInstallInfo();
@ -76,7 +78,7 @@ class nsInstallInfo
void GetArguments(nsString& aArgs) { aArgs = mArgs; }
long GetFlags() { return mFlags; }
PRUint32 GetFlags() { return mFlags; }
nsIXPINotifier* GetNotifier() { return mNotifier; };
@ -84,7 +86,7 @@ class nsInstallInfo
nsresult mError;
long mFlags;
PRUint32 mFlags;
nsString mURL;
nsString mArgs;
@ -258,6 +260,9 @@ class nsInstall
void GetInstallURL(nsString& url);
void SetInstallURL(const nsString& url);
PRUint32 GetInstallFlags() { return mInstallFlags; }
void SetInstallFlags(PRUint32 aFlags) { mInstallFlags = aFlags; }
PRBool GetStatusSent() { return mStatusSent; }
PRBool InInstallTransaction(void) { return mInstalledFiles != nsnull; }
@ -279,6 +284,7 @@ class nsInstall
nsString mInstallArguments;
nsString mInstallURL;
PRUint32 mInstallFlags;
nsInstallFolder* mPackageFolder;
PRBool mUserCancelled;

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

@ -51,11 +51,10 @@ static NS_DEFINE_IID(kIInstallTrigger_CID, NS_SoftwareUpdateInstallTrigger_CID);
nsInstallTrigger::nsInstallTrigger()
{
mScriptObject = nsnull;
NS_INIT_REFCNT();
NS_INIT_ISUPPORTS();
}
nsInstallTrigger::~nsInstallTrigger()
@ -165,12 +164,12 @@ nsInstallTrigger::UpdateEnabled(PRBool* aReturn)
NS_IMETHODIMP
nsInstallTrigger::Install(nsXPITriggerInfo* aTrigger, PRBool* aReturn)
{
nsresult rv;
NS_ASSERTION(aReturn, "Invalid pointer arg");
*aReturn = PR_FALSE;
PRBool enabled;
UpdateEnabled(&enabled);
if (!enabled)
nsresult rv = UpdateEnabled(&enabled);
if (NS_FAILED(rv) || !enabled)
{
delete aTrigger;
return NS_OK;
@ -180,7 +179,7 @@ nsInstallTrigger::Install(nsXPITriggerInfo* aTrigger, PRBool* aReturn)
if (mgr)
{
// The Install manager will delete itself when done
rv = mgr->InitManager( aTrigger );
rv = mgr->InitManager( aTrigger, 0 );
if (NS_SUCCEEDED(rv))
*aReturn = PR_TRUE;
}
@ -195,6 +194,45 @@ nsInstallTrigger::Install(nsXPITriggerInfo* aTrigger, PRBool* aReturn)
}
NS_IMETHODIMP
nsInstallTrigger::InstallChrome(PRUint32 aType, nsXPITriggerItem *aItem, PRBool* aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
NS_ENSURE_ARG_POINTER(aItem);
*aReturn = PR_FALSE;
// make sure we're allowing installs
PRBool enabled;
nsresult rv = UpdateEnabled(&enabled);
if (NS_FAILED(rv) || !enabled)
return NS_OK;
// The Install manager will delete itself when done, once we've called
// InitManager. Before then **WE** must delete it
nsXPInstallManager *mgr = new nsXPInstallManager();
if (mgr)
{
nsXPITriggerInfo* trigger = new nsXPITriggerInfo();
if ( trigger )
{
trigger->Add( aItem );
// The Install manager will delete itself when done
rv = mgr->InitManager( trigger, aType );
*aReturn = PR_TRUE;
}
else
{
rv = NS_ERROR_OUT_OF_MEMORY;
delete mgr;
}
}
return NS_OK;
}
NS_IMETHODIMP
nsInstallTrigger::StartSoftwareUpdate(const nsString& aURL, PRInt32 aFlags, PRBool* aReturn)
{
@ -219,7 +257,7 @@ nsInstallTrigger::StartSoftwareUpdate(const nsString& aURL, PRInt32 aFlags, PRBo
{
trigger->Add( item );
// The Install manager will delete itself when done
rv = mgr->InitManager( trigger );
rv = mgr->InitManager( trigger, 0 );
*aReturn = PR_TRUE;
}
else

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

@ -14,7 +14,11 @@
#include "nsSoftwareUpdate.h"
#include "nsXPITriggerInfo.h"
#define CHROMETYPE_SAFESKIN 1
#define CHROMETYPE_LOCALE 2
#define CHROMETYPE_SAFEMAX CHROMETYPE_LOCALE
#define CHROMETYPE_SCRIPTSKIN 3
#define CHROMETYPE_PACKAGE 4
class nsInstallTrigger: public nsIScriptObjectOwner, public nsIDOMInstallTriggerGlobal
@ -32,6 +36,7 @@ class nsInstallTrigger: public nsIScriptObjectOwner, public nsIDOMInstallTrigger
NS_IMETHOD UpdateEnabled(PRBool* aReturn);
NS_IMETHOD Install(nsXPITriggerInfo *aInfo, PRBool* aReturn);
NS_IMETHOD InstallChrome(PRUint32 aType, nsXPITriggerItem* aItem, PRBool* aReturn);
NS_IMETHOD StartSoftwareUpdate(const nsString& aURL, PRInt32 aFlags, PRInt32* aReturn);
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, PRInt32 aDiffLevel, const nsString& aVersion, PRInt32 aMode, PRInt32* aReturn);
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, PRInt32 aDiffLevel, nsIDOMInstallVersion* aVersion, PRInt32 aMode, PRInt32* aReturn);

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

@ -57,10 +57,11 @@ enum Install_slots
INSTALL_JARFILE = -3,
INSTALL_ARGUMENTS = -4,
INSTALL_URL = -5,
INSTALL_STATUSSENT = -6,
INSTALL_INSTALL = -7,
INSTALL_FILEOP = -8,
INSTALL_INSTALLED_FILES = -9
INSTALL_FLAGS = -6,
INSTALL_STATUSSENT = -7,
INSTALL_INSTALL = -8,
INSTALL_FILEOP = -9,
INSTALL_INSTALLED_FILES = -10
};
// prototype for fileOp object
@ -146,6 +147,10 @@ GetInstallProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
break;
}
case INSTALL_FLAGS:
*vp = INT_TO_JSVAL( a->GetInstallFlags() );
break;
case INSTALL_STATUSSENT:
*vp = BOOLEAN_TO_JSVAL( a->GetStatusSent() );
break;
@ -1766,6 +1771,7 @@ static JSPropertySpec InstallProperties[] =
{"jarfile", INSTALL_JARFILE, JSPROP_ENUMERATE | JSPROP_READONLY},
{"arguments", INSTALL_ARGUMENTS, JSPROP_ENUMERATE | JSPROP_READONLY},
{"url", INSTALL_URL, JSPROP_ENUMERATE | JSPROP_READONLY},
{"flags", INSTALL_FLAGS, JSPROP_ENUMERATE | JSPROP_READONLY},
{"_statusSent", INSTALL_STATUSSENT, JSPROP_READONLY},
{"Install", INSTALL_INSTALL, JSPROP_READONLY},
{"File", INSTALL_FILEOP, JSPROP_READONLY},
@ -1885,49 +1891,6 @@ static JSFunctionSpec InstallMethods[] =
{"abortInstall", InstallAbortInstall, 1},
{"finalizeInstall", InstallFinalizeInstall, 0},
{"startInstall", InstallStartInstall, 4},
{"AbortInstall", InstallAbortInstall, 1},
{"AddDirectory", InstallAddDirectory, 6},
{"AddSubcomponent", InstallAddSubcomponent, 6},
{"DeleteComponent", InstallDeleteComponent, 1},
{"DeleteFile", InstallDeleteFile, 2},
{"DiskSpaceAvailable", InstallDiskSpaceAvailable, 1},
{"Execute", InstallExecute, 2},
{"FinalizeInstall", InstallFinalizeInstall, 0},
{"Gestalt", InstallGestalt, 1},
{"GetComponentFolder", InstallGetComponentFolder, 2},
{"GetFolder", InstallGetFolder, 2},
{"GetLastError", InstallGetLastError, 0},
{"GetWinProfile", InstallGetWinProfile, 2},
{"GetWinRegistry", InstallGetWinRegistry, 0},
{"LoadResources", InstallLoadResources, 1},
{"Patch", InstallPatch, 5},
{"ResetError", InstallResetError, 0},
{"SetPackageFolder", InstallSetPackageFolder, 1},
{"StartInstall", InstallStartInstall, 4},
{"Uninstall", InstallUninstall, 1},
{"DirCreate", InstallFileOpDirCreate, 1},
{"DirGetParent", InstallFileOpDirGetParent, 1},
{"DirRemove", InstallFileOpDirRemove, 2},
{"DirRename", InstallFileOpDirRename, 2},
{"FileCopy", InstallFileOpFileCopy, 2},
{"FileDelete", InstallFileOpFileRemove, 1},
{"FileExists", InstallFileOpFileExists, 1},
{"FileExecute", InstallFileOpFileExecute, 2},
{"FileGetNativeVersion", InstallFileOpFileGetNativeVersion, 1},
{"FileGetDiskSpaceAvailable", InstallFileOpFileGetDiskSpaceAvailable,1},
{"FileGetModDate", InstallFileOpFileGetModDate, 1},
{"FileGetSize", InstallFileOpFileGetSize, 1},
{"FileIsDirectory", InstallFileOpFileIsDirectory, 1},
{"FileIsFile", InstallFileOpFileIsFile, 1},
{"FileModDateChanged", InstallFileOpFileModDateChanged, 2},
{"FileMove", InstallFileOpFileMove, 2},
{"FileRename", InstallFileOpFileRename, 2},
{"FileWindowsShortcut", InstallFileOpFileWindowsShortcut, 7},
{"FileMacAlias", InstallFileOpFileMacAlias, 2},
{"FileUnixLink", InstallFileOpFileUnixLink, 2},
{"LogComment", InstallLogComment, 1},
{"Alert", InstallAlert, 1},
{"Confirm", InstallConfirm, 2},
{0}
};
@ -1940,6 +1903,7 @@ JSObject * InitXPInstallObjects(JSContext *jscontext,
nsIFile* jarfile,
const PRUnichar* url,
const PRUnichar* args,
PRUint32 flags,
nsIZipReader * theJARFile)
{
JSObject *installObject = nsnull;
@ -1976,6 +1940,7 @@ JSObject * InitXPInstallObjects(JSContext *jscontext,
nativeInstallObject->SetJarFileLocation(jarfile);
nativeInstallObject->SetInstallArguments(args);
nativeInstallObject->SetInstallURL(url);
nativeInstallObject->SetInstallFlags(flags);
JS_SetPrivate(jscontext, installObject, nativeInstallObject);
nativeInstallObject->SetScriptObject(installObject);

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

@ -31,6 +31,7 @@
#include "nsString.h"
#include "nsIDOMInstallVersion.h"
#include "nsIDOMInstallTriggerGlobal.h"
#include "nsInstallTrigger.h"
#include "nsXPITriggerInfo.h"
#include "nsRepository.h"
@ -236,6 +237,80 @@ InstallTriggerGlobalInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
return JS_FALSE;
}
//
// Native method InstallChrome
//
PR_STATIC_CALLBACK(JSBool)
InstallTriggerGlobalInstallChrome(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstallTriggerGlobal *nativeThis = (nsIDOMInstallTriggerGlobal*)JS_GetPrivate(cx, obj);
PRBool nativeRet;
PRUint32 chromeType;
nsAutoString baseURL;
nsAutoString sourceURL;
nsAutoString name;
*rval = JSVAL_FALSE;
if (nsnull == nativeThis && (JS_FALSE == CreateNativeObject(cx, obj, &nativeThis)) ) {
return JS_FALSE;
}
// make sure XPInstall is enabled, return if not
PRBool enabled = PR_FALSE;
nativeThis->UpdateEnabled(&enabled);
if (!enabled)
return JS_TRUE;
// get window.location to construct relative URLs
JSObject* global = JS_GetGlobalObject(cx);
if (global)
{
jsval v;
if (JS_GetProperty(cx,global,"location",&v))
{
ConvertJSValToStr( baseURL, cx, v );
PRInt32 lastslash = baseURL.RFindChar('/');
if (lastslash != kNotFound)
{
baseURL.Truncate(lastslash+1);
}
}
}
if ( argc >= 3 )
{
chromeType = JSVAL_TO_INT(argv[0]);
ConvertJSValToStr(sourceURL, cx, argv[1]);
ConvertJSValToStr(name, cx, argv[2]);
if ( chromeType == CHROMETYPE_SAFESKIN || chromeType == CHROMETYPE_LOCALE )
{
nsresult rv;
nsXPITriggerItem* item = new nsXPITriggerItem(name.GetUnicode(),
sourceURL.GetUnicode());
if (item && item->IsRelativeURL())
item->mURL.Insert( baseURL, 0 );
rv = nativeThis->InstallChrome(chromeType, item, &nativeRet);
if (NS_FAILED(rv))
return JS_FALSE;
*rval = BOOLEAN_TO_JSVAL(nativeRet);
}
}
return JS_TRUE;
}
//
// Native method StartSoftwareUpdate
//
@ -571,17 +646,19 @@ JSClass InstallTriggerGlobalClass = {
//
static JSFunctionSpec InstallTriggerGlobalMethods[] =
{
// -- obsolete forms, do not document. Kept for 4.x compatibility
{"UpdateEnabled", InstallTriggerGlobalUpdateEnabled, 0},
{"Install", InstallTriggerGlobalInstall, 2},
{"StartSoftwareUpdate", InstallTriggerGlobalStartSoftwareUpdate, 2},
{"ConditionalSoftwareUpdate", InstallTriggerGlobalConditionalSoftwareUpdate, 5},
{"CompareVersion", InstallTriggerGlobalCompareVersion, 5},
{"GetVersion", InstallTriggerGlobalGetVersion, 2},
// -- new forms to match JS style --
{"updateEnabled", InstallTriggerGlobalUpdateEnabled, 0},
{"install", InstallTriggerGlobalInstall, 2},
{"startSoftwareUpdate", InstallTriggerGlobalStartSoftwareUpdate, 2},
{"conditionalSoftwareUpdate", InstallTriggerGlobalConditionalSoftwareUpdate, 5},
// -- new forms to match JS style --
{"enabled", InstallTriggerGlobalUpdateEnabled, 0},
{"install", InstallTriggerGlobalInstall, 2},
{"installChrome", InstallTriggerGlobalInstallChrome, 2},
{"startSoftwareUpdate", InstallTriggerGlobalStartSoftwareUpdate, 2},
{"compareVersion", InstallTriggerGlobalCompareVersion, 5},
{"getVersion", InstallTriggerGlobalGetVersion, 2},
{0}
@ -595,6 +672,10 @@ static JSConstDoubleSpec diff_constants[] =
{ nsIDOMInstallTriggerGlobal::REL_DIFF, "REL_DIFF" },
{ nsIDOMInstallTriggerGlobal::BLD_DIFF, "BLD_DIFF" },
{ nsIDOMInstallTriggerGlobal::EQUAL, "EQUAL" },
{ CHROMETYPE_SAFESKIN, "THEME" },
{ CHROMETYPE_LOCALE, "LOCALE" },
{ CHROMETYPE_SCRIPTSKIN, "SUPERSKIN" },
{ CHROMETYPE_PACKAGE, "PACKAGE" },
{0}
};

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

@ -53,14 +53,14 @@
static NS_DEFINE_CID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
extern JSObject *InitXPInstallObjects(JSContext *jscontext, JSObject *global, nsIFile* jarfile, const PRUnichar* url, const PRUnichar* args, nsIZipReader* hZip);
extern JSObject *InitXPInstallObjects(JSContext *jscontext, JSObject *global, nsIFile* jarfile, const PRUnichar* url, const PRUnichar* args, PRUint32 flags, nsIZipReader* hZip);
extern nsresult InitInstallVersionClass(JSContext *jscontext, JSObject *global, void** prototype);
extern nsresult InitInstallTriggerGlobalClass(JSContext *jscontext, JSObject *global, void** prototype);
// Defined in this file:
static void XPInstallErrorReporter(JSContext *cx, const char *message, JSErrorReport *report);
static PRInt32 GetInstallScriptFromJarfile(nsIZipReader* hZip, nsIFile* jarFile, char** scriptBuffer, PRUint32 *scriptLength);
static nsresult SetupInstallContext(nsIZipReader* hZip, nsIFile* jarFile, const PRUnichar* url, const PRUnichar* args, JSRuntime *jsRT, JSContext **jsCX, JSObject **jsGlob);
static nsresult SetupInstallContext(nsIZipReader* hZip, nsIFile* jarFile, const PRUnichar* url, const PRUnichar* args, PRUint32 flags, JSRuntime *jsRT, JSContext **jsCX, JSObject **jsGlob);
extern "C" void RunInstallOnThread(void *data);
@ -246,6 +246,7 @@ GetInstallScriptFromJarfile(nsIZipReader* hZip, nsIFile* jarFile, char** scriptB
// Argument : const char* jarFile - native filepath to where jar exists on disk
// Argument : const PRUnichar* url - URL of where this package came from
// Argument : const PRUnichar* args - any arguments passed into the javascript context
// Argument : PRUint32 flags - bitmask of flags passed in
// Argument : JSRuntime *jsRT - A valid JS Runtime
// Argument : JSContext **jsCX - Created context, destroy via JS_DestroyContext
// Argument : JSObject **jsGlob - created global object
@ -254,6 +255,7 @@ static nsresult SetupInstallContext(nsIZipReader* hZip,
nsIFile* jarFile,
const PRUnichar* url,
const PRUnichar* args,
PRUint32 flags,
JSRuntime *rt,
JSContext **jsCX,
JSObject **jsGlob)
@ -276,7 +278,7 @@ static nsresult SetupInstallContext(nsIZipReader* hZip,
JS_SetErrorReporter(cx, XPInstallErrorReporter);
glob = InitXPInstallObjects(cx, nsnull, jarFile, url, args, hZip);
glob = InitXPInstallObjects(cx, nsnull, jarFile, url, args, flags, hZip);
// Init standard classes
JS_InitStandardClasses(cx, glob);
@ -403,12 +405,13 @@ extern "C" void RunInstallOnThread(void *data)
// service not available (wizard context?)
// create our own runtime
ownRuntime = PR_TRUE;
rt = JS_Init(4L * 1024L * 1024L);
rt = JS_Init(4L * 1024L * 1024L);
}
rv = SetupInstallContext( hZip, jarpath,
url.GetUnicode(),
args.GetUnicode(),
installInfo->GetFlags(),
rt, &cx, &glob);
if (NS_SUCCEEDED(rv))

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

@ -42,9 +42,11 @@
#include "nsISoftwareUpdate.h"
#include "nsSoftwareUpdateIIDs.h"
#include "nsTextFormatter.h"
#include "nsXPITriggerInfo.h"
#include "nsXPInstallManager.h"
#include "nsInstallTrigger.h"
#include "nsInstallProgressDialog.h"
#include "nsInstallResources.h"
#include "nsSpecialSystemDirectory.h"
@ -54,6 +56,7 @@
#include "nsDirectoryService.h"
#include "nsIAppShellComponentImpl.h"
#include "nsINetSupportDialogService.h"
#include "nsIPrompt.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
@ -62,16 +65,16 @@ static NS_DEFINE_IID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
static NS_DEFINE_IID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID);
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
#include "nsIEventQueueService.h"
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
#define XPINSTALL_BUNDLE_URL "chrome://communicator/locale/xpinstall/xpinstall.properties"
nsXPInstallManager::nsXPInstallManager()
: mTriggers(0), mItem(0), mNextItem(0), mNumJars(0),
mFinalizing(PR_FALSE), mCancelled(PR_FALSE), mContentLength(0)
mFinalizing(PR_FALSE), mCancelled(PR_FALSE), mChromeType(0),
mSelectChrome(PR_TRUE), mContentLength(0)
{
NS_INIT_ISUPPORTS();
@ -142,13 +145,14 @@ nsXPInstallManager::QueryInterface(REFNSIID aIID,void** aInstancePtr)
NS_IMETHODIMP
nsXPInstallManager::InitManager(nsXPITriggerInfo* aTriggers)
nsXPInstallManager::InitManager(nsXPITriggerInfo* aTriggers, PRUint32 aChromeType)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIDialogParamBlock> ioParamBlock;
PRBool OKtoInstall = PR_FALSE;
mTriggers = aTriggers;
mChromeType = aChromeType;
if ( !mTriggers || mTriggers->Size() == 0 )
{
@ -172,48 +176,10 @@ nsXPInstallManager::InitManager(nsXPITriggerInfo* aTriggers)
LoadDialogWithNames(ioParamBlock);
// Now do the stuff to create a window and pass the JS args to it.
NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv );
if ( NS_SUCCEEDED( rv ) )
{
nsCOMPtr<nsIDOMWindow> hiddenWindow;
JSContext* jsContext;
rv = appShell->GetHiddenWindowAndJSContext( getter_AddRefs(hiddenWindow), &jsContext);
if (NS_SUCCEEDED(rv))
{
void* stackPtr;
jsval *argv = JS_PushArguments( jsContext,
&stackPtr,
"sss%ip",
"chrome://communicator/content/xpinstall/institems.xul",
"_blank",
"chrome,modal",
(const nsIID*)(&NS_GET_IID(nsIDialogParamBlock)),
(nsISupports*)ioParamBlock);
if (argv)
{
nsCOMPtr<nsIDOMWindow> newWindow;
rv = hiddenWindow->OpenDialog( jsContext,
argv,
4,
getter_AddRefs( newWindow));
if (NS_SUCCEEDED(rv))
{
JS_PopArguments( jsContext, stackPtr);
//Now get which button was pressed from the ParamBlock
PRInt32 buttonPressed = 0;
ioParamBlock->GetInt( 0, &buttonPressed );
OKtoInstall = buttonPressed ? PR_FALSE : PR_TRUE;
}
}
else
{
rv = NS_ERROR_FAILURE; // fix, better error code??
}
}
}
if (mChromeType == 0 || mChromeType > CHROMETYPE_SAFEMAX )
OKtoInstall = ConfirmInstall(ioParamBlock);
else
OKtoInstall = ConfirmChromeInstall();
}
// --- create and open the progress dialog
@ -270,6 +236,114 @@ nsXPInstallManager::InitManager(nsXPITriggerInfo* aTriggers)
return rv;
}
PRBool nsXPInstallManager::ConfirmInstall(nsIDialogParamBlock* ioParamBlock)
{
nsresult rv = NS_OK;
PRBool result = PR_FALSE;
// create a window and pass the JS args to it.
NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv );
if ( NS_SUCCEEDED( rv ) )
{
nsCOMPtr<nsIDOMWindow> hiddenWindow;
JSContext* jsContext;
rv = appShell->GetHiddenWindowAndJSContext( getter_AddRefs(hiddenWindow), &jsContext);
if (NS_SUCCEEDED(rv))
{
void* stackPtr;
jsval *argv = JS_PushArguments( jsContext,
&stackPtr,
"sss%ip",
"chrome://communicator/content/xpinstall/institems.xul",
"_blank",
"chrome,modal",
(const nsIID*)(&NS_GET_IID(nsIDialogParamBlock)),
(nsISupports*)ioParamBlock);
if (argv)
{
nsCOMPtr<nsIDOMWindow> newWindow;
rv = hiddenWindow->OpenDialog( jsContext,
argv,
4,
getter_AddRefs( newWindow));
if (NS_SUCCEEDED(rv))
{
JS_PopArguments( jsContext, stackPtr);
//Now get which button was pressed from the ParamBlock
PRInt32 buttonPressed = 0;
ioParamBlock->GetInt( 0, &buttonPressed );
result = buttonPressed ? PR_FALSE : PR_TRUE;
}
}
}
}
return result;
}
PRBool nsXPInstallManager::ConfirmChromeInstall()
{
nsXPITriggerItem* item = (nsXPITriggerItem*)mTriggers->Get(0);
// get the dialog strings
nsresult rv;
nsXPIDLString applyNowText;
nsXPIDLString confirmFormat;
PRUnichar* confirmText = nsnull;
nsCOMPtr<nsIStringBundle> xpiBundle;
NS_WITH_SERVICE( nsIStringBundleService, bundleSvc,
kStringBundleServiceCID, &rv );
if (NS_SUCCEEDED(rv) && bundleSvc)
{
rv = bundleSvc->CreateBundle( XPINSTALL_BUNDLE_URL, nsnull,
getter_AddRefs(xpiBundle) );
if (NS_SUCCEEDED(rv) && xpiBundle)
{
if ( mChromeType == CHROMETYPE_LOCALE )
{
xpiBundle->GetStringFromName(
NS_ConvertASCIItoUCS2("ApplyNowLocale").GetUnicode(),
getter_Copies(applyNowText));
xpiBundle->GetStringFromName(
NS_ConvertASCIItoUCS2("ConfirmLocale").GetUnicode(),
getter_Copies(confirmFormat));
}
else
{
xpiBundle->GetStringFromName(
NS_ConvertASCIItoUCS2("ApplyNowSkin").GetUnicode(),
getter_Copies(applyNowText));
xpiBundle->GetStringFromName(
NS_ConvertASCIItoUCS2("ConfirmSkin").GetUnicode(),
getter_Copies(confirmFormat));
}
confirmText = nsTextFormatter::smprintf(confirmFormat,
item->mName.GetUnicode(),
item->mURL.GetUnicode());
}
}
// confirmation dialog
PRBool bInstall = PR_FALSE;
if (confirmText)
{
NS_WITH_SERVICE(nsIPrompt, dlgService, kNetSupportDialogCID, &rv);
if (NS_SUCCEEDED(rv))
{
rv = dlgService->ConfirmCheck( confirmText,
applyNowText,
&mSelectChrome,
&bInstall );
}
}
return bInstall;
}
NS_IMETHODIMP nsXPInstallManager::DialogOpened(nsISupports* aWindow)
{
@ -430,10 +504,6 @@ void nsXPInstallManager::Shutdown()
// proxy exists: we're being called from script thread
mProxy->Close();
}
// else if (mDlg)
// mDlg->Close();
// mDlg = 0;
// Clean up downloaded files
nsXPITriggerItem* item;

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

@ -63,7 +63,7 @@ class nsXPInstallManager : public nsIXPINotifier,
NS_DECL_ISUPPORTS
NS_IMETHOD InitManager( nsXPITriggerInfo* aTrigger );
NS_IMETHOD InitManager( nsXPITriggerInfo* aTrigger, PRUint32 chromeType );
// nsIStreamObserver
NS_DECL_NSISTREAMOBSERVER
@ -88,6 +88,8 @@ class nsXPInstallManager : public nsIXPINotifier,
NS_IMETHOD DownloadNext();
void Shutdown();
void LoadDialogWithNames(nsIDialogParamBlock* ioParamBlock);
PRBool ConfirmInstall(nsIDialogParamBlock* ioParamBlock);
PRBool ConfirmChromeInstall();
nsXPITriggerInfo* mTriggers;
nsXPITriggerItem* mItem;
@ -95,6 +97,8 @@ class nsXPInstallManager : public nsIXPINotifier,
PRInt32 mNumJars;
PRBool mFinalizing;
PRBool mCancelled;
PRUint32 mChromeType;
PRBool mSelectChrome;
PRInt32 mContentLength;
nsCOMPtr<nsIXPIProgressDlg> mProxy;