Adding appshellcomponent interface and init code.

This commit is contained in:
dougt%netscape.com 1999-05-16 19:11:25 +00:00
Родитель 9f421cbe4b
Коммит 1e58554648
8 изменённых файлов: 145 добавлений и 122 удалений

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

@ -32,6 +32,10 @@
#include "nsIXPInstallProgressNotifier.h"
#define NS_IXPINSTALLCOMPONENT_PROGID NS_IAPPSHELLCOMPONENT_PROGID "/xpinstall"
#define NS_IXPINSTALLCOMPONENT_CLASSNAME "Mozilla XPInstall Component"
#define NS_ISOFTWAREUPDATE_IID \
{ 0x18c2f992, \
0xb09f, \
@ -40,11 +44,11 @@
}
class nsISoftwareUpdate : public nsISupports
class nsISoftwareUpdate : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISOFTWAREUPDATE_IID)
NS_IMETHOD InstallJar(const nsString& fromURL,
const nsString& localFile,
long flags) = 0;

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

@ -34,14 +34,6 @@
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#define NS_SoftwareUpdateFactory_CID \
{ /* 18c2f98a-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f98a, \
0xb09f, \
0x11d2, \
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#define NS_SoftwareUpdateInstall_CID \
{ /* 18c2f98b-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f98b, \
@ -50,14 +42,6 @@
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#define NS_SoftwareUpdateInstallFactory_CID \
{ /* 18c2f98c-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f98c, \
0xb09f, \
0x11d2, \
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#define NS_SoftwareUpdateInstallTrigger_CID \
{ /* 18c2f98d-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f98d, \
@ -66,14 +50,6 @@
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#define NS_SoftwareUpdateInstallTriggerFactory_CID \
{ /* 18c2f98e-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f98e, \
0xb09f, \
0x11d2, \
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#define NS_SoftwareUpdateInstallVersion_CID \
{ /* 18c2f98f-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f98f, \
@ -82,31 +58,7 @@
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#define NS_SoftwareUpdateInstallVersionFactory_CID \
{ /* 18c2f990-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f990, \
0xb09f, \
0x11d2, \
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#if 0
#define NS_SoftwareUpdateInstallFolder_CID \
{ /* 18c2f991-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f991, \
0xb09f, \
0x11d2, \
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#define NS_SoftwareUpdateInstallFolderFactory_CID \
{ /* 18c2f992-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f992, \
0xb09f, \
0x11d2, \
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#endif
#endif /* nsSoftwareUpdateIIDs_h___ */

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

@ -53,6 +53,7 @@ LINCS= \
-I$(PUBLIC)\raptor \
-I$(PUBLIC)\nspr2 \
-I$(PUBLIC)\zlib \
-I$(PUBLIC)\xpfe\components \
$(NULL)
LLIBS = \

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

@ -192,10 +192,9 @@ nsInstall::nsInstall()
mInstallArguments = "";
nsISoftwareUpdate *su;
nsresult rv = nsComponentManager::CreateInstance( kSoftwareUpdateCID,
nsnull,
kISoftwareUpdateIID,
(void**) &su);
nsresult rv = nsServiceManager::GetService(kSoftwareUpdateCID,
kISoftwareUpdateIID,
(nsISupports**) &su);
if (NS_SUCCEEDED(rv))
{

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

@ -41,6 +41,9 @@
#include "nsTopProgressNotifier.h"
#include "nsLoggingProgressNotifier.h"
#include "nsIAppShellComponent.h"
#include "nsIRegistry.h"
/* For Javascript Namespace Access */
#include "nsDOMCID.h"
#include "nsIServiceManager.h"
@ -76,36 +79,16 @@ static NS_DEFINE_IID(kInstallVersion_CID, NS_SoftwareUpdateInstallVersion_CID);
nsSoftwareUpdate* nsSoftwareUpdate::mInstance = NULL;
nsSoftwareUpdate::nsSoftwareUpdate()
{
#ifdef NS_DEBUG
printf("XPInstall Component created\n");
#endif
NS_INIT_ISUPPORTS();
Startup();
}
nsSoftwareUpdate::~nsSoftwareUpdate()
{
Shutdown();
}
nsSoftwareUpdate *nsSoftwareUpdate::GetInstance()
{
if (mInstance == NULL)
{
mInstance = new nsSoftwareUpdate();
}
return mInstance;
}
NS_IMPL_ISUPPORTS(nsSoftwareUpdate,nsISoftwareUpdate::GetIID());
nsresult
nsSoftwareUpdate::Startup()
{
/***************************************/
/***************************************/
/* Create us a queue */
/***************************************/
mInstalling = nsnull;
@ -165,15 +148,13 @@ nsSoftwareUpdate::Startup()
nsLoggingProgressNotifier *logger = new nsLoggingProgressNotifier();
RegisterNotifier(logger);
return NS_OK;
}
nsresult
nsSoftwareUpdate::Shutdown()
nsSoftwareUpdate::~nsSoftwareUpdate()
{
#ifdef NS_DEBUG
printf("*** XPInstall Component destroyed\n");
#endif
if (mJarInstallQueue != nsnull)
{
PRUint32 i=0;
@ -190,9 +171,72 @@ nsSoftwareUpdate::Shutdown()
}
NR_ShutdownRegistry();
return NS_OK;
}
NS_IMPL_ADDREF( nsSoftwareUpdate );
NS_IMPL_RELEASE( nsSoftwareUpdate );
NS_IMETHODIMP
nsSoftwareUpdate::QueryInterface( REFNSIID anIID, void **anInstancePtr )
{
nsresult rv = NS_OK;
/* Check for place to return result. */
if ( !anInstancePtr )
{
rv = NS_ERROR_NULL_POINTER;
}
else
{
/* Initialize result. */
*anInstancePtr = 0;
/* Check for IIDs we support and cast this appropriately. */
if ( anIID.Equals( nsISoftwareUpdate::GetIID() ) )
{
*anInstancePtr = (void*) ( (nsISoftwareUpdate*)this );
NS_ADDREF_THIS();
}
else if ( anIID.Equals( nsIAppShellComponent::GetIID() ) )
{
*anInstancePtr = (void*) ( (nsIAppShellComponent*)this );
NS_ADDREF_THIS();
}
else if ( anIID.Equals( kISupportsIID ) )
{
*anInstancePtr = (void*) ( (nsISupports*) (nsISoftwareUpdate*) this );
NS_ADDREF_THIS();
}
else
{
/* Not an interface we support. */\
rv = NS_NOINTERFACE;
}
}
return rv;
}
NS_IMETHODIMP
nsSoftwareUpdate::Initialize( nsIAppShellService *anAppShell, nsICmdLineService *aCmdLineService )
{
nsresult rv;
rv = nsServiceManager::RegisterService( NS_IXPINSTALLCOMPONENT_PROGID, ( (nsISupports*) (nsISoftwareUpdate*) this ) );
return rv;
}
NS_IMETHODIMP
nsSoftwareUpdate::Shutdown()
{
nsresult rv;
rv = nsServiceManager::ReleaseService( NS_IXPINSTALLCOMPONENT_PROGID, ( (nsISupports*) (nsISoftwareUpdate*) this ) );
return rv;
}
NS_IMETHODIMP
nsSoftwareUpdate::RegisterNotifier(nsIXPInstallProgressNotifier *notifier)
{
@ -313,7 +357,7 @@ nsSoftwareUpdateFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void
*aResult = NULL;
nsSoftwareUpdate *inst = nsSoftwareUpdate::GetInstance();
nsSoftwareUpdate *inst = new nsSoftwareUpdate();
if (inst == NULL)
return NS_ERROR_OUT_OF_MEMORY;
@ -438,12 +482,45 @@ NSRegisterSelf(nsISupports* aServMgr, const char *path)
printf("*** XPInstall is being registered\n");
#endif
rv = compMgr->RegisterComponent(kSoftwareUpdate_CID, NULL, NULL, path, PR_TRUE, PR_TRUE);
rv = compMgr->RegisterComponent( kSoftwareUpdate_CID,
NS_IXPINSTALLCOMPONENT_CLASSNAME,
NS_IXPINSTALLCOMPONENT_PROGID,
path,
PR_TRUE,
PR_TRUE );
if (NS_FAILED(rv)) goto done;
nsIRegistry *registry;
rv = servMgr->GetService( NS_REGISTRY_PROGID,
nsIRegistry::GetIID(),
(nsISupports**)&registry );
if ( NS_SUCCEEDED( rv ) )
{
registry->Open();
char buffer[256];
char *cid = nsSoftwareUpdate::GetCID().ToString();
PR_snprintf( buffer,
sizeof buffer,
"%s/%s",
NS_IAPPSHELLCOMPONENT_KEY,
cid ? cid : "unknown" );
delete [] cid;
nsIRegistry::Key key;
rv = registry->AddSubtree( nsIRegistry::Common,
buffer,
&key );
servMgr->ReleaseService( NS_REGISTRY_PROGID, registry );
}
rv = compMgr->RegisterComponent(kInstallTrigger_CID, NULL, NULL, path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) goto done;
rv = compMgr->RegisterComponent(kInstallVersion_CID, NULL, NULL, path, PR_TRUE, PR_TRUE);
done:
done:
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
return rv;
}

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

@ -14,38 +14,35 @@
class nsInstallInfo;
#include "nsIScriptExternalNameSet.h"
#include "nsIAppShellComponent.h"
#include "nsIXPInstallProgressNotifier.h"
#include "nsTopProgressNotifier.h"
class nsSoftwareUpdate: public nsISoftwareUpdate
class nsSoftwareUpdate: public nsIAppShellComponent, public nsISoftwareUpdate
{
public:
static const nsIID& IID() { static nsIID iid = NS_SoftwareUpdateInstall_CID; return iid; }
NS_DEFINE_STATIC_CID_ACCESSOR( NS_SoftwareUpdate_CID );
nsSoftwareUpdate();
virtual ~nsSoftwareUpdate();
static nsSoftwareUpdate *GetInstance();
NS_DECL_ISUPPORTS
NS_DECL_IAPPSHELLCOMPONENT
NS_IMETHOD InstallJar(const nsString& fromURL,
const nsString& localFile,
long flags);
NS_IMETHOD InstallJar(const nsString& fromURL,
const nsString& localFile,
long flags);
NS_IMETHOD RegisterNotifier(nsIXPInstallProgressNotifier *notifier);
NS_IMETHOD InstallPending(void);
NS_IMETHOD RegisterNotifier(nsIXPInstallProgressNotifier *notifier);
NS_IMETHOD InstallPending(void);
NS_IMETHOD InstallJarCallBack();
NS_IMETHOD GetTopLevelNotifier(nsIXPInstallProgressNotifier **notifier);
NS_IMETHOD InstallJarCallBack();
NS_IMETHOD GetTopLevelNotifier(nsIXPInstallProgressNotifier **notifier);
private:
nsresult Startup();
nsresult Shutdown();
nsresult RunNextInstall();
nsresult DeleteScheduledNodes();
@ -53,11 +50,6 @@ class nsSoftwareUpdate: public nsISoftwareUpdate
PRBool mInstalling;
nsVector* mJarInstallQueue;
nsTopProgressNotifier *mTopLevelObserver;
static nsSoftwareUpdate* mInstance;
};

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

@ -291,10 +291,9 @@ extern "C" void RunInstallOnThread(void *data)
nsISoftwareUpdate *softwareUpdate;
nsresult rv = nsComponentManager::CreateInstance( kSoftwareUpdateCID,
nsnull,
kISoftwareUpdateIID,
(void**) &softwareUpdate);
nsresult rv = nsServiceManager::GetService( kSoftwareUpdateCID,
kISoftwareUpdateIID,
(nsISupports**)&softwareUpdate);
nsIXPInstallProgressNotifier *notifier;

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

@ -23,7 +23,7 @@
#include "nsVector.h"
#include "nsISupports.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIURL.h"
#include "nsINetlibURL.h"
@ -51,10 +51,9 @@ nsSoftwareUpdateListener::nsSoftwareUpdateListener(nsInstallInfo *nextInstall)
mResult = -1;
};
mResult = nsComponentManager::CreateInstance( kSoftwareUpdateCID,
nsnull,
kISoftwareUpdateIID,
(void**) &mSoftwareUpdate);
mResult = nsServiceManager::GetService( kSoftwareUpdateCID,
kISoftwareUpdateIID,
(nsISupports**)&mSoftwareUpdate);
if (NS_FAILED(mResult))
return;