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.
22
* Alternatively, the contents of this file may be used under the terms of
23
* either the GNU General Public License Version 2 or later (the "GPL"), or
24
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
25
* in which case the provisions of the GPL or the LGPL are applicable instead
26
* of those above. If you wish to allow use of your version of this file only
27
* under the terms of either the GPL or the LGPL, and not to allow others to
28
* use your version of this file under the terms of the MPL, indicate your
29
* decision by deleting the provisions above and replace them with the notice
30
* and other provisions required by the GPL or the LGPL. If you do not delete
31
* the provisions above, a recipient may use your version of this file under
32
* the terms of any one of the MPL, the GPL or the LGPL.
33
* ***** END LICENSE BLOCK ***** */
35
Components.utils.import("resource://enigmail/enigmailCommon.jsm");
36
Components.utils.import("resource://enigmail/pipeConsole.jsm");
38
const Ec = EnigmailCommon;
40
function consoleLoad() {
41
Ec.DEBUG_LOG("enigmailConsole.js: consoleLoad\n");
43
top.controllers.insertControllerAt(0, CommandController);
45
Ec.getService(window);
47
// Refresh console every 2 seconds
48
window.consoleIntervalId = window.setInterval(refreshConsole, 2000);
52
function consoleUnload() {
53
Ec.DEBUG_LOG("enigmailConsole.js: consoleUnload\n");
55
// Cancel console refresh
56
if (window.consoleIntervalId) {
57
window.clearInterval(window.consoleIntervalId);
58
window.consoleIntervalId = null;
62
window.onload = consoleLoad;
63
window.onunload = consoleUnload;
65
function refreshConsole() {
66
//Ec.DEBUG_LOG("enigmailConsole.js: refreshConsole():\n");
68
if (EnigmailConsole.hasNewData()) {
69
Ec.DEBUG_LOG("enigmailConsole.js: refreshConsole(): hasNewData\n");
77
function updateData() {
78
//Ec.DEBUG_LOG("enigmailConsole.js: updateData():\n");
80
var contentFrame = Ec.getFrame(window, "contentFrame");
84
var consoleElement = contentFrame.document.getElementById('console');
86
consoleElement.firstChild.data = Ec.convertToUnicode(EnigmailConsole.getData(), "utf-8");
88
if (!contentFrame.mouseDownState)
89
contentFrame.scrollTo(0,9999);
93
function enigmailConsoleCopy()
95
var selText = getSelectionStr();
97
Ec.DEBUG_LOG("enigmailConsole.js: enigmailConsoleCopy: selText='"+selText+"'\n");
100
var clipHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].createInstance(Components.interfaces.nsIClipboardHelper);
102
clipHelper.copyString(selText);
108
function getSelectionStr()
111
var contentFrame = Ec.getFrame(window, "contentFrame");
113
var sel = contentFrame.getSelection();
114
return sel.toString();
121
function isItemSelected()
123
Ec.DEBUG_LOG("enigmailConsole.js: isItemSelected\n");
124
return getSelectionStr() != "";
127
function UpdateCopyMenu()
129
Ec.DEBUG_LOG("enigmailConsole.js: UpdateCopyMenu\n");
130
goUpdateCommand("cmd_copy");
133
var CommandController =
135
isCommandEnabled: function (aCommand)
139
return isItemSelected();
145
supportsCommand: function (aCommand)
155
doCommand: function (aCommand)
159
enigmailConsoleCopy();
166
onEvent: function (aEvent)