214260 - Getting even closer...

This commit is contained in:
ben%bengoodger.com 2003-12-11 00:41:00 +00:00
parent 2e858e759a
commit cde28321b3
4 changed files with 45 additions and 31 deletions

View File

@ -102,7 +102,7 @@ static PRInt32 gRefCnt = 0;
NS_IMPL_ISUPPORTS3(nsDownloadManager, nsIDownloadManager, nsIXPInstallManagerUI, nsIObserver)
nsDownloadManager::nsDownloadManager() : mBatches(0), mXPIProgress(nsnull)
nsDownloadManager::nsDownloadManager() : mBatches(0)
{
}
@ -132,10 +132,9 @@ nsDownloadManager::~nsDownloadManager()
NS_IF_RELEASE(gNC_DateStarted);
NS_IF_RELEASE(gNC_DateEnded);
if (mXPIProgress) {
delete mXPIProgress;
mXPIProgress = nsnull;
}
// Download Manager is shutting down! Tell the XPInstallManager to stop
// transferring any files that may have been being downloaded.
gObserverService->NotifyObservers(mXPIProgress, "xpinstall-progress", NS_LITERAL_STRING("cancel").get());
NS_RELEASE(gRDFService);
NS_RELEASE(gObserverService);
@ -559,13 +558,14 @@ nsDownloadManager::AddDownload(DownloadType aDownloadType,
// Assert icon information
if (aIconURL) {
nsCOMPtr<nsIRDFLiteral> iconURLLiteral;
gRDFService->GetLiteral(aIconURL, getter_AddRefs(iconURLLiteral));
nsCOMPtr<nsIRDFResource> iconURIRes;
nsDependentString iconURL(aIconURL);
gRDFService->GetUnicodeResource(iconURL, getter_AddRefs(iconURIRes));
mDataSource->GetTarget(downloadRes, gNC_IconURL, PR_TRUE, getter_AddRefs(node));
if (node)
rv = mDataSource->Change(downloadRes, gNC_IconURL, node, iconURLLiteral);
rv = mDataSource->Change(downloadRes, gNC_IconURL, node, iconURIRes);
else
rv = mDataSource->Assert(downloadRes, gNC_IconURL, iconURLLiteral, PR_TRUE);
rv = mDataSource->Assert(downloadRes, gNC_IconURL, iconURIRes, PR_TRUE);
}
internalDownload->SetMIMEInfo(aMIMEInfo);
@ -616,7 +616,9 @@ nsDownloadManager::AddDownload(DownloadType aDownloadType,
if (!mXPIProgress)
mXPIProgress = new nsXPIProgressListener(this);
mXPIProgress->AddDownload(*aDownload);
nsIXPIProgressDialog* dialog = mXPIProgress.get();
nsXPIProgressListener* listener = NS_STATIC_CAST(nsXPIProgressListener*, dialog);
listener->AddDownload(*aDownload);
}
mCurrDownloads.Put(&key, *aDownload);
@ -865,6 +867,11 @@ nsDownloadManager::GetCanCleanUp(PRBool* aResult)
nsresult
nsDownloadManager::ValidateDownloadsContainer()
{
// None of the function calls here should need error checking or their results
// null checked because they should always succeed. If they fail, and there's
// a crash, it's a sign that this function is being called after the download
// manager or services that it rely on have been shut down, and there's a
// problem in some other code, somewhere.
nsCOMPtr<nsIRDFContainer> downloads;
GetDownloadsContainer(getter_AddRefs(downloads));
@ -1312,7 +1319,9 @@ nsDownloadManager::GetXpiProgress(nsIXPIProgressDialog** aProgress)
NS_IMETHODIMP
nsDownloadManager::GetHasActiveXPIOperations(PRBool* aHasOps)
{
*aHasOps = !mXPIProgress ? PR_FALSE : mXPIProgress->HasActiveXPIOperations();
nsIXPIProgressDialog* dialog = mXPIProgress.get();
nsXPIProgressListener* listener = NS_STATIC_CAST(nsXPIProgressListener*, dialog);
*aHasOps = !mXPIProgress ? PR_FALSE : listener->HasActiveXPIOperations();
return NS_OK;
}
@ -1528,25 +1537,27 @@ nsDownloadsDataSource::GetTarget(nsIRDFResource* aSource, nsIRDFResource* aPrope
if (!hasIconURLArc) {
nsCOMPtr<nsIRDFNode> target;
rv = mInner->GetTarget(aSource, gNC_File, aTruthValue, getter_AddRefs(target));
if (NS_FAILED(rv)) return rv;
nsXPIDLCString path;
nsCOMPtr<nsIRDFResource> res(do_QueryInterface(target));
res->GetValue(getter_Copies(path));
nsAutoString iconURL(NS_LITERAL_STRING("moz-icon://"));
nsAutoString pathTemp; pathTemp.AssignWithConversion(path);
iconURL += pathTemp + NS_LITERAL_STRING("?size=32");
if (NS_SUCCEEDED(rv) && target) {
nsXPIDLCString path;
nsCOMPtr<nsIRDFResource> res(do_QueryInterface(target));
res->GetValue(getter_Copies(path));
nsAutoString iconURL(NS_LITERAL_STRING("moz-icon://"));
nsAutoString pathTemp; pathTemp.AssignWithConversion(path);
iconURL += pathTemp + NS_LITERAL_STRING("?size=32");
nsCOMPtr<nsIRDFResource> result;
gRDFService->GetUnicodeResource(iconURL, getter_AddRefs(result));
nsCOMPtr<nsIRDFResource> result;
gRDFService->GetUnicodeResource(iconURL, getter_AddRefs(result));
*aResult = result;
NS_IF_ADDREF(*aResult);
*aResult = result;
NS_IF_ADDREF(*aResult);
return NS_OK;
return NS_OK;
}
}
}
// Either it's some other property, or we DO have an IconURL property
// and we just need to get the value from the real datasource.
return mInner->GetTarget(aSource, aProperty, aTruthValue, aResult);
}

View File

@ -148,6 +148,7 @@ protected:
private:
nsCOMPtr<nsIDownloadProgressListener> mListener;
nsCOMPtr<nsIRDFDataSource> mDataSource;
nsCOMPtr<nsIXPIProgressDialog> mXPIProgress;
nsCOMPtr<nsIRDFContainer> mDownloadsContainer;
nsCOMPtr<nsIRDFContainerUtils> mRDFContainerUtils;
nsCOMPtr<nsIStringBundle> mBundle;
@ -155,8 +156,6 @@ private:
PRInt32 mBatches;
nsHashtable mCurrDownloads;
nsXPIProgressListener* mXPIProgress;
friend class nsDownload;
};

