~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

Viewing changes to extensions/enigmail/ui/content/enigRetrieveProgress.js

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ***** BEGIN LICENSE BLOCK *****
2
 
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
 
 *
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/
8
 
 *
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.
13
 
 *
14
 
 * The Original Code is Enigmail.
15
 
 *
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.
19
 
 *
20
 
 * Contributor(s):
21
 
 *
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 ***** */
34
 
 
35
 
// Uses: chrome://enigmail/content/enigmailCommon.js
36
 
 
37
 
Components.utils.import("resource://enigmail/enigmailCommon.jsm");
38
 
 
39
 
const Ec = EnigmailCommon;
40
 
 
41
 
var msgCompDeliverMode = Components.interfaces.nsIMsgCompDeliverMode;
42
 
 
43
 
// dialog is just an array we'll use to store various properties from the dialog document...
44
 
var dialog;
45
 
 
46
 
// the msgProgress is a nsIMsgProgress object
47
 
var msgProgress = null;
48
 
 
49
 
// random global variables...
50
 
var targetFile;
51
 
var itsASaveOperation = false;
52
 
var gProcess = null;
53
 
var gEnigCallbackFunc = null;
54
 
var gErrorData = '';
55
 
 
56
 
// all progress notifications are done through the nsIWebProgressListener implementation...
57
 
var progressListener = {
58
 
  onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus)
59
 
  {
60
 
    if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_START)
61
 
    {
62
 
      // dialog.progress.setAttribute( "value", 0 );
63
 
      // Put progress meter in undetermined mode.
64
 
      dialog.progress.setAttribute( "mode", "undetermined" );
65
 
    }
66
 
 
67
 
    if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP)
68
 
    {
69
 
      // we are done transmitting
70
 
      // Indicate completion in status area.
71
 
 
72
 
      // Put progress meter at 100%.
73
 
      dialog.progress.setAttribute( "value", 100 );
74
 
      dialog.progress.setAttribute( "mode", "normal" );
75
 
 
76
 
      if (msgProgress.processCanceledByUser)
77
 
        enigSendKeyCancel();
78
 
 
79
 
      window.close();
80
 
    }
81
 
  },
82
 
 
83
 
  onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
84
 
  {
85
 
  },
86
 
 
87
 
  onLocationChange: function(aWebProgress, aRequest, aLocation)
88
 
  {
89
 
    // we can ignore this notification
90
 
  },
91
 
 
92
 
  onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage)
93
 
  {
94
 
    // we can ignore this notification
95
 
  },
96
 
 
97
 
  onSecurityChange: function(aWebProgress, aRequest, state)
98
 
  {
99
 
    // we can ignore this notification
100
 
  },
101
 
 
102
 
  QueryInterface : function(iid)
103
 
  {
104
 
    if (iid.equals(Components.interfaces.nsIWebProgressListener) ||
105
 
        iid.equals(Components.interfaces.nsISupportsWeakReference) ||
106
 
        iid.equals(Components.interfaces.nsISupports))
107
 
      return this;
108
 
 
109
 
    throw Components.results.NS_NOINTERFACE;
110
 
  }
111
 
};
112
 
 
113
 
 
114
 
function onLoad() {
115
 
  // Set global variables.
116
 
  var inArg = window.arguments[0];
117
 
  window.arguments[1].result=false;
118
 
 
119
 
  dialog = new Object;
120
 
  dialog.strings = new Array;
121
 
  dialog.progress    = document.getElementById("dialog.progress");
122
 
 
123
 
  var enigmailSvc = GetEnigmailSvc();
124
 
  if (!enigmailSvc)
125
 
    return;
126
 
 
127
 
  // Set up dialog button callbacks.
128
 
  var object = this;
129
 
  doSetOKCancel("", function () { return object.onCancel();});
130
 
 
131
 
 
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");
136
 
  }
