Rest of tree-wide cleanup for bug 100212 - switch last consumers of nsIFile.URL r=dougt, sr=darin

This commit is contained in:
alecf%netscape.com 2002-01-09 02:08:01 +00:00
Родитель ad5d66331d
Коммит 5ac5a63a0e
16 изменённых файлов: 117 добавлений и 43 удалений

Просмотреть файл

@ -440,8 +440,10 @@ function PromptForSaveLocation(aDoSaveAsText, aEditorType, aMIMEType, ahtmlDocum
// set the file picker's current directory
// assuming we have information needed (like prior saved location)
try {
var fileLocation = Components.classes["@mozilla.org/file/local;1"].createInstance().QueryInterface(Components.interfaces.nsIFile);
fileLocation.URL = aDocumentURLString;
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
var fileLocation = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile);
ioService.initFileFromURLSpec(fileLocation, aDocumentURLString);
var parentLocation = fileLocation.parent;
if (parentLocation)
{
@ -463,7 +465,7 @@ function PromptForSaveLocation(aDoSaveAsText, aEditorType, aMIMEType, ahtmlDocum
if (dialogResult.filepickerClick != nsIFilePicker.returnCancel)
{
// reset urlstring to new save location
dialogResult.resultingURIString = fp.file.URL;
dialogResult.resultingURIString = ioService.getURLSpecFromFile(fp.file);
dialogResult.resultingLocalFile = fp.file;
SaveFilePickerDirectory(fp, aEditorType);
}
@ -648,7 +650,9 @@ if (!success)
if (!tempLocalFile)
{
tempLocalFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
tempLocalFile.URL = urlstring;
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
ioService.initFileFromURLSpec(tempLocalFile, urlstring);
}
var parentDir;
@ -1149,7 +1153,8 @@ var nsValidateCommand =
// See if it's a file:
var ifile = Components.classes["@mozilla.org/file/local;1"].createInstance().QueryInterface(Components.interfaces.nsIFile);
try {
ifile.URL = URL2Validate;
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
ioService.initFileFromURLSpec(ifile, URL2Validate);
// nsIFile throws an exception if it's not a file url
} catch (e) { ifile = null; }
if (ifile)

Просмотреть файл

@ -317,8 +317,12 @@ function SetFilePickerDirectory(filePicker, fileType)
if (location)
{
try {
var lastLocation = Components.classes["@mozilla.org/file/local;1"].createInstance().QueryInterface(Components.interfaces.nsIFile);
lastLocation.URL = location;
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
var lastLocation = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile);
ioService.initFileFromURLSpec(lastLocation) = location;
// Save current directory so we can reset it in SaveFilePickerDirectory
gFilePickerDirectory = filePicker.displayDirectory;
@ -334,7 +338,8 @@ function SaveFilePickerDirectory(filePicker, fileType)
{
if (filePicker && filePicker.file && filePicker.file.parent)
{
SetUnicharPref("editor.lastFileLocation."+fileType, filePicker.file.parent.URL);
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
SetUnicharPref("editor.lastFileLocation."+fileType, ioService.getURLSpecFromFile(filePicker.file.parent));
}
// Restore the directory used before SetFilePickerDirectory was called;

Просмотреть файл

@ -707,8 +707,10 @@ function GetLocalFileURL(filterType)
}
SaveFilePickerDirectory(fp, fileType);
// Note: fp.file.URL = fp.fileURL.spec
return fp.file ? fp.file.URL : null;
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
// Note: ioService.getURLSpecFromFile(fp.file) = fp.fileURL.spec
return fp.file ? ioService.getURLSpecFromFile(fp.file) : null;
}
function GetMetaElement(name)

Просмотреть файл

@ -470,8 +470,12 @@ nsHelperAppDialog.prototype = {
.getService( Components.interfaces.nsIProperties );
var file = fileLocator.get( "UMimTyp", Components.interfaces.nsIFile );
// Get the data source; load it synchronously if it must be initialized.
var ds = rdf.GetDataSourceBlocking( file.URL );
// Get the data source; load it synchronously if it must be
// initialized.
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
var fileurl = ioService.getURLSpecFromFile(file);
var ds = rdf.GetDataSourceBlocking( fileurl );
// Now check if this mimetype is really in there;
// This is done by seeing if there's a "value" arc from the mimetype resource

Просмотреть файл

@ -302,7 +302,9 @@ function loadDialog()
sourceUrl = persistArgs.source;
}
catch (e) {
sourceUrl = { spec: persistArgs.source.URL };
// must be an nsIFile
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
sourceUrl = { spec: ioService.getURLSpecFromFile(persistArgs.source) };
}
// When saving web pages, we don't need to do anything special to receive the time

Просмотреть файл

@ -49,7 +49,7 @@ var inspector;
const kSearchRegURL = "resource:///res/inspector/search-registry.rdf";
const kWindowMediatorIID = "@mozilla.org/rdf/datasource;1?name=window-mediator";
const kWindowMediatorCID = "@mozilla.org/rdf/datasource;1?name=window-mediator";
const kClipboardHelperCID = "@mozilla.org/widget/clipboardhelper;1";
const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
@ -174,7 +174,9 @@ InspectorApp.prototype =
var path = null; // TODO: should persist last path chosen in a pref
var file = FilePickerUtils.pickFile("Find Search File", path, ["filterXML"], "Open");
if (file) {
var url = file.URL;
var ioService = XPCU.getService("@mozilla.org/network/io-service;1","nsIIOService");
var url = ioService.getURLSpecFromFile(file);
// XX temporary until 56354 is fixed
url = url.replace("file://", "file:///");
this.startSearchModule(url);
@ -310,7 +312,7 @@ InspectorApp.prototype =
setTargetWindowById: function(aResId)
{
var windowManager = XPCU.getService(kWindowMediatorIID, "nsIWindowMediator");
var windowManager = XPCU.getService(kWindowMediatorCID, "nsIWindowMediator");
var win = windowManager.getWindowForResource(aResId);
if (win) {

Просмотреть файл

@ -61,6 +61,7 @@ var DiskSearch =
for (var i = 0; i < aExtList.length; i++) {
extHash[aExtList[i]] = true;
}
this.ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
// recursively build the list of results
var results = [];
@ -80,7 +81,7 @@ var DiskSearch =
ext = this.getExtension(entry.leafName);
if (ext) {
if (aExtHash[ext])
aResults.push(entry.URL);
aResults.push(this.ioService.getURLSpecFromFile(entry));
}
}
},

Просмотреть файл

@ -143,7 +143,11 @@ SidebarPrefs.prototype =
var file = dirService.get(aFileId, Components.interfaces.nsIFile);
if (!file.exists())
return null;
return file.URL;
var ioService = XPCU.getService("@mozilla.org/network/io-service;1", "nsIIOService");
return ioService.getURLSpecFromFile(file);
} catch (ex) {
return null;
}

Просмотреть файл

@ -514,8 +514,12 @@ inSearchModule.prototype =
} catch (ex) {
basefile = inSearchUtils.createLocalFile(aURL);
}
var file = XPCU.QI(file, "nsIFile");
this.mDialogURL = basefile.URL;
var ioService = XPCU.getService("@mozilla.org/network/io-service;1", "nsIIOService");
this.mDialogURL = ioService.getURLSpecFromFile(basefile);
*/
}

Просмотреть файл

@ -192,7 +192,7 @@ nsresult nsExternalHelperAppService::InitDataSource()
// Get file url spec to be used to initialize the DS.
nsXPIDLCString urlSpec;
rv = mimeTypesFile->GetURL(getter_Copies(urlSpec));
rv = NS_GetURLSpecFromFile(mimeTypesFile, getter_Copies(urlSpec));
NS_ENSURE_SUCCESS(rv, rv);
// Get the data source; if it is going to be created, then load is synchronous.

Просмотреть файл

@ -225,8 +225,11 @@ function onOK()
const kLFIID = Components.interfaces.nsILocalFile;
const kLF = Components.classes[kLFContractID].createInstance(kLFIID);
kLF.initWithUnicodePath(url);
if (kLF.exists())
url = kLF.URL;
if (kLF.exists()) {
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.classes.nsIIOService);
url = ioService.getURLSpecFromFile(kLF);
}
}
catch (e) {
}

