1
/* ***** BEGIN LICENSE BLOCK *****
2
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
* The contents of this file are subject to the Mozilla Public
5
* License Version 1.1 (the "MPL"); you may not use this file
6
* except in compliance with the MPL. You may obtain a copy of
7
* the MPL at http://www.mozilla.org/MPL/
9
* Software distributed under the MPL is distributed on an "AS
10
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11
* implied. See the MPL for the specific language governing
12
* rights and limitations under the MPL.
14
* The Original Code is Enigmail.
16
* The Initial Developer of the Original Code is Ramalingam Saravanan.
17
* Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
18
* Copyright (C) 2001 Ramalingam Saravanan. All Rights Reserved.
21
* Patrick Brunschwig <patrick@mozilla-enigmail.org>
23
* Alternatively, the contents of this file may be used under the terms of
24
* either the GNU General Public License Version 2 or later (the "GPL"), or
25
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
* in which case the provisions of the GPL or the LGPL are applicable instead
27
* of those above. If you wish to allow use of your version of this file only
28
* under the terms of either the GPL or the LGPL, and not to allow others to
29
* use your version of this file under the terms of the MPL, indicate your
30
* decision by deleting the provisions above and replace them with the notice
31
* and other provisions required by the GPL or the LGPL. If you do not delete
32
* the provisions above, a recipient may use your version of this file under
33
* the terms of any one of the MPL, the GPL or the LGPL.
34
* ***** END LICENSE BLOCK ***** */
36
// enigmailCommon.js: shared JS functions for Enigmail
38
// WARNING: This module functions must not be loaded in overlays to standard
41
Components.utils.import("resource://enigmail/enigmailCommon.jsm");
42
Components.utils.import("resource://enigmail/commonFuncs.jsm");
43
Components.utils.import("resource://enigmail/keyManagement.jsm");
46
// The compatible Enigmime version
47
var gEnigmimeVersion = "1.4";
52
// Maximum size of message directly processed by Enigmail
53
const ENIG_MSG_BUFFER_SIZE = 96000;
54
const ENIG_MSG_HEADER_SIZE = 16000;
55
const ENIG_UNLIMITED_BUFFER_SIZE = -1;
57
const ENIG_KEY_BUFFER_SIZE = 64000;
59
const ENIG_PROCESSINFO_CONTRACTID = "@mozilla.org/xpcom/process-info;1";
60
const ENIG_IPCBUFFER_CONTRACTID = "@mozilla.org/ipc/ipc-buffer;1";
61
const ENIG_ENIGMAIL_CONTRACTID = "@mozdev.org/enigmail/enigmail;1";
62
const ENIG_ENIGMIMELISTENER_CONTRACTID = "@mozilla.org/enigmail/mime-listener;1";
63
const ENIG_ENIGMIMESERVICE_CONTRACTID = "@mozdev.org/enigmail/enigmimeservice;1";
64
const ENIG_STRINGBUNDLE_CONTRACTID = "@mozilla.org/intl/stringbundle;1";
65
const ENIG_LOCAL_FILE_CONTRACTID = "@mozilla.org/file/local;1";
66
const ENIG_DIRSERVICE_CONTRACTID = "@mozilla.org/file/directory_service;1";
67
const ENIG_MIME_CONTRACTID = "@mozilla.org/mime;1";
68
const ENIG_WMEDIATOR_CONTRACTID = "@mozilla.org/rdf/datasource;1?name=window-mediator";
69
const ENIG_ASS_CONTRACTID = "@mozilla.org/appshell/appShellService;1";
70
const ENIG_CLIPBOARD_CONTRACTID = "@mozilla.org/widget/clipboard;1";
71
const ENIG_CLIPBOARD_HELPER_CONTRACTID = "@mozilla.org/widget/clipboardhelper;1"
72
const ENIG_TRANSFERABLE_CONTRACTID = "@mozilla.org/widget/transferable;1"
73
const ENIG_LOCALE_SVC_CONTRACTID = "@mozilla.org/intl/nslocaleservice;1";
74
const ENIG_DATE_FORMAT_CONTRACTID = "@mozilla.org/intl/scriptabledateformat;1"
75
const ENIG_ACCOUNT_MANAGER_CONTRACTID = "@mozilla.org/messenger/account-manager;1";
76
const ENIG_THREAD_MANAGER_CID = "@mozilla.org/thread-manager;1";
77
const ENIG_SIMPLEURI_CONTRACTID = "@mozilla.org/network/simple-uri;1";
78
const ENIG_SEAMONKEY_ID = "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}"
81
const ENIG_STANDARD_URL_CONTRACTID = "@mozilla.org/network/standard-url;1";
82
const ENIG_SCRIPTABLEINPUTSTREAM_CONTRACTID = "@mozilla.org/scriptableinputstream;1";
83
const ENIG_BINARYINPUTSTREAM_CONTRACTID = "@mozilla.org/binaryinputstream;1";
84
const ENIG_SAVEASCHARSET_CONTRACTID = "@mozilla.org/intl/saveascharset;1";
86
const ENIG_STREAMCONVERTERSERVICE_CID_STR =
87
"{892FFEB0-3F80-11d3-A16C-0050041CAF44}";
90
const ENIG_ISCRIPTABLEUNICODECONVERTER_CONTRACTID = "@mozilla.org/intl/scriptableunicodeconverter";
92
const ENIG_IOSERVICE_CONTRACTID = "@mozilla.org/network/io-service;1";
94
const ENIG_C = Components.classes;
95
const ENIG_I = Components.interfaces;
98
const ENIG_KEYTYPE_DSA = 1;
99
const ENIG_KEYTYPE_RSA = 2;
102
// field ID's of key list (as described in the doc/DETAILS file in the GnuPG distribution)
103
const ENIG_KEY_TRUST=1;
104
const ENIG_KEY_ID = 4;
105
const ENIG_CREATED = 5;
106
const ENIG_EXPIRY = 6;
107
const ENIG_UID_ID = 7;
108
const ENIG_OWNERTRUST = 8;
109
const ENIG_USER_ID = 9;
110
const ENIG_SIG_TYPE = 10;
111
const ENIG_KEY_USE_FOR = 11;
113
const ENIG_KEY_EXPIRED="e";
114
const ENIG_KEY_REVOKED="r";
115
const ENIG_KEY_INVALID="i";
116
const ENIG_KEY_DISABLED="d";
117
const ENIG_KEY_NOT_VALID=ENIG_KEY_EXPIRED+ENIG_KEY_REVOKED+ENIG_KEY_INVALID+ENIG_KEY_DISABLED;
121
const nsIEnigmail = ENIG_I.nsIEnigmail;
125
const ENIG_SIGN = nsIEnigmail.SEND_SIGNED;
126
const ENIG_ENCRYPT = nsIEnigmail.SEND_ENCRYPTED;
127
const ENIG_ENCRYPT_OR_SIGN = ENIG_ENCRYPT | ENIG_SIGN;
130
// UsePGPMimeOption values
131
const PGP_MIME_NEVER = 0;
132
const PGP_MIME_POSSIBLE = 1;
133
const PGP_MIME_ALWAYS = 2;
135
const ENIG_POSSIBLE_PGPMIME = -2081;
136
const ENIG_PGP_DESKTOP_ATT = -2082;
138
var gUsePGPMimeOptionList = ["usePGPMimeNever", "usePGPMimePossible",
141
var gEnigRecipientsSelection = ["-",
143
"perRecipientRulesAndEmail",
145
"askRecipientsAlways"];
147
const ENIG_BUTTON_POS_0 = 1;
148
const ENIG_BUTTON_POS_1 = 1 << 8;
149
const ENIG_BUTTON_POS_2 = 1 << 16;
150
const ENIG_BUTTON_TITLE_IS_STRING = 127;
152
const ENIG_HEADERMODE_KEYID = 0x01;
153
const ENIG_HEADERMODE_URL = 0x10;
157
function EnigGetFrame(win, frameName) {
158
return EnigmailCommon.getFrame(win, frameName);
161
// Initializes enigmailCommon
162
function EnigInitCommon(id) {
163
DEBUG_LOG("enigmailCommon.js: EnigInitCommon: id="+id+"\n");
165
gEnigPromptSvc = enigGetService("@mozilla.org/embedcomp/prompt-service;1", "nsIPromptService");
169
function GetEnigmailSvc() {
171
gEnigmailSvc = EnigmailCommon.getService(window);
175
// maxBytes == -1 => read everything
176
function EnigReadURLContents(url, maxBytes) {
177
DEBUG_LOG("enigmailCommon.js: EnigReadURLContents: url="+url+
180
var ioServ = enigGetService(ENIG_IOSERVICE_CONTRACTID, "nsIIOService");
182
throw Components.results.NS_ERROR_FAILURE;
184
var fileChannel = ioServ.newChannel(url, null, null)
186
var rawInStream = fileChannel.open();
188
var inStream = ENIG_C[ENIG_BINARYINPUTSTREAM_CONTRACTID].createInstance(ENIG_I.nsIBinaryInputStream);
189
inStream.setInputStream(rawInStream);
191
var available = inStream.available()
192
if ((maxBytes < 0) || (maxBytes > available))
193
maxBytes = available;
195
var data = inStream.readBytes(maxBytes);
202
// maxBytes == -1 => read whole file
203
function EnigReadFileContents(localFile, maxBytes) {
205
DEBUG_LOG("enigmailCommon.js: EnigReadFileContents: file="+localFile.leafName+
208
if (!localFile.exists() || !localFile.isReadable())
209
throw Components.results.NS_ERROR_FAILURE;
211
var ioServ = enigGetService(ENIG_IOSERVICE_CONTRACTID, "nsIIOService");
213
throw Components.results.NS_ERROR_FAILURE;
215
var fileURI = ioServ.newFileURI(localFile);
216
return EnigReadURLContents(fileURI.asciiSpec, maxBytes);
220
///////////////////////////////////////////////////////////////////////////////
222
function WRITE_LOG(str) {
223
EnigmailCommon.WRITE_LOG(str);
226
function DEBUG_LOG(str) {
227
EnigmailCommon.DEBUG_LOG(str);
230
function WARNING_LOG(str) {
231
EnigmailCommon.WARNING_LOG(str);
234
function ERROR_LOG(str) {
235
EnigmailCommon.ERROR_LOG(str);
238
function CONSOLE_LOG(str) {
239
EnigmailCommon.CONSOLE_LOG(str);
243
// write exception information
244
function EnigWriteException(referenceInfo, ex) {
245
EnigmailCommon.writeException(referenceInfo, ex);
248
///////////////////////////////////////////////////////////////////////////////
250
function EnigAlert(mesg) {
251
return EnigmailCommon.alert(window, mesg);
255
* Displays an alert dialog with 3-4 optional buttons.
256
* checkBoxLabel: if not null, display checkbox with text; the checkbox state is returned in checkedObj
257
* button-Labels: use "&" to indicate access key
258
* use "buttonType:label" or ":buttonType" to indicate special button types
259
* (buttonType is one of cancel, help, extra1, extra2)
260
* return: 0-2: button Number pressed
261
* -1: ESC or close window button pressed
264
function EnigLongAlert(mesg, checkBoxLabel, okLabel, labelButton2, labelButton3, checkedObj) {
265
return EnigmailCommon.longAlert(window, mesg, checkBoxLabel, okLabel, labelButton2, labelButton3, checkedObj);
268
function EnigAlertPref(mesg, prefText) {
269
return EnigmailCommon.alertPref(window, mesg, prefText);
272
// Confirmation dialog with OK / Cancel buttons (both customizable)
273
function EnigConfirm(mesg, okLabel, cancelLabel) {
274
return EnigmailCommon.confirmDlg(window, mesg, okLabel, cancelLabel);
278
function EnigConfirmPref(mesg, prefText, okLabel, cancelLabel) {
279
return EnigmailCommon.confirmPref(window, mesg, prefText, okLabel, cancelLabel);
282
function EnigError(mesg) {
283
return gEnigPromptSvc.alert(window, EnigGetString("enigError"), mesg);
286
function EnigPrefWindow(showBasic, clientType, selectTab) {
287
DEBUG_LOG("enigmailCommon.js: EnigPrefWindow\n");
288
EnigmailFuncs.openPrefWindow(window, showBasic, selectTab);
292
function EnigHelpWindow(source) {
293
EnigmailFuncs.openHelpWindow(source);
297
function EnigDisplayRadioPref(prefName, prefValue, optionElementIds) {
298
DEBUG_LOG("enigmailCommon.js: EnigDisplayRadioPref: "+prefName+", "+prefValue+"\n");
300
if (prefValue >= optionElementIds.length)
303
var groupElement = document.getElementById("enigmail_"+prefName);
304
var optionElement = document.getElementById(optionElementIds[prefValue]);
306
if (groupElement && optionElement) {
307
groupElement.selectedItem = optionElement;
308
groupElement.value = prefValue;
312
function EnigSetRadioPref(prefName, optionElementIds) {
313
DEBUG_LOG("enigmailCommon.js: EnigSetRadioPref: "+prefName+"\n");
316
var groupElement = document.getElementById("enigmail_"+prefName);
318
var optionElement = groupElement.selectedItem;
319
var prefValue = optionElement.value;
320
if (prefValue < optionElementIds.length) {
321
EnigSetPref(prefName, prefValue);
322
groupElement.value = prefValue;
329
function EnigSavePrefs() {
330
return EnigmailCommon.savePrefs();
333
function EnigGetPref(prefName) {
334
return EnigmailCommon.getPref(prefName);
337
function EnigGetDefaultPref(prefName) {
338
DEBUG_LOG("enigmailCommon.js: EnigGetDefaultPref: prefName="+prefName+"\n");
341
EnigmailCommon.prefBranch.lockPref(prefName);
342
prefValue = EnigGetPref(prefName);
343
EnigmailCommon.prefBranch.unlockPref(prefName);
350
function EnigSetPref(prefName, value) {
351
return EnigmailCommon.setPref(prefName, value);
354
function EnigGetSignMsg(identity) {
355
EnigmailFuncs.getSignMsg(identity);
359
function EnigConvertFromUnicode(text, charset) {
360
DEBUG_LOG("enigmailCommon.js: EnigConvertFromUnicode: "+charset+"\n");
365
if (! charset) charset="utf-8";
369
var unicodeConv = ENIG_C[ENIG_ISCRIPTABLEUNICODECONVERTER_CONTRACTID].getService(ENIG_I.nsIScriptableUnicodeConverter);
371
unicodeConv.charset = charset;
372
return unicodeConv.ConvertFromUnicode(text);
375
DEBUG_LOG("enigmailCommon.js: EnigConvertFromUnicode: caught an exception\n");
382
function EnigConvertToUnicode(text, charset) {
383
// DEBUG_LOG("enigmailCommon.js: EnigConvertToUnicode: "+charset+"\n");
385
if (!text || !charset /*|| (charset.toLowerCase() == "iso-8859-1")*/)
390
var unicodeConv = ENIG_C[ENIG_ISCRIPTABLEUNICODECONVERTER_CONTRACTID].getService(ENIG_I.nsIScriptableUnicodeConverter);
392
unicodeConv.charset = charset;
393
return unicodeConv.ConvertToUnicode(text);
396
DEBUG_LOG("enigmailCommon.js: EnigConvertToUnicode: caught an exception while converting'"+text+"' to "+charset+"\n");
401
function EnigConvertGpgToUnicode(text) {
402
return EnigmailCommon.convertGpgToUnicode(text);
405
function EnigFormatFpr(fingerprint) {
406
return EnigmailFuncs.formatFpr(fingerprint);
409
/////////////////////////
411
/////////////////////////
414
// return the options passed to a window
415
function EnigGetWindowOptions() {
417
if (window.location.search) {
418
var optList=window.location.search.substr(1).split(/\&/);
419
for (var i=0; i<optList.length; i++) {
420
var anOption=optList[i].split(/\=/);
421
winOptions[anOption[0]] = unescape(anOption[1]);
427
function EnigRulesEditor() {
428
EnigmailFuncs.openRulesEditor();
431
function EngmailCardDetails() {
432
EnigmailFuncs.openCardDetails();
435
function EnigKeygen() {
436
EnigmailFuncs.openKeyGen();
440
// retrieves a localized string from the enigmail.properties stringbundle
441
function EnigGetString(aStr) {
442
var argList = new Array();
443
// unfortunately arguments.shift() doesn't work, so we use a workaround
445
if (arguments.length > 1)
446
for (let i=1; i<arguments.length; i++)
447
argList.push(arguments[i]);
448
return EnigmailCommon.getString(aStr, (arguments.length > 1 ? argList : null));
451
// Remove all quoted strings (and angle brackets) from a list of email
452
// addresses, returning a list of pure email addresses
453
function EnigStripEmail(mailAddrs) {
454
return EnigmailFuncs.stripEmail(mailAddrs);
458
//get path for temporary directory (e.g. /tmp, C:\TEMP)
459
function EnigGetTempDir() {
460
return EnigmailCommon.getTempDir();
463
// get the OS platform
464
function EnigGetOS () {
465
return EnigmailCommon.getOS();
468
function EnigGetVersion() {
469
return EnigmailCommon.getVersion();
472
function EnigDisplayPrefs(showDefault, showPrefs, setPrefs) {
473
DEBUG_LOG("enigmailCommon.js: EnigDisplayPrefs\n");
475
var obj = new Object;
476
var prefList = EnigmailCommon.prefBranch.getChildList("",obj);
478
for (var prefItem in prefList) {
479
var prefName=prefList[prefItem];
480
var prefElement = document.getElementById("enigmail_"+prefName);
483
var prefType = EnigmailCommon.prefBranch.getPrefType(prefName);
486
prefValue = EnigGetDefaultPref(prefName);
489
prefValue = EnigGetPref(prefName);
492
DEBUG_LOG("enigmailCommon.js: EnigDisplayPrefs: "+prefName+"="+prefValue+"\n");
495
case EnigmailCommon.prefBranch.PREF_BOOL:
497
if (prefElement.getAttribute("invert") == "true") {
498
prefValue = ! prefValue;
502
prefElement.setAttribute("checked", "true");
504
prefElement.removeAttribute("checked");
510
if (prefElement.getAttribute("invert") == "true") {
511
if (prefElement.checked) {
512
EnigSetPref(prefName, false);
514
EnigSetPref(prefName, true);
518
if (prefElement.checked) {
519
EnigSetPref(prefName, true);
521
EnigSetPref(prefName, false);
528
case EnigmailCommon.prefBranch.PREF_INT:
530
prefElement.value = prefValue;
534
EnigSetPref(prefName, 0+prefElement.value);
539
case EnigmailCommon.prefBranch.PREF_STRING:
541
prefElement.value = prefValue;
543
EnigSetPref(prefName, prefElement.value);
547
DEBUG_LOG("enigmailCommon.js: EnigDisplayPrefs: "+prefName+" does not have a type?!\n");
553
function EnigFilePicker(title, displayDir, save, defaultExtension, defaultName, filterPairs) {
554
return EnigmailCommon.filePicker(window, title, displayDir, save, defaultExtension,
555
defaultName, filterPairs);
558
// get keys from keyserver
559
function EnigDownloadKeys(inputObj, resultObj) {
560
return EnigmailFuncs.downloadKeys(window, inputObj, resultObj);
563
// create new PGP Rule
564
function EnigNewRule(emailAddress) {
565
return EnigmailFuncs.createNewRule(window, emailAddress);
568
function EnigGetTrustCode(keyObj) {
569
return EnigmailFuncs.getTrustCode(keyObj);
572
// Load the key list into memory
573
// sortDirection: 1 = ascending / -1 = descending
575
function EnigLoadKeyList(refresh, keyListObj, sortColumn, sortDirection) {
576
return EnigmailFuncs.loadKeyList(window, refresh, keyListObj, sortColumn, sortDirection);
579
function EnigEditKeyTrust(userIdArr, keyIdArr) {
580
return EnigmailFuncs.editKeyTrust(window, userIdArr, keyIdArr);
583
function EnigDisplayKeyDetails(keyId, refresh) {
584
return EnigmailFuncs.openKeyDetails(window, keyId, refresh);
587
function EnigSignKey(userId, keyId, signingKeyHint) {
588
return EnigmailFuncs.signKey(window, userId, keyId, signingKeyHint);
592
function EnigChangeKeyPwd(keyId, userId) {
594
var enigmailSvc = GetEnigmailSvc();
598
if (! enigmailSvc.useGpgAgent()) {
599
// no gpg-agent: open dialog to enter new passphrase
605
window.openDialog("chrome://enigmail/content/enigmailChangePasswd.xul",
606
"", "dialog,modal,centerscreen", inputObj);
609
// gpg-agent used: gpg-agent will handle everything
610
EnigmailKeyMgmt.changePassphrase(window, "0x"+keyId, "", "",
611
function _changePwdCb(exitCode, errorMsg) {
613
EnigAlert(EnigGetString("changePassFailed")+"\n\n"+errorMsg);
620
function EnigRevokeKey(keyId, userId, callbackFunc) {
621
var enigmailSvc = GetEnigmailSvc();
625
var userDesc="0x"+keyId.substr(-8,8)+" - "+userId;
626
if (!EnigConfirm(EnigGetString("revokeKeyAsk", userDesc), EnigGetString("keyMan.button.revokeKey"))) return;
628
var tmpDir=EnigGetTempDir();
631
var revFile = ENIG_C[ENIG_LOCAL_FILE_CONTRACTID].createInstance(EnigGetLocalFileApi());
632
revFile.initWithPath(tmpDir);
633
if (!(revFile.isDirectory() && revFile.isWritable())) {
634
EnigAlert(EnigGetString("noTempDir"));
639
revFile.append("revkey.asc");
641
EnigmailKeyMgmt.genRevokeCert(window, "0x"+keyId, revFile, "0", "",
642
function _revokeCertCb(exitCode, errorMsg) {
644
revFile.remove(false);
645
EnigAlert(EnigGetString("revokeKeyFailed")+"\n\n"+errorMsg);
648
var errorMsgObj = {};
650
var r = enigmailSvc.importKeyFromFile(window, revFile, errorMsgObj, keyList);
651
revFile.remove(false);
653
EnigAlert(EnigGetString("revokeKeyFailed")+"\n\n"+EnigConvertGpgToUnicode(errorMsgObj.value));
656
EnigAlert(EnigGetString("revokeKeyOk"));
659
callbackFunc(r == 0);
664
function EnigGetLocalFileApi() {
665
return EnigmailCommon.getLocalFileApi();
668
function EnigShowPhoto (keyId, userId, photoNumber) {
669
EnigmailFuncs.showPhoto(window, keyId, userId, photoNumber);
672
function EnigGetFilePath (nsFileObj) {
673
return EnigmailCommon.getFilePath(nsFileObj);
676
function EnigCreateRevokeCert(keyId, userId, callbackFunc) {
677
var defaultFileName = userId.replace(/[\<\>]/g, "");
678
defaultFileName += " (0x"+keyId.substr(-8,8)+") rev.asc"
679
var outFile = EnigFilePicker(EnigGetString("saveRevokeCertAs"),
682
[EnigGetString("asciiArmorFile"), "*.asc"]);
683
if (! outFile) return -1;
685
var enigmailSvc = GetEnigmailSvc();
689
var errorMsgObj = {};
690
EnigmailKeyMgmt.genRevokeCert(window, "0x"+keyId, outFile, "1", "",
691
function _revokeCertCb(exitCode, errorMsg) {
693
EnigAlert(EnigGetString("revokeCertFailed")+"\n\n"+errorMsg);
696
EnigAlert(EnigGetString("revokeCertOK"));
699
if (callbackFunc) callbackFunc(exitCode == 0);
704
// return the label of trust for a given trust code
705
function EnigGetTrustLabel(trustCode) {
709
keyTrust=EnigGetString("keyValid.unknown");
712
keyTrust=EnigGetString("keyValid.invalid");
716
keyTrust=EnigGetString("keyValid.disabled");
719
keyTrust=EnigGetString("keyValid.revoked");
722
keyTrust=EnigGetString("keyValid.expired");
725
keyTrust=EnigGetString("keyTrust.untrusted");
728
keyTrust=EnigGetString("keyTrust.marginal");
731
keyTrust=EnigGetString("keyTrust.full");
734
keyTrust=EnigGetString("keyTrust.ultimate");
737
keyTrust=EnigGetString("keyTrust.group");
748
function EnigGetDateTime(dateNum, withDate, withTime) {
749
return EnigmailCommon.getDateTime(dateNum, withDate, withTime);
752
function enigCreateInstance (aURL, aInterface)
754
return ENIG_C[aURL].createInstance(ENIG_I[aInterface]);
757
function enigGetService (aURL, aInterface)
759
// determine how 'aInterface' is passed and handle accordingly
760
switch (typeof(aInterface))
763
return ENIG_C[aURL].getService(aInterface);
767
return ENIG_C[aURL].getService(ENIG_I[aInterface]);
771
return ENIG_C[aURL].getService();
777
function EnigCollapseAdvanced(obj, attribute, dummy) {
778
return EnigmailFuncs.collapseAdvanced(obj, attribute, dummy);
782
function EnigOpenURL(event, hrefObj) {
783
var xulAppinfo = ENIG_C["@mozilla.org/xre/app-info;1"].getService(ENIG_I.nsIXULAppInfo);
784
if (xulAppinfo.ID == ENIG_SEAMONKEY_ID) return;
787
var ioservice = ENIG_C["@mozilla.org/network/io-service;1"].
788
getService(ENIG_I.nsIIOService);
789
var iUri = ioservice.newURI(hrefObj.href, null, null);
790
var eps = ENIG_C["@mozilla.org/uriloader/external-protocol-service;1"].
791
getService(ENIG_I.nsIExternalProtocolService);
793
eps.loadURI(iUri, null);
795
event.preventDefault();
796
event.stopPropagation();