137
 
  else {
138
 
    statTxt.value=Ec.getString("keyserverProgress.refreshing");
139
 
    var subject = Ec.getString("keyserverTitle.refreshing");
140
 
  }
141
 
 
142
 
  msgProgress = Components.classes["@mozilla.org/messenger/progress;1"].createInstance(Components.interfaces.nsIMsgProgress);
143
 
 
144
 
  var procListener = {
145
 
    onStopRequest: function (exitCode) {
146
 
      processEnd(msgProgress, exitCode);
147
 
    },
148
 
    onStdoutData: function(data) {
149
 
    },
150
 
    onErrorData: function(data) {
151
 
      gErrorData += data;
152
 
    }
153
 
  }
154
 
 
155
 
  msgProgress.registerListener(progressListener);
156
 
  msgProgress.onStateChange(null, null, Components.interfaces.nsIWebProgressListener.STATE_START, 0)
157
 
  gEnigCallbackFunc = inArg.cbFunc;
158
 
 
159
 
  var errorMsgObj={};
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));
163
 
  }
164
 
 
165
 
  window.title = subject;
166
 
}
167
 
 
168
 
function onUnload()
169
 
{
170
 
  if (msgProgress)
171
 
  {
172
 
   try
173
 
   {
174
 
     msgProgress.unregisterListener(progressListener);
175
 
     msgProgress = null;
176
 
   }
177
 
 
178
 
   catch( exception ) {}
179
 
  }
180
 
}
181
 
 
182
 
// If the user presses cancel, tell the app launcher and close the dialog...
183
 
function onCancel ()
184
 
{
185
 
 
186
 
  try
187
 
  {
188
 
    msgProgress.processCanceledByUser = true;
189
 
  }
190
 
  catch( ex ) {return true;}
191
 
 
192
 
  // don't Close up dialog by returning false, the backend will close the dialog when everything will be aborted.
193
 
  return false;
194
 
}
195
 
 
196
 
function processEnd (progressBar, exitCode) {
197
 
  Ec.DEBUG_LOG("enigmailRetrieveProgress.js: processEnd\n");
198
 
 
199
 
  if (gProcess) {
200
 
    gProcess = null;
201
 
    Ec.DEBUG_LOG("enigmailRetrieveProgress.js: processEnd: exitCode = "+exitCode+"\n");
202
 
 
203
 
    var statusText=gEnigCallbackFunc(exitCode, "", false);
204
 
 
205
 
    var errorMsg="";
206
 
    try {
207
 
      if (gErrorData.length > 0) {
208
 
        var statusFlagsObj=new Object();
209
 
        var statusMsgObj=new Object();
210
 
        errorMsg=Ec.parseErrorOutput(gErrorData, statusFlagsObj, statusMsgObj);
211
 
      }
212
 
    } catch (ex) {}
213
 
 
214
 
    Ec.DEBUG_LOG("enigmailRetrieveProgress.js: processEnd: errorMsg="+errorMsg);
215
 
    if (errorMsg.search(/ec=\d+/i)>=0) {
216
 
      exitCode=-1;
217
 
    }
218
 
    statusText=gEnigCallbackFunc(exitCode, "", false);
219
 
    gEnigCallbackFunc(exitCode, errorMsg, true);
220
 
    if (exitCode == 0) {
221
 
      window.arguments[1].result=true;
222
 
    }
223
 
  }
224
 
 
225
 
  if (progressBar) {
226
 
    try {
227
 
      progressBar.onStateChange(null, null, Components.interfaces.nsIWebProgressListener.STATE_STOP, 0);
228
 
    }
229
 
    catch (ex) {}
230
 
  }
231
 
}
232
 
 
233
 
function enigSendKeyCancel() {
234
 
  if (gProcess) {
235
 
    var p = gProcess;
236
 
    gEnigCallbackFunc=null;
237
 
    gProcess=null;
238
 
    p.kill(false);
239
 
  }
240
 
}