forked from kylehuff/webpg-firefox
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed gmail integration not loading * Fixed Send Button override for gmail integration; closes #62; * Fixed issue that made it impossible to sign a UID in the search results; closes #63 * Added user preference to sign outgoing email in gmail by default; closes #64 * Improved load time and removed un-needed gmail_integration checks * Added very basic and unfriendly thunderbird support (sign only) * Changed utility method webpg.utils.onRequest to webpg.utils._onRequest to in order to pass validation for addons.mozilla.org, which erroneously detects this as a handleEvent call, not a user defined method. Lame.
- Loading branch information
Showing
18 changed files
with
460 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pref("extensions.webpg-firefox.decorate_inline", true); | ||
pref("extensions.webpg-firefox.gmail_integration", false); | ||
pref("extensions.webpg-firefox.sign_gmail", false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
/* <![CDATA[ */ | ||
if (typeof(webpg)=='undefined') { webpg = {}; } | ||
if (typeof(webpg.thunderbird)=='undefined') { webpg.thunderbird = {}; } | ||
|
||
// Global reference to webpg.thunderbird.compose | ||
var _this; | ||
|
||
// Global list of valid PGP actions | ||
var sendActions = { | ||
PSIGN: "PLAINSIGN", // Sign the message inline | ||
ASIGN: "ATTACHSIGN", // Create a detached signature and attach to the msg | ||
SIGN: "SIGN", // Create a signed data packet inline | ||
CRYPT: "CRYPT", // Encrypt the data inline | ||
CRYPTSIGN: "CRYPTSIGN", // Encrypt and Sign the data inline | ||
SYMCRYPT: "SYMCRYPT", // Perform Symmetric Encryption inline | ||
} | ||
|
||
webpg.thunderbird.compose = { | ||
|
||
init: function(aEvent) { | ||
webpg.plugin = document.getElementById("webpgPlugin"); | ||
|
||
if (!webpg.plugin.valid) | ||
return | ||
|
||
this.sendAction = false; | ||
this.actionPerformed = false; | ||
|
||
_this = webpg.thunderbird.compose; | ||
|
||
this.stateListener = { | ||
NotifyComposeFieldsReady: _this.composeFieldsReady, | ||
NotifyComposeBodyReady: _this.composeBodyReady, | ||
ComposeProcessDone: _this.composeProcessDone, | ||
SaveInFolderDone: _this.saveInFolderDone, | ||
} | ||
|
||
gMsgCompose.RegisterStateListener(this.stateListener); | ||
|
||
// The message window has been recycled | ||
window.addEventListener('compose-window-reopen', | ||
webpg.thunderbird.compose.reopenMessageListener, true); | ||
|
||
// The message is being sent | ||
window.addEventListener('compose-send-message', | ||
function _sendMessageListener (aEvent) { | ||
webpg.thunderbird.compose.sendMessageListener(aEvent); | ||
}, true); | ||
|
||
window.addEventListener('compose-window-close', | ||
webpg.thunderbird.compose.closeWindowListener, true); | ||
|
||
}, | ||
|
||
composeFieldsReady: function() { | ||
}, | ||
|
||
// The body of the message is available/ready | ||
composeBodyReady: function() { | ||
_this.editor = GetCurrentEditor(); | ||
}, | ||
|
||
// Called after message was sent/saved (fires twice) | ||
composeProcessDone: function(aResult) { | ||
}, | ||
|
||
saveInFolderDone: function(folderURI) { | ||
}, | ||
|
||
// The message was reopened or the window was recycled | ||
reopenMessageListener: function(aEvent) { | ||
}, | ||
|
||
// The message window was closed | ||
closeWindowListener: function(aEvent) { | ||
_this.actionPerformed = false; | ||
}, | ||
|
||
sendMessageListener: function(aEvent) { | ||
var msgcomposeWindow = document.getElementById("msgcomposeWindow"); | ||
var msgType = msgcomposeWindow.getAttribute("msgtype"); | ||
|
||
// Determine if this an actual send event | ||
if(!(msgType == nsIMsgCompDeliverMode.Now || msgType == nsIMsgCompDeliverMode.Later)) | ||
return; | ||
|
||
// Determine if we have a defined sendAction | ||
if (!_this.sendAction) | ||
return; | ||
|
||
// Determine if we have already performed the required action | ||
if (_this.actionPerformed) | ||
return; | ||
|
||
// execute the current sendAction | ||
var actionResult = _this.performSendAction(); | ||
|
||
// Handle any errors | ||
if (actionResult.error) { | ||
alert("WebPG - error: " + actionResult.error_string + "; Error code: " + actionResult.gpg_error_code); | ||
aEvent.preventDefault(); | ||
aEvent.stopPropagation(); | ||
} else { | ||
_this.actionPerformed = true; | ||
} | ||
}, | ||
|
||
setSendAction: function(action) { | ||
|
||
switch (action) { | ||
case sendActions.PSIGN: | ||
this.sendAction = "PLAINSIGN"; | ||
break; | ||
|
||
case sendActions.ASIGN: | ||
this.sendAction = "ATTACHSIGN"; | ||
break; | ||
|
||
case sendActions.CRYPTSIGN: | ||
this.sendAction = "CRYPTSIGN"; | ||
break; | ||
|
||
case sendActions.CRYPT: | ||
this.sendAction = "CRYPT"; | ||
break; | ||
|
||
default: | ||
this.sendAction = false; | ||
|
||
} | ||
|
||
}, | ||
|
||
getEditorContents: function() { | ||
const dce = Components.interfaces.nsIDocumentEncoder; | ||
var encFlags = dce.OutputFormatted | dce.OutputLFLineBreak; | ||
return _this.editor.outputToString("text/plain", encFlags); | ||
}, | ||
|
||
setEditorContents: function(contents) { | ||
this.editor.selectAll(); | ||
|
||
this.editor.beginTransaction(); | ||
|
||
try { | ||
var editor = this.editor.QueryInterface(Components.interfaces.nsIEditorMailSupport); | ||
editor.insertTextWithQuotations(contents); | ||
} catch (ex) { | ||
this.editor.insertText(contents); | ||
} | ||
|
||
this.editor.endTransaction(); | ||
}, | ||
|
||
performSendAction: function() { | ||
// Retrieve the contents of the editor | ||
var msgContents = this.getEditorContents(); | ||
|
||
var actionStatus = {'error': true}; | ||
|
||
switch (this.sendAction) { | ||
case webpg.constants.overlayActions.PSIGN: | ||
actionStatus = _this.clearSignMsg(msgContents); | ||
break; | ||
|
||
case webpg.constants.overlayActions.ASIGN: | ||
actionStatus = _this.clearSignMsg(msgContents); | ||
break; | ||
} | ||
|
||
return actionStatus; | ||
}, | ||
|
||
clearSignMsg: function(msg) { | ||
var signKey = webpg.preferences.default_key.get(); | ||
var signStatus = webpg.plugin.gpgSignText([signKey], msg, 2); | ||
if (!signStatus.error) | ||
_this.setEditorContents(signStatus.data); | ||
return signStatus; | ||
}, | ||
} | ||
|
||
window.addEventListener('compose-window-init', | ||
function _init(aEvent) { | ||
webpg.thunderbird.compose.init(aEvent); | ||
}, true); | ||
/* ]]> */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?xml-stylesheet href="chrome://webpg-firefox/skin/overlay.css" type="text/css"?> | ||
<!DOCTYPE overlay SYSTEM "chrome://webpg-firefox/locale/webpg.dtd"> | ||
<overlay id="webpg-overlay" xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> | ||
<script src="../../constants.js"/> | ||
<script src="../../utils.js"/> | ||
<script src="../../preferences.js"/> | ||
<script src="../../background.js"/> | ||
<script src="thunderbirdUtils.js"/> | ||
<script src="composeOverlay.js"/> | ||
<!-- <script src="../inline.js"/>--> | ||
<!-- <script src="../webpg_overlay.js"/>--> | ||
|
||
<stringbundleset id="stringbundleset"> | ||
<stringbundle id="webpg-strings" src="chrome://webpg-firefox/locale/webpg.properties"/> | ||
</stringbundleset> | ||
|
||
<toolbarpalette id="MsgComposeToolbarPalette"> | ||
<toolbarbutton id="webpg-msg-btn" | ||
class="webpg-msg-btn toolbarbutton-1" | ||
type="menu-button" | ||
buttontype="thunderbird" | ||
label="WebPG" | ||
> | ||
<menupopup> | ||
<menuitem id="webpg-msg-noaction" | ||
class="webpg-msg-noaction" | ||
type="radio" | ||
label="Do not use WebPG for this message" | ||
oncommand="webpg.thunderbird.compose.setSendAction('NOACTION');" | ||
name="webpg-send-action" | ||
/> | ||
<menuitem id="webpg-msg-sign" | ||
class="webpg-msg-sign" | ||
type="radio" | ||
label="Sign Inline (uses default key; EXPERIMENTAL)" | ||
oncommand="webpg.thunderbird.compose.setSendAction('PLAINSIGN');" | ||
name="webpg-send-action" | ||
/> | ||
<!-- <menuitem id="webpg-msg-sign-enc"--> | ||
<!-- class="webpg-msg-sign-enc"--> | ||
<!-- type="radio"--> | ||
<!-- label="Encrypt & Sign"--> | ||
<!-- oncommand="webpg.thunderbird.compose.setSendAction('CRYPTSIGN');"--> | ||
<!-- name="webpg-send-action"--> | ||
<!-- />--> | ||
<!-- <menuitem id="webpg-msg-enc"--> | ||
<!-- class="webpg-msg-enc"--> | ||
<!-- type="radio"--> | ||
<!-- label="Encrypt Only (do not sign)"--> | ||
<!-- oncommand="webpg.thunderbird.compose.setSendAction('CRYPT');"--> | ||
<!-- name="webpg-send-action"--> | ||
<!-- />--> | ||
<!-- <menuitem id="webpg-msg-symenc"--> | ||
<!-- class="webpg-msg-symenc"--> | ||
<!-- type="radio"--> | ||
<!-- label="Symmetric Encryption"--> | ||
<!-- oncommand="webpg.thunderbird.compose.setSendAction('SYMCRYPT');"--> | ||
<!-- name="webpg-send-action"--> | ||
<!-- />--> | ||
</menupopup> | ||
</toolbarbutton> | ||
</toolbarpalette> | ||
|
||
<menupopup id="menu_ToolsPopup"> | ||
<menuseparator/> | ||
<menu id="menu-webpg" label="&webpgMenu.label;" class="menu-iconic webpg-menu"> | ||
<menupopup id="webpg-menu-popup"> | ||
<menuitem class="webpg-menu-manager menuitem-iconic" label="&webpgMenu.labelManager;" oncommand="webpg.overlay.onContextCommand(event,webpg.constants.overlayActions.MANAGER)"/> | ||
<menuitem class="webpg-menu-options menuitem-iconic" label="&webpgMenu.labelOptions;" oncommand="webpg.overlay.onContextCommand(event,webpg.constants.overlayActions.OPTS)"/> | ||
<menuitem class="webpg-menu-about menuitem-iconic" label="&webpgMenu.labelAbout;" oncommand="webpg.overlay.onContextCommand(event,webpg.constants.overlayActions.ABOUT)"/> | ||
</menupopup> | ||
</menu> | ||
</menupopup> | ||
|
||
<popup id="contentAreaContextMenu"> | ||
<menuseparator/> | ||
<menu id="context-webpg" class="menu-iconic webpg-menu" label="&webpgContext.label;" src="chrome://webpg-firefox/skin/images/webpg-32.png"> | ||
<menupopup id="webpg-contex-popup"> | ||
<menuitem class="webpg-menu-sign context-menu-item menuitem-iconic" label="&webpgContext.labelClearSign;" oncommand="webpg.overlay.onContextCommand(event, webpg.constants.overlayActions.PSIGN)"/> | ||
<menuitem class="webpg-menu-verif context-menu-item menuitem-iconic" label="&webpgContext.labelVerif;" oncommand="webpg.overlay.onContextCommand(event,webpg.constants.overlayActions.VERIF)"/> | ||
<menuitem class="webpg-menu-crypt context-menu-item menuitem-iconic" label="&webpgContext.labelCrypt;" oncommand="webpg.overlay.onContextCommand(event,webpg.constants.overlayActions.CRYPT)"/> | ||
<menuitem class="webpg-menu-cryptsign context-menu-item menuitem-iconic" label="&webpgContext.labelCryptSign;" oncommand="webpg.overlay.onContextCommand(event,webpg.constants.overlayActions.CRYPTSIGN)"/> | ||
<menuitem class="webpg-menu-decrypt context-menu-item menuitem-iconic" label="&webpgContext.labelDecry;" oncommand="webpg.overlay.onContextCommand(event,webpg.constants.overlayActions.DECRYPT)"/> | ||
<menuitem class="webpg-menu-import context-menu-item menuitem-iconic" label="&webpgContext.labelImport;" oncommand="webpg.overlay.onContextCommand(event,webpg.constants.overlayActions.IMPORT)"/> | ||
<menuitem class="webpg-menu-export context-menu-item menuitem-iconic" label="&webpgContext.labelExport;" oncommand="webpg.overlay.onContextCommand(event,webpg.constants.overlayActions.EXPORT)"/> | ||
<menuseparator/> | ||
<menuitem class="webpg-menu-manager menuitem-iconic" label="&webpgContext.labelManager;" oncommand="webpg.overlay.onContextCommand(event,webpg.constants.overlayActions.MANAGER)"/> | ||
<menuitem class="webpg-menu-options menuitem-iconic" label="&webpgContext.labelOptions;" oncommand="webpg.overlay.onContextCommand(event,webpg.constants.overlayActions.OPTS)"/> | ||
<menuitem style="display: none;" id="webpg-menu-memo-pop" class="webpg-menu-rease menuitem-iconic" label="&webpgContext.labelErase;" oncommand="webpg.overlay.onContextCommand(event,webpg.constants.overlayActions.ERASE)"/> | ||
</menupopup> | ||
</menu> | ||
</popup> | ||
|
||
<window> | ||
<html:object id="webpgPlugin" type="application/x-webpg" height="1" width="1"></html:object> | ||
</window> | ||
</overlay> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* <![CDATA[ */ | ||
if (typeof(webpg)=='undefined') { webpg = {}; } | ||
if (typeof(webpg.thunderbird)=='undefined') { webpg.thunderbird = {}; } | ||
|
||
webpg.thunderbird.utils = { | ||
|
||
accountManager: function() { | ||
return Components.classes["@mozilla.org/messenger/account-manager;1"] | ||
.getService(Components.interfaces.nsIMsgAccountManager); | ||
}(), | ||
|
||
getIdentities: function() { | ||
var idSupports = this.accountManager.allIdentities; | ||
var identities = queryISupportsArray(idSupports, | ||
Components.interfaces.nsIMsgIdentity); | ||
|
||
return identities; | ||
}, | ||
|
||
getCurrentIdentity: function() { | ||
var msgIdentity = document.getElementById('msgIdentity').value; | ||
return this.accountManager.getIdentity(msgIdentity); | ||
}, | ||
|
||
getDefaultIdentity: function() { | ||
// Default identity | ||
var defaultIDs = this.accountManager.defaultAccount.identities; | ||
return (defaultIDs.Count() >= 1) ? defaultIDs.QueryElementAt(0, | ||
Components.interfaces.nsIMsgIdentity) : this.getIdentities()[0]; | ||
}, | ||
} | ||
|
||
/* ]]> */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.