View File

@ -207,7 +207,7 @@ var gDownloadObserver = {
XPInstallDownloadManager.addDownloads(params, installObserver);
break;
case "xpinstall-dialog-close":
if (gDownloadManager) {
if ("gDownloadManager" in window) {
var mgr = gDownloadManager.QueryInterface(Components.interfaces.nsIXPInstallManagerUI);
gCanAutoClose = mgr.hasActiveXPIOperations;
autoClose();
@ -520,8 +520,11 @@ var XPInstallDownloadManager = {
// MIME Info
var mimeInfo = mimeService.getFromTypeAndExtension(null, url.fileExtension);
var download = gDownloadManager.addDownload(uri, localTarget, displayName, mimeInfo, 0, null,
Components.interfaces.nsIXPInstallManagerUI.DOWNLOAD_TYPE_INSTALL);
if (!iconURL)
iconURL = "chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png";
var download = gDownloadManager.addDownload(Components.interfaces.nsIXPInstallManagerUI.DOWNLOAD_TYPE_INSTALL,
uri, localTarget, displayName, iconURL, mimeInfo, 0, null);
// Advance the enumerator
var certName = aParams.GetString(i++);

View File

@ -64,7 +64,8 @@ download[selected="true"] {
border-bottom: 1px dotted #7F9DB9;
}
download[state="0"], download[state="-1"], download[state="4"] {
download[state="0"], download[state="-1"], download[state="4"],
download[state="5"], download[state="6"] {
background-color: transparent;
background-image: url("chrome://mozapps/skin/downloads/downloadFader.png");
}