зеркало из https://github.com/mozilla/pjs.git
Run is working in the viewer.
Removing some older unused files.
This commit is contained in:
Родитель
6cf27d2a67
Коммит
ed24bdd135
|
@ -34,10 +34,6 @@ class nsISoftwareUpdate : public nsISupports
|
|||
{
|
||||
public:
|
||||
static const nsIID& IID() { static nsIID iid = NS_ISOFTWAREUPDATE_IID; return iid; }
|
||||
|
||||
NS_IMETHOD Startup() = 0;
|
||||
|
||||
NS_IMETHOD Shutdown()= 0;
|
||||
|
||||
NS_IMETHOD InstallJar(nsInstallInfo *installInfo) = 0;
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ REQUIRES = dom js netlib raptor xpcom
|
|||
|
||||
CPPSRCS = \
|
||||
nsSoftwareUpdate.cpp \
|
||||
nsSoftwareUpdateQueue.cpp \
|
||||
nsInstall.cpp \
|
||||
nsInstallDelete.cpp \
|
||||
nsInstallExecute.cpp \
|
||||
|
|
|
@ -72,7 +72,6 @@ OBJS = \
|
|||
.\$(OBJDIR)\nsJSInstallTriggerGlobal.obj \
|
||||
.\$(OBJDIR)\nsJSInstallVersion.obj \
|
||||
.\$(OBJDIR)\nsSoftwareUpdate.obj \
|
||||
.\$(OBJDIR)\nsSoftwareUpdateQueue.obj \
|
||||
.\$(OBJDIR)\nsSoftwareUpdateRun.obj \
|
||||
.\$(OBJDIR)\nsSoftwareUpdateStream.obj \
|
||||
.\$(OBJDIR)\nsInstallFile.obj \
|
||||
|
|
|
@ -68,62 +68,51 @@ 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 PRInt32 gLockCnt = 0;
|
||||
|
||||
static PRInt32 gStarted = 0;
|
||||
static PRInt32 gInstalling = 0;
|
||||
static PRInt32 gDownloading = 0;
|
||||
|
||||
static nsVector* gJarInstallQueue = nsnull;
|
||||
static nsVector* gJarDownloadQueue = nsnull;
|
||||
|
||||
|
||||
|
||||
nsSoftwareUpdate* nsSoftwareUpdate::mInstance = NULL;
|
||||
|
||||
nsSoftwareUpdate::nsSoftwareUpdate()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
||||
if (gStarted == 0)
|
||||
Startup();
|
||||
|
||||
PR_AtomicIncrement(&gStarted);
|
||||
|
||||
Startup();
|
||||
}
|
||||
nsSoftwareUpdate::~nsSoftwareUpdate()
|
||||
{
|
||||
PR_AtomicDecrement(&gStarted);
|
||||
|
||||
if (gStarted == 0)
|
||||
Shutdown();
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
nsSoftwareUpdate *nsSoftwareUpdate::GetInstance()
|
||||
{
|
||||
if (mInstance == NULL)
|
||||
{
|
||||
mInstance = new nsSoftwareUpdate();
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsSoftwareUpdate,NS_ISOFTWAREUPDATE_IID)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsSoftwareUpdate::Startup()
|
||||
{
|
||||
/***************************************/
|
||||
/* Create us a queue */
|
||||
/***************************************/
|
||||
|
||||
gJarInstallQueue = new nsVector();
|
||||
mInstalling = nsnull;
|
||||
|
||||
mJarInstallQueue = new nsVector();
|
||||
|
||||
/***************************************/
|
||||
/* Add us to the Javascript Name Space */
|
||||
/***************************************/
|
||||
|
||||
nsIScriptNameSetRegistry *scriptNameSet;
|
||||
nsresult result = nsServiceManager::GetService(kCScriptNameSetRegistryCID,
|
||||
kIScriptNameSetRegistryIID,
|
||||
(nsISupports **)&scriptNameSet);
|
||||
if (NS_OK == result)
|
||||
{
|
||||
nsSoftwareUpdateNameSet* nameSet = new nsSoftwareUpdateNameSet();
|
||||
scriptNameSet->AddExternalNameSet(nameSet);
|
||||
}
|
||||
|
||||
new nsSoftwareUpdateNameSet();
|
||||
|
||||
/***************************************/
|
||||
/* Register us with NetLib */
|
||||
/***************************************/
|
||||
|
@ -143,7 +132,7 @@ nsSoftwareUpdate::Startup()
|
|||
/* Stupid Hack to test js env*/
|
||||
/***************************************/
|
||||
// FIX: HACK HACK HACK!
|
||||
#if 1
|
||||
#if 0
|
||||
nsSpecialSystemDirectory jarFile(nsSpecialSystemDirectory::OS_TemporaryDirectory);
|
||||
jarFile += "test.jar";
|
||||
if (jarFile.Exists())
|
||||
|
@ -161,21 +150,22 @@ nsSoftwareUpdate::Startup()
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsSoftwareUpdate::Shutdown()
|
||||
{
|
||||
if (gJarInstallQueue != nsnull)
|
||||
if (mJarInstallQueue != nsnull)
|
||||
{
|
||||
PRUint32 i=0;
|
||||
for (; i < gJarInstallQueue->GetSize(); i++)
|
||||
for (; i < mJarInstallQueue->GetSize(); i++)
|
||||
{
|
||||
nsInstallInfo* element = (nsInstallInfo*)gJarInstallQueue->Get(i);
|
||||
nsInstallInfo* element = (nsInstallInfo*)mJarInstallQueue->Get(i);
|
||||
//FIX: need to add to registry....
|
||||
delete element;
|
||||
}
|
||||
|
||||
gJarInstallQueue->RemoveAll();
|
||||
delete (gJarInstallQueue);
|
||||
gJarInstallQueue = nsnull;
|
||||
mJarInstallQueue->RemoveAll();
|
||||
delete (mJarInstallQueue);
|
||||
mJarInstallQueue = nsnull;
|
||||
}
|
||||
|
||||
NR_ShutdownRegistry();
|
||||
|
@ -198,7 +188,7 @@ nsSoftwareUpdate::InstallJar( const nsString& fromURL,
|
|||
NS_IMETHODIMP
|
||||
nsSoftwareUpdate::InstallJar(nsInstallInfo *installInfo)
|
||||
{
|
||||
gJarInstallQueue->Add( installInfo );
|
||||
mJarInstallQueue->Add( installInfo );
|
||||
UpdateInstallJarQueue();
|
||||
|
||||
return NS_OK;
|
||||
|
@ -208,20 +198,20 @@ nsSoftwareUpdate::InstallJar(nsInstallInfo *installInfo)
|
|||
nsresult
|
||||
nsSoftwareUpdate::UpdateInstallJarQueue()
|
||||
{
|
||||
if (gInstalling == 0)
|
||||
if (mInstalling == 0)
|
||||
{
|
||||
gInstalling++;
|
||||
mInstalling++;
|
||||
|
||||
if (gJarInstallQueue->GetSize() <= 0)
|
||||
if (mJarInstallQueue->GetSize() <= 0)
|
||||
{
|
||||
gInstalling--;
|
||||
mInstalling--;
|
||||
return 0;
|
||||
}
|
||||
nsInstallInfo *nextInstall = (nsInstallInfo*)gJarInstallQueue->Get(0);
|
||||
nsInstallInfo *nextInstall = (nsInstallInfo*)mJarInstallQueue->Get(0);
|
||||
|
||||
if (nextInstall == nsnull)
|
||||
{
|
||||
gInstalling--;
|
||||
mInstalling--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -230,9 +220,9 @@ nsSoftwareUpdate::UpdateInstallJarQueue()
|
|||
Install( nextInstall );
|
||||
|
||||
delete nextInstall;
|
||||
gJarInstallQueue->Remove(0);
|
||||
mJarInstallQueue->Remove(0);
|
||||
|
||||
gInstalling--;
|
||||
mInstalling--;
|
||||
|
||||
// We are done with install the last jar, let see if there are any more.
|
||||
UpdateInstallJarQueue(); // FIX: Maybe we should do this different to avoid blowing our stack?
|
||||
|
@ -280,15 +270,19 @@ nsSoftwareUpdateFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void
|
|||
|
||||
*aResult = NULL;
|
||||
|
||||
nsSoftwareUpdate *inst = new nsSoftwareUpdate();
|
||||
nsSoftwareUpdate *inst = nsSoftwareUpdate::GetInstance();
|
||||
|
||||
if (inst == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult result = inst->QueryInterface(aIID, aResult);
|
||||
|
||||
if (result != NS_OK)
|
||||
delete inst;
|
||||
if (NS_FAILED(result))
|
||||
{
|
||||
*aResult = NULL;
|
||||
}
|
||||
|
||||
NS_ADDREF(inst); // Are we sure that we need to addref???
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -313,6 +307,16 @@ nsSoftwareUpdateFactory::LockFactory(PRBool aLock)
|
|||
nsSoftwareUpdateNameSet::nsSoftwareUpdateNameSet()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
nsIScriptNameSetRegistry *scriptNameSet;
|
||||
nsresult result = nsServiceManager::GetService(kCScriptNameSetRegistryCID,
|
||||
kIScriptNameSetRegistryIID,
|
||||
(nsISupports **)&scriptNameSet);
|
||||
if (NS_OK == result)
|
||||
{
|
||||
scriptNameSet->AddExternalNameSet(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
nsSoftwareUpdateNameSet::~nsSoftwareUpdateNameSet()
|
||||
|
@ -370,7 +374,7 @@ nsSoftwareUpdateNameSet::AddNameSet(nsIScriptContext* aScriptContext)
|
|||
extern "C" NS_EXPORT PRBool
|
||||
NSCanUnload(nsISupports* serviceMgr)
|
||||
{
|
||||
return PRBool (gStarted == 0 && gLockCnt == 0);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult
|
||||
|
|
|
@ -23,10 +23,10 @@ class nsSoftwareUpdate: public nsISoftwareUpdate
|
|||
nsSoftwareUpdate();
|
||||
~nsSoftwareUpdate();
|
||||
|
||||
static nsSoftwareUpdate *GetInstance();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Startup();
|
||||
NS_IMETHOD Shutdown();
|
||||
NS_IMETHOD InstallJar(nsInstallInfo *installInfo);
|
||||
NS_IMETHOD InstallJar(const nsString& fromURL,
|
||||
const nsString& flags,
|
||||
|
@ -35,8 +35,19 @@ class nsSoftwareUpdate: public nsISoftwareUpdate
|
|||
|
||||
|
||||
private:
|
||||
nsresult Startup();
|
||||
nsresult Shutdown();
|
||||
|
||||
nsresult UpdateInstallJarQueue();
|
||||
nsresult DeleteScheduledNodes();
|
||||
|
||||
PRInt32 mInstalling;
|
||||
nsVector* mJarInstallQueue;
|
||||
|
||||
static nsSoftwareUpdate* mInstance;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -15,26 +15,21 @@
|
|||
|
||||
#include "nsRepository.h"
|
||||
|
||||
#include "nsIWebShellWindow.h"
|
||||
#include "nsIBrowserWindow.h"
|
||||
#include "nsIWebShell.h"
|
||||
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptContextOwner.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsIAppShellService.h"
|
||||
|
||||
#include "nsIURL.h"
|
||||
|
||||
extern PRInt32 InitXPInstallObjects(nsIScriptContext *aContext, const char* jarfile, const char* args);
|
||||
|
||||
static NS_DEFINE_IID(kWebShellWindowIID, NS_IWEBSHELL_WINDOW_IID);
|
||||
static NS_DEFINE_IID(kIBrowserWindowIID, NS_IBROWSER_WINDOW_IID);
|
||||
static NS_DEFINE_IID(kBrowserWindowCID, NS_BROWSER_WINDOW_CID);
|
||||
static NS_DEFINE_IID(kIScriptContextOwnerIID, NS_ISCRIPTCONTEXTOWNER_IID);
|
||||
|
||||
static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
static NS_DEFINE_IID(kIAppShellServiceIID, NS_IAPPSHELL_SERVICE_IID);
|
||||
|
||||
/* ReadFileIntoBuffer
|
||||
* given a file name, reads it into buffer
|
||||
* returns an error code
|
||||
|
@ -104,12 +99,10 @@ extern "C" NS_EXPORT PRInt32 Install(const char* jarFile, const char* flags, con
|
|||
// Open the jarfile.
|
||||
void* hZip;
|
||||
|
||||
PRInt32 result = ZIP_OpenArchive(jarFile , &hZip);
|
||||
PRInt32 rv = ZIP_OpenArchive(jarFile , &hZip);
|
||||
|
||||
if (result != ZIP_OK)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if (rv != ZIP_OK)
|
||||
return rv;
|
||||
|
||||
|
||||
// Read manifest file for Install Script filename.
|
||||
|
@ -121,81 +114,71 @@ extern "C" NS_EXPORT PRInt32 Install(const char* jarFile, const char* flags, con
|
|||
installJSFileSpec.MakeUnique();
|
||||
|
||||
// Extract the install.js file.
|
||||
result = ZIP_ExtractFile( hZip, "install.js", installJSFileSpec.GetCString() );
|
||||
if (result != ZIP_OK)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
nsIAppShellService *appShell = nsnull;
|
||||
nsIURL *url;
|
||||
nsIWidget *newWindow;
|
||||
nsIWebShellWindow *webShellWindow;
|
||||
nsIWebShell *aWebShell;
|
||||
|
||||
nsresult rv = NS_NewURL(&url, "resource:/res/install/progress.xul");
|
||||
if (NS_FAILED(rv))
|
||||
rv = ZIP_ExtractFile( hZip, "install.js", installJSFileSpec.GetCString() );
|
||||
if (rv != ZIP_OK)
|
||||
{
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIWebShell* aWebShell = nsnull;
|
||||
nsIBrowserWindow* aWindow = nsnull;
|
||||
|
||||
// Create a new window so that we can display UI.
|
||||
|
||||
rv = nsServiceManager::GetService( kAppShellServiceCID,
|
||||
kIAppShellServiceIID,
|
||||
(nsISupports**) &appShell);
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kBrowserWindowCID,
|
||||
nsnull,
|
||||
kIBrowserWindowIID,
|
||||
(void**) &aWindow);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
{
|
||||
goto bail;
|
||||
}
|
||||
|
||||
aWindow->Init(nsnull, nsnull, nsRect(0, 0, 300, 300), PRUint32(~0), PR_FALSE);
|
||||
|
||||
rv = aWindow->GetWebShell(aWebShell);
|
||||
|
||||
appShell->CreateTopLevelWindow( nsnull, url, nsString("CID"), newWindow, nsnull, nsnull, 375, 375);
|
||||
|
||||
NS_RELEASE(url);
|
||||
|
||||
|
||||
if (rv == NS_OK)
|
||||
{
|
||||
// rv = newWindow->GetWebShell(aWebShell);
|
||||
nsIScriptContextOwner* scriptContextOwner;
|
||||
nsIScriptContext* scriptContext;
|
||||
|
||||
rv = aWebShell->QueryInterface( kIScriptContextOwnerIID, (void**)&scriptContextOwner);
|
||||
|
||||
if (rv == NS_OK)
|
||||
{
|
||||
nsIScriptContextOwner* scriptContextOwner;
|
||||
nsIScriptContext* scriptContext;
|
||||
rv = scriptContextOwner->GetScriptContext(&scriptContext);
|
||||
|
||||
rv = aWebShell->QueryInterface( kIScriptContextOwnerIID, (void**)&scriptContextOwner);
|
||||
|
||||
if (rv == NS_OK)
|
||||
if (NS_OK == rv)
|
||||
{
|
||||
rv = scriptContextOwner->GetScriptContext(&scriptContext);
|
||||
|
||||
InitXPInstallObjects(scriptContext, jarFile, args );
|
||||
|
||||
if (NS_OK == rv)
|
||||
{
|
||||
|
||||
InitXPInstallObjects(scriptContext, jarFile, args );
|
||||
char* buffer;
|
||||
unsigned long bufferLength;
|
||||
|
||||
ReadFileIntoBuffer(installJSFileSpec, &buffer, &bufferLength);
|
||||
|
||||
char* buffer;
|
||||
unsigned long bufferLength;
|
||||
|
||||
ReadFileIntoBuffer(installJSFileSpec, &buffer, &bufferLength);
|
||||
nsAutoString retval;
|
||||
PRBool isUndefined;
|
||||
// We expected this to block.
|
||||
scriptContext->EvaluateString(nsString(buffer), nsnull, 0, retval, &isUndefined);
|
||||
|
||||
nsAutoString retval;
|
||||
PRBool isUndefined;
|
||||
// We expected this to block.
|
||||
scriptContext->EvaluateString(nsString(buffer), nsnull, 0, retval, &isUndefined);
|
||||
|
||||
PR_FREEIF(buffer);
|
||||
NS_RELEASE(scriptContext);
|
||||
}
|
||||
|
||||
NS_RELEASE(scriptContextOwner);
|
||||
PR_FREEIF(buffer);
|
||||
NS_RELEASE(scriptContext);
|
||||
}
|
||||
|
||||
|
||||
NS_RELEASE(scriptContextOwner);
|
||||
}
|
||||
appShell->CloseTopLevelWindow(newWindow);
|
||||
// close and release window.
|
||||
// NS_RELEASE(aWebShell);
|
||||
}
|
||||
else
|
||||
|
||||
bail:
|
||||
|
||||
if (aWindow != nsnull)
|
||||
{
|
||||
return -1;
|
||||
aWindow->Close();
|
||||
NS_RELEASE(aWindow);
|
||||
}
|
||||
|
||||
ZIP_CloseArchive(&hZip);
|
||||
|
|
Загрузка…
Ссылка в новой задаче