Просмотреть файл

@ -182,9 +182,8 @@
if (fileLocator)
fileLocator = fileLocator.QueryInterface(Components.interfaces.nsIProperties);
var file = fileLocator.get(mimeTypes, Components.interfaces.nsIFile);
gDS = gRDF.GetDataSource(file.URL);
if (gDS)
gDS = gDS.QueryInterface(Components.interfaces.nsIRDFDataSource);
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
gDS = gRDF.GetDataSource(ioService.getURLSpecFromFile(file));
}
function onAccept()

Просмотреть файл

@ -1,3 +1,23 @@
/* -*- Mode: Java; tab-width: 2; c-basic-offset: 2; -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*
* Contributor(s):
*/
var gDescriptionField = null;
var gExtensionField = null;
var gMIMEField = null;
@ -73,13 +93,13 @@ function onOK()
}
const mimeTypes = "UMimTyp";
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"].getService();
if (fileLocator)
fileLocator = fileLocator.QueryInterface(Components.interfaces.nsIProperties);
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);
var file = fileLocator.get(mimeTypes, Components.interfaces.nsIFile);
gDS = gRDF.GetDataSource(file.URL);
if (gDS)
gDS = gDS.QueryInterface(Components.interfaces.nsIRDFDataSource);
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
gDS = gRDF.GetDataSource(ioService.getURLSpecFromFile(file));
// figure out if this mime type already exists.
var exists = mimeHandlerExists(gMIMEField.value);

