Skin/Locale installer (bug 32688) and groundwork for bug 32689

This commit is contained in:
dveditz%netscape.com 2000-05-05 06:23:11 +00:00
Родитель 6739b1e075
Коммит 0f49543379
28 изменённых файлов: 545 добавлений и 325 удалений

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

@ -64,15 +64,22 @@ class nsISoftwareUpdate : public nsISupports
NS_IMETHOD InstallJar(nsIFile* localFile,
const PRUnichar* URL,
const PRUnichar* arguments,
long flags,
nsIXPINotifier* notifier = 0) = 0;
PRUint32 flags,
nsIXPIListener* aListener = 0) = 0;
NS_IMETHOD InstallChrome(PRUint32 aType,
nsIFile* aFile,
const PRUnichar* URL,
const PRUnichar* aName,
PRBool aSelect,
nsIXPIListener* aListener = 0) = 0;
NS_IMETHOD RegisterNotifier(nsIXPINotifier *notifier) = 0;
NS_IMETHOD RegisterListener(nsIXPIListener *aListener) = 0;
/* FIX: these should be in a private interface */
NS_IMETHOD InstallJarCallBack() = 0;
NS_IMETHOD GetMasterNotifier(nsIXPINotifier **notifier) = 0;
NS_IMETHOD SetActiveNotifier(nsIXPINotifier *notifier) = 0;
NS_IMETHOD GetMasterListener(nsIXPIListener **aListener) = 0;
NS_IMETHOD SetActiveListener(nsIXPIListener *aListener) = 0;
NS_IMETHOD StartupTasks( PRBool* outAutoreg ) = 0;
};

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

@ -15,7 +15,7 @@
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Copyright (C) 2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
@ -26,7 +26,7 @@
#include "nsISupports.idl"
[uuid(eea90d40-b059-11d2-915e-c12b696c9333)]
interface nsIXPINotifier : nsISupports
interface nsIXPIListener : nsISupports
{
void BeforeJavascriptEvaluation(in wstring URL);
void AfterJavascriptEvaluation(in wstring URL);

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

@ -100,37 +100,31 @@ static NS_DEFINE_IID(kIStringBundleServiceIID, NS_ISTRINGBUNDLESERVICE_IID);
MOZ_DECL_CTOR_COUNTER(nsInstallInfo);
nsInstallInfo::nsInstallInfo(nsIFile* aFile,
const PRUnichar* aURL,
const PRUnichar* aArgs,
PRUint32 flags,
nsIXPINotifier* aNotifier)
: mError(0),
nsInstallInfo::nsInstallInfo(PRUint32 aInstallType,
nsIFile* aFile,
const PRUnichar* aURL,
const PRUnichar* aArgs,
PRUint32 flags,
nsIXPIListener* aListener,
nsIChromeRegistry* aChromeReg)
: mError(0),
mType(aInstallType),
mFlags(flags),
mURL(aURL),
mArgs(aArgs),
mFile(aFile),
mNotifier(aNotifier)
mListener(aListener),
mChromeReg(aChromeReg)
{
MOZ_COUNT_CTOR(nsInstallInfo);
}
nsInstallInfo::~nsInstallInfo()
{
MOZ_COUNT_DTOR(nsInstallInfo);
}
nsresult
nsInstallInfo::GetLocalFile(nsIFile** aSpec)
{
if (!mFile)
return NS_ERROR_NULL_POINTER;
return mFile->Clone(getter_AddRefs(aSpec));
}
static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
@ -170,7 +164,7 @@ nsInstall::nsInstall(nsIZipReader * theJARFile)
if (NS_SUCCEEDED(rv))
{
su->GetMasterNotifier( &mNotifier );
su->GetMasterListener( &mListener );
}
su->Release();
@ -254,9 +248,9 @@ nsInstall::GetRegPackageName(nsString& aRegPackageName)
void
nsInstall::InternalAbort(PRInt32 errcode)
{
if (mNotifier)
if (mListener)
{
mNotifier->FinalStatus(mInstallURL.GetUnicode(), errcode);
mListener->FinalStatus(mInstallURL.GetUnicode(), errcode);
mStatusSent = PR_TRUE;
}
@ -785,9 +779,9 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
if (*aReturn != nsInstall::SUCCESS)
{
SaveError( *aReturn );
if (mNotifier)
if (mListener)
{
mNotifier->FinalStatus(mInstallURL.GetUnicode(), *aReturn);
mListener->FinalStatus(mInstallURL.GetUnicode(), *aReturn);
mStatusSent = PR_TRUE;
}
return NS_OK;
@ -850,12 +844,12 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
}
}
if (mNotifier)
if (mListener)
{
char *objString = ie->toString();
if (objString)
{
mNotifier->FinalizeProgress(NS_ConvertASCIItoUCS2(objString).GetUnicode(),
mListener->FinalizeProgress(NS_ConvertASCIItoUCS2(objString).GetUnicode(),
(i+1), mInstalledFiles->Count());
delete [] objString;
}
@ -884,9 +878,9 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
else
*aReturn = SaveError( result );
if (mNotifier)
if (mListener)
{
mNotifier->FinalStatus(mInstallURL.GetUnicode(), *aReturn);
mListener->FinalStatus(mInstallURL.GetUnicode(), *aReturn);
mStatusSent = PR_TRUE;
}
}
@ -896,9 +890,9 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
// no actions queued: don't register the package version
// and no need for user confirmation
if (mNotifier)
if (mListener)
{
mNotifier->FinalStatus(mInstallURL.GetUnicode(), *aReturn);
mListener->FinalStatus(mInstallURL.GetUnicode(), *aReturn);
mStatusSent = PR_TRUE;
}
}
@ -1489,8 +1483,8 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aRegis
return SaveError(nsInstall::OUT_OF_MEMORY);
}
if (mNotifier)
mNotifier->InstallStarted(mInstallURL.GetUnicode(), mUIName.GetUnicode());
if (mListener)
mListener->InstallStarted(mInstallURL.GetUnicode(), mUIName.GetUnicode());
mStartInstallCompleted = PR_TRUE;
return NS_OK;
@ -2023,8 +2017,8 @@ nsInstall::FileOpFileUnixLink(nsInstallFolder& aTarget, PRInt32 aFlags, PRInt32*
void
nsInstall::LogComment(nsString& aComment)
{
if(mNotifier)
mNotifier->LogComment(aComment.GetUnicode());
if(mListener)
mListener->LogComment(aComment.GetUnicode());
}
/////////////////////////////////////////////////////////////////////////
@ -2046,8 +2040,8 @@ nsInstall::ScheduleForInstall(nsInstallObject* ob)
// flash current item
if (mNotifier)
mNotifier->ItemScheduled(NS_ConvertASCIItoUCS2(objString).GetUnicode());
if (mListener)
mListener->ItemScheduled(NS_ConvertASCIItoUCS2(objString).GetUnicode());
// do any unpacking or other set-up
@ -2067,7 +2061,7 @@ nsInstall::ScheduleForInstall(nsInstallObject* ob)
if (ob->RegisterPackageNode())
mRegisterPackage = PR_TRUE;
}
else if ( mNotifier )
else if ( mListener )
{
// error in preparation step -- log it
char* errRsrc = GetResourcedString(NS_ConvertASCIItoUCS2("ERROR"));
@ -2077,7 +2071,7 @@ nsInstall::ScheduleForInstall(nsInstallObject* ob)
nsString errstr; errstr.AssignWithConversion(errprefix);
errstr.AppendWithConversion(objString);
mNotifier->LogComment( errstr.GetUnicode() );
mListener->LogComment( errstr.GetUnicode() );
PR_smprintf_free(errprefix);
nsCRT::free(errRsrc);
@ -2318,14 +2312,6 @@ nsInstall::CleanUp(void)
}
void
nsInstall::GetJarFileLocation(nsString& aFile)
{
char* temp;
mJarFileLocation->GetPath(&temp);
aFile.AssignWithConversion(temp);
}
void
nsInstall::SetJarFileLocation(nsIFile* aFile)
{

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

@ -57,6 +57,7 @@
#include "nsIPersistentProperties2.h"
#include "nsIEnumerator.h"
#include "nsIZipReader.h"
#include "nsIChromeRegistry.h"
#define XPINSTALL_BUNDLE_URL "chrome://communicator/locale/xpinstall/xpinstall.properties"
@ -64,34 +65,36 @@ class nsInstallInfo
{
public:
nsInstallInfo( nsIFile* aFile,
nsInstallInfo( PRUint32 aInstallType,
nsIFile* aFile,
const PRUnichar* aURL,
const PRUnichar* aArgs,
PRUint32 aFlags,
nsIXPINotifier* aNotifier);
nsIXPIListener* aListener,
nsIChromeRegistry* aChromeReg);
virtual ~nsInstallInfo();
nsresult GetLocalFile(nsIFile** aSpec);
void GetURL(nsString& aURL) { aURL = mURL; }
void GetArguments(nsString& aArgs) { aArgs = mArgs; }
PRUint32 GetFlags() { return mFlags; }
nsIXPINotifier* GetNotifier() { return mNotifier; };
nsIFile* GetFile() { return mFile; }
const PRUnichar* GetURL() { return mURL.GetUnicode(); }
const PRUnichar* GetArguments() { return mArgs.GetUnicode(); }
PRUint32 GetFlags() { return mFlags; }
PRUint32 GetType() { return mType; }
nsIXPIListener* GetListener() { return mListener; }
nsIChromeRegistry* GetChromeRegistry() { return mChromeReg; }
private:
nsresult mError;
PRUint32 mType;
PRUint32 mFlags;
nsString mURL;
nsString mArgs;
nsCOMPtr<nsIFile> mFile;
nsCOMPtr<nsIXPINotifier> mNotifier;
nsCOMPtr<nsIXPIListener> mListener;
nsCOMPtr<nsIChromeRegistry> mChromeReg;
};
#ifdef XP_PC
@ -251,7 +254,7 @@ class nsInstall
void AddPatch(nsHashKey *aKey, nsIFile* fileName);
void GetPatch(nsHashKey *aKey, nsIFile** fileName);
void GetJarFileLocation(nsString& aFile);
nsIFile* GetJarFileLocation() { return mJarFileLocation; }
void SetJarFileLocation(nsIFile* aFile);
void GetInstallArguments(nsString& args);
@ -304,7 +307,7 @@ class nsInstall
//nsCOMPtr<nsISupportsArray> mInstalledFiles;
nsHashtable* mPatchList;
nsIXPINotifier *mNotifier;
nsIXPIListener *mListener;
nsCOMPtr<nsIStringBundle> mStringBundle;

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

@ -92,6 +92,13 @@ nsInstallFolder::nsInstallFolder()
MOZ_COUNT_CTOR(nsInstallFolder);
}
nsresult
nsInstallFolder::Init(nsIFile* rawIFile)
{
mFileSpec = rawIFile;
return NS_OK;
}
nsresult
nsInstallFolder::Init(const nsString& aFolderID, const nsString& aRelativePath)
{

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

@ -39,9 +39,11 @@ class nsInstallFolder
public:
nsInstallFolder();
virtual ~nsInstallFolder();
nsresult Init(nsInstallFolder& inFolder, const nsString& subString);
nsresult Init(const nsString& aFolderID, const nsString& aRelativePath);
virtual ~nsInstallFolder();
nsresult Init(nsIFile* rawIFile);
void GetDirectoryPath(nsString& aDirectoryPath);
nsIFile* GetFileSpec();
@ -54,7 +56,6 @@ class nsInstallFolder
void SetDirectoryPath(const nsString& aFolderID, const nsString& aRelativePath);
void PickDefaultDirectory();
PRInt32 MapNameToEnum(const nsString& name);
void SetAppShellDirectory(PRUint32 value);
};

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

@ -24,7 +24,6 @@
*/
#include "nsIXPINotifier.h"
#include "nsInstallProgressDialog.h"
#include "nsIAppShellComponentImpl.h"
@ -72,8 +71,8 @@ nsInstallProgressDialog::QueryInterface(REFNSIID aIID,void** aInstancePtr)
// Always NULL result, in case of failure
*aInstancePtr = NULL;
if (aIID.Equals(NS_GET_IID(nsIXPINotifier))) {
*aInstancePtr = (void*) ((nsIXPINotifier*)this);
if (aIID.Equals(NS_GET_IID(nsIXPIListener))) {
*aInstancePtr = (void*) ((nsIXPIListener*)this);
NS_ADDREF_THIS();
return NS_OK;
}
@ -83,7 +82,7 @@ nsInstallProgressDialog::QueryInterface(REFNSIID aIID,void** aInstancePtr)
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*) (nsISupports*)((nsIXPINotifier*)this);
*aInstancePtr = (void*) (nsISupports*)((nsIXPIListener*)this);
NS_ADDREF_THIS();
return NS_OK;
}

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

@ -42,7 +42,7 @@
#include "nsIDOMXULDocument.h"
class nsInstallProgressDialog : public nsIXPINotifier,
class nsInstallProgressDialog : public nsIXPIListener,
public nsIXPIProgressDlg
{
public:
@ -52,8 +52,8 @@ class nsInstallProgressDialog : public nsIXPINotifier,
NS_DECL_ISUPPORTS
// implement nsIXPINotifier
NS_DECL_NSIXPINOTIFIER
// implement nsIXPIListener
NS_DECL_NSIXPILISTENER
// implement nsIXPIProgressDlg
NS_DECL_NSIXPIPROGRESSDLG

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

@ -480,6 +480,7 @@ nsInstallTrigger::GetVersion(const nsString& component, nsString& version)
}
#if 0
// this will take a nsIURI, and create a temporary file. If it is local, we just us it.
void
@ -523,5 +524,5 @@ nsInstallTrigger::CreateTempFileFromURL(const nsString& aURL, nsString& tempFile
tempFileString.AssignWithConversion( NS_STATIC_CAST(const char*, nsNSPRPath( nsFilePath(tempFile) )) );
}
}
#endif

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

@ -14,11 +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
#define CHROME_SKIN 1
#define CHROME_LOCALE 2
#define CHROME_SAFEMAX CHROME_LOCALE
#define CHROME_CONTENT 4
#define CHROME_ALL 7
class nsInstallTrigger: public nsIScriptObjectOwner, public nsIDOMInstallTriggerGlobal
@ -52,8 +52,6 @@ class nsInstallTrigger: public nsIScriptObjectOwner, public nsIDOMInstallTrigger
private:
void *mScriptObject;
void CreateTempFileFromURL(const nsString& aURL, nsString& tempFileString);
};
#define NS_INSTALLTRIGGERCOMPONENT_PROGID NS_IXPINSTALLCOMPONENT_PROGID "/installtrigger"

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

