6 if (typeof playlistfolders ==
'undefined') {
7 var playlistfolders = {};
16 playlistfolders.servicepane={
20 _ensureDND:
function(n){
21 var dndacc = n.dndAcceptNear.split(
",");
23 for each (var e
in dndacc)
24 if (e ==
"application/x-pf-transfer-folder")
27 dndacc.push(
"application/x-pf-transfer-folder");
28 n.dndAcceptNear = dndacc.join(
",");
30 if (n.id.split(
"urn:item:").length > 1)
31 this._ensureAvailable(n.id.split(
"urn:item:")[1]);
38 _ensureAvailable:
function(guid){
40 var folders = playlistfolders.preferences.getFolders();
41 for each (var f
in folders)
42 for each (var e
in f.content)
46 playlistfolders.preferences.getFolderByGUID(
"{root}").content.push(guid);
52 var
Cr = Components.manager.QueryInterface(Components.interfaces.
53 nsIComponentRegistrar);
54 if (!Cr.isContractIDRegistered(
"@rsjtdrjgfuzkfg.com/servicepane/" +
56 playlistfolders.central.logEvent(
"servicepane",
57 "Register Service Pane Module.", 4);
58 var emgr = Components.classes[
'@mozilla.org/extensions/manager;1'].
60 var moduleFile = emgr.getInstallLocation(
"playlistfolders@" +
61 "rsjtdrjgfuzkfg.com").
62 getItemLocation(
"playlistfolders@" +
63 "rsjtdrjgfuzkfg.com");
64 moduleFile.append(
"components");
65 moduleFile.append(
"pfServicePane.js");
66 Cr.autoRegister(moduleFile);
69 var SPS =
Cc[
"@songbirdnest.com/servicepane/service;1"].
71 var nodes = SPS.getNode(
"SB:Playlists").childNodes;
72 while (nodes.hasMoreElements()){
73 this._ensureDND(nodes.getNext());
81 _getFolderNode:
function(folder){
82 var SPS =
Cc[
"@songbirdnest.com/servicepane/service;1"].
84 var dtSP_NS =
'http://songbirdnest.com/rdf/servicepane#';
85 var
node = SPS.getNode(
"urn:folder:" + folder.GUID);
87 node = SPS.createNode();
88 node.id =
"urn:folder:" + folder.GUID;
89 node.url =
"chrome://playlistfolders/content/folder.xul?guid=" +
91 node.name = folder.name;
92 node.contractid =
"@rsjtdrjgfuzkfg.com/servicepane/folders;1";
94 node.setAttributeNS(dtSP_NS,
"addonID",
95 "playlistfolders@rsjtdrjgfuzkfg.com");
97 node.setAttribute(
"isOpen",
"false");
98 node.image =
"chrome://playlistfolders/skin/" +
99 "icon-folder-closed.png";
101 node.image =
"chrome://playlistfolders/skin/icon-folder.png";
103 node.className =
"playlistfolder";
105 playlistfolders.central.logEvent(
"servicepane",
"Node urn:folder:" +
106 folder.GUID +
" exists already, " +
107 "won't create a new one.", 3,
108 "chrome://playlistfolders/content" +
115 playlistfolders.central.logEvent(
"servicepane",
116 "Service Pane initialisation started", 5);
121 var SPS =
Cc[
"@songbirdnest.com/servicepane/service;1"].
125 var fillFolder =
function (
node, folder){
126 for each (var e
in folder.content){
128 if (playlistfolders.preferences.isFolder(e)){
129 var f = playlistfolders.preferences.getFolderByGUID(e);
130 snode = playlistfolders.servicepane._getFolderNode(f);
131 fillFolder(snode, f);
132 }
else if (playlistfolders.preferences.isPlaylist(e)){
133 snode = SPS.getNode(
"urn:item:" + e);
136 node.appendChild(snode);
139 var rootFolder = playlistfolders.preferences.getFolderByGUID(
"{root}");
140 fillFolder(SPS.getNode(
"SB:Playlists"), rootFolder);
142 SPS.getNode(
"SB:Playlists").addMutationListener(
this);
144 playlistfolders.central.logEvent(
"servicepane",
"Service Pane " +
145 "controller started.", 4);
147 playlistfolders.central.logEvent(
"servicepane",
"Startup of Service " +
148 "Pane controller failed:\n\n" + e, 1,
149 "chrome://playlistfolders/content/" +
150 "servicepane.js", e.lineNumber);
156 playlistfolders.central.logEvent(
"servicepane",
"Servicepane controller " +
157 "shutdown started.", 5);
159 var SPS =
Cc[
"@songbirdnest.com/servicepane/service;1"].
161 SPS.getNode(
"SB:Playlists").removeMutationListener(
this);
163 playlistfolders.central.logEvent(
"servicepane",
164 "Servicepane controller stopped.", 4);
168 newFolder:
function(){
169 playlistfolders.central.logEvent(
"servicepane",
"Create new Folder", 5);
171 var bstrings = document.getElementById(
"playlistfolders-bookmark-strings");
172 var fname = bstrings.getString(
"newFolderDefault");
173 var folder = playlistfolders.preferences.createFolder(fname);
174 var
node = this._getFolderNode(folder);
176 var SPS =
Cc[
"@songbirdnest.com/servicepane/service;1"]
177 .getService(
Ci.sbIServicePaneService);
179 var nodes = SPS.getNode(
"SB:Playlists").childNodes;
180 while (nodes.hasMoreElements()){
181 var n = nodes.getNext();
182 if ((!fPlist) && n.id && (n.id.split(
"urn:item:").length > 1))
185 SPS.getNode(
"SB:Playlists").insertBefore(node, fPlist);
193 deleteFolder:
function(
id){
194 playlistfolders.central.logEvent(
"servicepane",
"Delete Folder with " +
197 var GUID =
id.split(
'urn:folder:')[1];
198 var folder = playlistfolders.preferences.getFolderByGUID(GUID);
201 if (!playlistfolders.preferences.isDeleteBypass()) {
203 .getService(
Ci.nsIPromptService);
206 var sbs =
Cc[
"@mozilla.org/intl/stringbundle;1"]
207 .getService(
Ci.nsIStringBundleService);
209 var songbirdStrings = sbs.createBundle(
"chrome://songbird/locale/" +
210 "songbird.properties");
211 var pfoldersStrings = sbs.createBundle(
"chrome://playlistfolders/locale/" +
212 "playlistfolders.properties");
213 var strTitle = pfoldersStrings.GetStringFromName(
"delete.title");
214 var strMsg = pfoldersStrings.formatStringFromName(
"delete.msg",
217 var strCheck =
SBString(
"playlist.deletewarning.check");
219 var r = promptService.confirmEx(
window,
222 Ci.nsIPromptService.STD_YES_NO_BUTTONS,
228 if (check.value ==
true) {
229 playlistfolders.preferences.doDeleteBypass()
237 if (playlistfolders.preferences.removeFolder(folder,
true))
238 document.getElementById(
id).parentNode.
247 playlistfolders.central.logEvent(
"servicepane",
"Rename Folder with " +
248 "Node " +
node.id +
" to " +
name, 5);
250 var GUID =
node.id.split(
'urn:folder:')[1];
251 var folder = playlistfolders.preferences.getFolderByGUID(GUID);
253 playlistfolders.preferences.renameFolder(folder,
name);
262 moveFolder:
function(
node, targetFolder, insertBefore){
263 playlistfolders.central.logEvent(
"servicepane",
"Move Folder with " +
264 "Node " +
node +
" to " +
265 targetFolder.id +
", before " +
266 (insertBefore ? insertBefore.id :
""), 5);
268 var SPS =
Cc[
"@songbirdnest.com/servicepane/service;1"]
269 .getService(
Ci.sbIServicePaneService);
270 targetFolder.insertBefore(SPS.getNode(
node), insertBefore);
278 movePlaylist:
function(pguid, targetFolder, insertBefore){
279 playlistfolders.central.logEvent(
"servicepane",
"Move Playlist " +
281 targetFolder.id +
", before " +
282 (insertBefore ? insertBefore.id :
""), 5);
284 var SPS =
Cc[
"@songbirdnest.com/servicepane/service;1"]
285 .getService(
Ci.sbIServicePaneService);
286 targetFolder.insertBefore(SPS.getNode(
'urn:item:' + pguid), insertBefore);
293 attrModified:
function(aNode, aAttrName, aNamespace, aOldVal, aNewVal){
295 if ((aNode.id.split(
"urn:folder").length > 1)&&(aAttrName ==
"isOpen")){
296 playlistfolders.central.logEvent(
"servicepane",
297 "Open/Closes State change: " +
299 var guid = aNode.id.split(
'urn:folder:')[1];
300 var folder = playlistfolders.preferences.getFolderByGUID(guid);
301 folder.closed = aNewVal ==
"false";
302 aNode.image = folder.closed ?
"chrome://playlistfolders/skin/" +
303 "icon-folder-closed.png"
304 :
"chrome://playlistfolders/skin/" +
310 if ((aNode.id.split(
"urn:item:").length > 1)){
311 playlistfolders.central.logEvent(
"servicepane",
312 "Moved Playlist node " + aNode.id, 5);
314 this._ensureDND(aNode);
316 var pguid = aNode.id.split(
"urn:item:")[1];
318 if (aParent.id !=
"SB:Playlists"){
319 var tGUID = aParent.id.split(
'urn:folder:')[1];
320 tfolder = playlistfolders.preferences.getFolderByGUID(tGUID);
323 if (aInsertBefores && (aInsertBefores.id.split(
'urn:item:').length > 1))
324 bGUID = aInsertBefores.id.split(
'urn:item:')[1];
325 if (aInsertBefores && (aInsertBefores.id.split(
'urn:folder:').length > 1))
326 bGUID = aInsertBefores.id.split(
'urn:folder:')[1];
327 playlistfolders.preferences.movePlaylist(pguid, tfolder, bGUID);
330 if ((aNode.id.split(
"urn:folder:").length > 1)){
331 playlistfolders.central.logEvent(
"servicepane",
332 "Moved Folder node " + aNode.id, 5);
334 var fguid = aNode.id.split(
"urn:folder:")[1];
336 if (aParent.id !=
"SB:Playlists"){
337 var tGUID = aParent.id.split(
'urn:folder:')[1];
338 tfolder = playlistfolders.preferences.getFolderByGUID(tGUID);
341 if (aInsertBefores && (aInsertBefores.id.split(
'urn:item:').length > 1))
342 bGUID = aInsertBefores.id.split(
'urn:item:')[1];
343 if (aInsertBefores && (aInsertBefores.id.split(
'urn:folder:').length > 1))
344 bGUID = aInsertBefores.id.split(
'urn:folder:')[1];
345 var folder = playlistfolders.preferences.getFolderByGUID(fguid);
347 playlistfolders.preferences.moveFolder(folder, tfolder, bGUID);
352 if (aNode.id.split(
"urn:item:").length <= 1)
355 if (aParent.id.split(
"urn:folder:").length <= 1)
358 var pGUID = aNode.id.split(
"urn:item:")[1];
359 var fGUID = aParent.id.split(
"urn:folder:")[1];
360 playlistfolders.preferences.removePlaylist(pGUID, fGUID);
getService(Ci.sbIFaceplateManager)
function SBString(aKey, aDefault, aStringBundle)
imageContainer removeChild(oldImage)
function onUnload()
onUnload - called when the cover preview window unloads.
sbDeviceServicePane prototype nodeInserted
sbDeviceServicePane prototype nodeRemoved