This commit is contained in:
dveditz%netscape.com 1999-08-11 00:31:15 +00:00
Родитель b345f302fd
Коммит 9662f439d7
8 изменённых файлов: 180 добавлений и 72 удалений

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

@ -31,7 +31,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = nsxpi
XPIDLSRCS = nsIXPINotifier.idl nsIXPIProgressDlg.idl
XPIDLSRCS = nsIXPINotifier.idl nsIXPIProgressDlg.idl nsPvtIXPIStubHook.idl
EXPORTS = \
nsIDOMInstallTriggerGlobal.h \

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

@ -34,6 +34,7 @@ EXPORTS= nsIDOMInstallTriggerGlobal.h \
XPIDLSRCS = \
.\nsIXPINotifier.idl \
.\nsIXPIProgressDlg.idl \
.\nsPvtIXPIStubHook.idl \
$(NULL)
include <$(DEPTH)\config\rules.mak>

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

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

@ -165,22 +165,44 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
}
else
{
nsresult rv = NS_OK;
PRInt32 folderDirSpecID = MapNameToEnum(aFolderID);
switch (folderDirSpecID)
{
case 100: /////////////////////////////////////////////////////////// Plugins
SetAppShellDirectory(nsSpecialFileSpec::App_PluginsDirectory );
if (!nsSoftwareUpdate::GetProgramDirectory())
{
SetAppShellDirectory(nsSpecialFileSpec::App_PluginsDirectory );
}
else
{
rv = nsSoftwareUpdate::GetProgramDirectory()->GetFileSpec(mFileSpec);
if (NS_SUCCEEDED(rv))
{
#ifdef XP_MAC
*mFileSpec += "Plugins";
#else
*mFileSpec += "plugins";
}
else
mFileSpec = nsnull;
#endif
}
break;
case 101: /////////////////////////////////////////////////////////// Program
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::OS_CurrentProcessDirectory ));
case 102: /////////////////////////////////////////////////////////// Communicator
if (!nsSoftwareUpdate::GetProgramDirectory())
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::OS_CurrentProcessDirectory ));
else
{
rv = nsSoftwareUpdate::GetProgramDirectory()->GetFileSpec(mFileSpec);
if (!NS_SUCCEEDED(rv))
mFileSpec = nsnull;
}
break;
case 102: /////////////////////////////////////////////////////////// Communicator
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::OS_CurrentProcessDirectory ));
break;
case 103: /////////////////////////////////////////////////////////// User Pick
// we should never be here.
mFileSpec = nsnull;
@ -230,11 +252,41 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
break;
case 110: /////////////////////////////////////////////////////////// Components
SetAppShellDirectory(nsSpecialFileSpec::App_ComponentsDirectory );
if (!nsSoftwareUpdate::GetProgramDirectory())
SetAppShellDirectory(nsSpecialFileSpec::App_ComponentsDirectory );
else
{
rv = nsSoftwareUpdate::GetProgramDirectory()->GetFileSpec(mFileSpec);
if (!NS_SUCCEEDED(rv))
mFileSpec = nsnull;
else
{
#ifdef XP_MAC
*mFileSpec += "Components";
#else
*mFileSpec += "components";
#endif
}
}
break;
case 111: /////////////////////////////////////////////////////////// Chrome
SetAppShellDirectory(nsSpecialFileSpec::App_ChromeDirectory );
if (!nsSoftwareUpdate::GetProgramDirectory())
SetAppShellDirectory(nsSpecialFileSpec::App_ChromeDirectory );
else
{
rv = nsSoftwareUpdate::GetProgramDirectory()->GetFileSpec(mFileSpec);
if (!NS_SUCCEEDED(rv))
mFileSpec = nsnull;
else
{
#ifdef XP_MAC
*mFileSpec += "Chrome";
#else
*mFileSpec += "chrome";
#endif
}
}
break;
case 200: /////////////////////////////////////////////////////////// Win System

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

