Changing ProgressNotifier to be nsISupports.

Adding a GUI progress dialog!
This commit is contained in:
dougt%netscape.com 1999-06-03 22:57:43 +00:00
Родитель 7b69f65bfd
Коммит 2066a13f12
15 изменённых файлов: 155 добавлений и 75 удалений

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

@ -4,4 +4,3 @@
nsISoftwareUpdate.h
nsSoftwareUpdateIIDs.h
nsIXPInstallProgressNotifier.h

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

@ -31,12 +31,13 @@ include $(DEPTH)/config/autoconf.mk
MODULE = xpinstall
XPIDLSRCS = nsIXPInstallProgress.idl
EXPORTS = \
nsIDOMInstallTriggerGlobal.h \
nsIDOMInstallVersion.h \
nsSoftwareUpdateIIDs.h \
nsISoftwareUpdate.h \
nsIXPInstallProgressNotifier.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

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

@ -22,17 +22,15 @@
# Daniel Veditz <dveditz@netscape.com>
# Douglas Turner <dougt@netscape.com>
MODULE=xpinstall
DEPTH=..\..
DEFINES=-D_IMPL_NS_DOM
EXPORTS= nsIDOMInstallTriggerGlobal.h \
nsIDOMInstallVersion.h \
nsSoftwareUpdateIIDs.h \
nsISoftwareUpdate.h \
nsIXPInstallProgressNotifier.h
nsISoftwareUpdate.h
MODULE=xpinstall
XPIDLSRCS = .\nsIXPInstallProgress.idl
include <$(DEPTH)\config\config.mak>
include <$(DEPTH)\config\rules.mak>

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

@ -30,7 +30,7 @@
#include "nsIFactory.h"
#include "nsString.h"
#include "nsIXPInstallProgressNotifier.h"
#include "nsIXPInstallProgress.h"
#define NS_IXPINSTALLCOMPONENT_PROGID NS_IAPPSHELLCOMPONENT_PROGID "/xpinstall"
#define NS_IXPINSTALLCOMPONENT_CLASSNAME "Mozilla XPInstall Component"
@ -53,13 +53,13 @@ class nsISoftwareUpdate : public nsISupports
const nsString& localFile,
long flags) = 0;
NS_IMETHOD RegisterNotifier(nsIXPInstallProgressNotifier *notifier) = 0;
NS_IMETHOD RegisterNotifier(nsIXPInstallProgress *notifier) = 0;
NS_IMETHOD InstallPending(void) = 0;
/* FIX: these should be in a private interface */
NS_IMETHOD InstallJarCallBack() = 0;
NS_IMETHOD GetTopLevelNotifier(nsIXPInstallProgressNotifier **notifier) = 0;
NS_IMETHOD GetTopLevelNotifier(nsIXPInstallProgress **notifier) = 0;
};

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

@ -45,6 +45,7 @@ LINCS= \
-I$(PUBLIC)\netlib \
-I$(PUBLIC)\xpcom \
-I$(PUBLIC)\pref \
-I$(PUBLIC)\rdf \
-I$(PUBLIC)\js \
-I$(PUBLIC)\dom \
-I$(PUBLIC)\raptor \
@ -94,6 +95,7 @@ OBJS = \
.\$(OBJDIR)\nsWinProfile.obj \
.\$(OBJDIR)\nsJSWinProfile.obj \
.\$(OBJDIR)\nsWinProfileItem.obj \
.\$(OBJDIR)\nsInstallProgressDialog.obj \
.\$(OBJDIR)\nsInstallFileOpItem.obj \
$(NULL)

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

