C++ side of fix for bug 100212 - move consumers of nsIFile.URL into nsIIOService. r=dougt, sr=darin

This commit is contained in:
alecf%netscape.com 2002-01-08 01:31:25 +00:00
parent 194f8df022
commit 5965318acb
21 changed files with 37 additions and 40 deletions

View File

@ -2529,7 +2529,7 @@ nsChromeRegistry::GetProfileRoot(nsCString& aFileURL)
return rv; return rv;
nsXPIDLCString urlSpec; nsXPIDLCString urlSpec;
rv = userChromeDir->GetURL(getter_Copies(urlSpec)); rv = NS_GetURLSpecFromFile(userChromeDir, getter_Copies(urlSpec));
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
aFileURL = urlSpec; aFileURL = urlSpec;
@ -2550,7 +2550,7 @@ nsChromeRegistry::GetInstallRoot(nsCString& aFileURL)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
nsXPIDLCString urlSpec; nsXPIDLCString urlSpec;
rv = appChromeDir->GetURL(getter_Copies(urlSpec)); rv = NS_GetURLSpecFromFile(appChromeDir, getter_Copies(urlSpec));
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
aFileURL = urlSpec; aFileURL = urlSpec;
@ -3084,7 +3084,7 @@ nsChromeRegistry::ProcessNewChromeBuffer(char *aBuffer, PRInt32 aLength)
* all we want here is the canonical url * all we want here is the canonical url
*/ */
nsXPIDLCString chromeURLfoopy; nsXPIDLCString chromeURLfoopy;
rv = chromeFile->GetURL(getter_Copies(chromeURLfoopy)); rv = NS_GetURLSpecFromFile(chromeFile, getter_Copies(chromeURLfoopy));
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
chromeURL = chromeURLfoopy; chromeURL = chromeURLfoopy;

View File

@ -326,7 +326,7 @@ nsresult nsDefaultURIFixup::ConvertFileToStringURI(nsString& aIn,
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
nsXPIDLCString fileurl; nsXPIDLCString fileurl;
filePath->GetURL(getter_Copies(fileurl)); NS_GetURLSpecFromFile(filePath, getter_Copies(fileurl));
aOut.Assign(fileurl); aOut.Assign(fileurl);
return NS_OK; return NS_OK;
} }

View File

@ -644,8 +644,8 @@ nsresult nsWebBrowserPersist::SaveDocumentInternal(
SetDocumentBase(aDocument, mCurrentBaseURI); SetDocumentBase(aDocument, mCurrentBaseURI);
// create a uri for aFile // create a uri for aFile
char *urlString = nsnull; nsXPIDLCString urlString;
nsresult rv = aFile->GetURL(&urlString); nsresult rv = NS_GetURLSpecFromFile(aFile, getter_Copies(urlString));
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), urlString); rv = NS_NewURI(getter_AddRefs(uri), urlString);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
@ -1293,7 +1293,7 @@ nsWebBrowserPersist::FixupNodeAttribute(nsIDOMNode *aNode,
else else
{ {
nsXPIDLCString fileurl; nsXPIDLCString fileurl;
file->GetURL(getter_Copies(fileurl)); NS_GetURLSpecFromFile(file, getter_Copies(fileurl));
newValue.AssignWithConversion(fileurl); newValue.AssignWithConversion(fileurl);
} }
if (data->mIsSubFrame) if (data->mIsSubFrame)

View File

@ -50,6 +50,7 @@
#include "nsIScriptSecurityManager.h" #include "nsIScriptSecurityManager.h"
#include "nsIScriptObjectPrincipal.h" #include "nsIScriptObjectPrincipal.h"
#include "nsIURL.h" #include "nsIURL.h"
#include "nsNetUtil.h"
#endif #endif
#ifndef NO_SUBSCRIPT_LOADER #ifndef NO_SUBSCRIPT_LOADER
#include "mozJSSubScriptLoader.h" #include "mozJSSubScriptLoader.h"
@ -1162,7 +1163,7 @@ mozJSComponentLoader::GlobalForLocation(const char *aLocation,
goto out; goto out;
} }
localFile->GetURL(getter_Copies(displayPath)); NS_GetURLSpecFromFile(localFile, getter_Copies(displayPath));
rv = localFile->OpenANSIFileDesc("r", &fileHandle); rv = localFile->OpenANSIFileDesc("r", &fileHandle);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
global = nsnull; global = nsnull;

