239394 nsIMIMEInfo should use interCaps for methods and attributes

r=bzbarsky sr=darin
This commit is contained in:
cbiesinger%web.de 2004-05-08 18:37:06 +00:00
Родитель ae90b49dc6
Коммит 33c5b41794
10 изменённых файлов: 24 добавлений и 224 удалений

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

@ -635,7 +635,7 @@ function appendFiltersForContentType(aFilePicker, aContentType, aFileExtension,
}
if (extString) {
aFilePicker.appendFilter(mimeInfo.Description, extString);
aFilePicker.appendFilter(mimeInfo.description, extString);
} else {
aFilePicker.appendFilters(Components.interfaces.nsIFilePicker.filterAll);
}
@ -839,7 +839,7 @@ function getDefaultExtension(aFilename, aURI, aContentType)
var mimeInfo = getMIMEInfoForType(aContentType, ext);
if (ext && mimeInfo && mimeInfo.ExtensionExists(ext)) {
if (ext && mimeInfo && mimeInfo.extensionExists(ext)) {
return ext;
}
@ -851,7 +851,7 @@ function getDefaultExtension(aFilename, aURI, aContentType)
} catch (e) {
}
if (urlext && mimeInfo && mimeInfo.ExtensionExists(urlext)) {
if (urlext && mimeInfo && mimeInfo.extensionExists(urlext)) {
return urlext;
}
else {

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

@ -228,7 +228,7 @@ PluginTypes.prototype = {
case "fileExtension":
return aObject.MIMEInfo.primaryExtension.toLowerCase();
case "fileType":
var desc = aObject.MIMEInfo.Description;
var desc = aObject.MIMEInfo.description;
// XXXben localize
return desc || aObject.MIMEInfo.primaryExtension.toUpperCase() + " file";
case "pluginEnabled":
@ -276,7 +276,7 @@ PluginTypes.prototype = {
var mimeInfo = this._pluginTypes[aRow].MIMEInfo;
if (aCol.id == "fileType") {
var desc = mimeInfo.Description;
var desc = mimeInfo.description;
// XXXben localize
return desc || mimeInfo.primaryExtension.toUpperCase() + " file";
}

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

@ -295,7 +295,7 @@ nsHelperAppDialog.prototype = {
// initIntro:
initIntro: function(url, filename) {
var intro = this.dialogElement( "intro" );
var desc = this.mLauncher.MIMEInfo.Description;
var desc = this.mLauncher.MIMEInfo.description;
var modified;
if ( this.mForced && desc )
{

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

@ -67,7 +67,7 @@ interface nsIMIMEInfo : nsISupports {
/**
* Set File Extensions. Input is a comma delimited list of extensions.
*/
void SetFileExtensions(in ACString aExtensions);
void setFileExtensions(in ACString aExtensions);
/**
* Returns whether or not the given extension is
@ -75,12 +75,12 @@ interface nsIMIMEInfo : nsISupports {
*
* @return TRUE if the association exists.
*/
boolean ExtensionExists(in ACString aExtension);
boolean extensionExists(in ACString aExtension);
/**
* Append a given extension to the set of extensions
*/
void AppendExtension(in ACString aExtension);
void appendExtension(in ACString aExtension);
/**
* Returns the first extension association in
@ -102,13 +102,13 @@ interface nsIMIMEInfo : nsISupports {
*
* @return The description
*/
attribute AString Description;
attribute AString description;
/**
* Mac Type and creator types
*/
attribute PRUint32 MacType;
attribute PRUint32 MacCreator;
attribute PRUint32 macType;
attribute PRUint32 macCreator;
/**
* Returns whether or not these two MIME infos are logically
@ -117,7 +117,7 @@ interface nsIMIMEInfo : nsISupports {
*
* @returns TRUE if the two are considered equal
*/
boolean Equals(in nsIMIMEInfo aMIMEInfo);
boolean equals(in nsIMIMEInfo aMIMEInfo);
/**
* Returns a nsIFile that points to the application the user has said

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

@ -132,7 +132,7 @@ HelperApps.prototype = {
while (extEnumerator.hasMore()) {
entry.addExtension(extEnumerator.getNext());
}
entry.description = aMIMEInfo.Description;
entry.description = aMIMEInfo.description;
entry.appDisplayName = "";
}
@ -224,7 +224,7 @@ HelperApps.prototype = {
}
}
else if (aProperty.EqualsNode(this._fileTypeArc)) {
if (typeInfo.Description == "") {
if (typeInfo.description == "") {
try {
var literal = bundle.getFormattedString("fileEnding", [typeInfo.primaryExtension.toUpperCase()]);
return gRDF.GetLiteral(literal);
@ -235,7 +235,7 @@ HelperApps.prototype = {
return gRDF.GetLiteral(typeInfo.MIMEType);
}
}
return gRDF.GetLiteral(typeInfo.Description);
return gRDF.GetLiteral(typeInfo.description);
}
else if (aProperty.EqualsNode(this._fileHandlerArc)) {
var handler = this.GetTarget(aSource, this._handlerPropArc, true);

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

@ -182,7 +182,7 @@ nsUnknownContentTypeDialog.prototype = {
var wildCardExtension = "*";
if (aSuggestedFileExtension) {
wildCardExtension += aSuggestedFileExtension;
picker.appendFilter(this.mLauncher.MIMEInfo.Description, wildCardExtension);
picker.appendFilter(this.mLauncher.MIMEInfo.description, wildCardExtension);
}
picker.appendFilters( nsIFilePicker.filterAll );
@ -374,7 +374,7 @@ nsUnknownContentTypeDialog.prototype = {
var mimeInfo = this.mLauncher.MIMEInfo;
// 1. Try to use the pretty description of the type, if one is available.
var typeString = mimeInfo.Description;
var typeString = mimeInfo.description;
if (typeString == "") {
// 2. If there is none, use the extension to identify the file, e.g. "ZIP file"

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

@ -216,7 +216,7 @@ nsUnknownContentTypeDialog.prototype = {
var wildCardExtension = "*";
if (aSuggestedFileExtension) {
wildCardExtension += aSuggestedFileExtension;
picker.appendFilter(this.mLauncher.MIMEInfo.Description, wildCardExtension);
picker.appendFilter(this.mLauncher.MIMEInfo.description, wildCardExtension);
}
picker.appendFilters( nsIFilePicker.filterAll );
@ -446,7 +446,7 @@ nsUnknownContentTypeDialog.prototype = {
var mimeInfo = this.mLauncher.MIMEInfo;
// 1. Try to use the pretty description of the type, if one is available.
var typeString = mimeInfo.Description;
var typeString = mimeInfo.description;
if (typeString == "") {
// 2. If there is none, use the extension to identify the file, e.g. "ZIP file"

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

@ -641,7 +641,7 @@ function appendFiltersForContentType(aFilePicker, aContentType, aFileExtension,
}
if (extString) {
aFilePicker.appendFilter(mimeInfo.Description, extString);
aFilePicker.appendFilter(mimeInfo.description, extString);
}
}
@ -845,7 +845,7 @@ function getDefaultExtension(aFilename, aURI, aContentType)
var mimeInfo = getMIMEInfoForType(aContentType, ext);
if (ext && mimeInfo && mimeInfo.ExtensionExists(ext)) {
if (ext && mimeInfo && mimeInfo.extensionExists(ext)) {
return ext;
}
@ -857,7 +857,7 @@ function getDefaultExtension(aFilename, aURI, aContentType)
} catch (e) {
}
if (urlext && mimeInfo && mimeInfo.ExtensionExists(urlext)) {
if (urlext && mimeInfo && mimeInfo.extensionExists(urlext)) {
return urlext;
}
else {

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

@ -269,7 +269,7 @@
while (extEnumerator.hasMore()) {
entry.addExtension(extEnumerator.getNext());
}
entry.description = info.Description;
entry.description = info.description;
entry.appDisplayName = "";
}

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

@ -1,200 +0,0 @@
/* -*- Mode: Java; tab-width: 2; c-basic-offset: 2; -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org Code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
var gDescriptionField = null;
var gExtensionField = null;
var gMIMEField = null;
var gAppPath = null;
var gPrefApplicationsBundle = null;
function Startup()
{
doSetOKCancel(onOK);
gDescriptionField = document.getElementById("description");
gExtensionField = document.getElementById("extensions");
gMIMEField = document.getElementById("mimeType");
gAppPath = document.getElementById("appPath");
gPrefApplicationsBundle = document.getElementById("bundle_prefApplications");
// If an arg was passed, then it's an nsIHelperAppLauncherDialog
if ( "arguments" in window && window.arguments[0] ) {
// Get mime info.
var info = window.arguments[0].mLauncher.MIMEInfo;
// Fill the fields we can from this.
gDescriptionField.value = info.Description;
gExtensionField.value = info.primaryExtension;
gMIMEField.value = info.MIMEType;
// an app may have been selected in the opening dialog but not in the mimeinfo
var app = info.preferredApplicationHandler || window.arguments[0].chosenApp;
if ( app ) {
gAppPath.value = app.path;
}
// Don't let user change mime type.
gMIMEField.setAttribute( "readonly", "true" );
// Start user in app field.
gAppPath.focus();
} else {
gDescriptionField.focus();
}
sizeToContent();
moveToAlertPosition();
}
function chooseApp()
{
const nsIFilePicker = Components.interfaces.nsIFilePicker;
var filePicker = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
if (filePicker) {
const FP = Components.interfaces.nsIFilePicker
var windowTitle = gPrefApplicationsBundle.getString("chooseHandler");
var programsFilter = gPrefApplicationsBundle.getString("programsFilter");
filePicker.init(window, windowTitle, FP.modeOpen);
if (navigator.platform == "Win32")
filePicker.appendFilter(programsFilter, "*.exe; *.com");
else
filePicker.appendFilters(FP.filterAll);
var filePicked = filePicker.show();
if (filePicked == nsIFilePicker.returnOK && filePicker.file) {
var file = filePicker.file.QueryInterface(Components.interfaces.nsILocalFile);
gAppPath.value = file.path;
gAppPath.select();
}
}
}
var gDS = null;
function onOK()
{
// Make sure all fields are filled in OK.
if ( !checkInput() ) {
return false;
}
const mimeTypes = "UMimTyp";
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);
var file = fileLocator.get(mimeTypes, Components.interfaces.nsIFile);
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
var fileHandler = ioService.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler);
gDS = gRDF.GetDataSource(fileHandler.getURLSpecFromFile(file));
gMIMEField.value = gMIMEField.value.toLowerCase();
// figure out if this mime type already exists.
var exists = mimeHandlerExists(gMIMEField.value);
if (exists) {
var titleMsg = gPrefApplicationsBundle.getString("handlerExistsTitle");
var dialogMsg = gPrefApplicationsBundle.getString("handlerExists");
dialogMsg = dialogMsg.replace(/%mime%/g, gMIMEField.value);
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
var replace = promptService.confirm(window, titleMsg, dialogMsg);
if (!replace)
{
window.close();
return false;
}
}
// now save the information
var handlerInfo = new HandlerOverride(MIME_URI(gMIMEField.value));
handlerInfo.mUpdateMode = exists; // XXX Somewhat sleazy, I know...
handlerInfo.mimeType = gMIMEField.value;
handlerInfo.description = gDescriptionField.value;
var extensionString = gExtensionField.value.replace(/[*.;]/g, "").toLowerCase();
var extensions = extensionString.split(" ");
for (var i = 0; i < extensions.length; i++) {
var currExtension = extensions[i];
handlerInfo.addExtension(currExtension);
}
handlerInfo.appPath = gAppPath.value;
// other info we need to set (not reflected in UI)
handlerInfo.isEditable = true;
handlerInfo.saveToDisk = false;
handlerInfo.handleInternal = false;
handlerInfo.alwaysAsk = true;
file = Components.classes["@mozilla.org/file/local;1"].createInstance();
if (file)
file = file.QueryInterface(Components.interfaces.nsILocalFile);
if (file) {
try {
file.initWithPath(gAppPath.value);
handlerInfo.appDisplayName = file.leafName;
}
catch(e) {
handlerInfo.appDisplayName = gAppPath.value;
}
}
// do the rest of the work (ugly yes, but it works)
handlerInfo.buildLinks();
// flush the ds to disk.
var remoteDS = gDS.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
if (remoteDS)
remoteDS.Flush();
// If an arg was passed, then it's an nsIHelperAppLauncherDialog
// and we need to update its MIMEInfo.
if ( "arguments" in window && window.arguments[0] ) {
// Get mime info.
var info = window.arguments[0].mLauncher.MIMEInfo;
// Update fields that might have changed.
info.preferredAction = Components.interfaces.nsIMIMEInfo.useHelperApp;
info.Description = gDescriptionField.value;
info.preferredApplicationHandler = file;
info.applicationDescription = handlerInfo.appDisplayName;
// Tell the nsIHelperAppLauncherDialog to update to the changes
window.arguments[0].updateSelf = true;
}
window.close();
return false;
}