Page MenuHome GnuPG

No OneTemporary

This file is larger than 256 KB, so syntax highlighting was skipped.
This document is not UTF8. It was detected as ISO-8859-1 (Latin 1) and converted to UTF8 for display.
diff --git a/package/enigmail.js b/package/enigmail.js
index 1769b05a..7bbc7694 100644
--- a/package/enigmail.js
+++ b/package/enigmail.js
@@ -1,5178 +1,5497 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "MPL"); you may not use this file
* except in compliance with the MPL. You may obtain a copy of
* the MPL at http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the MPL for the specific language governing
* rights and limitations under the MPL.
*
* The Original Code is Enigmail.
*
* The Initial Developer of the Original Code is Ramalingam Saravanan.
* Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
* Copyright (C) 2001 Ramalingam Saravanan. All Rights Reserved.
*
* Contributor(s):
* Patrick Brunschwig <patrick.brunschwig@gmx.net>
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License (the "GPL"), in which case
* the provisions of the GPL are applicable instead of
* those above. If you wish to allow use of your version of this
* file only under the terms of the GPL and not to allow
* others to use your version of this file under the MPL, indicate
* your decision by deleting the provisions above and replace them
* with the notice and other provisions required by the GPL.
* If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
// Maximum size of message directly processed by Enigmail
const MSG_BUFFER_SIZE = 98304; // 96 kB
const MAX_MSG_BUFFER_SIZE = 512000 // slightly less than 512 kB
const ERROR_BUFFER_SIZE = 16384; // 16 kB
const PGP_BATCH_OPTS = " +batchmode +force";
const GPG_BATCH_OPTS = " --batch --no-tty --status-fd 2";
const gDummyPKCS7 = 'Content-Type: multipart/mixed;\r\n boundary="------------060503030402050102040303\r\n\r\nThis is a multi-part message in MIME format.\r\n--------------060503030402050102040303\r\nContent-Type: application/x-pkcs7-mime\r\nContent-Transfer-Encoding: 8bit\r\n\r\n\r\n--------------060503030402050102040303\r\nContent-Type: application/x-enigmail-dummy\r\nContent-Transfer-Encoding: 8bit\r\n\r\n\r\n--------------060503030402050102040303--\r\n';
/* Implementations supplied by this module */
const NS_ENIGMAIL_CONTRACTID = "@mozdev.org/enigmail/enigmail;1";
const NS_PGP_MODULE_CONTRACTID = "@mozilla.org/mimecth/pgp;1";
const NS_ENIGMAILPROTOCOLHANDLER_CONTRACTID =
"@mozilla.org/network/protocol;1?name=enigmail";
const NS_ENIGMAIL_CID =
Components.ID("{847b3a01-7ab1-11d4-8f02-006008948af5}");
const NS_ENIGMAILPROTOCOLHANDLER_CID =
Components.ID("{847b3a11-7ab1-11d4-8f02-006008948af5}");
const NS_PGP_MODULE_CID =
Components.ID("{847b3af1-7ab1-11d4-8f02-006008948af5}");
const NS_ENIGMSGCOMPOSE_CID =
Components.ID("{847b3a21-7ab1-11d4-8f02-006008948af5}");
const NS_ENIGMSGCOMPOSEFACTORY_CID =
Components.ID("{847b3a22-7ab1-11d4-8f02-006008948af5}");
const NS_ENIGCLINE_SERVICE_CID =
Components.ID("{847b3ab1-7ab1-11d4-8f02-006008948af5}");
// Contract IDs and CIDs used by this module
const NS_IPCSERVICE_CONTRACTID = "@mozilla.org/process/ipc-service;1";
const NS_IPCBUFFER_CONTRACTID = "@mozilla.org/process/ipc-buffer;1";
const NS_PIPECONSOLE_CONTRACTID = "@mozilla.org/process/pipe-console;1";
const NS_PIPETRANSPORT_CONTRACTID="@mozilla.org/process/pipe-transport;1";
const NS_PROCESSINFO_CONTRACTID = "@mozilla.org/xpcom/process-info;1";
const NS_MSGCOMPOSESECURE_CONTRACTID = "@mozilla.org/messengercompose/composesecure;1";
const NS_ENIGMSGCOMPOSE_CONTRACTID = "@mozilla.org/enigmail/composesecure;1";
const NS_ENIGMSGCOMPOSEFACTORY_CONTRACTID = "@mozilla.org/enigmail/composesecure-factory;1";
const NS_ENIGMIMESERVICE_CONTRACTID = "@mozdev.org/enigmail/enigmimeservice;1";
const NS_SIMPLEURI_CONTRACTID = "@mozilla.org/network/simple-uri;1";
const NS_TIMER_CONTRACTID = "@mozilla.org/timer;1";
const NS_OBSERVERSERVICE_CONTRACTID = "@mozilla.org/observer-service;1";
const NS_PROMPTSERVICE_CONTRACTID = "@mozilla.org/embedcomp/prompt-service;1";
const ASS_CONTRACTID = "@mozilla.org/appshell/appShellService;1";
const WMEDIATOR_CONTRACTID = "@mozilla.org/rdf/datasource;1?name=window-mediator";
const NS_IOSERVICE_CONTRACTID = "@mozilla.org/network/io-service;1";
const NS_ISCRIPTABLEUNICODECONVERTER_CONTRACTID = "@mozilla.org/intl/scriptableunicodeconverter";
const NS_SCRIPTABLEINPUTSTREAM_CONTRACTID = "@mozilla.org/scriptableinputstream;1"
const ENIG_STRINGBUNDLE_CONTRACTID = "@mozilla.org/intl/stringbundle;1";
const NS_PREFS_SERVICE_CID = "@mozilla.org/preferences-service;1";
const NS_DOMPARSER_CONTRACTID = "@mozilla.org/xmlextras/domparser;1";
const NS_DOMSERIALIZER_CONTRACTID = "@mozilla.org/xmlextras/xmlserializer;1";
const NS_CATMAN_CONTRACTID = "@mozilla.org/categorymanager;1";
const NS_CLINE_SERVICE_CONTRACTID = "@mozilla.org/commandlinehandler/general-startup;1?type=pgpkeyman";
// Interfaces
const nsISupports = Components.interfaces.nsISupports;
const nsIObserver = Components.interfaces.nsIObserver;
const nsILocalFile = Components.interfaces.nsILocalFile;
const nsIProtocolHandler = Components.interfaces.nsIProtocolHandler;
const nsIIPCService = Components.interfaces.nsIIPCService;
const nsIPipeConsole = Components.interfaces.nsIPipeConsole;
const nsIProcessInfo = Components.interfaces.nsIProcessInfo;
const nsIEnigmail = Components.interfaces.nsIEnigmail;
//const nsIPGPModule = Components.interfaces.nsIPGPModule;
//const nsIPGPMsgBody = Components.interfaces.nsIPGPMsgBody;
//const nsIPGPMsgHeader = Components.interfaces.nsIPGPMsgHeader;
const nsIEnigStrBundle = Components.interfaces.nsIStringBundleService;
const nsICmdLineHandler = Components.interfaces.nsICmdLineHandler;
const nsICategoryManager = Components.interfaces.nsICategoryManager;
const nsIWindowWatcher = Components.interfaces.nsIWindowWatcher;
const NS_XPCOM_SHUTDOWN_OBSERVER_ID = "xpcom-shutdown";
///////////////////////////////////////////////////////////////////////////////
// Global variables
const GPG_COMMENT_OPT = "Using GnuPG with %s - http://enigmail.mozdev.org";
var gLogLevel = 3; // Output only errors/warnings by default
var gEnigmailSvc = null; // Global Enigmail Service
var gCachedPassphrase = null; // Cached passphrase
var gCacheTimer = null; // Cache timer
var gXULOwner = null; // Global XUL owner
var gEnvList = []; // Global environment list
var gEnigStrBundle; // Global string bundle
// GPG status flags mapping (see doc/DETAILS file in the GnuPG distribution)
var gStatusFlags = {GOODSIG: nsIEnigmail.GOOD_SIGNATURE,
BADSIG: nsIEnigmail.BAD_SIGNATURE,
ERRSIG: nsIEnigmail.UNVERIFIED_SIGNATURE,
EXPSIG: nsIEnigmail.EXPIRED_SIGNATURE,
REVKEYSIG: nsIEnigmail.GOOD_SIGNATURE,
EXPKEYSIG: nsIEnigmail.EXPIRED_KEY_SIGNATURE,
KEYEXPIRED: nsIEnigmail.EXPIRED_KEY,
KEYREVOKED: nsIEnigmail.REVOKED_KEY,
NO_PUBKEY: nsIEnigmail.NO_PUBKEY,
NO_SECKEY: nsIEnigmail.NO_SECKEY,
IMPORTED: nsIEnigmail.IMPORTED_KEY,
INV_RECP: nsIEnigmail.INVALID_RECIPIENT,
MISSING_PASSPHRASE: nsIEnigmail.MISSING_PASSPHRASE,
BAD_PASSPHRASE: nsIEnigmail.BAD_PASSPHRASE,
BADARMOR: nsIEnigmail.BAD_ARMOR,
NODATA: nsIEnigmail.NODATA,
DECRYPTION_FAILED: nsIEnigmail.DECRYPTION_FAILED,
DECRYPTION_OKAY: nsIEnigmail.DECRYPTION_OKAY,
TRUST_UNDEFINED: nsIEnigmail.UNTRUSTED_IDENTITY,
TRUST_NEVER: nsIEnigmail.UNTRUSTED_IDENTITY,
TRUST_MARGINAL: nsIEnigmail.UNTRUSTED_IDENTITY,
TRUST_FULLY: nsIEnigmail.TRUSTED_IDENTITY,
TRUST_ULTIMATE: nsIEnigmail.TRUSTED_IDENTITY
};
///////////////////////////////////////////////////////////////////////////////
// File read/write operations
const NS_LOCAL_FILE_CONTRACTID = "@mozilla.org/file/local;1";
const NS_LOCALFILEOUTPUTSTREAM_CONTRACTID =
"@mozilla.org/network/file-output-stream;1";
const NS_RDONLY = 0x01;
const NS_WRONLY = 0x02;
const NS_CREATE_FILE = 0x08;
const NS_TRUNCATE = 0x20;
const DEFAULT_FILE_PERMS = 0600;
const GET_BOOL = "GET_BOOL";
const GET_LINE = "GET_LINE";
const GET_HIDDEN = "GET_HIDDEN";
const BUTTON_POS_0 = 1;
const BUTTON_POS_1 = 1 << 8;
const BUTTON_POS_2 = 1 << 16;
function CreateFileStream(filePath, permissions) {
//DEBUG_LOG("enigmail.js: CreateFileStream: file="+filePath+"\n");
try {
var localFile = Components.classes[NS_LOCAL_FILE_CONTRACTID].createInstance(Components.interfaces.nsILocalFile);
localFile.initWithPath(filePath);
if (localFile.exists()) {
if (localFile.isDirectory() || !localFile.isWritable())
throw Components.results.NS_ERROR_FAILURE;
if (!permissions)
permissions = localFile.permissions;
}
if (!permissions)
permissions = DEFAULT_FILE_PERMS;
var flags = NS_WRONLY | NS_CREATE_FILE | NS_TRUNCATE;
var fileStream = Components.classes[NS_LOCALFILEOUTPUTSTREAM_CONTRACTID].createInstance(Components.interfaces.nsIFileOutputStream);
fileStream.init(localFile, flags, permissions, 0);
return fileStream;
} catch (ex) {
ERROR_LOG("enigmail.js: CreateFileStream: Failed to create "+filePath+"\n");
return null;
}
}
function WriteFileContents(filePath, data, permissions) {
DEBUG_LOG("enigmail.js: WriteFileContents: file="+filePath+"\n");
try {
var fileOutStream = CreateFileStream(filePath, permissions);
if (data.length) {
if (fileOutStream.write(data, data.length) != data.length)
throw Components.results.NS_ERROR_FAILURE;
fileOutStream.flush();
}
fileOutStream.close();
} catch (ex) {
ERROR_LOG("enigmail.js: WriteFileContents: Failed to write to "+filePath+"\n");
return false;
}
return true;
}
// Pack/unpack: Network (big-endian) byte order
function pack(value, bytes) {
var str = '';
var mask = 0xff;
for (var j=0; j < bytes; j++) {
str = String.fromCharCode( (value & mask) >> j*8 ) + str;
mask <<= 8;
}
return str;
}
function unpack(str) {
var len = str.length;
var value = 0;
for (var j=0; j < len; j++) {
value <<= 8;
value |= str.charCodeAt(j);
}
return value;
}
const hexTable = "0123456789abcdef";
function bytesToHex(str) {
var len = str.length;
var hex = '';
for (var j=0; j < len; j++) {
var charCode = str.charCodeAt(j);
hex += hexTable.charAt((charCode & 0xf0) >> 4) +
hexTable.charAt((charCode & 0x0f));
}
return hex;
}
function hexToBytes(hex) {
hex = hex.toLowerCase();
var bytes = (1+hex.length)/2;
var str = '';
for (var j=0; j < bytes; j++) {
var loc1 = hexTable.indexOf(hex.charAt(2*j));
var loc2 = 0;
if ((2*j+1) < hex.length)
loc2 = hexTable.indexOf(hex.charAt(2*j+1));
if (loc1 < 0) loc1 = 0;
if (loc2 < 0) loc2 = 0;
str += String.fromCharCode((loc1 << 4) + loc2);
}
return str;
}
///////////////////////////////////////////////////////////////////////////////
function WRITE_LOG(str) {
if (gLogLevel >= 4)
dump(str);
if (gEnigmailSvc && gEnigmailSvc.logFileStream) {
gEnigmailSvc.logFileStream.write(str, str.length);
//gEnigmailSvc.logFileStream.flush();
}
}
function DEBUG_LOG(str) {
if ((gLogLevel >= 4) || (gEnigmailSvc && gEnigmailSvc.logFileStream))
WRITE_LOG(str);
}
function WARNING_LOG(str) {
if (gLogLevel >= 3)
WRITE_LOG(str);
if (gEnigmailSvc && gEnigmailSvc.console)
gEnigmailSvc.console.write(str);
}
function ERROR_LOG(str) {
if (gLogLevel >= 2)
WRITE_LOG(str);
if (gEnigmailSvc && gEnigmailSvc.console)
gEnigmailSvc.console.write(str);
}
function CONSOLE_LOG(str) {
if (gLogLevel >= 3)
WRITE_LOG(str);
if (gEnigmailSvc && gEnigmailSvc.console)
gEnigmailSvc.console.write(str);
}
///////////////////////////////////////////////////////////////////////////////
var EnigModuleObj = {
registerSelf: function (compRegistrar, moduleFile,
registryLocation, componentType)
{
WRITE_LOG("enigmail.js: Registering components\n");
compRegistrar = compRegistrar.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compRegistrar.registerFactoryLocation(NS_ENIGMAIL_CID,
"Enigmail",
NS_ENIGMAIL_CONTRACTID,
moduleFile, registryLocation,
componentType);
compRegistrar.registerFactoryLocation(NS_ENIGMAILPROTOCOLHANDLER_CID,
"Enigmail Protocol Handler",
NS_ENIGMAILPROTOCOLHANDLER_CONTRACTID,
moduleFile, registryLocation,
componentType);
compRegistrar.registerFactoryLocation(NS_PGP_MODULE_CID,
"PGP Module",
NS_PGP_MODULE_CONTRACTID,
moduleFile, registryLocation,
componentType);
compRegistrar.registerFactoryLocation(NS_ENIGCLINE_SERVICE_CID,
"Enigmail Key Management CommandLine Service",
NS_CLINE_SERVICE_CONTRACTID,
moduleFile,
registryLocation,
componentType);
var catman = Components.classes[NS_CATMAN_CONTRACTID].getService(nsICategoryManager);
catman.addCategoryEntry("command-line-argument-handlers",
"Enigmail Key Management command line handler",
NS_CLINE_SERVICE_CONTRACTID, true, true);
WRITE_LOG("enigmail.js: Registered components\n");
},
unregisterSelf: function(compRegistrar, moduleFile, registryLocation)
{
DEBUG_LOG("enigmail.js: unregisterSelf\n");
compRegistrar = compRegistrar.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compRegistrar.unregisterFactoryLocation(NS_ENIGCLINE_SERVICE_CID,
moduleFile);
var catman = Components.classes[NS_CATMAN_CONTRACTID]
.getService(nsICategoryManager);
catman.deleteCategoryEntry("command-line-argument-handlers",
NS_CLINE_SERVICE_CONTRACTID, true);
},
getClassObject: function (compRegistrar, cid, iid) {
DEBUG_LOG("enigmail.js: getClassObject: cid="+cid+"\n");
if (!iid.equals(Components.interfaces.nsIFactory))
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
if (gEnigmailSvc == null) {
// Create Enigmail Service (delay initialization)
gEnigmailSvc = new Enigmail(false);
}
if (cid.equals(NS_ENIGCLINE_SERVICE_CID))
return EnigCLineFactory;
if (cid.equals(NS_ENIGMAIL_CID)) {
return new EnigmailFactory();
}
if (cid.equals(NS_ENIGMAILPROTOCOLHANDLER_CID)) {
return new EnigmailProtocolHandlerFactory();
}
if (cid.equals(NS_PGP_MODULE_CID)) {
return new PGPModuleFactory();
}
return null;
},
canUnload: function(compRegistrar)
{
DEBUG_LOG("enigmail.js: canUnload:\n");
return true;
}
};
/* Module entry point */
function NSGetModule(compRegistrar, moduleFile) {
DEBUG_LOG("enigmail.js: NSGetModule:\n");
return EnigModuleObj;
}
///////////////////////////////////////////////////////////////////////////////
function EnigmailFactory()
{
}
EnigmailFactory.prototype = {
QueryInterface: function (iid) {
//DEBUG_LOG("EnigmailFactory.QueryInterface:"+iid+"\n");
if (!iid.equals(Components.interfaces.nsIFactory) &&
!iid.equals(nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
},
createInstance: function (outer, iid) {
//DEBUG_LOG("EnigmailFactory.createInstance:\n");
if (!gEnigmailSvc)
throw Components.results.NS_ERROR_NOT_D;
return gEnigmailSvc;
}
}
function PGPModuleFactory()
{
}
PGPModuleFactory.prototype = {
QueryInterface: function (iid) {
//DEBUG_LOG("PGPModuleFactory.QueryInterface:"+iid+"\n");
if (!iid.equals(Components.interfaces.nsIFactory) &&
!iid.equals(nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
},
createInstance: function (outer, iid) {
DEBUG_LOG("PGPModuleFactory.createInstance:\n");
return new PGPModule();
}
}
function PGPMsgHeader(aTo, aCc, aBcc)
{
this.to = aTo;
this.cc = aCc;
this.bcc = aBcc;
}
PGPMsgHeader.prototype = {
to: "",
cc: "",
bcc: "",
QueryInterface: function (iid) {
DEBUG_LOG("PGPMsgHeader.QueryInterface:\n");
if (!iid.equals(nsIPGPMsgHeader) && !iid.equals(nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
}
}
/*
function PGPMsgBody(aBody)
{
this.body = aBody;
}
PGPMsgBody.prototype = {
body: "",
QueryInterface: function (iid) {
DEBUG_LOG("PGPMsgBody.QueryInterface:\n");
if (!iid.equals(nsIPGPMsgBody) && !iid.equals(nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
}
}
function PGPModule()
{
}
PGPModule.prototype = {
QueryInterface: function (iid) {
DEBUG_LOG("PGPModule.QueryInterface:\n");
if (!iid.equals(nsIPGPModule) && !iid.equals(nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
},
// void SetEncrypt(in boolean aEncrypt, in long aFlags,
// [retval] out long aNewFlags);
SetEncrypt: function (aEncrypt, aFlags, aNewFlags) {
DEBUG_LOG("PGPModule.SetEncrypt:\n");
return 0;
},
// void SetSign(in boolean aSign, in long aFlags,
// [retval] out long aNewFlags);
SetSign: function (aSign, aFlags, aNewFlags) {
DEBUG_LOG("PGPModule.SetSign:\n");
return 0;
},
// void SetPGPMIME(in boolean aMime, in long aFlags,
// [retval] out long aNewFlags);
SetPGPMIME: function (aMime, Flags, aNewFlags) {
DEBUG_LOG("PGPModule.SetPGPMIME:\n");
return 0;
},
// nsISupports CreateMsgHeader(in string aTo, in string aCc, in string aBcc);
CreateMsgHeader: function (aTo, aCc, aBcc) {
DEBUG_LOG("PGPModuleCreateMsgHeader.:\n");
return new PGPMsgHeader(aTo, aCc, aBcc);
},
//nsISupports CreateMsgBody(in string aBody);
CreateMsgBody: function (aBody) {
DEBUG_LOG("PGPModule.CreateMsgBody: "+aBody+"\n");
return new PGPMsgBody(aBody);
},
// string GetStringFromMsgBody(in nsISupports aMsgBody);
GetStringFromMsgBody: function (aMsgBody) {
DEBUG_LOG("PGPModule.GetStringFromMsgBody:\n");
aMsgBody = aMsgBody.QueryInterface(nsIPGPMsgBody);
return aMsgBody.body;
},
// void EncryptSign(in long aFlags, in nsISupports aMsgHeader,
// in nsISupports aOrigBody,
// [retval] out nsISupports aNewBody);
EncryptSign: function (aFlags, aMsgHeader, aOrigBody, aNewBody) {
DEBUG_LOG("PGPModule.EncryptSign:\n");
aMsgHeader = aMsgHeader.QueryInterface(nsIPGPMsgHeader);
aOrigBody = aOrigBody.QueryInterface(nsIPGPMsgBody);
DEBUG_LOG("PGPModule.EncryptSign: aMsgHeader.to="+aMsgHeader.to+"\n");
DEBUG_LOG("PGPModule.EncryptSign: aOrigBody.body="+aOrigBody.body+"\n");
DEBUG_LOG("PGPModule.EncryptSign: aNewBody="+aNewBody+"\n");
var exitCodeObj = new Object();
var statusFlagsObj = new Object();
var errorMsgObj = new Object();
var encryptFlags = nsIEnigmail.SEND_SIGNED | nsIEnigmail.SEND_ENCRYPTED;
var cipherText = gEnigmailSvc.encryptMessage(null, 0,
aOrigBody.body,
"",
aMsgHeader.to,
encryptFlags,
exitCodeObj,
statusFlagsObj,
errorMsgObj);
return new PGPMsgBody(cipherText);
},
// void DecryptVerify(in nsISupports aOrigBody,
// [retval] out nsISupports aNewBody)
DecryptVerify: function (aOrigBody, aNewBody) {
DEBUG_LOG("PGPModule.DecryptVerify:\n");
aOrigBody = aOrigBody.QueryInterface(nsIPGPMsgBody);
DEBUG_LOG("PGPModule.DecryptVerify: aOrigBody.body="+aOrigBody.body+"\n");
var exitCodeObj = new Object();
var errorMsgObj = new Object();
var signatureObj = new Object();
var statusFlagsObj = new Object();
var keyIdObj = new Object();
var userIdObj = new Object();
var plainText = gEnigmailSvc.decryptMessage(null, 0,
aOrigBody.body,
signatureObj,
exitCodeObj,
statusFlagsObj,
keyIdObj,
userIdObj,
errorMsgObj);
return new PGPMsgBody(plainText);
},
// void FreeMsgHeader(in nsISupports aMsgHeader);
FreeMsgHeader: function (aMsgHeader) {
DEBUG_LOG("PGPModule.FreeMsgHeader:\n");
},
// void FreeMsgBody(in nsISupports aMsgBody);
FreeMsgBody: function (aMsgBody) {
DEBUG_LOG("PGPModule.FreeMsgBody:\n");
},
// void FindHeader(in string aHeaderBuffer, in string aHeaderStr,
// out long aHeaderStartOffset, out long aHeaderLength,
// [retval] out long aBufferEndOffset);
FindHeader: function (aHeaderBuffer, aHeaderStr,
aHeaderStartOffset, aHeaderLength, aBufferEndOffset) {
DEBUG_LOG("PGPModule.FindHeader:\n");
DEBUG_LOG("PGPModule.EncryptSign: aHeaderBuffer="+aHeaderBuffer+"\n");
for (var k in aHeaderStartOffset)
DEBUG_LOG("PGPModule.EncryptSign: k="+k+"\n");
DEBUG_LOG("PGPModule.EncryptSign: aHeaderStartOffset="+aHeaderStartOffset+"\n");
DEBUG_LOG("PGPModule.EncryptSign: aHeaderLength="+aHeaderLength+"\n");
DEBUG_LOG("PGPModule.EncryptSign: aBufferEndOffset="+aBufferEndOffset+"\n");
aHeaderStartOffset.value = 0;
aHeaderLength.value = 0;
aBufferEndOffset.value = 0;
},
// boolean ContainsPGPContent(in string aBuffer);
ContainsPGPContent: function (aBuffer) {
DEBUG_LOG("PGPModule.ContainsPGPContent:\n");
return false;
}
}
*/
///////////////////////////////////////////////////////////////////////////////
// Utility functions
///////////////////////////////////////////////////////////////////////////////
function isAbsolutePath(filePath, isDosLike) {
// Check if absolute path
if (isDosLike) {
return (filePath.search(/^\w+:\\/) == 0);
} else {
return (filePath.search(/^\//) == 0)
}
}
function ResolvePath(filePath, envPath, isDosLike) {
DEBUG_LOG("enigmail.js: ResolvePath: filePath="+filePath+"\n");
if (isAbsolutePath(filePath, isDosLike))
return filePath;
if (!envPath)
return null;
var pathDirs = envPath.split(isDosLike ? ";" : ":");
for (var j=0; j<pathDirs.length; j++) {
try {
var pathDir = Components.classes[NS_LOCAL_FILE_CONTRACTID].createInstance(nsILocalFile);
pathDir.initWithPath(pathDirs[j]);
if (pathDir.exists() && pathDir.isDirectory()) {
pathDir.appendRelativePath(filePath);
if (pathDir.exists()) {
return pathDir.path;
}
}
} catch (ex) {
}
}
return null;
}
function EnigConvertToUnicode(text, charset) {
DEBUG_LOG("enigmail.js: EnigConvertToUnicode: "+charset+"\n");
if (!text || !charset || (charset.toLowerCase() == "iso-8859-1"))
return text;
// Encode plaintext
try {
var unicodeConv = Components.classes[NS_ISCRIPTABLEUNICODECONVERTER_CONTRACTID].getService(Components.interfaces.nsIScriptableUnicodeConverter);
unicodeConv.charset = charset;
return unicodeConv.ConvertToUnicode(text);
} catch (ex) {
return text;
}
}
function EnigConvertGpgToUnicode(text) {
if (typeof(text)=="string") {
var a=text.search(/[\x80-\xFF]{2}/);
var b=0;
while (a>=0) {
var ch=text.substr(a,2).toSource().substr(13,8).replace(/\\x/g, "\\u00");
var newCh=EnigConvertToUnicode(EnigConvertToUnicode(ch, "x-u-escaped"), "utf-8");
if (newCh != ch) {
//dump(ch+"\n");
var r=new RegExp(text.substr(a, 2), "g");
text=text.replace(r, newCh);
}
b=a+2;
a=text.substr(b+2).search(/[\x80-\xFF]{2}/);
if (a>=0) {
a += b+2;
}
}
a=text.search(/\\x3a/i);
if (a>0) {
text = text.replace(/\\x3a/ig, "\\e3A");
}
a=text.search(/\\x/);
while (a>=0) {
ch=text.substr(a,4).replace(/\\x/g, "\\u00");
newCh=EnigConvertToUnicode(ch, "x-u-escaped");
if (newCh != ch) {
r=new RegExp("\\"+text.substr(a, 4), "g");
text=text.replace(r, newCh);
}
a=text.search(/\\x/);
}
}
return text;
}
///////////////////////////////////////////////////////////////////////////////
// Enigmail protocol handler
///////////////////////////////////////////////////////////////////////////////
function EnigmailProtocolHandler()
{
}
EnigmailProtocolHandler.prototype.scheme = "enigmail";
EnigmailProtocolHandler.prototype.defaultPort = -1;
EnigmailProtocolHandler.prototype.QueryInterface =
function (iid)
{
DEBUG_LOG("enigmail.js: EnigmailProtocolHandler.QueryInterface\n");
if (!iid.equals(nsIProtocolHandler) && !iid.equals(nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
}
EnigmailProtocolHandler.prototype.newURI =
function (aSpec, originCharset, aBaseURI)
{
DEBUG_LOG("enigmail.js: EnigmailProtocolHandler.newURI: aSpec='"+aSpec+"'\n");
var uri = Components.classes[NS_SIMPLEURI_CONTRACTID].createInstance(Components.interfaces.nsIURI);
uri.spec = aSpec;
return uri;
}
EnigmailProtocolHandler.prototype.newChannel =
function (aURI)
{
DEBUG_LOG("enigmail.js: EnigmailProtocolHandler.newChannel: URI='"+aURI.spec+"'\n");
var messageId = ExtractMessageId(aURI.spec);
if (messageId) {
// Handle enigmail:message?id=...
if (!gEnigmailSvc)
throw Components.results.NS_ERROR_FAILURE;
var contentType, contentCharset, contentData;
if (gEnigmailSvc._messageIdList[messageId]) {
var messageUriObj = gEnigmailSvc._messageIdList[messageId];
contentType = messageUriObj.contentType;
contentCharset = messageUriObj.contentCharset;
contentData = messageUriObj.contentData;
DEBUG_LOG("enigmail.js: EnigmailProtocolHandler.newChannel: messageURL="+messageUriObj.originalUrl+", "+contentType+", "+contentCharset+"\n");
if (!messageUriObj.persist)
delete gEnigmailSvc._messageIdList[messageId];
} else {
contentType = "text/plain";
contentCharset = "";
contentData = "Enigmail error: invalid URI "+aURI.spec;
}
var channel = gEnigmailSvc.ipcService.newStringChannel(aURI,
contentType,
"UTF-8",
contentData);
return channel;
}
if (aURI.spec == aURI.scheme+":dummy") {
// Dummy PKCS7 content (to access mimeEncryptedClass)
channel = gEnigmailSvc.ipcService.newStringChannel(aURI,
"message/rfc822",
"",
gDummyPKCS7);
return channel;
}
var winName, spec;
if (aURI.spec == "about:"+aURI.scheme) {
// About Enigmail
winName = "about:"+enigmail;
spec = "chrome://enigmail/content/enigmailAbout.xul";
} else if (aURI.spec == aURI.scheme+":console") {
// Display enigmail console messages
winName = "enigmail:console";
spec = "chrome://enigmail/content/enigmailConsole.xul";
} else if (aURI.spec == aURI.scheme+":keygen") {
// Display enigmail key generation console
winName = "enigmail:keygen";
spec = "chrome://enigmail/content/enigmailKeygen.xul";
} else {
// Display Enigmail about page
winName = "about:enigmail";
spec = "chrome://enigmail/content/enigmailAbout.xul";
}
var windowManager = Components.classes[WMEDIATOR_CONTRACTID].getService(Components.interfaces.nsIWindowMediator);
var recentWin = windowManager.getMostRecentWindow(winName);
dump("recentWin="+recentWin+"\n");
if (recentWin) {
recentWin.focus();
} else {
var appShellSvc = Components.classes[ASS_CONTRACTID].getService(Components.interfaces.nsIAppShellService);
var domWin = appShellSvc.hiddenDOMWindow;
domWin.open(spec, "_blank", "chrome,menubar,toolbar,resizable");
}
throw Components.results.NS_ERROR_FAILURE;
}
function EnigmailProtocolHandlerFactory() {
}
EnigmailProtocolHandlerFactory.prototype = {
QueryInterface: function (iid) {
//DEBUG_LOG("EnigmailProtocolHandlerFactory.QueryInterface:"+iid+"\n");
if (!iid.equals(Components.interfaces.nsIFactory) &&
!iid.equals(nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
},
createInstance: function (outer, iid) {
DEBUG_LOG("enigmail.js: EnigmailProtocolHandlerFactory.createInstance\n");
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
if (!iid.equals(nsIProtocolHandler) && !iid.equals(nsISupports))
throw Components.results.NS_ERROR_INVALID_ARG;
return new EnigmailProtocolHandler();
}
}
///////////////////////////////////////////////////////////////////////////////
// Enigmail encryption/decryption service
///////////////////////////////////////////////////////////////////////////////
function GetXULOwner () {
if (gXULOwner)
return gXULOwner;
// Open temporary XUL channel
var ioServ = Components.classes[NS_IOSERVICE_CONTRACTID].getService(Components.interfaces.nsIIOService);
var temChannel = ioServ.newChannel("chrome://enigmail/content/dummy.xul",
"",
null);
// Get owner of XUL channel
gXULOwner = temChannel.owner;
// Release channel
temChannel = null;
DEBUG_LOG("enigmail.js: GetXULOwner: gXULOwner="+gXULOwner+"\n");
return gXULOwner;
}
function GetPassphrase(domWindow, passwdObj, useAgentObj) {
DEBUG_LOG("enigmail.js: GetPassphrase: \n");
useAgentObj.value = false;
try {
var noPassphrase = gEnigmailSvc.prefBranch.getBoolPref("noPassphrase");
var useAgent = gEnigmailSvc.prefBranch.getBoolPref("useGpgAgent");
useAgentObj.value = useAgent;
if (noPassphrase || useAgent) {
passwdObj.value = "";
return true;
}
}
catch(ex) {}
if (gEnigmailSvc.haveCachedPassphrase()) {
passwdObj.value = gCachedPassphrase;
return true;
}
// Obtain password interactively
var checkObj = new Object();
var promptMsg = EnigGetString("enterPass",gEnigmailSvc.agentType.toUpperCase());
passwdObj.value = "";
checkObj.value = true;
var maxIdleMinutes = gEnigmailSvc.getMaxIdleMinutes();
var checkMsg = (maxIdleMinutes>0) ? EnigGetString("rememberPass",maxIdleMinutes) : "";
var success;
var promptService = Components.classes[NS_PROMPTSERVICE_CONTRACTID].getService(Components.interfaces.nsIPromptService);
success = promptService.promptPassword(domWindow,
EnigGetString("Enigmail"),
promptMsg,
passwdObj,
checkMsg,
checkObj);
if (!success)
return false;
DEBUG_LOG("enigmail.js: GetPassphrase: got passphrase\n");
// Remember passphrase only if necessary
if (checkObj.value && (maxIdleMinutes > 0))
gEnigmailSvc.setCachedPassphrase(passwdObj.value);
return true;
}
function Enigmail(registeringModule)
{
DEBUG_LOG("enigmail.js: Enigmail: START "+registeringModule+"\n");
this.registeringModule = registeringModule;
DEBUG_LOG("enigmail.js: Enigmail: END\n");
}
Enigmail.prototype.registeringModule = false;
Enigmail.prototype.initialized = false;
Enigmail.prototype.initializationAttempted = false;
Enigmail.prototype.initializationError = "";
Enigmail.prototype.composeSecure = false;
Enigmail.prototype.logFileStream = null;
Enigmail.prototype.isUnix = false;
Enigmail.prototype.isWin32 = false;
Enigmail.prototype.isOs2 = false;
Enigmail.prototype.isDosLike = false;
Enigmail.prototype.ipcService = null;
Enigmail.prototype.prefBranch = null;
Enigmail.prototype.console = null;
Enigmail.prototype.keygenProcess = null;
Enigmail.prototype.keygenConsole = null;
Enigmail.prototype.quoteSign = "";
Enigmail.prototype.agentType = "";
Enigmail.prototype.agentPath = "";
Enigmail.prototype.agentVersion = "";
Enigmail.prototype.userIdList = null;
Enigmail.prototype.rulesList = null;
Enigmail.prototype._lastActiveTime = 0;
Enigmail.prototype._messageIdList = {};
Enigmail.prototype.QueryInterface =
function (iid) {
//DEBUG_LOG("Enigmail.QueryInterface:\n");
if (!iid.equals(nsIEnigmail) &&
!iid.equals(nsIObserver) &&
!iid.equals(nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
}
Enigmail.prototype.observe =
function (aSubject, aTopic, aData) {
DEBUG_LOG("enigmail.js: Enigmail.observe: topic='"+aTopic+"' \n");
if (aTopic == "timer-callback") {
// Cause cached password to expire, if need be
if (!this.haveCachedPassphrase()) {
// No cached password; cancel repeating timer
if (gCacheTimer)
gCacheTimer.cancel();
}
} else if (aTopic == NS_XPCOM_SHUTDOWN_OBSERVER_ID) {
// XPCOM shutdown
this.finalize();
// Reset mail.show_headers pref
try {
var prefSvc = Components.classes[NS_PREFS_SERVICE_CID]
.getService(Components.interfaces.nsIPrefService);
var prefRoot = prefSvc.getBranch(null);
var prefValue = 1;
try {
prefValue = this.prefBranch.getIntPref("show_headers");
} catch (ex) {}
prefRoot.setIntPref("mail.show_headers", prefValue);
prefSvc.savePrefFile(null);
} catch (ex) {}
}
}
Enigmail.prototype.alertMsg =
function (domWindow, mesg) {
var promptService = Components.classes[NS_PROMPTSERVICE_CONTRACTID].getService(Components.interfaces.nsIPromptService);
return promptService.alert(domWindow, EnigGetString("enigAlert"), mesg);
}
Enigmail.prototype.confirmMsg =
function (domWindow, mesg) {
var dummy={};
var promptService = Components.classes[NS_PROMPTSERVICE_CONTRACTID].getService(Components.interfaces.nsIPromptService);
var buttonPressed = promptService.confirmEx(domWindow,
EnigGetString("enigConfirm"),
mesg,
(promptService.BUTTON_TITLE_YES * BUTTON_POS_0) +
(promptService.BUTTON_TITLE_NO * BUTTON_POS_1),
null, null, null,
null, dummy);
return (buttonPressed==0); // promptService.confirm(domWindow, EnigGetString("enigConfirm"), mesg);
}
Enigmail.prototype.promptValue =
function (domWindow, mesg, valueObj) {
var promptService = Components.classes[NS_PROMPTSERVICE_CONTRACTID].getService(Components.interfaces.nsIPromptService);
var checkObj = new Object();
return promptService.prompt(domWindow, EnigGetString("enigPrompt"),
mesg, valueObj, "", checkObj);
}
Enigmail.prototype.errorMsg =
function (domWindow, mesg) {
var promptService = Components.classes[NS_PROMPTSERVICE_CONTRACTID].getService(Components.interfaces.nsIPromptService);
return promptService.alert(domWindow, EnigGetString("enigError"), mesg);
}
Enigmail.prototype.getMaxIdleMinutes =
function () {
var maxIdleMinutes = 5;
try {
maxIdleMinutes = this.prefBranch.getIntPref("maxIdleMinutes");
} catch (ex) {
}
return maxIdleMinutes;
}
Enigmail.prototype.getLogDirectoryPrefix =
function () {
var logDirectory = "";
try {
logDirectory = this.prefBranch.getCharPref("logDirectory");
} catch (ex) {
}
if (!logDirectory)
return "";
var dirPrefix = logDirectory + (this.isDosLike ? "\\" : "/");
return dirPrefix;
}
Enigmail.prototype.stillActive =
function () {
DEBUG_LOG("enigmail.js: Enigmail.stillActive: \n");
// Update last active time
var curDate = new Date();
this._lastActiveTime = curDate.getTime();
// DEBUG_LOG("enigmail.js: Enigmail.stillActive: _lastActiveTime="+this._lastActiveTime+"\n");
}
Enigmail.prototype.clearCachedPassphrase =
function () {
DEBUG_LOG("enigmail.js: Enigmail.clearCachedPassphrase: \n");
gCachedPassphrase = null;
}
Enigmail.prototype.setCachedPassphrase =
function (passphrase) {
DEBUG_LOG("enigmail.js: Enigmail.setCachedPassphrase: \n");
gCachedPassphrase = passphrase;
this.stillActive();
var maxIdleMinutes = this.getMaxIdleMinutes();
if (this.haveCachedPassphrase() && (maxIdleMinutes > 0)) {
// Start timer
if (gCacheTimer)
gCacheTimer.cancel();
var delayMillisec = maxIdleMinutes*60*1000;
if (Components.interfaces.nsITimer) {
// Use nsITimer: Post 1.2a mozilla trunk
const nsITimer = Components.interfaces.nsITimer;
gCacheTimer = Components.classes[NS_TIMER_CONTRACTID].createInstance(nsITimer);
if (!gCacheTimer) {
ERROR_LOG("enigmail.js: Enigmail.setCachedPassphrase: Error - failed to create timer\n");
throw Components.results.NS_ERROR_FAILURE;
}
gCacheTimer.init(this, delayMillisec,
nsITimer.TYPE_REPEATING_SLACK);
} else {
// Use nsIScriptableTimer: Stable Mozilla 1.0 branch
const nsIScriptableTimer = Components.interfaces.nsIScriptableTimer;
gCacheTimer = Components.classes[NS_TIMER_CONTRACTID].createInstance(nsIScriptableTimer);
if (!gCacheTimer) {
ERROR_LOG("enigmail.js: Enigmail.setCachedPassphrase: Error - failed to create scriptable timer\n");
throw Components.results.NS_ERROR_FAILURE;
}
gCacheTimer.init(this, delayMillisec,
nsIScriptableTimer.PRIORITY_NORMAL,
nsIScriptableTimer.TYPE_REPEATING_SLACK);
}
DEBUG_LOG("enigmail.js: Enigmail.setCachedPassphrase: gCacheTimer="+gCacheTimer+"\n");
}
}
Enigmail.prototype.haveCachedPassphrase =
function () {
DEBUG_LOG("enigmail.js: Enigmail.haveCachedPassphrase: \n");
var havePassphrase = ((typeof gCachedPassphrase) == "string");
if (!havePassphrase)
return false;
var curDate = new Date();
var currentTime = curDate.getTime();
var maxIdleMinutes = this.getMaxIdleMinutes();
var delayMillisec = maxIdleMinutes*60*1000;
var expired = ((currentTime - this._lastActiveTime) >= delayMillisec);
// DEBUG_LOG("enigmail.js: Enigmail.haveCachedPassphrase: ")
// DEBUG_LOG("currentTime="+currentTime+", _lastActiveTime="+this._lastActiveTime+", expired="+expired+"\n");
if (expired) {
// Too much idle time; forget cached password
gCachedPassphrase = null;
havePassphrase = false;
WRITE_LOG("enigmail.js: Enigmail.haveCachedPassphrase: CACHE IDLED OUT\n");
}
return havePassphrase;
}
Enigmail.prototype.finalize =
function () {
DEBUG_LOG("enigmail.js: Enigmail.finalize:\n");
if (!this.initialized) return;
if (this.logFileStream) {
this.logFileStream.close();
this.logFileStream = null;
}
if (this.console) {
this.console.close();
this.console = null;
}
gLogLevel = 3;
this.initializationError = "";
this.initializationAttempted = false;
this.initialized = false;
}
Enigmail.prototype.mimeInitialized =
function () {
var enigMimeService = Components.classes[NS_ENIGMIMESERVICE_CONTRACTID].getService(Components.interfaces.nsIEnigMimeService);
var value = enigMimeService.initialized;
DEBUG_LOG("enigmail.js: Enigmail.mimeInitialized: "+value+"\n");
return value;
}
Enigmail.prototype.initialize =
function (domWindow, version, prefBranch) {
this.initializationAttempted = true;
this.prefBranch = prefBranch;
DEBUG_LOG("enigmail.js: Enigmail.initialize: START\n");
if (this.initialized) return;
try {
var enigMsgComposeFactory = Components.classes[NS_ENIGMSGCOMPOSEFACTORY_CONTRACTID].createInstance(Components.interfaces.nsIFactory);
var compMgr = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerFactory(NS_ENIGMSGCOMPOSE_CID,
"Enig Msg Compose",
NS_MSGCOMPOSESECURE_CONTRACTID,
enigMsgComposeFactory);
var msgComposeSecureCID = compMgr.contractIDToCID(NS_MSGCOMPOSESECURE_CONTRACTID);
this.composeSecure = (msgComposeSecureCID.toString() ==
NS_ENIGMSGCOMPOSE_CID);
} catch (ex) {}
var ioServ = Components.classes[NS_IOSERVICE_CONTRACTID].getService(Components.interfaces.nsIIOService);
try {
var httpHandler = ioServ.getProtocolHandler("http");
httpHandler = httpHandler.QueryInterface(Components.interfaces.nsIHttpProtocolHandler);
}
catch (ex) {
httpHandler = domWindow.navigator;
}
this.oscpu = httpHandler.oscpu;
this.platform = httpHandler.platform;
if (httpHandler.vendor) {
this.vendor = httpHandler.vendor;
} else {
this.vendor = "Mozilla";
}
this.isUnix = (this.platform.search(/X11/i) == 0);
this.isWin32 = (this.platform.search(/Win/i) == 0);
this.isOs2 = (this.platform.search(/OS\/2/i) == 0);
if (this.isOs2) {
this.quoteSign="\\\"";
}
else {
this.quoteSign="'";
}
this.isDosLike = (this.isWin32 || this.isOs2);
var prefix = this.getLogDirectoryPrefix();
if (prefix) {
gLogLevel = 5;
this.logFileStream = CreateFileStream(prefix+"enigdbug.txt");
DEBUG_LOG("enigmail.js: Logging debug output to "+prefix+"enigdbug.txt\n");
}
this.version = version;
DEBUG_LOG("enigmail.js: Enigmail version "+this.version+"\n");
DEBUG_LOG("enigmail.js: OS/CPU="+this.oscpu+"\n");
DEBUG_LOG("enigmail.js: Platform="+this.platform+"\n");
DEBUG_LOG("enigmail.js: composeSecure="+this.composeSecure+"\n");
var processInfo;
try {
processInfo = Components.classes[NS_PROCESSINFO_CONTRACTID].getService(nsIProcessInfo);
} catch (ex) {
this.initializationError = EnigGetString("enigmimeNotAvail");
ERROR_LOG("enigmail.js: Enigmail.initialize: Error - "+this.initializationError+"\n");
throw Components.results.NS_ERROR_FAILURE;
}
this.processInfo = processInfo;
var nspr_log_modules = processInfo.getEnv("NSPR_LOG_MODULES");
var matches = nspr_log_modules.match(/enigmail:(\d+)/);
if (matches && (matches.length > 1)) {
gLogLevel = matches[1];
WARNING_LOG("enigmail.js: Enigmail: gLogLevel="+gLogLevel+"\n");
}
// Initialize global environment variables list
var passEnv = [ "PGPPATH", "GNUPGHOME",
"ALLUSERSPROFILE", "APPDATA", "BEGINLIBPATH",
"COMMONPROGRAMFILES", "COMSPEC", "DISPLAY",
"ENIGMAIL_PASS_ENV", "ENDLIBPATH",
"HOME", "HOMEDRIVE", "HOMEPATH",
"LANG", "LANGUAGE", "LC_ALL", "LC_COLLATE", "LC_CTYPE",
"LC_MESSAGES", "LC_MONETARY", "LC_NUMERIC", "LC_TIME",
"LOCPATH", "LOGNAME", "LD_LIBRARY_PATH", "MOZILLA_FIVE_HOME",
"NLSPATH", "PATH", "PATHEXT", "PROGRAMFILES", "PWD",
"SHELL", "SYSTEMDRIVE", "SYSTEMROOT",
"TEMP", "TMP", "TMPDIR", "TZ", "TZDIR", "UNIXROOT",
"USER", "USERPROFILE", "WINDIR" ];
try {
var useAgent=this.prefBranch.getBoolPref("useGpgAgent");
if (useAgent) {
passEnv.push("GPG_AGENT_INFO");
}
} catch (ex) {}
var passList = this.processInfo.getEnv("ENIGMAIL_PASS_ENV");
if (passList) {
var passNames = passList.split(":");
for (var k=0; k<passNames.length; k++)
passEnv.push(passNames[k]);
}
gEnvList = [];
for (var j=0; j<passEnv.length; j++) {
var envName = passEnv[j];
var envValue = this.processInfo.getEnv(envName);
if (envValue)
gEnvList.push(envName+"="+envValue);
}
DEBUG_LOG("enigmail.js: Enigmail.initialize: gEnvList = "+gEnvList+"\n");
try {
// Access IPC Service
var ipcService = Components.classes[NS_IPCSERVICE_CONTRACTID].getService();
ipcService = ipcService.QueryInterface(nsIIPCService);
this.ipcService = ipcService;
// Create a non-joinable console
var pipeConsole = Components.classes[NS_PIPECONSOLE_CONTRACTID].createInstance(nsIPipeConsole);
pipeConsole.open(500, 80, false);
this.console = pipeConsole;
pipeConsole.write("Initializing Enigmail service ...\n");
} catch (ex) {
this.initializationError = EnigGetString("enigmimeNotAvail");
ERROR_LOG("enigmail.js: Enigmail.initialize: Error - "+this.initializationError+"\n");
throw Components.results.NS_ERROR_FAILURE;
}
this.setAgentPath();
// Register to observe XPCOM shutdown
var obsServ = Components.classes[NS_OBSERVERSERVICE_CONTRACTID].getService();
obsServ = obsServ.QueryInterface(Components.interfaces.nsIObserverService);
obsServ.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
this.stillActive();
this.initialized = true;
DEBUG_LOG("enigmail.js: Enigmail.initialize: END\n");
}
Enigmail.prototype.reinitialize =
function () {
this.initialized = false;
this.initializationAttempted = true;
this.console.write("Reinitializing Enigmail service ...\n");
this.setAgentPath();
this.initialized = true;
}
Enigmail.prototype.setAgentPath =
function () {
var agentPath = "";
try {
agentPath = this.prefBranch.getCharPref("agentPath");
} catch (ex) {}
var agentList = ["gpg"];
var agentType = "";
if (agentPath) {
// Locate GPG/PGP executable
// Append default .exe extension for DOS-Like systems, if needed
if (this.isDosLike && (agentPath.search(/\.\w+$/) < 0))
agentPath += ".exe";
try {
var pathDir = Components.classes[NS_LOCAL_FILE_CONTRACTID].createInstance(nsILocalFile);
if (! isAbsolutePath(agentPath, this.isDosLike)) {
// path relative to Mozilla installation dir
var ds = Components.classes[DIR_SERV_CONTRACTID].getService();
var dsprops = ds.QueryInterface(Components.interfaces.nsIProperties);
pathDir = dsprops.get("CurProcD", Components.interfaces.nsILocalFile);
var dirs=agentPath.split(RegExp(this.isDosLike ? "\\\\" : "/"));
for (var i=0; i< dirs.length; i++) {
if (dirs[i]!=".") {
pathDir.append(dirs[i]);
}
}
pathDir.normalize();
agentPath = pathDir.target;
}
else {
// absolute path
pathDir.initWithPath(agentPath);
}
if (!pathDir.exists())
throw Components.results.NS_ERROR_FAILURE;
} catch (ex) {
this.initializationError = EnigGetString("gpgNotFound", agentPath);
ERROR_LOG("enigmail.js: Enigmail.initialize: Error - "+this.initializationError+"\n");
throw Components.results.NS_ERROR_FAILURE;
}
if (agentPath.search(/gpg[^\/\\]*$/i) > -1) {
agentType = "gpg";
} else if (agentPath.search(/pgp[^\/\\]*$/i) > -1) {
agentType = "pgp";
} else {
this.initializationError = "Cannot determine agent type (GPG/PGP) from executable filename "+agentPath;
ERROR_LOG("enigmail.js: Enigmail.initialize: Error - "+this.initializationError+"\n");
throw Components.results.NS_ERROR_FAILURE;
}
} else {
// Resolve relative path using PATH environment variable
var envPath = this.processInfo.getEnv("PATH");
for (var index=0; index<agentList.length; index++) {
agentType = agentList[index];
var agentName = this.isDosLike ? agentType+".exe" : agentType;
agentPath = ResolvePath(agentName, envPath, this.isDosLike);
if (agentPath) {
// Discard path info for DOS-like systems
/* if (this.isDosLike)
agentPath = agentType; */
break;
}
}
if (!agentPath && this.isDosLike) {
// DOS-like systems: search for GPG in c:\gnupg, c:\gnupg\bin, d:\gnupg, d:\gnupg\bin
var gpgPath = "c:\\gnupg;c:\\gnupg\\bin;d:\\gnupg;d:\\gnupg\\bin";
agentType = "gpg";
agentPath = ResolvePath("gpg.exe", gpgPath, this.isDosLike);
}
if (!agentPath) {
this.initializationError = EnigGetString("gpgNotInPath");
ERROR_LOG("enigmail.js: Enigmail: Error - "+this.initializationError+"\n");
throw Components.results.NS_ERROR_FAILURE;
}
}
CONSOLE_LOG("EnigmailAgentPath="+agentPath+"\n\n");
// Escape any backslashes in agent path
agentPath = agentPath.replace(/\\/g, "\\\\");
this.agentType = agentType;
this.agentPath = agentPath;
var command = this.getAgentPath();
if (agentType == "gpg") {
command += " --batch --no-tty --version";
} else {
command += " +batchmode -h";
}
// This particular command execution seems to be essential on win32
// (In particular, this should be the first command executed and
// *should* use the shell, i.e., command.com)
var outStrObj = new Object();
var outLenObj = new Object();
var errStrObj = new Object();
var errLenObj = new Object();
var exitCode = this.ipcService.execPipe(command, false, "", "", 0, [], 0,
outStrObj, outLenObj, errStrObj, errLenObj);
CONSOLE_LOG("enigmail> "+command.replace(/\\\\/g, "\\")+"\n");
var outStr = outStrObj.value;
if (errStrObj.value)
outStr += errStrObj.value;
CONSOLE_LOG(outStr+"\n");
var versionParts = outStr.replace(/[\r\n].*/g,"").split(/ /);
var gpgVersion = versionParts[versionParts.length-1]
this.agentVersion = gpgVersion;
// check GnuPG version number
var evalVersion = this.agentVersion.match(/^\d+\.\d+/)
if (evalVersion && evalVersion[0]<"1.2") {
this.alertMsg(domWindow, EnigGetString("oldGpgVersion", gpgVersion));
throw Components.results.NS_ERROR_FAILURE;
}
}
Enigmail.prototype.getAgentPath =
function () {
var p = "";
try {
p=" "+this.prefBranch.getCharPref("agentAdditionalParam").replace(/([\\\`])/g, "\\$1");
}
catch (ex) {}
return this.agentPath+p;
}
Enigmail.prototype.passwdCommand =
function () {
var command;
try {
var gpgVersion = this.agentVersion.match(/^\d+\.\d+/);
if (this.prefBranch.getBoolPref("useGpgAgent")) {
command = " --use-agent "
}
else {
command = " --passphrase-fd 0";
if (gpgVersion && gpgVersion[0] >= "1.1") {
command += " --no-use-agent ";
}
}
} catch (ex) {}
return command;
}
Enigmail.prototype.fixExitCode =
function (exitCode, statusFlags) {
if ((this.agentType == "gpg") && (exitCode == 256)) {
WARNING_LOG("enigmail.js: Enigmail.fixExitCode: Using gpg and exit code is 256. You seem to use cygwin-gpg, activating countermeasures.\n");
if (statusFlags & (nsIEnigmail.BAD_PASSPHRASE | nsIEnigmail.UNVERIFIED_SIGNATURE)) {
WARNING_LOG("enigmail.js: Enigmail.fixExitCode: Changing exitCode 256->2\n");
exitCode = 2;
} else {
WARNING_LOG("enigmail.js: Enigmail.fixExitCode: Changing exitCode 256->0\n");
exitCode = 0;
}
}
if (((this.agentVersion >= "1.3") && (this.agentVersion < "1.4.1" )) && (this.isDosLike)) {
if ((exitCode == 2) && (!(statusFlags & (nsIEnigmail.BAD_PASSPHRASE |
nsIEnigmail.UNVERIFIED_SIGNATURE |
nsIEnigmail.MISSING_PASSPHRASE |
nsIEnigmail.BAD_ARMOR |
nsIEnigmail.DECRYPTION_INCOMPLETE |
nsIEnigmail.DECRYPTION_FAILED |
nsIEnigmail.NO_PUBKEY |
nsIEnigmail.NO_SECKEY)))) {
WARNING_LOG("enigmail.js: Enigmail.fixExitCode: Using gpg version "+this.agentVersion+", activating countermeasures for file renaming bug.\n");
exitCode = 0;
}
}
return exitCode;
}
Enigmail.prototype.execCmd =
function (command, passphrase, input, exitCodeObj, statusFlagsObj,
statusMsgObj, errorMsgObj) {
WRITE_LOG("enigmail.js: Enigmail.execCmd: command = "+command+"\n");
if ((typeof input) != "string") input = "";
var prependPassphrase = ((typeof passphrase) == "string");
var envList = [];
envList = envList.concat(gEnvList);
var preInput;
if (prependPassphrase) {
envList.push("PGPPASSFD=0");
preInput = passphrase;
input = "\n" + input;
} else {
preInput = "";
}
var prefix = this.getLogDirectoryPrefix();
if (prefix && (gLogLevel >= 4)) {
if (prependPassphrase) {
// Obscure passphrase
WriteFileContents(prefix+"eniginp.txt", "<passphrase>"+input);
} else {
WriteFileContents(prefix+"eniginp.txt", input);
}
WriteFileContents(prefix+"enigcmd.txt", command.replace(/\\\\/g, "\\")+"\n");
WriteFileContents(prefix+"enigenv.txt", envList.join(",")+"\n");
DEBUG_LOG("enigmail.js: Enigmail.execCmd: copied command line/env/input to files "+prefix+"enigcmd.txt/enigenv.txt/eniginp.txt\n");
}
var outObj = new Object();
var errObj = new Object();
var outLenObj = new Object();
var errLenObj = new Object();
CONSOLE_LOG("\nenigmail> "+command.replace(/\\\\/g, "\\")+"\n");
try {
var useShell = false;
exitCodeObj.value = gEnigmailSvc.ipcService.execPipe(command,
useShell,
preInput,
input, input.length,
envList, envList.length,
outObj, outLenObj,
errObj, errLenObj);
} catch (ex) {
exitCodeObj.value = -1;
}
var outputData = "";
var errOutput = "";
if (outObj.value)
outputData = outObj.value;
if (errObj.value)
errOutput = errObj.value;
if (prefix && (gLogLevel >= 4)) {
WriteFileContents(prefix+"enigout.txt", outputData);
WriteFileContents(prefix+"enigerr.txt", errOutput);
DEBUG_LOG("enigmail.js: Enigmail.execCmd: copied command out/err data to files "+prefix+"enigout.txt/enigerr.txt\n");
}
DEBUG_LOG("enigmail.js: Enigmail.execCmd: exitCode = "+exitCodeObj.value+"\n");
DEBUG_LOG("enigmail.js: Enigmail.execCmd: errOutput = "+errOutput+"\n");
var errLines = errOutput.split(/\r?\n/);
// Discard last null string, if any
if ((errLines.length > 1) && !errLines[errLines.length-1])
errLines.pop();
var errArray = new Array();
var statusArray = new Array();
var statusPat = /^\[GNUPG:\] /;
var statusFlags = 0;
for (var j=0; j<errLines.length; j++) {
if (errLines[j].search(statusPat) == 0) {
var statusLine = errLines[j].replace(statusPat,"");
statusArray.push(statusLine);
var matches = statusLine.match(/^(\w+)\b/);
if (matches && (matches.length > 1)) {
var flag = gStatusFlags[matches[1]];
if (flag == nsIEnigmail.NODATA) {
// Recognize only "NODATA 1"
if (statusLine.search(/NODATA 1\b/) < 0)
flag = 0;
}
if (flag)
statusFlags |= flag;
//DEBUG_LOG("enigmail.js: Enigmail.execCmd: status match "+matches[1]+"\n");
}
} else {
errArray.push(errLines[j]);
}
}
exitCodeObj.value = this.fixExitCode(exitCodeObj.value, statusFlags);
statusFlagsObj.value = statusFlags;
statusMsgObj.value = statusArray.join("\n");
errorMsgObj.value = errArray.join("\n");
CONSOLE_LOG(errorMsgObj.value+"\n");
DEBUG_LOG("enigmail.js: Enigmail.execCmd: statusFlags = "+bytesToHex(pack(statusFlags,4))+"\n");
//DEBUG_LOG("enigmail.js: Enigmail.execCmd: statusMsg = "+statusMsgObj.value+"\n");
this.stillActive();
return outputData;
}
Enigmail.prototype.execStart =
function (command, needPassphrase, domWindow, prompter, listener,
noProxy, statusFlagsObj) {
WRITE_LOG("enigmail.js: Enigmail.execStart: command = "+command+", needPassphrase="+needPassphrase+", domWindow="+domWindow+", prompter="+prompter+", listener="+listener+", noProxy="+noProxy+"\n");
statusFlagsObj.value = 0;
var envList = [];
envList = envList.concat(gEnvList);
var passphrase = null;
var useAgentObj = {value: false};
if (needPassphrase) {
command += this.passwdCommand();
var passwdObj = new Object();
if (!GetPassphrase(domWindow, passwdObj, useAgentObj)) {
ERROR_LOG("enigmail.js: Enigmail.execStart: Error - no passphrase supplied\n");
statusFlagsObj.value |= nsIEnigmail.MISSING_PASSPHRASE;
return null;
}
passphrase = passwdObj.value;
}
var prefix = this.getLogDirectoryPrefix();
if (prefix && (gLogLevel >= 4)) {
WriteFileContents(prefix+"enigcmd.txt", command.replace(/\\\\/g, "\\")+"\n");
WriteFileContents(prefix+"enigenv.txt", envList.join(",")+"\n");
DEBUG_LOG("enigmail.js: Enigmail.execStart: copied command line/env to files "+prefix+"enigcmd.txt/enigenv.txt\n");
}
CONSOLE_LOG("\nenigmail> "+command.replace(/\\\\/g, "\\")+"\n");
var pipetrans = Components.classes[NS_PIPETRANSPORT_CONTRACTID].createInstance();
pipetrans = pipetrans.QueryInterface(Components.interfaces.nsIPipeTransport);
DEBUG_LOG("enigmail.js: Enigmail.execStart: pipetrans = " + pipetrans + "\n");
try {
var ipcBuffer = Components.classes[NS_IPCBUFFER_CONTRACTID].createInstance(Components.interfaces.nsIIPCBuffer);
ipcBuffer.open(ERROR_BUFFER_SIZE, false);
var mergeStderr = false;
pipetrans.initCommand(command, envList, envList.length,
0, "", noProxy, mergeStderr,
ipcBuffer);
if (listener) {
pipetrans.asyncRead(listener, null, 0, -1, 0);
}
if (needPassphrase && ! useAgentObj.value) {
// Write to child STDIN
// (ignore errors, because child may have exited already, closing STDIN)
try {
if (passphrase) {
pipetrans.writeSync(passphrase, passphrase.length);
}
pipetrans.writeSync("\n", 1);
} catch (ex) {}
}
return pipetrans;
} catch (ex) {
CONSOLE_LOG("enigmail.js: Enigmail.execStart: Error - Failed to start PipeTransport\n");
return null;
}
}
Enigmail.prototype.parseErrorOutput =
function (errOutput, statusFlagsObj, statusMsgObj) {
WRITE_LOG("enigmail.js: Enigmail.parseErrorOutput: \n");
var errLines = errOutput.split(/\r?\n/);
// Discard last null string, if any
if ((errLines.length > 1) && !errLines[errLines.length-1])
errLines.pop();
var errArray = new Array();
var statusArray = new Array();
var statusPat = /^\[GNUPG:\] /;
var statusFlags = 0;
for (var j=0; j<errLines.length; j++) {
if (errLines[j].search(statusPat) == 0) {
var statusLine = errLines[j].replace(statusPat,"");
statusArray.push(statusLine);
var matches = statusLine.match(/^(\w+)\b/);
if (matches && (matches.length > 1)) {
var flag = gStatusFlags[matches[1]];
if (flag == nsIEnigmail.NODATA) {
// Recognize only "NODATA 1"
if (statusLine.search(/NODATA 1\b/) < 0)
flag = 0;
}
if (flag)
statusFlags |= flag;
//DEBUG_LOG("enigmail.js: Enigmail.parseErrorOutput: status match '+matches[1]+"\n");
}
} else {
errArray.push(errLines[j]);
}
}
statusFlagsObj.value = statusFlags;
statusMsgObj.value = statusArray.join("\n");
var errorMsg = errArray.join("\n");
DEBUG_LOG("enigmail.js: Enigmail.parseErrorOutput: statusFlags = "+bytesToHex(pack(statusFlags,4))+"\n");
//DEBUG_LOG("enigmail.js: Enigmail.parseErrorOutput: statusMsg = "+statusMsgObj.value+"\n");
return errorMsg;
}
Enigmail.prototype.execEnd =
function (pipeTransport, statusFlagsObj, statusMsgObj, cmdLineObj, errorMsgObj) {
WRITE_LOG("enigmail.js: Enigmail.execEnd: \n");
// Extract command line
try {
var request = pipeTransport.QueryInterface(Components.interfaces.nsIRequest);
cmdLineObj.value = request.name;
} catch (ex) {
cmdLineObj.value = "unknown-command";
}
// Extract exit code and error output from pipeTransport
var exitCode = pipeTransport.exitCode();
var errListener = pipeTransport.console;
var errOutput = errListener.getData();
// Terminate pipeTransport
errListener.shutdown();
pipeTransport.terminate();
var prefix = this.getLogDirectoryPrefix();
if (prefix && (gLogLevel >= 4)) {
WriteFileContents(prefix+"enigerr.txt", errOutput);
DEBUG_LOG("enigmail.js: Enigmail.execEnd: copied command err output to file "+prefix+"enigerr.txt\n");
}
DEBUG_LOG("enigmail.js: Enigmail.execEnd: exitCode = "+exitCode+"\n");
DEBUG_LOG("enigmail.js: Enigmail.execEnd: errOutput = "+errOutput+"\n");
var errLines = errOutput.split(/\r?\n/);
// Discard last null string, if any
if ((errLines.length > 1) && !errLines[errLines.length-1])
errLines.pop();
var errArray = new Array();
var statusArray = new Array();
var statusPat = /^\[GNUPG:\] /;
var statusFlags = 0;
for (var j=0; j<errLines.length; j++) {
if (errLines[j].search(statusPat) == 0) {
var statusLine = errLines[j].replace(statusPat,"");
statusArray.push(statusLine);
var matches = statusLine.match(/^(\w+)\b/);
if (matches && (matches.length > 1)) {
var flag = gStatusFlags[matches[1]];
if (flag == nsIEnigmail.NODATA) {
// Recognize only "NODATA 1"
if (statusLine.search(/NODATA 1\b/) < 0)
flag = 0;
}
if (flag)
statusFlags |= flag;
//DEBUG_LOG("enigmail.js: Enigmail.execEnd: status match '+matches[1]+"\n");
}
} else {
errArray.push(errLines[j]);
}
}
if (errOutput.search(/jpeg image of size \d+/)>-1) {
statusFlags |= nsIEnigmail.PHOTO_AVAILABLE;
}
statusFlagsObj.value = statusFlags;
statusMsgObj.value = statusArray.join("\n");
errorMsgObj.value = errArray.join("\n");
CONSOLE_LOG(errorMsgObj.value+"\n");
DEBUG_LOG("enigmail.js: Enigmail.execEnd: statusFlags = "+bytesToHex(pack(statusFlags,4))+"\n");
//DEBUG_LOG("enigmail.js: Enigmail.execEnd: statusMsg = "+statusMsgObj.value+"\n");
this.stillActive();
return exitCode;
}
// Remove all quoted strings (and angle brackets) from a list of email
// addresses, returning a list of pure email address
function EnigStripEmail(mailAddrs) {
var qStart, qEnd;
while ((qStart = mailAddrs.indexOf('"')) != -1) {
qEnd = mailAddrs.indexOf('"', qStart+1);
if (qEnd == -1) {
ERROR_LOG("enigmail.js: EnigStripEmail: Unmatched quote in mail address: "+mailAddrs+"\n");
mailAddrs=mailAddrs.replace(/\"/g, "");
break;
}
mailAddrs = mailAddrs.substring(0,qStart) + mailAddrs.substring(qEnd+1);
}
// Eliminate all whitespace, just to be safe
mailAddrs = mailAddrs.replace(/\s+/g,"");
// Extract pure e-mail address list (stripping out angle brackets)
mailAddrs = mailAddrs.replace(/(^|,)[^,]*<([^>]+)>[^,]*/g,"$1$2");
return mailAddrs;
}
Enigmail.prototype.stripWhitespace = function(sendFlags) {
var stripThem=false;
if ((sendFlags & nsIEnigmail.SEND_SIGNED) &&
(!(sendFlags & nsIEnigmail.SEND_ENCRYPTED))) {
if (this.agentVersion >= "1.4.0" && this.agentVersion < "1.4.1") {
stripThem = true;
}
}
return stripThem;
}
Enigmail.prototype.encryptMessage =
function (parent, uiFlags, plainText, fromMailAddr, toMailAddr,
sendFlags, exitCodeObj, statusFlagsObj, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.encryptMessage: "+plainText.length+" bytes from "+fromMailAddr+" to "+toMailAddr+" ("+sendFlags+")\n");
exitCodeObj.value = -1;
statusFlagsObj.value = 0;
errorMsgObj.value = "";
if (!plainText) {
DEBUG_LOG("enigmail.js: Enigmail.encryptMessage: NO ENCRYPTION!\n");
exitCodeObj.value = 0;
return plainText;
}
if (!this.initialized) {
errorMsgObj.value = EnigGetString("notInit");
return "";
}
var defaultSend = sendFlags & nsIEnigmail.SEND_DEFAULT;
var signMsg = sendFlags & nsIEnigmail.SEND_SIGNED;
var encryptMsg = sendFlags & nsIEnigmail.SEND_ENCRYPTED;
if (encryptMsg) {
// First convert all linebreaks to newlines
plainText = plainText.replace(/\r\n/g, "\n");
plainText = plainText.replace(/\r/g, "\n");
// Using platform-specific linebreaks confuses some windows mail clients,
// so we convert everything to windows like good old PGP worked anyway.
plainText = plainText.replace(/\n/g, "\r\n");
}
var noProxy = true;
var startErrorMsgObj = new Object();
var ipcBuffer = Components.classes[NS_IPCBUFFER_CONTRACTID].createInstance(Components.interfaces.nsIIPCBuffer);
var bufferSize = ((plainText.length + 20000)/1024).toFixed(0)*1024;
if (MSG_BUFFER_SIZE > bufferSize)
bufferSize=MSG_BUFFER_SIZE;
ipcBuffer.open(bufferSize, false);
var pipeTrans = this.encryptMessageStart(parent, null, uiFlags,
fromMailAddr, toMailAddr,
"", sendFlags, ipcBuffer,
noProxy, startErrorMsgObj);
if (!pipeTrans) {
errorMsgObj.value = startErrorMsgObj.value;
return "";
}
// Write to child STDIN
// (ignore errors, because child may have exited already, closing STDIN)
try {
pipeTrans.writeSync(plainText, plainText.length);
} catch (ex) {}
// Wait for child STDOUT to close
pipeTrans.join();
var cipherText = ipcBuffer.getData();
ipcBuffer.shutdown();
var exitCode = this.encryptMessageEnd(parent, null, uiFlags, sendFlags,
plainText.length, pipeTrans,
statusFlagsObj, errorMsgObj);
exitCodeObj.value = exitCode;
if ((exitCodeObj.value == 0) && !cipherText)
exitCodeObj.value = -1;
if (exitCodeObj.value == 0) {
// Normal return
return cipherText;
}
// Error processing
ERROR_LOG("enigmail.js: Enigmail.encryptMessage: Error in command execution\n");
return "";
}
Enigmail.prototype.encryptMessageEnd =
function (parent, prompter, uiFlags, sendFlags, outputLen, pipeTransport,
statusFlagsObj, errorMsgObj)
{
DEBUG_LOG("enigmail.js: Enigmail.encryptMessageEnd: uiFlags="+uiFlags+", sendFlags="+bytesToHex(pack(sendFlags,4))+", outputLen="+outputLen+", pipeTransport="+pipeTransport+"\n");
var pgpMime = uiFlags & nsIEnigmail.UI_PGP_MIME;
statusFlagsObj.value = 0;
errorMsgObj.value = "";
if (!this.initialized) {
errorMsgObj.value = EnigGetString("notInit");
return -1;
}
// Terminate job and parse error output
var statusMsgObj = new Object();
var cmdLineObj = new Object();
var cmdErrorMsgObj = new Object();
var exitCode = this.execEnd(pipeTransport, statusFlagsObj, statusMsgObj, cmdLineObj, cmdErrorMsgObj);
var statusMsg = statusMsgObj.value;
exitCode = this.fixExitCode(exitCode, statusFlagsObj.value);
if ((exitCode == 0) && !outputLen) {
exitCode = -1;
}
if (exitCode == 0) {
// Normal return
errorMsgObj.value = cmdErrorMsgObj.value;
return 0;
}
// Error processing
ERROR_LOG("enigmail.js: Enigmail.encryptMessageEnd: Error in command execution\n");
var defaultSend = sendFlags & nsIEnigmail.SEND_DEFAULT;
var signMsg = sendFlags & nsIEnigmail.SEND_SIGNED;
var encryptMsg = sendFlags & nsIEnigmail.SEND_ENCRYPTED;
if ( (statusFlagsObj.value & nsIEnigmail.BAD_PASSPHRASE) ||
((this.agentType == "pgp") && signMsg && (exitCode != 21)) ) {
// "Unremember" passphrase on error return
this.clearCachedPassphrase();
}
if (statusFlagsObj.value & nsIEnigmail.BAD_PASSPHRASE) {
errorMsgObj.value = EnigGetString("badPhrase");
}
else if (statusFlagsObj.value & nsIEnigmail.INVALID_RECIPIENT) {
errorMsgObj.value = statusMsg;
}
else {
errorMsgObj.value = EnigGetString("badCommand");
}
if (cmdErrorMsgObj.value) {
errorMsgObj.value += "\n\n" + this.agentType + " "+EnigGetString("cmdLine");
errorMsgObj.value += "\n" + cmdLineObj.value;
errorMsgObj.value += "\n" + cmdErrorMsgObj.value;
}
if (pgpMime && errorMsgObj.value) {
if (prompter)
prompter.alert(EnigGetString("enigAlert"), errorMsgObj.value);
else
this.alertMsg(parent, errorMsgObj.value);
}
return exitCode;
}
var gPGPHashNum = {md5:1, sha1:2, ripemd160:3, sha256:4, sha384:5, sha512:6};
Enigmail.prototype.getEncryptCommand =
function (fromMailAddr, toMailAddr, hashAlgorithm, sendFlags, isAscii, errorMsgObj) {
try {
fromMailAddr = EnigStripEmail(fromMailAddr);
toMailAddr = EnigStripEmail(toMailAddr);
} catch (ex) {
errorMsgObj.value = EnigGetString("invalidEmail");
return null;
}
var defaultSend = sendFlags & nsIEnigmail.SEND_DEFAULT;
var signMsg = sendFlags & nsIEnigmail.SEND_SIGNED;
var encryptMsg = sendFlags & nsIEnigmail.SEND_ENCRYPTED;
var usePgpMime = sendFlags & nsIEnigmail.SEND_PGP_MIME;
var useDefaultComment = false;
try {
useDefaultComment = this.prefBranch.getBoolPref("useDefaultComment")
} catch(ex) { }
var hushMailSupport = false;
try {
hushMailSupport = this.prefBranch.getBoolPref("hushMailSupport")
} catch(ex) { }
var detachedSig = usePgpMime && signMsg && !encryptMsg;
var toAddrList = toMailAddr.split(/\s*,\s*/);
var k;
var encryptCommand = this.getAgentPath();
if (this.agentType == "pgp") {
encryptCommand += PGP_BATCH_OPTS + " -fta "
if (encryptMsg) {
encryptCommand += " -e";
if (signMsg)
encryptCommand += " -s";
if ((sendFlags & nsIEnigmail.SEND_ENCRYPT_TO_SELF) && fromMailAddr)
encryptCommand += " +encrypttoself=on";
for (k=0; k<toAddrList.length; k++)
encryptCommand += " "+toAddrList[k];
} else if (detachedSig) {
encryptCommand += " -sb";
if (hashAlgorithm && gPGPHashNum[hashAlgorithm.toLowerCase()])
encryptCommand += " +hashnum=" + gPGPHashNum[hashAlgorithm];
} else if (signMsg) {
encryptCommand += " -s";
}
if (fromMailAddr) {
encryptCommand += " +myname=" + fromMailAddr;
}
} else {
encryptCommand += GPG_BATCH_OPTS;
if (!useDefaultComment)
encryptCommand += " --comment "+this.quoteSign+GPG_COMMENT_OPT.replace(/\%s/, this.vendor)+this.quoteSign;
/*
if (usePgpMime && (! encryptMsg)) {
if (this.agentVersion >= "1.4.1") {
//encryptCommand += " --rfc2440-dshaw"
}
}
*/
var angledFromMailAddr = ((fromMailAddr.search(/^0x/) == 0) || hushMailSupport)
? fromMailAddr : "<" + fromMailAddr + ">";
angledFromMailAddr = angledFromMailAddr.replace(/([\"\'\`])/g, "\\$1");
if (encryptMsg) {
if (isAscii)
encryptCommand += " -a";
encryptCommand += " -e";
if (signMsg)
encryptCommand += " -s";
if (sendFlags & nsIEnigmail.SEND_ALWAYS_TRUST) {
if (this.agentVersion >= "1.4") {
encryptCommand += " --trust-model always"
}
else {
encryptCommand += " --always-trust";
}
}
if ((sendFlags & nsIEnigmail.SEND_ENCRYPT_TO_SELF) && fromMailAddr)
encryptCommand += " --encrypt-to " + angledFromMailAddr;
for (k=0; k<toAddrList.length; k++) {
toAddrList[k] = toAddrList[k].replace(/\'/g, "\\'");
encryptCommand += (hushMailSupport || (toAddrList[k].search(/^0x/) == 0)) ? " -r "+ toAddrList[k]
:" -r <" + toAddrList[k] + ">";
}
} else if (detachedSig) {
encryptCommand += " -s -b -t";
if (isAscii)
encryptCommand += " -a";
if (hashAlgorithm) {
encryptCommand += " --digest-algo "+hashAlgorithm;
}
} else if (signMsg) {
encryptCommand += " --clearsign";
if (hashAlgorithm) {
encryptCommand += " --digest-algo "+hashAlgorithm;
}
}
if (fromMailAddr) {
encryptCommand += " -u " + angledFromMailAddr;
}
}
return encryptCommand;
}
Enigmail.prototype.encryptMessageStart =
function (parent, prompter, uiFlags, fromMailAddr, toMailAddr,
hashAlgorithm, sendFlags, listener, noProxy, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.encryptMessageStart: prompter="+prompter+", uiFlags="+uiFlags+", from "+fromMailAddr+" to "+toMailAddr+", hashAlgorithm="+hashAlgorithm+" ("+bytesToHex(pack(sendFlags,4))+")\n");
var pgpMime = uiFlags & nsIEnigmail.UI_PGP_MIME;
if (uiFlags & nsIEnigmail.UI_RESTORE_STRICTLY_MIME) {
try {
var prefSvc = Components.classes[NS_PREFS_SERVICE_CID]
.getService(Components.interfaces.nsIPrefService);
var prefRoot = prefSvc.getBranch(null);
prefRoot.setBoolPref("mail.strictly_mime", false);
DEBUG_LOG("enigmail.js: Enigmail.encryptMessageStart: disabled quoted-printable\n");
}
catch (ex) {}
}
errorMsgObj.value = "";
if (!sendFlags) {
DEBUG_LOG("enigmail.js: Enigmail.encryptMessageStart: NO ENCRYPTION!\n");
errorMsgObj.value = EnigGetString("notRequired");
return null;
}
if (!this.initialized) {
errorMsgObj.value = EnigGetString("notInit");
return null;
}
if (this.keygenProcess) {
errorMsgObj.value = EnigGetString("notComplete");
return null;
}
var encryptCommand = this.getEncryptCommand(fromMailAddr, toMailAddr, hashAlgorithm, sendFlags, true, errorMsgObj);
if (! encryptCommand)
return null;
var signMsg = sendFlags & nsIEnigmail.SEND_SIGNED;
var statusFlagsObj = new Object();
var pipetrans = this.execStart(encryptCommand, signMsg, parent, prompter,
listener, noProxy, statusFlagsObj);
if (statusFlagsObj.value & nsIEnigmail.MISSING_PASSPHRASE) {
ERROR_LOG("enigmail.js: Enigmail.encryptMessageStart: Error - no passphrase supplied\n");
errorMsgObj.value = EnigGetString("noPassphrase");
}
if (pgpMime && errorMsgObj.value) {
if (prompter)
prompter.alert(EnigGetString("enigAlert"), errorMsgObj.value);
else
this.alertMsg(parent, errorMsgObj.value);
}
return pipetrans;
}
// Locates STRing in TEXT occurring only at the beginning of a line
function IndexOfArmorDelimiter(text, str, offset) {
//DEBUG_LOG("enigmail.js: IndexOfArmorDelimiter: "+str+", "+offset+"\n");
while (offset < text.length) {
var loc = text.indexOf(str, offset);
if ((loc < 1) || (text.charAt(loc-1) == "\n"))
return loc;
offset = loc + str.length;
}
return -1;
}
// Locates offsets bracketing PGP armored block in text,
// starting from given offset, and returns block type string.
// beginIndex = offset of first character of block
// endIndex = offset of last character of block (newline)
// If block is not found, the null string is returned;
Enigmail.prototype.locateArmoredBlock =
function (text, offset, indentStr, beginIndexObj, endIndexObj,
indentStrObj) {
DEBUG_LOG("enigmail.js: Enigmail.locateArmoredBlock: "+offset+", '"+indentStr+"'\n");
beginIndexObj.value = -1;
endIndexObj.value = -1;
var beginIndex = IndexOfArmorDelimiter(text, indentStr+"-----BEGIN PGP ", offset);
if (beginIndex == -1) {
var blockStart=text.indexOf("-----BEGIN PGP ")
if (blockStart>=0) {
var indentStart=text.search(/\n.*\-\-\-\-\-BEGIN PGP /)+1;
indentStrObj.value=text.substring(indentStart, blockStart);
indentStr=indentStrObj.value;
beginIndex = IndexOfArmorDelimiter(text, indentStr+"-----BEGIN PGP ", offset);
}
}
if (beginIndex == -1)
return "";
// Locate newline at end of armor header
offset = text.indexOf("\n", beginIndex);
if (offset == -1)
return "";
var endIndex = IndexOfArmorDelimiter(text, indentStr+"-----END PGP ", offset);
if (endIndex == -1)
return "";
// Locate newline at end of PGP block
endIndex = text.indexOf("\n", endIndex);
if (endIndex == -1) {
// No terminating newline
endIndex = text.length - 1;
}
var blockHeader = text.substr(beginIndex, offset-beginIndex+1);
var blockRegex = new RegExp("^" + indentStr +
"-----BEGIN PGP (.*)-----\\s*\\r?\\n");
var matches = blockHeader.match(blockRegex);
var blockType = "";
if (matches && (matches.length > 1)) {
blockType = matches[1];
DEBUG_LOG("enigmail.js: Enigmail.locateArmoredBlock: blockType="+blockType+"\n");
}
if (blockType == "UNVERIFIED MESSAGE") {
// Skip any unverified message block
return this.locateArmoredBlock(text, endIndex+1, indentStr,
beginIndexObj, endIndexObj, indentStrObj);
}
beginIndexObj.value = beginIndex;
endIndexObj.value = endIndex;
return blockType;
}
Enigmail.prototype.extractSignaturePart =
function (signatureBlock, part) {
DEBUG_LOG("enigmail.js: Enigmail.extractSignaturePart: part="+part+"\n");
// Search for blank line
var offset = signatureBlock.search(/\n\s*\r?\n/);
if (offset == -1)
return "";
offset = signatureBlock.indexOf("\n", offset+1);
if (offset == -1)
return "";
var beginIndex = signatureBlock.indexOf("-----BEGIN PGP SIGNATURE-----",
offset+1);
if (beginIndex == -1)
return "";
if (part == nsIEnigmail.SIGNATURE_TEXT) {
var signedText = signatureBlock.substr(offset+1, beginIndex-offset-1);
// Unescape leading dashes
signedText = signedText.replace(/^- -/, "-");
signedText = signedText.replace(/\n- -/g, "\n-");
signedText = signedText.replace(/\r- -/g, "\r-");
return signedText;
}
// Locate newline at end of armor header
offset = signatureBlock.indexOf("\n", beginIndex);
if (offset == -1)
return "";
var endIndex = signatureBlock.indexOf("-----END PGP SIGNATURE-----", offset);
if (endIndex == -1)
return "";
var signBlock = signatureBlock.substr(offset, endIndex-offset);
// Search for blank line
var armorIndex = signBlock.search(/\n\s*\r?\n/);
if (armorIndex == -1)
return "";
if (part == nsIEnigmail.SIGNATURE_HEADERS) {
return signBlock.substr(1, armorIndex);
}
armorIndex = signBlock.indexOf("\n", armorIndex+1);
if (armorIndex == -1)
return "";
if (part == nsIEnigmail.SIGNATURE_ARMOR) {
var armorData = signBlock.substr(armorIndex, endIndex-armorIndex);
armorData = armorData.replace(/\s*/g, "");
return armorData;
}
return "";
}
Enigmail.prototype.decryptMessage =
function (parent, uiFlags, cipherText, signatureObj, exitCodeObj,
statusFlagsObj, keyIdObj, userIdObj, sigDetailsObj, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.decryptMessage: "+cipherText.length+" bytes, "+uiFlags+"\n");
if (! cipherText)
return "";
var interactive = uiFlags & nsIEnigmail.UI_INTERACTIVE;
var allowImport = uiFlags & nsIEnigmail.UI_ALLOW_KEY_IMPORT;
var unverifiedEncryptedOK = uiFlags & nsIEnigmail.UI_UNVERIFIED_ENC_OK;
var oldSignature = signatureObj.value;
DEBUG_LOG("enigmail.js: Enigmail.decryptMessage: oldSignature="+oldSignature+"\n");
signatureObj.value = "";
exitCodeObj.value = -1;
statusFlagsObj.value = 0;
keyIdObj.value = "";
userIdObj.value = "";
errorMsgObj.value = "";
var beginIndexObj = new Object();
var endIndexObj = new Object();
var indentStrObj = new Object();
var blockType = this.locateArmoredBlock(cipherText, 0, "",
beginIndexObj, endIndexObj, indentStrObj);
if (!blockType || blockType == "SIGNATURE") {
errorMsgObj.value = EnigGetString("noPGPblock");
statusFlagsObj.value |= nsIEnigmail.DISPLAY_MESSAGE;
return "";
}
var publicKey = (blockType == "PUBLIC KEY BLOCK");
var verifyOnly = (blockType == "SIGNED MESSAGE");
var pgpBlock = cipherText.substr(beginIndexObj.value,
endIndexObj.value - beginIndexObj.value + 1);
if (indentStrObj.value) {
RegExp.multiline = true;
var indentRegexp = new RegExp("^"+indentStrObj.value, "g");
pgpBlock = pgpBlock.replace(indentRegexp, "");
RegExp.multiline = false;
}
var head = cipherText.substr(0, beginIndexObj.value);
var tail = cipherText.substr(endIndexObj.value+1,
cipherText.length - endIndexObj.value - 1);
if (publicKey) {
if (!allowImport) {
errorMsgObj.value = EnigGetString("decryptToImport");
statusFlagsObj.value |= nsIEnigmail.DISPLAY_MESSAGE;
statusFlagsObj.value |= nsIEnigmail.INLINE_KEY;
return "";
}
// Import public key
var importFlags = nsIEnigmail.UI_INTERACTIVE;
exitCodeObj.value = this.importKey(parent, importFlags, pgpBlock, "",
errorMsgObj);
if (exitCodeObj.value == 0) {
statusFlagsObj.value |= nsIEnigmail.IMPORTED_KEY;
}
return "";
}
var newSignature = "";
if (verifyOnly) {
newSignature = this.extractSignaturePart(pgpBlock,
nsIEnigmail.SIGNATURE_ARMOR);
if (oldSignature && (newSignature != oldSignature)) {
ERROR_LOG("enigmail.js: Enigmail.decryptMessage: Error - signature mismatch "+newSignature+"\n");
errorMsgObj.value = EnigGetString("sigMismatch");
statusFlagsObj.value |= nsIEnigmail.DISPLAY_MESSAGE;
return "";
}
}
var noOutput = false;
var noProxy = true;
var startErrorMsgObj = new Object();
var readBytes = MSG_BUFFER_SIZE;
if (verifyOnly && pgpBlock.length > MSG_BUFFER_SIZE) {
readBytes = ((pgpBlock.length+1500)/1024).toFixed(0)*1024;
}
if (readBytes > MAX_MSG_BUFFER_SIZE) {
errorMsgObj.value = EnigGetString("messageSizeError");
statusFlagsObj.value |= nsIEnigmail.OVERFLOWED;
exitCodeObj.value = 1;
return "";
}
const maxTries = 2;
var tryCount = 0;
while (tryCount < maxTries) {
tryCount++;
var ipcBuffer = Components.classes[NS_IPCBUFFER_CONTRACTID].createInstance(Components.interfaces.nsIIPCBuffer);
ipcBuffer.open(readBytes, false);
var pipeTrans = this.decryptMessageStart(parent, null, verifyOnly, noOutput,
ipcBuffer, noProxy, startErrorMsgObj);
if (!pipeTrans) {
errorMsgObj.value = startErrorMsgObj.value;
statusFlagsObj.value |= nsIEnigmail.DISPLAY_MESSAGE;
return "";
}
// Write to child STDIN
// (ignore errors, because child may have exited already, closing STDIN)
try {
pipeTrans.writeSync(pgpBlock, pgpBlock.length);
} catch (ex) {}
// Wait for child STDOUT to close
pipeTrans.join();
var overflowed = ipcBuffer.overflowed;
var plainText = ipcBuffer.getData();
if (ipcBuffer.overflowed && plainText.length < ipcBuffer.totalBytes) {
readBytes = ((ipcBuffer.totalBytes+1500)/1024).toFixed(0)*1024;
WRITE_LOG("enigmail.js: Enigmail.decryptMessage: decrypted text too big for standard buffer, retrying with buffer size="+readBytes+"\n");
}
else {
tryCount = maxTries;
}
ipcBuffer.shutdown();
ipcBuffer = null; // make sure the object gets freed
var exitCode = this.decryptMessageEnd(uiFlags, plainText.length, pipeTrans,
verifyOnly, noOutput,
statusFlagsObj, keyIdObj, userIdObj, sigDetailsObj,
errorMsgObj);
exitCodeObj.value = exitCode;
}
if ((head.search(/\S/) >= 0) ||
(tail.search(/\S/) >= 0)) {
statusFlagsObj.value |= nsIEnigmail.PARTIALLY_PGP;
}
if (exitCodeObj.value == 0) {
// Normal return
var doubleDashSeparator = false;
try {
doubleDashSeparator = this.prefBranch.getBoolPref("doubleDashSeparator")
} catch(ex) { }
if (doubleDashSeparator && (plainText.search(/(\r|\n)-- +(\r|\n)/) < 0) ) {
// Workaround for MsgCompose stripping trailing spaces from sig separator
plainText = plainText.replace(/(\r|\n)--(\r|\n)/, "$1-- $2");
}
statusFlagsObj.value |= nsIEnigmail.DISPLAY_MESSAGE;
if (verifyOnly && indentStrObj.value) {
RegExp.multiline = true;
plainText = plainText.replace(/^/g, indentStrObj.value)
RegExp.multiline = false;
}
return plainText;
}
var pubKeyId = keyIdObj.value;
if (statusFlagsObj.value & nsIEnigmail.BAD_SIGNATURE) {
if (verifyOnly && indentStrObj.value) {
// Probably replied message that could not be verified
errorMsgObj.value = EnigGetString("unverifiedReply")+"\n\n"+errorMsgObj.value;
return "";
}
// Return bad signature (for checking later)
signatureObj.value = newSignature;
} else if (pubKeyId &&
(statusFlagsObj.value & nsIEnigmail.UNVERIFIED_SIGNATURE)) {
var innerKeyBlock;
if (verifyOnly) {
// Search for indented public key block in signed message
var innerBlockType = this.locateArmoredBlock(pgpBlock, 0, "- ",
beginIndexObj, endIndexObj,
indentStrObj);
if (innerBlockType == "PUBLIC KEY BLOCK") {
innerKeyBlock = pgpBlock.substr(beginIndexObj.value,
endIndexObj.value - beginIndexObj.value + 1);
innerKeyBlock = innerKeyBlock.replace(/- -----/g, "-----");
statusFlagsObj.value |= nsIEnigmail.INLINE_KEY;
DEBUG_LOG("enigmail.js: Enigmail.decryptMessage: innerKeyBlock found\n");
}
}
if (allowImport) {
var importedKey = false;
if (innerKeyBlock) {
var importErrorMsgObj = new Object();
var importFlags2 = nsIEnigmail.UI_INTERACTIVE;
var exitStatus = this.importKey(parent, importFlags2, innerKeyBlock,
pubKeyId, importErrorMsgObj);
importedKey = (exitStatus == 0);
if (exitStatus > 0) {
this.alertMsg(parent, EnigGetString("cantImport")+importErrorMsgObj.value);
}
}
if (importedKey) {
// Recursive call; note that nsIEnigmail.UI_ALLOW_KEY_IMPORT is unset
// to break the recursion
var uiFlagsDeep = interactive ? nsIEnigmail.UI_INTERACTIVE : 0;
signatureObj.value = "";
return this.decryptMessage(parent, uiFlagsDeep, pgpBlock,
signatureObj, exitCodeObj, statusFlagsObj,
keyIdObj, userIdObj, sigDetailsObj, errorMsgObj);
}
}
if (plainText && !unverifiedEncryptedOK) {
// Append original PGP block to unverified message
plainText = "-----BEGIN PGP UNVERIFIED MESSAGE-----\r\n" + plainText +
"-----END PGP UNVERIFIED MESSAGE-----\r\n\r\n" + pgpBlock;
}
}
return verifyOnly ? "" : plainText;
}
Enigmail.prototype.decryptMessageStart =
function (parent, prompter, verifyOnly, noOutput,
listener, noProxy, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.decryptMessageStart: prompter="+prompter+", verifyOnly="+verifyOnly+", noOutput="+noOutput+"\n");
if (!this.initialized) {
errorMsgObj.value = EnigGetString("notInit");
return null;
}
if (this.keygenProcess) {
errorMsgObj.value = EnigGetString("notComplete");
return null;
}
var decryptCommand = this.getAgentPath();
if (this.agentType == "pgp") {
decryptCommand += PGP_BATCH_OPTS + " -ft";
} else if (noOutput) {
decryptCommand += GPG_BATCH_OPTS + " --verify";
} else {
decryptCommand += GPG_BATCH_OPTS + " -d";
}
var statusFlagsObj = new Object();
var pipetrans = this.execStart(decryptCommand, !verifyOnly, parent, prompter,
listener, noProxy, statusFlagsObj);
if (statusFlagsObj.value & nsIEnigmail.MISSING_PASSPHRASE) {
ERROR_LOG("enigmail.js: Enigmail.decryptMessageStart: Error - no passphrase supplied\n");
errorMsgObj.value = EnigGetString("noPassphrase");
return null;
}
return pipetrans;
}
Enigmail.prototype.decryptMessageEnd =
function (uiFlags, outputLen, pipeTransport, verifyOnly, noOutput,
statusFlagsObj, keyIdObj, userIdObj, sigDetailsObj, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.decryptMessageEnd: uiFlags="+uiFlags+", outputLen="+outputLen+", pipeTransport="+pipeTransport+", verifyOnly="+verifyOnly+", noOutput="+noOutput+"\n");
var interactive = uiFlags & nsIEnigmail.UI_INTERACTIVE;
var pgpMime = uiFlags & nsIEnigmail.UI_PGP_MIME;
var allowImport = uiFlags & nsIEnigmail.UI_ALLOW_KEY_IMPORT;
var unverifiedEncryptedOK = uiFlags & nsIEnigmail.UI_UNVERIFIED_ENC_OK;
statusFlagsObj.value = 0;
errorMsgObj.value = "";
if (!this.initialized) {
errorMsgObj.value = EnigGetString("notInit");
return -1;
}
// Terminate job and parse error output
var statusMsgObj = new Object();
var cmdLineObj = new Object();
var cmdErrorMsgObj = new Object();
var exitCode = this.execEnd(pipeTransport, statusFlagsObj, statusMsgObj, cmdLineObj, cmdErrorMsgObj);
if (pgpMime) {
statusFlagsObj.value |= verifyOnly ? nsIEnigmail.PGP_MIME_SIGNED
: nsIEnigmail.PGP_MIME_ENCRYPTED;
}
var statusMsg = statusMsgObj.value;
exitCode = this.fixExitCode(exitCode, statusFlagsObj.value);
if ((exitCode == 0) && !noOutput && !outputLen) {
exitCode = -1;
}
if (exitCode == 0) {
// Normal return
var errLines, goodSignPat, badSignPat, keyExpPat;
if (statusMsg) {
errLines = statusMsg.split(/\r?\n/);
goodSignPat = /GOODSIG (\w{16}) (.*)$/i;
badSignPat = /BADSIG (\w{16}) (.*)$/i;
keyExpPat = /EXPKEYSIG (\w{16}) (.*)$/i
revKeyPat = /REVKEYSIG (\w{16}) (.*)$/i;
validSigPat = /VALIDSIG (\w+) (.*) (\d+) (.*)/i;
} else {
errLines = cmdErrorMsgObj.value.split(/\r?\n/);
goodSignPat = /Good signature from (user )?"(.*)"\.?/i;
badSignPat = /BAD signature from (user )?"(.*)"\.?/i;
keyExpPat = /This key has expired/i;
revKeyPat = /This key has been revoked/i;
validSigPat = /dummy-not-used/i;
}
errorMsgObj.value = "";
var matches;
var signed = false;
var goodSignature;
var userId = "";
var keyId = "";
var sigDetails = "";
for (j=0; j<errLines.length; j++) {
matches = errLines[j].match(badSignPat);
if (matches && (matches.length > 2)) {
signed = true;
goodSignature = false;
userId = matches[2];
keyId = matches[1];
break;
}
matches = errLines[j].match(revKeyPat);
if (matches && (matches.length > 2)) {
signed = true;
goodSignature = true;
userId = matches[2];
keyId = matches[1];
break;
}
matches = errLines[j].match(goodSignPat);
if (matches && (matches.length > 2)) {
signed = true;
goodSignature = true;
userId = matches[2];
keyId = matches[1];
break;
}
matches = errLines[j].match(keyExpPat);
if (matches && (matches.length > 2)) {
signed = true;
goodSignature = true;
userId = matches[2];
keyId = matches[1];
break;
}
}
if (goodSignature) {
for (var j=0; j<errLines.length; j++) {
matches = errLines[j].match(validSigPat);
if (matches && (matches.length > 2)) {
sigDetails = errLines[j].substr(9);
break;
}
}
}
try {
if (userId && keyId && this.prefBranch.getBoolPref("displaySecondaryUid")) {
uids = this.getKeyDetails(keyId, true);
if (uids) {
userId = uids;
}
}
}
catch (ex) {}
if (userId) {
userId = EnigConvertToUnicode(userId, "UTF-8");
}
userIdObj.value = userId;
keyIdObj.value = keyId;
sigDetailsObj.value = sigDetails;
if (signed) {
var trustPrefix = "";
if (statusFlagsObj.value & nsIEnigmail.UNTRUSTED_IDENTITY) {
trustPrefix += EnigGetString("prefUntrusted")+" ";
}
if (statusFlagsObj.value & nsIEnigmail.REVOKED_KEY) {
trustPrefix += EnigGetString("prefRevoked")+" ";
}
if (statusFlagsObj.value & nsIEnigmail.EXPIRED_KEY_SIGNATURE) {
trustPrefix += EnigGetString("prefExpiredKey")+" ";
} else if (statusFlagsObj.value & nsIEnigmail.EXPIRED_SIGNATURE) {
trustPrefix += EnigGetString("prefExpired")+" ";
}
if (goodSignature) {
errorMsgObj.value = trustPrefix + EnigGetString("prefGood",userId) /* + ", " +
EnigGetString("keyId") + " 0x" + keyId.substring(8,16); */
if (this.agentType != "gpg") {
// Trust all good signatures, if not GPG
statusFlagsObj.value |= nsIEnigmail.GOOD_SIGNATURE | nsIEnigmail.TRUSTED_IDENTITY;
}
} else {
errorMsgObj.value = trustPrefix + EnigGetString("prefBad",userId) /*+ ", " +
EnigGetString("keyId") + " 0x" + keyId.substring(8,16); */
if (!exitCode)
exitCode = 1;
if (this.agentType != "gpg")
statusFlagsObj.value |= nsIEnigmail.BAD_SIGNATURE;
}
}
if (!verifyOnly && (this.agentType != "gpg")) {
statusFlagsObj.value |= nsIEnigmail.DECRYPTION_OKAY;
}
return exitCode;
}
if ( (statusFlagsObj.value & nsIEnigmail.BAD_PASSPHRASE) ||
((this.agentType == "pgp") && !verifyOnly && (exitCode != 30)) ) {
// "Unremember" passphrase on decryption failure
this.clearCachedPassphrase();
}
var pubKeyId;
if (statusFlagsObj.value & nsIEnigmail.UNVERIFIED_SIGNATURE) {
// Unverified signature
var matchb = statusMsg.match(/(^|\n)NO_PUBKEY (\w{8})(\w{8})/);
if (matchb && (matchb.length > 3)) {
pubKeyId = "0x" + matchb[3];
DEBUG_LOG("enigmail.js: Enigmail.decryptMessageEnd: NO_PUBKEY "+pubKeyId+"\n");
keyIdObj.value = matchb[2]+matchb[3];
}
if (statusFlagsObj.value & nsIEnigmail.DECRYPTION_OKAY) {
exitCode=0;
}
}
if (this.agentType != "gpg") {
// Not GPG
if (verifyOnly) {
// Assume bad signature is reason for failure
statusFlagsObj.value |= nsIEnigmail.BAD_SIGNATURE;
} else {
statusFlagsObj.value |= outputLen ? nsIEnigmail.DECRYPTION_OKAY
: nsIEnigmail.DECRYPTION_FAILED;
}
}
if (exitCode != 0) {
// Error processing
ERROR_LOG("enigmail.js: Enigmail.decryptMessageEnd: Error in command execution\n");
}
if (cmdErrorMsgObj.value) {
errorMsgObj.value = this.agentType + " " + EnigGetString("cmdLine");
errorMsgObj.value += "\n" + cmdLineObj.value;
errorMsgObj.value += "\n" + cmdErrorMsgObj.value;
}
return exitCode;
}
// ExitCode == 0 => success
// ExitCode > 0 => error
// ExitCode == -1 => Cancelled by user
Enigmail.prototype.receiveKey =
function (recvFlags, keyserver, keyId, requestObserver, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.receiveKey: "+keyId+"\n");
if (!this.initialized) {
errorMsgObj.value = EnigGetString("notInit");
return null;
}
if (this.agentType != "gpg") {
errorMsgObj.value = EnigGetString("failOnlyGPG");
return null;
}
if (!keyserver) {
errorMsgObj.value = EnigGetString("failNoServer");
return null;
}
if (!keyId) {
errorMsgObj.value = EnigGetString("failNoID");
return null;
}
var envList = [];
envList = envList.concat(gEnvList);
var proxyHost = null;
try {
if (this.prefBranch.getBoolPref("respectHttpProxy")) {
// determine proxy host
var prefsSvc = Components.classes[NS_PREFS_SERVICE_CID].getService(Components.interfaces.nsIPrefService);
var prefRoot = prefsSvc.getBranch(null);
var useProxy = prefRoot.getIntPref("network.proxy.type");
if (useProxy==1) {
var proxyHostName = prefRoot.getCharPref("network.proxy.http");
var proxyHostPort = prefRoot.getIntPref("network.proxy.http_port");
var noProxy = prefRoot.getCharPref("network.proxy.no_proxies_on").split(/[ ,]/);
for (var i=0; i<noProxy.length; i++) {
var proxySearch=new RegExp(noProxy[i].replace(/\./, "\\.")+"$", "i");
if (noProxy[i] && keyserver.search(proxySearch)>=0) {
i=noProxy.length+1;
proxyHostName=null;
}
}
if (proxyHostName && proxyHostPort) {
proxyHost="http://"+proxyHostName+":"+proxyHostPort
}
}
}
}
catch (ex) {}
var command = this.getAgentPath();
if (! (recvFlags & nsIEnigmail.SEARCH_KEY)) command += GPG_BATCH_OPTS;
if (proxyHost) {
command += " --keyserver-options honor-http-proxy";
envList.push("http_proxy="+proxyHost);
}
command += " --keyserver " + keyserver;
if (recvFlags & nsIEnigmail.DOWNLOAD_KEY) {
command += " --recv-keys " + keyId;
}
else if (recvFlags & nsIEnigmail.SEARCH_KEY) {
command += " --search-keys " + keyId;
}
else if (recvFlags & nsIEnigmail.UPLOAD_KEY) {
command += " --send-keys " + keyId;
}
var exitCodeObj = new Object();
var statusFlagsObj = new Object();
var statusMsgObj = new Object();
var cmdLineObj = new Object();
CONSOLE_LOG("enigmail> "+command.replace(/\\\\/g, "\\")+"\n");
var pipeConsole = Components.classes[NS_PIPECONSOLE_CONTRACTID].createInstance(Components.interfaces.nsIPipeConsole);
// Create joinable console
pipeConsole.open(20, 80, true);
var ipcRequest = null;
try {
ipcRequest = gEnigmailSvc.ipcService.execAsync(command,
false,
"",
"",
0,
envList, envList.length,
pipeConsole,
pipeConsole,
requestObserver);
} catch (ex) {
ERROR_LOG("enigmail.js: Enigmail.receiveKey: execAsync failed\n");
}
if (!ipcRequest) {
ERROR_LOG("enigmail.js: Enigmail.receiveKey: execAsync failed somehow\n");
return null;
}
return ipcRequest;
}
Enigmail.prototype.searchKey =
function (recvFlags, protocol, keyserver, port, keyValue, requestObserver, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.searchKey: "+keyValue+"\n");
if (!this.initialized) {
errorMsgObj.value = EnigGetString("notInit");
return null;
}
if (this.agentType != "gpg") {
errorMsgObj.value = EnigGetString("failOnlyGPG");
return null;
}
if (!keyserver) {
errorMsgObj.value = EnigGetString("failNoServer");
return null;
}
if (!keyValue) {
errorMsgObj.value = EnigGetString("failNoID");
return null;
}
var envList = [];
envList = envList.concat(gEnvList);
var proxyHost = null;
if (protocol=="hkp") {
try {
if (this.prefBranch.getBoolPref("respectHttpProxy")) {
// determine proxy host
var prefsSvc = Components.classes[NS_PREFS_SERVICE_CID].getService(Components.interfaces.nsIPrefService);
var prefRoot = prefsSvc.getBranch(null);
var useProxy = prefRoot.getIntPref("network.proxy.type");
if (useProxy==1) {
var proxyHostName = prefRoot.getCharPref("network.proxy.http");
var proxyHostPort = prefRoot.getIntPref("network.proxy.http_port");
var noProxy = prefRoot.getCharPref("network.proxy.no_proxies_on").split(/[ ,]/);
for (var i=0; i<noProxy.length; i++) {
var proxySearch=new RegExp(noProxy[i].replace(/\./, "\\.")+"$", "i");
if (noProxy[i] && keyserver.search(proxySearch)>=0) {
i=noProxy.length+1;
proxyHostName=null;
}
}
if (proxyHostName && proxyHostPort) {
proxyHost="http://"+proxyHostName+":"+proxyHostPort
}
}
}
}
catch (ex) {}
}
var baseCommand = "gpgkeys_" + protocol;
if (this.isDosLike) {
baseCommand+=".exe";
}
var baseDir = Components.classes[NS_LOCAL_FILE_CONTRACTID].createInstance(nsILocalFile);
baseDir.initWithPath(this.agentPath);
var command = null;
// try to locate gpgkeys_*
if (baseDir)
baseDir = baseDir.parent;
if (baseDir) {
var theCommand=baseDir.clone();
// first the same dir as gpg executable
theCommand.append(baseCommand);
if (theCommand.exists() && theCommand.isExecutable())
command = theCommand.path;
if (! command) {
// then lib
theCommand.append("lib");
theCommand.append(baseCommand);
if (theCommand.exists() && theCommand.isExecutable())
command = theCommand.path;
}
if (!command) {
if (baseDir.parent) {
baseDir=baseDir.parent;
theCommand=baseDir.clone();
// then ..\lib\gnupg or ../lib/gnupg
theCommand.append("lib");
theCommand.append("gnupg");
theCommand.append(baseCommand);
if (theCommand.exists() && theCommand.isExecutable()) {
command = theCommand.path;
}
else {
theCommand=baseDir.clone();
// then ..\libexec\gnupg or ../libexec/gnupg
theCommand.append("libexec");
theCommand.append("gnupg");
theCommand.append(baseCommand);
if (theCommand.exists() && theCommand.isExecutable())
command = theCommand.path;
}
}
}
}
if (! command) {
// no gpgkeys_* found
return null;
}
command=command.replace(/\\\\/g, "\\").replace(/\\/g, "\\\\");
// call gpgkeys to check the version number
var outObj = new Object();
var outLenObj = new Object();
var errObj = new Object();
var errLenObj = new Object();
var testCmd = command + " -V"
CONSOLE_LOG("\nenigmail> "+testCmd.replace(/\\\\/g, "\\")+"\n");
try {
var exitCode = this.ipcService.execPipe(testCmd,
false,
"",
"", 0,
envList, envList.length,
outObj, outLenObj,
errObj, errLenObj);
}
catch (ex) {
CONSOLE_LOG(testCmd.replace(/\\\\/g, "\\")+" failed\n");
return null;
}
if (exitCode !=0) {
CONSOLE_LOG(testCmd.replace(/\\\\/g, "\\")+" not found\n");
return null;
}
CONSOLE_LOG(outObj.value+"\n");
var ver = outObj.value.split(/[\n\r]+/);
if (Number(ver[0])==0 || Number(ver[0])==1) {
var inputData="VERSION "+ver[0]+"\nHOST "+keyserver+"\nPORT "+port+"\n";
}
else {
return null;
}
if (proxyHost) {
inputData+="OPTION honor-http-proxy\n";
envList.push("http_proxy="+proxyHost);
}
if (recvFlags & nsIEnigmail.SEARCH_KEY) {
inputData+="COMMAND search\n\n"+keyValue+"\n\n";
}
else if (recvFlags & nsIEnigmail.DOWNLOAD_KEY) {
inputData+="COMMAND get\n\n+"+keyValue+"\n\n";
}
var pipeConsole = Components.classes[NS_PIPECONSOLE_CONTRACTID].createInstance(Components.interfaces.nsIPipeConsole);
// Create joinable console
pipeConsole.open(5000, 0, true);
var errorConsole = Components.classes[NS_PIPECONSOLE_CONTRACTID].createInstance(Components.interfaces.nsIPipeConsole);
errorConsole.open(20, 0, true);
CONSOLE_LOG("enigmail> "+command.replace(/\\\\/g, "\\")+"\n");
var ipcRequest = null;
try {
ipcRequest = gEnigmailSvc.ipcService.execAsync(command,
false,
"",
inputData,
inputData.length,
envList, envList.length,
pipeConsole,
errorConsole,
requestObserver);
} catch (ex) {
ERROR_LOG("enigmail.js: Enigmail.searchKey: execAsync failed\n");
}
if (!ipcRequest) {
ERROR_LOG("enigmail.js: Enigmail.searchKey: execAsync failed somehow\n");
return null;
}
return ipcRequest;
}
Enigmail.prototype.extractKey =
function (parent, exportFlags, userId, outputFile, exitCodeObj, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.extractKey: "+userId+"\n");
if (!this.initialized) {
errorMsgObj.value = EnigGetString("notInit");
return "";
}
var command = this.getAgentPath();
command += GPG_BATCH_OPTS + " -a --export ";
command += userId;
var statusFlagsObj = new Object();
var statusMsgObj = new Object();
var cmdErrorMsgObj = new Object();
var keyBlock = this.execCmd(command, null, "",
exitCodeObj, statusFlagsObj, statusMsgObj, cmdErrorMsgObj);
if ((exitCodeObj.value == 0) && !keyBlock)
exitCodeObj.value = -1;
if (exitCodeObj.value != 0) {
errorMsgObj.value = EnigGetString("failKeyExtract");
if (cmdErrorMsgObj.value) {
errorMsgObj.value += "\n" + command;
errorMsgObj.value += "\n" + cmdErrorMsgObj.value;
}
return "";
}
if (exportFlags & nsIEnigmail.EXTRACT_SECRET_KEY) {
command = this.getAgentPath();
command += GPG_BATCH_OPTS + " -a --export-secret-keys ";
command += userId;
var secKeyBlock = this.execCmd(command, null, "",
exitCodeObj, statusFlagsObj, statusMsgObj, cmdErrorMsgObj);
if ((exitCodeObj.value == 0) && !secKeyBlock)
exitCodeObj.value = -1;
if (exitCodeObj.value != 0) {
errorMsgObj.value = EnigGetString("failKeyExtract");
if (cmdErrorMsgObj.value) {
errorMsgObj.value += "\n" + command;
errorMsgObj.value += "\n" + cmdErrorMsgObj.value;
}
return "";
}
if (keyBlock.substr(-1,1).search(/[\r\n]/)<0) keyBlock += "\n"
keyBlock+=secKeyBlock;
}
if (outputFile) {
if (! WriteFileContents(outputFile, keyBlock, DEFAULT_FILE_PERMS)) {
exitCodeObj.value = -1;
errorMsgObj.value = EnigGetString("fileWriteFailed", outputFile);
}
return "";
}
return keyBlock;
}
// ExitCode == 0 => success
// ExitCode > 0 => error
// ExitCode == -1 => Cancelled by user
Enigmail.prototype.importKey =
function (parent, uiFlags, msgText, keyId, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.importKey: id="+keyId+", "+uiFlags+"\n");
if (!this.initialized) {
errorMsgObj.value = EnigGetString("notInit");
return 1;
}
var beginIndexObj = new Object();
var endIndexObj = new Object();
var indentStrObj = new Object();
var blockType = this.locateArmoredBlock(msgText, 0, "",
beginIndexObj, endIndexObj,
indentStrObj);
if (!blockType) {
errorMsgObj.value = EnigGetString("noPGPblock");
return 1;
}
if (blockType != "PUBLIC KEY BLOCK") {
errorMsgObj.value = EnigGetString("notFirstBlock");
return 1;
}
var pgpBlock = msgText.substr(beginIndexObj.value,
endIndexObj.value - beginIndexObj.value + 1);
var interactive = uiFlags & nsIEnigmail.UI_INTERACTIVE;
if (interactive) {
var confirmMsg = EnigGetString("importKeyConfirm");
if (!this.confirmMsg(parent, confirmMsg)) {
errorMsgObj.value = EnigGetString("failCancel");
return -1;
}
}
var command = this.getAgentPath();
if (this.agentType == "pgp") {
command += PGP_BATCH_OPTS + " -ft -ka";
} else {
command += GPG_BATCH_OPTS + " --import";
}
var exitCodeObj = new Object();
var statusFlagsObj = new Object();
var statusMsgObj = new Object();
var output = this.execCmd(command, null, pgpBlock,
exitCodeObj, statusFlagsObj, statusMsgObj, errorMsgObj);
var statusMsg = statusMsgObj.value;
var pubKeyId;
if (exitCodeObj.value == 0) {
// Normal return
this.invalidateUserIdList();
if (statusMsg && (statusMsg.search("IMPORTED ") > -1)) {
var matches = statusMsg.match(/(^|\n)IMPORTED (\w{8})(\w{8})/);
if (matches && (matches.length > 3)) {
pubKeyId = "0x" + matches[3];
DEBUG_LOG("enigmail.js: Enigmail.importKey: IMPORTED "+pubKeyId+"\n");
}
}
}
return exitCodeObj.value;
}
Enigmail.prototype.importKeyFromFile =
function (parent, fileName, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.importKeyFromFile: fileName="+fileName+"\n");
if (!this.initialized) {
errorMsgObj.value = EnigGetString("notInit");
return 1;
}
fileName=fileName.replace(/\\/g, "\\\\");
var command = this.getAgentPath();
command += GPG_BATCH_OPTS + " --import '"+fileName+"'";
var statusFlagsObj = new Object();
var statusMsgObj = new Object();
var exitCodeObj = new Object();
var output = this.execCmd(command, null, "",
exitCodeObj, statusFlagsObj, statusMsgObj, errorMsgObj);
var statusMsg = statusMsgObj.value;
var pubKeyId;
if (exitCodeObj.value == 0) {
// Normal return
this.invalidateUserIdList();
if (statusMsg && (statusMsg.search("IMPORTED ") > -1)) {
var matches = statusMsg.match(/(^|\n)IMPORTED (\w{8})(\w{8})/);
if (matches && (matches.length > 3)) {
pubKeyId = "0x" + matches[3];
DEBUG_LOG("enigmail.js: Enigmail.importKey: IMPORTED "+pubKeyId+"\n");
}
}
errorMsgObj.value = EnigConvertGpgToUnicode(errorMsgObj.value);
}
return exitCodeObj.value;
}
Enigmail.prototype.generateKey =
function (parent, name, comment, email, expiryDate, keyLength, passphrase,
requestObserver) {
WRITE_LOG("enigmail.js: Enigmail.generateKey: \n");
if (this.keygenProcess || (this.agentType != "gpg"))
throw Components.results.NS_ERROR_FAILURE;
var pipeConsole = Components.classes[NS_PIPECONSOLE_CONTRACTID].createInstance(Components.interfaces.nsIPipeConsole);
// Create joinable console
pipeConsole.open(100, 80, true);
var command = this.getAgentPath() + GPG_BATCH_OPTS + " --gen-key";
pipeConsole.write(command.replace(/\\\\/g, "\\")+"\n");
CONSOLE_LOG(command.replace(/\\\\/g, "\\")+"\n");
var inputData = "%echo Generating a standard key\nKey-Type: DSA\nKey-Length: 1024\nSubkey-Type: ELG-E\n";
inputData += "Subkey-Length: "+keyLength+"\n";
inputData += "Name-Real: "+name+"\n";
if (comment)
inputData += "Name-Comment: "+comment+"\n";
inputData += "Name-Email: "+email+"\n";
inputData += "Expire-Date: "+String(expiryDate)+"\n";
pipeConsole.write(inputData+"\n");
CONSOLE_LOG(inputData+" \n");
if (passphrase.length)
inputData += "Passphrase: "+passphrase+"\n";
inputData += "%commit\n%echo done\n";
var ipcRequest = null;
try {
var useShell = false;
ipcRequest = gEnigmailSvc.ipcService.execAsync(command,
useShell,
"",
inputData,
inputData.length,
[], 0,
pipeConsole,
pipeConsole,
requestObserver);
} catch (ex) {
}
if (!ipcRequest) {
ERROR_LOG("enigmail.js: Enigmail.generateKey: execAsync failed\n");
return null;
}
this.keygenRequest = ipcRequest;
DEBUG_LOG("enigmail.js: Enigmail.generateKey: ipcRequest = "+ipcRequest+"\n");
return ipcRequest;
}
Enigmail.prototype.createMessageURI =
function (originalUrl, contentType, contentCharset, contentData, persist) {
DEBUG_LOG("enigmail.js: Enigmail.createMessageURI: "+originalUrl+
", "+contentType+", "+contentCharset+"\n");
var messageId = "msg" + Math.floor(Math.random()*1.0e9);
this._messageIdList[messageId] = {originalUrl:originalUrl,
contentType:contentType,
contentCharset:contentCharset,
contentData:contentData,
persist:persist};
return "enigmail:message?id="+messageId;
}
function ExtractMessageId(uri) {
var messageId = "";
var matches = uri.match(/^enigmail:message\?id=(.+)/);
if (matches && (matches.length > 1)) {
messageId = matches[1];
}
return messageId;
}
Enigmail.prototype.deleteMessageURI =
function (uri) {
DEBUG_LOG("enigmail.js: Enigmail.deleteMessageURI: "+uri+"\n");
var messageId = ExtractMessageId(uri);
if (!messageId)
return false;
return (delete this._messageIdList[messageId]);
}
function IPCContext()
{
}
IPCContext.prototype = {
command: "",
pipeTransport: null,
stdoutConsole: null,
stderrConsole: null,
QueryInterface: function (iid) {
if (!iid.equals(Components.interfaces.nsIIPCContext) &&
!iid.equals(Components.interfaces.nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
}
}
const ENIGMAIL_PANEL_URL = "chrome://enigmail/content/enigmailPanel.xul";
Enigmail.prototype.selectPanel =
function (url) {
WRITE_LOG("enigmail.js: Enigmail.selectPanel: "+url+"\n");
var wm = Components.classes[WMEDIATOR_CONTRACTID].getService(Components.interfaces.nsIWindowMediator);
var navWindowList = wm.getEnumerator("navigator:browser");
var retval = false;
while (navWindowList.hasMoreElements()) {
var navWindow =navWindowList.getNext();
DEBUG_LOG("enigmail.js: navWindow="+navWindow+"\n");
var href = navWindow._content.location.href;
DEBUG_LOG("enigmail.js: href="+href+"\n");
if (href.toLowerCase().indexOf(url.toLowerCase()) != 0)
continue;
var enigmailPanel = navWindow.document.getElementById("urn:sidebar:3rdparty-panel:"+ENIGMAIL_PANEL_URL);
DEBUG_LOG("enigmail.js: panel="+enigmailPanel+"\n");
if (!enigmailPanel) {
// Add panel
enigmailAddPanel();
enigmailPanel = navWindow.document.getElementById("urn:sidebar:3rdparty-panel:"+ENIGMAIL_PANEL_URL);
DEBUG_LOG("enigmail.js: panel="+enigmailPanel+"\n");
if (!enigmailPanel) {
DEBUG_LOG("enigmail.js: Added panel not found in document!\n");
return false;
}
}
navWindow.SidebarSelectPanel(enigmailPanel, true, true);
retval = true;
}
return retval;
}
// Chrome sidebar panel adding code
function enigmailAddPanel() {
DEBUG_LOG("enigmail.js: Adding Enigmail panel\n");
var sidebarObj = new chromeSidebar();
sidebarObj.addPanel("Enigmail", ENIGMAIL_PANEL_URL, "");
}
const PANELS_RDF_FILE = "UPnls"; /* directory services property to find panels.rdf */
const CONTAINER_CONTRACTID = "@mozilla.org/rdf/container;1";
const DIR_SERV_CONTRACTID = "@mozilla.org/file/directory_service;1"
const NETSEARCH_CONTRACTID = "@mozilla.org/rdf/datasource;1?name=internetsearch"
const RDF_CONTRACTID = "@mozilla.org/rdf/rdf-service;1";
const nsIRDFService = Components.interfaces.nsIRDFService;
const nsIRDFContainer = Components.interfaces.nsIRDFContainer;
const nsIRDFRemoteDataSource = Components.interfaces.nsIRDFRemoteDataSource;
function chromeSidebar()
{
this.rdf = Components.classes[RDF_CONTRACTID].getService(nsIRDFService);
this.datasource_uri = getSidebarDatasourceURI(PANELS_RDF_FILE);
DEBUG_LOG("enigmail.js: datasource_uri is" + this.datasource_uri + "\n");
this.resource = 'urn:sidebar:current-panel-list';
this.datasource = this.rdf.GetDataSource(this.datasource_uri);
}
chromeSidebar.prototype.nc = "http://home.netscape.com/NC-rdf#";
function sidebarURLSecurityCheck(url)
{
if (url.search(/(^chrome:|^http:|^ftp:|^https:)/) == -1)
throw "Script attempted to add sidebar panel from illegal source";
}
chromeSidebar.prototype.isPanel =
function (aContentURL)
{
var container =
Components.classes[CONTAINER_CONTRACTID].createInstance(nsIRDFContainer);
/* Create a resource for the new panel and add it to the list */
var panel_resource =
this.rdf.GetResource("urn:sidebar:3rdparty-panel:" + aContentURL);
return (container.IndexOf(panel_resource) != -1);
}
/* decorate prototype to provide ``class'' methods and property accessors */
chromeSidebar.prototype.addPanel =
function (aTitle, aContentURL, aCustomizeURL)
{
DEBUG_LOG("enigmail.js: addPanel(" + aTitle + ", " + aContentURL + ", " +
aCustomizeURL + ")" + "\n");
sidebarURLSecurityCheck(aContentURL);
// Create a "container" wrapper around the current panels to
// manipulate the RDF:Seq more easily.
var panel_list = this.datasource.GetTarget(this.rdf.GetResource(this.resource), this.rdf.GetResource(chromeSidebar.prototype.nc+"panel-list"), true);
if (panel_list) {
panel_list.QueryInterface(Components.interfaces.nsIRDFResource);
} else {
// Datasource is busted. Start over.
DEBUG_LOG("enigmail.js: Sidebar datasource is busted\n");
}
var container = Components.classes[CONTAINER_CONTRACTID].createInstance(nsIRDFContainer);
container.Init(this.datasource, panel_list);
/* Create a resource for the new panel and add it to the list */
var panel_resource =
this.rdf.GetResource("urn:sidebar:3rdparty-panel:" + aContentURL);
var panel_index = container.IndexOf(panel_resource);
if (panel_index != -1)
{
DEBUG_LOG("enigmail.js: addPanel(): panel already in list"+"\n");
return;
}
/* Now make some sidebar-ish assertions about it... */
this.datasource.Assert(panel_resource,
this.rdf.GetResource(this.nc + "title"),
this.rdf.GetLiteral(aTitle),
true);
this.datasource.Assert(panel_resource,
this.rdf.GetResource(this.nc + "content"),
this.rdf.GetLiteral(aContentURL),
true);
if (aCustomizeURL)
this.datasource.Assert(panel_resource,
this.rdf.GetResource(this.nc + "customize"),
this.rdf.GetLiteral(aCustomizeURL),
true);
container.AppendElement(panel_resource);
// Use an assertion to pass a "refresh" event to all the sidebars.
// They use observers to watch for this assertion (in sidebarOverlay.js).
this.datasource.Assert(this.rdf.GetResource(this.resource),
this.rdf.GetResource(this.nc + "refresh"),
this.rdf.GetLiteral("true"),
true);
this.datasource.Unassert(this.rdf.GetResource(this.resource),
this.rdf.GetResource(this.nc + "refresh"),
this.rdf.GetLiteral("true"));
/* Write the modified panels out. */
this.datasource.QueryInterface(nsIRDFRemoteDataSource).Flush();
DEBUG_LOG("enigmail.js: Panel successfully added to sidebar\n");
}
function getSidebarDatasourceURI(panels_file_id)
{
try
{
/* use the fileLocator to look in the profile directory
* to find 'panels.rdf', which is the
* database of the user's currently selected panels. */
var directory_service = Components.classes[DIR_SERV_CONTRACTID].getService();
if (directory_service)
directory_service = directory_service.QueryInterface(Components.interfaces.nsIProperties);
/* if <profile>/panels.rdf doesn't exist, get will copy
*bin/defaults/profile/panels.rdf to <profile>/panels.rdf */
var sidebar_file = directory_service.get(panels_file_id, Components.interfaces.nsIFile);
if (!sidebar_file.exists())
{
/* this should not happen, as GetFileLocation() should copy
* defaults/panels.rdf to the users profile directory */
DEBUG_LOG("enigmail.js: sidebar file does not exist" + "\n");
return null;
}
DEBUG_LOG("enigmail.js: sidebar uri is " + sidebar_file.URL + "\n");
return sidebar_file.URL;
}
catch (ex)
{
/* this should not happen */
DEBUG_LOG("enigmail.js: caught " + ex + " getting sidebar datasource uri" + "\n");
return null;
}
}
// retrieves a localized string from the enigmail.properties stringbundle
function EnigGetString(aStr) {
var restCount = arguments.length - 1;
if(!gEnigStrBundle) {
try {
var strBundleService = Components.classes[ENIG_STRINGBUNDLE_CONTRACTID].getService();
strBundleService = strBundleService.QueryInterface(nsIEnigStrBundle);
gEnigStrBundle = strBundleService.createBundle("chrome://enigmail/locale/enigmail.properties");
} catch (ex) {
ERROR_LOG("enigmailCommon.js: Error in instantiating stringBundleService\n");
}
}
if(gEnigStrBundle) {
try {
if(restCount > 0) {
var subPhrases = new Array();
for (var i = 1; i < arguments.length; i++) {
subPhrases.push(arguments[i]);
}
return gEnigStrBundle.formatStringFromName(aStr, subPhrases, subPhrases.length);
}
else {
return gEnigStrBundle.GetStringFromName(aStr);
}
} catch (ex) {
ERROR_LOG("enigmailCommon.js: Error in querying stringBundleService for string '"+aStr+"'\n");
}
}
return null;
}
Enigmail.prototype.invalidateUserIdList =
function () {
// clean the userIdList to force reloading the list at next usage
this.userIdList= null;
}
// returns the output of -with-colons --list[-secret]-keys
Enigmail.prototype.getUserIdList =
function (secretOnly, refresh, exitCodeObj, statusFlagsObj, errorMsgObj) {
if (secretOnly || refresh || this.userIdList == null) {
var gpgCommand = this.getAgentPath() + GPG_BATCH_OPTS;
if (secretOnly) {
gpgCommand += " --with-fingerprint --with-colons --list-secret-keys"; }
else {
gpgCommand += " --with-fingerprint --with-colons --list-keys";
}
if (!this.initialized) {
errorMsgObj.value = EnigGetString("notInit");
return "";
}
statusFlagsObj.value = 0;
var statusMsgObj = new Object();
var cmdErrorMsgObj = new Object();
var listText = this.execCmd(gpgCommand, null, "",
exitCodeObj, statusFlagsObj, statusMsgObj, cmdErrorMsgObj);
if (exitCodeObj.value != 0) {
errorMsgObj.value = EnigGetString("badCommand");
if (cmdErrorMsgObj.value) {
errorMsgObj.value += "\n" + gpgCommand;
errorMsgObj.value += "\n" + cmdErrorMsgObj.value;
}
return "";
}
listText=EnigConvertGpgToUnicode(listText).replace(/(\r\n|\r)/g, "\n");
if (secretOnly) {
return listText;
}
this.userIdList = listText;
}
else {
exitCodeObj.value=0;
statusFlagsObj.value=0;
errorMsgObj.value="";
}
return this.userIdList;
}
// returns the output of -with-colons --list-sig
Enigmail.prototype.getKeySig =
function (keyId, exitCodeObj, errorMsgObj) {
var gpgCommand = this.getAgentPath() + GPG_BATCH_OPTS + " --with-colons --with-fingerprint --list-sig "+keyId;
if (!this.initialized) {
errorMsgObj.value = EnigGetString("notInit");
return "";
}
var statusFlagsObj = new Object();
var statusMsgObj = new Object();
var cmdErrorMsgObj = new Object();
var listText = this.execCmd(gpgCommand, null, "",
exitCodeObj, statusFlagsObj, statusMsgObj, cmdErrorMsgObj);
if (exitCodeObj.value != 0) {
errorMsgObj.value = EnigGetString("badCommand");
if (cmdErrorMsgObj.value) {
errorMsgObj.value += "\n" + gpgCommand;
errorMsgObj.value += "\n" + cmdErrorMsgObj.value;
}
return "";
}
return listText;
}
// get key details.
// if uidOnly is true, returns just a list of uid's
Enigmail.prototype.getKeyDetails = function (keyId, uidOnly) {
var gpgCommand = this.getAgentPath() + GPG_BATCH_OPTS
gpgCommand += " --with-colons --list-keys " + keyId;
var statusMsgObj = new Object();
var cmdErrorMsgObj = new Object();
var statusFlagsObj = new Object();
var exitCodeObj = new Object();
var listText = this.execCmd(gpgCommand, null, "",
exitCodeObj, statusFlagsObj, statusMsgObj, cmdErrorMsgObj);
if (exitCodeObj.value != 0) {
return "";
}
listText=EnigConvertGpgToUnicode(listText).replace(/(\r\n|\r)/g, "\n");
if (uidOnly) {
var userList="";
var keyArr=listText.split(/\n/);
for (var i=0; i<keyArr.length; i++) {
switch (keyArr[i].substr(0,4)) {
case "uid:" :
userList += "\n";
case "pub:" :
userList += keyArr[i].split(/:/)[9];
}
}
return userList;
}
return listText;
}
Enigmail.prototype.encryptAttachment =
function (parent, fromMailAddr, toMailAddr, sendFlags, inFile, outFile,
exitCodeObj, statusFlagsObj, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.encryptAttachment\n");
if (!this.initialized) {
errorMsgObj.value = EnigGetString("notInit");
return "";
}
statusFlagsObj.value = 0;
var asciiArmor = false;
try {
asciiArmor = this.prefBranch.getBoolPref("inlineAttachAsciiArmor");
} catch (ex) {}
var gpgCommand = this.getEncryptCommand(fromMailAddr, toMailAddr, "", sendFlags, asciiArmor, errorMsgObj);
if (! gpgCommand)
return null;
var passphrase = null;
var signMessage = (sendFlags & nsIEnigmail.SEND_SIGNED);
if (signMessage ) {
gpgCommand += this.passwdCommand();
var passwdObj = new Object();
var useAgentObj = new Object();
if (!GetPassphrase(parent, passwdObj, useAgentObj)) {
ERROR_LOG("enigmail.js: Enigmail.encryptAttachment: Error - no passphrase supplied\n");
statusFlagsObj.value |= nsIEnigmail.MISSING_PASSPHRASE;
return null;
}
passphrase = passwdObj.value;
}
// escape the backslashes (mainly for Windows) and the ' character
inFile = inFile.replace(/([\\\"\'\`])/g, "\\$1");
//replace(/\\/g, "\\\\").replace(/\'/g, "\\'");
outFile = outFile.replace(/([\\\"\'\`])/g, "\\$1");
gpgCommand += " --yes -o " + this.quoteSign + outFile + this.quoteSign;
gpgCommand += " "+this.quoteSign + inFile + this.quoteSign;
var statusMsgObj = new Object();
var cmdErrorMsgObj = new Object();
var msg = this.execCmd(gpgCommand, passphrase, "",
exitCodeObj, statusFlagsObj, statusMsgObj, cmdErrorMsgObj);
if (exitCodeObj.value != 0) {
if (cmdErrorMsgObj.value) {
errorMsgObj.value = gpgCommand;
errorMsgObj.value += "\n" + cmdErrorMsgObj.value;
}
else {
errorMsgObj.value = "An unknown error has occurred";
}
return "";
}
return msg;
}
Enigmail.prototype.decryptAttachment =
function (parent, outFileName, displayName, inputBuffer,
exitCodeObj, statusFlagsObj, errorMsgObj) {
WRITE_LOG("enigmail.js: Enigmail.decryptAttachment: parent="+parent+", outFileName="+outFileName+"\n");
var dataLength = new Object();
var byteData = inputBuffer.getByteData(dataLength);
var attachmentHead = byteData.substr(0,200);
if (attachmentHead.match(/\-\-\-\-\-BEGIN PGP \w+ KEY BLOCK\-\-\-\-\-/)) {
// attachment appears to be a PGP key file
if (this.confirmMsg(parent, EnigGetString("attachmentPgpKey", displayName))) {
exitCodeObj.value = this.importKey(parent, 0, byteData, "", errorMsgObj);
statusFlagsObj.value = gStatusFlags.IMPORTED;
}
else {
exitCodeObj.value = 0;
statusFlagsObj.value = nsIEnigmail.DISPLAY_MESSAGE;
}
return true;
}
var command = this.getAgentPath();
outFileName = outFileName.replace(/([\\\"\'\`])/g, "\\$1");
//replace(/\\/g, "\\\\").replace(/'/g, "\\'");;
command += GPG_BATCH_OPTS + " -o " + this.quoteSign + outFileName + this.quoteSign;
command+= " --yes " + this.passwdCommand() + " -d ";
statusFlagsObj.value = 0;
var passphrase = null;
var passwdObj = new Object();
var useAgentObj = new Object();
if (!GetPassphrase(parent, passwdObj, useAgentObj)) {
ERROR_LOG("enigmail.js: Enigmail.decryptAttachment: Error - no passphrase supplied\n");
statusFlagsObj.value |= nsIEnigmail.MISSING_PASSPHRASE;
return null;
}
passphrase = passwdObj.value;
var noProxy = true;
var ipcBuffer = Components.classes[NS_IPCBUFFER_CONTRACTID].createInstance(Components.interfaces.nsIIPCBuffer);
ipcBuffer.open(MSG_BUFFER_SIZE, false);
var pipeTrans = this.execStart(command, false, parent, 0,
ipcBuffer, noProxy, statusFlagsObj);
if (!pipeTrans) {
return false;
}
var inStream;
try {
if (! useAgentObj.value) {
if (passphrase.length > 0) {
pipeTrans.writeSync(passphrase, passphrase.length);
}
pipeTrans.writeSync("\n", 1);
}
pipeTrans.writeSync(byteData, dataLength.value);
}
catch (ex) {
return false;
}
// Wait for child STDOUT to close
pipeTrans.join();
exitCodeObj.value = pipeTrans.exitCode();
var statusMsgObj = new Object();
var cmdLineObj = new Object();
try {
this.execEnd(pipeTrans, statusFlagsObj, statusMsgObj, cmdLineObj, errorMsgObj);
}
catch (ex) {};
return true;
}
+Enigmail.prototype.getCardStatus =
+function(exitCodeObj, errorMsgObj) {
+ var command = this.getAgentPath();
+
+ command += " --status-fd 2 --with-colons --card-status";
+ var statusMsgObj = new Object();
+ var statusFlagsObj = new Object();
+
+ var outputTxt = this.execCmd(command, null, "",
+ exitCodeObj, statusFlagsObj, statusMsgObj, errorMsgObj);
+
+ if ((exitCodeObj.value == 0) && !outputTxt) {
+ exitCodeObj.value = -1;
+ return "";
+ }
+
+ return outputTxt;
+}
+
Enigmail.prototype.showKeyPhoto =
function(keyId, exitCodeObj, errorMsgObj) {
var command = this.getAgentPath();
command += " --batch --no-tty --status-fd 1 --attribute-fd 1";
command += " --list-keys "+keyId;
var statusMsgObj = new Object();
var statusFlagsObj = new Object();
var outputTxt = this.execCmd(command, null, "",
exitCodeObj, statusFlagsObj, statusMsgObj, errorMsgObj);
if ((exitCodeObj.value == 0) && !outputTxt) {
exitCodeObj.value = -1;
return "";
}
if (this.agentVersion<"1.5" && this.isDosLike) {
// workaround for error in gpg
outputTxt=outputTxt.replace(/\r\n/g, "\n");
}
var startIndex=0;
var nextIndex=outputTxt.indexOf("[GNUPG:]",startIndex);
var imgSize=-1;
while (nextIndex>=0 && startIndex < outputTxt.length && startIndex>=0) {
var matches = outputTxt.substring(startIndex).match(/ATTRIBUTE ([A-F\d]+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+)/);
if (matches && matches[3]=="1") {
// attribute is an image
imgSize=Number(matches[2])
break;
}
startIndex=nextIndex+1;
nextIndex=outputTxt.indexOf("[GNUPG:]",startIndex);
}
if (imgSize>=0) {
startIndex = outputTxt.substring(nextIndex).search(/[\n\r]\[GNUPG:\] ATTRIBUTE /)+nextIndex+5;
var cr = outputTxt.substring(startIndex).search(/[\r\n]/);
// increase cr by 1 if CRLF
if (outputTxt.charAt(startIndex+cr)=="\r" &&
outputTxt.charAt(startIndex+cr+1)=="\n")
cr++;
var pictureData = outputTxt.substring(startIndex+cr+1+16, startIndex+cr+1+imgSize);
if (! pictureData.length)
return "";
try {
var flags = NS_WRONLY | NS_CREATE_FILE | NS_TRUNCATE;
var ds = Components.classes[DIR_SERV_CONTRACTID].getService();
var dsprops = ds.QueryInterface(Components.interfaces.nsIProperties);
var picFile = dsprops.get("TmpD", Components.interfaces.nsIFile);
picFile.append(keyId+".jpg");
picFile.createUnique(picFile.NORMAL_FILE_TYPE, DEFAULT_FILE_PERMS);
var fileStream = Components.classes[NS_LOCALFILEOUTPUTSTREAM_CONTRACTID].createInstance(Components.interfaces.nsIFileOutputStream);
fileStream.init(picFile, flags, DEFAULT_FILE_PERMS, 0);
if (fileStream.write(pictureData, pictureData.length) != pictureData.length)
throw Components.results.NS_ERROR_FAILURE;
fileStream.flush();
fileStream.close();
}
catch (ex) {
exitCodeObj.value = -1;
return "";
}
}
return picFile.path;
}
// Methods for handling Per-Recipient Rules
Enigmail.prototype.getRulesFile = function () {
DEBUG_LOG("enigmail.js: getRulesFile\n");
var ds = Components.classes[DIR_SERV_CONTRACTID].getService();
var dsprops = ds.QueryInterface(Components.interfaces.nsIProperties);
var rulesFile = dsprops.get("ProfD", Components.interfaces.nsILocalFile);
rulesFile.append("pgprules.xml");
return rulesFile;
}
Enigmail.prototype.loadRulesFile = function () {
DEBUG_LOG("enigmail.js: loadRulesFile\n");
var flags = NS_RDONLY;
var rulesFile = this.getRulesFile();
if (rulesFile.exists()) {
var ioServ = Components.classes[NS_IOSERVICE_CONTRACTID].getService(Components.interfaces.nsIIOService);
if (!ioServ)
throw Components.results.NS_ERROR_FAILURE;
var fileURI = ioServ.newFileURI(rulesFile);
var fileChannel = ioServ.newChannel(fileURI.asciiSpec, null, null);
var rawInStream = fileChannel.open();
var scriptableInStream = Components.classes[NS_SCRIPTABLEINPUTSTREAM_CONTRACTID].createInstance(Components.interfaces.nsIScriptableInputStream);
scriptableInStream.init(rawInStream);
var available = scriptableInStream.available()
var fileContents = scriptableInStream.read(available);
scriptableInStream.close();
if (fileContents.length==0 || fileContents.search(/^\s*$/)==0) {
return false;
}
var domParser=Components.classes[NS_DOMPARSER_CONTRACTID].createInstance(Components.interfaces.nsIDOMParser);
this.rulesList = domParser.parseFromString(fileContents, "text/xml");
return true;
}
return false;
}
Enigmail.prototype.saveRulesFile = function () {
DEBUG_LOG("enigmail.js: saveRulesFile\n");
var flags = NS_WRONLY | NS_CREATE_FILE | NS_TRUNCATE;
var domSerializer=Components.classes[NS_DOMSERIALIZER_CONTRACTID].createInstance(Components.interfaces.nsIDOMSerializer);
var rulesFile = this.getRulesFile();
if (rulesFile) {
if (this.rulesList) {
// the rule list is not empty -> write into file
return WriteFileContents(rulesFile.path,
domSerializer.serializeToString(this.rulesList.firstChild),
DEFAULT_FILE_PERMS);
}
else {
// empty rule list -> delete rules file
try {
rulesFile.remove(false);
}
catch (ex) {}
return true;
}
}
else
return false;
}
Enigmail.prototype.getRulesData = function (rulesListObj) {
DEBUG_LOG("enigmail.js: getRulesData\n");
var ret=true;
if (! this.rulesList) {
ret=this.loadRulesFile();
}
if (this.rulesList) {
rulesListObj.value = this.rulesList;
return ret;
}
rulesListObj.value = null;
return false;
}
Enigmail.prototype.addRule = function (appendToEnd, toAddress, keyList, sign, encrypt, pgpMime, flags) {
DEBUG_LOG("enigmail.js: addRule\n");
if (! this.rulesList) {
var domParser=Components.classes[NS_DOMPARSER_CONTRACTID].createInstance(Components.interfaces.nsIDOMParser);
this.rulesList = domParser.parseFromString("<pgpRuleList/>", "text/xml");
}
var negate = (flags & 1);
var rule=this.rulesList.createElement("pgpRule");
rule.setAttribute("email", toAddress);
rule.setAttribute("keyId", keyList);
rule.setAttribute("sign", sign);
rule.setAttribute("encrypt", encrypt);
rule.setAttribute("pgpMime", pgpMime);
rule.setAttribute("negateRule", flags);
var origFirstChild = this.rulesList.firstChild.firstChild;
if (origFirstChild && (! appendToEnd)) {
this.rulesList.firstChild.insertBefore(rule, origFirstChild);
this.rulesList.firstChild.insertBefore(this.rulesList.createTextNode(this.isDosLike ? "\r\n" : "\n"), origFirstChild);
}
else {
this.rulesList.firstChild.appendChild(rule);
this.rulesList.firstChild.appendChild(this.rulesList.createTextNode(this.isDosLike ? "\r\n" : "\n"));
}
}
Enigmail.prototype.clearRules = function () {
this.rulesList = null;
}
-function KeyEditor(pipeTrans) {
- this._pipeTrans = pipeTrans
+function KeyEditor(pipeTrans, reqObserver) {
+ this._pipeTrans = pipeTrans;
+ this._reqObserver = reqObserver;
}
KeyEditor.prototype = {
_pipeTrans: null,
_txt: null,
+ _req: null,
nextLine: function() {
return this._txt;
},
writeLine: function (inputData) {
this._pipeTrans.writeSync(inputData+"\n", inputData.length+1);
},
nextLine: function() {
var txt="";
while (txt.indexOf("[GNUPG:]") < 0) {
txt = this._pipeTrans.readLine(-1);
+ if (this._reqObserver) {
+ var newTxt = this._reqObserver.onDataAvailable(txt);
+ if (newTxt) {
+ txt = newTxt;
+ }
+ }
}
this._txt = txt;
return this._txt;
},
doCheck: function(inputType, promptVal) {
var a=this._txt.split(/ /);
return ((a[1] == inputType) && (a[2] == promptVal))
},
getText: function() {
return this._txt;
},
keyEditorMainLoop: function (callbackFunc, inputData, errorMsgObj) {
// main method that loops over the requests & responses of the
// GnuPG key editor
var txt="";
var r = { quitNow: false,
exitCode: -1 };
errorMsgObj.value=EnigGetString("undefinedError");
while (! r.quitNow) {
while ((txt.indexOf("[GNUPG:] GET_") < 0) && (! r.quitNow)) {
try {
txt = this.nextLine();
DEBUG_LOG(txt+"\n");
if (txt.indexOf("KEYEXPIRED") > 0) {
errorMsgObj.value=EnigGetString("noSignKeyExpired");
r.exitCode=-1;
}
if (txt.indexOf("[GNUPG:] BAD_PASSPHRASE")>=0) {
r.exitCode=-2;
}
+ if (txt.indexOf("[GNUPG:] ENIGMAIL_FAILURE")==0) {
+ r.exitCode = -3;
+ r.quitNow = true;
+ errorMsgObj.value = txt.substr(26);
+ }
if (txt.indexOf("[GNUPG:] ALREADY_SIGNED")>=0) {
errorMsgObj.value=EnigGetString("keyAlreadySigned");
r.exitCode=-1;
}
}
catch (ex) {
txt="";
r.quitNow=true;
}
}
if (! r.quitNow) {
if (callbackFunc) {
callbackFunc(inputData, this, r);
if (r.exitCode == 0) {
this.writeLine(r.writeTxt);
}
else {
errorMsgObj.value = r.errorMsg;
}
}
else {
r.quitNow=true;
r.exitCode = 0;
}
}
if (! r.quitNow) {
try{
txt = this.nextLine();
DEBUG_LOG(txt+"\n");
}
catch(ex) {
r.quitNow=true;
}
}
}
try {
this.writeLine("save");
txt = this.nextLine();
DEBUG_LOG(txt+"\n");
}
catch (ex) {
DEBUG_LOG("no more data\n");
}
return r.exitCode;
},
QueryInterface: function (iid) {
if (!iid.equals(Components.interfaces.nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
}
}
Enigmail.prototype.signKey =
function (parent, userId, keyId, signLocally, trustLevel, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.signKey: trustLevel="+trustLevel+", userId="+userId+", keyId="+keyId+"\n");
var r = this.editKey(parent, true, userId, keyId,
(signLocally ? "lsign" : "sign"),
{ trustLevel: trustLevel},
signKeyCallback,
+ null,
errorMsgObj);
this.stillActive();
return r;
}
Enigmail.prototype.setKeyTrust =
function (parent, keyId, trustLevel, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.setKeyTrust: trustLevel="+trustLevel+", keyId="+keyId+"\n");
return this.editKey(parent, false, null, keyId, "trust",
{ trustLevel: trustLevel},
keyTrustCallback,
+ null,
errorMsgObj);
}
Enigmail.prototype.genRevokeCert =
function (parent, keyId, outFile, reasonCode, reasonText, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.genRevokeCert: keyId="+keyId+"\n");
var r= this.editKey(parent, true, null, keyId, "revoke",
{ outFile: outFile,
reasonCode: reasonCode,
reasonText: reasonText },
revokeCertCallback,
+ null,
errorMsgObj);
this.stillActive();
return r;
}
Enigmail.prototype.addUid =
function (parent, keyId, name, email, comment, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.addUid: keyId="+keyId+", name="+name+", email="+email+"\n");
var r= this.editKey(parent, true, null, keyId, "adduid",
{ email: email,
name: name,
comment: comment,
nameAsked: 0,
emailAsked: 0 },
- addUidCallback,
+ addUidCallback,
+ null,
errorMsgObj);
this.stillActive();
return r;
}
Enigmail.prototype.deleteKey =
function (parent, keyId, deleteSecretKey, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.addUid: keyId="+keyId+", deleteSecretKey="+deleteSecretKey+"\n");
var cmd = (deleteSecretKey ? "--delete-secret-and-public-key" : "--delete-key");
var r= this.editKey(parent, false, null, keyId, cmd,
{},
- deleteKeyCallback,
+ deleteKeyCallback,
+ null,
errorMsgObj);
this.stillActive();
return r;
}
Enigmail.prototype.revokeSubkey =
function (parent, keyId, subkeys, reasonCode, reasonText, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.revokeSubkey: keyId="+keyId+"\n");
var r= this.editKey(parent, true, null, keyId, "",
{ step: 0,
subkeys: subkeys.split(/,/),
reasonCode: reasonCode,
reasonText: reasonText },
revokeSubkeyCallback,
+ null,
errorMsgObj);
this.stillActive();
return r;
}
Enigmail.prototype.enableDisableKey =
function (parent, keyId, disableKey, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.addUid: keyId="+keyId+", disableKey="+disableKey+"\n");
var cmd = (disableKey ? "disable" : "enable");
var r= this.editKey(parent, false, null, keyId, cmd,
{},
- null,
+ null,
+ null,
errorMsgObj);
this.stillActive();
return r;
}
Enigmail.prototype.setPrimaryUid =
function (parent, keyId, idNumber, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.setPrimaryUid: keyId="+keyId+", idNumber="+idNumber+"\n");
var r = this.editKey(parent, true, null, keyId, "",
{ idNumber: idNumber,
step: 0 },
- setPrimaryUidCallback,
+ setPrimaryUidCallback,
+ null,
errorMsgObj);
this.stillActive();
return r;
}
Enigmail.prototype.deleteUid =
function (parent, keyId, idNumber, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.deleteUid: keyId="+keyId+", idNumber="+idNumber+"\n");
var r = this.editKey(parent, true, null, keyId, "",
{ idNumber: idNumber,
step: 0 },
deleteUidCallback,
+ null,
errorMsgObj);
this.stillActive();
return r;
}
Enigmail.prototype.revokeUid =
function (parent, keyId, idNumber, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.revokeUid: keyId="+keyId+", idNumber="+idNumber+"\n");
var r = this.editKey(parent, true, null, keyId, "",
{ idNumber: idNumber,
step: 0 },
revokeUidCallback,
+ null,
errorMsgObj);
this.stillActive();
return r;
}
+function enigCardAdminobserver(guiObserver, isDosLike) {
+ this._guiObserver = guiObserver;
+ this.isDosLike = isDosLike;
+}
+
+enigCardAdminobserver.prototype =
+{
+ _guiObserver: null,
+ _failureCode: 0,
+
+ QueryInterface : function(iid)
+ {
+ if (iid.equals(Components.interfaces.nsIEnigMimeReadCallback) ||
+ iid.equals(Components.interfaces.nsISupports) )
+ return this;
+
+ throw Components.results.NS_NOINTERFACE;
+ },
+
+ onDataAvailable: function (data) {
+ var ret="";
+ DEBUG_LOG("enigmail.js: enigCardAdminobserver.onDataAvailable: data="+data+"\n");
+ if (this.isDosLike && data.indexOf("[GNUPG:] BACKUP_KEY_CREATED") == 0) {
+ data=data.replace(/\//g, "\\");
+ }
+ if (this._failureCode) {
+ ret = "[GNUPG:] ENIGMAIL_FAILURE "+data;
+ }
+ if (data.indexOf("[GNUPG:] SC_OP_FAILURE")>=0) {
+ this._failureCode = 1;
+ }
+ if (this._guiObserver) {
+ this._guiObserver.onDataAvailable(data);
+ }
+ return ret;
+ },
+}
+
+Enigmail.prototype.genCardKey =
+function (parent, name, email, comment, expiry, backupPasswd, requestObserver, errorMsgObj) {
+ DEBUG_LOG("enigmail.js: Enigmail.genCardKey: \n");
+ var generateObserver = new enigCardAdminobserver(requestObserver, this.isDosLike);
+ var r = this.editKey(parent, false, null, "", "--with-colons --card-edit",
+ { step: 0,
+ name: name,
+ email: email,
+ comment: comment,
+ expiry: expiry,
+ backupPasswd: backupPasswd,
+ backupKey: (backupPasswd.length > 0 ? "Y" : "N"),
+ parent: parent },
+ genCardKeyCallback,
+ generateObserver,
+ errorMsgObj);
+ return r;
+}
+
+Enigmail.prototype.cardAdminData =
+function (parent, name, firstname, lang, sex, url, login, forcepin, errorMsgObj) {
+ DEBUG_LOG("enigmail.js: Enigmail.cardAdminData: parent="+parent+", name="+name+", firstname="+firstname+", lang="+lang+", sex="+sex+", url="+url+", login="+login+", forcepin="+forcepin+"\n");
+ var adminObserver = new enigCardAdminobserver(null, this.isDosLike);
+ var r = this.editKey(parent, false, null, "", "--with-colons --card-edit",
+ { step: 0,
+ name: name,
+ firstname: firstname,
+ lang: lang,
+ sex: sex,
+ url: url,
+ login: login,
+ forcepin: forcepin },
+ cardAdminDataCallback,
+ adminObserver,
+ errorMsgObj);
+ return r;
+}
+
Enigmail.prototype.editKey =
-function (parent, needPassphrase, userId, keyId, editCmd, inputData, callbackFunc, errorMsgObj) {
+function (parent, needPassphrase, userId, keyId, editCmd, inputData, callbackFunc, requestObserver, errorMsgObj) {
DEBUG_LOG("enigmail.js: Enigmail.editKey: parent="+parent+", editCmd="+editCmd+"\n");
if (!this.initialized) {
errorMsgObj.value = EnigGetString("notInit");
return -1;
}
if (this.agentType != "gpg") {
errorMsgObj.value = EnigGetString("failOnlyGPG");
return -1;
}
errorMsgObj.value = "";
var command = this.getAgentPath();
var statusFlags = new Object();
var passphrase = "";
var useAgentObj = new Object();
if (needPassphrase) {
command += this.passwdCommand();
var passwdObj = new Object();
if (!GetPassphrase(parent, passwdObj, useAgentObj)) {
ERROR_LOG("enigmail.js: Enigmail.execStart: Error - no passphrase supplied\n");
errorMsgObj.value = EnigGetString("noPassphrase");
return -1;
}
passphrase = passwdObj.value;
}
else
{
useAgentObj.value = true;
}
- command += " --no-tty --status-fd 1 --command-fd 0"
+ command += " --no-tty --status-fd 1 --logger-fd 1 --command-fd 0"
if (userId) command += " -u " + userId;
if (editCmd == "revoke") {
// escape backslashes and ' characters
command += " -a -o "+this.quoteSign;
command += inputData.outFile.replace(/([\\\"\'\`])/g, "\\$1");
//replace(/\\/g, "\\\\").replace(/'/g, "\\'");
command += this.quoteSign+" --gen-revoke " + keyId;
}
else if (editCmd.indexOf("--")==0) {
command += " "+editCmd + " " + keyId;
}
else {
command += " --ask-cert-level --edit-key " + keyId + " " + editCmd;
}
+ command = command.replace(/ *$/, "");
var pipeTrans = this.execStart(command, false, parent, null, null,
true, statusFlags);
if (! pipeTrans) return -1;
if (! useAgentObj.value) {
try {
if (passphrase) {
pipeTrans.writeSync(passphrase, passphrase.length);
}
pipeTrans.writeSync("\n", 1);
} catch (ex) {}
}
var exitCode=-1;
try {
- var keyEdit = new KeyEditor(pipeTrans);
+ var keyEdit = new KeyEditor(pipeTrans, requestObserver);
exitCode = keyEdit.keyEditorMainLoop(callbackFunc, inputData, errorMsgObj);
} catch (ex) {
DEBUG_LOG("enigmail.js: Enigmail.editKey: caught exception from writing to pipeTrans\n");
}
switch(exitCode) {
case 0:
try {
exitCode = pipeTrans.exitCode();
} catch (ex) {
DEBUG_LOG("enigmail.js: Enigmail.editKey: caught exception from pipeTrans\n");
}
break;
case -2:
errorMsgObj.value=EnigGetString("badPhrase");
this.clearCachedPassphrase();
}
DEBUG_LOG("enigmail.js: Enigmail.editKey: GnuPG terminated with code="+exitCode+"\n");
return exitCode;
}
function signKeyCallback(inputData, keyEdit, ret) {
ret.writeTxt = "";
ret.errorMsg = "";
if (keyEdit.doCheck(GET_BOOL, "sign_uid.okay" )) {
ret.exitCode = 0;
ret.writeTxt = "Y";
}
else if (keyEdit.doCheck(GET_BOOL, "keyedit.sign_all.okay" )) {
ret.exitCode = 0;
ret.writeTxt = "Y";
}
else if (keyEdit.doCheck(GET_LINE, "sign_uid.expire" )) {
ret.exitCode = 0;
ret.writeTxt = "0";
}
else if (keyEdit.doCheck(GET_LINE, "trustsig_prompt.trust_value" )) {
ret.exitCode = 0;
ret.writeTxt = "0";
}
else if (keyEdit.doCheck(GET_LINE, "trustsig_prompt.trust_depth" )) {
ret.exitCode = 0;
ret.writeTxt = "";}
else if (keyEdit.doCheck(GET_LINE, "trustsig_prompt.trust_regexp" )) {
ret.exitCode = 0;
ret.writeTxt = "0";}
else if (keyEdit.doCheck(GET_LINE, "siggen.valid" )) {
ret.exitCode = 0;
ret.writeTxt = "0";
}
else if (keyEdit.doCheck(GET_BOOL, "sign_uid.local_promote_okay" )) {
ret.exitCode = 0;
ret.writeTxt = "Y";
}
else if (keyEdit.doCheck(GET_LINE, "sign_uid.class" )) {
ret.exitCode = 0;
ret.writeTxt = inputData.trustLevel;
}
else if (keyEdit.doCheck(GET_LINE, "keyedit.prompt")) {
ret.quitNow = true;
}
else {
ret.quitNow=true;
ERROR_LOG("Unknown command prompt: "+keyEdit.getText()+"\n");
ret.exitCode=-1;
}
}
function keyTrustCallback(inputData, keyEdit, ret) {
ret.writeTxt = "";
ret.errorMsg = "";
if (keyEdit.doCheck(GET_LINE, "edit_ownertrust.value" )) {
ret.exitCode = 0;
ret.writeTxt = inputData.trustLevel;
}
else if (keyEdit.doCheck(GET_BOOL, "edit_ownertrust.set_ultimate.okay")) {
ret.exitCode = 0;
ret.writeTxt = "Y";
}
else if (keyEdit.doCheck(GET_LINE, "keyedit.prompt")) {
ret.quitNow = true;
}
else {
ret.quitNow=true;
ERROR_LOG("Unknown command prompt: "+keyEdit.getText()+"\n");
ret.exitCode=-1;
}
}
function addUidCallback(inputData, keyEdit, ret) {
ret.writeTxt = "";
ret.errorMsg = "";
if (keyEdit.doCheck(GET_LINE, "keygen.name" )) {
++inputData.nameAsked;
if (inputData.nameAsked==1) {
ret.exitCode = 0;
ret.writeTxt = inputData.name;
}
else {
ret.exitCode=-1;
ret.quitNow=true;
ret.errorMsg="Invalid name (too short)";
}
}
else if (keyEdit.doCheck(GET_LINE, "keygen.email")) {
++inputData.emailAsked;
if (inputData.emailAsked==1) {
ret.exitCode = 0;
ret.writeTxt = inputData.email;
}
else {
ret.exitCode=-1;
ret.quitNow=true;
ret.errorMsg="Invalid email";
}
}
else if (keyEdit.doCheck(GET_LINE, "keygen.comment")) {
ret.exitCode = 0;
if (inputData.comment) {
ret.writeTxt = inputData.comment;
}
else {
ret.writeTxt="";
}
}
else if (keyEdit.doCheck(GET_LINE, "keyedit.prompt")) {
ret.quitNow = true;
}
else {
ret.quitNow=true;
ERROR_LOG("Unknown command prompt: "+keyEdit.getText()+"\n");
ret.exitCode=-1;
}
}
function revokeCertCallback(inputData, keyEdit, ret) {
ret.writeTxt = "";
ret.errorMsg = "";
if (keyEdit.doCheck(GET_LINE, "ask_revocation_reason.code" )) {
ret.exitCode = 0;
ret.writeTxt = inputData.reasonCode;
}
else if (keyEdit.doCheck(GET_LINE, "ask_revocation_reason.text" )) {
ret.exitCode = 0;
ret.writeTxt = "";
}
else if (keyEdit.doCheck(GET_BOOL, "gen_revoke.okay")) {
ret.exitCode = 0;
ret.writeTxt = "Y";
}
else if (keyEdit.doCheck(GET_BOOL, "ask_revocation_reason.okay" )) {
ret.exitCode = 0;
ret.writeTxt = "Y";
}
else if (keyEdit.doCheck(GET_BOOL, "openfile.overwrite.okay" )) {
ret.exitCode = 0;
ret.writeTxt = "Y";
}
else if (keyEdit.doCheck(GET_LINE, "keyedit.prompt")) {
ret.quitNow = true;
}
else {
ret.quitNow=true;
ERROR_LOG("Unknown command prompt: "+keyEdit.getText()+"\n");
ret.exitCode=-1;
}
}
function revokeSubkeyCallback(inputData, keyEdit, ret) {
ret.writeTxt = "";
ret.errorMsg = "";
if (keyEdit.doCheck(GET_LINE, "keyedit.prompt")) {
if (inputData.step < inputData.subkeys.length) {
ret.exitCode = 0;
ret.writeTxt = "key "+inputData.subkeys[inputData.step];
++inputData.step;
}
else if (inputData.step == inputData.subkeys.length) {
ret.exitCode = 0;
ret.writeTxt = "revkey";
++inputData.step;
}
else {
if (inputData.step == (inputData.subkeys.length+1)) {
ret.exitCode = 0;
}
else {
ret.exitCode = -1;
}
ret.quitNow = true;
}
}
else if (keyEdit.doCheck(GET_BOOL, "keyedit.revoke.subkey.okay")) {
ret.exitCode = 0;
ret.writeTxt = "Y";
}
else if (keyEdit.doCheck(GET_LINE, "ask_revocation_reason.code" )) {
ret.exitCode = 0;
ret.writeTxt = inputData.reasonCode;
}
else if (keyEdit.doCheck(GET_LINE, "ask_revocation_reason.text" )) {
ret.exitCode = 0;
ret.writeTxt = "";
}
else if (keyEdit.doCheck(GET_BOOL, "ask_revocation_reason.okay" )) {
++inputData.step;
ret.exitCode = 0;
ret.writeTxt = "Y";
}
else {
ret.quitNow=true;
ERROR_LOG("Unknown command prompt: "+keyEdit.getText()+"\n");
ret.exitCode=-1;
}
}
function setPrimaryUidCallback(inputData, keyEdit, ret) {
ret.writeTxt = "";
ret.errorMsg = "";
if (keyEdit.doCheck(GET_LINE, "keyedit.prompt" )) {
++inputData.step;
switch (inputData.step) {
case 1:
ret.exitCode = 0;
ret.writeTxt = "uid "+inputData.idNumber;
break;
case 2:
ret.exitCode = 0;
ret.writeTxt = "primary";
break;
case 3:
ret.exitCode = 0;
ret.quitNow=true;
break;
default:
ret.exitCode = -1;
ret.quitNow=true;
}
}
else {
ret.quitNow=true;
ERROR_LOG("Unknown command prompt: "+keyEdit.getText()+"\n");
ret.exitCode=-1;
}
}
function deleteUidCallback(inputData, keyEdit, ret) {
ret.writeTxt = "";
ret.errorMsg = "";
if (keyEdit.doCheck(GET_LINE, "keyedit.prompt" )) {
++inputData.step;
switch (inputData.step) {
case 1:
ret.exitCode = 0;
ret.writeTxt = "uid "+inputData.idNumber;
break;
case 2:
ret.exitCode = 0;
ret.writeTxt = "deluid";
break;
case 4:
ret.exitCode = 0;
ret.quitNow=true;
break;
default:
ret.exitCode = -1;
ret.quitNow=true;
}
}
else if (keyEdit.doCheck(GET_BOOL, "keyedit.remove.uid.okay" )) {
++inputData.step;
ret.exitCode = 0;
ret.writeTxt = "Y";
}
else {
ret.quitNow=true;
ERROR_LOG("Unknown command prompt: "+keyEdit.getText()+"\n");
ret.exitCode=-1;
}
}
function revokeUidCallback(inputData, keyEdit, ret) {
ret.writeTxt = "";
ret.errorMsg = "";
if (keyEdit.doCheck(GET_LINE, "keyedit.prompt" )) {
++inputData.step;
switch (inputData.step) {
case 1:
ret.exitCode = 0;
ret.writeTxt = "uid "+inputData.idNumber;
break;
case 2:
ret.exitCode = 0;
ret.writeTxt = "revuid";
break;
case 7:
ret.exitCode = 0;
ret.quitNow=true;
break;
default:
ret.exitCode = -1;
ret.quitNow=true;
}
}
else if (keyEdit.doCheck(GET_BOOL, "keyedit.revoke.uid.okay" )) {
++inputData.step;
ret.exitCode = 0;
ret.writeTxt = "Y";
}
else if (keyEdit.doCheck(GET_LINE, "ask_revocation_reason.code")) {
++inputData.step;
ret.exitCode = 0;
ret.writeTxt = "0"; // no reason specified
}
else if (keyEdit.doCheck(GET_LINE, "ask_revocation_reason.text")) {
++inputData.step;
ret.exitCode = 0;
ret.writeTxt = "";
}
else if (keyEdit.doCheck(GET_BOOL, "ask_revocation_reason.okay")) {
++inputData.step;
ret.exitCode = 0;
ret.writeTxt = "Y";
}
else {
ret.quitNow=true;
ERROR_LOG("Unknown command prompt: "+keyEdit.getText()+"\n");
ret.exitCode=-1;
}
}
function deleteKeyCallback(inputData, keyEdit, ret) {
ret.writeTxt = "";
ret.errorMsg = "";
if (keyEdit.doCheck(GET_BOOL, "delete_key.secret.okay")) {
ret.exitCode = 0;
ret.writeTxt = "Y";
}
else if (keyEdit.doCheck(GET_BOOL, "keyedit.remove.subkey.okay")) {
ret.exitCode = 0;
ret.writeTxt = "Y";
}
else if (keyEdit.doCheck(GET_BOOL, "delete_key.okay" )) {
ret.exitCode = 0;
ret.writeTxt = "Y";
}
else {
ret.quitNow=true;
ERROR_LOG("Unknown command prompt: "+keyEdit.getText()+"\n");
ret.exitCode=-1;
}
}
+function GetPin(domWindow, promptMsg, passwdObj) {
+ DEBUG_LOG("enigmail.js: GetPin: \n");
+
+ passwdObj.value = "";
+ var dummyObj = {};
+
+ var success = false;
+
+ var promptService = Components.classes[NS_PROMPTSERVICE_CONTRACTID].getService(Components.interfaces.nsIPromptService);
+ success = promptService.promptPassword(domWindow,
+ EnigGetString("Enigmail"),
+ promptMsg,
+ passwdObj,
+ null,
+ dummyObj);
+
+ if (!success)
+ return false;
+
+ DEBUG_LOG("enigmail.js: GetPin: got pin\n");
+
+ return true;
+}
+
+function genCardKeyCallback(inputData, keyEdit, ret) {
+ ret.writeTxt = "";
+ ret.errorMsg = "";
+
+ var pinObj={};
+
+ if (keyEdit.doCheck(GET_LINE, "cardedit.prompt")) {
+ if (inputData.step == 0) {
+ ret.exitCode = 0;
+ ret.writeTxt = "admin";
+ }
+ else if (inputData.step == 1) {
+ ret.exitCode = 0;
+ ret.writeTxt = "generate";
+ }
+ else {
+ ret.exitCode = 0;
+ ret.quitNow=true;
+ ret.writeTxt = "quit";
+ }
+ ++inputData.step;
+ }
+ else if (keyEdit.doCheck(GET_LINE, "cardedit.genkeys.backup_enc") ||
+ keyEdit.doCheck(GET_BOOL, "cardedit.genkeys.backup_enc")) {
+ ret.exitCode = 0;
+ ret.writeTxt = inputData.backupKey;
+ }
+ else if (keyEdit.doCheck(GET_BOOL, "cardedit.genkeys.replace_keys")) {
+ ret.exitCode = 0;
+ ret.writeTxt = "Y";
+ }
+ else if (keyEdit.doCheck(GET_HIDDEN, "passphrase.adminpin.ask")) {
+ ret.exitCode = 0;
+ pinObj={};
+ if (GetPin(inputData.parent, EnigGetString("enterAdminPin"), pinObj)) {
+ ret.writeTxt = pinObj.value;
+ }
+ else {
+ ret.errorMsg = EnigGetString("noPassphrase");
+ ret.quitNow=true;
+ }
+ }
+ else if (keyEdit.doCheck(GET_HIDDEN, "passphrase.pin.ask")) {
+ ret.exitCode = 0;
+ pinObj={};
+ if (GetPin(inputData.parent, EnigGetString("enterCardPin"), pinObj)) {
+ ret.writeTxt = pinObj.value;
+ }
+ else {
+ ret.errorMsg = EnigGetString("noPassphrase");
+ ret.quitNow=true;
+ }
+ }
+ else if (keyEdit.doCheck(GET_HIDDEN, "passphrase.enter")) {
+ ret.exitCode = 0;
+ ret.writeTxt = inputData.backupPasswd;
+ }
+ else if (keyEdit.doCheck(GET_LINE, "keygen.valid")) {
+ ret.exitCode = 0;
+ ret.writeTxt = inputData.expiry;
+ }
+ else if (keyEdit.doCheck(GET_LINE, "keygen.name")) {
+ ret.exitCode = 0;
+ ret.writeTxt = inputData.name;
+ }
+ else if (keyEdit.doCheck(GET_LINE, "keygen.email")) {
+ ret.exitCode = 0;
+ ret.writeTxt = inputData.email;
+ }
+ else if (keyEdit.doCheck(GET_LINE, "keygen.comment")) {
+ ret.exitCode = 0;
+ if (inputData.comment) {
+ ret.writeTxt = inputData.comment;
+ }
+ else {
+ ret.writeTxt="";
+ }
+ }
+ else {
+ ret.quitNow=true;
+ ERROR_LOG("Unknown command prompt: "+keyEdit.getText()+"\n");
+ ret.exitCode=-1;
+ }
+}
+
+function cardAdminDataCallback(inputData, keyEdit, ret) {
+ ret.writeTxt = "";
+ ret.errorMsg = "";
+
+ var pinObj={};
+
+ if (keyEdit.doCheck(GET_LINE, "cardedit.prompt")) {
+ ++inputData.step;
+ ret.exitCode = 0;
+ switch(inputData.step) {
+ case 1:
+ ret.writeTxt = "admin";
+ break;
+ case 2:
+ ret.writeTxt = "name";
+ break;
+ case 3:
+ ret.writeTxt = "lang";
+ break;
+ case 4:
+ ret.writeTxt = "sex";
+ break;
+ case 5:
+ ret.writeTxt = "url";
+ break;
+ case 6:
+ ret.writeTxt = "login";
+ break;
+ case 7:
+ if (inputData.forcepin != 0) {
+ ret.writeTxt = "forcesig";
+ break;
+ }
+ default:
+ ret.writeTxt = "quit";
+ ret.quitNow=true;
+ break;
+ }
+ }
+ else if (keyEdit.doCheck(GET_HIDDEN, "passphrase.adminpin.ask")) {
+ pinObj={};
+ if (GetPin(inputData.parent, EnigGetString("enterAdminPin"), pinObj)) {
+ ret.exitCode = 0;
+ ret.writeTxt = pinObj.value;
+ }
+ else {
+ ret.errorMsg = EnigGetString("noPassphrase");
+ ret.quitNow=true;
+ }
+ }
+ else if (keyEdit.doCheck(GET_HIDDEN, "passphrase.pin.ask")) {
+ ret.exitCode = 0;
+ pinObj={};
+ if (GetPin(inputData.parent, EnigGetString("enterCardPin"), pinObj)) {
+ ret.writeTxt = pinObj.value;
+ }
+ else {
+ ret.errorMsg = EnigGetString("noPassphrase");
+ ret.quitNow=true;
+ }
+ }
+ else if (keyEdit.doCheck(GET_LINE, "keygen.smartcard.surname")) {
+ ret.exitCode = 0;
+ ret.writeTxt = inputData.firstname;
+ }
+ else if (keyEdit.doCheck(GET_LINE, "keygen.smartcard.givenname")) {
+ ret.exitCode = 0;
+ ret.writeTxt = inputData.name;
+ }
+ else if (keyEdit.doCheck(GET_LINE, "cardedit.change_sex")) {
+ ret.exitCode = 0;
+ ret.writeTxt = inputData.sex;
+ }
+ else if (keyEdit.doCheck(GET_LINE, "cardedit.change_lang")) {
+ ret.exitCode = 0;
+ ret.writeTxt = inputData.lang;
+ }
+ else if (keyEdit.doCheck(GET_LINE, "cardedit.change_url")) {
+ ret.exitCode = 0;
+ ret.writeTxt = inputData.url;
+ }
+ else if (keyEdit.doCheck(GET_LINE, "cardedit.change_login")) {
+ ret.exitCode = 0;
+ ret.writeTxt = inputData.login;
+ }
+ else {
+ ret.quitNow=true;
+ ERROR_LOG("Unknown command prompt: "+keyEdit.getText()+"\n");
+ ret.exitCode=-1;
+ }
+}
/* Command Line handler service */
function EnigCLineService()
{}
EnigCLineService.prototype = {
/* nsISupports */
QueryInterface : function handler_QI(iid) {
if (iid.equals(nsISupports))
return this;
if (nsICmdLineHandler && iid.equals(nsICmdLineHandler))
return this;
if (nsICommandLineHandler && iid.equals(nsICommandLineHandler))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
},
commandLineArgument: "-pgpkeyman",
prefNameForStartup: "general.startup.pgpkeyman",
chromeUrlForTask: "chrome://enigmail/content/enigmailKeyManager.xul",
helpText: "Start with OpenPGP key manager",
helpInfo : " -pgpkeyman Open the OpenPGP key manager",
handlesArgs: false,
defaultArgs: "",
openWindowWithArgs: false
}
/* factory for command line handler service (EnigCLineService) */
var EnigCLineFactory = {
createInstance : function (outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
if (!iid.equals(nsICmdLineHandler) && !iid.equals(nsISupports))
throw Components.results.NS_ERROR_INVALID_ARG;
return new EnigCLineService().QueryInterface(iid);
}
}
diff --git a/package/nsIEnigmail.idl b/package/nsIEnigmail.idl
index 606cfab6..4b7acbb9 100644
--- a/package/nsIEnigmail.idl
+++ b/package/nsIEnigmail.idl
@@ -1,409 +1,433 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "MPL"); you may not use this file
* except in compliance with the MPL. You may obtain a copy of
* the MPL at http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the MPL for the specific language governing
* rights and limitations under the MPL.
*
* The Original Code is Enigmail.
*
* The Initial Developer of the Original Code is Ramalingam Saravanan.
* Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
* Copyright (C) 2001 Ramalingam Saravanan. All Rights Reserved.
*
* Contributor(s):
* Patrick Brunschwig <patrick.brunschwig@gmx.net>
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License (the "GPL"), in which case
* the provisions of the GPL are applicable instead of
* those above. If you wish to allow use of your version of this
* file only under the terms of the GPL and not to allow
* others to use your version of this file under the MPL, indicate
* your decision by deleting the provisions above and replace them
* with the notice and other provisions required by the GPL.
* If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
#include "nsISupports.idl"
#include "nsIIPCBuffer.idl"
interface nsIDOMWindow;
interface nsIDOMDocument;
interface nsIMsgWindow;
interface nsIPrompt;
interface nsIPrefBranch;
interface nsIStreamListener;
interface nsIPipeConsole;
interface nsIPipeTransport;
interface nsIIPCRequest;
interface nsIRequestObserver;
interface nsIFileOutputStream;
interface nsIIPCBuffer;
+interface nsIEnigMimeReadCallback;
/**
* The nsIEnigmail provides an openPGP-based encryption/decryption service
*/
[scriptable, uuid(847b3a00-7ab1-11d4-8f02-006008948af5)]
interface nsIEnigmail : nsISupports
{
readonly attribute string agentType; /* "gpg" or "pgp" */
readonly attribute string agentPath; /* executable path */
readonly attribute nsIPipeConsole console; /* Enigmail console */
readonly attribute boolean isWin32; /* Win32 system */
readonly attribute boolean isDosLike; /* DOS-like system (Win32, OS/2) */
readonly attribute nsIIPCRequest keygenRequest;
readonly attribute long maxIdleMinutes;
readonly attribute boolean initialized;
readonly attribute boolean initializationAttempted;
- readonly attribute string initializationError;
+ readonly attribute string initializationError;
readonly attribute boolean composeSecure;
readonly attribute nsIFileOutputStream logFileStream;
void initialize(in nsIDOMWindow domWindow, in string version,
in nsIPrefBranch enigmailPrefs);
void reinitialize();
void finalize();
boolean mimeInitialized();
void stillActive();
void clearCachedPassphrase();
string getLogDirectoryPrefix();
nsIPipeTransport encryptMessageStart(in nsIDOMWindow parent,
in nsIPrompt prompter,
in unsigned long uiFlags,
in string fromMailAddr,
in string toMailAddr,
in string hashAlgorithm,
in unsigned long sendFlags,
in nsIStreamListener listener,
in boolean noProxy,
out wstring errorMsg);
long encryptMessageEnd(in nsIDOMWindow parent,
in nsIPrompt prompter,
in unsigned long uiFlags,
in unsigned long sendFlags,
in unsigned long outputLen,
in nsIPipeTransport pipeTransport,
out unsigned long statusFlags,
out wstring errorMsg);
nsIPipeTransport decryptMessageStart(in nsIDOMWindow parent,
in nsIPrompt prompter,
in boolean verifyOnly,
in boolean noOutput,
in nsIStreamListener listener,
in boolean noProxy,
out wstring errorMsg);
long decryptMessageEnd(in unsigned long uiFlags,
in unsigned long outputLen,
in nsIPipeTransport pipeTransport,
in boolean verifyOnly,
in boolean noOutput,
out unsigned long statusFlags,
out wstring keyId,
out wstring userId,
out wstring sigDetails,
out wstring errorMsg);
boolean stripWhitespace(in unsigned long sendFlags);
long fixExitCode(in long exitCode,
in long statusFlags);
string parseErrorOutput(in string errOutput,
out unsigned long statusFlags,
out wstring statusMsg);
string locateArmoredBlock(in string text,
in long offset,
in string indentStr,
out long beginIndex,
out long endIndex,
out string foundIndentStr);
/* Cleartext signature parts */
const long SIGNATURE_TEXT = 1;
const long SIGNATURE_HEADERS = 2;
const long SIGNATURE_ARMOR = 3;
string extractSignaturePart(in string signatureBlock,
in long part);
/* User interaction flags */
const long UI_INTERACTIVE = 0x01;
const long UI_ALLOW_KEY_IMPORT = 0x02;
const long UI_UNVERIFIED_ENC_OK = 0x04;
const long UI_PGP_MIME = 0x08;
const long UI_TEST = 0x10;
const long UI_RESTORE_STRICTLY_MIME = 0x20;
/* Send message flags */
const long SEND_SIGNED = 0x001;
const long SEND_ENCRYPTED = 0x002;
const long SEND_DEFAULT = 0x004;
const long SEND_LATER = 0x008;
const long SEND_WITH_CHECK = 0x010;
const long SEND_ALWAYS_TRUST = 0x020;
const long SEND_ENCRYPT_TO_SELF = 0x040;
const long SEND_PGP_MIME = 0x080;
const long SEND_TEST = 0x100;
const long SAVE_MESSAGE = 0x200;
const long SEND_STRIP_WHITESPACE = 0x400;
wstring encryptMessage(in nsIDOMWindow parent,
in unsigned long uiFlags,
in string plainText,
in string fromMailAddr,
in string toMailAddr,
in unsigned long sendFlags,
out long exitCode,
out unsigned long statusFlags,
out wstring errorMsg);
/* Status flags */
const long GOOD_SIGNATURE = 0x000001;
const long BAD_SIGNATURE = 0x000002;
const long UNVERIFIED_SIGNATURE = 0x000004;
const long EXPIRED_SIGNATURE = 0x000008;
const long EXPIRED_KEY_SIGNATURE= 0x000010;
const long EXPIRED_KEY = 0x000020;
const long REVOKED_KEY = 0x000040;
const long NO_PUBKEY = 0x000080;
const long NO_SECKEY = 0x000100;
const long IMPORTED_KEY = 0x000200;
const long INVALID_RECIPIENT = 0x000400;
const long MISSING_PASSPHRASE = 0x000800;
const long BAD_PASSPHRASE = 0x001000;
const long BAD_ARMOR = 0x002000;
const long NODATA = 0x004000;
const long DECRYPTION_INCOMPLETE= 0x008000;
const long DECRYPTION_FAILED = 0x010000;
const long DECRYPTION_OKAY = 0x020000;
const long UNTRUSTED_IDENTITY = 0x040000;
const long TRUSTED_IDENTITY = 0x080000;
const long PGP_MIME_SIGNED = 0x100000;
const long PGP_MIME_ENCRYPTED = 0x200000;
const long DISPLAY_MESSAGE = 0x400000;
const long INLINE_KEY = 0x800000;
const long PARTIALLY_PGP = 0x1000000;
const long PHOTO_AVAILABLE = 0x2000000;
const long OVERFLOWED = 0x4000000;
wstring decryptMessage(in nsIDOMWindow parent,
in unsigned long uiFlags,
in string cipherText,
inout string signature,
out long exitCode,
out unsigned long statusFlags,
out wstring keyId,
out wstring userId,
out wstring sigDetails,
out wstring errorMsg);
boolean deleteMessageURI(in string uri);
boolean selectPanel(in string url);
/*** key handling functions ***/
long setKeyTrust(in nsIDOMWindow parent,
in string keyId,
in string trustLevel,
out wstring errorMsg);
long signKey(in nsIDOMWindow parent,
in string userId,
in string keyId,
in boolean signLocally,
in string trustLevel,
out wstring errorMsg);
long genRevokeCert(in nsIDOMWindow parent,
in string keyId,
in string outFile,
in string reasonCode,
in string reasonText,
out wstring errorMsg);
long revokeSubey (in nsIDOMWindow parent,
in string keyId,
in string subkeys,
in string reasonCode,
in string reasonText,
out wstring errorMsgObj);
long addUid(in nsIDOMWindow parent,
in string keyId,
in string name,
in string email,
in string comment,
out wstring errorMsg);
long deleteKey(in nsIDOMWindow parent,
in string keyId,
in boolean deleteSecretKey,
out wstring errorMsg);
long enableDisableKey(in nsIDOMWindow parent,
in string keyId,
in boolean disableKey,
out wstring errorMsgObj);
long setPrimaryUid (in nsIDOMWindow parent,
in string keyId,
in string idNumber,
out wstring errorMsg);
long deleteUid (in nsIDOMWindow parent,
in string keyId,
in string idNumber,
out wstring errorMsg);
long revokeUid (in nsIDOMWindow parent,
in string keyId,
in string idNumber,
out wstring errorMsg);
string getKeySig (in string keyId,
out long exitCode,
out wstring errorMsg);
string getKeyDetails (in string keyId,
in boolean uidOnly);
string showKeyPhoto (in string keyId,
out long exitCode,
out wstring errorMsg);
const long EXTRACT_SECRET_KEY = 0x01;
string extractKey(in nsIDOMWindow parent,
in unsigned long exportFlags,
in string userId,
in string outputFile,
out long exitCode,
out wstring errorMsg);
long importKey(in nsIDOMWindow parent,
in unsigned long uiFlags,
in string msgText,
in string keyId,
out wstring errorMsg);
long importKeyFromFile(in nsIDOMWindow parent,
in string fileName,
out string errorMsg);
nsIIPCRequest generateKey(in nsIDOMWindow parent,
in string name,
in string comment,
in string email,
in long expiryDate,
in long keyLength,
in string passphrase,
in nsIRequestObserver requestObserver);
/* Receive flags */
const long SEARCH_KEY = 0x01;
const long DOWNLOAD_KEY = 0x02;
const long UPLOAD_KEY = 0x04;
nsIIPCRequest searchKey(in unsigned long recvFlags,
in string protocol,
in string keyServer,
in string port,
in string keyValue,
in nsIRequestObserver requestObserver,
out wstring errorMsg);
nsIIPCRequest receiveKey(in unsigned long recvFlags,
in string keyServer,
in string keyId,
in nsIRequestObserver requestObserver,
out wstring errorMsg);
string createMessageURI(in string originalUrl,
in string contentType,
in string contentCharset,
in string contentData,
in boolean persist);
/* manage GPG key list cache */
string getUserIdList (in boolean secretOnly,
in boolean refresh,
out long exitCode,
out unsigned long statusFlags,
out wstring errorMsg);
void invalidateUserIdList();
/* attachment handling */
string encryptAttachment (in nsIDOMWindow parent,
in string fromMailAddr,
in string toMailAddr,
in unsigned long sendFlags,
in wstring inFile,
in wstring outFile,
out long exitCode,
out unsigned long statusFlags,
out wstring errorMsg);
boolean decryptAttachment (in nsIDOMWindow parent,
in string outFileName,
in string displayName,
in nsIIPCBuffer ipcBuffer,
out long exitCode,
out unsigned long statusFlags,
out wstring errorMsg);
/* per-recipient rules */
boolean getRulesData(out nsIDOMDocument rulesList);
void addRule(in boolean appendToEnd,
in string toAddress,
in string keyList,
in long sign,
in long encrypt,
in long pgpMime,
in long flags);
boolean saveRulesFile();
void clearRules();
+
+ /* smartcard functions */
+ string getCardStatus (out long exitCode,
+ out wstring errorMsg);
+
+ long genCardKey (in nsIDOMWindow parent,
+ in string name,
+ in string email,
+ in string comment,
+ in string expiry,
+ in string backupPasswd,
+ in nsIEnigMimeReadCallback requestObserver,
+ out wstring errorMsg);
+
+ long cardAdminData(in nsIDOMWindow parent,
+ in string name,
+ in string firstname,
+ in string lang,
+ in string sex,
+ in string url,
+ in string login,
+ in long forcepin,
+ out wstring errorMsg);
};
%{C++
#define NS_ENIGMAIL_CLASSNAME "Enigmail"
#define NS_ENIGMAIL_CONTRACTID "@mozdev.org/enigmail/enigmail;1"
#define NS_ENIGMAIL_CID \
{ /* 847b3a01-7ab1-11d4-8f02-006008948af5 */ \
0x847b3a01, 0x7ab1, 0x11d4, \
{0x8f, 0x02, 0x00, 0x60, 0x08, 0x94, 0x8a, 0xf5} }
%}
//////////////////////////////////////////////////////////////////////////////
diff --git a/public/Makefile.in b/public/Makefile.in
index 6f57e25a..de38d6cd 100644
--- a/public/Makefile.in
+++ b/public/Makefile.in
@@ -1,54 +1,55 @@
#!gmake
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "MPL"); you may not use this file
# except in compliance with the MPL. You may obtain a copy of
# the MPL at http://www.mozilla.org/MPL/
#
# Software distributed under the MPL is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the MPL for the specific language governing
# rights and limitations under the MPL.
#
# The Original Code is Enigmail.
#
# The Initial Developer of the Original Code is Ramalingam Saravanan.
# Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
# Copyright (C) 2001 Ramalingam Saravanan. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU General Public License (the "GPL"), in which case
# the provisions of the GPL are applicable instead of
# those above. If you wish to allow use of your version of this
# file only under the terms of the GPL and not to allow
# others to use your version of this file under the MPL, indicate
# your decision by deleting the provisions above and replace them
# with the notice and other provisions required by the GPL.
# If you do not delete the provisions above, a recipient
# may use your version of this file under either the MPL or the
# GPL.
#
# Makefile for public directory
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = enigmime
XPIDL_MODULE = enigmime
XPIDLSRCS = nsIEnigMsgCompFields.idl \
nsIEnigMimeService.idl \
nsIEnigMimeDecrypt.idl \
nsIEnigMimeVerify.idl \
nsIEnigMimeHeaderSink.idl \
nsIEnigMimeWriter.idl \
- nsIEnigMimeListener.idl
+ nsIEnigMimeListener.idl \
+ nsIEnigMimeReadCallback.idl
include $(topsrcdir)/config/rules.mk
diff --git a/ui/content/enigRetrieveProgress.xul b/ui/content/enigRetrieveProgress.xul
index b73b273b..17e48f49 100644
--- a/ui/content/enigRetrieveProgress.xul
+++ b/ui/content/enigRetrieveProgress.xul
@@ -1,91 +1,91 @@
<?xml version="1.0"?>
<!--
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "MPL"); you may not use this file
except in compliance with the MPL. You may obtain a copy of
the MPL at http://www.mozilla.org/MPL/
Software distributed under the MPL is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the MPL for the specific language governing
rights and limitations under the MPL.
The Original Code is Enigmail.
The Initial Developer of this code is Patrick Brunschwig.
Portions created by Patrick Brunschwig <patrick.brunschwig@gmx.net>
are Copyright (C) 2004 Patrick Brunschwig.
All Rights Reserved.
Contributor(s):
Alternatively, the contents of this file may be used under the
terms of the GNU General Public License (the "GPL"), in which case
the provisions of the GPL are applicable instead of
those above. If you wish to allow use of your version of this
file only under the terms of the GPL and not to allow
others to use your version of this file under the MPL, indicate
your decision by deleting the provisions above and replace them
with the notice and other provisions required by the GPL.
If you do not delete the provisions above, a recipient
may use your version of this file under either the MPL or the
GPL.
-->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://messenger/skin/dialogs.css" type="text/css"?>
<?xml-stylesheet href="chrome://enigmail/skin/enigmail.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://enigmail/locale/enigmail.dtd">
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
class="dialog"
title="&enigmail.retrieveKey.label;"
style="width: 36em;"
onload="onLoad()"
onunload="onUnload()">
<script type="application/x-javascript" src="chrome://enigmail/content/enigRetrieveProgress.js"/>
<grid flex="1">
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row>
<hbox pack="end">
<label id="dialog.dummy1" value=" "/>
</hbox>
<label id="dialog.status" crop="center" value=" "/>
</row>
<row class="thin-separator">
<hbox pack="end">
<label value="&enigmail.progressText.label;"/>
</hbox>
<progressmeter id="dialog.progress" mode="normal" value="0"/>
<hbox pack="end">
<label id="dialog.progressText"/>
</hbox>
</row>
<row>
<hbox pack="end">
<label id="dialog.dummy2" value=" "/>
</hbox>
<vbox>
<separator/>
- <label id="dialog.status2" crop="center" value="Retrieving key, please wait ..."/>
+ <label id="dialog.status2" crop="center" value="&enigmail.retrieveKey.retrieveMsg.label;"/>
</vbox>
</row>
</rows>
</grid>
<separator/>
<hbox id="CancelButton" pack="center">
<button id="cancel" label="&enigmail.cancelKey.label;" oncommand="doCancelButton()"/>
</hbox>
</window>
diff --git a/ui/content/enigmailKeyManager.js b/ui/content/enigmailKeyManager.js
index b6a84ac8..fcb78d06 100755
--- a/ui/content/enigmailKeyManager.js
+++ b/ui/content/enigmailKeyManager.js
@@ -1,1035 +1,1045 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "MPL"); you may not use this file
* except in compliance with the MPL. You may obtain a copy of
* the MPL at http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the MPL for the specific language governing
* rights and limitations under the MPL.
*
* The Original Code is Enigmail.
*
* The Initial Developer of this code is Patrick Brunschwig.
* Portions created by Patrick Brunschwig <patrick.brunschwig@gmx.net>
* are Copyright (C) 2004 Patrick Brunschwig.
* All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License (the "GPL"), in which case
* the provisions of the GPL are applicable instead of
* those above. If you wish to allow use of your version of this
* file only under the terms of the GPL and not to allow
* others to use your version of this file under the MPL, indicate
* your decision by deleting the provisions above and replace them
* with the notice and other provisions required by the GPL.
* If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
// Uses: chrome://enigmail/content/enigmailCommon.js
// Initialize enigmailCommon
EnigInitCommon("enigmailKeyManager");
const INPUT = 0;
const RESULT = 1;
// field ID's of key list (as described in the doc/DETAILS file in the GnuPG distribution)
const KEY_TRUST=1;
const KEY_ID = 4;
const CREATED = 5;
const EXPIRY = 6;
const OWNERTRUST = 8;
const USER_ID = 9;
const KEY_USE_FOR = 11;
const KEY_EXPIRED="e";
const KEY_REVOKED="r";
const KEY_INVALID="i";
const KEY_DISABLED="d";
const KEY_NOT_VALID=KEY_EXPIRED+KEY_REVOKED+KEY_INVALID+KEY_DISABLED;
var gUserList;
var gResult;
var gSendEncrypted=true;
var gKeyList;
var gEnigRemoveListener = false;
var gEnigLastSelectedKeys = null;
var gKeySortList = null;
var gEnigIpcRequest = null;
var gEnigCallbackFunc = null;
var gClearButton = null;
var gFilterBox = null;
var gSearchTimer = null;
var gSearchInput = null;
function enigmailKeyManagerLoad() {
DEBUG_LOG("enigmailKeyManager.js: Load\n");
gUserList = document.getElementById("pgpKeyList");
gFilterBox = document.getElementById("filterKey");
gClearButton = document.getElementById("clearFilter");
gSearchInput = document.getElementById("filterKey");
window.enigIpcRequest = null;
enigmailBuildList(false);
}
function enigmailRefreshKeys() {
var keyList = enigmailGetSelectedKeys();
gEnigLastSelectedKeys = [];
for (var i=0; i<keyList.length; i++) {
gEnigLastSelectedKeys[keyList[i]] = 1;
}
var treeChildren = document.getElementById("pgpKeyListChildren");
while (treeChildren.firstChild) {
treeChildren.removeChild(treeChildren.firstChild);
}
enigmailBuildList(true);
enigApplyFilter();
}
function enigLoadKeyList(secretOnly, refresh) {
DEBUG_LOG("enigmailMessengerOverlay.js: enigLoadKeyList\n");
try {
var exitCodeObj = new Object();
var statusFlagsObj = new Object();
var errorMsgObj = new Object();
var enigmailSvc = GetEnigmailSvc();
if (! enigmailSvc)
return null;
var userList = enigmailSvc.getUserIdList(secretOnly,
refresh,
exitCodeObj,
statusFlagsObj,
errorMsgObj);
if (exitCodeObj.value != 0) {
EnigAlert(errorMsgObj.value);
return null;
}
} catch (ex) {
ERROR_LOG("ERROR in enigmailUserSelection: enigLoadKeyList\n");
}
if (typeof(userList) == "string") {
return userList.split(/\n/);
}
else {
return [];
}
}
function enigmailBuildList(refresh) {
DEBUG_LOG("enigmailUserSelection.js: enigmailBuildList\n");
var sortUsers = function (a, b) {
if (a.userId.toLowerCase()<b.userId.toLowerCase()) { return -1;} else {return 1; }
}
var aGpgUserList = enigLoadKeyList(false, refresh);
if (!aGpgUserList) return;
var aGpgSecretsList = enigLoadKeyList(true, refresh);
if (!aGpgSecretsList && !refresh) {
if (EnigConfirm(EnigGetString("noSecretKeys"))) {
EnigKeygen();
enigmailRefreshKeys(true);
}
}
gUserList.currentItem=null;
var treeChildren=document.getElementById("pgpKeyListChildren");
gKeyList = new Array();
var gKeySortList = new Array();
var keyObj = new Object();
var i;
for (i=0; i<aGpgUserList.length; i++) {
var listRow=aGpgUserList[i].split(/:/);
if (listRow.length>=0) {
switch (listRow[0]) {
case "pub":
keyObj = new Object();
keyObj.expiry=listRow[EXPIRY];
keyObj.created=listRow[CREATED];
keyObj.userId=EnigConvertGpgToUnicode(listRow[USER_ID].replace(/\\e3A/g, ":"));
keyObj.keyId=listRow[KEY_ID];
keyObj.keyTrust=listRow[KEY_TRUST];
keyObj.keyUseFor=listRow[KEY_USE_FOR];
keyObj.ownerTrust=listRow[OWNERTRUST];
keyObj.SubUserIds=new Array();
keyObj.fpr="";
keyObj.photoAvailable=false;
keyObj.secretAvailable=false;
gKeyList[listRow[KEY_ID]] = keyObj;
gKeySortList.push({userId: keyObj.userId, keyId: keyObj.keyId});
break;
case "fpr":
keyObj.fpr=listRow[USER_ID];
break;
case "uid":
var subUserId = {
userId: EnigConvertGpgToUnicode(listRow[USER_ID].replace(/\\e3A/g, ":")),
keyTrust: listRow[KEY_TRUST],
type: "uid"
}
keyObj.SubUserIds.push(subUserId);
break;
case "uat":
if (listRow[USER_ID].indexOf("1 ")==0) {
var userId=EnigGetString("userAtt.photo");
keyObj.SubUserIds.push({userId: userId, keyTrust:"", type: "uat"});
keyObj.photoAvailable=true;
}
}
}
}
// search and mark keys that have secret keys
for (i=0; i<aGpgSecretsList.length; i++) {
listRow=aGpgSecretsList[i].split(/:/);
if (listRow.length>=0) {
if (listRow[0] == "sec") {
if (typeof(gKeyList[listRow[KEY_ID]]) == "object") {
gKeyList[listRow[KEY_ID]].secretAvailable=true;
}
}
}
}
gKeySortList.sort(sortUsers);
var selectedItems=[];
for (i=0; i < gKeySortList.length; i++) {
var keyId = gKeySortList[i].keyId;
if (gEnigLastSelectedKeys && typeof(gEnigLastSelectedKeys[keyId]) != "undefined")
selectedItems.push(i);
var treeItem=null;
treeItem=enigUserSelCreateRow(gKeyList[keyId], -1)
if (gKeyList[keyId].SubUserIds.length) {
treeItem.setAttribute("container", "true");
var subChildren=document.createElement("treechildren");
for (var subkey=0; subkey<gKeyList[keyId].SubUserIds.length; subkey++) {
var subItem=enigUserSelCreateRow(gKeyList[keyId], subkey);
subChildren.appendChild(subItem);
}
treeItem.appendChild(subChildren);
}
if (treeItem)
treeChildren.appendChild(treeItem);
}
gUserList.appendChild(treeChildren);
// select last selected key
if (selectedItems.length>0) {
gUserList.view.selection.select(selectedItems[0]);
for (i=1; i<selectedItems.length; i++) {
gUserList.view.selection.rangedSelect(selectedItems[i], selectedItems[i], true)
}
}
else {
gUserList.view.selection.select(0);
}
}
// create a (sub) row for the user tree
function enigUserSelCreateRow (keyObj, subKeyNum) {
var expCol=document.createElement("treecell");
var userCol=document.createElement("treecell");
var keyCol=document.createElement("treecell");
var typeCol=document.createElement("treecell");
var validCol=document.createElement("treecell");
var trustCol=document.createElement("treecell");
var fprCol=document.createElement("treecell");
var userRow=document.createElement("treerow");
var treeItem=document.createElement("treeitem");
userCol.setAttribute("id", "name");
if (subKeyNum <0) {
// primary key
userCol.setAttribute("label", keyObj.userId);
keyCol.setAttribute("label", keyObj.keyId.substr(-8,8));
if (keyObj.secretAvailable) {
typeCol.setAttribute("label", EnigGetString("keyType.publicAndSec"));
}
else {
typeCol.setAttribute("label", EnigGetString("keyType.public"));
}
var keyTrust = keyObj.keyTrust;
treeItem.setAttribute("keytype", "pub");
fprCol.setAttribute("label",EnigFormatFpr(keyObj.fpr));
}
else {
// secondary user id
keyObj.SubUserIds[subKeyNum].userId = EnigConvertGpgToUnicode(keyObj.SubUserIds[subKeyNum].userId);
userCol.setAttribute("label", keyObj.SubUserIds[subKeyNum].userId);
treeItem.setAttribute("keytype", keyObj.SubUserIds[subKeyNum].type);
keyCol.setAttribute("label", "");
typeCol.setAttribute("label", "");
keyTrust = keyObj.SubUserIds[subKeyNum].keyTrust;
}
var keyTrustLabel = EnigGetTrustLabel(keyTrust);
expCol.setAttribute("label", keyObj.expiry);
expCol.setAttribute("id", "expiry");
if (keyObj.keyUseFor.indexOf("D")>=0) {
keyTrustLabel=EnigGetString("keyValid.disabled");
}
validCol.setAttribute("label", keyTrustLabel);
trustCol.setAttribute("label", EnigGetTrustLabel(keyObj.ownerTrust));
keyCol.setAttribute("id", "keyid");
typeCol.setAttribute("id", "keyType");
validCol.setAttribute("id", "keyValid");
trustCol.setAttribute("id", "ownerTrust")
userRow.appendChild(userCol);
userRow.appendChild(keyCol);
userRow.appendChild(typeCol);
userRow.appendChild(validCol);
userRow.appendChild(trustCol);
userRow.appendChild(expCol);
userRow.appendChild(fprCol);
if ((keyTrust.length>0) &&
(KEY_NOT_VALID.indexOf(keyTrust.charAt(0))>=0) ||
(keyObj.keyUseFor.indexOf("D")>=0)) {
for (var node=userRow.firstChild; node; node=node.nextSibling) {
node.setAttribute("properties", "enigKeyInactive");
}
}
if (keyObj.secretAvailable && subKeyNum <0) {
for (node=userRow.firstChild; node; node=node.nextSibling) {
var attr=node.getAttribute("properties");
if (typeof(attr)=="string") {
node.setAttribute("properties", attr+" enigmailOwnKey");
}
else {
node.setAttribute("properties", "enigmailOwnKey");
}
}
}
treeItem.setAttribute("id", keyObj.keyId);
treeItem.appendChild(userRow);
return treeItem;
}
function enigmailGetSelectedKeys() {
var idList = new Array();
var rangeCount = gUserList.view.selection.getRangeCount();
for(var i=0; i<rangeCount; i++)
{
var start = {};
var end = {};
gUserList.view.selection.getRangeAt(i,start,end);
for(var c=start.value; c<=end.value; c++)
{
try {
idList.push(gUserList.view.getItemAtIndex(c).id);
}
catch(ex) {
return [];
}
}
}
return idList;
}
function enigmailKeyMenu() {
var keyList = enigmailGetSelectedKeys();
if (keyList.length == 1 && gKeyList[keyList[0]].secretAvailable) {
document.getElementById("bcRevoke").removeAttribute("disabled");
document.getElementById("bcManageUid").removeAttribute("disabled");
}
else {
document.getElementById("bcRevoke").setAttribute("disabled", "true");
document.getElementById("bcManageUid").setAttribute("disabled", "true");
}
if (keyList.length == 1 && gKeyList[keyList[0]].photoAvailable) {
document.getElementById("bcViewPhoto").removeAttribute("disabled");
}
else {
document.getElementById("bcViewPhoto").setAttribute("disabled", "true");
}
if (keyList.length == 1) {
document.getElementById("bcSignKey").removeAttribute("disabled");
document.getElementById("bcViewSig").removeAttribute("disabled");
document.getElementById("bcKeyDetails").removeAttribute("disabled");
document.getElementById("bcDeleteKey").removeAttribute("disabled");
document.getElementById("bcEnableKey").removeAttribute("disabled");
if (gKeyList[keyList[0]].keyUseFor.indexOf("D")>0 ||
gKeyList[keyList[0]].keyTrust.indexOf(KEY_DISABLED)>=0) {
document.getElementById("bcEnableKey").setAttribute("label", EnigGetString("keyMan.enableKey"))
}
else {
document.getElementById("bcEnableKey").setAttribute("label", EnigGetString("keyMan.disableKey"))
}
}
else {
document.getElementById("bcSignKey").setAttribute("disabled", "true");
document.getElementById("bcViewSig").setAttribute("disabled", "true");
document.getElementById("bcKeyDetails").setAttribute("disabled", "true");
document.getElementById("bcDeleteKey").setAttribute("disabled", "true");
document.getElementById("bcEnableKey").setAttribute("disabled", "true");
}
}
function enigmailDblClick(event) {
if (event) {
if (event.button != 0) return;
}
var keyList = enigmailGetSelectedKeys();
var keyType="";
if (keyList.length == 1) {
var rangeCount = gUserList.view.selection.getRangeCount();
var start = {};
var end = {};
gUserList.view.selection.getRangeAt(0,start,end);
try {
keyType = gUserList.view.getItemAtIndex(start.value).getAttribute("keytype");
}
catch(ex) {}
}
if (keyType=="uat") {
enigShowPhoto();
}
else {
enigmailKeyDetails();
}
}
function enigmailKeyDetails() {
var keyList = enigmailGetSelectedKeys();
var inputObj = {
keyId: keyList[0],
secKey: gKeyList[ keyList[0]].secretAvailable
};
window.openDialog("chrome://enigmail/content/enigmailKeyDetailsDlg.xul",
"", "dialog,modal,centerscreen", inputObj);
}
function enigmailDeleteKey() {
var keyList = enigmailGetSelectedKeys();
var enigmailSvc = GetEnigmailSvc();
if (!enigmailSvc)
return;
var userId="0x"+keyList[0].substr(-8,8)+" - "+gKeyList[keyList[0]].userId;
var deleteSecret=false;
if(gKeyList[keyList[0]].secretAvailable) {
if (!EnigConfirm(EnigGetString("deleteSecretKey", userId))) return;
deleteSecret=true;
}
else {
if (!EnigConfirm(EnigGetString("deletePubKey", userId))) return;
}
var errorMsgObj = {};
var r=enigmailSvc.deleteKey(window, "0x"+keyList[0], deleteSecret, errorMsgObj);
if (r != 0) {
EnigAlert(EnigGetString("deleteKeyFailed")+"\n\n"+errorMsgObj.value);
}
else {
EnigAlert(EnigGetString("deleteKeyOk"));
}
enigmailRefreshKeys();
}
function enigmailEnableKey() {
var keyList = enigmailGetSelectedKeys();
var disableKey = (gKeyList[keyList[0]].keyUseFor.indexOf("D")<0 &&
gKeyList[keyList[0]].keyTrust.indexOf(KEY_DISABLED)<0);
var enigmailSvc = GetEnigmailSvc();
if (!enigmailSvc)
return;
var errorMsgObj = {};
var r=enigmailSvc.enableDisableKey(window, "0x"+keyList[0], disableKey, errorMsgObj);
if (r != 0) {
EnigAlert(EnigGetString("enableKeyFailed")+"\n\n"+errorMsgObj.value);
}
enigmailRefreshKeys();
}
function enigShowPhoto() {
var keyList = enigmailGetSelectedKeys();
EnigShowPhoto(keyList[0], gKeyList[keyList[0]].userId);
}
function enigEditKeyTrust() {
var keyList = enigmailGetSelectedKeys();
if (keyList.length==0) {
EnigAlert(EnigGetString("noKeySelected"));
return;
}
var userIdList = [];
for (var i=0; i < keyList.length; i++) {
userIdList.push(gKeyList[keyList[i]].userId);
}
EnigEditKeyTrust(userIdList, keyList);
enigmailRefreshKeys();
}
function enigSignKey() {
var keyList = enigmailGetSelectedKeys();
if (keyList.length==0) {
EnigAlert(EnigGetString("noKeySelected"));
return;
}
EnigSignKey(gKeyList[keyList[0]].userId, keyList[0], null);
enigmailRefreshKeys();
}
function enigmailRevokeKey() {
var keyList = enigmailGetSelectedKeys();
var enigmailSvc = GetEnigmailSvc();
if (!enigmailSvc)
return;
var userId="0x"+keyList[0].substr(-8,8)+" - "+gKeyList[keyList[0]].userId;
if (!EnigConfirm(EnigGetString("revokeKeyAsk", userId))) return;
var tmpDir=EnigGetTempDir();
try {
var revFile = Components.classes[ENIG_LOCAL_FILE_CONTRACTID].createInstance(Components.interfaces.nsILocalFile);
revFile.initWithPath(tmpDir);
if (!(revFile.isDirectory() && revFile.isWritable())) {
EnigAlert(EnigGetString("noTempDir"));
return;
}
}
catch (ex) {}
revFile.append("revkey.asc");
revFile.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0600);
var errorMsgObj = {};
var r=enigmailSvc.genRevokeCert(window, "0x"+keyList[0], revFile.path, "0", "", errorMsgObj);
if (r != 0) {
revFile.remove(false);
EnigAlert(EnigGetString("revokeKeyFailed")+"\n\n"+errorMsgObj.value);
return;
}
r = enigmailSvc.importKeyFromFile(window, revFile.path, errorMsgObj);
revFile.remove(false);
if (r != 0) {
EnigAlert(EnigGetString("revokeKeyFailed")+"\n\n"+errorMsgObj.value);
}
else {
EnigAlert(EnigGetString("revokeKeyOk"));
}
enigmailRefreshKeys();
}
function enigCreateRevokeCert() {
var keyList = enigmailGetSelectedKeys();
EnigCreateRevokeCert(keyList[0], gKeyList[keyList[0]].userId);
}
function enigmailExportKeys() {
var keyList = enigmailGetSelectedKeys();
if (keyList.length==0) {
EnigAlert(EnigGetString("noKeySelected"));
return;
}
var exportFlags = 0;
if (gKeyList[keyList[0]].secretAvailable) {
if (EnigConfirm(EnigGetString("exportSecretKey"))) {
exportFlags |= nsIEnigmail.EXTRACT_SECRET_KEY;
}
}
var enigmailSvc = GetEnigmailSvc();
if (!enigmailSvc)
return;
if (keyList.length==1) {
var defaultFileName = gKeyList[keyList[0]].userId.replace(/[\<\>]/g, "");
if (exportFlags & nsIEnigmail.EXTRACT_SECRET_KEY) {
defaultFileName = EnigGetString("specificPubSecKeyFilename", defaultFileName, keyList[0].substr(-8,8))+".asc";
}
else {
defaultFileName = EnigGetString("specificPubKeyFilename", defaultFileName, keyList[0].substr(-8,8))+".asc";
}
}
else {
if (exportFlags & nsIEnigmail.EXTRACT_SECRET_KEY) {
defaultFileName = EnigGetString("defaultPubSecKeyFilename")+".asc"
}
else {
defaultFileName = EnigGetString("defaultPubKeyFilename")+".asc"
}
}
var outFile = EnigFilePicker(EnigGetString("exportToFile"),
"", true, "*.asc",
defaultFileName,
[EnigGetString("asciiArmorFile"), "*.asc"]);
if (! outFile) return;
var keyListStr = "0x"+keyList.join(" 0x");
var exitCodeObj = {};
var errorMsgObj = {};
enigmailSvc.extractKey(window, exportFlags, keyListStr, outFile.path, exitCodeObj, errorMsgObj);
if (exitCodeObj.value != 0) {
EnigAlert(EnigGetString("saveKeysFailed")+"\n\n"+errorMsgObj.value);
}
else {
EnigAlert(EnigGetString("saveKeysOK"));
}
}
function enigmailImportKeysFromFile() {
var enigmailSvc = GetEnigmailSvc();
if (!enigmailSvc)
return;
var inFile = EnigFilePicker(EnigGetString("importFile"),
"", false, "*.asc", "",
[EnigGetString("gnupgFile"), "*.asc;*.gpg;*.pgp"]);
if (! inFile) return;
var errorMsgObj = {};
var exitCode =enigmailSvc.importKeyFromFile(window, inFile.path, errorMsgObj);
if (exitCode != 0) {
EnigAlert(EnigGetString("importKeysFailed")+"\n\n"+errorMsgObj.value);
}
else {
EnigLongAlert(EnigGetString("successKeyImport")+"\n\n"+errorMsgObj.value);
}
enigmailRefreshKeys();
}
function enigmailSearchKeys () {
var inputObj = {
searchList : ""
};
var resultObj = new Object();
window.openDialog("chrome://enigmail/content/enigmailSearchKey.xul",
"", "dialog,modal,centerscreen", inputObj, resultObj);
if (resultObj.importedKeys > 0) {
enigmailRefreshKeys();
}
}
function enigmailListSig() {
var keyList = enigmailGetSelectedKeys();
var inputObj = {
keyId: keyList[0],
keyListArr: gKeyList
};
window.openDialog("chrome://enigmail/content/enigmailViewKeySigDlg.xul",
"", "dialog,modal,centerscreen,resizable=yes", inputObj);
}
function enigmailManageUids() {
var keyList = enigmailGetSelectedKeys();
var inputObj = {
keyId: keyList[0]
};
window.openDialog("chrome://enigmail/content/enigmailManageUidDlg.xul",
"", "dialog,modal,centerscreen,resizable", inputObj);
enigmailRefreshKeys();
}
function enigmailImportFromClipbrd() {
var enigmailSvc = GetEnigmailSvc();
if (!enigmailSvc)
return;
if (!EnigConfirm(EnigGetString("importFromClip"))) {
return;
}
var clipBoard = Components.classes[ENIG_CLIPBOARD_CONTRACTID].getService(Components.interfaces.nsIClipboard);
try {
var transferable = Components.classes[ENIG_TRANSFERABLE_CONTRACTID].createInstance(Components.interfaces.nsITransferable);
transferable.addDataFlavor("text/unicode");
clipBoard.getData(transferable, clipBoard.kGlobalClipboard);
var flavour = {};
var data = {};
var length = {};
transferable.getAnyTransferData(flavour, data, length);
var cBoardContent=data.value.QueryInterface(Components.interfaces.nsISupportsString).data;
DEBUG_LOG("enigmailKeyManager.js: enigmailImportFromClipbrd: got data from clipboard");
}
catch(ex) {}
var errorMsgObj = {};
var r=enigmailSvc.importKey(window, 0, cBoardContent, "", errorMsgObj);
EnigLongAlert(errorMsgObj.value);
enigmailRefreshKeys();
}
function enigmailCopyToClipbrd() {
var enigmailSvc = GetEnigmailSvc();
if (!enigmailSvc)
return;
var keyList = enigmailGetSelectedKeys();
if (keyList.length==0) {
EnigAlert(EnigGetString("noKeySelected"));
return;
}
var exitCodeObj={};
var errorMsgObj={};
var keyData = enigmailSvc.extractKey(window, 0, "0x"+keyList.join(" 0x"), null, exitCodeObj, errorMsgObj);
if (exitCodeObj.value != 0) {
EnigAlert(EnigGetString("copyToClipbrdFailed")+"\n\n"+errorMsgObj.value);
return;
}
var clipBoard = Components.classes[ENIG_CLIPBOARD_CONTRACTID].getService(Components.interfaces.nsIClipboard);
try {
clipBoardHlp = Components.classes[ENIG_CLIPBOARD_HELPER_CONTRACTID].getService(Components.interfaces.nsIClipboardHelper);
clipBoardHlp.copyStringToClipboard(keyData, clipBoard.kGlobalClipboard);
if (clipBoard.supportsSelectionClipboard()) {
clipBoardHlp.copyStringToClipboard(keyData, clipBoard.kSelectionClipboard);
}
DEBUG_LOG("enigmailKeyManager.js: enigmailImportFromClipbrd: got data from clipboard");
EnigAlert(EnigGetString("copyToClipbrdOK"));
}
catch(ex) {
EnigAlert(EnigGetString("copyToClipbrdFailed"));
}
}
function enigmailSearchKey() {
var inputObj = {
searchList : null
};
var resultObj = new Object();
window.openDialog("chrome://enigmail/content/enigmailSearchKey.xul",
"", "dialog,modal,centerscreen", inputObj, resultObj);
if (resultObj.importedKeys > 0) {
enigmailRefreshKeys();
}
}
function enigmailUploadKeys() {
enigmailKeyServerAcess(nsIEnigmail.UPLOAD_KEY, enigmailUploadKeysCb);
}
function enigmailUploadKeysCb(exitCode, errorMsg, msgBox) {
if (msgBox) {
if (exitCode!=0) {
EnigLongAlert(EnigGetString("sendKeysFailed")+"\n"+errorMsg);
}
}
else {
return (EnigGetString(exitCode==0 ? "sendKeysOK" : "sendKeysFailed"));
}
return "";
}
function enigmailReceiveKey() {
enigmailKeyServerAcess(nsIEnigmail.DOWNLOAD_KEY, enigmailReceiveKeyCb);
}
function enigmailReceiveKeyCb(exitCode, errorMsg, msgBox) {
if (msgBox) {
if (exitCode==0) {
EnigLongAlert(EnigGetString("receiveKeysOk") + "\n"+ errorMsg);
enigmailRefreshKeys();
}
else {
EnigLongAlert(EnigGetString("receiveKeysFailed")+"\n"+errorMsg);
}
}
else {
return (EnigGetString(exitCode==0 ? "receiveKeysOk" : "receiveKeysFailed"));
}
return "";
}
//
// ----- key filtering functionality -----
//
function onSearchInput(returnKeyHit)
{
if (gSearchTimer) {
clearTimeout(gSearchTimer);
gSearchTimer = null;
}
// only select the text when the return key was hit
if (returnKeyHit) {
gSearchInput.select();
onEnterInSearchBar();
}
else {
gSearchTimer = setTimeout("onEnterInSearchBar();", 800);
}
}
function onSearchKeyPress(event)
{
// 13 == return
if (event && event.keyCode == 13) {
event.stopPropagation(); // make sure the dialog is not closed...
onSearchInput(true);
}
}
function onEnterInSearchBar() {
if (gSearchInput.value == "")
{
onResetFilter();
return;
}
gClearButton.setAttribute("disabled", false);
enigApplyFilter();
}
function getFirstNode() {
return document.getElementById("pgpKeyListChildren").firstChild;
}
function onResetFilter() {
gFilterBox.value="";
var node=getFirstNode();
while (node) {
node.hidden=false;
node = node.nextSibling;
}
gClearButton.setAttribute("disabled", true);
}
function enigApplyFilter() {
var searchTxt=gSearchInput.value;
if (!searchTxt || searchTxt.length==0) return;
searchTxt = searchTxt.toLowerCase();
var node=getFirstNode();
while (node) {
var uid = gKeyList[node.id].userId;
var hideNode = true;
if ((uid.toLowerCase().indexOf(searchTxt) >= 0) ||
(node.id.toLowerCase().indexOf(searchTxt) >= 0)) {
hideNode = false;
}
for (var subUid=0; subUid < gKeyList[node.id].SubUserIds.length; subUid++) {
uid = gKeyList[node.id].SubUserIds[subUid].userId;
if (uid.toLowerCase().indexOf(searchTxt) >= 0) {
hideNode = false;
}
}
node.hidden=hideNode;
node = node.nextSibling;
}
}
//
// ----- keyserver related functionality ----
//
function enigmailKeyServerAcess(accessType, callbackFunc) {
var enigmailSvc = GetEnigmailSvc();
if (!enigmailSvc)
return;
var resultObj = {};
if (accessType == nsIEnigmail.UPLOAD_KEY) {
var inputObj = {
upload: true
};
}
else {
inputObj = {};
}
var selKeyList = enigmailGetSelectedKeys();
if (selKeyList.length==0) {
EnigAlert(EnigGetString("noKeySelected"));
return;
}
var keyList=[];
for (var i=0; i < selKeyList.length; i++) {
keyList.push("0x"+selKeyList[i].substr(-8,8)+" - "+ gKeyList[selKeyList[i]].userId);
}
inputObj.keyId = keyList.join(", ");
window.openDialog("chrome://enigmail/content/enigmailKeyserverDlg.xul",
"", "dialog,modal,centerscreen", inputObj, resultObj);
if (! resultObj.value) {
return;
}
var progressBar=Components.classes["@mozilla.org/messenger/progress;1"].createInstance(Components.interfaces.nsIMsgProgress);
var requestObserver = new EnigRequestObserver(enigSendKeyTerminate, {'progressBar': progressBar, 'callType': 1});
var progressListener = {
onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus)
{
if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP) {
if (progressBar.processCanceledByUser)
enigSendKeyCancel(progressBar);
}
},
onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
{},
onLocationChange: function(aWebProgress, aRequest, aLocation)
{},
onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage)
{},
onSecurityChange: function(aWebProgress, aRequest, state)
{},
QueryInterface : function(iid)
{
if (iid.equals(Components.interfaces.nsIWebProgressListener) ||
iid.equals(Components.interfaces.nsISupportsWeakReference) ||
iid.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
}
};
progressBar.registerListener(progressListener);
var errorMsgObj={};
gEnigIpcRequest = enigmailSvc.receiveKey(accessType, resultObj.value, "0x"+selKeyList.join(" 0x"), requestObserver, errorMsgObj);
if (gEnigIpcRequest == null) {
callbackFunc(-1, errorMsgObj.value, true);
return;
}
gEnigCallbackFunc = callbackFunc;
if (accessType == nsIEnigmail.UPLOAD_KEY) {
document.getElementById("statusText").value=EnigGetString("uploadingKey");
}
else {
document.getElementById("statusText").value=EnigGetString("downloadingKey");
}
document.getElementById("progressBar").removeAttribute("collapsed");
document.getElementById("cancelBox").removeAttribute("collapsed");
}
function enigSendKeyTerminate (terminateArg, ipcRequest) {
DEBUG_LOG("enigmailKeyManager.js: enigSendKeyTerminate\n");
if (terminateArg && terminateArg.progressBar) {
terminateArg.progressBar.onStateChange(null, null, Components.interfaces.nsIWebProgressListener.STATE_STOP, 0);
}
if (gEnigIpcRequest) {
var cbFunc = gEnigCallbackFunc;
var keyRetrProcess = gEnigIpcRequest.pipeTransport;
var exitCode;
var statusText = document.getElementById("statusText");
document.getElementById("progressBar").setAttribute("collapsed", "true");
document.getElementById("cancelBox").setAttribute("collapsed", "true");
var enigmailSvc = GetEnigmailSvc();
if (keyRetrProcess && !keyRetrProcess.isAttached()) {
keyRetrProcess.terminate();
exitCode = keyRetrProcess.exitCode();
DEBUG_LOG("enigmailKeyManager.js: enigSendKeyTerminate: exitCode = "+exitCode+"\n");
if (enigmailSvc) {
exitCode = enigmailSvc.fixExitCode(exitCode, 0);
}
}
statusText.value=cbFunc(exitCode, "", false);
var errorMsg="";
try {
var gpgConsole = gEnigIpcRequest.stderrConsole.QueryInterface(Components.interfaces.nsIPipeConsole);
if (gpgConsole && gpgConsole.hasNewData()) {
errorMsg = gpgConsole.getData();
if (enigmailSvc) {
var statusFlagsObj=new Object();
var statusMsgObj=new Object();
errorMsg=enigmailSvc.parseErrorOutput(errorMsg, statusFlagsObj, statusMsgObj);
}
}
} catch (ex) {}
DEBUG_LOG("enigmailKeyManager.js: enigSendKeyTerminate: errorMsg="+errorMsg);
if (errorMsg.search(/ec=\d+/i)>=0) {
exitCode=-1;
}
statusText.value=cbFunc(exitCode, "", false);
cbFunc(exitCode, errorMsg, true);
window.setTimeout(enigHideStatus, 5000);
gEnigIpcRequest.close(true);
}
}
function enigSendKeyCancel() {
document.getElementById("cancelButton").setAttribute("collapsed", "true");
var keyRetrProcess = gEnigIpcRequest.pipeTransport;
if (keyRetrProcess && !keyRetrProcess.isAttached()) {
keyRetrProcess.terminate();
}
gEnigIpcRequest.close(true);
document.getElementById("statusText").value=EnigGetString("keyserverAccessAborted");
document.getElementById("progressBar").setAttribute("collapsed", "true");
window.setTimeout(enigHideStatus, 5000);
gEnigIpcRequest=null;
gEnigCallbackFunc=null;
}
function enigHideStatus() {
document.getElementById("statusText").value="";
document.getElementById("progressBar").setAttribute("collapsed", "true");
document.getElementById("cancelBox").setAttribute("collapsed", "true");
}
+function engmailCardStatus() {
+ window.openDialog("chrome://enigmail/content/enigmailCardDetails.xul",
+ "", "dialog,modal,centerscreen");
+}
+
+function engmailGenerateCardKey() {
+ window.openDialog("chrome://enigmail/content/enigmailGenCardKey.xul",
+ "", "dialog,modal,centerscreen");
+ enigmailRefreshKeys();
+}
diff --git a/ui/content/enigmailKeyManager.xul b/ui/content/enigmailKeyManager.xul
index a0e33bca..d78058d3 100755
--- a/ui/content/enigmailKeyManager.xul
+++ b/ui/content/enigmailKeyManager.xul
@@ -1,304 +1,319 @@
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://enigmail/skin/enigmail.css" type="text/css"?>
<!DOCTYPE window [
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
%brandDTD;
<!ENTITY % enigMailDTD SYSTEM "chrome://enigmail/locale/enigmail.dtd" >
%enigMailDTD;
]>
<window id="enigmailKeyManager"
title="&enigmail.keyMan.title;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="enigmailKeyManagerLoad();"
height="450"
width="700"
windowtype="enigmail:KeyManager"
persist="screenX screenY width height">
<script type="application/x-javascript" src="chrome://enigmail/content/enigmailCommon.js"/>
<script type="application/x-javascript" src="chrome://enigmail/content/enigmailKeyManager.js"/>
<keyset id="winKeys">
<key id="key_closeWin" key="&enigmail.keyMan.closeWin.key;"
oncommand="window.close()" modifiers="accel"/>
<key id="key_delete"
keycode="VK_DELETE"
oncommand="enigmailDeleteKey()"/>
</keyset>
<broadcasterset>
<broadcaster id="bcSignKey" disabled="false"/>
<broadcaster id="bcSetTrust" disabled="false"/>
<broadcaster id="bcViewSig" disabled="false"/>
<broadcaster id="bcViewPhoto" disabled="false"/>
<broadcaster id="bcManageUid" disabled="false"/>
<broadcaster id="bcRevoke" disabled="false"/>
<broadcaster id="bcKeyDetails" disabled="false"/>
<broadcaster id="bcDeleteKey" disabled="false"/>
<broadcaster id="bcEnableKey" disabled="false" label=""/>
</broadcasterset>
<menubar id="mainmenu" grippyhidden="true">
<menu label="&enigmail.keyMan.fileMenu.label;"
accesskey="&enigmail.keyMan.fileMenu.accesskey;">
<menupopup onpopupshowing="enigmailKeyMenu()">
<menuitem label="&enigmail.keyMan.importFromFile.label;"
id="importFromFile"
accesskey="&enigmail.keyMan.importFromFile.accesskey;"
oncommand="enigmailImportKeysFromFile()"/>
<menuitem label="&enigmail.keyMan.exportToFile.label;"
id="exportKey"
accesskey="&enigmail.keyMan.exportToFile.accesskey;"
oncommand="enigmailExportKeys()"/>
<menuseparator/>
<menuitem label="&enigmail.keyMan.reload.label;"
id="refreshKeys"
accesskey="&enigmail.keyMan.reload.accesskey;"
oncommand="enigmailRefreshKeys();"/>
<menuseparator/>
<menuitem label="&enigmail.keyMan.close.label;"
accesskey="&enigmail.keyMan.close.accesskey;"
key="key_closeWin"
oncommand="window.close()"/>
</menupopup>
</menu>
<menu label="&enigmail.keyMan.editMenu.label;"
accesskey="&enigmail.keyMan.editMenu.accesskey;">
<menupopup onpopupshowing="enigmailKeyMenu()">
<menuitem label="&enigmail.keyMan.importFromClipbrd.label;"
id="importFromClipbrd"
accesskey="&enigmail.keyMan.importFromClipbrd.accesskey;"
oncommand="enigmailImportFromClipbrd()"/>
<menuitem label="&enigmail.keyMan.copyToClipbrd.label;"
id="copyToClipbrd"
accesskey="&enigmail.keyMan.copyToClipbrd.accesskey;"
oncommand="enigmailCopyToClipbrd()"/>
<menuseparator/>
<menuitem label="&enigmail.keyMan.sign.label;"
id="signKey"
observes="bcSignKey"
accesskey="&enigmail.keyMan.sign.accesskey;"
oncommand="enigSignKey()"/>
<menuitem label="&enigmail.keyMan.setTrust.label;"
id="setTrust"
observes="bcSetTrust"
accesskey="&enigmail.keyMan.setTrust.accesskey;"
oncommand="enigEditKeyTrust()"/>
<menuseparator/>
<menuitem id="enableKey"
observes="bcEnableKey"
accesskey="&enigmail.keyMan.enableKey.accesskey;"
oncommand="enigmailEnableKey()"/>
<menuitem label="&enigmail.keyMan.revokeKey.label;"
id="revokeKey"
observes="bcRevoke"
accesskey="&enigmail.keyMan.revokeKey.accesskey;"
oncommand="enigmailRevokeKey()"/>
<menuitem label="&enigmail.keyMan.delKey.label;"
id="deleteKey"
key="key_delete"
observes="bcDeleteKey"
accesskey="&enigmail.keyMan.delKey.accesskey;"
oncommand="enigmailDeleteKey()"/>
<menuseparator/>
<menuitem id="manageUid"
label="&enigmail.keyMan.manageUid.label;"
observes="bcManageUid"
accesskey="&enigmail.keyMan.manageUid.accesskey;"
oncommand="enigmailManageUids()"/>
</menupopup>
</menu>
<menu id="viewMenu"
label="&enigmail.keyMan.viewMenu.label;"
accesskey="&enigmail.keyMan.viewMenu.accesskey;">
<menupopup onpopupshowing="enigmailKeyMenu()"> <!-- view menu -->
<menuitem label="&enigmail.keyMan.viewSig.label;"
id="viewSig"
observes="bcViewSig"
accesskey="&enigmail.keyMan.viewSig.accesskey;"
oncommand="enigmailListSig()"/>
<menuitem label="&enigmail.keyMan.viewPhoto.label;"
id="viewPhoto"
observes="bcViewPhoto"
accesskey="&enigmail.keyMan.showPhoto.accesskey;"
oncommand="enigShowPhoto()"/>
<menuitem label="&enigmail.keyMan.keyProps.label;"
id="keyDetails"
observes="bcKeyDetails"
accesskey="&enigmail.keyMan.keyDetails.accesskey;"
oncommand="enigmailKeyDetails()"/>
</menupopup>
</menu>
<menu id="keyserverMenu"
label="&enigmail.keyMan.keyserverMenu.label;"
accesskey="&enigmail.keyMan.keyserverMenu.accesskey;">
<menupopup onpopupshowing="enigmailKeyMenu()"> <!-- keyserverMenu menu -->
<menuitem label="&enigmail.keyMan.refreshKey.label;"
id="refreshKey"
accesskey="&enigmail.keyMan.refreshKey.accesskey;"
oncommand="enigmailReceiveKey()"/>
<menuitem label="&enigmail.keyMan.importFromServer.label;"
id="importFromServer"
accesskey="&enigmail.keyMan.importFromServer.accesskey;"
oncommand="enigmailSearchKey()"/>
<menuitem label="&enigmail.keyMan.uploadToServer.label;"
id="uploadToServer"
accesskey="&enigmail.keyMan.uploadToServer.accesskey;"
oncommand="enigmailUploadKeys()"/>
</menupopup>
</menu>
<menu id="generateMenu"
label="&enigmail.keyMan.generateMenu.label;"
accesskey="&enigmail.keyMan.generateMenu.accesskey;">
<menupopup onpopupshowing="enigmailKeyMenu()"> <!-- generate menu -->
<menuitem label="&enigmail.keyMan.generate.label;"
id="genKey"
accesskey="&enigmail.keyMan.generate.accesskey;"
oncommand="EnigKeygen(); enigmailRefreshKeys();"/>
<menuitem label="&enigmail.keyMan.genRevoke.label;"
id="revokationCertificate"
observes="bcRevoke"
accesskey="&enigmail.keyMan.genRevoke.accesskey;"
oncommand="enigCreateRevokeCert()"/>
</menupopup>
</menu>
+
+ <menu id="cardMenu"
+ label="&enigmail.keyMan.cardMenu.label;"
+ accesskey="&enigmail.keyMan.cardMenu.accesskey;">
+ <menupopup>
+ <menuitem label="&enigmail.keyMan.cardData.label;"
+ id="cardData"
+ accesskey="&enigmail.keyMan.cardData.accesskey;"
+ oncommand="engmailCardStatus()"/>
+ <menuitem label="&enigmail.keyMan.genCardKey.label;"
+ id="genCardKey"
+ accesskey="&enigmail.keyMan.genCardKey.accesskey;"
+ oncommand="engmailGenerateCardKey()"/>
+ </menupopup>
+ </menu>
</menubar>
<popupset>
<popup id="ctxmenu"
onpopupshowing="enigmailKeyMenu();">
<menuitem label="&enigmail.keyMan.ctxCopyToClipbrd.label;"
id="ctxCopyToClipbrd"
oncommand="enigmailCopyToClipbrd()"/>
<menuitem label="&enigmail.keyMan.ctxExportToFile.label;"
id="ctxExport"
oncommand="enigmailExportKeys()"/>
<menuseparator/>
<menuitem label="&enigmail.keyMan.ctxUploadToServer.label;"
id="ctxUpload"
oncommand="enigmailUploadKeys()"/>
<menuitem label="&enigmail.keyMan.ctxRefreshKey.label;"
id="ctxRefreshKey"
oncommand="enigmailReceiveKey()"/>
<menuseparator/>
<menuitem id="ctxSign" observes="bcSignKey" label="&enigmail.keyMan.sign.label;" oncommand="enigSignKey()"/>
<menuitem id="ctxTrust" label="&enigmail.keyMan.setTrust.label;" oncommand="enigEditKeyTrust()"/>
<menuseparator/>
<menuitem id="ctxEnableKey" observes="bcEnableKey" oncommand="enigmailEnableKey()"/>
<menuitem id="ctxRevokeKey" observes="bcRevoke" label="&enigmail.keyMan.revokeKey.label;" oncommand="enigmailRevokeKey()"/>
<menuitem id="ctxDeleteKey" observes="bcDeleteKey" label="&enigmail.keyMan.delKey.label;" oncommand="enigmailDeleteKey()"/>
<menuseparator/>
<menuitem id="ctxManageUid" observes="bcManageUid" label="&enigmail.keyMan.manageUid.label;" oncommand="enigmailManageUids()"/>
<menuitem id="ctxRevokationCert" observes="bcRevoke" label="&enigmail.keyMan.ctxGenRevoke.label;" oncommand="enigCreateRevokeCert()"/>
<menuseparator/>
<menuitem id="ctxViewSig" observes="bcViewSig" label="&enigmail.keyMan.ctxViewSig.label;" oncommand="enigmailListSig()"/>
<menuitem id="ctxViewPhoto" observes="bcViewPhoto" label="&enigmail.keyMan.ctxViewPhoto.label;" oncommand="enigShowPhoto()"/>
<menuitem id="ctxDetails" observes="bcViewSig" label="&enigmail.keyMan.keyProps.label;"
oncommand="enigmailKeyDetails()"/>
</popup>
</popupset>
<hbox flex="0" align="center">
<label value="&enigmail.keyMan.filter.label;"/>
<textbox id="filterKey" type="text" size="30"
onfocus="this.select();"
onclick="this.select();"
oninput="onSearchInput(false);"
onkeypress="onSearchKeyPress(event);"/>
<button label="&enigmail.keyMan.clearFilter.label;"
id="clearFilter" disabled="true"
accesskey="&enigmail.keyMan.clearFilter.accesskey;"
oncommand="onResetFilter();"/>
</hbox>
<groupbox width="700px" flex="1">
<hbox flex="1">
<tree id="pgpKeyList" flex="1"
enableColumnDrag="true"
seltype="multiple"
hidecolumnpicker="false"
ondblclick="enigmailDblClick(event)">
<treecols>
<treecol id="enigUserNameCol" primary="true"
flex="1"
label="&enigmail.keyUserId.label;"/>
<splitter class="tree-splitter"/>
<treecol id="keyCol" style="width:90px"
label="&enigmail.keyId.label;"
persist="width,hidden"/>
<splitter class="tree-splitter"/>
<treecol id="typeCol" style="width:70px"
label="&enigmail.keyMan.keyType.label;"
persist="width,hidden"/>
<splitter class="tree-splitter"/>
<treecol id="validityCol" style="width:70px"
label="&enigmail.keyMan.calcTrust.label;"
persist="width,hidden"/>
<splitter class="tree-splitter"/>
<treecol id="trustCol" style="width:70px"
label="&enigmail.keyMan.ownerTrust.label;"
persist="width,hidden"/>
<splitter class="tree-splitter"/>
<treecol id="expCol" style="width:70px"
label="&enigmail.keyExpiry.label;"
persist="width,hidden"/>
<splitter class="tree-splitter"/>
<treecol id="fprCol" style="width:70px"
label="&enigmail.keyMan.fingerprint.label;"
hidden="true"
persist="width,hidden"/>
</treecols>
<treechildren id="pgpKeyListChildren"
context="ctxmenu"/>
</tree>
</hbox>
</groupbox>
<!-- status line -->
<hbox id="statusLine">
<label id="statusText" value=" "/>
<progressmeter id="progressBar" mode="undetermined" value="0" collapsed="true"/>
<description id="cancelBox" collapsed="true">
<a class="enigmailLink" href=""
id="cancelButton" onclick="enigSendKeyCancel()">&enigmail.keyMan.stopTransfer.label;</a>
</description>
</hbox>
</window>
diff --git a/ui/content/enigmailKeygen.js b/ui/content/enigmailKeygen.js
index eb805f13..d3baaaa7 100644
--- a/ui/content/enigmailKeygen.js
+++ b/ui/content/enigmailKeygen.js
@@ -1,406 +1,410 @@
// Uses: chrome://enigmail/content/enigmailCommon.js
// Initialize enigmailCommon
EnigInitCommon("enigmailKeygen");
const ENIG_ACCOUNT_MANAGER_CONTRACTID = "@mozilla.org/messenger/account-manager;1";
var gAccountManager = Components.classes[ENIG_ACCOUNT_MANAGER_CONTRACTID].getService(Components.interfaces.nsIMsgAccountManager);
var gAutoCrypto;
var gIdentityList;
var gIdentityListPopup;
var gUseForSigning;
var gKeygenRequest;
var gAllData = "";
var gGeneratedKey="";
var gUsedId;
function enigmailKeygenLoad() {
DEBUG_LOG("enigmailKeygen.js: Load\n");
gAutoCrypto = EnigGetPref("autoCrypto");
gIdentityList = document.getElementById("userIdentity");
gIdentityListPopup = document.getElementById("userIdentityPopup");
gUseForSigning = document.getElementById("useForSigning");
if (gIdentityListPopup) {
fillIdentityListPopup();
}
enigmailKeygenUpdate(true, false);
var enigmailSvc = GetEnigmailSvc();
if (!enigmailSvc) {
EnigAlert(EnigGetString("accessError"));
}
if (enigmailSvc.agentType != "gpg") {
EnigAlert(EnigGetString("onlyGPG"));
return;
}
}
function enigmailOnClose() {
enigmailKeygenCancel();
}
function enigmailKeygenUnload() {
DEBUG_LOG("enigmailKeygen.js: Unload\n");
enigmailKeygenCloseRequest();
}
function enigmailKeygenUpdate(getPrefs, setPrefs) {
DEBUG_LOG("enigmailKeygen.js: Update: "+getPrefs+", "+setPrefs+"\n");
var noPassphrase = document.getElementById("noPassphrase");
var noPassphraseChecked = getPrefs ? EnigGetPref("noPassphrase")
: noPassphrase.checked;
if (setPrefs) {
EnigSetPref("noPassphrase", noPassphraseChecked);
}
noPassphrase.checked = noPassphraseChecked;
var passphrase1 = document.getElementById("passphrase");
var passphrase2 = document.getElementById("passphraseRepeat");
passphrase1.disabled = noPassphraseChecked;
passphrase2.disabled = noPassphraseChecked;
if (gAutoCrypto) {
var commentElement = document.getElementById("keyComment");
commentElement.value = "Enigmail auto crypto";
commentElement.disabled = true;
}
}
function enigmailKeygenTerminate(terminateArg, ipcRequest) {
DEBUG_LOG("enigmailKeygen.js: Terminate: "+ipcRequest+"\n");
// Give focus to this window
window.focus();
var keygenProcess = ipcRequest.pipeTransport;
var enigmailSvc = GetEnigmailSvc();
if (!enigmailSvc) {
EnigAlert(EnigGetString("accessError"));
}
if (keygenProcess && !keygenProcess.isAttached) {
keygenProcess.terminate();
var exitCode = keygenProcess.exitCode();
DEBUG_LOG("enigmailKeygenConsole.htm: exitCode = "+exitCode+"\n");
if (enigmailSvc) {
exitCode = enigmailSvc.fixExitCode(exitCode, 0);
}
}
enigRefreshConsole();
ipcRequest.close(true);
if (gUseForSigning.checked) {
var curId = gUsedId;
curId.setBoolAttribute("enablePgp", true);
curId.setIntAttribute("pgpKeyMode", 1);
if (gGeneratedKey) {
curId.setCharAttribute("pgpkeyId", "0x"+gGeneratedKey.substr(-8,8));
}
else {
curId.setCharAttribute("pgpkeyId", curId.email);
}
enigmailKeygenUpdate(false, true);
EnigSavePrefs();
if (EnigConfirm(EnigGetString("genComplete", curId.email))) {
EnigCreateRevokeCert(gGeneratedKey, curId.email);
}
} else {
EnigAlert(EnigGetString("genCompleteNoSign"));
}
enigmailKeygenCloseRequest();
enigmailSvc.invalidateUserIdList();
window.close();
}
// Cleanup and close window
function enigmailKeygenCloseRequest() {
DEBUG_LOG("enigmailKeygen.js: CloseRequest\n");
// Cancel console refresh
if (window.consoleIntervalId) {
window.clearInterval(window.consoleIntervalId);
window.consoleIntervalId = null;
}
if (gKeygenRequest) {
try {
var keygenProcess = gKeygenRequest.pipeTransport;
if (keygenProcess)
keygenProcess.terminate();
} catch(ex) {}
gKeygenRequest.close(true);
gKeygenRequest = null;
}
}
function enigmailKeygenStart() {
DEBUG_LOG("enigmailKeygen.js: Start\n");
if (gKeygenRequest && gKeygenRequest.isPending()) {
EnigAlert(EnigGetString("genGoing"));
return;
}
var enigmailSvc = GetEnigmailSvc();
if (!enigmailSvc) {
EnigAlert(EnigGetString("accessError"));
return;
}
var passphraseElement = document.getElementById("passphrase");
var passphrase2Element = document.getElementById("passphraseRepeat");
var passphrase = passphraseElement.value;
if (passphrase != passphrase2Element.value) {
EnigAlert(EnigGetString("passNoMatch"));
return;
}
if (passphrase.search(/[\x80-\xFF]/)>=0) {
EnigAlert(EnigGetString("passCharProblem"));
return;
}
var noPassphraseElement = document.getElementById("noPassphrase");
if (!passphrase && !noPassphraseElement.checked) {
EnigAlert(EnigGetString("passCheckBox"));
return;
}
var commentElement = document.getElementById("keyComment");
var comment = commentElement.value;
if (!passphrase) {
if (comment)
comment += "; ";
comment += "no password";
}
var noExpiry = document.getElementById("noExpiry");
var expireInput = document.getElementById("expireInput");
var timeScale = document.getElementById("timeScale");
var expiryTime = 0;
if (! noExpiry.checked) {
expiryTime = Number(expireInput.value) * Number(timeScale.value);
if (expiryTime > 36500) {
EnigAlert(EnigGetString("expiryTooLong"));
return;
}
+ if (! (expiryTime > 0)) {
+ EnigAlert(EnigGetString("expiryTooShort"));
+ return;
+ }
}
var keySize = Number(document.getElementById("keySize").value);
var curId = getCurrentIdentity();
gUsedId = curId;
var userName = curId.fullName;
var userEmail = curId.email;
if (!userName) {
EnigAlert(EnigGetString("passUserName"));
return;
}
var idString = userName;
if (comment)
idString += " (" + comment + ")";
idString += " <" + userEmail + ">";
var confirmMsg = EnigGetString("keyConfirm",idString);
if (!EnigConfirm(confirmMsg)) {
return;
}
var ipcRequest = null;
var requestObserver = new EnigRequestObserver(enigmailKeygenTerminate,null);
try {
ipcRequest = enigmailSvc.generateKey(window,
userName,
comment,
userEmail,
expiryTime,
keySize,
passphrase,
requestObserver);
} catch (ex) {
}
if (!ipcRequest) {
EnigAlert("Key generation failed!");
}
gKeygenRequest = ipcRequest;
WRITE_LOG("enigmailKeygen.js: Start: gKeygenRequest = "+gKeygenRequest+"\n");
// Refresh console every 2 seconds
window.consoleIntervalId = window.setInterval(enigRefreshConsole, 2000);
enigRefreshConsole();
}
function enigRefreshConsole() {
//DEBUG_LOG("enigmailKeygen.js: enigRefreshConsole:\n");
if (!gKeygenRequest)
return;
var keygenConsole = gKeygenRequest.stdoutConsole;
try {
keygenConsole = keygenConsole.QueryInterface(Components.interfaces.nsIPipeConsole);
if (keygenConsole && keygenConsole.hasNewData()) {
DEBUG_LOG("enigmailKeygen.js: enigRefreshConsole(): hasNewData\n");
var contentFrame = EnigGetFrame(window, "keygenConsole");
if (contentFrame) {
var consoleElement = contentFrame.document.getElementById('console');
gAllData += keygenConsole.getNewData();
var keyCreatedIndex = gAllData.indexOf("[GNUPG:] KEY_CREATED");
if (keyCreatedIndex >0) {
gGeneratedKey = gAllData.substr(keyCreatedIndex);
gGeneratedKey = gGeneratedKey.replace(/(.*\[GNUPG:\] KEY_CREATED . )([a-fA-F0-9]+)([\n\r].*)*/, "$2");
gAllData = gAllData.replace(/\[GNUPG:\] KEY_CREATED . [a-fA-F0-9]+[\n\r]/, "");
}
gAllData = gAllData.replace(/[\r\n]*\[GNUPG:\] GOOD_PASSPHRASE/g, "").replace(/([\r\n]*\[GNUPG:\] PROGRESS primegen )(.)( \d+ \d+)/g, "$2")
consoleElement.firstChild.data = gAllData.replace(/(.{70})/g, "$1\n");
if (!contentFrame.mouseDownState)
contentFrame.scrollTo(0,9999);
}
}
} catch (ex) {}
}
function enigmailKeygenCancel() {
DEBUG_LOG("enigmailKeygen.js: Cancel\n");
if (gKeygenRequest) {
var closeWin = EnigConfirm(EnigGetString("keyAbort"));
}
else {
closeWin=true;
}
if (closeWin) {
enigmailKeygenCloseRequest();
window.close();
}
}
function onNoExpiry() {
var noExpiry = document.getElementById("noExpiry");
var expireInput = document.getElementById("expireInput");
var timeScale = document.getElementById("timeScale");
expireInput.disabled=noExpiry.checked;
timeScale.disabled=noExpiry.checked;
}
function queryISupportsArray(supportsArray, iid) {
var result = new Array;
for (var i=0; i<supportsArray.Count(); i++) {
result[i] = supportsArray.GetElementAt(i).QueryInterface(iid);
}
return result;
}
function getCurrentIdentity()
{
var item = gIdentityList.selectedItem;
var identityKey = item.getAttribute('id');
var identity = gAccountManager.getIdentity(identityKey);
return identity;
}
function fillIdentityListPopup()
{
DEBUG_LOG("enigmailKeygen.js: fillIdentityListPopup\n");
var idSupports = gAccountManager.allIdentities;
var identities = queryISupportsArray(idSupports,
Components.interfaces.nsIMsgIdentity);
DEBUG_LOG("enigmailKeygen.js: fillIdentityListPopup: "+identities + "\n");
// Default identity
var defIdentity;
var defIdentities = gAccountManager.defaultAccount.identities;
if (defIdentities.Count() >= 1) {
defIdentity = defIdentities.QueryElementAt(0, Components.interfaces.nsIMsgIdentity);
} else {
defIdentity = identities[0];
}
DEBUG_LOG("enigmailKeygen.js: fillIdentityListPopup: default="+defIdentity.key+"\n");
var selected = false;
for (var i=0; i<identities.length; i++) {
var identity = identities[i];
DEBUG_LOG("id.valid="+identity.valid+"\n");
if (!identity.valid || !identity.email)
continue;
var serverSupports = gAccountManager.GetServersForIdentity(identity);
if (serverSupports.GetElementAt(0)) {
var inServer = serverSupports.GetElementAt(0).QueryInterface(Components.interfaces.nsIMsgIncomingServer);
var accountName = " - "+inServer.prettyName;
DEBUG_LOG("enigmailKeygen.js: accountName="+accountName+"\n");
DEBUG_LOG("enigmailKeygen.js: email="+identity.email+"\n");
var item = document.createElement('menuitem');
// item.setAttribute('label', identity.identityName);
item.setAttribute('label', identity.identityName + accountName);
item.setAttribute('class', 'identity-popup-item');
item.setAttribute('accountname', accountName);
item.setAttribute('id', identity.key);
item.setAttribute('email', identity.email);
gIdentityListPopup.appendChild(item);
if (!selected)
gIdentityList.selectedItem = item;
if (identity.key == defIdentity.key) {
gIdentityList.selectedItem = item;
selected = true;
}
}
}
}
diff --git a/ui/content/enigmailKeygen.xul b/ui/content/enigmailKeygen.xul
index 4d315ed5..cbcfb59f 100644
--- a/ui/content/enigmailKeygen.xul
+++ b/ui/content/enigmailKeygen.xul
@@ -1,138 +1,138 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://enigmail/skin/enigmail.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://enigmail/locale/enigmail.dtd" >
<window
id="enigmailKeygen"
title="&enigmail.keygenTitle.label;"
windowtype="enigmail:keygen"
width="600" height="480"
orient="vertical"
onload="enigmailKeygenLoad()"
onclose="enigmailOnClose()"
onunload="enigmailKeygenUnload()"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js" />
<script type="application/x-javascript" src="chrome://enigmail/content/enigmailCommon.js"/>
<script type="application/x-javascript" src="chrome://enigmail/content/enigmailKeygen.js"/>
<popupset id="aTooltipSet"/>
<groupbox id="userIdBox" orient="vertical">
<hbox orient="horizontal" align="center">
<text class="label" value="&enigmail.keyUserId.label;"/>
<menulist id="userIdentity" label="..." flex="1">
<menupopup id="userIdentityPopup"/>
</menulist>
</hbox>
<checkbox id="useForSigning"
label="&enigmail.useForSigning.label;"
checked="true" />
</groupbox>
<checkbox id="noPassphrase"
label="&enigmail.keyNoPassphrase.label;"
oncommand="enigmailKeygenUpdate(false, false);" />
<grid>
<columns>
<column />
<column flex="1"/>
</columns>
<rows>
<row>
<hbox id="passphraseBox" align="center">
<label control="passphrase" value="&enigmail.keyPassphrase.label;" />
</hbox>
- <hbox>
+ <hbox align="center">
<textbox id="passphrase" type="password" />
<label control="passphraseRepeat" value="&enigmail.keyPassphraseRepeat.label;" />
<textbox id="passphraseRepeat" type="password" />
</hbox>
</row>
<row>
<hbox align="center">
<label control="keyComment" value="&enigmail.keyComment.label;" />
</hbox>
<textbox id="keyComment" />
</row>
<row>
<hbox align="center">
<label value="&enigmail.keyGen.expire.label;"/>
</hbox>
<hbox align="center">
<textbox id="expireInput" size="5" maxlength="5" value="5"/>
<menulist id="timeScale" label="&enigmail.keyGen.years.label;" value="365">
<menupopup id="timeScalePopup">
<menuitem id="years" value="365" label="&enigmail.keyGen.years.label;" selected="true"/>
<menuitem id="months" value="30" label="&enigmail.keyGen.months.label;"/>
<menuitem id="days" value="1" label="&enigmail.keyGen.days.label;"/>
</menupopup>
</menulist>
<checkbox label="&enigmail.keyGen.noExpiry.label;"
id="noExpiry" oncommand="onNoExpiry()"/>
</hbox>
</row>
<row>
<hbox align="center">
<label value="&enigmail.keyGen.keySize.label;"/>
</hbox>
<hbox flex="0">
<menulist id="keySize" label="2048" value="2048" >
<menupopup id="keySizePopup">
<menuitem id="keySize_1024" value="1024" label="1024"/>
<menuitem id="keySize_2048" value="2048" label="2048" selected="true"/>
<menuitem id="keySize_4096" value="4096" label="4096"/>
</menupopup>
</menulist>
</hbox>
</row>
</rows>
</grid>
<separator/>
<hbox autostretch="never">
<button label="&enigmail.generateKey.label;"
class="dialog"
tooltip="aTooltip"
tooltiptext="&enigmail.generateKey.tooltip;"
oncommand="enigmailKeygenStart();" />
<button label="&enigmail.cancelKey.label;"
class="dialog"
tooltip="aTooltip"
tooltiptext="&enigmail.cancelKey.tooltip;"
oncommand="enigmailKeygenCancel();" />
</hbox>
<separator/>
<groupbox id="keygenConsoleBox" orient="vertical" flex="1">
- <caption label="Keygen Console"/>
+ <caption label="&enigmail.keyGen.console.label;"/>
<description>&enigmail.keygen.desc;</description>
<iframe id="keygenConsole" type="content" name="keygenConsole"
src="chrome://enigmail/content/enigmailKeygenConsole.htm"
height="200" flex="1"/>
</groupbox>
</window>
diff --git a/ui/content/enigmailMsgHdrViewOverlay.js b/ui/content/enigmailMsgHdrViewOverlay.js
index 79027207..b15a7b44 100644
--- a/ui/content/enigmailMsgHdrViewOverlay.js
+++ b/ui/content/enigmailMsgHdrViewOverlay.js
@@ -1,839 +1,840 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "MPL"); you may not use this file
except in compliance with the MPL. You may obtain a copy of
the MPL at http://www.mozilla.org/MPL/
Software distributed under the MPL is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the MPL for the specific language governing
rights and limitations under the MPL.
The Original Code is Enigmail.
The Initial Developer of the Original Code is Ramalingam Saravanan.
Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
Copyright (C) 2001 Ramalingam Saravanan. All Rights Reserved.
Contributor(s):
Patrick Brunschwig <patrick.brunschwig@gmx.net>
Alternatively, the contents of this file may be used under the
terms of the GNU General Public License (the "GPL"), in which case
the provisions of the GPL are applicable instead of
those above. If you wish to allow use of your version of this
file only under the terms of the GPL and not to allow
others to use your version of this file under the MPL, indicate
your decision by deleting the provisions above and replace them
with the notice and other provisions required by the GPL.
If you do not delete the provisions above, a recipient
may use your version of this file under either the MPL or the
GPL.
*/
// Uses: chrome://enigmail/content/enigmailCommon.js
// (already loaded by enigmailMessengerOverlay(!))
window.addEventListener("load", enigHdrViewLoad, false);
addEventListener('messagepane-unloaded', enigHdrViewUnload, true);
var gEnigStatusBar;
function enigHdrViewLoad()
{
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: enigHdrViewLoad\n");
// Override SMIME ui
var signedHdrElement = document.getElementById("signedHdrIcon");
if (signedHdrElement) {
signedHdrElement.setAttribute("onclick", "enigViewSecurityInfo(event, true);");
signedHdrElement.setAttribute("context", "enigSecurityContext");
}
var encryptedHdrElement = document.getElementById("encryptedHdrIcon");
if (encryptedHdrElement) {
encryptedHdrElement.setAttribute("onclick", "enigViewSecurityInfo(event, true);");
encryptedHdrElement.setAttribute("context", "enigSecurityContext");
}
gEnigStatusBar = document.getElementById("enigmail-status-bar");
}
function enigStartHeaders()
{
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: enigStartHeaders\n");
gEnigStatusBar.removeAttribute("signed");
gEnigStatusBar.removeAttribute("encrypted");
var enigmailBox = document.getElementById("enigmailBox");
var statusText = document.getElementById("enigmailStatusText");
var statusTextBox = document.getElementById("enigmailStatusTextBox");
if (enigmailBox && !enigmailBox.collapsed) {
enigmailBox.setAttribute("collapsed", "true");
if (statusText) statusText.value="";
}
if (statusText)
statusText.setAttribute("class", "plain enigmailHeaderValue enigmailHeaderBoxLabelSignatureOk");
if (statusTextBox)
statusTextBox.setAttribute("class", "enigmailHeaderNameBox enigmailHeaderBoxLabelSignatureOk");
statusText = document.getElementById("collapsedEnigmailStatusText");
if (enigmailBox && !enigmailBox.collapsed) {
if (statusText) tatusText.value="";
}
if (statusText)
statusText.setAttribute("class", "plain enigmailHeaderValue enigmailHeaderBoxLabelSignatureOk");
var msgFrame = EnigGetFrame(window, "messagepane");
if (msgFrame) {
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: msgFrame="+msgFrame+"\n");
msgFrame.addEventListener("unload", enigMessageUnload, true);
msgFrame.addEventListener("load", enigMessageAutoDecrypt, false);
}
enigForgetEncryptedURI();
if (messageHeaderSink)
try {
messageHeaderSink.enigPrepSecurityInfo();
}
catch (ex) {}
}
function enigEndHeaders()
{
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: enigEndHeaders\n");
gEnigStatusBar.removeAttribute("signed");
gEnigStatusBar.removeAttribute("encrypted");
var statusText = document.getElementById("enigmailStatusText");
if (statusText) {
statusText.setAttribute("class", "plain enigmailHeaderValue enigmailHeaderBoxLabelSignatureOk");
}
statusText = document.getElementById("collapsedEnigmailStatusText");
if (statusText) {
statusText.setAttribute("class", "plain enigmailHeaderValue enigmailHeaderBoxLabelSignatureOk");
}
}
function enigBeforeStartHeaders() {
return true;
}
// Match the userId from gpg to the sender's from address
function enigMatchUidToSender(userId) {
var fromAddr = currentHeaderData["from"].headerValue;
try {
fromAddr=EnigStripEmail(fromAddr);
}
catch(ex) {}
var userIdList=userId.split(/\n/);
try {
for (var i=0; i<userIdList.length; i++) {
if (fromAddr.toLowerCase() == EnigStripEmail(userIdList[i]).toLowerCase()) {
userId = userIdList[i];
break;
}
}
if (i>=userIdList.length) userId=userIdList[0];
}
catch (ex) {
userId=userIdList[0];
}
return userId;
}
function enigUpdateHdrIcons(exitCode, statusFlags, keyId, userId, sigDetails, errorMsg) {
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: enigUpdateHdrIcons: exitCode="+exitCode+", statusFlags="+statusFlags+", keyId="+keyId+", userId="+userId+", "+errorMsg+"\n");
gEnigLastEncryptedURI = GetLoadedMessage();
var bodyElement = document.getElementById("messagepanebox");
/*
var bodyElement = msgFrame.document.getElementsByTagName("body")[0];
if (! bodyElement) {
bodyElement = msgFrame.frames.document.body;
}
*/
if (userId && (userId.indexOf("\n")>=0)) {
var replaceUid=enigMatchUidToSender(userId);
errorMsg = errorMsg.replace(userId, replaceUid);
userId=EnigConvertGpgToUnicode(replaceUid);
}
+ userId=userId.replace(/\\[xe]3a/gi, ":");
var errorLines="";
var fullStatusInfo="";
if (exitCode == ENIG_POSSIBLE_PGPMIME) {
exitCode = 0;
}
else {
if (errorMsg) {
- errorMsg=EnigConvertGpgToUnicode(errorMsg);
+ errorMsg=EnigConvertGpgToUnicode(errorMsg).replace(/\\[xe]3a/gi, ":");
errorLines = errorMsg.split(/\r?\n/);
fullStatusInfo=errorMsg;
}
}
if (errorLines && (errorLines.length > 22) ) {
// Retain only first twenty lines and last two lines of error message
var lastLines = errorLines[errorLines.length-2] + "\n" +
errorLines[errorLines.length-1] + "\n";
while (errorLines.length > 20)
errorLines.pop();
errorMsg = errorLines.join("\n") + "\n...\n" + lastLines;
}
var statusInfo = "";
var statusLine = "";
var statusArr = [];
if (statusFlags & nsIEnigmail.NODATA) {
if (statusFlags & nsIEnigmail.PGP_MIME_SIGNED)
statusFlags |= nsIEnigmail.UNVERIFIED_SIGNATURE;
if (statusFlags & nsIEnigmail.PGP_MIME_ENCRYPTED)
statusFlags |= nsIEnigmail.DECRYPTION_INCOMPLETE;
}
if (! EnigGetPref("displayPartiallySigned")) {
if ((statusFlags & (nsIEnigmail.PARTIALLY_PGP))
&& (statusFlags & (nsIEnigmail.BAD_SIGNATURE))) {
statusFlags &= ~(nsIEnigmail.BAD_SIGNATURE | nsIEnigmail.PARTIALLY_PGP);
if (statusFlags == 0) {
errorMsg="";
fullStatusInfo="";
}
}
}
var msgSigned = (statusFlags & (nsIEnigmail.BAD_SIGNATURE |
nsIEnigmail.GOOD_SIGNATURE |
nsIEnigmail.EXPIRED_KEY_SIGNATURE |
nsIEnigmail.EXPIRED_SIGNATURE |
nsIEnigmail.UNVERIFIED_SIGNATURE |
nsIEnigmail.REVOKED_KEY |
nsIEnigmail.EXPIRED_KEY_SIGNATURE |
nsIEnigmail.EXPIRED_SIGNATURE));
var msgEncrypted = (statusFlags & (nsIEnigmail.DECRYPTION_OKAY |
nsIEnigmail.DECRYPTION_INCOMPLETE |
nsIEnigmail.DECRYPTION_FAILED));
if (msgSigned && (statusFlags & nsIEnigmail.IMPORTED_KEY)) {
statusFlags &= (~nsIEnigmail.IMPORTED_KEY);
}
if (((!(statusFlags & (nsIEnigmail.DECRYPTION_INCOMPLETE |
nsIEnigmail.DECRYPTION_FAILED |
nsIEnigmail.UNVERIFIED_SIGNATURE |
nsIEnigmail.BAD_SIGNATURE))) ||
(statusFlags & nsIEnigmail.DISPLAY_MESSAGE) &&
!(statusFlags & nsIEnigmail.UNVERIFIED_SIGNATURE)) &&
!(statusFlags & nsIEnigmail.IMPORTED_KEY)) {
// Normal exit / display message
statusLine = errorMsg;
statusInfo = statusLine;
if (sigDetails) {
var detailArr=sigDetails.split(/ /);
var dat=new Date(detailArr[2]*1000);
var appLocale = Components.classes[ENIG_LOCALE_SVC_CONTRACTID].getService(Components.interfaces.nsILocaleService).getApplicationLocale();
var dateFormat = Components.classes[ENIG_DATE_FORMAT_CONTRACTID].getService(Components.interfaces.nsIScriptableDateFormat);
dateTime = dateFormat.FormatDateTime(appLocale.getCategory("NSILOCALE_TIME"),
dateFormat.dateFormatShort,
dateFormat.timeFormatNoSeconds,
dat.getFullYear(), dat.getMonth()+1, dat.getDate(),
dat.getHours(), dat.getMinutes(), 0);
var txt = EnigGetString("keyAndSigDate", keyId.substr(-8, 8), dateTime);
statusArr.push(txt);
statusInfo += "\n" + txt;
var fpr = EnigFormatFpr(detailArr[0]);
if (fpr) {
statusInfo += "\n"+EnigGetString("keyFpr", fpr);
}
}
fullStatusInfo = statusInfo;
} else {
if (keyId) {
statusInfo = EnigGetString("keyNeeded",keyId);
if (statusFlags & nsIEnigmail.INLINE_KEY) {
statusLine = statusInfo + EnigGetString("clickDecrypt");
} else {
statusLine = statusInfo + EnigGetString("clickPen");
}
statusInfo = EnigGetString("unverifiedSig");
statusLine = statusInfo + EnigGetString("clickPen");
statusInfo += "\n\n" + errorMsg;
} else if (statusFlags & nsIEnigmail.UNVERIFIED_SIGNATURE) {
statusInfo = EnigGetString("unverifiedSig");
statusLine = statusInfo + EnigGetString("clickQueryPenDetails");
statusInfo += "\n\n" + errorMsg;
} else if (statusFlags & (nsIEnigmail.BAD_SIGNATURE |
nsIEnigmail.UNVERIFIED_SIGNATURE |
nsIEnigmail.EXPIRED_SIGNATURE |
nsIEnigmail.EXPIRED_KEY_SIGNATURE)) {
statusInfo = EnigGetString("failedSig");
statusLine = statusInfo + EnigGetString("clickPenDetails");
statusInfo += "\n\n" + errorMsg;
} else if (statusFlags & nsIEnigmail.DECRYPTION_INCOMPLETE) {
statusInfo = EnigGetString("incompleteDecrypt");
statusLine = statusInfo + EnigGetString("clickKey");
statusInfo += "\n\n" + errorMsg;
} else if (statusFlags & nsIEnigmail.DECRYPTION_FAILED) {
if (statusFlags & nsIEnigmail.NO_SECKEY) {
statusInfo = EnigGetString("needKey");
} else {
statusInfo = EnigGetString("failedDecrypt");
}
statusLine = statusInfo + EnigGetString("clickKeyDetails");
statusInfo += "\n\n" + errorMsg;
} else if (statusFlags & nsIEnigmail.BAD_PASSPHRASE) {
statusInfo = EnigGetString("badPhrase");
statusLine = statusInfo + EnigGetString("clickDecryptRetry");
statusInfo += "\n\n" + errorMsg;
} else if (statusFlags & nsIEnigmail.IMPORTED_KEY) {
statusLine = "";
statusInfo = "";
EnigAlert(errorMsg);
} else {
statusInfo = EnigGetString("failedDecryptVerify");
statusLine = statusInfo + EnigGetString("viewInfo");
statusInfo += "\n\n" + errorMsg;
}
}
if (statusFlags & nsIEnigmail.DECRYPTION_OKAY ||
(gEnigStatusBar.getAttribute("encrypted")=="ok")) {
if (!statusInfo) {
statusInfo = EnigGetString("decryptedMsg");
}
else {
statusInfo = EnigGetString("decryptedMsg")+"\n"+statusInfo;
}
if (!statusLine) {
statusLine=statusInfo;
}
else {
statusLine=EnigGetString("decryptedMsg")+"; "+statusLine;
}
}
if (EnigGetPref("displayPartiallySigned")) {
if (statusFlags & nsIEnigmail.PARTIALLY_PGP) {
if (msgSigned && msgEncrypted) {
statusLine = EnigGetString("msgPart", EnigGetString("msgSignedAndEnc"));
statusLine += EnigGetString("clickPenKeyDetails");
}
else if (msgEncrypted) {
statusLine = EnigGetString("msgPart", EnigGetString("msgEncrypted"));
statusLine += EnigGetString("clickQueryKeyDetails");
}
else if (msgSigned) {
statusLine = EnigGetString("msgPart", EnigGetString("msgSigned"));
statusLine += EnigGetString("clickQueryPenDetails");
}
}
}
gEnigSecurityInfo = { statusFlags: statusFlags,
keyId: keyId,
userId: userId,
statusLine: statusLine,
msgSigned: msgSigned,
statusArr: statusArr,
statusInfo: statusInfo,
fullStatusInfo: fullStatusInfo };
var enigmailBox = document.getElementById("enigmailBox");
var statusText = document.getElementById("enigmailStatusText");
var statusTextBox = document.getElementById("enigmailStatusTextBox");
var expStatusText = document.getElementById("expandedEnigmailStatusText");
if (statusArr.length>0) {
expStatusText.value = statusArr[0];
expStatusText.setAttribute("state", "true");
}
else {
expStatusText.value = "";
expStatusText.setAttribute("state", "false");
}
if (statusLine) {
statusText.value = statusLine +" ";
enigmailBox.removeAttribute("collapsed");
enigDisplayExtendedStatus(true);
} else {
statusText.value = "";
enigmailBox.setAttribute("collapsed", "true");
enigDisplayExtendedStatus(false);
}
if (!gSMIMEContainer)
return;
// Update icons and header-box css-class
try {
gSMIMEContainer.collapsed = false;
gSignedUINode.collapsed = false;
gEncryptedUINode.collapsed = false;
if (statusFlags & nsIEnigmail.BAD_SIGNATURE) {
// Display untrusted/bad signature icon
gSignedUINode.setAttribute("signed", "notok");
statusText.setAttribute("class", "plain enigmailHeaderValue enigmailHeaderBoxLabelSignatureNotOk");
expStatusText.setAttribute("class", "plain enigmailHeaderValue enigmailHeaderBoxLabelSignatureNotOk");
statusTextBox.setAttribute("class", "enigmailHeaderNameBox enigmailHeaderBoxLabelSignatureNotOk");
gEnigStatusBar.setAttribute("signed", "notok");
}
else if ((statusFlags & nsIEnigmail.GOOD_SIGNATURE) &&
(statusFlags & nsIEnigmail.TRUSTED_IDENTITY) &&
!(statusFlags & (nsIEnigmail.REVOKED_KEY |
nsIEnigmail.EXPIRED_KEY_SIGNATURE |
nsIEnigmail.EXPIRED_SIGNATURE))) {
// Display trusted good signature icon
gSignedUINode.setAttribute("signed", "ok");
statusText.setAttribute("class", "plain enigmailHeaderValue enigmailHeaderBoxLabelSignatureOk");
expStatusText.setAttribute("class", "plain enigmailHeaderValue enigmailHeaderBoxLabelSignatureOk");
statusTextBox.setAttribute("class", "enigmailHeaderNameBox enigmailHeaderBoxLabelSignatureOk");
gEnigStatusBar.setAttribute("signed", "ok");
bodyElement.setAttribute("enigSigned", "ok");
}
else if (statusFlags & nsIEnigmail.UNVERIFIED_SIGNATURE) {
// Display unverified signature icon
gSignedUINode.setAttribute("signed", "unknown");
statusText.setAttribute("class", "plain enigmailHeaderValue enigmailHeaderBoxLabelSignatureUnknown");
expStatusText.setAttribute("class", "plain enigmailHeaderValue enigmailHeaderBoxLabelSignatureUnknown");
statusTextBox.setAttribute("class", "enigmailHeaderNameBox enigmailHeaderBoxLabelSignatureUnknown");
gEnigStatusBar.setAttribute("signed", "unknown");
}
else if (statusFlags & (nsIEnigmail.REVOKED_KEY |
nsIEnigmail.EXPIRED_KEY_SIGNATURE |
nsIEnigmail.EXPIRED_SIGNATURE |
nsIEnigmail.GOOD_SIGNATURE)) {
// Display unverified signature icon
gSignedUINode.setAttribute("signed", "unknown");
statusText.setAttribute("class", "plain enigmailHeaderValue enigmailHeaderBoxLabelSignatureVerified");
expStatusText.setAttribute("class", "plain enigmailHeaderValue enigmailHeaderBoxLabelSignatureVerified");
statusTextBox.setAttribute("class", "enigmailHeaderNameBox enigmailHeaderBoxLabelSignatureVerified");
gEnigStatusBar.setAttribute("signed", "unknown");
}
else if (statusFlags & nsIEnigmail.INLINE_KEY) {
statusText.setAttribute("class", "plain enigmailHeaderValue enigmailHeaderBoxLabelSignatureUnknown");
statusTextBox.setAttribute("class", "enigmailHeaderNameBox enigmailHeaderBoxLabelSignatureUnknown");
}
else {
statusText.setAttribute("class", "plain enigmailHeaderNameBox enigmailHeaderBoxLabelNoSignature");
statusTextBox.setAttribute("class", "enigmailHeaderNameBox enigmailHeaderBoxLabelNoSignature");
}
if (statusFlags & nsIEnigmail.DECRYPTION_OKAY) {
var enigMimeService = Components.classes[ENIG_ENIGMIMESERVICE_CONTRACTID].getService(Components.interfaces.nsIEnigMimeService);
if (enigMimeService)
{
enigMimeService.rememberEncrypted(gEnigLastEncryptedURI);
}
// Display encrypted icon
gEncryptedUINode.setAttribute("encrypted", "ok");
gEnigStatusBar.setAttribute("encrypted", "ok");
}
else if (statusFlags &
(nsIEnigmail.DECRYPTION_INCOMPLETE | nsIEnigmail.DECRYPTION_FAILED) ) {
// Display un-encrypted icon
gEncryptedUINode.setAttribute("encrypted", "notok");
gEnigStatusBar.setAttribute("encrypted", "notok");
statusText.setAttribute("class", "plain enigmailHeaderValue enigmailHeaderBoxLabelSignatureNotOk");
statusTextBox.setAttribute("class", "enigmailHeaderNameBox enigmailHeaderBoxLabelSignatureNotOk");
}
} catch (ex) {}
}
function enigDispSecurityContext() {
var optList = ["pgpSecurityInfo", "copySecurityInfo"];
for (var j=0; j<optList.length; j++) {
var menuElement = document.getElementById("enigmail_"+optList[j]);
if (gEnigSecurityInfo) {
menuElement.removeAttribute("disabled");
}
else {
menuElement.setAttribute("disabled", "true");
}
}
enigSetSenderStatus("signSenderKey", "editSenderKeyTrust" , "showPhoto");
}
function enigUpdateSendersKeyMenu() {
enigSetSenderStatus("keyMgmtSignKey", "keyMgmtKeyTrust", "keyMgmtShowPhoto")
}
function enigSetSenderStatus(elemSign, elemTrust, elemPhoto) {
var photo=false;
var sign=false;
var trust=false;
if (gEnigSecurityInfo) {
if (gEnigSecurityInfo.statusFlags & nsIEnigmail.PHOTO_AVAILABLE) {
photo=true;
}
if (gEnigSecurityInfo.msgSigned ) {
if (!(gEnigSecurityInfo.statusFlags &
(nsIEnigmail.REVOKED_KEY | nsIEnigmail.EXPIRED_KEY_SIGNATURE | nsIEnigmail.UNVERIFIED_SIGNATURE))) {
sign=true;
}
if (!(gEnigSecurityInfo.statusFlags & nsIEnigmail.UNVERIFIED_SIGNATURE)) {
trust=true;
}
}
}
if (elemTrust)
document.getElementById("enigmail_"+elemTrust).setAttribute("disabled", !trust);
if (elemSign)
document.getElementById("enigmail_"+elemSign).setAttribute("disabled", !sign);
if (elemPhoto)
document.getElementById("enigmail_"+elemPhoto).setAttribute("disabled", !photo);
}
function enigEditKeyTrust() {
EnigEditKeyTrust([gEnigSecurityInfo.userId], [gEnigSecurityInfo.keyId]);
ReloadWithAllParts();
}
function enigSignKey() {
EnigSignKey(gEnigSecurityInfo.userId, gEnigSecurityInfo.keyId, null)
ReloadWithAllParts();
}
function enigMsgHdrViewLoad(event)
{
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: enigMsgHdrViewLoad\n");
var listener = {};
listener.onStartHeaders = enigStartHeaders;
listener.onEndHeaders = enigEndHeaders;
listener.beforeStartHeaders = enigBeforeStartHeaders;
gMessageListeners.push(listener);
}
function enigMessageUnload() {
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: enigMessageUnload\n");
}
function enigHdrViewUnload() {
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: enigHdrViewUnLoad\n");
enigForgetEncryptedURI();
}
function enigCopyStatusInfo() {
if (gEnigSecurityInfo) {
var clipHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].createInstance(Components.interfaces.nsIClipboardHelper);
clipHelper.copyString(gEnigSecurityInfo.fullStatusInfo);
}
}
function enigShowPhoto() {
if (! gEnigSecurityInfo)
return
EnigShowPhoto(gEnigSecurityInfo.keyId, gEnigSecurityInfo.userId);
}
function enigCreateRuleFromAddress(emailAddressNode) {
if (emailAddressNode)
{
EnigNewRule(emailAddressNode.getAttribute("emailAddress"));
}
}
function enigForgetEncryptedURI()
{
if (gEnigLastEncryptedURI)
{
var enigMimeService = Components.classes[ENIG_ENIGMIMESERVICE_CONTRACTID].getService(Components.interfaces.nsIEnigMimeService);
if (enigMimeService) {
enigMimeService.forgetEncrypted(gEnigLastEncryptedURI);
gEnigLastEncryptedURI = null;
}
}
}
function enigMsgHdrViewHide() {
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: enigMsgHdrViewHide\n");
var enigmailBox = document.getElementById("enigmailBox");
enigmailBox.setAttribute("collapsed", true);
gEnigSecurityInfo = { statusFlags: 0,
keyId: "",
userId: "",
statusLine: "",
statusInfo: "",
fullStatusInfo: "" };
}
function enigMsgHdrViewUnhide() {
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: enigMsgHdrViewUnhide\n");
if (gEnigSecurityInfo.statusFlags != 0) {
var enigmailBox = document.getElementById("enigmailBox");
enigmailBox.removeAttribute("collapsed");
}
}
function enigDisplayExtendedStatus(displayMe) {
var expStatusText = document.getElementById("expandedEnigmailStatusText");
if (displayMe && expStatusText.getAttribute("state") == "true") {
if (expStatusText.getAttribute("display") == "true") {
expStatusText.removeAttribute("collapsed");
}
else {
expStatusText.setAttribute("collapsed", "true");
}
}
else {
expStatusText.setAttribute("collapsed", "true");
}
}
function enigToggleHeaderView() {
var viewToggle = document.getElementById("enigToggleHeaderView");
var expandedText = document.getElementById("expandedEnigmailStatusText");
var state = viewToggle.getAttribute("state");
if (state=="true") {
viewToggle.setAttribute("state", "false");
viewToggle.setAttribute("class", "collapsedHeaderViewButton");
expandedText.setAttribute("display", "false");
enigDisplayExtendedStatus(false);
}
else {
viewToggle.setAttribute("state", "true");
viewToggle.setAttribute("class", "expandHeaderViewButton");
expandedText.setAttribute("display", "true");
enigDisplayExtendedStatus(true);
}
}
addEventListener('messagepane-loaded', enigMsgHdrViewLoad, true);
addEventListener('messagepane-hide', enigMsgHdrViewHide, true);
addEventListener('messagepane-unhide', enigMsgHdrViewUnhide, true);
// THE FOLLOWING OVERRIDES CODE IN msgHdrViewOverlay.js
var fEnigOpenAttachment;
try {
// Mozilla <= 1.5
if (openAttachment) {
fEnigOpenAttachment = openAttachment;
openAttachment = function (msg) {
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: openAttachment: "+msg.contentType+"\n");
if (msg.contentType.search(/^message\/rfc822/i) == 0) {
// Reset mail.show_headers pref to "original" value
EnigShowHeadersAll(false);
}
fEnigOpenAttachment(msg);
}
}
} catch (ex) {
// Mozilla >= 1.6a
if (createNewAttachmentInfo.prototype.openAttachment) {
createNewAttachmentInfo.prototype.origOpenAttachment = createNewAttachmentInfo.prototype.openAttachment;
createNewAttachmentInfo.prototype.openAttachment = function () {
if (this.contentType.search(/^message\/rfc822/i) == 0) {
// Reset mail.show_headers pref to "original" value
EnigShowHeadersAll(false);
}
this.origOpenAttachment();
}
}
}
if (messageHeaderSink) {
// Modify the methods onStartHeaders, getSecurityinfo, setSecurityInfo
// of the object messageHeaderSink in msgHdrViewOverlay.js.
// Use the pref "extensions.enigmail.show_headers"
// instead of "mail.show_headers"
messageHeaderSink.onStartHeaders = function()
{
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: messageHeaderSink.onStartHeaders: START\n");
mSaveHdr = null;
// clear out any pending collected address timers...
if (gCollectAddressTimer)
{
gCollectAddess = "";
clearTimeout(gCollectAddressTimer);
gCollectAddressTimer = null;
}
mSaveHdr = null;
if (this.enigDetermineHeadersPref())
{
gViewAllHeaders = true;
}
else
{
if (gViewAllHeaders) // if we currently are in view all header mode, rebuild our header view so we remove most of the header data
{
hideHeaderView(gExpandedHeaderView);
gExpandedHeaderView = {};
initializeHeaderViewTables();
}
gViewAllHeaders = false;
}
ClearCurrentHeaders();
gBuiltExpandedView = false;
gBuiltCollapsedView = false;
gBuildAttachmentsForCurrentMsg = false;
gBuildAttachmentPopupForCurrentMsg = true;
ClearAttachmentList();
ClearEditMessageButton();
if (typeof(gMessageNotificationBar) == "object") {
// TB >= 1.0+
gMessageNotificationBar.clearMsgNotifications();
}
else if (typeof(SetUpRemoteContentBar) == "function") {
// TB >= 0.8
SetUpRemoteContentBar(null);
}
for (index in gMessageListeners)
gMessageListeners[index].onStartHeaders();
}
messageHeaderSink.enigDetermineHeadersPref = function ()
{
var headersPref = 1;
if (EnigGetPref("parseAllHeaders")) {
headersPref = EnigGetPref("show_headers");
} else try {
headersPref = gEnigPrefRoot.getIntPref("mail.show_headers");
} catch (ex) {}
return (headersPref == 2);
}
messageHeaderSink.enigPrepSecurityInfo = function ()
{
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: enigPrepSecurityInfo\n");
var securityInfo = this.securityInfo;
var innerSMIMEHeaderSink = null;
var enigMimeHeaderSink = null;
try {
innerSMIMEHeaderSink = securityInfo.QueryInterface(Components.interfaces.nsIMsgSMIMEHeaderSink);
try {
enigMimeHeaderSink = innerSMIMEHeaderSink.QueryInterface(Components.interfaces.nsIEnigMimeHeaderSink);
} catch (ex) {}
} catch (ex) {}
if (!enigMimeHeaderSink) {
this.securityInfo = new EnigMimeHeaderSink(innerSMIMEHeaderSink);
}
}
}
function EnigMimeHeaderSink(innerSMIMEHeaderSink) {
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: EnigMimeHeaderSink.innerSMIMEHeaderSink="+innerSMIMEHeaderSink+"\n");
this._smimeHeaderSink = innerSMIMEHeaderSink;
}
EnigMimeHeaderSink.prototype =
{
_smimeHeaderSink: null,
QueryInterface : function(iid)
{
//DEBUG_LOG("enigmailMsgHdrViewOverlay.js: EnigMimeHeaderSink.QI: "+iid+"\n");
if (iid.equals(Components.interfaces.nsIMsgSMIMEHeaderSink) &&
this._smimeHeaderSink)
return this;
if (iid.equals(Components.interfaces.nsIEnigMimeHeaderSink) ||
iid.equals(Components.interfaces.nsISupports) )
return this;
throw Components.results.NS_NOINTERFACE;
},
updateSecurityStatus: function(uriSpec, exitCode, statusFlags, keyId, userId, sigDetails, errorMsg)
{
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: EnigMimeHeaderSink.updateSecurityStatus: uriSpec="+uriSpec+"\n");
var msgUriSpec = enigGetCurrentMsgUriSpec();
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: EnigMimeHeaderSink.updateSecurityStatus: msgUriSpec="+msgUriSpec+"\n");
if (!uriSpec || (uriSpec == msgUriSpec)) {
enigUpdateHdrIcons(exitCode, statusFlags, keyId, userId, sigDetails, errorMsg);
}
return;
},
maxWantedNesting: function()
{
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: EnigMimeHeaderSink.maxWantedNesting:\n");
return this._smimeHeaderSink.maxWantedNesting();
},
signedStatus: function(aNestingLevel, aSignatureStatus, aSignerCert)
{
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: EnigMimeHeaderSink.signedStatus:\n");
return this._smimeHeaderSink.signedStatus(aNestingLevel, aSignatureStatus, aSignerCert);
},
encryptionStatus: function(aNestingLevel, aEncryptionStatus, aRecipientCert)
{
DEBUG_LOG("enigmailMsgHdrViewOverlay.js: EnigMimeHeaderSink.encryptionStatus:\n");
return this._smimeHeaderSink.encryptionStatus(aNestingLevel, aEncryptionStatus, aRecipientCert);
}
};
diff --git a/ui/content/enigmailSearchKey.js b/ui/content/enigmailSearchKey.js
index 8ae41715..1bc4da00 100755
--- a/ui/content/enigmailSearchKey.js
+++ b/ui/content/enigmailSearchKey.js
@@ -1,723 +1,733 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "MPL"); you may not use this file
* except in compliance with the MPL. You may obtain a copy of
* the MPL at http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the MPL for the specific language governing
* rights and limitations under the MPL.
*
* The Original Code is Enigmail.
*
* The Initial Developer of this code is Patrick Brunschwig.
* Portions created by Patrick Brunschwig <patrick.brunschwig@gmx.net>
* are Copyright (C) 2004 Patrick Brunschwig.
* All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License (the "GPL"), in which case
* the provisions of the GPL are applicable instead of
* those above. If you wish to allow use of your version of this
* file only under the terms of the GPL and not to allow
* others to use your version of this file under the MPL, indicate
* your decision by deleting the provisions above and replace them
* with the notice and other provisions required by the GPL.
* If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
// Uses: chrome://enigmail/content/enigmailCommon.js
// Initialize enigmailCommon
EnigInitCommon("enigmailSearchKey");
const INPUT = 0;
const RESULT = 1;
-const ENIG_DEFAULT_HKP_PORT="11371";
+const ENIG_DEFAULT_HKP_PORT = "11371";
+const ENIG_DEFAULT_LDAP_PORT = "389";
-const ENIG_IMG_NOT_SELECTED ="chrome://enigmail/content/check0.png";
-const ENIG_IMG_SELECTED ="chrome://enigmail/content/check1.png";
-const ENIG_IMG_DISABLED ="chrome://enigmail/content/check2.png";
+const ENIG_IMG_NOT_SELECTED = "chrome://enigmail/content/check0.png";
+const ENIG_IMG_SELECTED = "chrome://enigmail/content/check1.png";
+const ENIG_IMG_DISABLED = "chrome://enigmail/content/check2.png";
const ENIG_CONN_TYPE_HTTP = 1;
const ENIG_CONN_TYPE_GPGKEYS = 2;
const KEY_EXPIRED="e";
const KEY_REVOKED="r";
const KEY_INVALID="i";
const KEY_DISABLED="d";
const KEY_NOT_VALID=KEY_EXPIRED+KEY_REVOKED+KEY_INVALID+KEY_DISABLED;
function trim(str) {
return str.replace(/^(\s*)(.*)/, "$2").replace(/\s+$/,"");
}
function onLoad () {
window.arguments[RESULT].importedKeys=0;
var ioService = Components.classes[ENIG_IOSERVICE_CONTRACTID].getService(Components.interfaces.nsIIOService);
if (ioService && ioService.offline) {
EnigAlert(EnigGetString("needOnline"));
enigCloseDialog();
return false;
}
var valueObj = {};
if (window.arguments[INPUT].searchList) {
valueObj = { keyId: "<"+window.arguments[INPUT].searchList.join("> <")+">" };
}
var checkObj = new Object();
var keyserver = null;
while (! keyserver) {
window.openDialog("chrome://enigmail/content/enigmailKeyserverDlg.xul",
"", "dialog,modal,centerscreen", valueObj, checkObj);
if (! checkObj.value) {
enigCloseDialog();
return false;
}
keyserver = checkObj.value;
if (! window.arguments[INPUT].searchList) {
window.arguments[INPUT].searchList = checkObj.email.split(/[,; ]+/);
}
}
var protocol="";
if (keyserver.search(/[a-zA-Z0-9\-\_\.]+:\/\//)==0) {
protocol=keyserver.replace(/^([a-zA-Z0-9\-\_\.]+)(:\/\/.*)/, "$1");
if (protocol.search(/hkp/i) >= 0) {
protocol="hkp";
}
keyserver=keyserver.replace(/^[a-zA-Z0-9\-\_\.]+:\/\//, "");
}
else {
protocol="hkp";
}
+
+ var port="";
+ switch (protocol) {
+ case "hkp":
+ var port = ENIG_DEFAULT_HKP_PORT;
+ break;
+ case "ldap":
+ port = ENIG_DEFAULT_LDAP_PORT;
+ break;
+ }
- var port = ENIG_DEFAULT_HKP_PORT;
var m = keyserver.match(/^(.+)(:)(\d+)$/);
if (m && m.length==4) {
keyserver = m[1];
port = m[3];
}
window.enigRequest = {
searchList: window.arguments[INPUT].searchList,
keyNum: 0,
keyserver: keyserver,
port: port,
protocol: protocol,
keyList: [],
requestType: (EnigGetPref("useGpgKeysTool") ? ENIG_CONN_TYPE_GPGKEYS : ENIG_CONN_TYPE_HTTP),
gpgkeysRequest: null,
progressMeter: document.getElementById("dialog.progress"),
httpInProgress: false
};
switch (window.enigRequest.requestType) {
case ENIG_CONN_TYPE_HTTP:
enigNewHttpRequest(nsIEnigmail.SEARCH_KEY, enigScanKeys);
break;
case ENIG_CONN_TYPE_GPGKEYS:
enigNewGpgKeysRequest(nsIEnigmail.SEARCH_KEY, enigScanKeys);
break;
}
return true;
}
function onAccept () {
DEBUG_LOG("enigmailSearchKey.js: onAccept\n");
var keySelList = document.getElementById("enigmailKeySel");
var treeChildren=keySelList.getElementsByAttribute("id", "enigmailKeySelChildren")[0];
window.enigRequest.dlKeyList = [];
var item=treeChildren.firstChild;
while (item) {
var aRows = item.getElementsByAttribute("id","indicator")
if (aRows.length) {
var elem=aRows[0];
if (elem.getAttribute("active") == "1") {
window.enigRequest.dlKeyList.push(item.getAttribute("id"));
}
}
item = item.nextSibling;
}
if (window.enigRequest.dlKeyList.length>0) {
window.enigRequest.progressMeter.value = 0;
window.enigRequest.progressMeter.mode = "determined";
document.getElementById("progress.box").removeAttribute("hidden");
document.getElementById("dialog.accept").setAttribute("disabled", "true");
window.enigRequest.keyNum = 0;
switch (window.enigRequest.requestType) {
case ENIG_CONN_TYPE_HTTP:
enigNewHttpRequest(nsIEnigmail.DOWNLOAD_KEY, enigImportKeys);
break;
case ENIG_CONN_TYPE_GPGKEYS:
enigNewGpgKeysRequest(nsIEnigmail.DOWNLOAD_KEY, enigImportKeys);
break;
}
// do not yet close the window, so that we can display some progress info
return false;
}
return true;
}
function onCancel() {
if (window.enigRequest.httpInProgress) {
// stop download
try {
if ((typeof(window.enigHttpReq) == "object") &&
(window.enigHttpReq.readyState != 4)) {
window.enigHttpReq.abort();
}
window.enigRequest.httpInProgress=false;
if (window.enigRequest.gpgkeysRequest) {
enigGpgkeysCloseRequest();
}
}
catch (ex) {}
}
window.close();
}
function enigStatusError () {
DEBUG_LOG("enigmailSearchKey.js: enigStatusError\n");
window.enigRequest.httpInProgress=false;
EnigAlert(EnigGetString("noKeyserverConn", this.channel.originalURI.prePath));
enigCloseDialog();
}
function enigCloseDialog() {
document.getElementById("enigmailSearchKeyDlg").cancelDialog();
window.close();
}
function enigStatusLoaded (event) {
DEBUG_LOG("enigmailSearchKey.js: enigStatusLoaded\n");
if (this.status == 200) {
// de-HTMLize the result
var htmlTxt = this.responseText.replace(/<([^<>]+)>/g, "");
this.requestCallbackFunc(ENIG_CONN_TYPE_HTTP, htmlTxt);
}
else if (this.status == 500 && this.statusText=="OK") {
this.requestCallbackFunc(ENIG_CONN_TYPE_HTTP, "no keys found");
}
else if (this.statusText!="OK") {
EnigAlert(EnigGetString("keyDownloadFailed", this.statusText));
enigCloseDialog();
return;
}
}
function enigImportKeys (connType, txt) {
DEBUG_LOG("enigmailSearchKey.js: enigImportKeys\n");
window.enigRequest.keyNum++;
window.enigRequest.progressMeter.mode = "determined";
window.enigRequest.progressMeter.value = (100 * window.enigRequest.keyNum / window.enigRequest.dlKeyList.length).toFixed(0);
if (!enigImportHtmlKeys(txt)) return;
if (window.enigRequest.dlKeyList.length > window.enigRequest.keyNum) {
switch (connType) {
case ENIG_CONN_TYPE_HTTP:
enigNewHttpRequest(nsIEnigmail.DOWNLOAD_KEY, window.enigHttpReq.requestCallbackFunc);
break;
case ENIG_CONN_TYPE_GPGKEYS:
enigNewGpgKeysRequest(nsIEnigmail.DOWNLOAD_KEY, window.enigRequest.callbackFunction);
}
return;
}
window.enigRequest.httpInProgress=false;
enigCloseDialog();
}
function enigImportHtmlKeys(txt) {
var errorMsgObj = new Object();
var enigmailSvc = GetEnigmailSvc();
if (! enigmailSvc)
return false;
var uiFlags = nsIEnigmail.UI_ALLOW_KEY_IMPORT;
var r = enigmailSvc.importKey(window, uiFlags, txt,
window.enigRequest.dlKeyList[window.enigRequest.keyNum-1],
errorMsgObj);
if (errorMsgObj.value)
EnigAlert(errorMsgObj.value);
if (r == 0) {
window.arguments[RESULT].importedKeys++;
return true;
}
return false;
}
function enigNewHttpRequest(requestType, requestCallbackFunc) {
DEBUG_LOG("enigmailSearchKey.js: enigNewHttpRequest\n");
switch (window.enigRequest.protocol) {
case "hkp":
window.enigRequest.protocol = "http";
case "http":
case "https":
break;
default:
var msg=EnigGetString("protocolNotSupported", window.enigRequest.protocol);
if (! EnigGetPref("useGpgKeysTool"))
msg += " "+EnigGetString("gpgkeysDisabled");
EnigAlert(msg);
enigCloseDialog();
return;
}
var httpReq = new XMLHttpRequest();
var reqCommand;
switch (requestType) {
case nsIEnigmail.SEARCH_KEY:
var pubKey = escape("<"+trim(window.enigRequest.searchList[window.enigRequest.keyNum])+">");
reqCommand = window.enigRequest.protocol+"://"+window.enigRequest.keyserver+":"+window.enigRequest.port+"/pks/lookup?search="+pubKey+"&op=index";
break;
case nsIEnigmail.DOWNLOAD_KEY:
var keyId = escape(trim(window.enigRequest.dlKeyList[window.enigRequest.keyNum]));
reqCommand = window.enigRequest.protocol+"://"+window.enigRequest.keyserver+":"+window.enigRequest.port+"/pks/lookup?search="+keyId+"&op=get";
break;
default:
EnigAlert("Unknown request type "+requestType);
return;
}
window.enigRequest.httpInProgress=true;
httpReq.open("GET", reqCommand);
httpReq.onerror=enigStatusError;
httpReq.onload=enigStatusLoaded;
httpReq.requestCallbackFunc = requestCallbackFunc;
window.enigHttpReq = httpReq;
httpReq.send("");
}
function enigScanKeys(connType, htmlTxt) {
DEBUG_LOG("enigmailSearchKey.js: enigScanKeys\n");
window.enigRequest.keyNum++;
window.enigRequest.progressMeter.mode = "determined";
window.enigRequest.progressMeter.value = (100 * window.enigRequest.keyNum / window.enigRequest.searchList.length).toFixed(0);
switch (connType) {
case ENIG_CONN_TYPE_HTTP:
// interpret HTML codes (e.g. &lt;)
var domParser = new DOMParser();
// needs improvement: result is max. 4096 bytes long!
var htmlNode = domParser.parseFromString("<p>" + htmlTxt + "</p>", "text/xml");
if (htmlNode.firstChild.nodeName=="parsererror") {
EnigAlert("internalError");
return false;
}
enigScanHtmlKeys(htmlNode.firstChild.firstChild.data);
break;
case ENIG_CONN_TYPE_GPGKEYS:
enigScanGpgKeys(EnigConvertGpgToUnicode(htmlTxt));
break;
default:
ERROR_LOG("bizarre connType: "+connType+"\n");
}
if (window.enigRequest.searchList.length > window.enigRequest.keyNum) {
switch (connType) {
case ENIG_CONN_TYPE_HTTP:
enigNewHttpRequest(nsIEnigmail.SEARCH_KEY, window.enigHttpReq.requestCallbackFunc);
break;
case ENIG_CONN_TYPE_GPGKEYS:
enigNewGpgKeysRequest(nsIEnigmail.SEARCH_KEY, window.enigRequest.callbackFunction);
}
return true;
}
window.enigRequest.httpInProgress=false;
enigPopulateList(window.enigRequest.keyList);
document.getElementById("progress.box").setAttribute("hidden", "true");
if (window.enigRequest.keyList.length == 0) {
EnigAlert(EnigGetString("noKeyFound"));
enigCloseDialog();
}
document.getElementById("dialog.accept").removeAttribute("disabled");
return true;
}
function enigScanHtmlKeys (txt) {
DEBUG_LOG("enigmailSearchKey.js: enigScanHtmlKeys\n");
var lines=txt.split(/(\n\r|\n|\r)/);
var key;
for (i=0; i<lines.length; i++) {
if (lines[i].search(/^\s*pub /)==0) {
// new key
if (key) {
// first, append prev. key to keylist
window.enigRequest.keyList.push(key);
}
key = null;
var m=lines[i].match(/(\d+[a-zA-Z]?\/)([0-9a-fA-F]+)(\s+[\d\/\-\.]+\s+)(.*)/);
if (m && m.length>0 ) {
key={
keyId: m[2],
created: m[3],
uid: []
};
if (m[4].search(/.+<.+@.+>/)>=0) {
key.uid.push(trim(m[4]));
}
else if (m[4].search(/key (revoked|expired|disabled)/i)>=0) {
DEBUG_LOG("revoked key id "+m[4]+"\n");
key=null;
}
}
}
else {
// amend to key
if (key) {
var uid = trim(lines[i]);
if (uid.length>0)
key.uid.push(uid);
}
}
}
// append prev. key to keylist
if (key) {
window.enigRequest.keyList.push(key);
}
}
function enigScanGpgKeys(txt) {
DEBUG_LOG("enigmailSearchKey.js: enigScanGpgKeys\n");
var lines=txt.split(/(\r\n|\n|\r)/);
var outputType=0;
var key;
- for (i=0; i<lines.length; i++) {
+ for (var i=0; i<lines.length; i++) {
if (outputType == 0 && lines[i].search(/^COUNT \d+\s*$/)==0) {
outputType=1;
continue;
}
if (outputType == 0 && lines[i].search(/^pub:[\da-fA-F]{8}/)==0) {
outputType=2;
}
if (outputType==1 && (lines[i].search(/^([a-fA-F0-9]{8}){1,2}:/))==0) {
// output from gpgkeys_* protocol version 0
// new key
var m=lines[i].split(/:/);
if (m && m.length>0 ) {
if (key) {
if (key.keyId == m[0]) {
key.uid.push(trim(m[1]));
}
else {
window.enigRequest.keyList.push(key);
key=null;
}
}
if (! key) {
var dat=new Date(m[3]*1000);
var month=String(dat.getMonth()+101).substr(1);
var day=String(dat.getDate()+100).substr(1);
key={
keyId: m[0],
created: dat.getFullYear()+"-"+month+"-"+day,
uid: [m[1]]
};
}
}
}
if (outputType==2 && (lines[i].search(/^pub:/))==0) {
// output from gpgkeys_* protocol version 1
// new key
m=lines[i].split(/:/);
if (m && m.length>1 ) {
if (key) {
window.enigRequest.keyList.push(key);
key=null;
}
dat=new Date(m[4]*1000);
month=String(dat.getMonth()+101).substr(1);
day=String(dat.getDate()+100).substr(1);
key={
keyId: m[1],
created: dat.getFullYear()+"-"+month+"-"+day,
uid: []
};
}
}
- if (outputType==2 && (lines[i].search(/^uid:.*:.*:.*:.*$/))==0) {
+ if (outputType==2 && (lines[i].search(/^uid:.+/))==0) {
// output from gpgkeys_* protocol version 1
// uid for key
m=lines[i].split(/:/);
if (m && m.length>1 ) {
if (key)
key.uid.push(trim(m[1]));
}
}
}
// append prev. key to keylist
if (key) {
window.enigRequest.keyList.push(key);
}
}
// interaction with gpgkeys_xxx
function enigNewGpgKeysRequest(requestType, callbackFunction) {
DEBUG_LOG("enigmailSearchkey.js: enigNewGpgKeysRequest\n");
var enigmailSvc = GetEnigmailSvc();
if (!enigmailSvc) {
EnigAlert(EnigGetString("accessError"));
return;
}
window.enigRequest.callbackFunction = callbackFunction;
var requestObserver = new EnigRequestObserver(enigmailGpgkeysTerminate, null);
var errorMsgObj = new Object();
var ipcRequest = null;
window.enigRequest.gpgkeysRequest = null;
try {
if (requestType == nsIEnigmail.SEARCH_KEY) {
var keyValue = window.enigRequest.searchList[window.enigRequest.keyNum];
}
else {
keyValue = window.enigRequest.dlKeyList[window.enigRequest.keyNum];
}
ipcRequest = enigmailSvc.searchKey(requestType,
window.enigRequest.protocol,
window.enigRequest.keyserver,
window.enigRequest.port,
keyValue,
requestObserver,
errorMsgObj);
} catch (ex) {}
if (!ipcRequest) {
// calling gpgkeys_xxx failed, let's try builtin http variant
switch (window.enigRequest.protocol) {
case "hkp":
case "http":
case "https":
window.enigRequest.requestType = ENIG_CONN_TYPE_HTTP;
enigNewHttpRequest(requestType, enigScanKeys);
return;
default:
EnigAlert(EnigGetString("gpgKeysFailed", window.enigRequest.protocol));
enigCloseDialog();
return;
}
}
window.enigRequest.gpgkeysRequest = ipcRequest;
WRITE_LOG("enigmailSearchkey.js: Start: window.enigRequest.gpgkeysRequest = "+window.enigRequest.gpgkeysRequest+"\n");
}
function enigGpgkeysCloseRequest() {
DEBUG_LOG("enigmailSearchkey.js: CloseRequest\n");
if (window.enigRequest.gpgkeysRequest) {
try {
var searchkeyProcess = window.enigRequest.gpgkeysRequest.pipeTransport;
if (searchkeyProcess)
searchkeyProcess.terminate();
} catch(ex) {}
window.enigRequest.gpgkeysRequest.close(true);
window.enigRequest.gpgkeysRequest = null;
}
}
function enigmailGpgkeysTerminate(terminateArg, ipcRequest) {
DEBUG_LOG("enigmailSearchkey.js: Terminate: "+ipcRequest+"\n");
var GpgkeysProcess = ipcRequest.pipeTransport;
var enigmailSvc = GetEnigmailSvc();
if (GpgkeysProcess && !GpgkeysProcess.isAttached) {
GpgkeysProcess.terminate();
var exitCode = GpgkeysProcess.exitCode();
DEBUG_LOG("enigmailGpgkeysConsole: exitCode = "+exitCode+"\n");
if (enigmailSvc) {
exitCode = enigmailSvc.fixExitCode(exitCode, 0);
}
}
var console = window.enigRequest.gpgkeysRequest.stdoutConsole;
try {
console = console.QueryInterface(Components.interfaces.nsIPipeConsole);
var txt = null;
if (console && console.hasNewData()) {
DEBUG_LOG("enigmailSearchkey.js: enigRefreshConsole(): hasNewData\n");
txt = console.getData();
}
ipcRequest.close(true);
enigGpgkeysCloseRequest();
if (txt)
window.enigRequest.callbackFunction(ENIG_CONN_TYPE_GPGKEYS, txt);
} catch (ex) {}
}
// GUI related stuff
function enigPopulateList(keyList) {
DEBUG_LOG("enigmailSearchKey.js: enigPopulateList\n");
var sortUsers = function (a,b) {
if (a.uid[0]<b.uid[0]) { return -1; } else {return 1; }
}
keyList.sort(sortUsers);
var treeList = document.getElementById("enigmailKeySel");
var treeChildren=treeList.getElementsByAttribute("id", "enigmailKeySelChildren")[0];
var treeItem;
for (var i=0; i<keyList.length; i++) {
treeItem = enigUserSelCreateRow(keyList[i].keyId, false, keyList[i].uid[0], keyList[i].created, "");
if (keyList[i].uid.length>1) {
treeItem.setAttribute("container", "true");
var subChildren=document.createElement("treechildren");
for (j=1; j<keyList[i].uid.length; j++) {
var subItem=enigUserSelCreateRow(keyList[i].keyId, true, keyList[i].uid[j], "", "");
subChildren.appendChild(subItem);
}
treeItem.appendChild(subChildren);
}
treeChildren.appendChild(treeItem);
}
}
function enigUserSelCreateRow (keyId, subKey, userId, dateField, trustStatus) {
var selectCol=document.createElement("treecell");
selectCol.setAttribute("id", "indicator");
var expCol=document.createElement("treecell");
var userCol=document.createElement("treecell");
userCol.setAttribute("id", "name");
if (trustStatus.charAt(0)==KEY_EXPIRED) {
expCol.setAttribute("label", EnigGetString("selKeyExpired", dateField));
}
else {
expCol.setAttribute("label", dateField);
}
expCol.setAttribute("id", "expiry");
userCol.setAttribute("label", userId);
var keyCol=document.createElement("treecell");
keyCol.setAttribute("id", "keyid");
if (subKey) {
enigSetActive(selectCol, -1);
keyCol.setAttribute("label", "");
}
else {
enigSetActive(selectCol, 0);
keyCol.setAttribute("label", keyId.substr(-8));
}
var userRow=document.createElement("treerow");
userRow.appendChild(selectCol);
userRow.appendChild(userCol);
userRow.appendChild(expCol);
userRow.appendChild(keyCol);
var treeItem=document.createElement("treeitem");
treeItem.setAttribute("id", "0x"+keyId);
treeItem.appendChild(userRow);
return treeItem;
}
function enigmailKeySelCallback(event) {
DEBUG_LOG("enigmailSearchKey.js: enigmailKeySelCallback\n");
var Tree = document.getElementById("enigmailKeySel");
var row = {};
var col = {};
var elt = {};
Tree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, col, elt);
if (row.value == -1)
return;
var treeItem = Tree.contentView.getItemAtIndex(row.value);
Tree.currentItem=treeItem;
if (typeof(col.value) == "string") {
// mozilla <= 1.7
if (col.value != "selectionCol")
return;
}
else {
// mozilla >= 1.8a1
if (col.value.id != "selectionCol")
return;
}
var aRows = treeItem.getElementsByAttribute("id","indicator")
if (aRows.length) {
var elem=aRows[0];
if (elem.getAttribute("active") == "1") {
enigSetActive(elem, 0);
} else if (elem.getAttribute("active") == "0") {
enigSetActive(elem, 1);
}
}
}
// set the "active" flag and the corresponding image
function enigSetActive(element, status) {
if (status>=0)
element.setAttribute("active", status.toString());
switch (status)
{
case 0:
element.setAttribute("src", ENIG_IMG_NOT_SELECTED);
break;
case 1:
element.setAttribute("src", ENIG_IMG_SELECTED);
break;
case 2:
element.setAttribute("src", ENIG_IMG_DISABLED);
break;
default:
element.setAttribute("active", -1);
}
}
diff --git a/ui/jar.mn b/ui/jar.mn
index e096f619..b7c04b28 100644
--- a/ui/jar.mn
+++ b/ui/jar.mn
@@ -1,147 +1,149 @@
enigmail.jar:
content/enigmail/contents.rdf (content/contents.rdf)
content/enigmail/enigmailCommon.js (content/enigmailCommon.js)
content/enigmail/enigmailAbCardViewOverlay.xul (content/enigmailAbCardViewOverlay.xul)
content/enigmail/enigmailAbContactsPanel.xul (content/enigmailAbContactsPanel.xul)
content/enigmail/enigmailAbOverlay.js (content/enigmailAbOverlay.js)
content/enigmail/enigmailAbout.xul (content/enigmailAbout.xul)
content/enigmail/enigmailAbout.js (content/enigmailAbout.js)
content/enigmail/enigmailAbout.htm (content/enigmailAbout.htm)
content/enigmail/enigmailAddUidDlg.xul (content/enigmailAddUidDlg.xul)
content/enigmail/enigmailAlertDlg.xul (content/enigmailAlertDlg.xul)
content/enigmail/enigmailAttachmentsDialog.xul (content/enigmailAttachmentsDialog.xul)
content/enigmail/enigmailAttachmentsDialog.js (content/enigmailAttachmentsDialog.js)
content/enigmail/enigmailAmIdEditOverlay.xul (content/enigmailAmIdEditOverlay.xul)
content/enigmail/enigmailCheckLanguage.xul (content/enigmailCheckLanguage.xul)
+ content/enigmail/enigmailCardDetails.xul (content/enigmailCardDetails.xul)
content/enigmail/enigmailConsole.xul (content/enigmailConsole.xul)
content/enigmail/enigmailConsole.js (content/enigmailConsole.js)
content/enigmail/enigmailConsole.htm (content/enigmailConsole.htm)
content/enigmail/enigmailCustToolOverlay.xul (content/enigmailCustToolOverlay.xul)
content/enigmail/enigmailDispPhoto.xul (content/enigmailDispPhoto.xul)
content/enigmail/enigmailEditIdentity.js (content/enigmailEditIdentity.js)
content/enigmail/enigmailEditIdentity.xul (content/enigmailEditIdentity.xul)
content/enigmail/enigmailEditKeyTrustDlg.xul (content/enigmailEditKeyTrustDlg.xul)
content/enigmail/enigmailEncryptionDlg.xul (content/enigmailEncryptionDlg.xul)
content/enigmail/enigmailEncryptionDlg.js (content/enigmailEncryptionDlg.js)
+ content/enigmail/enigmailGenCardKey.xul (content/enigmailGenCardKey.xul)
content/enigmail/enigmailHelp.xul (content/enigmailHelp.xul)
content/enigmail/enigmailHelp.js (content/enigmailHelp.js)
content/enigmail/enigmailKeyDetailsDlg.xul (content/enigmailKeyDetailsDlg.xul)
content/enigmail/enigmailKeyManager.xul (content/enigmailKeyManager.xul)
content/enigmail/enigmailKeyManager.js (content/enigmailKeyManager.js)
content/enigmail/enigmailManageUidDlg.xul (content/enigmailManageUidDlg.xul)
content/enigmail/enigmailPanel.xul (content/enigmailPanel.xul)
content/enigmail/enigmailPanel.js (content/enigmailPanel.js)
content/enigmail/enigmailRulesEditor.xul (content/enigmailRulesEditor.xul)
content/enigmail/enigmailRulesEditor.js (content/enigmailRulesEditor.js)
content/enigmail/enigmailSearchKey.js (content/enigmailSearchKey.js)
content/enigmail/enigmailSearchKey.xul (content/enigmailSearchKey.xul)
content/enigmail/enigmailSelectPanel.xul (content/enigmailSelectPanel.xul)
content/enigmail/enigmailSingleRcptSettings.js (content/enigmailSingleRcptSettings.js)
content/enigmail/enigmailSingleRcptSettings.xul (content/enigmailSingleRcptSettings.xul)
content/enigmail/enigmailSelectPanel.js (content/enigmailSelectPanel.js)
content/enigmail/enigmailSignKeyDlg.xul (content/enigmailSignKeyDlg.xul)
content/enigmail/pref-enigmail.xul (content/pref-enigmail.xul)
content/enigmail/pref-enigmail.js (content/pref-enigmail.js)
content/enigmail/pref-enigmail-seamonkey.xul (content/pref-enigmail-seamonkey.xul)
content/enigmail/pref-enigmail-seamonkey.js (content/pref-enigmail-seamonkey.js)
content/enigmail/am-enigprefs.xul (content/am-enigprefs.xul)
content/enigmail/am-enigprefs.js (content/am-enigprefs.js)
content/enigmail/am-enigprefs-edit.xul (content/am-enigprefs-edit.xul)
content/enigmail/enigmailKeygen.xul (content/enigmailKeygen.xul)
content/enigmail/enigmailKeygen.js (content/enigmailKeygen.js)
content/enigmail/enigmailKeygenConsole.htm (content/enigmailKeygenConsole.htm)
content/enigmail/enigmailKeyserverDlg.xul (content/enigmailKeyserverDlg.xul)
content/enigmail/enigmailUserSelection.xul (content/enigmailUserSelection.xul)
content/enigmail/enigmailUserSelection.js (content/enigmailUserSelection.js)
content/enigmail/enigmailUpgrade.xul (content/enigmailUpgrade.xul)
content/enigmail/enigmailUninstall.xul (content/enigmailUninstall.xul)
content/enigmail/enigmailNavigatorOverlay.xul (content/enigmailNavigatorOverlay.xul)
content/enigmail/enigmailNavigatorOverlay.js (content/enigmailNavigatorOverlay.js)
content/enigmail/enigmailMsgComposeOverlay.xul (content/enigmailMsgComposeOverlay.xul)
content/enigmail/enigmailMsgComposeOverlay.js (content/enigmailMsgComposeOverlay.js)
content/enigmail/enigmailMsgComposeHelper.js (content/enigmailMsgComposeHelper.js)
content/enigmail/enigmailMessengerOverlay.xul (content/enigmailMessengerOverlay.xul)
content/enigmail/enigmailMessengerOverlay.js (content/enigmailMessengerOverlay.js)
content/enigmail/enigmailMsgHdrViewOverlay.xul (content/enigmailMsgHdrViewOverlay.xul)
content/enigmail/enigmailMsgHdrViewOverlay.js (content/enigmailMsgHdrViewOverlay.js)
content/enigmail/enigmailMsgPrintOverlay.xul (content/enigmailMsgPrintOverlay.xul)
content/enigmail/enigmailMsgPrintOverlay.js (content/enigmailMsgPrintOverlay.js)
content/enigmail/enigmailPrefsOverlay.xul (content/enigmailPrefsOverlay.xul)
content/enigmail/enigmailViewFile.xul (content/enigmailViewFile.xul)
content/enigmail/enigmailViewKeySigDlg.xul (content/enigmailViewKeySigDlg.xul)
content/enigmail/enigRetrieveProgress.xul (content/enigRetrieveProgress.xul)
content/enigmail/enigRetrieveProgress.js (content/enigRetrieveProgress.js)
content/enigmail/check0.png (skin/images/check0.png)
content/enigmail/check1.png (skin/images/check1.png)
content/enigmail/check2.png (skin/images/check2.png)
locale/en-US/enigmail/contents.rdf (locale/en-US/contents.rdf)
locale/en-US/enigmail/enigmail.dtd (locale/en-US/enigmail.dtd)
locale/en-US/enigmail/enigmail.properties (locale/en-US/enigmail.properties)
locale/en-US/enigmail/am-enigprefs.properties (locale/en-US/am-enigprefs.properties)
locale/en-US/enigmail/upgrade_080.html (locale/en-US/upgrade_080.html)
locale/en-US/enigmail/help/messenger.html (locale/en-US/help/messenger.html)
locale/en-US/enigmail/help/compose.html (locale/en-US/help/compose.html)
locale/en-US/enigmail/help/rulesEditor.html (locale/en-US/help/rulesEditor.html)
locale/en-US/enigmail/help/editRcptRule.html (locale/en-US/help/editRcptRule.html)
enigmail-en-US.jar:
locale/en-US/enigmail/contents.rdf (locale/en-US/contents.rdf)
locale/en-US/enigmail/enigmail.dtd (locale/en-US/enigmail.dtd)
locale/en-US/enigmail/enigmail.properties (locale/en-US/enigmail.properties)
locale/en-US/enigmail/am-enigprefs.properties (locale/en-US/am-enigprefs.properties)
locale/en-US/enigmail/upgrade_080.html (locale/en-US/upgrade_080.html)
locale/en-US/enigmail/help/messenger.html (locale/en-US/help/messenger.html)
locale/en-US/enigmail/help/compose.html (locale/en-US/help/compose.html)
locale/en-US/enigmail/help/rulesEditor.html (locale/en-US/help/rulesEditor.html)
locale/en-US/enigmail/help/editRcptRule.html (locale/en-US/help/editRcptRule.html)
enigmail-skin-tbird.jar:
skin/classic/enigmail/contents.rdf (skin/classic/contents.rdf)
skin/classic/enigmail/enigmail.css (skin/classic/enigmail.css)
skin/classic/enigmail/enigmail-about.png (skin/classic/images/enigmail-about.png)
skin/classic/enigmail/enigmail-toolbar.png (skin/classic/images/enigmail-toolbar.png)
skin/classic/enigmail/enigmail-toolbar-small.png (skin/classic/images/enigmail-toolbar-small.png)
skin/classic/enigmail/enigmail-settings.png (skin/classic/images/enigmail-settings.png)
skin/classic/enigmail/enigmail-settings-small.png (skin/classic/images/enigmail-settings-small.png)
skin/classic/enigmail/enigEncInactive.png (skin/classic/images/enigEncInactive.png)
skin/classic/enigmail/enigEncNotOk.png (skin/classic/images/enigEncNotOk.png)
skin/classic/enigmail/enigEncOk.png (skin/classic/images/enigEncOk.png)
skin/classic/enigmail/enigSignInactive.png (skin/classic/images/enigSignInactive.png)
skin/classic/enigmail/enigSignNotOk.png (skin/classic/images/enigSignNotOk.png)
skin/classic/enigmail/enigSignOk.png (skin/classic/images/enigSignOk.png)
skin/classic/enigmail/enigSignUnkown.png (skin/classic/images/enigSignUnkown.png)
enigmail-skin.jar:
skin/modern/enigmail/contents.rdf (skin/contents.rdf)
skin/modern/enigmail/enigmail.css (skin/enigmail.css)
skin/modern/enigmail/enigdecrypt-act.png (skin/images/enigdecrypt-act.png)
skin/modern/enigmail/enigdecrypt-hov.png (skin/images/enigdecrypt-hov.png)
skin/modern/enigmail/enigdecrypt.png (skin/images/enigdecrypt.png)
skin/modern/enigmail/enigdecrypt-dis.png (skin/images/enigdecrypt-dis.png)
skin/modern/enigmail/enigsend.png (skin/images/enigsend.png)
skin/modern/enigmail/enigsend-act.png (skin/images/enigsend-act.png)
skin/modern/enigmail/enigsend-dis.png (skin/images/enigsend-dis.png)
skin/modern/enigmail/enigsend-hov.png (skin/images/enigsend-hov.png)
skin/modern/enigmail/enigEncInactive.png (skin/images/enigEncInactive.png)
skin/modern/enigmail/enigEncNotOk.png (skin/images/enigEncNotOk.png)
skin/modern/enigmail/enigEncOk.png (skin/images/enigEncOk.png)
skin/modern/enigmail/enigSignInactive.png (skin/images/enigSignInactive.png)
skin/modern/enigmail/enigSignNotOk.png (skin/images/enigSignNotOk.png)
skin/modern/enigmail/enigSignOk.png (skin/images/enigSignOk.png)
skin/modern/enigmail/enigSignUnkown.png (skin/images/enigSignUnkown.png)
skin/classic/enigmail/contents.rdf (skin/classic-seamonkey/contents.rdf)
skin/classic/enigmail/enigmail.css (skin/classic-seamonkey/enigmail.css)
skin/classic/enigmail/enigdecrypt-act.gif (skin/classic-seamonkey/images/enigdecrypt-act.gif)
skin/classic/enigmail/enigdecrypt-hov.gif (skin/classic-seamonkey/images/enigdecrypt-hov.gif)
skin/classic/enigmail/enigdecrypt.gif (skin/classic-seamonkey/images/enigdecrypt.gif)
skin/classic/enigmail/enigdecrypt-dis.gif (skin/classic-seamonkey/images/enigdecrypt-dis.gif)
skin/classic/enigmail/enigsend.gif (skin/classic-seamonkey/images/enigsend.gif)
skin/classic/enigmail/enigsend-act.gif (skin/classic-seamonkey/images/enigsend-act.gif)
skin/classic/enigmail/enigsend-dis.gif (skin/classic-seamonkey/images/enigsend-dis.gif)
skin/classic/enigmail/enigsend-hov.gif (skin/classic-seamonkey/images/enigsend-hov.gif)
skin/classic/enigmail/enigEncInactive.png (skin/images/enigEncInactive.png)
skin/classic/enigmail/enigEncNotOk.png (skin/images/enigEncNotOk.png)
skin/classic/enigmail/enigEncOk.png (skin/images/enigEncOk.png)
skin/classic/enigmail/enigSignInactive.png (skin/images/enigSignInactive.png)
skin/classic/enigmail/enigSignNotOk.png (skin/images/enigSignNotOk.png)
skin/classic/enigmail/enigSignOk.png (skin/images/enigSignOk.png)
skin/classic/enigmail/enigSignUnkown.png (skin/images/enigSignUnkown.png)
diff --git a/ui/locale/en-US/enigmail.dtd b/ui/locale/en-US/enigmail.dtd
index a7a61793..9034aae9 100644
--- a/ui/locale/en-US/enigmail.dtd
+++ b/ui/locale/en-US/enigmail.dtd
@@ -1,465 +1,497 @@
<!ENTITY enigmail.label "Enigmail">
<!ENTITY enigmail.keyUserId.label "Account / User ID">
<!ENTITY enigmail.keygenTitle.label "Enigmail - Generate OpenPGP Key">
<!ENTITY enigmail.useForSigning.label "Use generated key for the selected identity">
<!ENTITY enigmail.keyComment.label "Comment">
<!ENTITY enigmail.keyNoPassphrase.label "No passphrase">
<!ENTITY enigmail.keyPassphrase.label "Passphrase">
<!ENTITY enigmail.keyPassphraseRepeat.label "Passphrase (repeat)">
<!ENTITY enigmail.generateKey.label "Generate key">
<!ENTITY enigmail.generateKey.tooltip "Generates a new OpenPGP compliant key for encryption and/or signing">
<!ENTITY enigmail.cancelKey.label "Cancel">
<!ENTITY enigmail.cancelKey.tooltip "Cancel Key Generation">
<!ENTITY enigmail.keyGen.expire.label "Key expires in">
<!ENTITY enigmail.keyGen.days.label "days">
<!ENTITY enigmail.keyGen.months.label "months">
<!ENTITY enigmail.keyGen.years.label "years">
<!ENTITY enigmail.keyGen.noExpiry.label "Key does not expire">
<!ENTITY enigmail.keyGen.keySize.label "Key size">
+<!ENTITY enigmail.keyGen.console.label "Key Generation Console">
<!ENTITY enigmail.preferences.label "Enigmail Preferences">
<!ENTITY enigmail.passwordSettings.label "Passphrase settings">
<!ENTITY enigmail.userNoPassphrase.label "No passphrase for user">
<!ENTITY enigmail.defaultEncryptionOption.label "Choose default encryption options">
<!ENTITY enigmail.usePGPMimeOption.label "Choose PGP/MIME option">
<!ENTITY enigmail.mimeHashAlgorithm.label "Hash algorithm">
<!ENTITY enigmail.agentPath.label "GnuPG executable path">
<!ENTITY enigmail.agentAdditionalParam.label "Additional parameters for GnuPG">
<!ENTITY enigmail.send_plaintext_flowed.label "Allow flowed text (RFC 2646)">
<!ENTITY enigmail.mime_parts_on_demand.label "Load MIME parts on demand (IMAP folders)">
<!ENTITY enigmail.mime_parts_on_demand.tooltip "You should turn this OFF if you are receiving PGP/MIME messages on IMAP folders">
<!ENTITY enigmail.allowEmptySubject.label "Allow empty subject">
<!ENTITY enigmail.maxIdleMinutesHead.label "Remember passphrase for">
<!ENTITY enigmail.maxIdleMinutesTail.label "minutes of idle time">
<!ENTITY enigmail.resetPrefsButton.label "Reset">
<!ENTITY enigmail.prefsHelpButton.label "Help">
<!ENTITY enigmail.upgradeButton.label "Upgrade Enigmail">
<!ENTITY enigmail.uninstallButton.label "Uninstall Enigmail">
<!ENTITY enigmail.basic.label "Basic">
<!ENTITY enigmail.sending.label "Sending">
<!ENTITY enigmail.keySel.label "Key Selection">
<!ENTITY enigmail.pgpMime.label "PGP/MIME">
<!ENTITY enigmail.advancedPrefsButton.label "Advanced">
<!ENTITY enigmail.debug.label "Debugging">
<!ENTITY enigmail.basicPrefs.label "Basic Settings">
<!ENTITY enigmail.whenSending.label "When sending mail">
<!ENTITY enigmail.moreOptions.label "More options">
<!ENTITY enigmail.encryptToSelf.label "Encrypt to self">
<!ENTITY enigmail.alwaysTrustSend.label "Always trust user ID">
<!ENTITY enigmail.useDefaultComment.label "Do not add Enigmail comment in OpenPGP signature">
<!ENTITY enigmail.keyserver.label "Keyserver">
<!ENTITY enigmail.keyserverDlg.label "Select Keyserver">
<!ENTITY enigmail.keyservers.label "Keyserver(s)">
<!ENTITY enigmail.keyservers.sample "Example: sks.dnsalias.net, pgp.mit.edu, ldap://certserver.pgp.com">
<!ENTITY enigmail.searchForKey.label "Search for key">
<!ENTITY enigmail.disableSMIMEui.label "Hide SMIME buttons/menus">
<!ENTITY enigmail.doubleDashSeparator.label "Treat '--' as signature separator">
<!ENTITY enigmail.useGpgAgent.label "Use gpg-agent for passphrase handling">
<!ENTITY enigmail.hushMailSupport.label "Do not use '&lt;' and '&gt;' to specify email addresses (for Hushmail keys)">
<!ENTITY enigmail.logdirectory.label "Log directory">
<!ENTITY enigmail.testemail.label "Test email">
<!ENTITY enigmail.test.label "Test">
<!ENTITY enigmail.decryptbutton.label "Decrypt">
<!ENTITY enigmail.decryptbutton.tip "Decrypt or verify the message with OpenPGP (Enigmail)">
<!ENTITY enigmail.messengermenu.accesskey "n">
<!ENTITY enigmail.decryptverify.label "Decrypt/Verify">
<!ENTITY enigmail.importpublickey.label "Import Public Key">
<!ENTITY enigmail.savedecrypted.label "Save Decrypted Message">
<!ENTITY enigmail.autoDecrypt.label "Automatically Decrypt/Verify Messages">
<!ENTITY enigmail.clearPassphrase.label "Clear Saved Passphrase">
<!ENTITY enigmail.editRules.label "Edit Per-Recipient Rules">
<!ENTITY enigmail.prefs.label "Preferences">
<!ENTITY enigmail.advprefs.label "Advanced preferences">
<!ENTITY enigmail.debugMenu.label "Debugging Enigmail">
<!ENTITY enigmail.viewconsole.label "View Console">
<!ENTITY enigmail.viewdebuglog.label "View Logfile">
<!ENTITY enigmail.generatekey.label "Generate key">
<!ENTITY enigmail.upgrade.label "Upgrade">
<!ENTITY enigmail.help.label "Help">
<!ENTITY enigmail.about.label "About Enigmail">
<!ENTITY enigmail.reload.label "Reload IMAP Message">
<!ENTITY enigmail.browse.label "Browse...">
<!ENTITY enigmail.sendersKeyMenu.label "Sender's Key">
<!ENTITY enigmail.decryptverify.accesskey "D">
<!ENTITY enigmail.importpublickey.accesskey "I">
<!ENTITY enigmail.savedecrypted.accesskey "S">
<!ENTITY enigmail.reload.accesskey "M">
<!ENTITY enigmail.autoDecrypt.accesskey "A">
<!ENTITY enigmail.debugMenu.accesskey "G">
<!ENTITY enigmail.clearPassphrase.accesskey "l">
<!ENTITY enigmail.editRules.accesskey "R">
<!ENTITY enigmail.prefs.accesskey "P">
<!ENTITY enigmail.viewconsole.accesskey "c">
<!ENTITY enigmail.viewdebuglog.accesskey "g">
<!ENTITY enigmail.generatekey.accesskey "G">
<!ENTITY enigmail.upgrade.accesskey "U">
<!ENTITY enigmail.help.accesskey "H">
<!ENTITY enigmail.about.accesskey "b">
<!ENTITY enigmail.sendersKeyMenu.accesskey "K">
<!ENTITY enigmail.securitybutton.label "OpenPGP">
<!ENTITY enigmail.securitybutton.tip "OpenPGP (Enigmail) security settings">
<!ENTITY enigmail.signedsend.label "Sign Message">
<!ENTITY enigmail.encryptedsend.label "Encrypt Message">
<!ENTITY enigmail.disableRules.label "Ignore Per-Recipient Rules">
<!ENTITY enigmail.composeOptionsMenu.label "Default Composition Options">
<!ENTITY enigmail.pgpAccountSettings.label "Signing/Encryption Options...">
<!ENTITY enigmail.mimeOptionsMenu.label "PGP/MIME Options...">
<!ENTITY enigmail.sendOptionsMenu.label "Send Options...">
<!ENTITY enigmail.defaultKeySelOpts.label "Key Selection Options...">
<!ENTITY enigmail.sendPGPMime.label "Use PGP/MIME for This Message">
<!ENTITY enigmail.undoencryption.label "Undo Encryption">
<!ENTITY enigmail.insertkey.label "Insert Public Key">
<!ENTITY enigmail.composemenu.accesskey "n">
<!ENTITY enigmail.signedsend.accesskey "S">
<!ENTITY enigmail.signedsend.key "S">
<!ENTITY enigmail.encryptedsend.accesskey "E">
<!ENTITY enigmail.encryptedsend.key "P">
<!ENTITY enigmail.disableRules.accesskey "I">
<!ENTITY enigmail.composeOptionsMenu.accesskey "D">
<!ENTITY enigmail.sendOptionsMenu.accesskey "S">
<!ENTITY enigmail.defaultKeySelOpts.accesskey "K">
<!ENTITY enigmail.pgpAccountSettings.accesskey "E">
<!ENTITY enigmail.mimeOptionsMenu.accesskey "P">
<!ENTITY enigmail.sendPGPMime.accesskey "P">
<!ENTITY enigmail.undoencryption.accesskey "U">
<!ENTITY enigmail.insertkey.accesskey "K">
<!ENTITY enigmail.defaultEncryption.label "Encrypt messages by default">
<!ENTITY enigmail.defaultEncryptionSign.label "Sign encrypted messages by default">
<!ENTITY enigmail.defaultSignPlainMsg.label "Sign non-encrypted messages by default">
<!ENTITY enigmail.defaultEncryptionNone.label "No default encryption">
<!ENTITY enigmail.defaultNotSignedsend.label "Do not sign messages by default">
<!ENTITY enigmail.recipientsSelectionOption.label "Behavior for Selecting Keys of Recipients When Sending Messages">
<!ENTITY enigmail.askRecipientsAlways.label "Always display selection">
<!ENTITY enigmail.askRecipientsClever.label "Display selection when necessary">
<!ENTITY enigmail.askRecipientsNever.label "Never display OpenPGP key selection dialog">
<!ENTITY enigmail.normalKeySelection.label "Normal Key Selection">
<!ENTITY enigmail.perRecipientRules.label "Use Key Selection Rules">
<!ENTITY enigmail.disabled.label "Disabled">
<!ENTITY enigmail.perRecipientRulesManual.label "Define rules manually">
<!ENTITY enigmail.perRecipientRulesAlways.label "Prompt for every unknown recipient">
<!ENTITY enigmail.defineRules.label "Define Rules ...">
<!ENTITY enigmail.usePGPMimeAlways.label "Always use PGP/MIME">
<!ENTITY enigmail.usePGPMimePossible.label "Allow to use PGP/MIME">
<!ENTITY enigmail.usePGPMimeNever.label "Never use PGP/MIME">
<!ENTITY enigmail.keepSettingsForReply.label "Encrypt if replying to encrypted message">
<!ENTITY enigmail.confirmBeforeSend.label "Always confirm before sending">
<!ENTITY enigmail.wrapHtmlBeforeSend.label "Rewrap signed HTML text before sending">
<!ENTITY enigmail.defaultEncryptionSign.accesskey "E">
<!ENTITY enigmail.defaultEncryptionOnly.accesskey "c">
<!ENTITY enigmail.defaultEncryptionNone.accesskey "N">
<!ENTITY enigmail.usePGPMimeAlways.accesskey "A">
<!ENTITY enigmail.usePGPMimePossible.accesskey "U">
<!ENTITY enigmail.usePGPMimeNever.accesskey "v">
<!ENTITY enigmail.defaultSignMsg.accesskey "S">
<!ENTITY enigmail.defaultNotSignedsend.accesskey "G">
<!ENTITY enigmail.confirmBeforeSend.accesskey "A">
<!ENTITY enigmail.keygen.desc "<a class='enigmailStrong'>NOTE: Key generation may take up to several minutes to complete.</a> Do not exit the application while key generation is in progress. Actively browsing or performing disk-intensive operations during key generation will replenish the 'randomness pool' and speed-up the process. You will be alerted when key generation is completed.">
<!ENTITY enigmail.console.label "View Enigmail console">
<!ENTITY enigmail.console.tooltip "View Enigmail console">
<!ENTITY enigmail.uninstall.label "Uninstall Enigmail">
<!ENTITY enigmail.uninstall.tooltip "Uninstall Enigmail">
<!ENTITY enigmail.selectpanel.label "Select Enigmail Panel">
<!ENTITY enigmail.selectpanel.tooltip "Select Enigmail Panel">
<!ENTITY enigmail.userSelectionList.label "OpenPGP Key Selection">
<!ENTITY enigmail.usersNotFound.label "Recipients not found">
<!ENTITY enigmail.keyExpiry.label "Expiry">
<!ENTITY enigmail.keyTrust.label "Trust">
<!ENTITY enigmail.keySelection.label "Selection">
<!ENTITY enigmail.keyId.label "Key ID">
<!ENTITY enigmail.userSelPlainText.label "Send mail unencrypted">
<!ENTITY enigmail.userSelPlainTextNotSigned.label "Send mail unencrypted and not signed">
<!ENTITY enigmail.userSelPlainText.accesskey "S">
<!ENTITY enigmail.displayNoLonger.label "Do not display this dialog again if encryption is not possible">
<!ENTITY enigmail.importMissingKeys.label "Download missing keys">
<!ENTITY enigmail.importMissingKeys.accesskey "D">
<!ENTITY enigmail.importMissingKeys.tooltip "Try to import the missing keys from a key server">
<!ENTITY enigmail.importMissingKeys.accesskey "I">
<!ENTITY enigmail.refreshKeys.label "Refresh Key List">
<!ENTITY enigmail.refreshKeys.accesskey "R">
<!ENTITY enigmail.perRecipientsOption.label "Create per-recipient rule(s)">
<!ENTITY enigmail.experimental.label "Use experimental inline signing/encryption for PGP/MIME">
<!ENTITY enigmail.enigmailAttachDesc.label "This message contains attachments. How would you like encrypt/sign them?">
<!ENTITY enigmail.enigEncryptAttachNone.label "Just encrypt/sign the message text, but not the attachments">
<!ENTITY enigmail.enigEncryptAttachInline.label "Encrypt each attachment separately and send the message using inline PGP">
<!ENTITY enigmail.enigEncryptAttachPgpMime.label "Encrypt/sign the message as a whole and send it using PGP/MIME">
<!ENTITY enigmail.ctxDecryptOpen.label "Decrypt and Open">
<!ENTITY enigmail.ctxDecryptSave.label "Decrypt and Save As...">
<!ENTITY enigmail.ctxDecryptOpen.accesskey "D">
<!ENTITY enigmail.ctxDecryptSave.accesskey "C">
<!ENTITY enigmail.amPrefTitle.label "OpenPGP Options (Enigmail)">
<!ENTITY enigmail.amPrefDesc.label "Support for OpenPGP encryption and signing messages is provided by Enigmail. You need to have GnuPG (gpg) installed in order to use this feature.">
<!ENTITY enigmail.amPrefEnablePgp.label "Enable OpenPGP support (Enigmail) for this identity">
<!ENTITY enigmail.amPrefUseFromAddr.label "Use email address of this identity to identify OpenPGP key">
<!ENTITY enigmail.amPrefUseKeyId.label "Use specific OpenPGP key ID (0x1234ABCD):">
<!ENTITY enigmail.amPrefSelectKey.label "Select Key ...">
<!ENTITY enigmail.amPrefDefaultEncrypt.label "Message Composition Default Options">
<!ENTITY enigmail.encryptionDlg.label "Enigmail Encryption &amp; Signing Settings">
<!ENTITY enigmail.encDlgEncrypt.label "Encrypt Message">
<!ENTITY enigmail.encDlgEncrypt.accesskey "E">
<!ENTITY enigmail.encDlgSign.label "Sign Message">
<!ENTITY enigmail.encDlgSign.accesskey "S">
<!ENTITY enigmail.encDlgPgpMime.label "Use PGP/MIME">
<!ENTITY enigmail.encDlgPgpMime.accesskey "U">
<!ENTITY enigmail.amPrefPgpHeader.label "Send 'OpenPGP' Header">
<!ENTITY enigmail.amPrefPgpHeader.none.label "Do not send any 'OpenPGP' header">
<!ENTITY enigmail.amPrefPgpHeader.id.label "Send OpenPGP Key ID">
<!ENTITY enigmail.amPrefPgpHeader.url.label "Send URL for key retrieval:">
<!ENTITY enigmail.retrieveKey.label "Retrieving keys">
<!ENTITY enigmail.progressText.label "Progress:">
+<!ENTITY enigmail.retrieveKey.retrieveMsg.label "Retrieving key, please wait ...">
<!ENTITY enigmail.editPgpSecurity.label "OpenPGP Security ...">
<!ENTITY enigmail.editPgpSecurity.accesskey "O">
<!ENTITY enigmail.openPgpSecurity.label "OpenPGP Security">
<!ENTITY enigmail.pgpSecurityInfo.label "OpenPGP Security Info ...">
<!ENTITY enigmail.copySecurityInfo.label "Copy OpenPGP Security Info">
<!ENTITY enigmail.showPhoto.label "View OpenPGP Photo ID">
<!ENTITY enigmail.signSenderKey.label "Sign Key ...">
<!ENTITY enigmail.trustSenderKey.label "Set Key Trust ...">
<!ENTITY enigmail.signSenderKeyPopup.label "Sign Sender's Key ...">
<!ENTITY enigmail.trustSenderKeyPopup.label "Set Sender's Key Trust ...">
<!ENTITY enigmail.smimeSecurityInfo.label "S/MIME Security Info ...">
<!ENTITY enigmail.createRuleFromAddr.label "Create OpenPGP Rule from Address...">
<!ENTITY enigmail.keyManWindow.label "OpenPGP Key Management">
<!ENTITY enigmail.keyManWindow.accesskey "O">
<!ENTITY enigmail.singleRcptSettings.label "Enigmail - Recipient Settings">
<!ENTITY enigmail.keysToUse.label "Key(s) to use:">
<!ENTITY enigmail.selKeysButton.label "Select Key(s)...">
<!ENTITY enigmail.action.label "Action">
<!ENTITY enigmail.nextRule.label "Continue with next rule for the matching address">
<!ENTITY enigmail.nextAddress.label "Do not check further rules for the matching address">
<!ENTITY enigmail.useKeys.label "Use the following OpenPGP keys:">
<!ENTITY enigmail.selKeysButton.accesskey "S">
<!ENTITY enigmail.setDefaultsFor.label "Defaults for ...">
<!ENTITY enigmail.encryption.label "Encryption">
<!ENTITY enigmail.signing.label "Signing">
<!ENTITY enigmail.never.label "Never">
<!ENTITY enigmail.always.label "Always">
<!ENTITY enigmail.maybe.label "Yes, if selected in Message Composition">
<!ENTITY enigmail.singleRcptSettings.desc "(Note: in case of conflicts, 'Never' overrules 'Always')">
<!ENTITY enigmail.ruleEmail.label "Set OpenPGP Rules for">
<!ENTITY enigmail.ruleEmail.tooltip "Only fill in email addresses, do NOT set the names of the recipients\nE.g. 'Some Name &lt;some.name@address.net&gt;' is invalid">
<!ENTITY enigmail.sepratationDesc.label "(Separate several email addresses with spaces)">
<!ENTITY enigmail.matchDescStart.label "Apply rule if recipient">
<!ENTITY enigmail.matchDescEnd.label "one of the above addresses">
<!ENTITY enigmail.matchExact.label "Is exactly">
<!ENTITY enigmail.matchContains.label "Contains">
<!ENTITY enigmail.matchBegin.label "Starts with">
<!ENTITY enigmail.matchEnd.label "Ends with">
<!ENTITY enigmail.not.label "Not">
<!ENTITY enigmail.rulesEditor.label "Enigmail - Per-Recipient Rules Editor">
<!ENTITY enigmail.email.label "Email">
<!ENTITY enigmail.pgpKeys.label "OpenPGP Key(s)">
<!ENTITY enigmail.sign.label "Sign">
<!ENTITY enigmail.encrypt.label "Encrypt">
<!ENTITY enigmail.edit.label "Modify">
<!ENTITY enigmail.edit.accesskey "M">
<!ENTITY enigmail.add.label "Add">
<!ENTITY enigmail.add.accesskey "A">
<!ENTITY enigmail.delete.label "Delete">
<!ENTITY enigmail.delete.accesskey "E">
<!ENTITY enigmail.moveUp.label "Move Up">
<!ENTITY enigmail.moveUp.accesskey "U">
<!ENTITY enigmail.moveDown.label "Move Down">
<!ENTITY enigmail.moveDown.accesskey "D">
<!ENTITY enigmail.searchRule.label "View rules with email addresses containing:">
<!ENTITY enigmail.clearSearch.label "Clear">
<!ENTITY enigmail.clearSearch.accesskey "C">
<!ENTITY enigmail.searchKeyDlg.label "Download OpenPGP Keys">
<!ENTITY enigmail.searchKeyDlgCapt.label "Found Keys - Select to Import">
<!ENTITY enigmail.created.label "Created">
<!ENTITY enigmail.valid.label "Valid">
<!ENTITY enigmail.progress.label "Progress">
<!ENTITY enigmail.sKeyDlg.title "Enigmail - Sign Key">
<!ENTITY enigmail.sKeyDlg.signKey.label "Key to be signed:">
<!ENTITY enigmail.sKeyDlg.fingerprint.label "Fingerprint:">
<!ENTITY enigmail.sKeyDlg.signWithKey.label "Key for signing:">
<!ENTITY enigmail.sKeyDlg.checked.label "How carefully have you verified that the key you are about to sign actually belongs to the person(s) named above?">
<!ENTITY enigmail.sKeyDlg.noAnswer.label "I will not answer">
<!ENTITY enigmail.sKeyDlg.notChecked.label "I have not checked at all">
<!ENTITY enigmail.sKeyDlg.casualCheck.label "I have done casual checking">
<!ENTITY enigmail.sKeyDlg.carefulCheck.label "I have done very careful checking">
<!ENTITY enigmail.sKeyDlg.createLocal.label "Local signature (cannot be exported)">
<!ENTITY enigmail.sKeyDlg.alreadySigned.label "Note: some keys already signed with the key selected for signing!">
<!ENTITY enigmail.addUidDlg.title "Enigmail - Add User ID">
<!ENTITY enigmail.addUidDlg.name.label "Name">
<!ENTITY enigmail.addUidDlg.email.label "Email">
<!ENTITY enigmail.addUidDlg.comment.label "Comment (optional)">
<!ENTITY enigmail.keyTrust.title "Enigmail - Set Key Trust">
<!ENTITY enigmail.keyTrust.trustKey.label "Key To Trust:">
<!ENTITY enigmail.keyTrust.trustLevel.label "How much do you trust the key?">
<!ENTITY enigmail.keyTrust.dontKnow.label "I don't know">
<!ENTITY enigmail.keyTrust.noTrust.label "I do NOT trust">
<!ENTITY enigmail.keyTrust.marginalTrust.label "I trust marginally">
<!ENTITY enigmail.keyTrust.fullTrust.label "I trust fully">
<!ENTITY enigmail.keyTrust.ultimateTrust.label "I trust ultimately">
<!ENTITY enigmail.keyMan.title "OpenPGP Key Management">
<!ENTITY enigmail.keyMan.close.label "Close Window">
<!ENTITY enigmail.keyMan.generate.label "New Key Pair">
<!ENTITY enigmail.keyMan.sign.label "Sign Key">
<!ENTITY enigmail.keyMan.setTrust.label "Set Key Trust">
<!ENTITY enigmail.keyMan.genRevoke.label "Revocation Certificate">
<!ENTITY enigmail.keyMan.ctxGenRevoke.label "Generate &amp; Save Revocation Certificate">
<!ENTITY enigmail.keyMan.fileMenu.label "File">
<!ENTITY enigmail.keyMan.editMenu.label "Edit">
<!ENTITY enigmail.keyMan.viewMenu.label "View">
<!ENTITY enigmail.keyMan.keyserverMenu.label "Keyserver">
<!ENTITY enigmail.keyMan.generateMenu.label "Generate">
+<!ENTITY enigmail.keyMan.cardMenu.label "SmartCard">
<!ENTITY enigmail.keyMan.fileMenu.accesskey "F">
<!ENTITY enigmail.keyMan.editMenu.accesskey "E">
<!ENTITY enigmail.keyMan.viewMenu.accesskey "V">
<!ENTITY enigmail.keyMan.keyserverMenu.accesskey "K">
<!ENTITY enigmail.keyMan.generateMenu.accesskey "G">
+<!ENTITY enigmail.keyMan.cardMenu.accesskey "S">
<!ENTITY enigmail.keyMan.importFromFile.label "Import Keys from File">
<!ENTITY enigmail.keyMan.importFromServer.label "Search for Keys">
<!ENTITY enigmail.keyMan.importFromClipbrd.label "Import Keys from Clipboard">
<!ENTITY enigmail.keyMan.exportToFile.label "Export Keys to File">
<!ENTITY enigmail.keyMan.uploadToServer.label "Upload Public Keys">
<!ENTITY enigmail.keyMan.copyToClipbrd.label "Copy Public Keys to Clipboard">
<!ENTITY enigmail.keyMan.ctxExportToFile.label "Export Keys to File">
<!ENTITY enigmail.keyMan.ctxUploadToServer.label "Upload Public Keys to Keyserver">
<!ENTITY enigmail.keyMan.ctxCopyToClipbrd.label "Copy Public Keys to Clipboard">
<!ENTITY enigmail.keyMan.refreshKey.label "Refresh Public Keys">
<!ENTITY enigmail.keyMan.ctxRefreshKey.label "Refresh Public Keys From Keyserver">
<!ENTITY enigmail.keyMan.reload.label "Reload Key Cache">
<!ENTITY enigmail.keyMan.addUid.label "Add User ID">
<!ENTITY enigmail.keyMan.manageUid.label "Manage User IDs">
<!ENTITY enigmail.keyMan.delKey.label "Delete Key">
<!ENTITY enigmail.keyMan.revokeKey.label "Revoke Key">
<!ENTITY enigmail.keyMan.keyProps.label "Key Properties">
<!ENTITY enigmail.keyMan.viewPhoto.label "Photo ID">
<!ENTITY enigmail.keyMan.ctxViewPhoto.label "View Photo ID">
<!ENTITY enigmail.keyMan.viewSig.label "Signatures">
<!ENTITY enigmail.keyMan.ctxViewSig.label "View Signatures">
<!ENTITY enigmail.keyMan.keyType.label "Type">
<!ENTITY enigmail.keyMan.calcTrust.label "Calculated Trust">
<!ENTITY enigmail.keyMan.ownerTrust.label "Owner Trust">
<!ENTITY enigmail.keyMan.stopTransfer.label "Stop transfer">
<!ENTITY enigmail.keyMan.fingerprint.label "Fingerprint">
+<!ENTITY enigmail.keyMan.cardData.label "Card Details">
+<!ENTITY enigmail.keyMan.genCardKey.label "Generate Key">
<!ENTITY enigmail.keyMan.filter.label "Filter for user ID's or key ID's containing:">
<!ENTITY enigmail.keyMan.clearFilter.label "Clear">
<!ENTITY enigmail.keyMan.clearFilter.accesskey "C">
<!ENTITY enigmail.keyMan.window.accesskey "W">
<!ENTITY enigmail.keyMan.close.accesskey "C">
<!ENTITY enigmail.keyMan.generate.accesskey "K">
<!ENTITY enigmail.keyMan.sign.accesskey "S">
<!ENTITY enigmail.keyMan.setTrust.accesskey "T">
<!ENTITY enigmail.keyMan.genRevoke.accesskey "R">
<!ENTITY enigmail.keyMan.delKey.accesskey "D">
<!ENTITY enigmail.keyMan.revokeKey.accesskey "R">
<!ENTITY enigmail.keyMan.importFromFile.accesskey "I">
<!ENTITY enigmail.keyMan.exportToFile.accesskey "E">
<!ENTITY enigmail.keyMan.importFromServer.accesskey "S">
<!ENTITY enigmail.keyMan.uploadToServer.accesskey "U">
<!ENTITY enigmail.keyMan.reload.accesskey "R">
<!ENTITY enigmail.keyMan.addUid.accesskey "A">
<!ENTITY enigmail.keyMan.manageUid.accesskey "M">
<!ENTITY enigmail.keyMan.viewSig.accesskey "S">
<!ENTITY enigmail.keyMan.showPhoto.accesskey "P">
<!ENTITY enigmail.keyMan.closeWin.key "W">
<!ENTITY enigmail.keyMan.importMenu.accesskey "I">
<!ENTITY enigmail.keyMan.exportMenu.accesskey "X">
<!ENTITY enigmail.keyMan.importFromClipbrd.accesskey "I">
<!ENTITY enigmail.keyMan.copyToClipbrd.accesskey "C">
<!ENTITY enigmail.keyMan.keyDetails.accesskey "K">
<!ENTITY enigmail.keyMan.enableKey.accesskey "B">
<!ENTITY enigmail.keyMan.refreshKey.accesskey "R">
+<!ENTITY enigmail.keyMan.cardData.accesskey "C">
+<!ENTITY enigmail.keyMan.genCardKey.accesskey "G">
<!ENTITY enigmail.viewKeySigDlg.title "Signature List">
<!ENTITY enigmail.viewKeySigDlg.sigForKey.label "Signatures for Key:">
<!ENTITY enigmail.viewKeySigDlg.sigType.label "Sig. Type">
<!ENTITY enigmail.manageUidDlg.title "Change Primary User ID">
<!ENTITY enigmail.manageUidDlg.affectedKey.label "Key to change:">
<!ENTITY enigmail.manageUidDlg.availableUid.label "Available user IDs:">
<!ENTITY enigmail.manageUidDlg.addUid.label "Add">
<!ENTITY enigmail.manageUidDlg.deleteUid.label "Delete">
<!ENTITY enigmail.manageUidDlg.revokeUid.label "Revoke">
<!ENTITY enigmail.manageUidDlg.setPrimary.label "Set primary">
<!ENTITY enigmail.keyDetails.title "Key Properties">
<!ENTITY enigmail.keyDetails.userId.label "Primary User ID">
<!ENTITY enigmail.keyDetails.keyId.label "Key ID">
<!ENTITY enigmail.keyDetails.ID.label "ID">
<!ENTITY enigmail.keyDetails.keyType.label "Type">
<!ENTITY enigmail.keyDetails.subType.label "Subkey">
<!ENTITY enigmail.keyDetails.algorithm.label "Algorithm">
<!ENTITY enigmail.keyDetails.size.label "Size">
<!ENTITY enigmail.keyDetails.created.label "Created">
<!ENTITY enigmail.keyDetails.expiry.label "Expiry">
<!ENTITY enigmail.keyDetails.calcTrust.label "Calculated trust">
<!ENTITY enigmail.keyDetails.ownerTrust.label "Owner trust">
<!ENTITY enigmail.keyDetails.fingerprint.label "Fingerprint">
+<!ENTITY enigmail.cardDetails.title "OpenPGP SmartCard Details">
+<!ENTITY enigmail.cardDetails.vendor.label "Manufacturer">
+<!ENTITY enigmail.cardDetails.serial.label "Serial Number">
+<!ENTITY enigmail.cardDetails.name.label "Firstname, Name">
+<!ENTITY enigmail.cardDetails.lang.label "Language">
+<!ENTITY enigmail.cardDetails.sex.label "Sex">
+<!ENTITY enigmail.cardDetails.url.label "URL of public key">
+<!ENTITY enigmail.cardDetails.login.label "Login data">
+<!ENTITY enigmail.cardDetails.forcepin.label "Force signature PIN">
+<!ENTITY enigmail.cardDetails.maxpinlen.label "Max. PIN length">
+<!ENTITY enigmail.cardDetails.pinretry.label "PIN retry counter">
+<!ENTITY enigmail.cardDetails.sigcount.label "Signature counter">
+<!ENTITY enigmail.cardDetails.sigKey.label "Signature key">
+<!ENTITY enigmail.cardDetails.keyCreated.label "Created">
+<!ENTITY enigmail.cardDetails.encKey.label "Encryption key">
+<!ENTITY enigmail.cardDetails.authKey.label "Authentication key">
+<!ENTITY enigmail.cardDetails.male.label "Male">
+<!ENTITY enigmail.cardDetails.female.label "Female">
+<!ENTITY enigmail.cardDetails.yes.label "Yes">
+<!ENTITY enigmail.cardDetails.no.label "No">
+
+<!ENTITY enigmail.genCardKey.title "Generate OpenPGP Key">
+<!ENTITY enigmail.genCardKey.backupKey.label "Save backup of key outside the card">
+<!ENTITY enigmail.genCardKey.desc "<a class='enigmailStrong'>NOTE: Key generation may take up to several minutes to complete.</a> Do not exit the application while key generation is in progress.You will be alerted when key generation is completed.">
diff --git a/ui/locale/en-US/enigmail.properties b/ui/locale/en-US/enigmail.properties
index 49464028..966c6b43 100644
--- a/ui/locale/en-US/enigmail.properties
+++ b/ui/locale/en-US/enigmail.properties
@@ -1,373 +1,384 @@
Enigmail=Enigmail
# Strings used within enigmailCommon.js
enigAlert=Enigmail Alert
enigConfirm=Enigmail Confirm
enigError=Enigmail Error
enigPrompt=Enigmail Prompt
dlgYes=Yes
dlgNo=No
dlgNever=Do not ask me again
dlgKeepSetting=Remember my answer and do not ask me again
dlgNoPrompt=Do not show me this dialog again
configNow=Do you wish to configure Enigmail for version %S now?
configEnigmail=Configure Enigmail?
repeatPrefix=\n\nThis alert will repeat %S
repeatSuffixSingular=more time.
repeatSuffixPlural=more times.
noRepeat=\n\nThis alert will not repeat until you upgrade Enigmail.
noLogDir=Please set debug preference 'Log directory' to create a log file
noLogFile=Log file has not been created yet!
restartForLog=Please restart the application to create log file
pgpNotSupported=You seem to be using Enigmail together with PGP 6.x\n\nUnfortunately, PGP 6.x has a number of issues that prevent Enigmail from working correctly. Therefore, Enigmail does not support PGP 6.x anymore; please switch to GnuPG (GPG) instead.\n\nIf you need help on switching to GnuPG, check the Help section of the Enigmail homepage.
avoidInitErr=To avoid this alert, either fix the problem or uninstall Enigmail using the Enigmail->Preferences menu
passphraseCleared=The passphrase has been cleared.
keyGeneration=Enigmail Key Generation
noPhotoAvailable=No Photo available
# Strings in enigmailAbout.js
usingVersion=Running Enigmail version %S
versionWarning=Warning: Incompatible Enigmime version %S
enigmimeWarning=Warning: Enigmime module not available
usingAgent=Using %S executable %S to encrypt and decrypt
agentError=ERROR: Failed to access Enigmime service!
# Strings in enigmailKeygen.js
accessError=Error in accessing Enigmail service
onlyGPG=Key generation only works with GnuPG (not with PGP)!
genComplete=Key generation completed! Identity <%S> will be used for signing.\n\nWe highly recommend to create a revocation certificate for your key. This certificate can be used to invalidate your key, e.g. in case your secret key gets lost or compromised. Do you want to create such a revocation certificate now?
genCompleteNoSign=Key generation completed!
genGoing=Key generation already in progress!
passNoMatch=Passphrase entries do not match; please re-enter
passCheckBox=Please check box if specifying no passphrase for key
passUserName=Please specify user name for this identity
passCharProblem=You are using special characters in your passphrase. Unfortunately, this can cause troubles for other applications. Please choose a passphrase consisting of any of these characters: a-z A-Z 0-9 /.;:-,!?(){}[]%*
keyConfirm=Generate public and private keys for '%S'?
keyAbort=Abort key generation?
expiryTooLong=You cannot create a key that expires in more than 100 years.
+expiryTooShort=Your key must be valid for at least one day.
# Strings in enigmailMessengerOverlay.js
keyImport=\n\nClick Yes button to import public key %S from keyserver.
keyImportError=Unable to receive public key\n\n
securityInfo=OpenPGP Security Info\n\n
enigHeader=Enigmail:
enigNote=Note from Enigmail: Attachments to this message have not been signed or encrypted.
enigContentNote=Enigmail: *Attachments to this message have not been signed or encrypted*\r\n\r\n
possiblyPgpMime=Possibly PGP/MIME encrypted or signed message; click Decrypt button to verifiy
noDecrypted=No decrypted message to save!\nUse Save command from File menu
noMessage=No message to save!
useButton=Please click Decrypt button to decrypt message
saveHeader=Enigmail: Save decrypted message
saveAttachmentHeader=Enigmail: Save decrypted attachment
noTempDir=Could not find a temporary directory to write to\nPlease set the TEMP environment variable
attachmentPgpKey=The attachment '%S' you are opening appears to be an OpenPGP key file.\n\nClick Yes to import the keys contained or No to view the file contents in a browser window
beginPgpPart=********* *BEGIN ENCRYPTED or SIGNED PART* *********
endPgpPart=********** *END ENCRYPTED or SIGNED PART* **********
notePartEncrypted=Enigmail: *Parts of the message have NOT been signed or encrypted*
decryptOkNoSig=Warning\n\nDecryption was successful, but the signature could not be verified correctly
contAnyway=Do you want to continue anyway?
noPgpMessage=Message not OpenPGP signed or encrypted
# Strings in enigmailMsgComposeOverlay.js
keysToExport=Select OpenPGP Keys to Insert
keysToUse=Select OpenPGP Key(s) to use for %S
pubKey=Public key for %S\n
windowLocked=Compose window is locked; send cancelled
sendUnencrypted=Failed to initialize Enigmail.\nSend unencrypted message?
composeSpecifyEmail=Please specify your primary email address, which will be used to choose the signing key for outgoing messages.\n If you leave it blank, the FROM address of the message will be used to choose the signing key.
sendingBCC=This message has BCC (blind copy) recipients. If this message is encrypted, all recipients will be able to determine the identity of the BCC recipients by examining the encryption key list, leading to loss of confidentiality. \n\nClick Yes to proceed with encryption anyway, or No to abort the send operation.
sendingNews=Encrypted send operation aborted.\n\nThis message cannot be encrypted because there are newsgroup recipients. Please re-send the message without encryption.
noPGPMIME=PGP/MIME not available!\nUse inline PGP for signing/encryption?
hasHTML=HTML mail warning:\nThis message may contain HTML, which could cause signing/encryption to fail. To avoid this in the future, you should press the SHIFT key when clicking on the Compose/Reply button to send signed mail.\nIf you sign mail by default, you should uncheck the 'Compose Messages in HTML' preference box to permanently disable HTML mail for this mail account.
strippingHTML=Message contains HTML formatting information that will be lost when converting to plain text for signing/encryption. Do you wish to proceed?
attachWarning=Attachments to this message are not local, they cannot be encrypted. In order to encrypt the attachments, store them as local files first and attach these files. Do you wish to proceed anyway?
savingMessage=Do you want to encrypt the message before saving?
quotedPrintableWarn=You have enabled 'quoted-printable' encoding for sending messages. This may result in incorrect decryption and/or verification of your message.\n Do you wish to turn off sending 'quoted-printable' messages now?
minimalLineWrapping=You have set line wrapping to %S characters. For correct encryption and/or signing, this value needs to be at least 68.\nDo you wish to change line wrapping to 68 characters now?
warning=Warning
signIconClicked=You have manually modified signing. Therefore, while you are composing this message, (de)activating signing does not depend anymore on (de)activating encryption.
sendAborted=Send operation aborted.\n\n
statPGPMIME=PGP/MIME
statSigned=SIGNED
statEncrypted=ENCRYPTED
statPlain=PLAINTEXT
offlineSave=Save %S message to %S in Unsent Messages folder?
onlineSend=Send %S message to %S?
offlineNote=You are currently offline. Do you wish to save the message in the Unsent Messages folder?
encryptKeysNote=Note: the message is encrypted with the following User ID's / Keys: %S
signFailed=Error in Enigmail; Encryption/signing failed; send unencrypted email?
acctNotConfigured=You did not configure this identity for using OpenPGP security (Enigmail).\nSend unencrypted message?
recipientsSelectionHdr=Select Recipients for Encryption
configureNow=You did not yet configure OpenPGP security (Enigmail) for the selected identity. Do you want to do this now?
signYes=Message will be signed
signNo=Message will not be signed
encryptYes=Message will be encrypted
encryptNo=Message will not be encrypted
rulesConflict=Conflicting per-recipient rules detected\n%S\n\nSend message with these settings?
# Strings in enigmailMsgHdrViewOverlay.js
keyNeeded=Public key %S needed to verify signature
clickDecrypt=; click Decrypt button
clickDecryptRetry=; click Decrypt button to retry
clickPen=; click Pen icon
clickPenDetails=; click Pen icon for details
clickQueryPenDetails=; click Pen icon for details
clickKey=; click Key icon
clickQueryKeyDetails=; click Key icon for details
clickKeyDetails=; click Key icon for details
clickPenKeyDetails=; click Pen or Key icon for details
msgPart=Part of the message %S
msgSigned=signed
msgEncrypted=encrypted
msgSignedAndEnc=signed and encrypted
reloadImapMessage=Reload complete IMAP message to decrypt/verify?
reloadImapError=Error - IMAP message too large to decrypt/verify
unverifiedSig=Unverified signature
incompleteDecrypt=Decryption incomplete
failedSig=Error - signature verification failed
needKey=Error - secret key needed to decrypt message
failedDecrypt=Error - decryption failed
badPhrase=Error - bad passphrase
failedDecryptVerify=Error - decryption/verification failed
viewInfo=; View > Message security info for details
decryptedMsg=Decrypted message
# Strings in enigmailNavigatorOverlay.js
navEncryptError=Error in encrypting and/or signing message.\n
navDecryptError=Error in decrypting message.\n
# Strings in pref-enigmail.js
uninstallConfirm=Do you wish to delete all Enigmail-related files in the Mozilla component and chrome directories?
uninstallFailOverlay=Failed to uninstall Enigmail communicator overlay RDF; not deleting chrome jar file
uninstallFailDelete=Error in deleting file
uninstallFail=Failed to uninstall Enigmail
uninstallSuccess=Uninstalled Enigmail
testNoSvc=EnigTest: Failed to access Enigmail service
testNoEmail=EnigTest: Please specify mail address for testing
testSucceeded=Enigmail is working properly. For details, check the Console available from the Enigmail menu
oldGpgVersion=Enigmail initialization failed.\n\nYou are using GnuPG version %S, which is not up to date anymore. Enigmail requires GnuPG version 1.2 or newer; please upgrade your GnuPG installation, or Enigmail will not work.
jslibNeeded=This operation requires the "Jslib" package, version %S or newer. You can get it from http://jslib.mozdev.org/installation.html.
locateGpg=Locate GnuPG program
invalidGpgPath=GnuPG cannot be executed with the path provided. Enigmail is therefore deactivated until you change the path to GnuPG again or until you restart the application.
# Strings used in components/enigmail.js
# (said file also re-uses some strings from above)
enterPass=Please type in your OpenPGP passphrase
+repeatPass=Please repeat your OpenPGP passphrase
+enterPassNoMatch=The passwords did not match!\nPlease type in your OpenPGP passphrase
rememberPass=Remember for %S idle minutes
+enterAdminPin=Please type in the ADMIN PIN of your Smartcard
+enterCardPin=Please type your Smartcard PIN
notInit=Error - Enigmail service not yet initialized
badCommand=Error - encryption command failed
cmdLine=command line and output:
notRequired=Error - no encryption required
notComplete=Error - key generation not yet completed
invalidEmail=Error - invalid email address(es)
noPassphrase=Error - no passphrase supplied
noPGPblock=Error - No valid armored OpenPGP data block found
unverifiedReply=Indented message part (reply) was probably modified
decryptToImport=Click Decrypt button to import public key block in message
sigMismatch=Error - Signature mismatch
cantImport=Error in importing public key\n\n
messageSizeError=Message too large to be verified
gpgNotFound=Unable to locate GnuPG program '%S'.\nMake sure you have set the GnuPG executable path correctly in the Enigmail Preferences
gpgNotInPath=Unable to locate GnuPG executable in the PATH.\nMake sure you have set the GnuPG executable path correctly in the Enigmail Preferences
enigmimeNotAvail=Enigmime Service not available
prefUntrusted=UNTRUSTED
prefRevoked=REVOKED KEY
prefExpiredKey=EXPIRED KEY
prefExpired=EXPIRED
prefGood=Good signature from %S
prefBad=BAD signature from %S
failFingerprint=Error - fingerprint extraction command failed
failMultiple=Error - Multiple keys found for %S
failNoKey=Error - No key found for %S
failOnlyGPG=Error - Only GnuPG can receive keys from keyserver
failCancel=Error - Key receive cancelled by user
failNoServer=Error - No keyserver specified to receive key from
failNoID=Error - No key ID specified to receive key for
failKeyExtract=Error - key extraction command failed
notFirstBlock=Error - First OpenPGP block not public key block
importKeyConfirm=Import public key(s) embedded in message?
failKeyImport=Error - key importing failed
fileWriteFailed=Failed to write to file %S
successKeyImport=The key(s) were successfully imported
importKey=Import public key %S from keyserver:
uploadKey=Send public key %S to keyserver:
keyId=Key ID
keyAndSigDate=Key ID: 0x%S / Signed on: %S
keyFpr=Key fingerprint: %S
photoFor=OpenPGP Photo ID for %S
noEmailProvided=You did not provide an email address!
invalidRecp=Invalid recipients: %S
# Strings used in enigmailUserSelection.js
selKeyExpired=expired %S
createdHeader=Created
keyInvalid=INVALID KEY
keyDisabled=DISABLED KEY
atLeastOneKey=No key selected! You have to select at least one key for accepting this dialog
# Strings used in enigmailAttachmentDialog.js
pgpMimeNote=NOTE: PGP/MIME is only supported by a limited number of mail clients! On Windows only Enigmail, Sylpheed, Pegasus and Mulberry are known to support this standard; on Linux/UNIX and Mac OS X most popular mail clients support it. If you are unsure, select the %S option.
first=first
second=second
# Strings used in am-enigprefs.js
encryptKeyHeader=Select OpenPGP Key for Encryption
identityName=Identity: %S
# Strings used in enigmailSingleRcptSettings.js
noEncryption=You have activated encryption, but you did not select a key. In order to encrypt mails sent to %S, you need to specify one or several valid key(s) from your keylist. Do you want to disable encryption for %S?
noKeyToUse=(none - no encryption)
noEmptyRule=The Rule may not be empty! Please set an email address in the Rule field.
invalidAddress=The email address(es) you have entered are not valid. You should not set the names of the recipients, just the email addresses. E.g.:\nInvalid: Some Name <some.name@address.net>\nValid: some.name@address.net
noCurlyBrackets=The curly brackets {} have a special meaning and should not be used in the email addresses. If you want to modify the matching behavior for this rule, use the 'Apply rule if recipient ...' option.\nMore information is available from the Help button.
# Strings used in enigmailRulesEditor.js
never=Never
always=Always
possible=Possible
deleteRule=Really delete the selected rule?
nextRcpt=(Next recipient)
negateRule=Not
# Strings used in enigmailSearchKey.js
needOnline=The function you have selected is not available in offline mode. Please go online and try again.
protocolNotSupported=The protocol '%S://' that you have selected is not supported for downloading OpenPGP keys.
gpgkeysDisabled=It might help to enable the option 'extensions.enigmail.useGpgKeysTool'.
noKeyserverConn=Could not connect to keyserver at %S.
keyDownloadFailed=Failed to download key from keyserver. Status message is:\n%S
internalError=An internal error occurred. The keys could not be downloaded or imported.
noKeyFound=I am sorry, could not find any key that would match the email addresses specified.
# gpgkeys_%S is one of the gpg command line tools gpgkeys_hkp, gpgkeys_ldap, etc.
gpgKeysFailed=Failed to search or download key from keyserver: gpgkeys_%S could not be executed.
# Strings in enigmailEditKeyTrustDlg.xul
setKeyTrustFailed=Setting key trust failed
setKeyTrustOK=Key trust successfully set
# Strings in enigmailSignKeyDlg.xul
signKeyFailed=Key signing failed
signKeyOK=Key successfully signed
undefinedError=An undefined error occurred.
keyAlreadySigned=The key is already signed, you cannot sign it twice.
noSignKeyExpired=The key is expired. You can only sign keys that are still valid.
# Strings in enigmailKeyManager.js
keyValid.unknown=unknown
keyValid.invalid=invalid
keyValid.disabled=disabled
keyValid.revoked=revoked
keyValid.expired=expired
keyValid.noSubkey=no valid subkey
keyTrust.untrusted=untrusted
keyTrust.marginal=marginal
keyTrust.full=trusted
keyTrust.ultimate=ultimate
keyType.public=pub
keyType.publicAndSec=pub/sec
keyMan.enableKey=Enable Key
keyMan.disableKey=Disable Key
userAtt.photo=User attribute (JPEG image)
asciiArmorFile=ASCII Armored Files (*.asc)
gnupgFile=GnuPG Files
saveRevokeCertAs=Create & Save Revocation Certificate
revokeCertOK=The revocation certificate has been successfully created. You can use it to invalidate your public key, e.g. in case you would lose your secret key.\n\nPlease transfer it to a medium which can be stored away safely such as a CD or Floppy Disk. If somebody gains access to this certificate they can use it to render your key unusable.
revokeCertFailed=The revocation certificate could not be created.
addUidOK=User ID added successfully
addUidFailed=Adding the User ID failed
noKeySelected=You should select at least on key in order to perform the selected operation
exportToFile=Export Public Key To File
exportSecretKey=Do you want to include the secret key in the saved OpenPGP key file?
saveKeysOK=The keys were successfully saved
saveKeysFailed=Saving the keys failed
importKeysFailed=Importing the keys failed
enableKeyFailed=Enabling/disabling the key failed
specificPubKeyFilename=%S (0x%S) pub
specificPubSecKeyFilename=%S (0x%S) pub-sec
defaultPubKeyFilename=Exported-public-keys
defaultPubSecKeyFilename=Exported-public-and-secret-keys
noSecretKeys=No secret keys found.\n\nDo you want to generate your own key now?
sendKeysOk=Key(s) sent successfully
sendKeysFailed=Sending of keys failed
receiveKeysOk=Key(s) updated successfully
receiveKeysFailed=Downloading of keys failed
importFromClip=Do you want to import some key(s) from clipboard?
copyToClipbrdFailed=Could not copy the selected key(s) to the clipboard.
copyToClipbrdOK=Key(s) copied to clipboard
deleteSecretKey=WARNING: You are about to delete a secret key!\nIf you delete your secret key, you will no longer be able to decrypt any messages encrypted for that key.\n\nDo you really want to delete BOTH, the secret key and the public key\n'%S'?
deletePubKey=Do you want to delete the public key\n'%S'?
deleteKeyOk=Key successfully deleted
deleteKeyFailed=The key could not be deleted.
revokeKeyAsk=This function creates and imports a revocation certificate. Do you really want to revoke the key %S?
revokeKeyOk=The key has been revoked. If your key is available on a key server, it is recommended to re-upload it, so that others can see the revocation.
revokeKeyFailed=The key could not be revoked.
uploadingKey=Uploading key(s)...
downloadingKey=Downloading key(s)...
keyserverAccessAborted=aborted
# Strings in enigmailViewKeySigDlg.xul
keySignatureLocal=Local
keySignatureExportable=Exportable
keySignatureNoKey=No key
userIdNotFound=(User ID not found)
# Strings in enigmailManageUidDlg.xul
changePrimUidFailed=Changing the primary User ID failed
changePrimUidOK=The primary user ID was changed successfully
deleteUidFailed=Deleting the user ID %S failed
deleteUidOK=User ID %S was deleted successfully
revokeUidFailed=Revoking the user ID %S failed
revokeUidOK=User ID %S was revoked successfully. If your key is available on a key server, it is recommended to re-upload it, so that others can see the revocation.
revokeUidQuestion=Do you really want to revoke the user ID %S?
deleteUidQuestion=Do you really want to delete the user ID %S?\n\nPlease note: if you have submitted your public key to a key server, deleting a user ID will not change anything. In this case you should use 'Revoke user ID'.
# Strings in enigmailKeyDetailsDlg.xul
keyTypePublic=public key
keyTypeSubkey=subkey
keyTypePair=key pair
keyExpiryNever=never
keyAlgorithm_1=RSA
keyAlgorithm_2=RSA
keyAlgorithm_3=RSA
keyAlgorithm_16=ELG
keyAlgorithm_17=DSA
keyAlgorithm_20=ELG
+
+# Strings in enigmailGenCardKey.xul
+keygen.started=Please wait while the key is being generated ....
+keygen.completed=Key Generated. The new Key ID is: 0x%S
+keygen.keyBackup=The key is backed up as %S
+keygen.passRequired=Please specify a passphrase if you want to create a backup copy of your key outside your SmartCard.
diff --git a/uuid_enig.txt b/uuid_enig.txt
index bd624182..83b1e2cf 100644
--- a/uuid_enig.txt
+++ b/uuid_enig.txt
@@ -1,48 +1,49 @@
uuid_enig.txt: UUIDs used by Enigmail
--------------------------------------
5 Apr 2001
A block of 256 UUIDs was generated by running uuidgen,
ranging from
/* 847b3a00-7ab1-11d4-8f02-006008948af5 */
to
/* 847b3aff-7ab1-11d4-8f02-006008948af5 */
with the 7th and 8th hex digits varying from 00 to ff.
Of these, the following UUIDs are being used as IIDs and CIDs:
nsIEnigMail IID "847b3a00-7ab1-11d4-8f02-006008948af5"
nsEnigMail CID "847b3a01-7ab1-11d4-8f02-006008948af5"
EnigMailProtocolHandler CID "847b3a11-7ab1-11d4-8f02-006008948af5"
nsEnigMsgCompose CID "847b3a21-7ab1-11d4-8f02-006008948af5"
nsEnigMsgComposeFactory CID "847b3a22-7ab1-11d4-8f02-006008948af5"
nsIEnigMsgCompFields IID "847b3a30-7ab1-11d4-8f02-006008948af5"
nsEnigMsgCompFields CID "847b3a31-7ab1-11d4-8f02-006008948af5"
nsIEnigMimeService IID "847b3a40-7ab1-11d4-8f02-006008948af5"
nsEnigMimeService CID "847b3a41-7ab1-11d4-8f02-006008948af5"
nsEnigContentHandler CID "847b3a51-7ab1-11d4-8f02-006008948af5"
nsEnigContentHandlerFactory CID "847b3a52-7ab1-11d4-8f02-006008948af5"
nsIEnigMimeListener IID "847b3a60-7ab1-11d4-8f02-006008948af5"
nsEnigMimeListener CID "847b3a61-7ab1-11d4-8f02-006008948af5"
nsIEnigMimeDecrypt IID "847b3a70-7ab1-11d4-8f02-006008948af5"
nsEnigMimeDecrypt CID "847b3a71-7ab1-11d4-8f02-006008948af5"
nsIEnigMimeHeaderSink IID "847b3a80-7ab1-11d4-8f02-006008948af5"
+nsEnigMimeReadCallback CID "847b3a81-7ab1-11d4-8f02-006008948af5"
nsIEnigMimeVerify IID "847b3a90-7ab1-11d4-8f02-006008948af5"
ns EnigMimeVerify CID "847b3a91-7ab1-11d4-8f02-006008948af5"
nsIEnigMimeWriter IID "847b3aa0-7ab1-11d4-8f02-006008948af5"
nsEnigMimeWriter CID "847b3aa1-7ab1-11d4-8f02-006008948af5"
EnigmailPrefsService CID "847b3ab0-7ab1-11d4-8f02-006008948af5"
EnigmailCmdLineService CID "847b3ab1-7ab1-11d4-8f02-006008948af5"

File Metadata

Mime Type
text/x-diff
Expires
Tue, Dec 30, 5:51 PM (15 h, 27 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
63/46/3fb9038fdecf791910f9224bee0a

Event Timeline