From 4ab5f71126317c77e89e3a632533632ba14fb764 Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Sun, 27 Jul 2008 08:56:22 -0400 Subject: [PATCH] Bug 441636 - Store and retrieve DBus handler apps correctly r=biesi --- uriloader/exthandler/nsHandlerService.js | 51 +++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/uriloader/exthandler/nsHandlerService.js b/uriloader/exthandler/nsHandlerService.js index 2ba419dd2076..e5c21f04b76c 100755 --- a/uriloader/exthandler/nsHandlerService.js +++ b/uriloader/exthandler/nsHandlerService.js @@ -96,6 +96,17 @@ const NC_PATH = NC_NS + "path"; // nsIWebHandlerApp::uriTemplate const NC_URI_TEMPLATE = NC_NS + "uriTemplate"; +// nsIDBusHandlerApp::service +const NC_SERVICE = NC_NS + "service"; + +// nsIDBusHandlerApp::method +const NC_METHOD = NC_NS + "method"; + +// nsIDBusHandlerApp::objectPath +const NC_OBJPATH = NC_NS + "objectPath"; + +// nsIDBusHandlerApp::dbusInterface +const NC_INTERFACE = NC_NS + "dBusInterface"; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); @@ -566,6 +577,31 @@ HandlerService.prototype = { createInstance(Ci.nsIWebHandlerApp); handlerApp.uriTemplate = uriTemplate; } + else if (this._hasValue(aHandlerAppID, NC_SERVICE)) { + let service = this._getValue(aHandlerAppID, NC_SERVICE); + if (!service) + return null; + + let method = this._getValue(aHandlerAppID, NC_METHOD); + if (!method) + return null; + + let objpath = this._getValue(aHandlerAppID, NC_OBJPATH); + if (!objpath) + return null; + + let interface = this._getValue(aHandlerAppID, NC_INTERFACE); + if (!interface) + return null; + + handlerApp = Cc["@mozilla.org/uriloader/dbus-handler-app;1"]. + createInstance(Ci.nsIDBusHandlerApp); + handlerApp.service = service; + handlerApp.method = method; + handlerApp.objectPath = objpath; + handlerApp.dBusInterface = interface; + + } else return null; @@ -771,15 +807,28 @@ HandlerService.prototype = { if (aHandlerApp instanceof Ci.nsILocalHandlerApp) { this._setLiteral(aHandlerAppID, NC_PATH, aHandlerApp.executable.path); this._removeTarget(aHandlerAppID, NC_URI_TEMPLATE); + this._removeTarget(aHandlerAppID, NC_METHOD); + this._removeTarget(aHandlerAppID, NC_SERVICE); + this._removeTarget(aHandlerAppID, NC_OBJPATH); + this._removeTarget(aHandlerAppID, NC_INTERFACE); } else if(aHandlerApp instanceof Ci.nsIWebHandlerApp){ aHandlerApp.QueryInterface(Ci.nsIWebHandlerApp); this._setLiteral(aHandlerAppID, NC_URI_TEMPLATE, aHandlerApp.uriTemplate); this._removeTarget(aHandlerAppID, NC_PATH); + this._removeTarget(aHandlerAppID, NC_METHOD); + this._removeTarget(aHandlerAppID, NC_SERVICE); + this._removeTarget(aHandlerAppID, NC_OBJPATH); + this._removeTarget(aHandlerAppID, NC_INTERFACE); } else if(aHandlerApp instanceof Ci.nsIDBusHandlerApp){ aHandlerApp.QueryInterface(Ci.nsIDBusHandlerApp); - + this._setLiteral(aHandlerAppID, NC_SERVICE, aHandlerApp.service); + this._setLiteral(aHandlerAppID, NC_METHOD, aHandlerApp.method); + this._setLiteral(aHandlerAppID, NC_OBJPATH, aHandlerApp.objectPath); + this._setLiteral(aHandlerAppID, NC_INTERFACE, aHandlerApp.dBusInterface); + this._removeTarget(aHandlerAppID, NC_PATH); + this._removeTarget(aHandlerAppID, NC_URI_TEMPLATE); } else { throw "unknown handler type";