@ -84,6 +84,7 @@ static NS_DEFINE_IID(kInstallVersion_CID, NS_SoftwareUpdateInstallVersion_CID);
nsSoftwareUpdate* nsSoftwareUpdate::mInstance = nsnull;
nsIFileSpec* nsSoftwareUpdate::mProgramDir = nsnull;
nsSoftwareUpdate *
@ -105,7 +106,8 @@ nsSoftwareUpdate::nsSoftwareUpdate()
#endif
NS_INIT_ISUPPORTS();
mStubLockout = PR_FALSE;
/***************************************/
/* Create us a queue */
/***************************************/
@ -185,14 +187,22 @@ nsSoftwareUpdate::~nsSoftwareUpdate()
mJarInstallQueue = nsnull;
}
PR_Unlock(mLock);
PR_DestroyLock(mLock);
NR_ShutdownRegistry();
if (mProgramDir)
mProgramDir->Release();
}
//------------------------------------------------------------------------
// nsISupports implementation
//------------------------------------------------------------------------
NS_IMPL_ADDREF( nsSoftwareUpdate );
NS_IMPL_RELEASE( nsSoftwareUpdate );
NS_IMETHODIMP
nsSoftwareUpdate::QueryInterface( REFNSIID anIID, void **anInstancePtr )
{
@ -210,6 +220,8 @@ nsSoftwareUpdate::QueryInterface( REFNSIID anIID, void **anInstancePtr )
*anInstancePtr = (void*) ( (nsISoftwareUpdate*)this );
else if ( anIID.Equals( nsIAppShellComponent::GetIID() ) )
*anInstancePtr = (void*) ( (nsIAppShellComponent*)this );
else if (anIID.Equals( nsPvtIXPIStubHook::GetIID() ) )
*anInstancePtr = (void*) ( (nsPvtIXPIStubHook*)this );
else if ( anIID.Equals( kISupportsIID ) )
*anInstancePtr = (void*) ( (nsISupports*) (nsISoftwareUpdate*) this );
else
@ -232,6 +244,8 @@ nsSoftwareUpdate::Initialize( nsIAppShellService *anAppShell, nsICmdLineService
{
nsresult rv;
mStubLockout = PR_TRUE; // prevent use of nsPvtIXPIStubHook by browser
rv = nsServiceManager::RegisterService( NS_IXPINSTALLCOMPONENT_PROGID, ( (nsISupports*) (nsISoftwareUpdate*) this ) );
return rv;
@ -337,15 +351,18 @@ nsSoftwareUpdate::RunNextInstall()
if ( info )
mInstalling = PR_TRUE;
else
// XXX leaks any nsInstallInfos left in queue
else
{
NS_ERROR("leaking all nsInstallInfos left in queue");
rv = NS_ERROR_NULL_POINTER;
VR_Close();
}
}
else
{
// nothing more to do
VR_Close();
}
}
else
{
// nothing more to do
VR_Close();
}
PR_Unlock(mLock);
@ -357,6 +374,31 @@ nsSoftwareUpdate::RunNextInstall()
}
NS_IMETHODIMP
nsSoftwareUpdate::SetProgramDirectory(nsIFileSpec *aDir)
{
if (mStubLockout)
return NS_ERROR_ABORT;
else if ( !aDir )
return NS_ERROR_NULL_POINTER;
// fix GetFolder return path
mProgramDir = aDir;
mProgramDir->AddRef();
// setup version registry path
char* path;
nsresult rv = aDir->GetNativePath( &path );
if (NS_SUCCEEDED(rv))
{
VR_SetRegDirectory( path );
}
return rv;
}
/////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////

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

