1
/* ***** BEGIN LICENSE BLOCK *****
2
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
* The contents of this file are subject to the Mozilla Public
5
* License Version 1.1 (the "MPL"); you may not use this file
6
* except in compliance with the MPL. You may obtain a copy of
7
* the MPL at http://www.mozilla.org/MPL/
9
* Software distributed under the MPL is distributed on an "AS
10
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11
* implied. See the MPL for the specific language governing
12
* rights and limitations under the MPL.
14
* The Original Code is Enigmail.
16
* The Initial Developer of the Original Code is Patrick Brunschwig.
17
* Portions created by Patrick Brunschwig <patrick@mozilla-enigmail.org> are
18
* Copyright (C) 2005 Patrick Brunschwig. All Rights Reserved.
22
* Alternatively, the contents of this file may be used under the terms of
23
* either the GNU General Public License Version 2 or later (the "GPL"), or
24
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
25
* in which case the provisions of the GPL or the LGPL are applicable instead
26
* of those above. If you wish to allow use of your version of this file only
27
* under the terms of either the GPL or the LGPL, and not to allow others to
28
* use your version of this file under the terms of the MPL, indicate your
29
* decision by deleting the provisions above and replace them with the notice
30
* and other provisions required by the GPL or the LGPL. If you do not delete
31
* the provisions above, a recipient may use your version of this file under
32
* the terms of any one of the MPL, the GPL or the LGPL.
33
* ***** END LICENSE BLOCK ***** */
35
// Uses: chrome://enigmail/content/enigmailCommon.js
37
Components.utils.import("resource://enigmail/enigmailCommon.jsm");
39
const Ec = EnigmailCommon;
41
var msgCompDeliverMode = Components.interfaces.nsIMsgCompDeliverMode;
43
// dialog is just an array we'll use to store various properties from the dialog document...
46
// the msgProgress is a nsIMsgProgress object
47
var msgProgress = null;
49
// random global variables...
51
var itsASaveOperation = false;
53
var gEnigCallbackFunc = null;
56
// all progress notifications are done through the nsIWebProgressListener implementation...
57
var progressListener = {
58
onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus)
60
if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_START)
62
// dialog.progress.setAttribute( "value", 0 );
63
// Put progress meter in undetermined mode.
64
dialog.progress.setAttribute( "mode", "undetermined" );
67
if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP)
69
// we are done transmitting
70
// Indicate completion in status area.
72
// Put progress meter at 100%.
73
dialog.progress.setAttribute( "value", 100 );
74
dialog.progress.setAttribute( "mode", "normal" );
76
if (msgProgress.processCanceledByUser)
83
onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
87
onLocationChange: function(aWebProgress, aRequest, aLocation)
89
// we can ignore this notification
92
onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage)
94
// we can ignore this notification
97
onSecurityChange: function(aWebProgress, aRequest, state)
99
// we can ignore this notification
102
QueryInterface : function(iid)
104
if (iid.equals(Components.interfaces.nsIWebProgressListener) ||
105
iid.equals(Components.interfaces.nsISupportsWeakReference) ||
106
iid.equals(Components.interfaces.nsISupports))
109
throw Components.results.NS_NOINTERFACE;
115
// Set global variables.
116
var inArg = window.arguments[0];
117
window.arguments[1].result=false;
120
dialog.strings = new Array;
121
dialog.progress = document.getElementById("dialog.progress");
123
var enigmailSvc = GetEnigmailSvc();
127
// Set up dialog button callbacks.
129
doSetOKCancel("", function () { return object.onCancel();});
132
var statTxt=document.getElementById("dialog.status2");
133
if (inArg.accessType == nsIEnigmail.UPLOAD_KEY) {
134
statTxt.value=Ec.getString("keyserverProgress.uploading");
135
subject = Ec.getString("keyserverTitle.uploading");
138
statTxt.value=Ec.getString("keyserverProgress.refreshing");
139
var subject = Ec.getString("keyserverTitle.refreshing");
142
msgProgress = Components.classes["@mozilla.org/messenger/progress;1"].createInstance(Components.interfaces.nsIMsgProgress);
145
onStopRequest: function (exitCode) {
146
processEnd(msgProgress, exitCode);
148
onStdoutData: function(data) {
150
onErrorData: function(data) {
155
msgProgress.registerListener(progressListener);
156
msgProgress.onStateChange(null, null, Components.interfaces.nsIWebProgressListener.STATE_START, 0)
157
gEnigCallbackFunc = inArg.cbFunc;
160
gProcess = Ec.receiveKey(inArg.accessType, inArg.keyServer, inArg.keyList, procListener, errorMsgObj);
161
if (gProcess == null) {
162
EnigAlert(Ec.getString("sendKeysFailed")+"\n"+EnigConvertGpgToUnicode(errorMsgObj.value));
165
window.title = subject;
174
msgProgress.unregisterListener(progressListener);
178
catch( exception ) {}
182
// If the user presses cancel, tell the app launcher and close the dialog...
188
msgProgress.processCanceledByUser = true;
190
catch( ex ) {return true;}
192
// don't Close up dialog by returning false, the backend will close the dialog when everything will be aborted.
196
function processEnd (progressBar, exitCode) {
197
Ec.DEBUG_LOG("enigmailRetrieveProgress.js: processEnd\n");
201
Ec.DEBUG_LOG("enigmailRetrieveProgress.js: processEnd: exitCode = "+exitCode+"\n");
203
var statusText=gEnigCallbackFunc(exitCode, "", false);
207
if (gErrorData.length > 0) {
208
var statusFlagsObj=new Object();
209
var statusMsgObj=new Object();
210
errorMsg=Ec.parseErrorOutput(gErrorData, statusFlagsObj, statusMsgObj);
214
Ec.DEBUG_LOG("enigmailRetrieveProgress.js: processEnd: errorMsg="+errorMsg);
215
if (errorMsg.search(/ec=\d+/i)>=0) {
218
statusText=gEnigCallbackFunc(exitCode, "", false);
219
gEnigCallbackFunc(exitCode, errorMsg, true);
221
window.arguments[1].result=true;
227
progressBar.onStateChange(null, null, Components.interfaces.nsIWebProgressListener.STATE_STOP, 0);
233
function enigSendKeyCancel() {
236
gEnigCallbackFunc=null;