50 if (typeof(
Cc) ==
"undefined")
51 var
Cc = Components.classes;
52 if (typeof(
Ci) ==
"undefined")
53 var
Ci = Components.interfaces;
54 if (typeof(
Cr) ==
"undefined")
55 var
Cr = Components.results;
56 if (typeof(
Cu) ==
"undefined")
57 var
Cu = Components.utils;
60 Cu.import(
"resource://app/jsmodules/ObserverUtils.jsm");
61 Cu.import(
"resource://app/jsmodules/StringUtils.jsm");
62 Cu.import(
"resource://gre/modules/XPCOMUtils.jsm");
81 classID: Components.ID(
"{3124ec90-1dd2-11b2-8059-c4e994415c12}"),
82 contractID:
"@songbirdnest.com/Songbird/WindowsAutoPlayService;1",
83 ifList: [ Ci.sbIWindowsAutoPlayService,
84 Ci.sbICommandLineFlagHandler,
88 sbWindowsAutoPlayServiceCfg._xpcom_categories = [
90 category:
"app-startup",
91 entry: sbWindowsAutoPlayServiceCfg.className,
92 value:
"service," + sbWindowsAutoPlayServiceCfg.contractID
134 classID: sbWindowsAutoPlayServiceCfg.classID,
135 contractID: sbWindowsAutoPlayServiceCfg.contractID,
139 _isInitialized:
false,
140 _isProcessingEvents:
false,
142 _actionHandlerTable:
null,
160 function sbWindowsAutoPlayService_addActionHandler(aHandler, aAction) {
162 var actionHandlerList;
163 if (aAction in this._actionHandlerTable) {
164 actionHandlerList = this._actionHandlerTable[aAction];
166 actionHandlerList = [];
167 this._actionHandlerTable[aAction] = actionHandlerList;
171 if (actionHandlerList.indexOf(aHandler) < 0)
172 actionHandlerList.push(aHandler);
185 function sbWindowsAutoPlayService_removeActionHandler(aHandler, aAction) {
188 if (!this._isInitialized)
192 if (!(aAction in this._actionHandlerTable))
194 var actionHandlerList = this._actionHandlerTable[aAction];
197 var handlerIndex = actionHandlerList.indexOf(aHandler);
198 if (handlerIndex >= 0)
199 actionHandlerList.splice(handlerIndex, 1);
202 if (!actionHandlerList.length)
203 delete this._actionHandlerTable[aAction];
221 observe:
function sbWindowsAutoPlayService_observe(aSubject, aTopic,
aData) {
225 this._handleAppStartup();
228 case "songbird-main-window-presented" :
229 this._handleSBMainWindowPresented();
232 case "quit-application-granted" :
233 this._handleQuitApplicationGranted();
257 handleFlag:
function sbWindowsAutoPlayService_handleFlag(aFlag, aParam) {
262 case "autoplay-manage-volume-device" :
263 this._handleAutoPlayManageVolumeDevice();
266 case "autoplay-manage-mtp-device" :
267 this._handleAutoPlayManageMTPDevice();
270 case "autoplay-cd-rip" :
271 this._handleAutoPlayCDRip();
288 QueryInterface: XPCOMUtils.generateQI(sbWindowsAutoPlayServiceCfg.ifList),
301 _handleAutoPlayManageVolumeDevice:
302 function sbWindowsAutoPlayService__handleAutoPlayManageVolumeDevice() {
306 (Ci.sbIWindowsAutoPlayService.ACTION_MANAGE_VOLUME_DEVICE,
312 if (!actionHandled) {
313 var windowWatcher = Cc[
"@songbirdnest.com/Songbird/window-watcher;1"]
314 .getService(Ci.sbIWindowWatcher);
316 var func =
function(aWindow)
317 { _this._alertUserCannotManageVolumeDevice(aWindow); };
318 windowWatcher.callWithWindow(
"Songbird:Main", func);
327 _handleAutoPlayManageMTPDevice:
328 function sbWindowsAutoPlayService__handleAutoPlayManageMTPDevice() {
332 (Ci.sbIWindowsAutoPlayService.ACTION_MANAGE_MTP_DEVICE,
338 if (!actionHandled) {
339 var windowWatcher = Cc[
"@songbirdnest.com/Songbird/window-watcher;1"]
340 .getService(Ci.sbIWindowWatcher);
342 var func =
function(aWindow)
343 { _this._alertUserCannotManageMTPDevice(aWindow); };
344 windowWatcher.callWithWindow(
"Songbird:Main", func);
353 _handleAutoPlayCDRip:
354 function sbWindowsAutoPlayService__handleAutoPlayCDRip() {
358 (Ci.sbIWindowsAutoPlayService.ACTION_CD_RIP,
364 if (!actionHandled) {
365 var windowWatcher = Cc[
"@songbirdnest.com/Songbird/window-watcher;1"]
366 .getService(Ci.sbIWindowWatcher);
368 var func =
function(aWindow)
369 { _this._alertUserCannotCDRip(aWindow); };
370 windowWatcher.callWithWindow(
"Songbird:Main", func);
385 _handleAction:
function sbWindowsAutoPlayService__handleAction(aAction,
388 if (!(aAction in this._actionHandlerTable))
390 var actionHandlerList = this._actionHandlerTable[aAction];
393 var actionHandled =
false;
394 for (var
i = 0;
i < actionHandlerList.length;
i++) {
395 var actionHandler = actionHandlerList[
i];
397 actionHandled = actionHandler.handleAction(aAction, aActionArg);
405 return actionHandled;
416 _alertUserCannotManageVolumeDevice:
function
417 sbWindowsAutoPlayService__alertUserCannotManageVolumeDevice(aWindow) {
419 var
Application = Cc[
"@mozilla.org/fuel/application;1"]
420 .getService(Ci.fuelIApplication);
423 var stringNamePrefix =
"windows.autoplay.cannot_manage_device.dialog.";
424 if (Application.extensions.has(
"msc@songbirdnest.com")) {
425 if (!Application.extensions.get(
"msc@songbirdnest.com").enabled) {
427 "windows.autoplay.cannot_manage_device.msc_not_enabled.dialog.";
431 "windows.autoplay.cannot_manage_device.msc_not_installed.dialog.";
435 var prompter = Cc[
"@songbirdnest.com/Songbird/Prompter;1"]
436 .createInstance(Ci.sbIPrompter);
437 var title =
SBString(stringNamePrefix +
"title");
439 prompter.alert(aWindow, title, msg);
450 _alertUserCannotManageMTPDevice:
function
451 sbWindowsAutoPlayService__alertUserCannotManageMTPDevice(aWindow) {
453 var
Application = Cc[
"@mozilla.org/fuel/application;1"]
454 .getService(Ci.fuelIApplication);
457 var stringNamePrefix =
"windows.autoplay.cannot_manage_device.dialog.";
458 if (Application.extensions.has(
"mtp@songbirdnest.com")) {
459 if (!Application.extensions.get(
"mtp@songbirdnest.com").enabled) {
461 "windows.autoplay.cannot_manage_device.mtp_not_enabled.dialog.";
465 "windows.autoplay.cannot_manage_device.mtp_not_installed.dialog.";
469 var prompter = Cc[
"@songbirdnest.com/Songbird/Prompter;1"]
470 .createInstance(Ci.sbIPrompter);
471 var title =
SBString(stringNamePrefix +
"title");
473 prompter.alert(aWindow, title, msg);
484 _alertUserCannotCDRip:
485 function sbWindowsAutoPlayService__alertUserCannotCDRip(aWindow) {
486 var prefix =
"windows.autoplay.cannot_cd_rip.dialog.";
487 var prompter = Cc[
"@songbirdnest.com/Songbird/Prompter;1"]
488 .createInstance(Ci.sbIPrompter);
489 var title =
SBString(prefix +
"title");
491 prompter.alert(aWindow, title, msg);
504 _handleAppStartup:
function sbWindowsAutoPlayService__handleAppStartup() {
514 _handleSBMainWindowPresented:
515 function sbWindowsAutoPlayService__handleSBMainWindowPresented() {
527 _handleQuitApplicationGranted:
528 function sbWindowsAutoPlayService__handleQuitApplicationGranted() {
544 _startCommandLine:
function sbWindowsAutoPlayService__startCommandLine() {
546 var commandLineManager =
547 Cc[
"@songbirdnest.com/commandlinehandler/general-startup;1?type=songbird"]
548 .getService(Ci.sbICommandLineManager);
551 commandLineManager.addFlagHandler(
this,
"autoplay-manage-volume-device");
552 commandLineManager.addFlagHandler(
this,
"autoplay-manage-mtp-device");
555 commandLineManager.addFlagHandler(
this,
"autoplay-cd-rip");
563 _stopCommandLine:
function sbWindowsAutoPlayService__stopCommandLine() {
565 var commandLineManager =
566 Cc[
"@songbirdnest.com/commandlinehandler/general-startup;1?type=songbird"]
567 .getService(Ci.sbICommandLineManager);
570 commandLineManager.removeFlagHandler(
this,
"autoplay-manage-volume-device");
573 commandLineManager.removeFlagHandler(
this,
"autoplay-cd-rip");
587 _initialize:
function sbWindowsAutoPlayService__initialize() {
589 if (this._isInitialized)
593 this._actionHandlerTable = {};
596 if (!this._observerSet) {
597 this._observerSet =
new ObserverSet();
598 this._observerSet.add(
this,
599 "songbird-main-window-presented",
602 this._observerSet.add(
this,
"quit-application-granted",
false,
false);
606 this._isInitialized =
true;
614 _finalize:
function sbWindowsAutoPlayService__finalize() {
616 if (this._observerSet) {
617 this._observerSet.removeAll();
618 this._observerSet =
null;
625 this._actionHandlerTable =
null;
628 this._isInitialized =
false;
636 _start:
function sbWindowsAutoPlayService__start() {
639 if (this._isProcessingEvents)
641 this._isProcessingEvents =
true;
644 this._startCommandLine();
652 _stop:
function sbWindowsAutoPlayService__stop() {
654 if (!this._isProcessingEvents)
658 this._stopCommandLine();
661 this._isProcessingEvents =
false;
function NSGetModule(compMgr, fileSpec)
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
function sbWindowsAutoPlayService()
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
function SBString(aKey, aDefault, aStringBundle)
DataRemote prototype constructor
sbDeviceFirmwareAutoCheckForUpdate prototype classID
sbWindowsAutoPlayServiceCfg _xpcom_categories
var sbWindowsAutoPlayServiceCfg
_getSelectedPageStyle s i
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe