more Application Helper Pref panel stuff (supporting removal of handlers)

This commit is contained in:
ben%netscape.com 2000-07-08 03:21:23 +00:00
Родитель c99fd7394b
Коммит 64c6c5c0f1
5 изменённых файлов: 126 добавлений и 78 удалений

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

@ -346,3 +346,42 @@ function unassertMIMEStuff(aMIMEString, aPropertyString, aValueString)
gDS.Unassert(mimeSource, valueProperty, mimeLiteral, true);
}
function removeOverride(aMIMEType)
{
dump("*** mimeType = " + aMIMEType + "\n");
// remove entry from seq
var rdfc = Components.classes["component://netscape/rdf/container"].createInstance();
if (rdfc) {
rdfc = rdfc.QueryInterface(Components.interfaces.nsIRDFContainer);
if (rdfc) {
var containerRes = gRDF.GetResource("urn:mimetypes:root");
rdfc.Init(gDS, containerRes);
var element = gRDF.GetResource(MIME_URI(aMIMEType));
if (rdfc.IndexOf(element) != -1)
rdfc.RemoveElement(element, true);
}
}
// remove items from the graph
var urns = [ [MIME_URI, ["description", "editable", "value", "smallIcon", "largeIcon"], [HANDLER_URI, "handlerProp"]],
[HANDLER_URI, ["handleInternal", "saveToDisk", "alwaysAsk"], [APP_URI, "externalApplication"]],
[APP_URI, ["path", "prettyName"]] ];
for (var i = 0; i < urns.length; i++) {
var mimeRes = gRDF.GetResource(urns[i][0](aMIMEType));
dump("*** mimeRes = " + mimeRes + "\n");
// unassert the toplevel properties
var properties = urns[i][1];
for (var j = 0; j < properties.length; j++) {
var propertyRes = gRDF.GetResource(NC_RDF(properties[j]), true);
dump("*** propertyRes = " + propertyRes + "\n");
var mimeValue = gDS.GetTarget(mimeRes, propertyRes, true);
dump("*** mimeValue = " + mimeValue + "\n");
gDS.Unassert(mimeRes, propertyRes, mimeValue, true);
}
if (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);
}
}
}

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

@ -133,9 +133,9 @@
doEnabling();
}
var gDS = null;
function onOK()
{
var gDS = null;
function onOK()
{
const mimeTypes = 66638;
var fileLocator = Components.classes["component://netscape/filelocator"].getService();
if (fileLocator)
@ -206,7 +206,7 @@ function onOK()
window.opener.gUpdateTypeRV = true;
window.close();
}
}
]]>
</script>

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

@ -1,6 +1,5 @@
var gNewTypeRV = null;
var gRemoveTypeRV = null;
var gUpdateTypeRV = null;
function newType()
@ -16,11 +15,17 @@ function newType()
function removeType()
{
// implement me
if (gRemoveTypeRV) {
//gTree.builder.rebuild();
var titleMsg = gBundle.GetStringFromName("removeHandlerTitle");
var dialogMsg = gBundle.GetStringFromName("removeHandler");
dialogMsg = dialogMsg.replace(/%n/g, "\n");
var commonDialogService = nsJSComponentManager.getService("component://netscape/appshell/commonDialogs",
"nsICommonDialogs");
var remove = commonDialogService.Confirm(window, titleMsg, dialogMsg);
if (remove) {
var uri = gTree.selectedItems[0].id;
var handlerOverride = new HandlerOverride(uri);
removeOverride(handlerOverride.mimeType);
gTree.setAttribute("ref", "urn:mimetypes");
gRemoveTypeRV = null;
}
}

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

@ -38,6 +38,7 @@
<script language="JavaScript" src="chrome://communicator/content/pref/pref-applications.js"></script>
<script language="JavaScript" src="chrome://communicator/content/pref/overrideHandler.js"></script>
<script language="JavaScript" src="chrome://global/content/strres.js"></script>
<script language="JavaScript" src="chrome://global/content/nsJSComponentManager.js"></script>
<box class="box-smallheader" title="&lHeader;"/>

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

@ -8,3 +8,6 @@ programsFilter=Programs
handlerExists=A helper already exists for the MIME type '%mime%'. Do you want to replace it?
handlerExistsTitle=Helper Application Exists
removeHandlerTitle=Remove File Type
removeHandler=If you remove a registered type, the helper will no longer be able to automatically handle files of this type. %n%nAre you sure you want to remove this file type?