зеркало из https://github.com/mozilla/pjs.git
Fix bug 86640 -- change helper app dialog to properly remember the selected
course of action, move the "neverAsk" information from prefs back to mimeTypes.rdf, remove the "Reset" button from helper app prefs, set up a way to select "use default OS helper" for a given type. Patch by Bill Law <law@netscape.com> and Philip K. Warren <pkw@us.ibm.com>, r=biesi, sr=bzbarsky, what passes for moa in helper apps=bzbarsky.
This commit is contained in:
Родитель
1f0e013d6c
Коммит
bb6ace680c
|
@ -138,7 +138,31 @@ HandlerOverride.prototype = {
|
|||
else
|
||||
changeMIMEStuff(HANDLER_URI(this.mimeType), "saveToDisk", aSavedToDisk);
|
||||
this.setHandlerProcedure("handleInternal", "false");
|
||||
this.setHandlerProcedure("useSystemDefault", "false");
|
||||
},
|
||||
|
||||
get useSystemDefault()
|
||||
{
|
||||
return getHandlerInfoForType(this.URI, "useSystemDefault");
|
||||
},
|
||||
|
||||
set useSystemDefault(aUseSystemDefault)
|
||||
{
|
||||
var handlerSource = gRDF.GetResource(HANDLER_URI(this.mimeType));
|
||||
var handlerProperty = gRDF.GetResource(NC_RDF("useSystemDefault"));
|
||||
var trueLiteral = gRDF.GetLiteral("true");
|
||||
var hasUseSystemDefault = gDS.HasAssertion(handlerSource, handlerProperty, trueLiteral, true);
|
||||
if (!hasUseSystemDefault) {
|
||||
var falseLiteral = gRDF.GetLiteral("false");
|
||||
hasUseSystemDefault = gDS.HasAssertion(handlerSource, handlerProperty, falseLiteral, true);
|
||||
}
|
||||
if (!this.mUpdateMode || !hasUseSystemDefault)
|
||||
assertMIMEStuff(HANDLER_URI(this.mimeType), "useSystemDefault", aUseSystemDefault);
|
||||
else
|
||||
changeMIMEStuff(HANDLER_URI(this.mimeType), "useSystemDefault", aUseSystemDefault);
|
||||
this.setHandlerProcedure("handleInternal", "false");
|
||||
this.setHandlerProcedure("saveToDisk", "false");
|
||||
},
|
||||
|
||||
get handleInternal()
|
||||
{
|
||||
|
@ -160,6 +184,7 @@ HandlerOverride.prototype = {
|
|||
else
|
||||
changeMIMEStuff(HANDLER_URI(this.mimeType), "handleInternal", aHandledInternally);
|
||||
this.setHandlerProcedure("saveToDisk", "false");
|
||||
this.setHandlerProcedure("useSystemDefault", "false");
|
||||
},
|
||||
|
||||
setHandlerProcedure: function (aHandlerProcedure, aValue)
|
||||
|
@ -317,7 +342,7 @@ function mimeHandlerExists(aMIMEType)
|
|||
{
|
||||
var valueProperty = gRDF.GetResource(NC_RDF("value"));
|
||||
var mimeSource = gRDF.GetResource(MIME_URI(aMIMEType));
|
||||
var mimeLiteral = gRDF.GetLiteral(gMIMEField.value);
|
||||
var mimeLiteral = gRDF.GetLiteral(aMIMEType);
|
||||
return gDS.HasAssertion(mimeSource, valueProperty, mimeLiteral, true);
|
||||
}
|
||||
|
||||
|
@ -349,7 +374,6 @@ function unassertMIMEStuff(aMIMEString, aPropertyString, aValueString)
|
|||
|
||||
function removeOverride(aMIMEType)
|
||||
{
|
||||
dump("*** mimeType = " + aMIMEType + "\n");
|
||||
// remove entry from seq
|
||||
var rdfc = Components.classes["@mozilla.org/rdf/container;1"].createInstance();
|
||||
if (rdfc) {
|
||||
|
@ -372,7 +396,7 @@ function removeOverride(aMIMEType)
|
|||
// remove items from the graph
|
||||
var urns = [ [MIME_URI, ["description", "editable", "value", "fileExtensions", "smallIcon", "largeIcon"],
|
||||
[HANDLER_URI, "handlerProp"]],
|
||||
[HANDLER_URI, ["handleInternal", "saveToDisk", "alwaysAsk"],
|
||||
[HANDLER_URI, ["handleInternal", "saveToDisk", "alwaysAsk", "useSystemDefault"],
|
||||
[APP_URI, "externalApplication"]],
|
||||
[APP_URI, ["path", "prettyName"]] ];
|
||||
for (var i = 0; i < urns.length; i++) {
|
||||
|
@ -396,7 +420,7 @@ function removeOverride(aMIMEType)
|
|||
gDS.Unassert(mimeRes, propertyRes, mimeValue, true);
|
||||
}
|
||||
}
|
||||
if (urns[i][2]) {
|
||||
if ("2" in urns[i] && urns[i][2]) {
|
||||
var linkRes = gRDF.GetResource(NC_RDF(urns[i][2][1]), true);
|
||||
var linkTarget = gRDF.GetResource(urns[i][2][0](aMIMEType), true);
|
||||
gDS.Unassert(mimeRes, linkRes, linkTarget);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
style="width: 30em;"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&editType.label;"
|
||||
newtitle="&newType.label;"
|
||||
onload="Startup();"
|
||||
ondialogaccept="return onAccept();">
|
||||
|
||||
|
@ -41,28 +42,38 @@
|
|||
<script type="application/x-javascript" src="chrome://communicator/content/pref/overrideHandler.js"/>
|
||||
<script type="application/x-javascript">
|
||||
<![CDATA[
|
||||
var gExtensionLabel = null;
|
||||
var gExtension = null;
|
||||
var gMIMEField = null;
|
||||
var gHandlerGroup = null;
|
||||
var gAppPath = null;
|
||||
var gAskBeforeOpen = null;
|
||||
var gContentType = null;
|
||||
var gDescription = null;
|
||||
var gPrefApplicationsBundle = null;
|
||||
|
||||
var gOldMIME = null;
|
||||
var gOldDesc = null;
|
||||
var gOldExtensions = null;
|
||||
|
||||
const nsIMIMEInfo = Components.interfaces.nsIMIMEInfo;
|
||||
|
||||
function Startup()
|
||||
{
|
||||
gContentType = document.getElementById("contentType");
|
||||
gExtensionLabel = document.getElementById("extension");
|
||||
gDescription = document.getElementById("description");
|
||||
gExtension = document.getElementById("extension");
|
||||
gMIMEField = document.getElementById("mimeType");
|
||||
gHandlerGroup = document.getElementById("handler");
|
||||
gAppPath = document.getElementById("appPath");
|
||||
gAskBeforeOpen = document.getElementById("askBeforeOpen");
|
||||
|
||||
gPrefApplicationsBundle = document.getElementById("bundle_prefApplications");
|
||||
|
||||
// Set values for radio items to nsIMIMEInfo constants
|
||||
var rSaveToDisk = document.getElementById("saveToDisk");
|
||||
var rUseHelperApp = document.getElementById("useHelperApp");
|
||||
var rUseSystemDefault = document.getElementById("useSystemDefault");
|
||||
rSaveToDisk.value = nsIMIMEInfo.saveToDisk;
|
||||
rUseHelperApp.value = nsIMIMEInfo.useHelperApp;
|
||||
rUseSystemDefault.value = nsIMIMEInfo.useSystemDefault;
|
||||
|
||||
var handlerInfo = window.arguments[0];
|
||||
|
||||
|
@ -71,32 +82,70 @@
|
|||
// Arg is an nsHelperAppDlg object in this case.
|
||||
window.gHelperAppDlg = window.arguments[0];
|
||||
var info = window.arguments[0].mLauncher.MIMEInfo;
|
||||
|
||||
// Get mime type from which we can construct a HandlerInfo...
|
||||
var mimeType = info.MIMEType.toLowerCase();
|
||||
|
||||
// Construct what we need from mime type URI.
|
||||
getDS();
|
||||
handlerInfo = window.arguments[0] = new HandlerOverride( MIME_URI( mimeType ) );
|
||||
|
||||
// Don't let the user change the mime type; we ignore any such changes anyway.
|
||||
gMIMEField.setAttribute( "readonly", "true" );
|
||||
|
||||
// Update entry (without dialog showing).
|
||||
try {
|
||||
updateEntry(info);
|
||||
} catch(e) { dump("updateEntry failed: " + e + "\n"); }
|
||||
|
||||
// Close the dialog.
|
||||
window.close();
|
||||
|
||||
// Done.
|
||||
return;
|
||||
}
|
||||
|
||||
// Default to true in case the preference cannot be retrieved
|
||||
var forceAlwaysAsk = true;
|
||||
try {
|
||||
var prefService = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPrefService);
|
||||
var prefBranch = prefService.getBranch("browser.helperApps.alwaysAsk.");
|
||||
forceAlwaysAsk = prefBranch.getBoolPref("force");
|
||||
} catch(e) {
|
||||
dump("forceAlwaysAsk defaulting to true since preference couldn't be opened\n");
|
||||
}
|
||||
|
||||
if ( !handlerInfo.URI )
|
||||
{
|
||||
// Opening for "New Type".
|
||||
var newTitle = document.documentElement.getAttribute("newtitle");
|
||||
document.documentElement.setAttribute("title", newTitle);
|
||||
|
||||
// Initialize some stuff to blank for new types.
|
||||
gOldMIME = gOldDesc = gOldExtensions = "";
|
||||
|
||||
// Make default "use system default."
|
||||
gHandlerGroup.selectedItem = gHandlerGroup.getElementsByAttribute("value",nsIMIMEInfo.useSystemDefault)[0];
|
||||
|
||||
// Always ask box default depends on pref.
|
||||
gAskBeforeOpen.checked = forceAlwaysAsk;
|
||||
gAskBeforeOpen.disabled = forceAlwaysAsk;
|
||||
|
||||
// Put focus on mime type field.
|
||||
gMIMEField.focus();
|
||||
|
||||
// Size/position the dialog.
|
||||
sizeToContent();
|
||||
window.moveToAlertPosition();
|
||||
|
||||
// Avoid the normal "edit" case code.
|
||||
return;
|
||||
}
|
||||
|
||||
gExtensionLabel.setAttribute("value", handlerInfo.extensions);
|
||||
gExtension.setAttribute("value", handlerInfo.extensions);
|
||||
gMIMEField.value = handlerInfo.mimeType;
|
||||
gOldMIME = handlerInfo.mimeType;
|
||||
gOldDesc = handlerInfo.description;
|
||||
gOldExtensions = handlerInfo.extensions;
|
||||
|
||||
// figure out how this type is handled
|
||||
var data = 0;
|
||||
if (handlerInfo.handleInternal == "true")
|
||||
data = 0;
|
||||
else if (handlerInfo.saveToDisk == "true")
|
||||
data = 1;
|
||||
var data = nsIMIMEInfo.saveToDisk;
|
||||
if (handlerInfo.saveToDisk == "true")
|
||||
data = nsIMIMEInfo.saveToDisk;
|
||||
else if (handlerInfo.useSystemDefault == "true")
|
||||
data = nsIMIMEInfo.useSystemDefault;
|
||||
else
|
||||
data = 2;
|
||||
data = nsIMIMEInfo.useHelperApp;
|
||||
|
||||
gHandlerGroup.selectedItem = gHandlerGroup.getElementsByAttribute("value", data)[0];
|
||||
doEnabling();
|
||||
|
@ -105,11 +154,6 @@
|
|||
if (appPath != undefined)
|
||||
gAppPath.value = appPath;
|
||||
|
||||
var prefs = Components.classes["@mozilla.org/preferences;1"].
|
||||
getService(Components.interfaces.nsIPrefBranch);
|
||||
var forceAlwaysAsk = prefs.
|
||||
getBoolPref("browser.helperApps.alwaysAsk.force");
|
||||
|
||||
if (forceAlwaysAsk)
|
||||
{
|
||||
gAskBeforeOpen.checked = true;
|
||||
|
@ -120,7 +164,7 @@
|
|||
gAskBeforeOpen.checked = handlerInfo.alwaysAsk == "true" ? true : false;
|
||||
}
|
||||
|
||||
gContentType.setAttribute("value", handlerInfo.description);
|
||||
gDescription.setAttribute("value", handlerInfo.description);
|
||||
var ext;
|
||||
var posOfFirstSpace = handlerInfo.extensions.indexOf(" ");
|
||||
if (posOfFirstSpace > -1)
|
||||
|
@ -169,8 +213,8 @@
|
|||
|
||||
function selectAppRadio()
|
||||
{
|
||||
if (gHandlerGroup.value != "2")
|
||||
gHandlerGroup.selectedItem = gHandlerGroup.getElementsByAttribute("value", "2")[0];
|
||||
if (gHandlerGroup.value != nsIMIMEInfo.useHelperApp)
|
||||
gHandlerGroup.selectedItem = gHandlerGroup.getElementsByAttribute("value", nsIMIMEInfo.useHelperApp)[0];
|
||||
doEnabling();
|
||||
}
|
||||
|
||||
|
@ -187,6 +231,64 @@
|
|||
gDS = gRDF.GetDataSource(fileHandler.getURLSpecFromFile(file));
|
||||
}
|
||||
|
||||
function updateEntry(info)
|
||||
{
|
||||
// Initialize data source.
|
||||
getDS();
|
||||
|
||||
// Get mime type from which we can construct a HandlerInfo...
|
||||
var mimeType = info.MIMEType.toLowerCase();
|
||||
|
||||
// Create HandlerOverride and populate it.
|
||||
var entry = new HandlerOverride(MIME_URI(mimeType));
|
||||
entry.mUpdateMode = mimeHandlerExists(mimeType);
|
||||
entry.mimeType = mimeType;
|
||||
entry.isEditable = true;
|
||||
entry.alwaysAsk = info.alwaysAskBeforeHandling;
|
||||
|
||||
// If not updating (i.e., a newly encountered mime type),
|
||||
// then update extension list and description.
|
||||
if (!entry.mUpdateMode) {
|
||||
var extCount = { value: 0 };
|
||||
var extArray = { value: null };
|
||||
info.GetFileExtensions(extCount, extArray);
|
||||
for (var i = 0; i < extArray.value.length; i++) {
|
||||
entry.addExtension(extArray.value[i]);
|
||||
}
|
||||
entry.description = info.Description;
|
||||
entry.appDisplayName = "";
|
||||
}
|
||||
|
||||
if (info.preferredAction == nsIMIMEInfo.saveToDisk) {
|
||||
entry.saveToDisk = true;
|
||||
if (!entry.mUpdateMode) {
|
||||
// Creating a new entry, set path.
|
||||
entry.appPath = "";
|
||||
}
|
||||
} else if (info.preferredAction == nsIMIMEInfo.useSystemDefault ||
|
||||
info.preferredApplicationHandler == null) {
|
||||
entry.useSystemDefault = true;
|
||||
if (!entry.mUpdateMode) {
|
||||
// Creating a new entry, set path.
|
||||
entry.appPath = "";
|
||||
}
|
||||
} else {
|
||||
entry.saveToDisk = false;
|
||||
entry.useSystemDefault = false;
|
||||
entry.handleInternal = false;
|
||||
entry.appPath = info.preferredApplicationHandler.path;
|
||||
entry.appDisplayName = info.applicationDescription;
|
||||
}
|
||||
|
||||
// Do RDF magic.
|
||||
entry.buildLinks();
|
||||
|
||||
// flush the ds to disk.
|
||||
var remoteDS = gDS.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
|
||||
if (remoteDS)
|
||||
remoteDS.Flush();
|
||||
}
|
||||
|
||||
function onAccept()
|
||||
{
|
||||
// Validate input.
|
||||
|
@ -213,31 +315,34 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (gOldMIME)
|
||||
if (gOldMIME && gOldMIME != gMIMEField.value)
|
||||
removeOverride(gOldMIME); // delete old handler
|
||||
|
||||
// now save the information
|
||||
var handlerInfo = new HandlerOverride(MIME_URI(gMIMEField.value));
|
||||
handlerInfo.mUpdateMode = mimeHandlerExists(gMIMEField.value);
|
||||
handlerInfo.mUpdateMode = (gOldMIME == gMIMEField.value);
|
||||
handlerInfo.mimeType = gMIMEField.value;
|
||||
|
||||
// set description, editable, and extensions
|
||||
handlerInfo.description = gOldDesc
|
||||
handlerInfo.isEditable = true;
|
||||
var extensions = gOldExtensions.toLowerCase().split(" ");
|
||||
handlerInfo.description = gDescription.value;
|
||||
var extensions = gExtension.value.toLowerCase().split(" ");
|
||||
for (var i = 0; i < extensions.length; i++) {
|
||||
var currExtension = extensions[i];
|
||||
handlerInfo.addExtension(currExtension);
|
||||
}
|
||||
|
||||
// other info we need to set (not reflected in UI)
|
||||
if (gHandlerGroup.value == "2") {
|
||||
if (gHandlerGroup.value == nsIMIMEInfo.useHelperApp) {
|
||||
handlerInfo.appPath = gAppPath.value;
|
||||
handlerInfo.setHandlerProcedure("saveToDisk", "false");
|
||||
handlerInfo.setHandlerProcedure("useSystemDefault", "false");
|
||||
handlerInfo.setHandlerProcedure("handleInternal", "false");
|
||||
}
|
||||
else if (gHandlerGroup.value == "1")
|
||||
else if (gHandlerGroup.value == nsIMIMEInfo.saveToDisk)
|
||||
handlerInfo.saveToDisk = true;
|
||||
else if (gHandlerGroup.value == nsIMIMEInfo.useSystemDefault)
|
||||
handlerInfo.useSystemDefault = true;
|
||||
else
|
||||
handlerInfo.handleInternal = true;
|
||||
|
||||
|
@ -253,7 +358,7 @@
|
|||
if (file) {
|
||||
try {
|
||||
file.initWithPath(gAppPath.value);
|
||||
handlerInfo.appDisplayName = file.unicodeLeafName;
|
||||
handlerInfo.appDisplayName = file.leafName;
|
||||
}
|
||||
catch(e) {
|
||||
handlerInfo.appDisplayName = gAppPath.value;
|
||||
|
@ -268,83 +373,60 @@
|
|||
if (remoteDS)
|
||||
remoteDS.Flush();
|
||||
|
||||
// See if invoked on behalf of helper app dialog...
|
||||
if ( "gHelperAppDlg" in window ) {
|
||||
// Get mime info.
|
||||
var info = gHelperAppDlg.mLauncher.MIMEInfo;
|
||||
|
||||
// Update fields that might have changed.
|
||||
if ( gHandlerGroup.value == "1" ) {
|
||||
info.preferredAction = Components.interfaces.nsIMIMEInfo.saveToDisk;
|
||||
} else if ( gHandlerGroup.value == "2" ) {
|
||||
info.preferredAction = Components.interfaces.nsIMIMEInfo.useHelperApp;
|
||||
info.preferredApplicationHandler = file;
|
||||
info.applicationDescription = handlerInfo.appDisplayName;
|
||||
} else {
|
||||
info.preferredAction = Components.interfaces.nsIMIMEInfo.handleInternally;
|
||||
}
|
||||
|
||||
// tell the helper app dialog to update itself
|
||||
gHelperAppDlg.updateSelf = true;
|
||||
}
|
||||
|
||||
window.opener.gUpdateTypeRV = true;
|
||||
return true;
|
||||
}
|
||||
]]>
|
||||
</script>
|
||||
<vbox>
|
||||
<hbox align="center">
|
||||
<image id="contentTypeImage"/>
|
||||
<label id="contentType" crop="right"/>
|
||||
<grid flex="1">
|
||||
<columns>
|
||||
<column/>
|
||||
<column flex="1"/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row align="center">
|
||||
<label value="&mimetype.label;" accesskey="&mimetype.accesskey;" control="mimeType"/>
|
||||
<textbox id="mimeType"/>
|
||||
</row>
|
||||
<row align="center">
|
||||
<label value="&description.label;" accesskey="&description.accesskey;" control="description"/>
|
||||
<textbox id="description" crop="right" flex="1"/>
|
||||
</row>
|
||||
<row align="center">
|
||||
<label value="&extension.label;" accesskey="&extension.accesskey;" control="extension"/>
|
||||
<textbox id="extension"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</hbox>
|
||||
|
||||
<separator class="thin"/>
|
||||
|
||||
<separator class="groove"/>
|
||||
|
||||
<separator class="thin"/>
|
||||
|
||||
<grid>
|
||||
<columns>
|
||||
<column flex="1"/>
|
||||
<column flex="3"/>
|
||||
</columns>
|
||||
|
||||
<rows>
|
||||
<row align="center">
|
||||
<label value="&extension.label;"/>
|
||||
<label id="extension"/>
|
||||
</row>
|
||||
<row align="center">
|
||||
<label value="&mimetype.label;" accesskey="&mimetype.accesskey;"
|
||||
control="mimeType"/>
|
||||
<textbox id="mimeType" flex="1"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
||||
<separator class="thin"/>
|
||||
|
||||
<groupbox>
|
||||
<caption label="&handledby.label;"/>
|
||||
|
||||
<description value="&handling.label;"/>
|
||||
<radiogroup id="handler">
|
||||
<!-- Turn this off since we can't make it work yet
|
||||
<radio value="4" label="&useDefault.label;" accesskey="&useDefault.accesskey;" oncommand="doEnabling();"/>
|
||||
-->
|
||||
<radio value="1" label="&saveToDisk.label;" accesskey="&saveToDisk.accesskey;" oncommand="doEnabling();"/>
|
||||
<radio id="useSystemDefault" label="&useDefault.label;" accesskey="&useDefault.accesskey;" oncommand="doEnabling();"/>
|
||||
<hbox align="center">
|
||||
<radio value="2" label="&application.label;" accesskey="&application.accesskey;" oncommand="doEnabling();"/>
|
||||
<radio id="useHelperApp" label="&application.label;" accesskey="&application.accesskey;" oncommand="doEnabling();"/>
|
||||
<textbox id="appPath" flex="1" onchange="selectAppRadio();"/>
|
||||
<button label="&browse.label;" accesskey="&browse.accesskey;"
|
||||
oncommand="chooseApp();"/>
|
||||
</hbox>
|
||||
<radio id="saveToDisk" label="&saveToDisk.label;" accesskey="&saveToDisk.accesskey;" oncommand="doEnabling();"/>
|
||||
</radiogroup>
|
||||
|
||||
</groupbox>
|
||||
|
||||
<separator class="thin"/>
|
||||
|
||||
<hbox align="center">
|
||||
<checkbox id="askBeforeOpen" label="&askBeforeOpen.label;" accesskey="&askBeforeOpen.accesskey;"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
|
||||
<separator class="thin"/>
|
||||
</dialog>
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ var gDS = null;
|
|||
var gPrefApplicationsBundle = null;
|
||||
|
||||
var gExtensionField = null;
|
||||
var gMIMETypeField = null;
|
||||
var gMIMEDescField = null;
|
||||
var gHandlerField = null;
|
||||
var gNewTypeButton = null;
|
||||
var gEditButton = null;
|
||||
|
@ -33,7 +33,8 @@ var gRemoveButton = null;
|
|||
|
||||
function newType()
|
||||
{
|
||||
window.openDialog("chrome://communicator/content/pref/pref-applications-new.xul", "appEdit", "chrome,modal=yes,resizable=no");
|
||||
var handlerOverride = new HandlerOverride();
|
||||
window.openDialog("chrome://communicator/content/pref/pref-applications-edit.xul", "appEdit", "chrome,modal=yes,resizable=no", handlerOverride);
|
||||
if (gNewTypeRV) {
|
||||
//gList.builder.rebuild();
|
||||
gList.setAttribute("ref", "urn:mimetypes");
|
||||
|
@ -43,17 +44,22 @@ function newType()
|
|||
|
||||
function removeType()
|
||||
{
|
||||
var titleMsg = gPrefApplicationsBundle.getString("removeHandlerTitle");
|
||||
var dialogMsg = gPrefApplicationsBundle.getString("removeHandler");
|
||||
dialogMsg = dialogMsg.replace(/%n/g, "\n");
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
|
||||
var remove = promptService.confirm(window, titleMsg, dialogMsg);
|
||||
if (remove) {
|
||||
var uri = gList.selectedItems[0].id;
|
||||
var handlerOverride = new HandlerOverride(uri);
|
||||
removeOverride(handlerOverride.mimeType);
|
||||
gList.setAttribute("ref", "urn:mimetypes");
|
||||
// Only prompt if setting is "useHelperApp".
|
||||
var uri = gList.selectedItems[0].id;
|
||||
var handlerOverride = new HandlerOverride(uri);
|
||||
if ( !handlerOverride.useSystemDefault && !handlerOverride.saveToDisk ) {
|
||||
var titleMsg = gPrefApplicationsBundle.getString("removeHandlerTitle");
|
||||
var dialogMsg = gPrefApplicationsBundle.getString("removeHandler");
|
||||
dialogMsg = dialogMsg.replace(/%n/g, "\n");
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
|
||||
var remove = promptService.confirm(window, titleMsg, dialogMsg);
|
||||
if (!remove) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
removeOverride(handlerOverride.mimeType);
|
||||
gList.setAttribute("ref", "urn:mimetypes");
|
||||
selectApplication();
|
||||
}
|
||||
|
||||
function editType()
|
||||
|
@ -66,6 +72,89 @@ function editType()
|
|||
}
|
||||
}
|
||||
|
||||
const xmlSinkObserver = {
|
||||
onBeginLoad: function(aSink)
|
||||
{
|
||||
},
|
||||
onInterrupt: function(aSink)
|
||||
{
|
||||
},
|
||||
onResume: function(aSink)
|
||||
{
|
||||
},
|
||||
// This is called when the RDF data source has finished loading.
|
||||
onEndLoad: function(aSink)
|
||||
{
|
||||
// Unhook observer.
|
||||
aSink.removeXMLSinkObserver(this);
|
||||
|
||||
// Convert old "don't ask" pref info to helper app pref entries
|
||||
try {
|
||||
var prefService = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPrefService);
|
||||
var prefBranch = prefService.getBranch("browser.helperApps.neverAsk.");
|
||||
if (!prefBranch) return;
|
||||
} catch(e) { return; }
|
||||
|
||||
var neverAskSave = new Array();
|
||||
var neverAskOpen = new Array();
|
||||
try {
|
||||
neverAskSave = prefBranch.getCharPref("saveToDisk").split(",");
|
||||
} catch(e) {}
|
||||
try {
|
||||
neverAskOpen = prefBranch.getCharPref("openFile").split(",");
|
||||
} catch(e) {}
|
||||
|
||||
var i;
|
||||
var newEntries = {};
|
||||
for ( i = 0; i < neverAskSave.length; i++ ) {
|
||||
// See if mime type is in data source.
|
||||
var type = unescape(neverAskSave[i]);
|
||||
if (type != "" && !mimeHandlerExists(type)) {
|
||||
// Not in there, need to create an entry now so user can edit it.
|
||||
newEntries[type] = "saveToDisk";
|
||||
}
|
||||
}
|
||||
|
||||
for ( i = 0; i < neverAskOpen.length; i++ ) {
|
||||
// See if mime type is in data source.
|
||||
var type = unescape(neverAskOpen[i]);
|
||||
if (type != "" && !mimeHandlerExists(type)) {
|
||||
// Not in there, need to create an entry now so user can edit it.
|
||||
newEntries[type] = "useSystemDefault";
|
||||
}
|
||||
}
|
||||
|
||||
// Now create all new entries.
|
||||
for ( var newEntry in newEntries ) {
|
||||
this.createNewEntry(newEntry, newEntries[newEntry]);
|
||||
}
|
||||
|
||||
// Don't need these any more!
|
||||
try { prefBranch.clearUserPref("saveToDisk"); } catch(e) {}
|
||||
try { prefBranch.clearUserPref("openFile"); } catch(e) {}
|
||||
},
|
||||
onError: function(aSink, aStatus, aMsg)
|
||||
{
|
||||
},
|
||||
createNewEntry: function(mimeType, action)
|
||||
{
|
||||
// Create HandlerOverride and populate it.
|
||||
var entry = new HandlerOverride(MIME_URI(mimeType));
|
||||
entry.mUpdateMode = false;
|
||||
entry.mimeType = mimeType;
|
||||
entry.description = "";
|
||||
entry.isEditable = true;
|
||||
entry.alwaysAsk = false;
|
||||
entry.appPath = "";
|
||||
entry.appDisplayName = "";
|
||||
// This sets preferred action.
|
||||
entry[action] = true;
|
||||
|
||||
// Do RDF magic.
|
||||
entry.buildLinks();
|
||||
}
|
||||
}
|
||||
|
||||
function Startup()
|
||||
{
|
||||
// set up the string bundle
|
||||
|
@ -74,7 +163,7 @@ function Startup()
|
|||
// set up the elements
|
||||
gList = document.getElementById("appList");
|
||||
gExtensionField = document.getElementById("extension");
|
||||
gMIMETypeField = document.getElementById("mimeType");
|
||||
gMIMEDescField = document.getElementById("mimeDesc");
|
||||
gHandlerField = document.getElementById("handler");
|
||||
gNewTypeButton = document.getElementById("newTypeButton");
|
||||
gEditButton = document.getElementById("editButton");
|
||||
|
@ -90,12 +179,20 @@ function Startup()
|
|||
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
|
||||
var fileHandler = ioService.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler);
|
||||
dump("spec is " + fileHandler.getURLSpecFromFile(file));
|
||||
gDS = gRDF.GetDataSource(fileHandler.getURLSpecFromFile(file));
|
||||
|
||||
// intialize the listbox
|
||||
gList.database.AddDataSource(gDS);
|
||||
gList.setAttribute("ref", "urn:mimetypes");
|
||||
|
||||
// Test whether the data source is already loaded.
|
||||
if (gDS.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).loaded) {
|
||||
// Do it now.
|
||||
xmlSinkObserver.onEndLoad(gDS.QueryInterface(Components.interfaces.nsIRDFXMLSink));
|
||||
} else {
|
||||
// Add observer that will kick in when data source load completes.
|
||||
gDS.QueryInterface(Components.interfaces.nsIRDFXMLSink).addXMLSinkObserver( xmlSinkObserver );
|
||||
}
|
||||
}
|
||||
|
||||
function selectApplication()
|
||||
|
@ -104,7 +201,7 @@ function selectApplication()
|
|||
var uri = gList.selectedItems[0].id;
|
||||
var handlerOverride = new HandlerOverride(uri);
|
||||
gExtensionField.setAttribute("value", handlerOverride.extensions);
|
||||
gMIMETypeField.setAttribute("value", handlerOverride.mimeType);
|
||||
gMIMEDescField.setAttribute("value", handlerOverride.description);
|
||||
|
||||
// figure out how this type is handled
|
||||
if (handlerOverride.handleInternal == "true")
|
||||
|
@ -113,8 +210,12 @@ function selectApplication()
|
|||
else if (handlerOverride.saveToDisk == "true")
|
||||
gHandlerField.setAttribute("value",
|
||||
gPrefApplicationsBundle.getString("saveToDisk"));
|
||||
else if (handlerOverride.useSystemDefault == "true")
|
||||
gHandlerField.setAttribute("value",
|
||||
gPrefApplicationsBundle.getString("useSystemDefault"));
|
||||
else
|
||||
gHandlerField.setAttribute("value", handlerOverride.appDisplayName);
|
||||
gHandlerField.setAttribute("value",
|
||||
gPrefApplicationsBundle.getFormattedString("useHelperApp", [handlerOverride.appDisplayName]));
|
||||
var ext;
|
||||
var posOfFirstSpace = handlerOverride.extensions.indexOf(" ");
|
||||
if (posOfFirstSpace > -1)
|
||||
|
@ -130,7 +231,7 @@ function selectApplication()
|
|||
gHandlerField.removeAttribute("value");
|
||||
document.getElementById("contentTypeImage").removeAttribute("src");
|
||||
gExtensionField.removeAttribute("value");
|
||||
gMIMETypeField.removeAttribute("value");
|
||||
gMIMEDescField.removeAttribute("value");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,12 +253,3 @@ function updateLockedButtonState(handlerEditable)
|
|||
gRemoveButton.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
function clearRememberedSettings()
|
||||
{
|
||||
var prefBranch = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPrefBranch);
|
||||
if (prefBranch) {
|
||||
prefBranch.setCharPref("browser.helperApps.neverAsk.saveToDisk", "");
|
||||
prefBranch.setCharPref("browser.helperApps.neverAsk.openFile", "");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,8 +45,8 @@
|
|||
<groupbox flex="1">
|
||||
<caption label="&descript;"/>
|
||||
<label value="&fileTypes.label;"/>
|
||||
<hbox flex="1">
|
||||
<vbox flex="1">
|
||||
<vbox>
|
||||
<hbox flex="1">
|
||||
<listbox id="appList" flex="1"
|
||||
sortResource="http://home.netscape.com/NC-rdf#value"
|
||||
sortDirection="ascending"
|
||||
|
@ -73,48 +73,47 @@
|
|||
</rule>
|
||||
</template>
|
||||
</listbox>
|
||||
|
||||
<hbox>
|
||||
<vbox>
|
||||
<button id="newTypeButton"
|
||||
label="&newTypeButton.label;" accesskey="&newTypeButton.accesskey;"
|
||||
oncommand="newType();"/>
|
||||
<button id="editButton"
|
||||
label="&editButton.label;" accesskey="&editButton.accesskey;"
|
||||
oncommand="editType();"/>
|
||||
<button id="removeButton"
|
||||
label="&removeButton.label;" accesskey="&removeButton.accesskey;"
|
||||
oncommand="removeType();"/>
|
||||
</vbox>
|
||||
</hbox>
|
||||
<groupbox orient="horizontal">
|
||||
<caption label="&file;"/>
|
||||
<hbox flex="1">
|
||||
<vbox style="width: 40px; height: 40px;" pack="center" align="center">
|
||||
<image id="contentTypeImage"/>
|
||||
</vbox>
|
||||
<grid orient="horizontal">
|
||||
<grid flex="1">
|
||||
<columns>
|
||||
<column/>
|
||||
<column flex="1"/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<row align="center">
|
||||
<label value="&mimeDesc;"/>
|
||||
<label id="mimeDesc" crop="right" flex="1"/>
|
||||
</row>
|
||||
<row align="center">
|
||||
<label value="&exten;"/>
|
||||
<label id="extension"/>
|
||||
<label id="extension" crop="right"/>
|
||||
</row>
|
||||
<row>
|
||||
<label value="&mimeType;"/>
|
||||
<label id="mimeType"/>
|
||||
</row>
|
||||
<row>
|
||||
<row align="center">
|
||||
<label value="&handle;"/>
|
||||
<textbox id="handler" readonly="true" style="width: 175px" />
|
||||
<textbox id="handler" readonly="true" flex="1"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</hbox>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<button id="newTypeButton"
|
||||
label="&newTypeButton.label;" accesskey="&newTypeButton.accesskey;"
|
||||
oncommand="newType();"
|
||||
prefstring="pref.application.disable_button.new_type"/>
|
||||
<button id="editButton"
|
||||
label="&editButton.label;" accesskey="&editButton.accesskey;"
|
||||
oncommand="editType();"
|
||||
prefstring="pref.application.disable_button.edit"/>
|
||||
<button id="removeButton"
|
||||
label="&removeButton.label;" accesskey="&removeButton.accesskey;"
|
||||
oncommand="removeType();"
|
||||
prefstring="pref.application.disable_button.remove"/>
|
||||
</vbox>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
</vbox>
|
||||
</groupbox>
|
||||
<groupbox id="pluginFinderBox">
|
||||
<caption label="&plugins.label;"/>
|
||||
|
@ -126,12 +125,4 @@
|
|||
<description>&pluginFinderDesc.label;</description>
|
||||
</vbox>
|
||||
</groupbox>
|
||||
<groupbox>
|
||||
<caption label="&fileOpening.label;"/>
|
||||
<hbox pack="start" align="center">
|
||||
<description flex="1">&resetText.label;</description>
|
||||
<spacer flex="1"/>
|
||||
<button label="&resetButton.label;" oncommand="clearRememberedSettings();"/>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
</page>
|
||||
|
|
|
@ -1,31 +1,24 @@
|
|||
|
||||
<!ENTITY editType.label "Edit Type">
|
||||
<!ENTITY newType.label "New Type">
|
||||
<!ENTITY extension.label "Extension:">
|
||||
<!ENTITY extension.accesskey "e">
|
||||
<!--LOCALIZATION NOTE (mimeType): 'MIME' should not be translated -->
|
||||
<!ENTITY mimetype.label "MIME Type:">
|
||||
<!ENTITY mimetype.accesskey "m">
|
||||
<!ENTITY description.label "Description:">
|
||||
<!ENTITY description.accesskey "d">
|
||||
|
||||
<!ENTITY handledby.label "Handled By">
|
||||
|
||||
<!ENTITY useDefault.label "Use system default">
|
||||
<!ENTITY useDefault.accesskey "u">
|
||||
<!ENTITY saveToDisk.label "Save to Disk">
|
||||
<!ENTITY handling.label "When a file of this type is encountered:">
|
||||
<!ENTITY useDefault.label "Open it using the default application">
|
||||
<!ENTITY useDefault.accesskey "o">
|
||||
<!ENTITY saveToDisk.label "Save it to Disk">
|
||||
<!ENTITY saveToDisk.accesskey "s">
|
||||
<!ENTITY application.label "Application">
|
||||
<!ENTITY application.accesskey "a">
|
||||
<!ENTITY application.label "Open it with:">
|
||||
<!ENTITY application.accesskey "w">
|
||||
|
||||
<!ENTITY browse.label "Choose...">
|
||||
<!ENTITY browse.accesskey "c">
|
||||
|
||||
<!ENTITY askBeforeOpen.label "Ask me before opening downloaded files of this type">
|
||||
<!ENTITY askBeforeOpen.label "Always ask me before handling files of this type">
|
||||
<!ENTITY askBeforeOpen.accesskey "k">
|
||||
|
||||
<!ENTITY newDescription.label "Description of type:">
|
||||
<!ENTITY newDescription.accesskey "d">
|
||||
<!ENTITY newExtensions.label "File extension:">
|
||||
<!ENTITY newExtensions.accesskey "e">
|
||||
<!ENTITY newMIME.label "MIME type:">
|
||||
<!ENTITY newMIME.accesskey "m">
|
||||
<!ENTITY newAppPath.label "Application to use:">
|
||||
<!ENTITY newAppPath.accesskey "a">
|
||||
<!ENTITY newTypeTitle.label "New Type">
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<!--LOCALIZATION NOTE : FILE The Applications prefs dialog -->
|
||||
<!ENTITY lHeader "Helper Applications">
|
||||
<!ENTITY descript "Specify which application should handle each file type">
|
||||
<!ENTITY descript "Specify how to handle files of each file type">
|
||||
<!ENTITY fileTypes.label "File types:">
|
||||
<!ENTITY aimLaunchSelect.label "AOL Instant Messenger Launch">
|
||||
<!ENTITY newTypeButton.label "New Type...">
|
||||
|
@ -12,12 +12,9 @@
|
|||
<!ENTITY removeButton.label "Remove">
|
||||
<!ENTITY removeButton.accesskey "r">
|
||||
<!ENTITY file "File Type Details">
|
||||
<!ENTITY exten "Extension:">
|
||||
<!--LOCALIZATION NOTE (mimeType): 'MIME' should not be translated -->
|
||||
<!ENTITY mimeType "MIME type:">
|
||||
<!ENTITY handle "Handled by:">
|
||||
<!ENTITY resetText.label "Click "Reset" to clear your file-opening preferences and be asked before opening files.">
|
||||
<!ENTITY resetButton.label "Reset">
|
||||
<!ENTITY exten "Extension(s):">
|
||||
<!ENTITY mimeDesc "Description:">
|
||||
<!ENTITY handle "When encountered:">
|
||||
<!ENTITY fileOpening.label "Opening files">
|
||||
<!ENTITY plugins.label "Plug-in Finder Service">
|
||||
<!ENTITY pluginFinder.label "Always use the Netscape Plug-in Finder Service (PFS) to get plug-ins.">
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
# foo
|
||||
|
||||
saveToDisk=Save to Disk
|
||||
handleInternally=Handled Internally
|
||||
saveToDisk=Save these files to disk
|
||||
useSystemDefault=Open these files using the default application
|
||||
useHelperApp=Open these files with %S
|
||||
handleInternally=Display files of this type in the browser
|
||||
|
||||
chooseHandler=Choose Application Helper
|
||||
programsFilter=Programs
|
||||
|
||||
handlerExists=A helper already exists for the MIME type '%mime%'. Do you want to replace it?
|
||||
handlerExists=A helper already exists for the MIME type '%mime%'. Do you want to replace it?
|
||||
handlerExistsTitle=Helper Application Exists
|
||||
|
||||
emptyMIMEType=You must specify a MIME type.
|
||||
|
|
Загрузка…
Ссылка в новой задаче