@ -17,9 +17,12 @@ class nsInstallInfo;
#include "nsIScriptExternalNameSet.h"
#include "nsIAppShellComponent.h"
#include "nsIXPINotifier.h"
#include "nsPvtIXPIStubHook.h"
#include "nsTopProgressNotifier.h"
class nsSoftwareUpdate: public nsIAppShellComponent, public nsISoftwareUpdate
class nsSoftwareUpdate: public nsIAppShellComponent,
public nsISoftwareUpdate,
public nsPvtIXPIStubHook
{
public:
@ -27,8 +30,11 @@ class nsSoftwareUpdate: public nsIAppShellComponent, public nsISoftwareUpdate
static nsSoftwareUpdate *GetInstance();
nsSoftwareUpdate();
virtual ~nsSoftwareUpdate();
/** GetProgramDirectory
* information used within the XPI module -- not
* available through any interface
*/
static nsIFileSpec* GetProgramDirectory() { return mProgramDir; }
NS_DECL_ISUPPORTS
NS_DECL_IAPPSHELLCOMPONENT
@ -44,16 +50,28 @@ class nsSoftwareUpdate: public nsIAppShellComponent, public nsISoftwareUpdate
NS_IMETHOD InstallJarCallBack();
NS_IMETHOD GetMasterNotifier(nsIXPINotifier **notifier);
NS_IMETHOD SetActiveNotifier(nsIXPINotifier *notifier);
/** SetProgramDirectory() 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 SetProgramDirectory(nsIFileSpec *dir);
nsSoftwareUpdate();
virtual ~nsSoftwareUpdate();
private:
static nsSoftwareUpdate* mInstance;
static nsIFileSpec* mProgramDir;
nsresult RunNextInstall();
nsresult DeleteScheduledNodes();
PRLock* mLock;
PRBool mInstalling;
PRBool mStubLockout;
nsVector* mJarInstallQueue;
nsTopProgressNotifier mMasterNotifier;
};

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

@ -40,9 +40,6 @@
#include "plstr.h"
#ifdef XP_PC
#include <direct.h>
#endif
//------------------------------------------------------------------------
@ -51,6 +48,7 @@
static nsIXPINotifier *gNotifier = 0;
static nsISoftwareUpdate *gXPI = 0;
static nsIServiceManager *gServiceMgr = 0;
static NS_DEFINE_IID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID);
@ -59,43 +57,25 @@ static NS_DEFINE_IID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID);
//------------------------------------------------------------------------
// XPI_Init()
//------------------------------------------------------------------------
PR_PUBLIC_API(nsresult) XPI_Init( pfnXPIStart startCB,
pfnXPIProgress progressCB,
pfnXPIFinal finalCB )
PR_PUBLIC_API(nsresult) XPI_Init(
#ifdef XP_MAC
const FSSpec& aDir,
#else
const char* aDir,
#endif
pfnXPIStart startCB,
pfnXPIProgress progressCB,
pfnXPIFinal finalCB )
{
nsresult rv;
char szTemp[_MAX_PATH];
nsCOMPtr<nsIFileSpec> nsIfsDirectory;
nsFileSpec nsfsDirectory;
#ifdef XP_PC
//
// Passing 0 as the 2nd parameter to AutoRegister() will tell it to
// automatically determine the path to the components directory.
// Since XPI_Init() is being called by Setup.exe, not apprunner.exe,
// the wrong components directory is determined.
// As a requirement to loading xpistub.dll, it must be loaded from
// the same directory as xpcom.dll.
// This makes is easy to locate the correct components directory by
// using a form of GetCurrentDirectory().
//
// Since nsFileSpec() does not contain a GetCwd() function,
// a call to getcwd() is being used under Windows only.
//
rv = NS_InitXPCOM(&gServiceMgr);
if (!NS_SUCCEEDED(rv))
return rv;
getcwd(szTemp, _MAX_PATH);
PL_strcat(szTemp, "\\");
PL_strcat(szTemp, "components");
nsfsDirectory = szTemp;
rv = NS_NewFileSpecWithSpec(*(&nsfsDirectory), getter_AddRefs(nsIfsDirectory));
if(NS_FAILED(rv))
return rv;
rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, nsIfsDirectory);
#else
rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, 0);
#endif
if (NS_SUCCEEDED(rv))
{
rv = nsComponentManager::CreateInstance(kSoftwareUpdateCID,
@ -134,7 +114,8 @@ PR_PUBLIC_API(void) XPI_Exit()
if (gXPI)
gXPI->Release();
// XXX How do I shut down XPCOM? Do I need to?
NS_ShutdownXPCOM(gServiceMgr);
}
@ -144,13 +125,13 @@ PR_PUBLIC_API(void) XPI_Exit()
// XPI_Install()
//------------------------------------------------------------------------
PR_PUBLIC_API(nsresult) XPI_Install(
#ifndef XP_MAC
const char* aFile,
#else
#ifdef XP_MAC
const FSSpec& aFile,
#else
const char* aFile,
#endif
const char* aArgs,
long aFlags )
const char* aArgs,
long aFlags )
{
nsresult rv = NS_ERROR_NULL_POINTER;
nsString args(aArgs);

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

@ -60,33 +60,47 @@ typedef void (*pfnXPIProgress)(const char* msg, PRInt32 val, PRInt32 max);
typedef void (*pfnXPIFinal) (const char* URL, PRInt32 finalStatus);
/** XPI_Init
*
* call XPI_Init() to initialize XPCOM and the XPInstall
* engine, and to pass in your callback functions
* engine, and to pass in your callback functions.
*
* @param aDir directory to use as "program" directory. If NULL default
* will be used -- the location of the calling executable.
* Must be native filename format.
* @param startCB Called when script started
* @param progressCB Called for each installed file
* @param finalCB Called with status code at end
*
* @returns XPCOM status code indicating success or failure
*/
PR_EXTERN(nsresult) XPI_Init( pfnXPIStart startCB,
pfnXPIProgress progressCB,
pfnXPIFinal finalCB );
PR_EXTERN(nsresult) XPI_Init(
#ifdef XP_MAC
const FSSpec& aDir,
#else
const char* aDir,
#endif
pfnXPIStart startCB,
pfnXPIProgress progressCB,
pfnXPIFinal finalCB );
/** XPI_Install
*
* Install a XPI package from a local file
* Install an XPI package from a local file
*
* @param file Native filename of XPI archive
* @param args Install.arguments, if any
* @param flags the old SmartUpdate trigger flags. This may go away
*/
PR_EXTERN(nsresult) XPI_Install(
#ifndef XP_MAC
const char* file,
PR_EXTERN(nsresult) XPI_Install(
#ifdef XP_MAC
const FSSpec& file,
#else
const FSSpec& file,
const char* file,
#endif
const char* args,
long flags );
const char* args,
long flags );
/** XPI_Exit
*