@ -156,7 +156,7 @@ nsInstallInfo::GetArguments(nsString& args, PRUint32 index)
{
nsString aURL = GetFromURL(index);
PRInt32 result = aURL.RFind('?');
PRInt32 result = aURL.RFind("?");
if (result != -1)
{
aURL.Right(args, (aURL.Length() - result - 1) );
@ -1621,7 +1621,7 @@ nsInstall::ExtractFileFromJar(const nsString& aJarfile, nsFileSpec* aSuggestedNa
// Get the extention of the file in the jar.
PRInt32 result = aJarfile.RFind('.');
PRInt32 result = aJarfile.RFind(".");
if (result != -1)
{
// We found an extention. Add it to the tempfileName string

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

@ -44,7 +44,7 @@
#include "nsInstallObject.h"
#include "nsInstallVersion.h"
#include "nsIXPInstallProgressNotifier.h"
#include "nsIXPInstallProgress.h"
class nsInstallInfo
@ -235,7 +235,7 @@ class nsInstall
nsVector* mInstalledFiles;
nsHashtable* mPatchList;
nsIXPInstallProgressNotifier *mNotifier;
nsIXPInstallProgress *mNotifier;
PRInt32 mLastError;

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

@ -153,6 +153,8 @@ nsInstallTrigger::UpdateEnabled(PRBool* aReturn)
*aReturn = PR_FALSE; /* no prefs manager. set to false */
}
//FIX!!!!!!!!!!
*aReturn = PR_TRUE;
return NS_OK;
}
@ -254,14 +256,14 @@ nsInstallTrigger::CreateTempFileFromURL(const nsString& aURL, nsString& tempFile
{
nsSpecialSystemDirectory tempFile(nsSpecialSystemDirectory::OS_TemporaryDirectory);
PRInt32 result = aURL.RFind('/');
PRInt32 result = aURL.RFind("/");
if (result != -1)
{
nsString jarName;
aURL.Right(jarName, (aURL.Length() - result) );
PRInt32 argOffset = jarName.RFind('?');
PRInt32 argOffset = jarName.RFind("?");
if (argOffset != -1)
{

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

@ -22,7 +22,7 @@
* Douglas Turner <dougt@netscape.com>
*/
#include "nsIXPInstallProgressNotifier.h"
#include "nsIXPInstallProgress.h"
#include "nsLoggingProgressNotifier.h"
#include "nsFileSpec.h"
@ -35,24 +35,28 @@
nsLoggingProgressNotifier::nsLoggingProgressNotifier()
{
NS_INIT_REFCNT();
}
nsLoggingProgressNotifier::~nsLoggingProgressNotifier()
{
}
void
nsLoggingProgressNotifier::BeforeJavascriptEvaluation(void)
NS_IMPL_ISUPPORTS(nsLoggingProgressNotifier, nsIXPInstallProgress::GetIID());
NS_IMETHODIMP
nsLoggingProgressNotifier::BeforeJavascriptEvaluation()
{
nsSpecialSystemDirectory logFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
logFile += "Install.log";
mLogStream = new nsOutputFileStream(logFile, PR_WRONLY | PR_CREATE_FILE | PR_APPEND, 0744 );
mLogStream->seek(logFile.GetFileSize());
return NS_OK;
}
void
nsLoggingProgressNotifier::AfterJavascriptEvaluation(void)
NS_IMETHODIMP
nsLoggingProgressNotifier::AfterJavascriptEvaluation()
{
char* time;
GetTime(&time);
@ -65,12 +69,14 @@ nsLoggingProgressNotifier::AfterJavascriptEvaluation(void)
mLogStream->close();
delete mLogStream;
mLogStream = nsnull;
return NS_OK;
}
void
NS_IMETHODIMP
nsLoggingProgressNotifier::InstallStarted(const char* UIPackageName)
{
if (mLogStream == nsnull) return;
if (mLogStream == nsnull) return -1;
char* time;
GetTime(&time);
@ -84,26 +90,28 @@ nsLoggingProgressNotifier::InstallStarted(const char* UIPackageName)
PL_strfree(time);
return NS_OK;
}
long
NS_IMETHODIMP
nsLoggingProgressNotifier::ItemScheduled(const char* message )
{
return 0;
return NS_OK;
}
void
nsLoggingProgressNotifier::InstallFinalization(const char* message, long itemNum, long totNum )
NS_IMETHODIMP
nsLoggingProgressNotifier::InstallFinalization(const char* message, PRInt32 itemNum, PRInt32 totNum )
{
if (mLogStream == nsnull) return;
if (mLogStream == nsnull) return -1;
*mLogStream << " Item [" << (itemNum+1) << "/" << totNum << "]\t" << message << nsEndl;
return NS_OK;
}
void
nsLoggingProgressNotifier::InstallAborted(void)
NS_IMETHODIMP
nsLoggingProgressNotifier::InstallAborted()
{
if (mLogStream == nsnull) return;
if (mLogStream == nsnull) return -1;
char* time;
GetTime(&time);
@ -111,6 +119,7 @@ nsLoggingProgressNotifier::InstallAborted(void)
*mLogStream << " Aborted Installation at " << time << nsEndl << nsEndl;
PL_strfree(time);
return NS_OK;
}
void

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

@ -27,23 +27,25 @@
#ifndef nsLoggingProgressNotifier_H__
#define nsLoggingProgressNotifier_H__
#include "nsIXPInstallProgressNotifier.h"
#include "nsIXPInstallProgress.h"
#include "nsFileStream.h"
class nsLoggingProgressNotifier : public nsIXPInstallProgressNotifier
class nsLoggingProgressNotifier : public nsIXPInstallProgress
{
public:
nsLoggingProgressNotifier();
virtual ~nsLoggingProgressNotifier();
void BeforeJavascriptEvaluation(void);
void AfterJavascriptEvaluation(void);
void InstallStarted(const char* UIPackageName);
long ItemScheduled(const char* message );
void InstallFinalization(const char* message, long itemNum, long totNum );
void InstallAborted(void);
NS_DECL_ISUPPORTS
NS_IMETHOD BeforeJavascriptEvaluation();
NS_IMETHOD AfterJavascriptEvaluation();
NS_IMETHOD InstallStarted(const char* UIPackageName);
NS_IMETHOD ItemScheduled(const char* message );
NS_IMETHOD InstallFinalization(const char* message, PRInt32 itemNum, PRInt32 totNum );
NS_IMETHOD InstallAborted();
private:
void GetTime(char** aString);

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

@ -40,6 +40,7 @@
#include "nsTopProgressNotifier.h"
#include "nsLoggingProgressNotifier.h"
#include "nsInstallProgressDialog.h"
#include "nsIAppShellComponent.h"
#include "nsIRegistry.h"
@ -54,6 +55,10 @@
#include "nsIScriptNameSpaceManager.h"
#include "nsIScriptExternalNameSet.h"
#include "nsIEventQueueService.h"
#include "nsProxyObjectManager.h"
////////////////////////////////////////////////////////////////////////////////
// Globals
////////////////////////////////////////////////////////////////////////////////
@ -76,8 +81,8 @@ static NS_DEFINE_IID(kInstallTrigger_CID, NS_SoftwareUpdateInstallTrigger_CID);
static NS_DEFINE_IID(kIInstallVersion_IID, NS_IDOMINSTALLVERSION_IID);
static NS_DEFINE_IID(kInstallVersion_CID, NS_SoftwareUpdateInstallVersion_CID);
static NS_DEFINE_IID(kProxyObjectManagerIID, NS_IPROXYEVENT_MANAGER_IID);
static NS_DEFINE_IID(kEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
nsSoftwareUpdate::nsSoftwareUpdate()
@ -148,7 +153,56 @@ nsSoftwareUpdate::nsSoftwareUpdate()
nsLoggingProgressNotifier *logger = new nsLoggingProgressNotifier();
RegisterNotifier(logger);
nsIProxyObjectManager *manager;
nsInstallProgressDialog *dialog = new nsInstallProgressDialog();
nsInstallProgressDialog *proxy;
nsISupports *dialogBase;
nsresult rv = dialog->QueryInterface(kISupportsIID, (void**)&dialogBase);
if (NS_SUCCEEDED(rv))
{
rv = nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
kProxyObjectManagerIID,
(nsISupports **)&manager);
if (NS_SUCCEEDED(rv))
{
// I am assuming that the thread that starts us up is the UI thread. this will/may break
// I need to make a generic way of getting at the UI event queue.
nsIEventQueueService *eventQService;
rv = nsServiceManager::GetService(NS_EVENTQUEUESERVICE_PROGID,
kEventQueueServiceIID,
(nsISupports **)&eventQService);
if (NS_SUCCEEDED(rv))
{
nsIEventQueue *eventQ;
eventQService->GetThreadEventQueue(PR_GetCurrentThread(), &eventQ);
PLEventQueue *plEventQ;
eventQ->GetPLEventQueue(&plEventQ);
rv = manager->GetProxyObject(plEventQ, nsIXPInstallProgress::GetIID(), dialogBase, PROXY_SYNC, (void**)&proxy);
if (NS_SUCCEEDED(rv))
{
RegisterNotifier(proxy);
}
}
}
}
if (dialog)
dialog->Release();
}
nsSoftwareUpdate::~nsSoftwareUpdate()
{
#ifdef NS_DEBUG
@ -238,7 +292,7 @@ nsSoftwareUpdate::Shutdown()
NS_IMETHODIMP
nsSoftwareUpdate::RegisterNotifier(nsIXPInstallProgressNotifier *notifier)
nsSoftwareUpdate::RegisterNotifier(nsIXPInstallProgress *notifier)
{
// 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
@ -250,7 +304,7 @@ nsSoftwareUpdate::RegisterNotifier(nsIXPInstallProgressNotifier *notifier)
}
NS_IMETHODIMP
nsSoftwareUpdate::GetTopLevelNotifier(nsIXPInstallProgressNotifier **notifier)
nsSoftwareUpdate::GetTopLevelNotifier(nsIXPInstallProgress **notifier)
{
*notifier = mTopLevelObserver;
return NS_OK;

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

@ -15,7 +15,7 @@ class nsInstallInfo;
#include "nsIScriptExternalNameSet.h"
#include "nsIAppShellComponent.h"
#include "nsIXPInstallProgressNotifier.h"
#include "nsIXPInstallProgress.h"
#include "nsTopProgressNotifier.h"
class nsSoftwareUpdate: public nsIAppShellComponent, public nsISoftwareUpdate
@ -34,12 +34,12 @@ class nsSoftwareUpdate: public nsIAppShellComponent, public nsISoftwareUpdate
const nsString& localFile,
long flags);
NS_IMETHOD RegisterNotifier(nsIXPInstallProgressNotifier *notifier);
NS_IMETHOD RegisterNotifier(nsIXPInstallProgress *notifier);
NS_IMETHOD InstallPending(void);
NS_IMETHOD InstallJarCallBack();
NS_IMETHOD GetTopLevelNotifier(nsIXPInstallProgressNotifier **notifier);
NS_IMETHOD GetTopLevelNotifier(nsIXPInstallProgress **notifier);
private:

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

@ -295,7 +295,7 @@ extern "C" void RunInstallOnThread(void *data)
kISoftwareUpdateIID,
(nsISupports**)&softwareUpdate);
nsIXPInstallProgressNotifier *notifier;
nsIXPInstallProgress *notifier;
if (NS_SUCCEEDED(rv))
{

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

@ -22,7 +22,7 @@
* Douglas Turner <dougt@netscape.com>
*/
#include "nsIXPInstallProgressNotifier.h"
#include "nsIXPInstallProgress.h"
#include "nsTopProgressNotifier.h"
nsTopProgressNotifier::nsTopProgressNotifier()
@ -37,7 +37,7 @@ nsTopProgressNotifier::~nsTopProgressNotifier()
PRUint32 i=0;
for (; i < mNotifiers->GetSize(); i++)
{
nsIXPInstallProgressNotifier* element = (nsIXPInstallProgressNotifier*)mNotifiers->Get(i);
nsIXPInstallProgress* element = (nsIXPInstallProgress*)mNotifiers->Get(i);
delete element;
}
@ -46,8 +46,12 @@ nsTopProgressNotifier::~nsTopProgressNotifier()
}
}
NS_IMPL_ISUPPORTS(nsTopProgressNotifier, nsIXPInstallProgress::GetIID());
long
nsTopProgressNotifier::RegisterNotifier(nsIXPInstallProgressNotifier * newNotifier)
nsTopProgressNotifier::RegisterNotifier(nsIXPInstallProgress * newNotifier)
{
return mNotifiers->Add( newNotifier );
}
@ -61,22 +65,24 @@ nsTopProgressNotifier::UnregisterNotifier(long id)
void
nsTopProgressNotifier::BeforeJavascriptEvaluation(void)
NS_IMETHODIMP
nsTopProgressNotifier::BeforeJavascriptEvaluation()
{
if (mNotifiers)
{
PRUint32 i=0;
for (; i < mNotifiers->GetSize(); i++)
{
nsIXPInstallProgressNotifier* element = (nsIXPInstallProgressNotifier*)mNotifiers->Get(i);
nsIXPInstallProgress* element = (nsIXPInstallProgress*)mNotifiers->Get(i);
if (element != NULL)
element->BeforeJavascriptEvaluation();
}
}
return NS_OK;
}
void
NS_IMETHODIMP
nsTopProgressNotifier::AfterJavascriptEvaluation(void)
{
if (mNotifiers)
@ -84,14 +90,15 @@ nsTopProgressNotifier::AfterJavascriptEvaluation(void)
PRUint32 i=0;
for (; i < mNotifiers->GetSize(); i++)
{
nsIXPInstallProgressNotifier* element = (nsIXPInstallProgressNotifier*)mNotifiers->Get(i);
nsIXPInstallProgress* element = (nsIXPInstallProgress*)mNotifiers->Get(i);
if (element != NULL)
element->AfterJavascriptEvaluation();
}
}
return NS_OK;
}
void
NS_IMETHODIMP
nsTopProgressNotifier::InstallStarted(const char* UIPackageName)
{
if (mNotifiers)
@ -99,14 +106,15 @@ nsTopProgressNotifier::InstallStarted(const char* UIPackageName)
PRUint32 i=0;
for (; i < mNotifiers->GetSize(); i++)
{
nsIXPInstallProgressNotifier* element = (nsIXPInstallProgressNotifier*)mNotifiers->Get(i);
nsIXPInstallProgress* element = (nsIXPInstallProgress*)mNotifiers->Get(i);
if (element != NULL)
element->InstallStarted(UIPackageName);
}
}
return NS_OK;
}
long
NS_IMETHODIMP
nsTopProgressNotifier::ItemScheduled( const char* message )
{
long rv = 0;
@ -116,7 +124,7 @@ nsTopProgressNotifier::ItemScheduled( const char* message )
PRUint32 i=0;
for (; i < mNotifiers->GetSize(); i++)
{
nsIXPInstallProgressNotifier* element = (nsIXPInstallProgressNotifier*)mNotifiers->Get(i);
nsIXPInstallProgress* element = (nsIXPInstallProgress*)mNotifiers->Get(i);
if (element != NULL)
if (element->ItemScheduled( message ) != 0)
rv = -1;
@ -126,22 +134,23 @@ nsTopProgressNotifier::ItemScheduled( const char* message )
return rv;
}
void
nsTopProgressNotifier::InstallFinalization( const char* message, long itemNum, long totNum )
NS_IMETHODIMP
nsTopProgressNotifier::InstallFinalization( const char* message, PRInt32 itemNum, PRInt32 totNum )
{
if (mNotifiers)
{
PRUint32 i=0;
for (; i < mNotifiers->GetSize(); i++)
{
nsIXPInstallProgressNotifier* element = (nsIXPInstallProgressNotifier*)mNotifiers->Get(i);
nsIXPInstallProgress* element = (nsIXPInstallProgress*)mNotifiers->Get(i);
if (element != NULL)
element->InstallFinalization( message, itemNum, totNum );
}
}
return NS_OK;
}
void
NS_IMETHODIMP
nsTopProgressNotifier::InstallAborted(void)
{
if (mNotifiers)
@ -149,11 +158,12 @@ nsTopProgressNotifier::InstallAborted(void)
PRUint32 i=0;
for (; i < mNotifiers->GetSize(); i++)
{
nsIXPInstallProgressNotifier* element = (nsIXPInstallProgressNotifier*)mNotifiers->Get(i);
nsIXPInstallProgress* element = (nsIXPInstallProgress*)mNotifiers->Get(i);
if (element != NULL)
element->InstallAborted();
}
}
return NS_OK;
}

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

@ -25,26 +25,29 @@
#ifndef nsTopProgressNotifier_h__
#define nsTopProgressNotifier_h__
#include "nsIXPInstallProgressNotifier.h"
#include "nsIXPInstallProgress.h"
#include "nsVector.h"
class nsTopProgressNotifier : public nsIXPInstallProgressNotifier
class nsTopProgressNotifier : public nsIXPInstallProgress
{
public:
nsTopProgressNotifier();
virtual ~nsTopProgressNotifier();
long RegisterNotifier(nsIXPInstallProgressNotifier * newNotifier);
long RegisterNotifier(nsIXPInstallProgress * newNotifier);
void UnregisterNotifier(long id);
void BeforeJavascriptEvaluation(void);
void AfterJavascriptEvaluation(void);
void InstallStarted(const char* UIPackageName);
long ItemScheduled(const char* message );
void InstallFinalization(const char* message, long itemNum, long totNum );
void InstallAborted(void);
NS_DECL_ISUPPORTS
NS_IMETHOD BeforeJavascriptEvaluation();
NS_IMETHOD AfterJavascriptEvaluation();
NS_IMETHOD InstallStarted(const char* UIPackageName);
NS_IMETHOD ItemScheduled(const char* message );
NS_IMETHOD InstallFinalization(const char* message, PRInt32 itemNum, PRInt32 totNum );
NS_IMETHOD InstallAborted();
private:
nsVector *mNotifiers;