michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: Components.utils.import("resource://gre/modules/devtools/event-emitter.js"); michael@0: michael@0: const EXPORTED_SYMBOLS = ["Devices"]; michael@0: michael@0: let addonInstalled = false; michael@0: michael@0: const Devices = { michael@0: _devices: {}, michael@0: michael@0: get helperAddonInstalled() { michael@0: return addonInstalled; michael@0: }, michael@0: set helperAddonInstalled(v) { michael@0: addonInstalled = v; michael@0: this.emit("addon-status-updated", v); michael@0: }, michael@0: michael@0: register: function (name, device) { michael@0: this._devices[name] = device; michael@0: this.emit("register"); michael@0: }, michael@0: michael@0: unregister: function (name) { michael@0: delete this._devices[name]; michael@0: this.emit("unregister"); michael@0: }, michael@0: michael@0: available: function () { michael@0: return Object.keys(this._devices).sort(); michael@0: }, michael@0: michael@0: getByName: function (name) { michael@0: return this._devices[name]; michael@0: } michael@0: }; michael@0: michael@0: EventEmitter.decorate(Devices);