зеркало из https://github.com/mozilla/pjs.git
Cleaned up nsXPIFlash function names.
Added notification flash preference Added nsIProgressEventSink to nsXPInstallManager
This commit is contained in:
Родитель
ed7bf067d3
Коммит
0767c5d05c
|
@ -28,6 +28,8 @@
|
|||
#include "nsRDFCID.h"
|
||||
|
||||
#include "VerReg.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsISoftwareUpdate.h"
|
||||
|
||||
#define NC_XPIFLASH_SOURCES "NC:SoftwareUpdateDataSources"
|
||||
#define NC_XPIFLASH_PACKAGES "NC:SoftwarePackages"
|
||||
|
@ -63,13 +65,15 @@ private:
|
|||
nsXPINotifierImpl();
|
||||
virtual ~nsXPINotifierImpl();
|
||||
|
||||
nsresult NotificationEnabled(PRBool* aReturn);
|
||||
nsresult Init();
|
||||
nsresult SynchronouslyOpenRemoteDataSource(const char* aURL, nsIRDFDataSource** aResult);
|
||||
nsresult AddNewSoftwareFromDistributor(nsIRDFResource *inDistributor);
|
||||
nsresult AddDistributor(nsIRDFResource *inDistributor);
|
||||
PRBool IsNewerOrUninstalled(const char* regKey, const char* versionString);
|
||||
PRInt32 CompareVersions(VERSION *oldversion, VERSION *newVersion);
|
||||
void StringToVersionNumbers(const nsString& version, int32 *aMajor, int32 *aMinor, int32 *aRelease, int32 *aBuild);
|
||||
|
||||
|
||||
nsCOMPtr<nsISupports> mInner;
|
||||
nsIRDFService* mRDF;
|
||||
|
||||
|
@ -149,9 +153,48 @@ nsXPINotifierImpl::~nsXPINotifierImpl()
|
|||
}
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kPrefsIID, NS_IPREF_IID);
|
||||
static NS_DEFINE_IID(kPrefsCID, NS_PREF_CID);
|
||||
|
||||
nsresult
|
||||
nsXPINotifierImpl::NotificationEnabled(PRBool* aReturn)
|
||||
{
|
||||
nsIPref * prefs;
|
||||
|
||||
nsresult rv = nsServiceManager::GetService(kPrefsCID,
|
||||
kPrefsIID,
|
||||
(nsISupports**) &prefs);
|
||||
|
||||
|
||||
if ( NS_SUCCEEDED(rv) )
|
||||
{
|
||||
rv = prefs->GetBoolPref( (const char*) XPINSTALL_ENABLE_NOTIFICATIONS, aReturn);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
*aReturn = PR_FALSE;
|
||||
}
|
||||
|
||||
NS_RELEASE(prefs);
|
||||
}
|
||||
else
|
||||
{
|
||||
*aReturn = PR_FALSE; /* no prefs manager. set to false */
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXPINotifierImpl::Init()
|
||||
{
|
||||
PRBool enabled;
|
||||
|
||||
NotificationEnabled(&enabled);
|
||||
|
||||
if (!enabled)
|
||||
return NS_OK;
|
||||
|
||||
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||
|
||||
nsresult rv;
|
||||
|
@ -222,7 +265,7 @@ nsXPINotifierImpl::Init()
|
|||
nsCOMPtr<nsIRDFResource> aDistributor(do_QueryInterface(i, &rv));
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
rv = AddNewSoftwareFromDistributor(aDistributor);
|
||||
rv = AddDistributor(aDistributor);
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
distributorEnumerator->HasMoreElements(&moreElements);
|
||||
|
@ -234,7 +277,7 @@ nsXPINotifierImpl::Init()
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXPINotifierImpl::AddNewSoftwareFromDistributor(nsIRDFResource *inDistributor)
|
||||
nsXPINotifierImpl::AddDistributor(nsIRDFResource *inDistributor)
|
||||
{
|
||||
char* uri;
|
||||
inDistributor->GetValue(&uri);
|
||||
|
@ -329,6 +372,7 @@ nsXPINotifierImpl::AddNewSoftwareFromDistributor(nsIRDFResource *inDistributor)
|
|||
if (NS_FAILED(rv)) break;
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> ds = do_QueryInterface(mInner);
|
||||
|
||||
ds->Assert(aPackage, kNC_Type, kXPI_Notifier_Type, PR_TRUE);
|
||||
ds->Assert(aPackage, kNC_Source, title, PR_TRUE);
|
||||
ds->Assert(aPackage, kNC_URL, url, PR_TRUE);
|
||||
|
|
|
@ -36,6 +36,11 @@
|
|||
#define NS_IXPINSTALLCOMPONENT_PROGID NS_IAPPSHELLCOMPONENT_PROGID "/xpinstall"
|
||||
#define NS_IXPINSTALLCOMPONENT_CLASSNAME "Mozilla XPInstall Component"
|
||||
|
||||
#define XPINSTALL_ENABLE_PREF "xpinstall.enabled"
|
||||
#define XPINSTALL_ENABLE_NOTIFICATIONS "xpinstall.notifications_enabled" //TODO: this needs to be fixed at some point.
|
||||
#define XPINSTALL_MANUAL_CONFIRM "xpinstall.manual_confirm"
|
||||
|
||||
|
||||
#define XPI_NO_NEW_THREAD 0x1000
|
||||
|
||||
#define NS_ISOFTWAREUPDATE_IID \
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
pref("xpinstall.enabled", true);
|
||||
pref("xpinstall.show_details", false);
|
||||
pref("xpinstall.manual_confirm", true);
|
||||
pref("xpinstall.notifications_enabled", true);
|
||||
|
|
|
@ -87,8 +87,4 @@ class nsSoftwareUpdateNameSet : public nsIScriptExternalNameSet
|
|||
NS_IMETHOD InitializeClasses(nsIScriptContext* aScriptContext);
|
||||
NS_IMETHOD AddNameSet(nsIScriptContext* aScriptContext);
|
||||
};
|
||||
|
||||
#define XPINSTALL_ENABLE_PREF "xpinstall.enabled"
|
||||
#define XPINSTALL_DETAILS_PREF "xpinstall.show_details"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,13 +30,9 @@
|
|||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsIURL.h"
|
||||
#ifdef NECKO
|
||||
|
||||
#include "nsNeckoUtil.h"
|
||||
#include "nsIBufferInputStream.h"
|
||||
#else
|
||||
#include "nsINetlibURL.h"
|
||||
#include "nsINetService.h"
|
||||
#endif
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIStreamListener.h"
|
||||
|
||||
|
@ -53,7 +49,6 @@
|
|||
#include "nsIAppShellComponentImpl.h"
|
||||
#include "nsIPrompt.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID );
|
||||
static NS_DEFINE_IID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
|
||||
|
@ -92,6 +87,8 @@ nsXPInstallManager::QueryInterface(REFNSIID aIID,void** aInstancePtr)
|
|||
*aInstancePtr = NS_STATIC_CAST(nsIStreamListener*,this);
|
||||
else if (aIID.Equals(nsIXULWindowCallbacks::GetIID()))
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIXULWindowCallbacks*,this);
|
||||
else if (aIID.Equals(nsIProgressEventSink::GetIID()))
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIProgressEventSink*,this);
|
||||
else if (aIID.Equals(kISupportsIID))
|
||||
*aInstancePtr = NS_STATIC_CAST( nsISupports*, NS_STATIC_CAST(nsIXPINotifier*,this));
|
||||
else
|
||||
|
@ -224,19 +221,13 @@ nsresult nsXPInstallManager::DownloadNext()
|
|||
{
|
||||
// --- start the download
|
||||
nsIURI *pURL;
|
||||
#ifdef NECKO
|
||||
rv = NS_NewURI(&pURL, mItem->mURL);
|
||||
#else
|
||||
rv = NS_NewURL(&pURL, mItem->mURL);
|
||||
#endif
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
#ifdef NECKO
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
// XXX: Should there be a LoadGroup?
|
||||
rv = NS_OpenURI( this, nsnull, pURL, nsnull );
|
||||
NS_RELEASE(pURL);
|
||||
#else
|
||||
rv = NS_OpenURL( pURL, this );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,60 +291,21 @@ void nsXPInstallManager::Shutdown()
|
|||
mDlg->Close();
|
||||
|
||||
mDlg = 0;
|
||||
|
||||
NS_RELEASE_THIS();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// IStreamListener methods
|
||||
#ifndef NECKO
|
||||
NS_IMETHODIMP
|
||||
nsXPInstallManager::GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* info)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPInstallManager::OnProgress( nsIURI* aURL,
|
||||
PRUint32 Progress,
|
||||
PRUint32 ProgressMax)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPInstallManager::OnStatus(nsIURI* aURL,
|
||||
const PRUnichar* aMsg)
|
||||
{
|
||||
if (mDlg)
|
||||
return mDlg->SetActionText( aMsg );
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
#ifdef NECKO
|
||||
nsXPInstallManager::OnStartRequest(nsIChannel* channel, nsISupports *ctxt)
|
||||
#else
|
||||
nsXPInstallManager::OnStartRequest(nsIURI* aURL,
|
||||
const char *aContentType)
|
||||
#endif
|
||||
{
|
||||
mItem->mFile->OpenStreamForWriting();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
#ifdef NECKO
|
||||
nsXPInstallManager::OnStopRequest(nsIChannel* channel, nsISupports *ctxt,
|
||||
nsresult status, const PRUnichar *errorMsg)
|
||||
#else
|
||||
nsXPInstallManager::OnStopRequest(nsIURI* aURL,
|
||||
nsresult status,
|
||||
const PRUnichar* aMsg)
|
||||
#endif
|
||||
{
|
||||
nsresult rv;
|
||||
switch( status )
|
||||
|
@ -380,16 +332,10 @@ nsXPInstallManager::OnStopRequest(nsIURI* aURL,
|
|||
return rv;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
#ifdef NECKO
|
||||
nsXPInstallManager::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt,
|
||||
nsIInputStream *pIStream,
|
||||
PRUint32 sourceOffset,
|
||||
PRUint32 length)
|
||||
#else
|
||||
nsXPInstallManager::OnDataAvailable(nsIURI* aURL,
|
||||
nsIInputStream *pIStream,
|
||||
PRUint32 length)
|
||||
#endif
|
||||
{
|
||||
PRUint32 amt;
|
||||
PRInt32 result;
|
||||
|
@ -417,7 +363,17 @@ nsXPInstallManager::OnDataAvailable(nsIURI* aURL,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPInstallManager::OnProgress(nsIChannel *channel, nsISupports *ctxt, PRUint32 aProgress, PRUint32 aProgressMax)
|
||||
{
|
||||
return mProxy->SetProgress(aProgress, aProgressMax);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPInstallManager::OnStatus(nsIChannel *channel, nsISupports *ctxt, const PRUnichar *aMsg)
|
||||
{
|
||||
return mProxy->SetActionText(aMsg);
|
||||
}
|
||||
|
||||
|
||||
// IXPINotifier methods
|
||||
|
|
|
@ -32,10 +32,6 @@
|
|||
#include "nsString.h"
|
||||
|
||||
#include "nsIURL.h"
|
||||
#ifndef NECKO
|
||||
#include "nsINetlibURL.h"
|
||||
#include "nsINetService.h"
|
||||
#endif
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIXPINotifier.h"
|
||||
|
@ -49,11 +45,12 @@
|
|||
#include "nsIWebShell.h"
|
||||
#include "nsIWebShellWindow.h"
|
||||
#include "nsIXULWindowCallbacks.h"
|
||||
|
||||
#include "nsIProgressEventSink.h"
|
||||
|
||||
|
||||
class nsXPInstallManager : public nsIXPINotifier,
|
||||
public nsIStreamListener,
|
||||
public nsIProgressEventSink,
|
||||
public nsIXULWindowCallbacks
|
||||
{
|
||||
public:
|
||||
|
@ -64,25 +61,18 @@ class nsXPInstallManager : public nsIXPINotifier,
|
|||
|
||||
NS_IMETHOD InitManager( nsXPITriggerInfo* aTrigger );
|
||||
|
||||
#ifdef NECKO
|
||||
// nsIStreamObserver
|
||||
NS_DECL_NSISTREAMOBSERVER
|
||||
|
||||
// nsIStreamListener
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
#else
|
||||
// IStreamListener methods
|
||||
NS_IMETHOD GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* info);
|
||||
NS_IMETHOD OnProgress(nsIURI* aURL, PRUint32 Progress, PRUint32 ProgressMax);
|
||||
NS_IMETHOD OnStatus(nsIURI* aURL, const PRUnichar* aMsg);
|
||||
NS_IMETHOD OnStartRequest(nsIURI* aURL, const char *aContentType);
|
||||
NS_IMETHOD OnDataAvailable(nsIURI* aURL, nsIInputStream *pIStream, PRUint32 length);
|
||||
NS_IMETHOD OnStopRequest(nsIURI* aURL, nsresult status, const PRUnichar* aMsg);
|
||||
#endif
|
||||
|
||||
// IXPINotifier methods
|
||||
NS_DECL_NSIXPINOTIFIER
|
||||
|
||||
// nsIProgressEventSink
|
||||
NS_DECL_NSIPROGRESSEVENTSINK
|
||||
|
||||
// IXULWindowCallbacks methods
|
||||
NS_IMETHOD ConstructBeforeJavaScript(nsIWebShell *aWebShell);
|
||||
NS_IMETHOD ConstructAfterJavaScript(nsIWebShell *aWebShell);
|
||||
|
|
Загрузка…
Ссылка в новой задаче