View File

@ -2186,7 +2186,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge
if (isFile) { if (isFile) {
// convert file:///c:/ to c: if needed // convert file:///c:/ to c: if needed
nsCOMPtr<nsILocalFile> aFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID); nsCOMPtr<nsILocalFile> aFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
if (NS_SUCCEEDED(aFile->SetURL(dataToPost)) && if (NS_SUCCEEDED(NS_InitFileFromURLSpec(aFile,dataToPost)) &&
NS_SUCCEEDED(aFile->GetPath(getter_Copies(filename)))) NS_SUCCEEDED(aFile->GetPath(getter_Copies(filename))))
dataToPost = filename; dataToPost = filename;
} }

View File

@ -2186,7 +2186,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge
if (isFile) { if (isFile) {
// convert file:///c:/ to c: if needed // convert file:///c:/ to c: if needed
nsCOMPtr<nsILocalFile> aFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID); nsCOMPtr<nsILocalFile> aFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
if (NS_SUCCEEDED(aFile->SetURL(dataToPost)) && if (NS_SUCCEEDED(NS_InitFileFromURLSpec(aFile,dataToPost)) &&
NS_SUCCEEDED(aFile->GetPath(getter_Copies(filename)))) NS_SUCCEEDED(aFile->GetPath(getter_Copies(filename))))
dataToPost = filename; dataToPost = filename;
} }

View File

@ -49,6 +49,7 @@
#include "nsIFileChannel.h" #include "nsIFileChannel.h"
#include "nsIFileSpec.h" #include "nsIFileSpec.h"
#include "nsAppDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h"
#include "nsNetUtil.h"
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFCompositeDataSourceCID, NS_RDFCOMPOSITEDATASOURCE_CID); static NS_DEFINE_CID(kRDFCompositeDataSourceCID, NS_RDFCOMPOSITEDATASOURCE_CID);
@ -125,7 +126,7 @@ nsMsgServiceProviderService::Init()
continue; continue;
nsXPIDLCString urlSpec; nsXPIDLCString urlSpec;
rv = dirEntry->GetURL(getter_Copies(urlSpec)); rv = NS_GetURLSpecFromFile(dirEntry, getter_Copies(urlSpec));
rv = LoadDataSource(urlSpec); rv = LoadDataSource(urlSpec);
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed reading in the datasource\n"); NS_ASSERTION(NS_SUCCEEDED(rv), "Failed reading in the datasource\n");
} }

View File

