1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is Mozilla Communicator client code, released
19 * The Initial Developer of the Original Code is
20 * Netscape Communications Corporation.
21 * Portions created by the Initial Developer are Copyright (C) 1998
22 * the Initial Developer. All Rights Reserved.
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
42 var gCanClose = false;
43 var gCancelled = false;
45 // implements nsIXPIProgressDialog
48 onStateChange: function( aIndex, aState, aValue )
50 const state = Components.interfaces.nsIXPIProgressDialog;
51 var status = document.getElementById("status"+aIndex);
52 var progress = document.getElementById("progress"+aIndex);
55 case state.DOWNLOAD_START:
56 status.setAttribute("value",
57 gBundle.getString("progress.downloading"));
58 progress.setAttribute("value","0%");
61 case state.DOWNLOAD_DONE:
62 status.setAttribute("value",
63 gBundle.getString("progress.downloaded"));
64 progress.setAttribute("value","100%");
67 case state.INSTALL_START:
68 status.setAttribute("value",
69 gBundle.getString("progress.installing"));
70 progress.setAttribute("mode","undetermined");
73 case state.INSTALL_DONE:
74 progress.setAttribute("mode","determined");
75 progress.hidden = true;
79 msg = gBundle.getString("error"+aValue);
83 msg = gBundle.stringBundle.formatStringFromName(
84 "unknown.error", [aValue], 1 );
86 status.setAttribute("value",msg);
89 case state.DIALOG_CLOSE:
90 // nsXPInstallManager is done with us, but we'll let users
91 // dismiss the dialog themselves so they can see the status
92 // (unless we're closing because the user cancelled)
93 document.getElementById("ok").disabled = false;
94 document.getElementById("cancel").disabled = true;
104 onProgress: function( aIndex, aValue, aMaxValue )
106 var percent = Math.round( 100 * (aValue/aMaxValue) );
107 var node = document.getElementById("progress"+aIndex);
108 node.setAttribute("value", percent);
111 QueryInterface: function( iid )
113 if (!iid.equals(Components.interfaces.nsISupports) &&
114 !iid.equals(Components.interfaces.nsIXPIProgressDialog))
115 throw Components.results.NS_ERROR_NO_INTERFACE;
124 doSetOKCancel(dlgOK, dlgCancel);
125 document.getElementById("ok").disabled = true;
126 document.getElementById("cancel").focus();
127 gBundle = document.getElementById("xpinstallBundle");
129 var param = window.arguments[0].QueryInterface(
130 Components.interfaces.nsIDialogParamBlock );
132 dump (" error getting param block interface \n");
136 var numElements = param.GetInt(1);
137 while ( i < numElements )
139 var moduleName = param.GetString(i++);
140 var URL = param.GetString(i++);
141 var certName = param.GetString(i++);
142 addTreeItem(row++, moduleName, URL);
145 gManager = window.arguments[1];
147 // inform nsXPInstallManager we're open for business
148 gManager.observe( progressHooks, "xpinstall-progress", "open" );
151 function addTreeItem(aRow, aName, aUrl)
153 // first column is the package name
154 var item = document.createElement("description");
155 item.setAttribute("class", "packageName");
156 item.setAttribute("id", "package"+aRow);
157 item.setAttribute("value", aName);
158 item.setAttribute("tooltiptext", aUrl);
160 // second column is the status
161 var status = document.createElement('description');
162 status.setAttribute("class", "packageStatus");
163 status.setAttribute("id", "status"+aRow);
164 status.setAttribute("value", gBundle.getString("progress.queued"));
166 // third row is a progress meter
167 var progress = document.createElement("progressmeter");
168 progress.setAttribute("class", "packageProgress");
169 progress.setAttribute("id", "progress"+aRow);
170 progress.setAttribute("value", "0%");
172 // create row and add it to the grid
173 var row = document.createElement("row");
174 row.appendChild(item);
175 row.appendChild(status);
176 row.appendChild(progress);
177 document.getElementById("xpirows").appendChild(row);
180 function dlgOK() { return true; }
186 gManager.observe( progressHooks, "xpinstall-progress", "cancel");
188 // window is closed by native impl after cleanup