waitForCompletion.js
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25  */
26 
27 
28 /* wait for completion global object */
29 
31 gWaitForCompletion.mDeviceManager = null;
32 gWaitForCompletion.mDevices = [];
33 
34 /* window load event handler */
35 gWaitForCompletion.onLoad = function()
36 {
37  /* Get the dialog element. */
38  var dialog = document.getElementById("dialog");
39 
40  /* Hide the cancel button. */
41  var cancelButton = document.getAnonymousElementByAttribute(dialog, "dlgtype",
42  "cancel");
43  cancelButton.setAttribute("hidden", "true");
44 
45  /* get the device manager */
46  this.mDeviceManager =
47  Components.classes['@songbirdnest.com/Songbird/DeviceManager;2']
48  .getService(Components.interfaces.sbIDeviceManager2);
49 
50  /* listen to all device events */
51  this.mDeviceManager.addEventListener(this);
52 }
53 
54 /* window unload event handler */
55 gWaitForCompletion.onUnload = function()
56 {
57  // remove ourselves as a device event listener
58  if (this.mDeviceManager) {
59  this.mDeviceManager.removeEventListener(this);
60  }
61 }
62 
63 /* sbIDeviceEventListener callback */
64 gWaitForCompletion.onDeviceEvent = function(aDeviceEvent)
65 {
66  /* some event occurred. can we disconnect yet? */
67  if (this.mDeviceManager.canDisconnect) {
68  /* close the window */
69  window.close();
70  }
71 }
72 
73 /* just enough nsISupports to make everyone happy */
74 gWaitForCompletion.QueryInterface = function(aInterfaceID)
75 {
76  /* Check for supported interfaces. */
77  if (!aInterfaceID.equals(Components.interfaces.nsISupports) &&
78  !aInterfaceID.equals(Components.interfaces.sbIDeviceEventListener)) {
79  throw(Components.results.NS_ERROR_NO_INTERFACE);
80  }
81 
82  return this;
83 }
var cancelButton
let window
var dialog
Definition: openLocation.js:43
var gWaitForCompletion
gWaitForCompletion mDeviceManager
return null
Definition: FeedWriter.js:1143