bug 79886 get install log working again (casualty of xpcdom landing). r=ssu

This commit is contained in:
dveditz%netscape.com 2001-05-14 08:45:44 +00:00
Родитель b229b1c6b4
Коммит 622e28fb32
2 изменённых файлов: 52 добавлений и 132 удалений

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

@ -52,7 +52,6 @@
#include "nsTopProgressNotifier.h"
#include "nsLoggingProgressNotifier.h"
#include "nsIAppShellComponent.h"
#include "nsIRegistry.h"
#include "nsBuildID.h"
@ -89,12 +88,6 @@ nsSoftwareUpdate* nsSoftwareUpdate::mInstance = nsnull;
nsCOMPtr<nsIFile> nsSoftwareUpdate::mProgramDir = nsnull;
char* nsSoftwareUpdate::mLogName = nsnull;
#if NOTIFICATION_ENABLE
#include "nsUpdateNotification.h"
static NS_DEFINE_CID(kUpdateNotificationCID, NS_XPI_UPDATE_NOTIFIER_CID);
nsIUpdateNotification* nsSoftwareUpdate::mUpdateNotifier= nsnull;
#endif
nsSoftwareUpdate *
nsSoftwareUpdate::GetInstance()
@ -110,12 +103,10 @@ nsSoftwareUpdate::GetInstance()
nsSoftwareUpdate::nsSoftwareUpdate()
: mInstalling(PR_FALSE),
mStubLockout(PR_FALSE),
mMasterListener(0),
mReg(0)
{
NS_INIT_ISUPPORTS();
mMasterListener = new nsTopProgressListener;
NS_IF_ADDREF (mMasterListener);
mLock = PR_NewLock();
@ -168,7 +159,6 @@ nsSoftwareUpdate::~nsSoftwareUpdate()
NR_ShutdownRegistry();
//NS_IF_RELEASE( mProgramDir );
NS_IF_RELEASE (mMasterListener);
mInstance = nsnull;
@ -184,75 +174,21 @@ NS_IMPL_THREADSAFE_ISUPPORTS2(nsSoftwareUpdate,
nsISoftwareUpdate,
nsPIXPIStubHook);
NS_IMETHODIMP
nsSoftwareUpdate::Initialize( nsIAppShellService *anAppShell, nsICmdLineService *aCmdLineService )
{
// Close the registry if open. We left it open through most of startup
// so it wouldn't get opened and closed a lot by different services
if (mReg)
NR_RegClose(mReg);
// prevent use of nsPIXPIStubHook by browser
mStubLockout = PR_TRUE;
/***************************************/
/* Register us with NetLib */
/***************************************/
// FIX
/***************************************/
/* Create a top level observer */
/***************************************/
nsLoggingProgressListener *logger = new nsLoggingProgressListener();
RegisterListener(logger);
#if NOTIFICATION_ENABLE
/***************************************/
/* Create a Update notification object */
/***************************************/
NS_IF_RELEASE(mUpdateNotifier);
nsComponentManager::CreateInstance(kUpdateNotificationCID,
nsnull,
NS_GET_IID(nsIUpdateNotification),
(void**)&mUpdateNotifier);
#endif
return NS_OK;
}
NS_IMETHODIMP
nsSoftwareUpdate::Shutdown()
{
#if NOTIFICATION_ENABLED
if (mUpdateNotifier)
{
mUpdateNotifier->DisplayUpdateDialog();
NS_RELEASE(mUpdateNotifier);
}
#endif
// nothing to do here. Should we UnregisterService?
return NS_OK;
}
NS_IMETHODIMP
nsSoftwareUpdate::RegisterListener(nsIXPIListener *aListener)
{
// we are going to ignore the returned ID and enforce that once you
// register a Listener, you can not remove it. This should at some
// point be fixed.
// once you register a Listener, you can not remove it.
// This should get changed at some point.
if (!mMasterListener)
CreateMasterListener();
if (!mMasterListener)
return NS_ERROR_FAILURE;
if (mMasterListener)
{
mMasterListener->RegisterListener(aListener);
return NS_OK;
}
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
@ -262,27 +198,41 @@ nsSoftwareUpdate::GetMasterListener(nsIXPIListener **aListener)
if (!aListener)
return NS_ERROR_NULL_POINTER;
if (mMasterListener)
{
if (!mMasterListener)
CreateMasterListener();
if (!mMasterListener)
return NS_ERROR_FAILURE;
NS_ADDREF (mMasterListener);
*aListener = mMasterListener;
return NS_OK;
}
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSoftwareUpdate::SetActiveListener(nsIXPIListener *aListener)
{
if (mMasterListener)
{
if (!mMasterListener)
CreateMasterListener();
if (!mMasterListener)
return NS_ERROR_FAILURE;
mMasterListener->SetActiveListener (aListener);
return NS_OK;
}
void nsSoftwareUpdate::CreateMasterListener()
{
mMasterListener = new nsTopProgressListener;
if (mMasterListener)
{
NS_ADDREF(mMasterListener);
nsLoggingProgressListener *logger = new nsLoggingProgressListener();
mMasterListener->RegisterListener(logger);
}
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
@ -468,6 +418,11 @@ nsSoftwareUpdate::RunNextInstall()
nsInstallInfo* info = nsnull;
PR_Lock(mLock);
// make sure master master listener exists
if (!mMasterListener)
CreateMasterListener();
if (!mInstalling)
{
if ( mJarInstallQueue.Count() > 0 )
@ -503,15 +458,9 @@ nsSoftwareUpdate::RunNextInstall()
NS_IMETHODIMP
nsSoftwareUpdate::StubInitialize(nsIFile *aDir, const char* logName)
{
if (mStubLockout)
return NS_ERROR_ABORT;
else if ( !aDir )
if ( !aDir )
return NS_ERROR_NULL_POINTER;
// only allow once, it could be a mess if we've already started installing
mStubLockout = PR_TRUE;
// fix GetFolder return path
nsresult rv = aDir->Clone(getter_AddRefs(mProgramDir));
@ -529,10 +478,6 @@ nsSoftwareUpdate::StubInitialize(nsIFile *aDir, const char* logName)
return NS_ERROR_OUT_OF_MEMORY;
}
// Create the logfile observer
nsLoggingProgressListener *logger = new nsLoggingProgressListener();
RegisterListener(logger);
return rv;
}
@ -650,16 +595,7 @@ static nsModuleComponentInfo components[] =
NS_SOFTWAREUPDATENAMESET_CID,
NS_SOFTWAREUPDATENAMESET_CONTRACTID,
nsSoftwareUpdateNameSetConstructor
},
#if NOTIFICATION_ENABLED
{ "XPInstall Update Notifier",
NS_XPI_UPDATE_NOTIFIER_CID,
NS_XPI_UPDATE_NOTIFIER_CONTRACTID,
nsXPINotifierImpl::New
},
#endif
}
};

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

@ -23,17 +23,12 @@ class nsInstallInfo;
#include "nsPIXPIStubHook.h"
#include "nsTopProgressNotifier.h"
#if NOTIFICATION_ENABLE
#include "nsIUpdateNotification.h"
#endif
#define XPI_ROOT_KEY "software/mozilla/xpinstall"
#define XPI_AUTOREG_VAL "Autoreg"
#define XPCOM_KEY "software/mozilla/XPCOM"
class nsSoftwareUpdate: public nsIAppShellComponent,
public nsISoftwareUpdate,
class nsSoftwareUpdate: public nsISoftwareUpdate,
public nsPIXPIStubHook
{
public:
@ -54,7 +49,7 @@ class nsSoftwareUpdate: public nsIAppShellComponent,
static char* GetLogName() { return mLogName; }
NS_DECL_ISUPPORTS
NS_DECL_NSIAPPSHELLCOMPONENT
NS_DECL_NSPIXPISTUBHOOK
NS_IMETHOD InstallJar( nsIFile* localFile,
const PRUnichar* URL,
@ -77,13 +72,6 @@ class nsSoftwareUpdate: public nsIAppShellComponent,
NS_IMETHOD SetActiveListener(nsIXPIListener *aListener);
NS_IMETHOD StartupTasks( PRBool* needAutoreg );
/** StubInitialize() is private for the Install Wizard.
* The mStubLockout property makes sure this is only called
* once, and is also set by the AppShellComponent initialize
* so it can't be called during a normal Mozilla run
*/
NS_IMETHOD StubInitialize(nsIFile *dir, const char* logName);
nsSoftwareUpdate();
virtual ~nsSoftwareUpdate();
@ -93,16 +81,12 @@ class nsSoftwareUpdate: public nsIAppShellComponent,
static nsCOMPtr<nsIFile> mProgramDir;
static char* mLogName;
#if NOTIFICATION_ENABLE
static nsIUpdateNotification *mUpdateNotifier;
#endif
nsresult RunNextInstall();
nsresult RegisterNameset();
void CreateMasterListener();
PRLock* mLock;
PRBool mInstalling;
PRBool mStubLockout;
nsVoidArray mJarInstallQueue;
nsTopProgressListener *mMasterListener;