@ -38,6 +38,7 @@
#include "nsMsgAttachment.h" #include "nsMsgAttachment.h"
#include "nsILocalFile.h" #include "nsILocalFile.h"
#include "nsReadableUtils.h" #include "nsReadableUtils.h"
#include "nsNetUtil.h"
NS_IMPL_ISUPPORTS1(nsMsgAttachment, nsIMsgAttachment) NS_IMPL_ISUPPORTS1(nsMsgAttachment, nsIMsgAttachment)
@ -180,7 +181,7 @@ nsresult nsMsgAttachment::DeleteAttachment()
nsCOMPtr<nsILocalFile> urlFile(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv)); nsCOMPtr<nsILocalFile> urlFile(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
rv = urlFile->SetURL(mUrl.get()); NS_InitFileFromURLSpec(urlFile, mUrl.get());
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
PRBool bExists = PR_FALSE; PRBool bExists = PR_FALSE;

View File

@ -2462,12 +2462,6 @@ nsPluginHostImpl::~nsPluginHostImpl()
#ifdef NS_DEBUG #ifdef NS_DEBUG
printf("nsPluginHostImpl dtor\n"); printf("nsPluginHostImpl dtor\n");
#endif #endif
nsCOMPtr<nsIObserverService> obsService = do_GetService("@mozilla.org/observer-service;1");
if (obsService)
{
obsService->RemoveObserver(this, "quit-application");
obsService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
}
Destroy(); Destroy();
} }
@ -5326,7 +5320,7 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL,
if (aIsFile) { if (aIsFile) {
// convert file:///c:/ to c: // convert file:///c:/ to c:
nsCOMPtr<nsILocalFile> aFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID); nsCOMPtr<nsILocalFile> aFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
if (NS_SUCCEEDED(aFile->SetURL(dataToPost))) if (NS_SUCCEEDED(NS_InitFileFromURLSpec(aFile,dataToPost)))
if (NS_SUCCEEDED(aFile->GetPath(getter_Copies(filename)))) { if (NS_SUCCEEDED(aFile->GetPath(getter_Copies(filename)))) {
// tell the listener about it so it will delete the file later // tell the listener about it so it will delete the file later
listenerPeer->SetLocalFile(filename); listenerPeer->SetLocalFile(filename);

View File

@ -1081,7 +1081,7 @@ NS_IMETHODIMP pluginInstanceOwner::GetURL(const char *aURL, const char *aTarget,
if (isFile) { if (isFile) {
// convert file:///c:/ to c: if needed // convert file:///c:/ to c: if needed
nsCOMPtr<nsILocalFile> aFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID); nsCOMPtr<nsILocalFile> aFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
if (NS_SUCCEEDED(aFile->SetURL(dataToPost)) && if (NS_SUCCEEDED(NS_InitFileFromURLSpec(aFile,dataToPost)) &&
NS_SUCCEEDED(aFile->GetPath(getter_Copies(filename)))) NS_SUCCEEDED(aFile->GetPath(getter_Copies(filename))))
dataToPost = filename; dataToPost = filename;
} }

View File

@ -62,6 +62,7 @@ static PRLogModuleInfo* gLog;
#include "nsCollationCID.h" #include "nsCollationCID.h"
#include "nsIPlatformCharset.h" #include "nsIPlatformCharset.h"
#include "nsReadableUtils.h" #include "nsReadableUtils.h"
#include "nsNetUtil.h"
static NS_DEFINE_CID(kCollationFactoryCID, NS_COLLATIONFACTORY_CID); static NS_DEFINE_CID(kCollationFactoryCID, NS_COLLATIONFACTORY_CID);
@ -214,7 +215,7 @@ nsDirectoryIndexStream::Init(nsIFile* aDir)
mBuf.Append("300: "); mBuf.Append("300: ");
nsXPIDLCString url; nsXPIDLCString url;
rv = mDir->GetURL(getter_Copies(url)); rv = NS_GetURLSpecFromFile(mDir, getter_Copies(url));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
mBuf.Append(url); mBuf.Append(url);
mBuf.Append('\n'); mBuf.Append('\n');

View File

@ -46,6 +46,7 @@
#include "nsIObjectInputStream.h" #include "nsIObjectInputStream.h"
#include "nsIObjectOutputStream.h" #include "nsIObjectOutputStream.h"
#include "nsNetCID.h" #include "nsNetCID.h"
#include "nsNetUtil.h"
#include "prlog.h" #include "prlog.h"
static NS_DEFINE_CID(kThisImplCID, NS_THIS_STANDARDURL_IMPL_CID); static NS_DEFINE_CID(kThisImplCID, NS_THIS_STANDARDURL_IMPL_CID);
@ -1614,7 +1615,7 @@ nsStandardURL::GetFile(nsIFile **result)
nsCOMPtr<nsILocalFile> localFile(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv)); nsCOMPtr<nsILocalFile> localFile(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = localFile->SetURL(mSpec.get()); rv = NS_InitFileFromURLSpec(localFile, mSpec.get());
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
#if defined(PR_LOGGING) #if defined(PR_LOGGING)
@ -1637,7 +1638,7 @@ nsStandardURL::SetFile(nsIFile *file)
nsresult rv; nsresult rv;
nsXPIDLCString url; nsXPIDLCString url;
rv = file->GetURL(getter_Copies(url)); NS_GetURLSpecFromFile(file, getter_Copies(url));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = SetSpec(url); rv = SetSpec(url);

View File

@ -96,7 +96,7 @@ nsResURL::GetFile(nsIFile **result)
do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv); do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = localFile->SetURL(spec); rv = NS_InitFileFromURLSpec(localFile, spec);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
return CallQueryInterface(localFile, result); return CallQueryInterface(localFile, result);

View File

@ -149,7 +149,7 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsXPIDLCString url; nsXPIDLCString url;
rv = file->GetURL(getter_Copies(url)); rv = NS_GetURLSpecFromFile(file, getter_Copies(url));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
baseUri.Assign(url); baseUri.Assign(url);
@ -157,7 +157,7 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
rv = file->GetParent(getter_AddRefs(parent)); rv = file->GetParent(getter_AddRefs(parent));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (parent) { if (parent) {
rv = parent->GetURL(getter_Copies(url)); NS_GetURLSpecFromFile(parent, getter_Copies(url));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
parentStr.Assign(url); parentStr.Assign(url);
} }

View File

@ -2529,7 +2529,7 @@ nsChromeRegistry::GetProfileRoot(nsCString& aFileURL)
return rv; return rv;
nsXPIDLCString urlSpec; nsXPIDLCString urlSpec;
rv = userChromeDir->GetURL(getter_Copies(urlSpec)); rv = NS_GetURLSpecFromFile(userChromeDir, getter_Copies(urlSpec));
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
aFileURL = urlSpec; aFileURL = urlSpec;
@ -2550,7 +2550,7 @@ nsChromeRegistry::GetInstallRoot(nsCString& aFileURL)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
nsXPIDLCString urlSpec; nsXPIDLCString urlSpec;
rv = appChromeDir->GetURL(getter_Copies(urlSpec)); rv = NS_GetURLSpecFromFile(appChromeDir, getter_Copies(urlSpec));
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
aFileURL = urlSpec; aFileURL = urlSpec;
@ -3084,7 +3084,7 @@ nsChromeRegistry::ProcessNewChromeBuffer(char *aBuffer, PRInt32 aLength)
* all we want here is the canonical url * all we want here is the canonical url
*/ */
nsXPIDLCString chromeURLfoopy; nsXPIDLCString chromeURLfoopy;
rv = chromeFile->GetURL(getter_Copies(chromeURLfoopy)); rv = NS_GetURLSpecFromFile(chromeFile, getter_Copies(chromeURLfoopy));
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
chromeURL = chromeURLfoopy; chromeURL = chromeURLfoopy;

View File

@ -256,7 +256,7 @@ FileSystemDataSource::isDirURI(nsIRDFResource* source)
nsCOMPtr<nsILocalFile> aDir = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID); nsCOMPtr<nsILocalFile> aDir = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
rv = aDir->SetURL(uri); rv = NS_InitFileFromURLSpec(aDir, uri);
if (NS_FAILED(rv)) return(PR_FALSE); if (NS_FAILED(rv)) return(PR_FALSE);
PRBool isDirFlag = PR_FALSE; PRBool isDirFlag = PR_FALSE;

View File

@ -53,15 +53,13 @@
#include "nsXPIDLString.h" #include "nsXPIDLString.h"
#include "nsReadableUtils.h" #include "nsReadableUtils.h"
#include "nsPrimitiveHelpers.h" #include "nsPrimitiveHelpers.h"
#include "nsIURL.h"
#include "nsImageClipboard.h" #include "nsImageClipboard.h"
#include "nsIFileChannel.h"
#include "nsIWidget.h" #include "nsIWidget.h"
#include "nsIComponentManager.h" #include "nsIComponentManager.h"
#include "nsWidgetsCID.h" #include "nsWidgetsCID.h"
#include "nsVoidArray.h" #include "nsVoidArray.h"
#include "nsFileSpec.h" #include "nsNetUtil.h"
#include "nsIImage.h" #include "nsIImage.h"
@ -673,7 +671,7 @@ nsClipboard :: FindURLFromLocalFile ( IDataObject* inDataObject, UINT inIndex, v
nsCOMPtr<nsILocalFile> file; nsCOMPtr<nsILocalFile> file;
if ( NS_SUCCEEDED(NS_NewLocalFile(filepath, PR_FALSE, getter_AddRefs(file))) ) { if ( NS_SUCCEEDED(NS_NewLocalFile(filepath, PR_FALSE, getter_AddRefs(file))) ) {
nsXPIDLCString urlSpec; nsXPIDLCString urlSpec;
file->GetURL( getter_Copies(urlSpec) ); NS_GetURLSpecFromFile(file, getter_Copies(urlSpec));
// convert it to unicode and pass it out // convert it to unicode and pass it out
nsMemory::Free(*outData); nsMemory::Free(*outData);

View File

@ -75,7 +75,7 @@ static void* ProcessURLArg(char* str)
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
nsXPIDLCString fileurl; nsXPIDLCString fileurl;
rv = file->GetURL(getter_Copies(fileurl)); rv = NS_GetURLSpecFromFile(file, getter_Copies(fileurl));
if (NS_SUCCEEDED(rv) && fileurl.get()) if (NS_SUCCEEDED(rv) && fileurl.get())
return NS_REINTERPRET_CAST(void*, nsCRT::strdup(fileurl.get())); return NS_REINTERPRET_CAST(void*, nsCRT::strdup(fileurl.get()));
} }

View File

@ -1231,7 +1231,7 @@ InternetSearchDataSource::GetCategoryList()
rv = NS_GetSpecialDirectory(NS_APP_SEARCH_50_FILE, getter_AddRefs(searchFile)); rv = NS_GetSpecialDirectory(NS_APP_SEARCH_50_FILE, getter_AddRefs(searchFile));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
searchFile->GetURL(getter_Copies(searchFileURLSpec)); NS_GetURLSpecFromFile(searchFile, getter_Copies(searchFileURLSpec));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = remoteCategoryDataSource->Init(searchFileURLSpec); rv = remoteCategoryDataSource->Init(searchFileURLSpec);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
@ -3774,7 +3774,7 @@ InternetSearchDataSource::SaveEngineInfoIntoGraph(nsIFile *file, nsIFile *icon,
if (icon) if (icon)
{ {
nsXPIDLCString iconFileURL; nsXPIDLCString iconFileURL;
if (NS_FAILED(rv = icon->GetURL(getter_Copies(iconFileURL)))) if (NS_FAILED(rv = NS_GetURLSpecFromFile(icon, getter_Copies(iconFileURL))))
return(rv); return(rv);
iconURL.AssignWithConversion(iconFileURL); iconURL.AssignWithConversion(iconFileURL);
} }

View File

@ -75,7 +75,7 @@ static void* ProcessURLArg(char* str)
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
nsXPIDLCString fileurl; nsXPIDLCString fileurl;
rv = file->GetURL(getter_Copies(fileurl)); rv = NS_GetURLSpecFromFile(file, getter_Copies(fileurl));
if (NS_SUCCEEDED(rv) && fileurl.get()) if (NS_SUCCEEDED(rv) && fileurl.get())
return NS_REINTERPRET_CAST(void*, nsCRT::strdup(fileurl.get())); return NS_REINTERPRET_CAST(void*, nsCRT::strdup(fileurl.get()));
} }

View File

@ -1207,7 +1207,7 @@ nsInstall::LoadResources(JSContext* cx, const nsString& aBaseName, jsval* aRetur
#if 1 #if 1
{ {
nsXPIDLCString spec; nsXPIDLCString spec;
resFile->GetURL(getter_Copies(spec)); ret = NS_GetURLSpecFromFile(resFile, getter_Copies(spec));
if (NS_FAILED(ret)) { if (NS_FAILED(ret)) {
NS_WARNING("cannot get url spec\n"); NS_WARNING("cannot get url spec\n");
nsServiceManager::ReleaseService(kStringBundleServiceCID, service); nsServiceManager::ReleaseService(kStringBundleServiceCID, service);