@ -326,7 +326,7 @@ nsInstallVersion::StringToVersionNumbers(const nsString& version, PRInt32 *aMajo
*aRelease = releaseStr.ToInteger(&errorCode);
prev = dot+1;
if ( version.Length() > dot )
if ( (int)version.Length() > dot )
{
nsString buildStr;
version.Mid(buildStr, prev, version.Length() - prev);

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

@ -119,17 +119,27 @@ GetInstallProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
case INSTALL_JARFILE:
{
nsAutoString prop;
a->GetJarFileLocation(prop);
*vp = STRING_TO_JSVAL( JS_NewUCStringCopyN(cx, prop.GetUnicode(), prop.Length()) );
nsInstallFolder* folder = new nsInstallFolder();
if ( folder )
{
folder->Init(a->GetJarFileLocation());
JSObject* fileSpecObject =
JS_NewObject(cx, &FileSpecObjectClass, gFileSpecProto, NULL);
if (fileSpecObject)
{
JS_SetPrivate(cx, fileSpecObject, folder);
*vp = OBJECT_TO_JSVAL(fileSpecObject);
}
else
delete folder;
}
break;
}
case INSTALL_ARGUMENTS:
{
nsString prop;
nsAutoString prop;
a->GetInstallArguments(prop);
*vp = STRING_TO_JSVAL( JS_NewUCStringCopyN(cx, prop.GetUnicode(), prop.Length()) );
@ -1437,6 +1447,24 @@ InstallPatch(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return JS_TRUE;
}
//
// Native method RegisterChrome
//
PR_STATIC_CALLBACK(JSBool)
InstallRegisterChrome(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
*rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
// If there's no private data, this must be the prototype, so ignore
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
if (nsnull == nativeThis) {
return JS_TRUE;
}
PRUint32 installType = 0;
nsIFile* chrome = nsnull;
}
//
// Native method ResetError
@ -1449,26 +1477,8 @@ InstallResetError(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
*rval = JSVAL_VOID;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if(argc >= 0)
{
// public int ResetError (void);
if(NS_OK != nativeThis->ResetError())
{
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else
{
JS_ReportError(cx, "Function ResetError requires 0 parameters");
return JS_FALSE;
}
if (nativeThis)
nativeThis->ResetError();
return JS_TRUE;
}
@ -1860,12 +1870,12 @@ static JSFunctionSpec InstallMethods[] =
{"logComment", InstallLogComment, 1},
{"patch", InstallPatch, 5},
{"performInstall", InstallFinalizeInstall, 0},
{"registerChrome", InstallRegisterChrome, 2},
{"resetError", InstallResetError, 0},
{"setPackageFolder", InstallSetPackageFolder, 1},
{"uninstall", InstallUninstall, 1},
// -- new forms for the file/dir methods --
// (Access via Install object is deprecated)
// the raw file methods are deprecated, use the File object instead
{"dirCreate", InstallFileOpDirCreate, 1},
{"dirGetParent", InstallFileOpDirGetParent, 1},
{"dirRemove", InstallFileOpDirRemove, 2},

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

@ -246,7 +246,7 @@ InstallTriggerGlobalInstallChrome(JSContext *cx, JSObject *obj, uintN argc, jsva
{
nsIDOMInstallTriggerGlobal *nativeThis = (nsIDOMInstallTriggerGlobal*)JS_GetPrivate(cx, obj);
PRBool nativeRet;
PRUint32 chromeType;
uint32 chromeType;
nsAutoString baseURL;
nsAutoString sourceURL;
nsAutoString name;
@ -282,25 +282,22 @@ InstallTriggerGlobalInstallChrome(JSContext *cx, JSObject *obj, uintN argc, jsva
}
if ( argc >= 3 )
{
chromeType = JSVAL_TO_INT(argv[0]);
JS_ValueToECMAUint32(cx, argv[0], &chromeType);
ConvertJSValToStr(sourceURL, cx, argv[1]);
ConvertJSValToStr(name, cx, argv[2]);
if ( chromeType == CHROMETYPE_SAFESKIN || chromeType == CHROMETYPE_LOCALE )
if ( chromeType & CHROME_ALL )
{
nsresult rv;
// there's at least one known chrome type
nsXPITriggerItem* item = new nsXPITriggerItem(name.GetUnicode(),
sourceURL.GetUnicode());
if (item && item->IsRelativeURL())
item->mURL.Insert( baseURL, 0 );
rv = nativeThis->InstallChrome(chromeType, item, &nativeRet);
nsresult rv = nativeThis->InstallChrome(chromeType, item, &nativeRet);
if (NS_FAILED(rv))
return JS_FALSE;
@ -672,10 +669,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" },
{ CHROME_SKIN, "SKIN" },
{ CHROME_LOCALE, "LOCALE" },
{ CHROME_CONTENT, "CONTENT" },
{ CHROME_ALL, "PACKAGE" },
{0}
};

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

@ -23,7 +23,6 @@
* Pierre Phaneuf <pp@ludusdesign.com>
*/
#include "nsIXPINotifier.h"
#include "nsLoggingProgressNotifier.h"
#include "nsInstall.h"
@ -36,13 +35,13 @@
nsLoggingProgressNotifier::nsLoggingProgressNotifier()
nsLoggingProgressListener::nsLoggingProgressListener()
: mLogStream(0)
{
NS_INIT_ISUPPORTS();
}
nsLoggingProgressNotifier::~nsLoggingProgressNotifier()
nsLoggingProgressListener::~nsLoggingProgressListener()
{
if (mLogStream)
{
@ -53,10 +52,10 @@ nsLoggingProgressNotifier::~nsLoggingProgressNotifier()
}
}
NS_IMPL_ISUPPORTS(nsLoggingProgressNotifier, NS_GET_IID(nsIXPINotifier));
NS_IMPL_ISUPPORTS(nsLoggingProgressListener, NS_GET_IID(nsIXPIListener));
NS_IMETHODIMP
nsLoggingProgressNotifier::BeforeJavascriptEvaluation(const PRUnichar *URL)
nsLoggingProgressListener::BeforeJavascriptEvaluation(const PRUnichar *URL)
{
nsSpecialSystemDirectory logFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
#ifdef XP_MAC
@ -84,7 +83,7 @@ nsLoggingProgressNotifier::BeforeJavascriptEvaluation(const PRUnichar *URL)
}
NS_IMETHODIMP
nsLoggingProgressNotifier::AfterJavascriptEvaluation(const PRUnichar *URL)
nsLoggingProgressListener::AfterJavascriptEvaluation(const PRUnichar *URL)
{
if (mLogStream == nsnull) return NS_ERROR_NULL_POINTER;
@ -104,7 +103,7 @@ nsLoggingProgressNotifier::AfterJavascriptEvaluation(const PRUnichar *URL)
}
NS_IMETHODIMP
nsLoggingProgressNotifier::InstallStarted(const PRUnichar *URL, const PRUnichar* UIPackageName)
nsLoggingProgressListener::InstallStarted(const PRUnichar *URL, const PRUnichar* UIPackageName)
{
if (mLogStream == nsnull) return NS_ERROR_NULL_POINTER;
@ -130,13 +129,13 @@ nsLoggingProgressNotifier::InstallStarted(const PRUnichar *URL, const PRUnichar*
}
NS_IMETHODIMP
nsLoggingProgressNotifier::ItemScheduled(const PRUnichar* message )
nsLoggingProgressListener::ItemScheduled(const PRUnichar* message )
{
return NS_OK;
}
NS_IMETHODIMP
nsLoggingProgressNotifier::FinalizeProgress(const PRUnichar* message, PRInt32 itemNum, PRInt32 totNum )
nsLoggingProgressListener::FinalizeProgress(const PRUnichar* message, PRInt32 itemNum, PRInt32 totNum )
{
if (mLogStream == nsnull) return NS_ERROR_NULL_POINTER;
@ -145,7 +144,7 @@ nsLoggingProgressNotifier::FinalizeProgress(const PRUnichar* message, PRInt32 it
}
NS_IMETHODIMP
nsLoggingProgressNotifier::FinalStatus(const PRUnichar *URL, PRInt32 status)
nsLoggingProgressListener::FinalStatus(const PRUnichar *URL, PRInt32 status)
{
if (mLogStream == nsnull) return NS_ERROR_NULL_POINTER;
@ -178,7 +177,7 @@ nsLoggingProgressNotifier::FinalStatus(const PRUnichar *URL, PRInt32 status)
}
void
nsLoggingProgressNotifier::GetTime(char** aString)
nsLoggingProgressListener::GetTime(char** aString)
{
PRExplodedTime et;
char line[256];
@ -188,7 +187,7 @@ nsLoggingProgressNotifier::GetTime(char** aString)
}
NS_IMETHODIMP
nsLoggingProgressNotifier::LogComment(const PRUnichar* comment)
nsLoggingProgressListener::LogComment(const PRUnichar* comment)
{
if (mLogStream == nsnull) return NS_ERROR_NULL_POINTER;

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

@ -31,17 +31,17 @@
#include "nsFileStream.h"
class nsLoggingProgressNotifier : public nsIXPINotifier
class nsLoggingProgressListener : public nsIXPIListener
{
public:
nsLoggingProgressNotifier();
virtual ~nsLoggingProgressNotifier();
nsLoggingProgressListener();
virtual ~nsLoggingProgressListener();
NS_DECL_ISUPPORTS
// nsIXPINotifier interfaces
NS_DECL_NSIXPINOTIFIER
// nsIXPIListener interfaces
NS_DECL_NSIXPILISTENER
private:
void GetTime(char** aString);

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

@ -65,7 +65,10 @@
#include "nsIEventQueueService.h"
#include "nsProxyObjectManager.h"
#include "nsProxiedService.h"
#include "nsIChromeRegistry.h"
extern "C" void RunChromeInstallOnThread(void *data);
////////////////////////////////////////////////////////////////////////////////
// Globals
@ -88,6 +91,7 @@ static NS_DEFINE_CID(kInstallTrigger_CID, NS_SoftwareUpdateInstallTrigger_CID);
static NS_DEFINE_IID(kIInstallVersion_IID, NS_IDOMINSTALLVERSION_IID);
static NS_DEFINE_CID(kInstallVersion_CID, NS_SoftwareUpdateInstallVersion_CID);
static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID);
static NS_DEFINE_CID(knsRegistryCID, NS_REGISTRY_CID);
nsSoftwareUpdate* nsSoftwareUpdate::mInstance = nsnull;
@ -246,8 +250,8 @@ nsSoftwareUpdate::Initialize( nsIAppShellService *anAppShell, nsICmdLineService
/* Create a top level observer */
/***************************************/
nsLoggingProgressNotifier *logger = new nsLoggingProgressNotifier();
RegisterNotifier(logger);
nsLoggingProgressListener *logger = new nsLoggingProgressListener();
RegisterListener(logger);
#if NOTIFICATION_ENABLE
/***************************************/
@ -281,33 +285,33 @@ nsSoftwareUpdate::Shutdown()
NS_IMETHODIMP
nsSoftwareUpdate::RegisterNotifier(nsIXPINotifier *notifier)
nsSoftwareUpdate::RegisterListener(nsIXPIListener *aListener)
{
// we are going to ignore the returned ID and enforce that once you
// register a notifier, you can not remove it. This should at some
// register a Listener, you can not remove it. This should at some
// point be fixed.
(void) mMasterNotifier.RegisterNotifier(notifier);
(void) mMasterListener.RegisterListener(aListener);
return NS_OK;
}
NS_IMETHODIMP
nsSoftwareUpdate::GetMasterNotifier(nsIXPINotifier **notifier)
nsSoftwareUpdate::GetMasterListener(nsIXPIListener **aListener)
{
NS_ASSERTION(notifier, "getter has invalid return pointer");
if (!notifier)
NS_ASSERTION(aListener, "getter has invalid return pointer");
if (!aListener)
return NS_ERROR_NULL_POINTER;
*notifier = &mMasterNotifier;
*aListener = &mMasterListener;
return NS_OK;
}
NS_IMETHODIMP
nsSoftwareUpdate::SetActiveNotifier(nsIXPINotifier *notifier)
nsSoftwareUpdate::SetActiveListener(nsIXPIListener *aListener)
{
mMasterNotifier.SetActiveNotifier(notifier);
mMasterListener.SetActiveListener(aListener);
return NS_OK;
}
@ -315,14 +319,25 @@ NS_IMETHODIMP
nsSoftwareUpdate::InstallJar( nsIFile* aLocalFile,
const PRUnichar* aURL,
const PRUnichar* aArguments,
long flags,
nsIXPINotifier* aNotifier)
PRUint32 flags,
nsIXPIListener* aListener)
{
if ( !aLocalFile )
return NS_ERROR_NULL_POINTER;
nsInstallInfo *info =
new nsInstallInfo( aLocalFile, aURL, aArguments, flags, aNotifier );
// -- grab a proxied Chrome Registry now while we can
nsresult rv;
nsIChromeRegistry* chromeReg = nsnull;
NS_WITH_ALWAYS_PROXIED_SERVICE( nsIChromeRegistry,
tmpReg,
kChromeRegistryCID,
NS_UI_THREAD_EVENTQ, &rv);
if (NS_SUCCEEDED(rv))
chromeReg = tmpReg;
// we want to call this with or without a chrome registry
nsInstallInfo *info = new nsInstallInfo( 0, aLocalFile, aURL, aArguments,
flags, aListener, chromeReg );
if (!info)
return NS_ERROR_OUT_OF_MEMORY;
@ -336,6 +351,44 @@ nsSoftwareUpdate::InstallJar( nsIFile* aLocalFile,
}
NS_IMETHODIMP
nsSoftwareUpdate::InstallChrome( PRUint32 aType,
nsIFile* aFile,
const PRUnichar* URL,
const PRUnichar* aName,
PRBool aSelect,
nsIXPIListener* aListener)
{
nsresult rv;
NS_WITH_ALWAYS_PROXIED_SERVICE( nsIChromeRegistry,
chromeReg,
kChromeRegistryCID,
NS_UI_THREAD_EVENTQ, &rv);
if (NS_FAILED(rv))
return rv;
nsInstallInfo *info = new nsInstallInfo( aType,
aFile,
URL,
aName,
(PRUint32)aSelect,
aListener,
chromeReg);
if (!info)
return NS_ERROR_OUT_OF_MEMORY;
PR_CreateThread(PR_USER_THREAD,
RunChromeInstallOnThread,
(void*)info,
PR_PRIORITY_NORMAL,
PR_GLOBAL_THREAD,
PR_UNJOINABLE_THREAD,
0);
return NS_OK;
}
NS_IMETHODIMP
nsSoftwareUpdate::InstallJarCallBack()
{
@ -513,8 +566,8 @@ nsSoftwareUpdate::StubInitialize(nsIFile *aDir)
VR_SetRegDirectory( tempPath );
// Create the logfile observer
nsLoggingProgressNotifier *logger = new nsLoggingProgressNotifier();
RegisterNotifier(logger);
nsLoggingProgressListener *logger = new nsLoggingProgressListener();
RegisterListener(logger);
// setup version registry path
char* path;

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

@ -18,7 +18,6 @@ class nsInstallInfo;
#include "nsIScriptExternalNameSet.h"
#include "nsIAppShellComponent.h"
#include "nsIXPINotifier.h"
#include "nsPIXPIStubHook.h"
#include "nsTopProgressNotifier.h"
@ -53,14 +52,21 @@ class nsSoftwareUpdate: public nsIAppShellComponent,
NS_IMETHOD InstallJar( nsIFile* localFile,
const PRUnichar* URL,
const PRUnichar* arguments,
long flags = 0,
nsIXPINotifier* notifier = 0);
PRUint32 flags = 0,
nsIXPIListener* aListener = 0);
NS_IMETHOD RegisterNotifier(nsIXPINotifier *notifier);
NS_IMETHOD InstallChrome( PRUint32 aType,
nsIFile* aFile,
const PRUnichar* URL,
const PRUnichar* aName,
PRBool aSelect,
nsIXPIListener* aListener = 0);
NS_IMETHOD RegisterListener(nsIXPIListener *aListener);
NS_IMETHOD InstallJarCallBack();
NS_IMETHOD GetMasterNotifier(nsIXPINotifier **notifier);
NS_IMETHOD SetActiveNotifier(nsIXPINotifier *notifier);
NS_IMETHOD GetMasterListener(nsIXPIListener **aListener);
NS_IMETHOD SetActiveListener(nsIXPIListener *aListener);
NS_IMETHOD StartupTasks( PRBool* needAutoreg );
/** StubInitialize() is private for the Install Wizard.
@ -89,7 +95,7 @@ class nsSoftwareUpdate: public nsIAppShellComponent,
PRBool mInstalling;
PRBool mStubLockout;
nsVoidArray mJarInstallQueue;
nsTopProgressNotifier mMasterNotifier;
nsTopProgressListener mMasterListener;
HREG mReg;

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

@ -33,7 +33,10 @@
#include "nsIServiceManager.h"
#include "nsSpecialSystemDirectory.h"
#include "nsProxiedService.h"
#include "nsFileStream.h"
#include "nsIURI.h"
#include "nsNetUtil.h"
#include "nspr.h"
#include "jsapi.h"
@ -43,10 +46,10 @@
#include "nsIZipReader.h"
#include "nsIJSRuntimeService.h"
#include "nsCOMPtr.h"
#include "nsIEventQueueService.h"
#include "nsXPIDLString.h"
#include "nsILocalFile.h"
#include "nsIChromeRegistry.h"
#include "nsInstallTrigger.h"
#include "nsIConsoleService.h"
#include "nsIScriptError.h"
@ -355,7 +358,7 @@ extern "C" void RunInstallOnThread(void *data)
PRInt32 finalStatus;
PRBool sendStatus = PR_TRUE;
nsIXPINotifier *notifier;
nsIXPIListener *listener;
// lets set up an eventQ so that our xpcom/proxies will not have to:
nsCOMPtr<nsIEventQueue> eventQ;
@ -374,20 +377,13 @@ extern "C" void RunInstallOnThread(void *data)
return;
}
softwareUpdate->SetActiveNotifier( installInfo->GetNotifier() );
softwareUpdate->GetMasterNotifier(&notifier);
softwareUpdate->SetActiveListener( installInfo->GetListener() );
softwareUpdate->GetMasterListener(&listener);
nsString url;
installInfo->GetURL(url);
if(notifier)
notifier->BeforeJavascriptEvaluation( url.GetUnicode() );
if(listener)
listener->BeforeJavascriptEvaluation( installInfo->GetURL() );
nsString args;
installInfo->GetArguments(args);
nsCOMPtr<nsIFile> jarpath;
rv = installInfo->GetLocalFile(getter_AddRefs(jarpath));
nsCOMPtr<nsIFile> jarpath = installInfo->GetFile();
if (NS_SUCCEEDED(rv))
{
finalStatus = GetInstallScriptFromJarfile( hZip,
@ -409,8 +405,8 @@ extern "C" void RunInstallOnThread(void *data)
}
rv = SetupInstallContext( hZip, jarpath,
url.GetUnicode(),
args.GetUnicode(),
installInfo->GetURL(),
installInfo->GetArguments(),
installInfo->GetFlags(),
rt, &cx, &glob);
@ -481,16 +477,111 @@ extern "C" void RunInstallOnThread(void *data)
finalStatus = nsInstall::DOWNLOAD_ERROR;
}
if(notifier)
if(listener)
{
if ( sendStatus )
notifier->FinalStatus( url.GetUnicode(), finalStatus );
listener->FinalStatus( installInfo->GetURL(), finalStatus );
notifier->AfterJavascriptEvaluation( url.GetUnicode() );
listener->AfterJavascriptEvaluation( installInfo->GetURL() );
}
if (scriptBuffer) delete [] scriptBuffer;
softwareUpdate->SetActiveNotifier(0);
softwareUpdate->SetActiveListener(0);
softwareUpdate->InstallJarCallBack();
}
//-----------------------------------------------------------------------------
// RunChromeInstallOnThread
//
// Performs the guts of a chrome install on its own thread
//
// XXX: need to return errors/status somehow. What feedback will a user want?
// How do we get it there? Maybe just alerts on errors, could also dump to
// the new console service.
//-----------------------------------------------------------------------------
extern "C" void RunChromeInstallOnThread(void *data)
{
nsresult rv;
NS_ASSERTION(data, "No nsInstallInfo passed to Chrome Install");
nsInstallInfo *info = (nsInstallInfo*)data;
nsIXPIListener* listener = info->GetListener();
if (listener)
listener->BeforeJavascriptEvaluation(info->GetURL());
// make sure we've got a chrome registry -- can't proceed if not
nsIChromeRegistry* reg = info->GetChromeRegistry();
if (reg)
{
// build up jar: URL
nsCString spec;
spec.SetCapacity(200);
spec = "jar:";
nsCOMPtr<nsIURI> pURL;
rv = NS_NewURI(getter_AddRefs(pURL), "file:");
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(pURL);
if (fileURL)
rv = fileURL->SetFile(info->GetFile());
else
rv = NS_ERROR_NO_INTERFACE;
if (NS_SUCCEEDED(rv))
{
nsXPIDLCString localURL;
rv = fileURL->GetSpec(getter_Copies(localURL));
spec.Append(localURL);
spec.Append("!/");
}
}
// Now register the new chrome
if (NS_SUCCEEDED(rv))
{
PRBool isSkin = (info->GetType() & CHROME_SKIN);
PRBool isLocale = (info->GetType() & CHROME_LOCALE);
PRBool isContent = (info->GetType() & CHROME_CONTENT);
PRBool selected = (info->GetFlags() != 0);
if ( isContent )
{
rv = reg->InstallPackage(spec.GetBuffer(), PR_TRUE);
}
if ( isSkin )
{
rv = reg->InstallSkin(spec.GetBuffer(), PR_TRUE);
if (NS_SUCCEEDED(rv) && selected)
{
rv = reg->SelectSkin(info->GetArguments(), PR_TRUE);
}
}
if ( isLocale )
{
rv = reg->InstallLocale(spec.GetBuffer(), PR_TRUE);
if (NS_SUCCEEDED(rv) && selected)
{
rv = reg->SelectLocale(info->GetArguments(), PR_TRUE);
}
}
// now that all types are registered try to activate
if ( isSkin && selected )
reg->RefreshSkins();
if ( isContent || (isLocale && selected) )
reg->ReloadChrome();
}
}
if (listener)
listener->AfterJavascriptEvaluation(info->GetURL());
delete info;
}

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

@ -24,66 +24,65 @@
* Pierre Phaneuf <pp@ludusdesign.com>
*/
#include "nsIXPINotifier.h"
#include "nsTopProgressNotifier.h"
nsTopProgressNotifier::nsTopProgressNotifier()
nsTopProgressListener::nsTopProgressListener()
{
NS_INIT_ISUPPORTS();
mNotifiers = new nsVoidArray();
mListeners = new nsVoidArray();
mActive = 0;
}
nsTopProgressNotifier::~nsTopProgressNotifier()
nsTopProgressListener::~nsTopProgressListener()
{
if (mNotifiers)
if (mListeners)
{
PRInt32 i=0;
for (; i < mNotifiers->Count(); i++)
for (; i < mListeners->Count(); i++)
{
nsIXPINotifier* element = (nsIXPINotifier*)mNotifiers->ElementAt(i);
nsIXPIListener* element = (nsIXPIListener*)mListeners->ElementAt(i);
NS_IF_RELEASE(element);
}
mNotifiers->Clear();
delete (mNotifiers);
mListeners->Clear();
delete (mListeners);
}
}
NS_IMPL_ISUPPORTS(nsTopProgressNotifier, NS_GET_IID(nsIXPINotifier));
NS_IMPL_ISUPPORTS(nsTopProgressListener, NS_GET_IID(nsIXPIListener));
long
nsTopProgressNotifier::RegisterNotifier(nsIXPINotifier * newNotifier)
nsTopProgressListener::RegisterListener(nsIXPIListener * newListener)
{
NS_IF_ADDREF( newNotifier );
return mNotifiers->AppendElement( newNotifier );
NS_IF_ADDREF( newListener );
return mListeners->AppendElement( newListener );
}
void
nsTopProgressNotifier::UnregisterNotifier(long id)
nsTopProgressListener::UnregisterListener(long id)
{
nsIXPINotifier *item = (nsIXPINotifier*)mNotifiers->ElementAt(id);
nsIXPIListener *item = (nsIXPIListener*)mListeners->ElementAt(id);
NS_IF_RELEASE(item);
mNotifiers->ReplaceElementAt(nsnull, id);
mListeners->ReplaceElementAt(nsnull, id);
}
NS_IMETHODIMP
nsTopProgressNotifier::BeforeJavascriptEvaluation(const PRUnichar *URL)
nsTopProgressListener::BeforeJavascriptEvaluation(const PRUnichar *URL)
{
if (mActive)
mActive->BeforeJavascriptEvaluation(URL);
if (mNotifiers)
if (mListeners)
{
PRInt32 i=0;
for (; i < mNotifiers->Count(); i++)
for (; i < mListeners->Count(); i++)
{
nsIXPINotifier* element = (nsIXPINotifier*)mNotifiers->ElementAt(i);
nsIXPIListener* element = (nsIXPIListener*)mListeners->ElementAt(i);
if (element != NULL)
element->BeforeJavascriptEvaluation(URL);
}
@ -93,17 +92,17 @@ nsTopProgressNotifier::BeforeJavascriptEvaluation(const PRUnichar *URL)
}
NS_IMETHODIMP
nsTopProgressNotifier::AfterJavascriptEvaluation(const PRUnichar *URL)
nsTopProgressListener::AfterJavascriptEvaluation(const PRUnichar *URL)
{
if (mActive)
mActive->AfterJavascriptEvaluation(URL);
if (mNotifiers)
if (mListeners)
{
PRInt32 i=0;
for (; i < mNotifiers->Count(); i++)
for (; i < mListeners->Count(); i++)
{
nsIXPINotifier* element = (nsIXPINotifier*)mNotifiers->ElementAt(i);
nsIXPIListener* element = (nsIXPIListener*)mListeners->ElementAt(i);
if (element != NULL)
element->AfterJavascriptEvaluation(URL);
}
@ -112,17 +111,17 @@ nsTopProgressNotifier::AfterJavascriptEvaluation(const PRUnichar *URL)
}
NS_IMETHODIMP
nsTopProgressNotifier::InstallStarted(const PRUnichar *URL, const PRUnichar* UIPackageName)
nsTopProgressListener::InstallStarted(const PRUnichar *URL, const PRUnichar* UIPackageName)
{
if (mActive)
mActive->InstallStarted(URL, UIPackageName);
if (mNotifiers)
if (mListeners)
{
PRInt32 i=0;
for (; i < mNotifiers->Count(); i++)
for (; i < mListeners->Count(); i++)
{
nsIXPINotifier* element = (nsIXPINotifier*)mNotifiers->ElementAt(i);
nsIXPIListener* element = (nsIXPIListener*)mListeners->ElementAt(i);
if (element != NULL)
element->InstallStarted(URL, UIPackageName);
}
@ -131,19 +130,19 @@ nsTopProgressNotifier::InstallStarted(const PRUnichar *URL, const PRUnichar* UIP
}
NS_IMETHODIMP
nsTopProgressNotifier::ItemScheduled( const PRUnichar* message )
nsTopProgressListener::ItemScheduled( const PRUnichar* message )
{
long rv = 0;
if (mActive)
mActive->ItemScheduled( message );
if (mNotifiers)
if (mListeners)
{
PRInt32 i=0;
for (; i < mNotifiers->Count(); i++)
for (; i < mListeners->Count(); i++)
{
nsIXPINotifier* element = (nsIXPINotifier*)mNotifiers->ElementAt(i);
nsIXPIListener* element = (nsIXPIListener*)mListeners->ElementAt(i);
if (element != NULL)
element->ItemScheduled( message );
}
@ -153,17 +152,17 @@ nsTopProgressNotifier::ItemScheduled( const PRUnichar* message )
}
NS_IMETHODIMP
nsTopProgressNotifier::FinalizeProgress( const PRUnichar* message, PRInt32 itemNum, PRInt32 totNum )
nsTopProgressListener::FinalizeProgress( const PRUnichar* message, PRInt32 itemNum, PRInt32 totNum )
{
if (mActive)
mActive->FinalizeProgress( message, itemNum, totNum );
if (mNotifiers)
if (mListeners)
{
PRInt32 i=0;
for (; i < mNotifiers->Count(); i++)
for (; i < mListeners->Count(); i++)
{
nsIXPINotifier* element = (nsIXPINotifier*)mNotifiers->ElementAt(i);
nsIXPIListener* element = (nsIXPIListener*)mListeners->ElementAt(i);
if (element != NULL)
element->FinalizeProgress( message, itemNum, totNum );
}
@ -172,17 +171,17 @@ nsTopProgressNotifier::FinalizeProgress( const PRUnichar* message, PRInt32 itemN
}
NS_IMETHODIMP
nsTopProgressNotifier::FinalStatus(const PRUnichar *URL, PRInt32 status)
nsTopProgressListener::FinalStatus(const PRUnichar *URL, PRInt32 status)
{
if (mActive)
mActive->FinalStatus(URL, status);
if (mNotifiers)
if (mListeners)
{
PRInt32 i=0;
for (; i < mNotifiers->Count(); i++)
for (; i < mListeners->Count(); i++)
{
nsIXPINotifier* element = (nsIXPINotifier*)mNotifiers->ElementAt(i);
nsIXPIListener* element = (nsIXPIListener*)mListeners->ElementAt(i);
if (element != NULL)
element->FinalStatus(URL,status);
}
@ -191,17 +190,17 @@ nsTopProgressNotifier::FinalStatus(const PRUnichar *URL, PRInt32 status)
}
NS_IMETHODIMP
nsTopProgressNotifier::LogComment(const PRUnichar* comment)
nsTopProgressListener::LogComment(const PRUnichar* comment)
{
if (mActive)
mActive->LogComment(comment);
if (mNotifiers)
if (mListeners)
{
PRInt32 i=0;
for (; i < mNotifiers->Count(); i++)
for (; i < mListeners->Count(); i++)
{
nsIXPINotifier* element = (nsIXPINotifier*)mNotifiers->ElementAt(i);
nsIXPIListener* element = (nsIXPIListener*)mListeners->ElementAt(i);
if (element != NULL)
element->LogComment(comment);
}

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

@ -31,26 +31,26 @@
#include "nsVoidArray.h"
class nsTopProgressNotifier : public nsIXPINotifier
class nsTopProgressListener : public nsIXPIListener
{
public:
nsTopProgressNotifier();
virtual ~nsTopProgressNotifier();
nsTopProgressListener();
virtual ~nsTopProgressListener();
long RegisterNotifier(nsIXPINotifier * newNotifier);
void UnregisterNotifier(long id);
void SetActiveNotifier(nsIXPINotifier *aNotifier)
{ mActive = aNotifier; }
long RegisterListener(nsIXPIListener * newListener);
void UnregisterListener(long id);
void SetActiveListener(nsIXPIListener *aListener)
{ mActive = aListener; }
NS_DECL_ISUPPORTS
// implements nsIXPINotifier
NS_DECL_NSIXPINOTIFIER
// implements nsIXPIListener
NS_DECL_NSIXPILISTENER
private:
nsVoidArray *mNotifiers;
nsCOMPtr<nsIXPINotifier> mActive;
nsVoidArray *mListeners;
nsCOMPtr<nsIXPIListener> mActive;
};

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

@ -29,7 +29,7 @@
#include "nsVoidArray.h"
#include "nsCOMPtr.h"
#include "nsISupportsUtils.h"
#include "nsIXPINotifier.h"
//#include "nsIXPINotifier.h"
#include "nsIFileSpec.h"
#include "nsILocalFile.h"
#include "nsIOutputStream.h"

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

@ -50,11 +50,12 @@
#include "nsInstallProgressDialog.h"
#include "nsInstallResources.h"
#include "nsSpecialSystemDirectory.h"
//#include "nsFileStream.h"
#include "nsProxyObjectManager.h"
#include "nsIDOMWindow.h"
#include "nsDirectoryService.h"
#include "nsFileLocations.h"
#include "nsProxiedService.h"
#include "nsIAppShellComponentImpl.h"
#include "nsINetSupportDialogService.h"
#include "nsIPrompt.h"
@ -63,7 +64,7 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID );
static NS_DEFINE_IID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
static NS_DEFINE_IID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID);
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
@ -115,8 +116,8 @@ nsXPInstallManager::QueryInterface(REFNSIID aIID,void** aInstancePtr)
if (!aInstancePtr)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(NS_GET_IID(nsIXPINotifier)))
*aInstancePtr = NS_STATIC_CAST(nsIXPINotifier*,this);
if (aIID.Equals(NS_GET_IID(nsIXPIListener)))
*aInstancePtr = NS_STATIC_CAST(nsIXPIListener*,this);
else if (aIID.Equals(NS_GET_IID(nsIStreamListener)))
*aInstancePtr = NS_STATIC_CAST(nsIStreamListener*,this);
else if (aIID.Equals(NS_GET_IID(nsPIXPIManagerCallbacks)))
@ -126,7 +127,7 @@ nsXPInstallManager::QueryInterface(REFNSIID aIID,void** aInstancePtr)
else if (aIID.Equals(NS_GET_IID(nsIInterfaceRequestor)))
*aInstancePtr = NS_STATIC_CAST(nsIInterfaceRequestor*,this);
else if (aIID.Equals(NS_GET_IID(nsISupports)))
*aInstancePtr = NS_STATIC_CAST( nsISupports*, NS_STATIC_CAST(nsIXPINotifier*,this));
*aInstancePtr = NS_STATIC_CAST( nsISupports*, NS_STATIC_CAST(nsIXPIListener*,this));
else
*aInstancePtr = 0;
@ -176,7 +177,7 @@ nsXPInstallManager::InitManager(nsXPITriggerInfo* aTriggers, PRUint32 aChromeTyp
LoadDialogWithNames(ioParamBlock);
if (mChromeType == 0 || mChromeType > CHROMETYPE_SAFEMAX )
if (mChromeType == 0 || mChromeType > CHROME_SAFEMAX )
OKtoInstall = ConfirmInstall(ioParamBlock);
else
OKtoInstall = ConfirmChromeInstall();
@ -200,13 +201,13 @@ nsXPInstallManager::InitManager(nsXPITriggerInfo* aTriggers, PRUint32 aChromeTyp
if (NS_SUCCEEDED(rv))
{
rv = pmgr->GetProxyObject( NS_UI_THREAD_EVENTQ, NS_GET_IID(nsIXPIProgressDlg),
Idlg, PROXY_SYNC | PROXY_ALWAYS, getter_AddRefs(mProxy) );
Idlg, PROXY_SYNC | PROXY_ALWAYS, getter_AddRefs(mDlg) );
}
if (NS_SUCCEEDED(rv))
{
rv = mProxy->Open(ioParamBlock);
rv = mDlg->Open(ioParamBlock);
}
}
}
@ -301,7 +302,7 @@ PRBool nsXPInstallManager::ConfirmChromeInstall()
getter_AddRefs(xpiBundle) );
if (NS_SUCCEEDED(rv) && xpiBundle)
{
if ( mChromeType == CHROMETYPE_LOCALE )
if ( mChromeType == CHROME_LOCALE )
{
xpiBundle->GetStringFromName(
NS_ConvertASCIItoUCS2("ApplyNowLocale").GetUnicode(),
@ -378,7 +379,7 @@ NS_IMETHODIMP nsXPInstallManager::DownloadNext()
// XXX serious problem with trigger! try to carry on
rv = DownloadNext();
}
else if ( mItem->IsFileURL() )
else if ( mItem->IsFileURL() && mChromeType == 0 )
{
nsCOMPtr<nsIURI> pURL;
@ -409,26 +410,8 @@ NS_IMETHODIMP nsXPInstallManager::DownloadNext()
}
else
{
// We have one to download
// --- figure out a temp file name
nsCOMPtr<nsILocalFile> temp;
NS_WITH_SERVICE(nsIProperties, directoryService, NS_DIRECTORY_SERVICE_PROGID, &rv);
directoryService->Get("system.OS_TemporaryDirectory", NS_GET_IID(nsIFile), getter_AddRefs(temp));
PRInt32 pos = mItem->mURL.RFindChar('/');
if ( pos != -1 )
{
nsString jarleaf;
mItem->mURL.Right( jarleaf, mItem->mURL.Length() - (pos + 1));
temp->Append(nsAutoCString(jarleaf));
}
else
temp->Append("xpinstall.xpi");
MakeUnique(temp); //nsIFileXXX: need MakeUnique function.
mItem->mFile = temp;
// We have one to download -- figure out the destination file name
rv = GetDestinationFile(mItem->mURL, getter_AddRefs(mItem->mFile));
if (NS_SUCCEEDED(rv))
{
// --- start the download
@ -464,8 +447,8 @@ NS_IMETHODIMP nsXPInstallManager::DownloadNext()
// all downloaded, queue them for installation
// can't cancel from here on cause we can't undo installs in a multitrigger
if (mProxy)
mProxy->StartInstallPhase();
if (mDlg)
mDlg->StartInstallPhase();
NS_WITH_SERVICE(nsISoftwareUpdate, softupdate, nsSoftwareUpdate::GetCID(), &rv);
if (NS_SUCCEEDED(rv))
@ -475,11 +458,22 @@ NS_IMETHODIMP nsXPInstallManager::DownloadNext()
mItem = (nsXPITriggerItem*)mTriggers->Get(i);
if ( mItem && mItem->mFile )
{
rv = softupdate->InstallJar(mItem->mFile,
if ( mChromeType == 0 ) {
rv = softupdate->InstallJar(mItem->mFile,
mItem->mURL.GetUnicode(),
mItem->mArguments.GetUnicode(),
mItem->mFlags,
this );
}
else {
rv = softupdate->InstallChrome(mChromeType,
mItem->mFile,
mItem->mURL.GetUnicode(),
mItem->mName.GetUnicode(),
mSelectChrome,
this );
}
if (NS_SUCCEEDED(rv))
PR_AtomicIncrement(&mNumJars);
else
@ -512,26 +506,22 @@ nsXPInstallManager::CancelInstall()
void nsXPInstallManager::Shutdown()
{
if (mProxy)
{
// proxy exists: we're being called from script thread
mProxy->Close();
}
if (mDlg)
mDlg->Close();
// Clean up downloaded files
// Clean up downloaded files, regular XPInstall only not chrome installs
nsXPITriggerItem* item;
nsCOMPtr<nsIFile> tmpSpec;
for (PRUint32 i = 0; i < mTriggers->Size(); i++ )
if ( mChromeType == 0 )
{
item = NS_STATIC_CAST(nsXPITriggerItem*, mTriggers->Get(i));
if ( item && item->mFile && !item->IsFileURL() )
for (PRUint32 i = 0; i < mTriggers->Size(); i++ )
{
item->mFile->Delete(PR_FALSE);
item = NS_STATIC_CAST(nsXPITriggerItem*, mTriggers->Get(i));
if ( item && item->mFile && !item->IsFileURL() )
item->mFile->Delete(PR_FALSE);
}
}
NS_RELEASE_THIS();
}
@ -595,6 +585,79 @@ void nsXPInstallManager::LoadDialogWithNames(nsIDialogParamBlock* ioParamBlock)
}
NS_IMETHODIMP
nsXPInstallManager::GetDestinationFile(nsString& url, nsILocalFile* *file)
{
NS_ENSURE_ARG_POINTER(file);
nsresult rv;
nsString leaf;
PRInt32 pos = url.RFindChar('/');
url.Mid( leaf, pos+1, url.Length() );
if (mChromeType == 0 )
{
// a regular XPInstall, not chrome
NS_WITH_SERVICE(nsIProperties, directoryService,
NS_DIRECTORY_SERVICE_PROGID, &rv);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsILocalFile> temp;
directoryService->Get("system.OS_TemporaryDirectory",
NS_GET_IID(nsIFile),
getter_AddRefs(temp));
temp->AppendUnicode(leaf.GetUnicode());
MakeUnique(temp);
*file = temp;
NS_IF_ADDREF(*file);
}
}
else
{
// a chrome install, download straight to final destination
NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIFileSpec> userChrome;
nsCOMPtr<nsILocalFile> target;
// Get the user's Chrome directory, create if necessary
rv = locator->GetFileLocation(
nsSpecialFileSpec::App_UserChromeDirectory,
getter_AddRefs(userChrome));
NS_ASSERTION(NS_SUCCEEDED(rv) && userChrome,
"App_UserChromeDirectory not defined!");
if (NS_SUCCEEDED(rv))
{
PRBool exists;
rv = userChrome->Exists(&exists);
if (NS_SUCCEEDED(rv) && !exists)
{
rv = userChrome->CreateDir();
}
nsFileSpec tmpSpec;
userChrome->GetFileSpec(&tmpSpec);
rv = NS_FileSpecToIFile(&tmpSpec, getter_AddRefs(target));
if (NS_SUCCEEDED(rv))
{
target->AppendUnicode(leaf.GetUnicode());
MakeUnique(target);
*file = target;
NS_IF_ADDREF(*file);
}
}
}
}
return rv;
}
NS_IMETHODIMP
nsXPInstallManager::OnStartRequest(nsIChannel* channel, nsISupports *ctxt)
{
@ -738,7 +801,7 @@ nsXPInstallManager::OnProgress(nsIChannel *channel, nsISupports *ctxt, PRUint32
rv = channel->GetContentLength(&mContentLength);
if (NS_FAILED(rv)) return rv;
}
return mProxy->SetProgress(aProgress, mContentLength, mode);
return mDlg->SetProgress(aProgress, mContentLength, mode);
}
return NS_OK;
@ -748,7 +811,7 @@ NS_IMETHODIMP
nsXPInstallManager::OnStatus(nsIChannel *channel, nsISupports *ctxt, const PRUnichar *aMsg)
{
if (!mCancelled)
return mProxy->SetActionText(aMsg);
return mDlg->SetActionText(aMsg);
return NS_OK;
}
@ -760,7 +823,7 @@ nsXPInstallManager::GetInterface(const nsIID & eventSinkIID, void* *_retval)
return QueryInterface(eventSinkIID, (void**)_retval);
}
// IXPINotifier methods
// IXPIListener methods
NS_IMETHODIMP
nsXPInstallManager::BeforeJavascriptEvaluation(const PRUnichar *URL)
@ -768,10 +831,10 @@ nsXPInstallManager::BeforeJavascriptEvaluation(const PRUnichar *URL)
nsresult rv = NS_OK;
mFinalizing = PR_FALSE;
mProxy->SetProgress( 0, 0, 'u' ); // turn on the barber pole
mDlg->SetProgress( 0, 0, 'u' ); // turn on the barber pole
PRUnichar tmp[] = { '\0' };
mProxy->SetActionText(tmp);
mDlg->SetActionText(tmp);
return rv;
}
@ -789,14 +852,14 @@ nsXPInstallManager::AfterJavascriptEvaluation(const PRUnichar *URL)
NS_IMETHODIMP
nsXPInstallManager::InstallStarted(const PRUnichar *URL, const PRUnichar *UIPackageName)
{
mProxy->SetActionText(nsnull);
return mProxy->SetHeading( nsString(UIPackageName).GetUnicode() );
mDlg->SetActionText(nsnull);
return mDlg->SetHeading( nsString(UIPackageName).GetUnicode() );
}
NS_IMETHODIMP
nsXPInstallManager::ItemScheduled(const PRUnichar *message)
{
return mProxy->SetActionText( nsString(message).GetUnicode() );
return mDlg->SetActionText( nsString(message).GetUnicode() );
}
NS_IMETHODIMP
@ -813,12 +876,12 @@ nsXPInstallManager::FinalizeProgress(const PRUnichar *message, PRInt32 itemNum,
nsresult rv = mStringBundle->GetStringFromName(ucRsrcName, &ucRsrcVal);
if (NS_SUCCEEDED(rv) && ucRsrcVal)
{
mProxy->SetActionText( ucRsrcVal );
mDlg->SetActionText( ucRsrcVal );
nsCRT::free(ucRsrcVal);
}
}
}
return mProxy->SetProgress( itemNum, totNum, 'n' );
return mDlg->SetProgress( itemNum, totNum, 'n' );
}
NS_IMETHODIMP

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

@ -37,6 +37,7 @@
#include "nsIXPINotifier.h"
#include "nsXPITriggerInfo.h"
#include "nsIXPIProgressDlg.h"
#include "nsIChromeRegistry.h"
#include "nsISoftwareUpdate.h"
@ -51,7 +52,7 @@
#include "nsIDialogParamBlock.h"
class nsXPInstallManager : public nsIXPINotifier,
class nsXPInstallManager : public nsIXPIListener,
public nsIStreamListener,
public nsIProgressEventSink,
public nsIInterfaceRequestor,
@ -71,8 +72,8 @@ class nsXPInstallManager : public nsIXPINotifier,
// nsIStreamListener
NS_DECL_NSISTREAMLISTENER
// IXPINotifier methods
NS_DECL_NSIXPINOTIFIER
// IXPIListener methods
NS_DECL_NSIXPILISTENER
// nsIProgressEventSink
NS_DECL_NSIPROGRESSEVENTSINK
@ -87,6 +88,7 @@ class nsXPInstallManager : public nsIXPINotifier,
private:
NS_IMETHOD DownloadNext();
void Shutdown();
NS_IMETHOD GetDestinationFile(nsString& url, nsILocalFile* *file);
void LoadDialogWithNames(nsIDialogParamBlock* ioParamBlock);
PRBool ConfirmInstall(nsIDialogParamBlock* ioParamBlock);
PRBool ConfirmChromeInstall();
@ -101,9 +103,8 @@ class nsXPInstallManager : public nsIXPINotifier,
PRBool mSelectChrome;
PRInt32 mContentLength;
nsCOMPtr<nsIXPIProgressDlg> mProxy;
nsCOMPtr<nsIXPIProgressDlg> mDlg;
nsCOMPtr<nsIStringBundle> mStringBundle;
};
#endif

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

@ -22,7 +22,6 @@
* Douglas Turner <dougt@netscape.com>
*/
#include "nsIXPINotifier.h"
#include "nsSimpleNotifier.h"
#include <stdlib.h>

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

@ -29,14 +29,14 @@
#include "nsIXPINotifier.h"
class nsSimpleNotifier : public nsIXPINotifier
class nsSimpleNotifier : public nsIXPIListener
{
public:
nsSimpleNotifier();
virtual ~nsSimpleNotifier();
NS_DECL_NSIXPINOTIFIER
NS_DECL_NSIXPILISTENER
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);

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

@ -27,41 +27,41 @@
extern PRInt32 gInstallStatus;
nsStubNotifier::nsStubNotifier( pfnXPIProgress aProgress )
nsStubListener::nsStubListener( pfnXPIProgress aProgress )
: m_progress(aProgress)
{
NS_INIT_ISUPPORTS();
}
nsStubNotifier::~nsStubNotifier()
nsStubListener::~nsStubListener()
{}
NS_IMPL_ISUPPORTS(nsStubNotifier, NS_GET_IID(nsIXPINotifier));
NS_IMPL_ISUPPORTS(nsStubListener, NS_GET_IID(nsIXPIListener));
NS_IMETHODIMP
nsStubNotifier::BeforeJavascriptEvaluation(const PRUnichar *URL)
nsStubListener::BeforeJavascriptEvaluation(const PRUnichar *URL)
{
// we're not interested in this one
return NS_OK;
}
NS_IMETHODIMP
nsStubNotifier::AfterJavascriptEvaluation(const PRUnichar *URL)
nsStubListener::AfterJavascriptEvaluation(const PRUnichar *URL)
{
// we're not interested in this one
return NS_OK;
}
NS_IMETHODIMP
nsStubNotifier::InstallStarted(const PRUnichar *URL, const PRUnichar* UIPackageName)
nsStubListener::InstallStarted(const PRUnichar *URL, const PRUnichar* UIPackageName)
{
// we're not interested in this one
return NS_OK;
}
NS_IMETHODIMP
nsStubNotifier::ItemScheduled(const PRUnichar* message )
nsStubListener::ItemScheduled(const PRUnichar* message )
{
if (m_progress)
{
@ -73,7 +73,7 @@ nsStubNotifier::ItemScheduled(const PRUnichar* message )
}
NS_IMETHODIMP
nsStubNotifier::FinalizeProgress(const PRUnichar* message, PRInt32 itemNum, PRInt32 totNum )
nsStubListener::FinalizeProgress(const PRUnichar* message, PRInt32 itemNum, PRInt32 totNum )
{
if (m_progress)
{
@ -85,7 +85,7 @@ nsStubNotifier::FinalizeProgress(const PRUnichar* message, PRInt32 itemNum, PRIn
}
NS_IMETHODIMP
nsStubNotifier::FinalStatus(const PRUnichar *URL, PRInt32 status)
nsStubListener::FinalStatus(const PRUnichar *URL, PRInt32 status)
{
// if (m_final)
// m_final( nsCAutoString(URL), status );
@ -94,7 +94,7 @@ nsStubNotifier::FinalStatus(const PRUnichar *URL, PRInt32 status)
}
NS_IMETHODIMP
nsStubNotifier::LogComment(const PRUnichar* comment)
nsStubListener::LogComment(const PRUnichar* comment)
{
// we're not interested in this one
return NS_OK;

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

@ -30,15 +30,15 @@
#include "xpistub.h"
#include "nsIXPINotifier.h"
class nsStubNotifier : public nsIXPINotifier
class nsStubListener : public nsIXPIListener
{
public:
nsStubNotifier( pfnXPIProgress );
virtual ~nsStubNotifier();
nsStubListener( pfnXPIProgress );
virtual ~nsStubListener();
NS_DECL_ISUPPORTS
NS_DECL_NSIXPINOTIFIER
NS_DECL_NSIXPILISTENER
private:
pfnXPIProgress m_progress;

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

@ -69,7 +69,7 @@
// globals
//------------------------------------------------------------------------
static nsIXPINotifier *gNotifier = 0;
static nsIXPIListener *gListener = 0;
static nsISoftwareUpdate *gXPI = 0;
static nsIServiceManager *gServiceMgr = 0;
@ -205,7 +205,7 @@ PR_PUBLIC_API(nsresult) XPI_Init(
//--------------------------------------------------------------------
// Save the install wizard's callbacks as a nsIXPINotifer for later
//--------------------------------------------------------------------
nsStubNotifier* stub = new nsStubNotifier( progressCB );
nsStubListener* stub = new nsStubListener( progressCB );
if (!stub)
{
gXPI->Release();
@ -213,7 +213,7 @@ PR_PUBLIC_API(nsresult) XPI_Init(
}
else
{
rv = stub->QueryInterface(NS_GET_IID(nsIXPINotifier), (void**)&gNotifier);
rv = stub->QueryInterface(NS_GET_IID(nsIXPIListener), (void**)&gListener);
}
return rv;
}
@ -225,8 +225,8 @@ PR_PUBLIC_API(nsresult) XPI_Init(
//------------------------------------------------------------------------
PR_PUBLIC_API(void) XPI_Exit()
{
if (gNotifier)
gNotifier->Release();
if (gListener)
gListener->Release();
if (gXPI)
gXPI->Release();
@ -269,7 +269,7 @@ PR_PUBLIC_API(PRInt32) XPI_Install(
if (iFile && gXPI)
rv = gXPI->InstallJar( iFile, URLstr.GetUnicode(), args.GetUnicode(),
(aFlags | XPI_NO_NEW_THREAD), gNotifier );
(aFlags | XPI_NO_NEW_THREAD), gListener );
return gInstallStatus;
}