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

View File

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

View File

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

View File

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

View File

@ -2186,7 +2186,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge
if (isFile) {
// convert file:///c:/ to c: if needed
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))))
dataToPost = filename;
}

View File

@ -2186,7 +2186,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge
if (isFile) {
// convert file:///c:/ to c: if needed
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))))
dataToPost = filename;
}

View File

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

View File

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

View File

@ -2462,12 +2462,6 @@ nsPluginHostImpl::~nsPluginHostImpl()
#ifdef NS_DEBUG
printf("nsPluginHostImpl dtor\n");
#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();
}
@ -5326,7 +5320,7 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL,
if (aIsFile) {
// convert file:///c:/ to c:
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)))) {
// tell the listener about it so it will delete the file later
listenerPeer->SetLocalFile(filename);

View File

@ -1081,7 +1081,7 @@ NS_IMETHODIMP pluginInstanceOwner::GetURL(const char *aURL, const char *aTarget,
if (isFile) {
// convert file:///c:/ to c: if needed
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))))
dataToPost = filename;
}

View File

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

View File

@ -46,6 +46,7 @@
#include "nsIObjectInputStream.h"
#include "nsIObjectOutputStream.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "prlog.h"
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));
if (NS_FAILED(rv)) return rv;
rv = localFile->SetURL(mSpec.get());
rv = NS_InitFileFromURLSpec(localFile, mSpec.get());
if (NS_FAILED(rv)) return rv;
#if defined(PR_LOGGING)
@ -1637,7 +1638,7 @@ nsStandardURL::SetFile(nsIFile *file)
nsresult rv;
nsXPIDLCString url;
rv = file->GetURL(getter_Copies(url));
NS_GetURLSpecFromFile(file, getter_Copies(url));
if (NS_FAILED(rv)) return rv;
rv = SetSpec(url);

View File

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

View File

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

View File

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

View File

@ -256,7 +256,7 @@ FileSystemDataSource::isDirURI(nsIRDFResource* source)
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);
PRBool isDirFlag = PR_FALSE;

View File

@ -53,15 +53,13 @@
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsPrimitiveHelpers.h"
#include "nsIURL.h"
#include "nsImageClipboard.h"
#include "nsIFileChannel.h"
#include "nsIWidget.h"
#include "nsIComponentManager.h"
#include "nsWidgetsCID.h"
#include "nsVoidArray.h"
#include "nsFileSpec.h"
#include "nsNetUtil.h"
#include "nsIImage.h"
@ -672,8 +670,8 @@ nsClipboard :: FindURLFromLocalFile ( IDataObject* inDataObject, UINT inIndex, v
// we have a normal file, use some Necko objects to get our file path
nsCOMPtr<nsILocalFile> file;
if ( NS_SUCCEEDED(NS_NewLocalFile(filepath, PR_FALSE, getter_AddRefs(file))) ) {
nsXPIDLCString urlSpec;
file->GetURL( getter_Copies(urlSpec) );
nsXPIDLCString urlSpec;
NS_GetURLSpecFromFile(file, getter_Copies(urlSpec));
// convert it to unicode and pass it out
nsMemory::Free(*outData);

View File

@ -75,7 +75,7 @@ static void* ProcessURLArg(char* str)
if (NS_SUCCEEDED(rv))
{
nsXPIDLCString fileurl;
rv = file->GetURL(getter_Copies(fileurl));
rv = NS_GetURLSpecFromFile(file, getter_Copies(fileurl));
if (NS_SUCCEEDED(rv) && 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));
if (NS_FAILED(rv)) return rv;
searchFile->GetURL(getter_Copies(searchFileURLSpec));
NS_GetURLSpecFromFile(searchFile, getter_Copies(searchFileURLSpec));
if (NS_FAILED(rv)) return rv;
rv = remoteCategoryDataSource->Init(searchFileURLSpec);
if (NS_FAILED(rv)) return rv;
@ -3774,7 +3774,7 @@ InternetSearchDataSource::SaveEngineInfoIntoGraph(nsIFile *file, nsIFile *icon,
if (icon)
{
nsXPIDLCString iconFileURL;
if (NS_FAILED(rv = icon->GetURL(getter_Copies(iconFileURL))))
if (NS_FAILED(rv = NS_GetURLSpecFromFile(icon, getter_Copies(iconFileURL))))
return(rv);
iconURL.AssignWithConversion(iconFileURL);
}

View File

@ -75,7 +75,7 @@ static void* ProcessURLArg(char* str)
if (NS_SUCCEEDED(rv))
{
nsXPIDLCString fileurl;
rv = file->GetURL(getter_Copies(fileurl));
rv = NS_GetURLSpecFromFile(file, getter_Copies(fileurl));
if (NS_SUCCEEDED(rv) && 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
{
nsXPIDLCString spec;
resFile->GetURL(getter_Copies(spec));
ret = NS_GetURLSpecFromFile(resFile, getter_Copies(spec));
if (NS_FAILED(ret)) {
NS_WARNING("cannot get url spec\n");
nsServiceManager::ReleaseService(kStringBundleServiceCID, service);