27 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
28 Components.utils.import(
"resource://app/jsmodules/ArrayConverter.jsm");
43 "songbird.library_importexport.autoshutdown";
45 "songbird.library_importexport.autostartup";
47 "songbird.library_exporter.export_tracks";
49 "songbird.library_exporter.export_playlists";
51 "songbird.library_exporter.export_smartplaylists";
53 "songbird.library_exporter.start_agent"
55 var AppPrefs =
Cc[
"@mozilla.org/fuel/application;1"]
56 .getService(
Ci.fuelIApplication).prefs;
63 fileClone.append(aFileName);
70 var taskFileFolder =
Cc[
"@mozilla.org/file/directory_service;1"]
71 .getService(
Ci.nsIProperties)
72 .get(
"AppRegD",
Ci.nsIFile);
74 var entries = taskFileFolder.directoryEntries;
75 while (entries.hasMoreElements()) {
76 var curFile = entries.getNext().QueryInterface(
Ci.nsIFile);
78 if (curFile.leafName.indexOf(TASKFILE_NAME) > -1) {
79 curFile.remove(
false);
86 var dataFile =
Cc[
"@mozilla.org/file/directory_service;1"]
87 .getService(
Ci.nsIProperties)
88 .get(
"AppRegD",
Ci.nsIFile);
89 dataFile.append(TASKFILE_NAME);
95 var stream =
Cc[
"@mozilla.org/network/file-input-stream;1"]
96 .createInstance(
Ci.nsIFileInputStream);
97 stream.init(aFile, 0x1, 0, 0);
98 stream.QueryInterface(
Ci.nsILineInputStream);
110 AppPrefs.setValue(PREF_EXPORT_TRACKS,
false);
111 AppPrefs.setValue(PREF_EXPORT_PLAYLISTS,
false);
112 AppPrefs.setValue(PREF_EXPORT_SMARTPLAYLISTS,
false);
113 AppPrefs.setValue(PREF_EXPORT_STARTAGENT,
false);
121 AppPrefs.setValue(PREF_EXPORT_TRACKS,
true);
122 AppPrefs.setValue(PREF_EXPORT_PLAYLISTS,
false);
123 AppPrefs.setValue(PREF_EXPORT_SMARTPLAYLISTS,
false);
124 AppPrefs.setValue(PREF_EXPORT_STARTAGENT,
false);
132 AppPrefs.setValue(PREF_EXPORT_TRACKS,
true);
133 AppPrefs.setValue(PREF_EXPORT_PLAYLISTS,
true);
134 AppPrefs.setValue(PREF_EXPORT_SMARTPLAYLISTS,
false);
135 AppPrefs.setValue(PREF_EXPORT_STARTAGENT,
false);
143 AppPrefs.setValue(PREF_EXPORT_TRACKS,
true);
144 AppPrefs.setValue(PREF_EXPORT_PLAYLISTS,
true);
145 AppPrefs.setValue(PREF_EXPORT_SMARTPLAYLISTS,
true);
146 AppPrefs.setValue(PREF_EXPORT_STARTAGENT,
false);
157 this._dataFile = aDataFile;
158 this._addedMediaLists = [];
159 this._removedMediaLists = [];
160 this._addedMediaItems = {};
161 this._curMediaListName =
"";
162 this._curParseMode = -1;
165 this._parseDataFile();
171 getAddedMediaLists:
function() {
172 return this._addedMediaLists;
174 getRemovedMediaLists:
function() {
175 return this._removedMediaLists;
177 getAddedMediaItems:
function() {
178 return this._addedMediaItems;
182 _STATE_MODE_ADDEDMEDIALISTS : 1,
183 _STATE_MODE_REMOVEDMEDIALISTS : 2,
184 _STATE_MODE_ADDEDMEDIAITEMS : 3,
186 _parseDataFile:
function() {
191 var hasSchema =
false;
196 hasMore = inputStream.readLine(curLine);
197 dump(curLine.value +
"\n");
199 if (curLine.value ==
"") {
203 else if ((result = /^\[(.*?)(?::(.*))?\]$/(curLine.value))) {
207 case TASKFILE_SCHEMAVERSION_HEADER:
209 "schema version mismatch");
212 case TASKFILE_ADDEDMEDIALISTS_HEADER:
214 "unexpected junk in add media lists header");
215 this._curParseMode = this._STATE_MODE_ADDEDMEDIALISTS;
217 case TASKFILE_REMOVEDMEDIALISTS_HEADER:
219 "unexpected junk in remove media lists header");
220 this._curParseMode = this._STATE_MODE_REMOVEDMEDIALISTS;
222 case TASKFILE_ADDEDMEDIAITEMS_HEADER:
223 this._curParseMode = this._STATE_MODE_ADDEDMEDIAITEMS;
226 this._curMediaListName = decodeURIComponent(result[2]);
229 doFail(
'Unexpected section header "' + escape(result[1]) +
'"');
232 else if ((result = /^(\
d+)=(.*)$/(curLine.value))) {
234 assertEqual(result[1], nextItem,
"items out of order");
237 var curValue = decodeURIComponent(result[2]);
238 switch (this._curParseMode) {
239 case this._STATE_MODE_ADDEDMEDIALISTS:
240 this._addedMediaLists.push(curValue);
243 case this._STATE_MODE_REMOVEDMEDIALISTS:
244 this._removedMediaLists.push(curValue);
248 doFail(
"Unexpected state " + this._curParseMode);
251 else if ((result = /^([0-9a-f-]{36})=(.*)$/(curLine.value))) {
254 var curValue = decodeURIComponent(result[2]);
255 switch (this._curParseMode) {
256 case this._STATE_MODE_ADDEDMEDIAITEMS:
257 if (!this._addedMediaItems[this._curMediaListName]) {
258 this._addedMediaItems[this._curMediaListName] = [];
260 this._addedMediaItems[this._curMediaListName].push(curValue);
264 doFail(
"Unexpected state " + this._curParseMode);
268 doFail(
"Unexpected line " + curLine.value);
272 assertTrue(hasSchema,
"No schema version information found");
function assertNotEqual(aExpected, aActual, aMessage)
function assertTrue(aTest, aMessage)
function assertEqual(aExpected, aActual, aMessage)
function newFileURI(file)
StringArrayEnumerator prototype hasMore