Просмотреть файл

@ -1,3 +1,22 @@
/* -*- Mode: Java; tab-width: 2; c-basic-offset: 2; -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*
* Contributor(s):
*/
var gNewTypeRV = null;
var gUpdateTypeRV = null;
@ -65,13 +84,13 @@ function Startup()
updateLockedButtonState(false);
const mimeTypes = "UMimTyp";
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"].getService();
if (fileLocator)
fileLocator = fileLocator.QueryInterface(Components.interfaces.nsIProperties);
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);
var file = fileLocator.get(mimeTypes, Components.interfaces.nsIFile);
gDS = gRDF.GetDataSource(file.URL);
if (gDS)
gDS = gDS.QueryInterface(Components.interfaces.nsIRDFDataSource);
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
dump("spec is " + ioService.getURLSpecFromFile(file));
gDS = gRDF.GetDataSource(ioService.getURLSpecFromFile(file));
// intialise the tree
gTree.database.AddDataSource(gDS);

Просмотреть файл

@ -707,7 +707,10 @@ function sidebar_revert_to_default_panels() {
function get_sidebar_datasource_uri() {
try {
var sidebar_file = sidebar_get_panels_file();
return sidebar_file.URL;
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
return ioService.getURLSpecFromFile(sidebar_file);
} catch (ex) {
// This should not happen
debug("Error: Unable to load panels file.\n");

Просмотреть файл

@ -42,6 +42,7 @@ const SIDEBAR_CID = Components.ID("{22117140-9c6e-11d3-aaf1-00805f8a4905}")
const CONTAINER_CONTRACTID = "@mozilla.org/rdf/container;1";
const DIR_SERV_CONTRACTID = "@mozilla.org/file/directory_service;1"
const NETSEARCH_CONTRACTID = "@mozilla.org/rdf/datasource;1?name=internetsearch"
const IO_SERV_CONTRACTID = "@mozilla.org/network/io-service;1";
const nsISupports = Components.interfaces.nsISupports;
const nsIFactory = Components.interfaces.nsIFactory;
const nsISidebar = Components.interfaces.nsISidebar;
@ -400,9 +401,7 @@ function getSidebarDatasourceURI(panels_file_id)
/* use the fileLocator to look in the profile directory
* to find 'panels.rdf', which is the
* database of the user's currently selected panels. */
var directory_service = Components.classes[DIR_SERV_CONTRACTID].getService();
if (directory_service)
directory_service = directory_service.QueryInterface(Components.interfaces.nsIProperties);
var directory_service = Components.classes[DIR_SERV_CONTRACTID].getService(Components.interfaces.nsIProperties);
/* if <profile>/panels.rdf doesn't exist, get will copy
*bin/defaults/profile/panels.rdf to <profile>/panels.rdf */
@ -416,8 +415,10 @@ function getSidebarDatasourceURI(panels_file_id)
return null;
}
debug("sidebar uri is " + sidebar_file.URL);
return sidebar_file.URL;
var io_service = Components.classes[IO_SERV_CONTRACTID].getService(Components.interfaces.nsIIOService);
var sidebar_uri = io_service.getURLSpecFromFile(sidebar_file);
debug("sidebar uri is " + sidebar_uri);
return sidebar_uri;
}
catch (ex)
{