mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 13:07:52 +00:00
compareVersion() returns NOT_FOUND rather than comparing as if a missing
component had a version of 0.0.0.0. Removed some dead code. r=sgehani sr= mscott
This commit is contained in:
parent
6a1cc39113
commit
27743a2a68
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
@ -22,7 +22,7 @@
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
@ -46,12 +46,13 @@
|
||||
|
||||
#define NS_IDOMINSTALLTRIGGERGLOBAL_IID \
|
||||
{ 0x18c2f987, 0xb09f, 0x11d2, \
|
||||
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53}}
|
||||
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53}}
|
||||
|
||||
class nsIDOMInstallTriggerGlobal : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMINSTALLTRIGGERGLOBAL_IID; return iid; }
|
||||
enum {
|
||||
NOT_FOUND = -5,
|
||||
MAJOR_DIFF = 4,
|
||||
MINOR_DIFF = 3,
|
||||
REL_DIFF = 2,
|
||||
|
@ -10,15 +10,15 @@
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
* The Original Code is Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Contributor(s):
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
@ -57,20 +57,20 @@
|
||||
0xb09f, \
|
||||
0x11d2, \
|
||||
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53}\
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class nsISoftwareUpdate : public nsISupports
|
||||
class nsISoftwareUpdate : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISOFTWAREUPDATE_IID)
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISOFTWAREUPDATE_IID)
|
||||
|
||||
NS_IMETHOD InstallJar(nsIFile* localFile,
|
||||
const PRUnichar* URL,
|
||||
const PRUnichar* arguments,
|
||||
nsIDOMWindowInternal* aParentWindow,
|
||||
PRUint32 flags,
|
||||
nsIXPIListener* aListener = 0) = 0;
|
||||
nsIXPIListener* aListener = 0) = 0;
|
||||
|
||||
NS_IMETHOD InstallChrome(PRUint32 aType,
|
||||
nsIFile* aFile,
|
||||
@ -78,39 +78,17 @@ class nsISoftwareUpdate : public nsISupports
|
||||
const PRUnichar* aName,
|
||||
PRBool aSelect,
|
||||
nsIXPIListener* aListener = 0) = 0;
|
||||
|
||||
|
||||
NS_IMETHOD RegisterListener(nsIXPIListener *aListener) = 0;
|
||||
|
||||
|
||||
/* FIX: these should be in a private interface */
|
||||
NS_IMETHOD InstallJarCallBack() = 0;
|
||||
NS_IMETHOD InstallJarCallBack() = 0;
|
||||
NS_IMETHOD GetMasterListener(nsIXPIListener **aListener) = 0;
|
||||
NS_IMETHOD SetActiveListener(nsIXPIListener *aListener) = 0;
|
||||
NS_IMETHOD StartupTasks( PRBool* outAutoreg ) = 0;
|
||||
};
|
||||
|
||||
|
||||
// Module implementation
|
||||
class nsSoftwareUpdateModule : public nsIModule
|
||||
{
|
||||
public:
|
||||
nsSoftwareUpdateModule();
|
||||
virtual ~nsSoftwareUpdateModule();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIMODULE
|
||||
|
||||
protected:
|
||||
nsresult Initialize();
|
||||
|
||||
void Shutdown();
|
||||
|
||||
PRBool mInitialized;
|
||||
nsCOMPtr<nsIGenericFactory> mSoftwareUpdateFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mInstallTriggerFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mInstallVersionFactory;
|
||||
};
|
||||
|
||||
#define XPI_ROOT_KEY "software/mozilla/xpinstall"
|
||||
#define XPI_AUTOREG_VAL "Autoreg"
|
||||
#define XPCOM_KEY "software/mozilla/XPCOM"
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
@ -22,7 +22,7 @@
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
@ -52,10 +52,6 @@
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsIDirectoryService.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
|
||||
#include "VerReg.h"
|
||||
|
||||
#include "nsIContentHandler.h"
|
||||
@ -76,6 +72,9 @@ nsInstallTrigger::nsInstallTrigger()
|
||||
{
|
||||
mScriptObject = nsnull;
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
||||
// make sure all the SoftwareUpdate initialization has happened
|
||||
nsCOMPtr<nsISoftwareUpdate> svc (do_GetService(NS_IXPINSTALLCOMPONENT_CONTRACTID));
|
||||
}
|
||||
|
||||
nsInstallTrigger::~nsInstallTrigger()
|
||||
@ -89,31 +88,31 @@ NS_IMPL_THREADSAFE_ISUPPORTS3 (nsInstallTrigger,
|
||||
nsIContentHandler);
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aScriptObject, "null arg");
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (nsnull == mScriptObject)
|
||||
|
||||
if (nsnull == mScriptObject)
|
||||
{
|
||||
nsIScriptGlobalObject *global = nsnull;
|
||||
aContext->GetGlobalObject(&global);
|
||||
|
||||
res = NS_NewScriptInstallTriggerGlobal( aContext,
|
||||
(nsISupports *)(nsIDOMInstallTriggerGlobal*)this,
|
||||
(nsISupports *)global,
|
||||
res = NS_NewScriptInstallTriggerGlobal( aContext,
|
||||
(nsISupports *)(nsIDOMInstallTriggerGlobal*)this,
|
||||
(nsISupports *)global,
|
||||
&mScriptObject);
|
||||
NS_IF_RELEASE(global);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
@ -123,10 +122,10 @@ nsInstallTrigger::SetScriptObject(void *aScriptObject)
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::HandleContent(const char * aContentType,
|
||||
const char * aCommand,
|
||||
nsISupports* aWindowContext,
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::HandleContent(const char * aContentType,
|
||||
const char * aCommand,
|
||||
nsISupports* aWindowContext,
|
||||
nsIRequest* request)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
@ -138,9 +137,9 @@ nsInstallTrigger::HandleContent(const char * aContentType,
|
||||
rv = aChannel->GetURI(getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
request->Cancel(NS_BINDING_ABORTED);
|
||||
request->Cancel(NS_BINDING_ABORTED);
|
||||
|
||||
if (uri) {
|
||||
if (uri) {
|
||||
nsXPIDLCString spec;
|
||||
rv = uri->GetSpec(getter_Copies(spec));
|
||||
if (NS_FAILED(rv))
|
||||
@ -156,7 +155,7 @@ nsInstallTrigger::HandleContent(const char * aContentType,
|
||||
PRBool value;
|
||||
rv = StartSoftwareUpdate(globalObject, NS_ConvertASCIItoUCS2(spec), 0, &value);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && value)
|
||||
if (NS_SUCCEEDED(rv) && value)
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
@ -166,12 +165,12 @@ nsInstallTrigger::HandleContent(const char * aContentType,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::UpdateEnabled(PRBool* aReturn)
|
||||
{
|
||||
nsIPref * prefs;
|
||||
|
||||
nsresult rv = nsServiceManager::GetService(kPrefsCID,
|
||||
|
||||
nsresult rv = nsServiceManager::GetService(kPrefsCID,
|
||||
kPrefsIID,
|
||||
(nsISupports**) &prefs);
|
||||
|
||||
@ -204,7 +203,7 @@ nsInstallTrigger::Install(nsIScriptGlobalObject* aGlobalObject, nsXPITriggerInfo
|
||||
|
||||
PRBool enabled;
|
||||
nsresult rv = UpdateEnabled(&enabled);
|
||||
if (NS_FAILED(rv) || !enabled)
|
||||
if (NS_FAILED(rv) || !enabled)
|
||||
{
|
||||
delete aTrigger;
|
||||
return NS_OK;
|
||||
@ -268,7 +267,7 @@ nsInstallTrigger::InstallChrome(nsIScriptGlobalObject* aGlobalObject, PRUint32 a
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::StartSoftwareUpdate(nsIScriptGlobalObject* aGlobalObject, const nsString& aURL, PRInt32 aFlags, PRBool* aReturn)
|
||||
{
|
||||
PRBool enabled;
|
||||
@ -313,7 +312,7 @@ nsInstallTrigger::StartSoftwareUpdate(nsIScriptGlobalObject* aGlobalObject, cons
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::CompareVersion(const nsString& aRegName, PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild, PRInt32* aReturn)
|
||||
{
|
||||
nsInstallVersion inVersion;
|
||||
@ -322,7 +321,7 @@ nsInstallTrigger::CompareVersion(const nsString& aRegName, PRInt32 aMajor, PRInt
|
||||
return CompareVersion(aRegName, &inVersion, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::CompareVersion(const nsString& aRegName, const nsString& aVersion, PRInt32* aReturn)
|
||||
{
|
||||
nsInstallVersion inVersion;
|
||||
@ -332,37 +331,9 @@ nsInstallTrigger::CompareVersion(const nsString& aRegName, const nsString& aVers
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::InitRegistry(void)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NR_StartupRegistry(); /* startup the registry; if already started, this will essentially be a noop */
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
|
||||
if(!directoryService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsILocalFile> dir;
|
||||
directoryService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(dir));
|
||||
if (dir)
|
||||
{
|
||||
char* nativePath;
|
||||
dir->GetPath(&nativePath);
|
||||
// EVIL version registry does not take a nsIFile.;
|
||||
VR_SetRegDirectory( nativePath );
|
||||
if (nativePath)
|
||||
nsMemory::Free(nativePath);
|
||||
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::CompareVersion(const nsString& aRegName, nsIDOMInstallVersion* aVersion, PRInt32* aReturn)
|
||||
{
|
||||
nsresult rv;
|
||||
*aReturn = EQUAL; // assume failure.
|
||||
*aReturn = NOT_FOUND; // assume failure.
|
||||
|
||||
PRBool enabled;
|
||||
|
||||
@ -374,40 +345,29 @@ nsInstallTrigger::CompareVersion(const nsString& aRegName, nsIDOMInstallVersion*
|
||||
NS_ConvertUCS2toUTF8 regName(aRegName);
|
||||
REGERR status;
|
||||
nsInstallVersion regNameVersion;
|
||||
|
||||
rv = InitRegistry();
|
||||
if(rv != NS_OK)
|
||||
return rv;
|
||||
|
||||
status = VR_GetVersion( NS_CONST_CAST(char *, regName.get()), &cVersion );
|
||||
|
||||
/* if we got the version */
|
||||
if ( status == REGERR_OK )
|
||||
if ( status == REGERR_OK )
|
||||
{
|
||||
if ( VR_ValidateComponent( NS_CONST_CAST(char *, regName.get()) ) == REGERR_NOFILE )
|
||||
// we found the version
|
||||
if ( VR_ValidateComponent( NS_CONST_CAST(char *, regName.get()) ) != REGERR_NOFILE )
|
||||
{
|
||||
regNameVersion.Init(0,0,0,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
regNameVersion.Init(cVersion.major,
|
||||
cVersion.minor,
|
||||
cVersion.release,
|
||||
// and the installed file was not missing: do the compare
|
||||
regNameVersion.Init(cVersion.major,
|
||||
cVersion.minor,
|
||||
cVersion.release,
|
||||
cVersion.build);
|
||||
|
||||
regNameVersion.CompareTo( aVersion, aReturn );
|
||||
}
|
||||
}
|
||||
else
|
||||
regNameVersion.Init(0,0,0,0);
|
||||
|
||||
regNameVersion.CompareTo( aVersion, aReturn );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::GetVersion(const nsString& component, nsString& version)
|
||||
{
|
||||
nsresult rv;
|
||||
PRBool enabled;
|
||||
|
||||
UpdateEnabled(&enabled);
|
||||
@ -417,10 +377,6 @@ nsInstallTrigger::GetVersion(const nsString& component, nsString& version)
|
||||
VERSION cVersion;
|
||||
NS_ConvertUCS2toUTF8 regName(component);
|
||||
REGERR status;
|
||||
|
||||
rv = InitRegistry();
|
||||
if(rv != NS_OK)
|
||||
return rv;
|
||||
|
||||
status = VR_GetVersion( NS_CONST_CAST(char *, regName.get()), &cVersion );
|
||||
|
||||
@ -428,19 +384,19 @@ nsInstallTrigger::GetVersion(const nsString& component, nsString& version)
|
||||
|
||||
/* if we got the version */
|
||||
// XXX fix the right way after PR3 or RTM
|
||||
// if ( status == REGERR_OK && VR_ValidateComponent( tempCString ) == REGERR_OK)
|
||||
// if ( status == REGERR_OK && VR_ValidateComponent( tempCString ) == REGERR_OK)
|
||||
if ( status == REGERR_OK )
|
||||
{
|
||||
nsInstallVersion regNameVersion;
|
||||
|
||||
regNameVersion.Init(cVersion.major,
|
||||
cVersion.minor,
|
||||
cVersion.release,
|
||||
|
||||
regNameVersion.Init(cVersion.major,
|
||||
cVersion.minor,
|
||||
cVersion.release,
|
||||
cVersion.build);
|
||||
|
||||
regNameVersion.ToString(version);
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#define CHROME_DELAYED 0x10
|
||||
#define CHROME_SELECT 0x20
|
||||
|
||||
class nsInstallTrigger: public nsIScriptObjectOwner,
|
||||
class nsInstallTrigger: public nsIScriptObjectOwner,
|
||||
public nsIDOMInstallTriggerGlobal,
|
||||
public nsIContentHandler
|
||||
{
|
||||
@ -34,7 +34,7 @@ class nsInstallTrigger: public nsIScriptObjectOwner,
|
||||
|
||||
nsInstallTrigger();
|
||||
virtual ~nsInstallTrigger();
|
||||
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICONTENTHANDLER
|
||||
|
||||
@ -50,11 +50,9 @@ class nsInstallTrigger: public nsIScriptObjectOwner,
|
||||
NS_IMETHOD CompareVersion(const nsString& aRegName, nsIDOMInstallVersion* aVersion, PRInt32* aReturn);
|
||||
NS_IMETHOD GetVersion(const nsString& component, nsString& version);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
void *mScriptObject;
|
||||
|
||||
NS_IMETHOD InitRegistry(void);
|
||||
};
|
||||
|
||||
#define NS_INSTALLTRIGGERCOMPONENT_CONTRACTID "@mozilla.org/xpinstall/installtrigger;1"
|
||||
|
@ -19,12 +19,12 @@ class nsInstallVersion: public nsIScriptObjectOwner, public nsIDOMInstallVersion
|
||||
|
||||
nsInstallVersion();
|
||||
virtual ~nsInstallVersion();
|
||||
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void* aScriptObject);
|
||||
|
||||
|
||||
NS_IMETHOD Init(PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild);
|
||||
NS_IMETHOD Init(const nsString& aVersionString);
|
||||
|
||||
@ -39,7 +39,7 @@ class nsInstallVersion: public nsIScriptObjectOwner, public nsIDOMInstallVersion
|
||||
|
||||
NS_IMETHOD GetBuild(PRInt32* aBuild);
|
||||
NS_IMETHOD SetBuild(PRInt32 aBuild);
|
||||
|
||||
|
||||
NS_IMETHOD ToString(nsString& aReturn);
|
||||
NS_IMETHOD CompareTo(nsIDOMInstallVersion* aVersion, PRInt32* aReturn);
|
||||
NS_IMETHOD CompareTo(const nsString& aString, PRInt32* aReturn);
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
@ -22,7 +22,7 @@
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
@ -80,12 +80,12 @@ FinalizeInstallTriggerGlobal(JSContext *cx, JSObject *obj)
|
||||
if (nsnull != nativeThis) {
|
||||
// get the js object
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == nativeThis->QueryInterface(NS_GET_IID(nsIScriptObjectOwner),
|
||||
if (NS_OK == nativeThis->QueryInterface(NS_GET_IID(nsIScriptObjectOwner),
|
||||
(void**)&owner)) {
|
||||
owner->SetScriptObject(nsnull);
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
|
||||
|
||||
// The addref was part of JSObject construction
|
||||
NS_RELEASE(nativeThis);
|
||||
}
|
||||
@ -106,11 +106,11 @@ static JSBool CreateNativeObject(JSContext *cx, JSObject *obj, nsIDOMInstallTrig
|
||||
(void **)&nativeThis);
|
||||
|
||||
if (NS_OK != result) return JS_FALSE;
|
||||
|
||||
|
||||
result = nativeThis->QueryInterface(NS_GET_IID(nsIScriptObjectOwner),
|
||||
(void **)&owner);
|
||||
|
||||
if (NS_OK != result)
|
||||
if (NS_OK != result)
|
||||
{
|
||||
NS_RELEASE(nativeThis);
|
||||
return JS_FALSE;
|
||||
@ -118,9 +118,9 @@ static JSBool CreateNativeObject(JSContext *cx, JSObject *obj, nsIDOMInstallTrig
|
||||
|
||||
owner->SetScriptObject((void *)obj);
|
||||
JS_SetPrivate(cx, obj, nativeThis);
|
||||
|
||||
|
||||
*aResult = nativeThis;
|
||||
|
||||
|
||||
NS_RELEASE(nativeThis); // we only want one refcnt. JSUtils cleans us up.
|
||||
return JS_TRUE;
|
||||
}
|
||||
@ -139,7 +139,7 @@ InstallTriggerGlobalUpdateEnabled(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
if (nsnull == nativeThis && (JS_FALSE == CreateNativeObject(cx, obj, &nativeThis)) )
|
||||
return JS_TRUE;
|
||||
|
||||
nativeThis->UpdateEnabled(&nativeRet);
|
||||
nativeThis->UpdateEnabled(&nativeRet);
|
||||
*rval = BOOLEAN_TO_JSVAL(nativeRet);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@ -182,7 +182,7 @@ InstallTriggerGlobalInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// parse associative array of installs
|
||||
if ( argc >= 1 && JSVAL_IS_OBJECT(argv[0]) )
|
||||
{
|
||||
@ -191,7 +191,7 @@ InstallTriggerGlobalInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
||||
return JS_FALSE;
|
||||
|
||||
JSIdArray *ida = JS_Enumerate( cx, JSVAL_TO_OBJECT(argv[0]) );
|
||||
if ( ida )
|
||||
if ( ida )
|
||||
{
|
||||
jsval v;
|
||||
const PRUnichar *name, *URL;
|
||||
@ -302,7 +302,7 @@ InstallTriggerGlobalInstallChrome(JSContext *cx, JSObject *obj, uintN argc, jsva
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ( argc >= 3 )
|
||||
{
|
||||
JS_ValueToECMAUint32(cx, argv[0], &chromeType);
|
||||
@ -490,7 +490,7 @@ PR_STATIC_CALLBACK(JSBool)
|
||||
InstallTriggerGlobalGetVersion(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMInstallTriggerGlobal *nativeThis = (nsIDOMInstallTriggerGlobal*)JS_GetPrivate(cx, obj);
|
||||
|
||||
|
||||
nsAutoString regname;
|
||||
nsAutoString version;
|
||||
|
||||
@ -506,7 +506,7 @@ InstallTriggerGlobalGetVersion(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
if(version.IsEmpty())
|
||||
*rval = JSVAL_NULL;
|
||||
else
|
||||
@ -520,7 +520,7 @@ InstallTriggerGlobalGetVersion(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
||||
// class for InstallTriggerGlobal
|
||||
//
|
||||
JSClass InstallTriggerGlobalClass = {
|
||||
"InstallTrigger",
|
||||
"InstallTrigger",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
@ -535,7 +535,7 @@ JSClass InstallTriggerGlobalClass = {
|
||||
//
|
||||
// InstallTriggerGlobal class methods
|
||||
//
|
||||
static JSFunctionSpec InstallTriggerGlobalMethods[] =
|
||||
static JSFunctionSpec InstallTriggerGlobalMethods[] =
|
||||
{
|
||||
// -- obsolete forms, do not document. Kept for 4.x compatibility
|
||||
{"UpdateEnabled", InstallTriggerGlobalUpdateEnabled, 0},
|
||||
@ -554,13 +554,14 @@ static JSFunctionSpec InstallTriggerGlobalMethods[] =
|
||||
};
|
||||
|
||||
|
||||
static JSConstDoubleSpec diff_constants[] =
|
||||
static JSConstDoubleSpec diff_constants[] =
|
||||
{
|
||||
{ nsIDOMInstallTriggerGlobal::MAJOR_DIFF, "MAJOR_DIFF" },
|
||||
{ nsIDOMInstallTriggerGlobal::MINOR_DIFF, "MINOR_DIFF" },
|
||||
{ nsIDOMInstallTriggerGlobal::REL_DIFF, "REL_DIFF" },
|
||||
{ nsIDOMInstallTriggerGlobal::BLD_DIFF, "BLD_DIFF" },
|
||||
{ nsIDOMInstallTriggerGlobal::EQUAL, "EQUAL" },
|
||||
{ nsIDOMInstallTriggerGlobal::NOT_FOUND, "NOT_FOUND" },
|
||||
{ CHROME_SKIN, "SKIN" },
|
||||
{ CHROME_LOCALE, "LOCALE" },
|
||||
{ CHROME_CONTENT, "CONTENT" },
|
||||
@ -573,13 +574,13 @@ static JSConstDoubleSpec diff_constants[] =
|
||||
nsresult InitInstallTriggerGlobalClass(JSContext *jscontext, JSObject *global, void** prototype)
|
||||
{
|
||||
JSObject *proto = nsnull;
|
||||
|
||||
|
||||
if (prototype != nsnull)
|
||||
*prototype = nsnull;
|
||||
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
nsnull, // parent proto
|
||||
nsnull, // parent proto
|
||||
&InstallTriggerGlobalClass, // JSClass
|
||||
nsnull, // JSNative ctor
|
||||
nsnull, // ctor args
|
||||
@ -587,16 +588,16 @@ nsresult InitInstallTriggerGlobalClass(JSContext *jscontext, JSObject *global, v
|
||||
nsnull, // proto funcs
|
||||
nsnull, // ctor props (static)
|
||||
InstallTriggerGlobalMethods); // ctor funcs (static)
|
||||
|
||||
|
||||
|
||||
|
||||
if (nsnull == proto) return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
if ( PR_FALSE == JS_DefineConstDoubles(jscontext, proto, diff_constants) )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (prototype != nsnull)
|
||||
*prototype = proto;
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -616,24 +617,24 @@ nsresult NS_InitInstallTriggerGlobalClass(nsIScriptContext *aContext, void **aPr
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "InstallTriggerGlobal", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp) ||
|
||||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp))
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp))
|
||||
{
|
||||
nsresult rv = InitInstallTriggerGlobalClass(jscontext, global, (void**)&proto);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp))
|
||||
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp))
|
||||
{
|
||||
proto = JSVAL_TO_OBJECT(vp);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aPrototype)
|
||||
if (aPrototype)
|
||||
*aPrototype = proto;
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -690,7 +691,7 @@ NS_NewScriptInstallTriggerGlobal(nsIScriptContext *aContext,
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(installTriggerGlobal);
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
@ -88,7 +88,7 @@ static NS_DEFINE_CID(kInstallVersion_CID, NS_SoftwareUpdateInstallVersion_CID);
|
||||
static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID);
|
||||
static NS_DEFINE_CID(knsRegistryCID, NS_REGISTRY_CID);
|
||||
|
||||
static NS_DEFINE_CID(kIProcessCID, NS_PROCESS_CID);
|
||||
static NS_DEFINE_CID(kIProcessCID, NS_PROCESS_CID);
|
||||
|
||||
nsSoftwareUpdate* nsSoftwareUpdate::mInstance = nsnull;
|
||||
nsCOMPtr<nsIFile> nsSoftwareUpdate::mProgramDir = nsnull;
|
||||
@ -99,7 +99,7 @@ PRBool nsSoftwareUpdate::mNeedCleanup = PR_FALSE;
|
||||
nsSoftwareUpdate *
|
||||
nsSoftwareUpdate::GetInstance()
|
||||
{
|
||||
if (mInstance == nsnull)
|
||||
if (mInstance == nsnull)
|
||||
mInstance = new nsSoftwareUpdate();
|
||||
|
||||
NS_IF_ADDREF(mInstance);
|
||||
@ -114,7 +114,7 @@ nsSoftwareUpdate::nsSoftwareUpdate()
|
||||
mReg(0)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
||||
|
||||
mLock = PR_NewLock();
|
||||
|
||||
/***************************************/
|
||||
@ -122,14 +122,14 @@ nsSoftwareUpdate::nsSoftwareUpdate()
|
||||
/***************************************/
|
||||
|
||||
NR_StartupRegistry(); /* startup the registry; if already started, this will essentially be a noop */
|
||||
|
||||
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
|
||||
|
||||
if(!directoryService) return;
|
||||
|
||||
|
||||
nsCOMPtr<nsILocalFile> dir;
|
||||
directoryService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(dir));
|
||||
if (dir)
|
||||
@ -140,12 +140,12 @@ nsSoftwareUpdate::nsSoftwareUpdate()
|
||||
VR_SetRegDirectory( nativePath );
|
||||
if (nativePath)
|
||||
nsMemory::Free(nativePath);
|
||||
|
||||
|
||||
}
|
||||
/***************************************/
|
||||
/* Add this as a shutdown observer */
|
||||
/***************************************/
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
@ -197,10 +197,10 @@ nsSoftwareUpdate::Shutdown()
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsILocalFile> pathToCleanupUtility;
|
||||
//Get the program directory
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
directoryService->Get(NS_OS_CURRENT_PROCESS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
directoryService->Get(NS_OS_CURRENT_PROCESS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(pathToCleanupUtility));
|
||||
#if defined (XP_MAC)
|
||||
pathToCleanupUtility->Append(ESSENTIAL_FILES);
|
||||
@ -217,17 +217,17 @@ nsSoftwareUpdate::Shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSoftwareUpdate::Observe(nsISupports *aSubject,
|
||||
const char *aTopic,
|
||||
NS_IMETHODIMP nsSoftwareUpdate::Observe(nsISupports *aSubject,
|
||||
const char *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
|
||||
Shutdown();
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsSoftwareUpdate::RegisterListener(nsIXPIListener *aListener)
|
||||
{
|
||||
// once you register a Listener, you can not remove it.
|
||||
@ -238,7 +238,7 @@ nsSoftwareUpdate::RegisterListener(nsIXPIListener *aListener)
|
||||
|
||||
if (!mMasterListener)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
mMasterListener->RegisterListener(aListener);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -301,9 +301,9 @@ nsSoftwareUpdate::InstallJar( nsIFile* aLocalFile,
|
||||
// -- grab a proxied Chrome Registry now while we can
|
||||
nsresult rv;
|
||||
nsIChromeRegistry* chromeReg = nsnull;
|
||||
NS_WITH_ALWAYS_PROXIED_SERVICE( nsIChromeRegistry,
|
||||
NS_WITH_ALWAYS_PROXIED_SERVICE( nsIChromeRegistry,
|
||||
tmpReg,
|
||||
kChromeRegistryCID,
|
||||
kChromeRegistryCID,
|
||||
NS_UI_THREAD_EVENTQ, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
chromeReg = tmpReg;
|
||||
@ -311,7 +311,7 @@ nsSoftwareUpdate::InstallJar( nsIFile* aLocalFile,
|
||||
// we want to call this with or without a chrome registry
|
||||
nsInstallInfo *info = new nsInstallInfo( 0, aLocalFile, aURL, aArguments,
|
||||
flags, aListener, aParentWindow, chromeReg );
|
||||
|
||||
|
||||
if (!info)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
@ -335,7 +335,7 @@ nsSoftwareUpdate::InstallChrome( PRUint32 aType,
|
||||
nsresult rv;
|
||||
NS_WITH_ALWAYS_PROXIED_SERVICE( nsIChromeRegistry,
|
||||
chromeReg,
|
||||
kChromeRegistryCID,
|
||||
kChromeRegistryCID,
|
||||
NS_UI_THREAD_EVENTQ, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
@ -346,7 +346,7 @@ nsSoftwareUpdate::InstallChrome( PRUint32 aType,
|
||||
aName,
|
||||
(PRUint32)aSelect,
|
||||
aListener,
|
||||
nsnull,
|
||||
nsnull,
|
||||
chromeReg);
|
||||
if (!info)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -482,7 +482,7 @@ nsSoftwareUpdate::RunNextInstall()
|
||||
if (!mMasterListener)
|
||||
CreateMasterListener();
|
||||
|
||||
if (!mInstalling)
|
||||
if (!mInstalling)
|
||||
{
|
||||
if ( mJarInstallQueue.Count() > 0 )
|
||||
{
|
||||
@ -490,7 +490,7 @@ nsSoftwareUpdate::RunNextInstall()
|
||||
|
||||
if ( info )
|
||||
mInstalling = PR_TRUE;
|
||||
else
|
||||
else
|
||||
{
|
||||
// bogus elements got into the queue
|
||||
NS_ERROR("leaks remaining nsInstallInfos, please file bug!");
|
||||
@ -591,7 +591,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsSoftwareUpdateNameSet);
|
||||
#define NS_SOFTWAREUPDATENAMESET_CONTRACTID \
|
||||
"@mozilla.org/xpinstall/softwareupdatenameset;1"
|
||||
|
||||
static NS_METHOD
|
||||
static NS_METHOD
|
||||
RegisterSoftwareUpdate( nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
@ -622,37 +622,37 @@ RegisterSoftwareUpdate( nsIComponentManager *aCompMgr,
|
||||
|
||||
|
||||
// The list of components we register
|
||||
static const nsModuleComponentInfo components[] =
|
||||
static const nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "SoftwareUpdate Component",
|
||||
{ "SoftwareUpdate Component",
|
||||
NS_SoftwareUpdate_CID,
|
||||
NS_IXPINSTALLCOMPONENT_CONTRACTID,
|
||||
nsSoftwareUpdateConstructor,
|
||||
RegisterSoftwareUpdate
|
||||
},
|
||||
|
||||
{ "InstallTrigger Component",
|
||||
|
||||
{ "InstallTrigger Component",
|
||||
NS_SoftwareUpdateInstallTrigger_CID,
|
||||
NS_INSTALLTRIGGERCOMPONENT_CONTRACTID,
|
||||
NS_INSTALLTRIGGERCOMPONENT_CONTRACTID,
|
||||
nsInstallTriggerConstructor
|
||||
},
|
||||
|
||||
{ "InstallVersion Component",
|
||||
|
||||
{ "InstallVersion Component",
|
||||
NS_SoftwareUpdateInstallVersion_CID,
|
||||
NS_INSTALLVERSIONCOMPONENT_CONTRACTID,
|
||||
nsInstallVersionConstructor
|
||||
nsInstallVersionConstructor
|
||||
},
|
||||
|
||||
{ "XPInstall Content Handler",
|
||||
NS_SoftwareUpdateInstallTrigger_CID,
|
||||
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"application/x-xpinstall",
|
||||
nsInstallTriggerConstructor
|
||||
nsInstallTriggerConstructor
|
||||
},
|
||||
|
||||
{ "Software update nameset",
|
||||
NS_SOFTWAREUPDATENAMESET_CID,
|
||||
NS_SOFTWAREUPDATENAMESET_CONTRACTID,
|
||||
nsSoftwareUpdateNameSetConstructor
|
||||
nsSoftwareUpdateNameSetConstructor
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user