27 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
28 Components.utils.import(
"resource://app/jsmodules/DropHelper.jsm");
29 Components.utils.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
30 Components.utils.import(
"resource://app/jsmodules/SBUtils.jsm");
32 const Ci = Components.interfaces;
33 const Cc = Components.classes;
36 "@songbirdnest.com/Songbird/Library/medialistduplicatefilter;1";
50 "SBPlaylistCommand_AddToLibrary" ];
74 playlistCommands: [
null]
77 _getMenu:
function(aSubMenu)
79 return this.root_commands;
82 getVisible:
function(
aHost )
87 getNumCommands:
function( aSubMenu,
aHost )
89 return this._getMenu(aSubMenu).ids.length;
92 getCommandId:
function( aSubMenu, aIndex,
aHost )
94 return this._getMenu(aSubMenu).ids[ aIndex ] ||
"";
97 getCommandType:
function( aSubMenu, aIndex,
aHost )
99 return this._getMenu(aSubMenu).types[ aIndex ] ||
"";
102 getCommandText:
function( aSubMenu, aIndex,
aHost )
104 return this._getMenu(aSubMenu).names[ aIndex ] ||
"";
107 getCommandFlex:
function( aSubMenu, aIndex,
aHost )
109 return ( this._getMenu(aSubMenu).types[ aIndex ] ==
"separator" ) ? 1 : 0;
112 getCommandToolTipText:
function( aSubMenu, aIndex,
aHost )
114 return this._getMenu(aSubMenu).tooltips[ aIndex ] ||
"";
117 getCommandValue:
function( aSubMenu, aIndex,
aHost )
126 refreshCustomCommand:
function( aElement, aId,
aHost )
130 getCommandVisible:
function( aSubMenu, aIndex,
aHost )
135 getCommandFlag:
function( aSubmenu, aIndex,
aHost )
140 getCommandChoiceItem:
function( aChoiceMenu,
aHost )
145 getCommandEnabled:
function( aSubMenu, aIndex,
aHost )
147 if (this.context.playlist.tree.currentIndex == -1)
return false;
148 return this._getMenu(aSubMenu).enableds[ aIndex ];
151 getCommandShortcutModifiers:
function ( aSubMenu, aIndex,
aHost )
153 return this._getMenu(aSubMenu).modifiers[ aIndex ] ||
"";
156 getCommandShortcutKey:
function ( aSubMenu, aIndex,
aHost )
158 return this._getMenu(aSubMenu).keys[ aIndex ] ||
"";
161 getCommandShortcutKeycode:
function ( aSubMenu, aIndex,
aHost )
163 return this._getMenu(aSubMenu).keycodes[ aIndex ] ||
"";
166 getCommandShortcutLocal:
function ( aSubMenu, aIndex,
aHost )
171 getCommandSubObject:
function ( aSubMenu, aIndex,
aHost )
173 return this._getMenu(aSubMenu).playlistCommands[ aIndex ] ||
null;
176 onCommand:
function( aSubMenu, aIndex,
aHost,
id,
value )
178 this.addToLibrary.handleCommand(
id, this.context);
184 dupObject:
function (obj) {
193 duplicate:
function()
195 var obj = this.dupObject(
this);
196 obj.context = this.dupObject(this.context);
200 initCommands:
function(
aHost) {
201 if (!this.addToLibrary) {
203 this.addToLibrary.init(
this);
207 shutdownCommands:
function() {
208 if (!this.addToLibrary) {
209 dump(
"this.addToLibrary is null in SBPlaylistCommand_AddToLibrary ?!!\n");
213 this.addToLibrary.shutdown();
217 setContext:
function( context )
219 var playlist = context.playlist;
220 var
window = context.window;
224 if ( playlist && playlist.wrappedJSObject )
225 playlist = playlist.wrappedJSObject;
227 if ( window && window.wrappedJSObject )
228 window = window.wrappedJSObject;
230 this.context.playlist = playlist;
231 this.context.window =
window;
236 if (!aIID.equals(Components.interfaces.sbIPlaylistCommands) &&
237 !aIID.equals(Components.interfaces.nsISupportsWeakReference) &&
238 !aIID.equals(Components.interfaces.nsISupports))
240 throw Components.results.NS_ERROR_NO_INTERFACE;
252 init:
function addToLibraryHelper_init(aCommands) {
254 Cc[
"@songbirdnest.com/Songbird/library/Manager;1"]
255 .getService(
Ci.sbILibraryManager);
257 Cc[
"@songbirdnest.com/Songbird/DeviceManager;2"]
258 .getService(
Ci.sbIDeviceManager2);
261 shutdown:
function addToLibraryHelper_shutdown() {
262 this.deviceManager =
null;
266 _getDeviceLibraryForLibrary:
function(aDevice, aLibrary) {
267 var libs = aDevice.content.libraries;
268 for (var
i = 0;
i < libs.length;
i++) {
269 var devLib = libs.queryElementAt(
i,
Ci.sbIDeviceLibrary);
270 if (devLib.equals(aLibrary))
277 _itemsFromEnumerator:
function(aItemEnum) {
278 var items =
Cc[
"@mozilla.org/array;1"].createInstance(
Ci.nsIMutableArray);
280 while (aItemEnum.hasMoreElements())
281 items.appendElement(aItemEnum.getNext(),
false);
287 handleCommand:
function addToLibraryHelper_handleCommand(
id, context) {
292 var selection = context.playlist.mediaListView
293 .selection.selectedMediaItems;
294 var sourceLibrary = context.playlist.mediaListView.mediaList.library;
296 var device = this.deviceManager.getDeviceForItem(sourceLibrary);
298 var items = this._itemsFromEnumerator(selection);
300 var deviceLibrary = this._getDeviceLibraryForLibrary(
301 device, sourceLibrary);
304 Cc[
"@songbirdnest.com/Songbird/Device/DeviceLibrarySyncDiff;1"]
305 .createInstance(
Ci.sbIDeviceLibrarySyncDiff);
309 differ.generateDropLists(sourceLibrary,
316 device.importFromDevice(destLibrary, changeset.value);
318 DNDUtils.reportAddedTracks(changeset.value.changes.length,
325 destLibrary.addSome(selected);
331 Components.utils.reportError(e);
const SB_MEDIALISTDUPLICATEFILTER_CONTRACTID
const ADDTOLIBRARY_MENU_ID
const ADDTOLIBRARY_MENU_TYPE
sbOSDControlService prototype QueryInterface
sbDownloadDeviceServicePaneModule prototype shutdown
const ADDTOLIBRARY_MENU_KEYCODE
_collectFormDataForFrame aDocument
function addToLibraryHelper()
const ADDTOLIBRARY_COMMAND_ID
const ADDTOLIBRARY_MENU_TOOLTIP
const ADDTOLIBRARY_MENU_KEY
var SBPlaylistCommand_AddToLibrary
const ADDTOLIBRARY_MENU_MODIFIERS
_getSelectedPageStyle s i
const ADDTOLIBRARY_MENU_NAME