34 const CONTRACTID =
"@mozilla.org/rdf/datasource;1?name=addon-metadata";
35 const CLASSNAME =
"Songbird Addon Metadata Datasource";
36 const CID = Components.ID(
"{a1edd551-0f29-4ce9-aebc-92fbee77f37e}");
37 const IID = Components.interfaces.nsIRDFDataSource;
49 const PREFIX_ADDON_URI =
"urn:songbird:addon:";
63 return PREFIX_ADDON_URI +
id;
79 this._RDF = Components.classes[
"@mozilla.org/rdf/rdf-service;1"]
80 .getService(Components.interfaces.nsIRDFService);
86 if (!this._loadDatasource() || this._isRebuildRequired()) {
88 this._purgeDatasource();
89 this._buildDatasource();
93 dump(
"AddonMetadata: Constructor Error: " + e.toString());
96 var
os = Components.classes[
"@mozilla.org/observer-service;1"]
97 .getService(Components.interfaces.nsIObserverService);
98 os.addObserver(
this,
"xpcom-shutdown",
false);
114 _isRebuildRequired:
function _isRebuildRequired() {
117 if (!emDataFile.exists()) {
122 var newLastModified = emDataFile.lastModifiedTime.toString();
125 var
prefs = Components.classes[
"@mozilla.org/preferences-service;1"]
126 .getService(Components.interfaces.nsIPrefBranch);
127 var lastModified = 0;
134 if (lastModified == newLastModified) {
153 _loadDatasource:
function _loadDatasource() {
159 this._datasource = this._getDatasource(file);
165 if (!file.exists()) {
177 _purgeDatasource:
function _purgeDatasource() {
183 this._RDF.UnregisterDataSource(this._datasource);
191 debug(
"\nAddonMetadata: _purgeDatasource: Could not remove "
192 +
"addon-metadata.rdf. Bad things may happen.\n");
197 this._loadDatasource();
207 _getProfileFile:
function _getProfileFile(filename) {
209 var
file = Components.classes[
"@mozilla.org/file/directory_service;1"]
210 .getService(Components.interfaces.nsIProperties)
211 .get(
"ProfD", Components.interfaces.nsIFile);
212 var localFile = file.QueryInterface(Components.interfaces.nsILocalFile);
213 localFile.appendRelativePath(filename)
223 _buildDatasource:
function _buildDatasource() {
228 var cu = Components.classes[
"@mozilla.org/rdf/container-utils;1"]
229 .getService(Components.interfaces.nsIRDFContainerUtils);
230 var container = cu.MakeSeq(this._datasource, itemRoot);
232 var extManager = Components.classes[
"@mozilla.org/extensions/manager;1"]
233 .getService(Components.interfaces.nsIExtensionManager);
236 var addons = extManager.getItemList(Components.interfaces.nsIUpdateItem.TYPE_ADDON, {});
237 for (var
i = 0;
i < addons.length;
i++)
239 var
id = addons[
i].id;
242 if (this._isExtensionDisabled(
id)) {
249 var location = extManager.getInstallLocation(
id);
252 if (!installManifestFile.exists()) {
253 this._reportErrors([
"install.rdf for id " +
id +
" was not found " +
254 "at location " + installManifestFile.path]);
257 var manifestDS = this._getDatasource(installManifestFile);
258 var itemNode = this._RDF.GetResource(
ADDON_NS(
id));
260 this._copyManifest(itemNode, manifestDS);
263 container.AppendElement(itemNode);
267 this._datasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource)
277 _isExtensionDisabled:
function _isExtensionDisabled(
id) {
278 var item = this._RDF.GetResource(
ITEM_NS(
id));
279 var extManager = Components.classes[
"@mozilla.org/extensions/manager;1"]
280 .getService(Components.interfaces.nsIExtensionManager);
281 var userDisabled = this._RDF.GetResource(
EM_NS(
"userDisabled"));
282 if (extManager.datasource.hasArcOut(item, userDisabled)) {
283 var
target = extManager.datasource.GetTarget(item, userDisabled,
true);
284 if (target instanceof Components.interfaces.nsIRDFLiteral){
285 target = target.QueryInterface(Components.interfaces.nsIRDFLiteral);
286 return target.Value ==
"true";
289 var appDisabled = this._RDF.GetResource(
EM_NS(
"appDisabled"));
290 if (extManager.datasource.hasArcOut(item, appDisabled)) {
291 var target = extManager.datasource.GetTarget(item, appDisabled,
true);
292 if (target instanceof Components.interfaces.nsIRDFLiteral){
293 target = target.QueryInterface(Components.interfaces.nsIRDFLiteral);
294 return target.Value ==
"true";
306 _copyManifest:
function _copyManifest(itemNode, manifestDS) {
309 var resources = manifestDS.GetAllResources();
310 while (resources.hasMoreElements()) {
311 var resource = resources.getNext().QueryInterface(Components.interfaces.nsIRDFResource);
314 var arcs = manifestDS.ArcLabelsOut(resource);
315 while (arcs.hasMoreElements()) {
316 var arc = arcs.getNext().QueryInterface(Components.interfaces.nsIRDFResource);
319 var targets = manifestDS.GetTargets(resource, arc,
true);
320 while (targets.hasMoreElements()) {
321 var target = targets.getNext().QueryInterface(Components.interfaces.nsIRDFNode);
325 newResource = resource;
327 newResource = itemNode;
331 this._datasource.Assert(newResource, arc, target,
true);
347 _getDatasource:
function _getDatasource(
file) {
348 var ioServ = Components.classes[
"@mozilla.org/network/io-service;1"]
349 .getService(Components.interfaces.nsIIOService);
350 var fph = ioServ.getProtocolHandler(
"file")
351 .QueryInterface(Components.interfaces.nsIFileProtocolHandler);
353 var fileURL = fph.getURLSpecFromFile(
file);
354 var ds = this._RDF.GetDataSourceBlocking(fileURL);
361 _deinit:
function _deinit() {
365 this._datasource =
null;
372 var
os = Components.classes[
"@mozilla.org/observer-service;1"]
373 .getService(Components.interfaces.nsIObserverService);
375 case "xpcom-shutdown":
376 os.removeObserver(
this,
"xpcom-shutdown");
384 _reportErrors:
function _reportErrors(errorList) {
385 var consoleService = Components.classes[
"@mozilla.org/consoleservice;1"].
386 getService(Components.interfaces.nsIConsoleService);
387 for (var
i = 0;
i < errorList.length;
i++) {
388 consoleService.logStringMessage(
"Addon Metadata Reader: " + errorList[
i]);
389 debug(
"AddonMetadataReader: " + errorList[i] +
"\n");
399 if (!iid.equals(
IID) &&
400 !iid.equals(Components.interfaces.nsIObserver) &&
401 !iid.equals(Components.interfaces.nsISupports))
402 throw Components.results.NS_ERROR_NO_INTERFACE;
407 if (iid.equals(
IID)) {
408 return this._datasource;
427 registerSelf:
function(componentManager, fileSpec, location, type) {
428 componentManager = componentManager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
429 for (var
key in this._objects) {
430 var obj = this._objects[
key];
431 componentManager.registerFactoryLocation(obj.CID, obj.className, obj.contractID,
432 fileSpec, location, type);
437 if (!iid.equals(Components.interfaces.nsIFactory))
438 throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
440 for (var
key in this._objects) {
441 if (cid.equals(
this._objects[
key].CID))
442 return this._objects[
key].factory;
445 throw Components.results.NS_ERROR_NO_INTERFACE;
448 _makeFactory: #1=
function(ctor) {
449 function ci(outer, iid) {
451 throw Components.results.NS_ERROR_NO_AGGREGATION;
452 return (
new ctor()).QueryInterface(iid);
465 canUnload:
function(componentManager) {
sbOSDControlService prototype className
SafebrowsingApplicationMod prototype registerSelf
for(let i=0;i< aHistory.count;i++)
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbOSDControlService prototype QueryInterface
getService(Ci.sbIFaceplateManager)
SafebrowsingApplicationMod prototype getClassObject
DataRemote prototype constructor
_getSelectedPageStyle s i
sbDeviceFirmwareAutoCheckForUpdate prototype observe