25 const Cc = Components.classes;
26 const CC = Components.Constructor;
27 const Ci = Components.interfaces;
28 const Cr = Components.results;
29 const Cu = Components.utils;
31 Cu.import(
"resource://gre/modules/XPCOMUtils.jsm");
32 Cu.import(
"resource://app/jsmodules/ArrayConverter.jsm");
37 this._numProviders = 0;
39 this._defaultProvider =
null;
41 var catMgr =
Cc[
"@mozilla.org/categorymanager;1"]
42 .getService(
Ci.nsICategoryManager);
43 var e = catMgr.enumerateCategory(
'metadata-lookup');
44 while (e.hasMoreElements()) {
45 var
key = e.getNext().QueryInterface(
Ci.nsISupportsCString);
46 var contract = catMgr.getCategoryEntry(
'metadata-lookup', key);
48 var provider =
Cc[contract].getService(
Ci.sbIMetadataLookupProvider);
49 this._providers[provider.name] = provider;
53 if (!this._defaultProvider)
54 this._defaultProvider = provider;
59 if (provider.weight <
this._defaultProvider.weight)
60 this._defaultProvider = provider;
63 dump(
"mlm // failed to register: " + contract +
"\n" +
64 "mlm // reason: " + e +
"\n");
68 Cc[
"@mozilla.org/observer-service;1"]
69 .getService(
Ci.nsIObserverService)
70 .addObserver(
this,
"songbird-library-manager-before-shutdown",
false);
75 classID : Components.ID(
'46733000-1dd2-11b2-8022-ba2da8a6a950'),
76 contractID :
'@songbirdnest.com/Songbird/MetadataLookup/manager;1',
82 _defaultProvider:
null,
86 getProviders:
function() {
87 return ArrayConverter.enumerator([
p for each (
p in this._providers)]);
91 getProvider:
function(aProviderName) {
92 if (this._providers[aProviderName])
93 return this._providers[aProviderName];
95 throw Cr.NS_ERROR_NOT_AVAILABLE;
98 get numProviders()
this._numProviders,
100 get defaultProvider() {
101 if (this._numProviders == 0)
102 throw Cr.NS_ERROR_NOT_AVAILABLE;
107 .getService(
Ci.fuelIApplication);
108 var userDefault = Application.prefs.getValue(
109 "metadata.lookup.default_provider",
"");
110 if (userDefault && this._providers[userDefault]) {
111 return this._providers[userDefault];
115 return this._defaultProvider;
120 observe:
function sbMLM_observe(aSubject, aTopic,
aData) {
121 if (aTopic ==
"songbird-library-manager-before-shutdown") {
124 Cc[
"@mozilla.org/observer-service;1"]
125 .getService(
Ci.nsIObserverService)
126 .removeObserver(
this,
"songbird-library-manager-before-shutdown");
127 this._providers = {};
128 this._numProviders = 0;
129 this._defaultProvider =
null;
135 return XPCOMUtils.generateModule([
sbMLM]);
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
sbDeviceFirmwareAutoCheckForUpdate prototype classID
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe