importLibrary.js
Go to the documentation of this file.
1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 :miv */
3 /*
4 //
5 // BEGIN SONGBIRD GPL
6 //
7 // This file is part of the Songbird web player.
8 //
9 // Copyright(c) 2005-2008 POTI, Inc.
10 // http://songbirdnest.com
11 //
12 // This file may be licensed under the terms of of the
13 // GNU General Public License Version 2 (the "GPL").
14 //
15 // Software distributed under the License is distributed
16 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
17 // express or implied. See the GPL for the specific language
18 // governing rights and limitations.
19 //
20 // You should have received a copy of the GPL along with this
21 // program. If not, go to http://www.gnu.org/licenses/gpl.html
22 // or write to the Free Software Foundation, Inc.,
23 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 // END SONGBIRD GPL
26 //
27  */
28 
34 //------------------------------------------------------------------------------
35 //------------------------------------------------------------------------------
36 //
37 // Import library dialog.
38 //
39 //------------------------------------------------------------------------------
40 //------------------------------------------------------------------------------
41 
42 //------------------------------------------------------------------------------
43 //
44 // Import library dialog imported services.
45 //
46 //------------------------------------------------------------------------------
47 
48 // Songbird imports.
49 Components.utils.import("resource://app/jsmodules/StringUtils.jsm");
50 
51 
52 //------------------------------------------------------------------------------
53 //
54 // Import library dialog defs.
55 //
56 //------------------------------------------------------------------------------
57 
58 // Component manager defs.
59 if (typeof(Cc) == "undefined")
60  var Cc = Components.classes;
61 if (typeof(Ci) == "undefined")
62  var Ci = Components.interfaces;
63 if (typeof(Cr) == "undefined")
64  var Cr = Components.results;
65 if (typeof(Cu) == "undefined")
66  var Cu = Components.utils;
67 
68 
69 //------------------------------------------------------------------------------
70 //
71 // Import library dialog services.
72 //
73 //------------------------------------------------------------------------------
74 
75 var importLibrary = {
76  //
77  // Import library dialog services fields.
78  //
79  // _dialogPB Dialog box parameter block.
80  // _importType Type of import to perform.
81  // "first_run" Import run for the first time.
82  // "manual" Import manually initiated by user.
83  // "manual_first_import" First import manual initiated by user.
84  // "changed" Import intitiated due to change in library.
85  // "error" Import re-run after error.
86  //
87 
88  _dialogPB: null,
89  _importType: null,
90 
91 
92  //----------------------------------------------------------------------------
93  //
94  // Event handling services.
95  //
96  //----------------------------------------------------------------------------
97 
102  doLoad: function importLibrary_doLoad() {
103  // Get the dialog box parameters.
104  this._dialogPB = window.arguments[0].QueryInterface(Ci.nsIDialogParamBlock);
105  this._importType = this._dialogPB.GetString(0);
106 
107  // Default to not doing import.
108  this._dialogPB.SetString(0, "false");
109 
110  // Get the library importer.
111  var libraryImporterManager =
112  Cc["@songbirdnest.com/Songbird/LibraryImporterManager;1"]
113  .getService(Ci.sbILibraryImporterManager);
114  var libraryImporter = libraryImporterManager.defaultLibraryImporter;
115  if (!libraryImporter) {
116  onExit();
117  return;
118  }
119 
120  // Check if this is the first manual import.
121  if ((this._importType == "manual") &&
122  !libraryImporter.libraryPreviouslyImported) {
123  this._importType = "manual_first_import";
124  }
125 
126  // Set the user query text.
127  //XXXeps don't hardcode iTunes
128  //XXXeps set query based on dialog params
129  var queryDescElem = document.getElementById("import_library_query");
130  var userQuery = SBBrandedFormattedString
131  ("import_library.dialog_query." + this._importType,
132  [ "iTunes" ]);
133  var userQueryNode = document.createTextNode(userQuery);
134  queryDescElem.appendChild(userQueryNode);
135 
136  // Initialize the import library preferences UI.
137  importLibraryPrefsUI.initialize();
138 
139  // Read the import library preferences.
140  importLibraryPrefsUI.readPrefs();
141  },
142 
143 
148  doAccept: function importLibrary_doAccept() {
149  // Write the import library preferences.
150  importLibraryPrefsUI.writePrefs();
151 
152  // Indicate that importing should be done.
153  this._dialogPB.SetString(0, "true");
154 
155  return true;
156  }
157 }
158 
const Cu
function onExit(skipSave)
onExit handler, saves window size and position before closing the window.
Definition: windowUtils.js:355
const Cc
function doLoad()
function SBBrandedFormattedString(aKey, aParams, aDefault, aStringBundle)
let window
return null
Definition: FeedWriter.js:1143
const Cr
const Ci