2 * (C) Copyright 2004-2007 Shawn Betts
3 * (C) Copyright 2007-2009 John J. Foerch
4 * (C) Copyright 2007-2008 Jeremy Maitin-Shepard
6 * Use, modification, and distribution are subject to the terms specified in the
10 const PREFIX_ITEM_URI = "urn:mozilla:item:";
11 const PREFIX_NS_EM = "http://www.mozilla.org/2004/em-rdf#";
13 var extension_manager = Cc["@mozilla.org/extensions/manager;1"]
14 .getService(Ci.nsIExtensionManager);
16 function get_extension_rdf_property (id, name, type) {
17 const rdf_service = Cc["@mozilla.org/rdf/rdf-service;1"]
18 .getService(Ci.nsIRDFService);
19 var value = extension_manager.datasource.GetTarget(
20 rdf_service.GetResource(PREFIX_ITEM_URI + id),
21 rdf_service.GetResource(PREFIX_NS_EM + name),
25 return value.QueryInterface(type || Ci.nsIRDFLiteral).Value;
28 function get_extension_update_item (id) {
29 return extension_manager.getItemForID(id);
32 function extension_info (id) {
35 extension_info.prototype = {
36 // Returns the nsIUpdateItem object associated with this extension
37 get update_item () { return get_extension_update_item(this.id); },
39 get_rdf_property : function (name, type) {
40 return get_extension_rdf_property(this.id, name, type);
44 get isDisabled () { return this.get_rdf_property("isDisabled"); },
45 get aboutURL () { return this.get_rdf_property("aboutURL"); },
46 get addonID () { return this.get_rdf_property("addonID"); },
47 get availableUpdateURL () { return this.get_rdf_property("availableUpdateURL"); },
48 get availableUpdateVersion () { return this.get_rdf_property("availableUpdateVersion"); },
49 get blocklisted () { return this.get_rdf_property("blocklisted"); },
50 get compatible () { return this.get_rdf_property("compatible"); },
51 get description () { return this.get_rdf_property("description"); },
52 get downloadURL () { return this.get_rdf_property("downloadURL"); },
53 get isDisabled () { return this.get_rdf_property("isDisabled"); },
54 get hidden () { return this.get_rdf_property("hidden"); },
55 get homepageURL () { return this.get_rdf_property("homepageURL"); },
56 get iconURL () { return this.get_rdf_property("iconURL"); },
57 get internalName () { return this.get_rdf_property("internalName"); },
58 get locked () { return this.get_rdf_property("locked"); },
59 get name () { return this.get_rdf_property("name"); },
60 get optionsURL () { return this.get_rdf_property("optionsURL"); },
61 get opType () { return this.get_rdf_property("opType"); },
62 get plugin () { return this.get_rdf_property("plugin"); },
63 get previewImage () { return this.get_rdf_property("previewImage"); },
64 get satisfiesDependencies () { return this.get_rdf_property("satisfiesDependencies"); },
65 get providesUpdatesSecurely () { return this.get_rdf_property("providesUpdatesSecurely"); },
66 get type () { return this.get_rdf_property("type", Ci.nsIRDFInt); },
67 get updateable () { return this.get_rdf_property("updateable"); },
68 get updateURL () { return this.get_rdf_property("updateURL"); },
69 get version () { return this.get_rdf_property("version"); }
72 function extension_is_enabled (id) {
73 var info = new extension_info(id);
74 return info.update_item && (info.isDisabled == "false");