diff --git a/extension/XULContent/thunderbird/composeOverlay.js b/extension/XULContent/thunderbird/composeOverlay.js index 96082bd..e20bbc9 100644 --- a/extension/XULContent/thunderbird/composeOverlay.js +++ b/extension/XULContent/thunderbird/composeOverlay.js @@ -358,7 +358,7 @@ webpg.thunderbird.compose = { return true; }); } - var status = webpg.plugin.gpgEncrypt(msg, recipients, (sign == true) ? 1 : 0); + var status = webpg.plugin.gpgEncrypt(msg, recipients, (sign == true) ? 1 : 0, []); webpg.plugin.restoreGPGConfig(); if (!status.error) webpg.thunderbird.compose.setEditorContents(status.data); @@ -374,7 +374,7 @@ webpg.thunderbird.compose = { symCryptMsg: function(msg) { try { - var encryptStatus = webpg.plugin.gpgSymmetricEncrypt(msg, 0); + var encryptStatus = webpg.plugin.gpgSymmetricEncrypt(msg, 0, []); if (!encryptStatus.error) webpg.thunderbird.compose.setEditorContents(encryptStatus.data); } catch (err) { diff --git a/extension/background.js b/extension/background.js index 056ae09..e464500 100644 --- a/extension/background.js +++ b/extension/background.js @@ -61,7 +61,10 @@ webpg.background = { /* Check to make sure all of the enabled_keys are private keys this would occur if the key was enabled and then the secret key was deleted. */ + webpg.default_key = webpg.preferences.default_key.get(); webpg.secret_keys = webpg.plugin.getPrivateKeyList(); + for (var sKey in webpg.secret_keys) + webpg.secret_keys[sKey].default = (sKey == webpg.default_key); webpg.enabled_keys = webpg.preferences.enabled_keys.get(); var secret_keys = webpg.secret_keys; var enabled_keys = webpg.enabled_keys; @@ -210,8 +213,10 @@ webpg.background = { break; case 'sign': - var signing_key = webpg.preferences.default_key.get() - var sign_status = webpg.plugin.gpgSignText([signing_key], + var signers = (typeof(request.signers)!=undefined + && request.signers != null + && request.signers.length > 0) ? request.signers : [webpg.preferences.default_key.get()] + var sign_status = webpg.plugin.gpgSignText(signers, request.selectionData.selectionText, 2); response = sign_status; if (!sign_status.error && sign_status.data.length > 0) { @@ -343,10 +348,13 @@ webpg.background = { case 'encrypt': var sign = (typeof(request.sign)=='undefined' || request.sign == false) ? 0 : 1; + var signers = (typeof(request.signers)!=undefined + && request.signers != null + && request.signers.length > 0) ? request.signers : []; if (request.recipients.length > 0) { //console.log(request.data, request.recipients); response = webpg.plugin.gpgEncrypt(request.data, - request.recipients, sign); + request.recipients, sign, signers); } else { response = ""; } @@ -364,7 +372,7 @@ webpg.background = { //console.log("encrypt requested"); if (request.recipients && request.recipients.length > 0) { response = webpg.plugin.gpgEncrypt(request.data, - request.recipients, 1); + request.recipients, 1, request.signers); } else { response = ""; } @@ -378,7 +386,7 @@ webpg.background = { case 'symmetricEncrypt': //console.log("symmetric encryption requested"); - response = webpg.plugin.gpgSymmetricEncrypt(request.data, 0); + response = webpg.plugin.gpgSymmetricEncrypt(request.data, 0, []); if (request.message_event == "context" || request.message_event == "editor") webpg.utils.tabs.sendRequest(sender.tab, { "msg": "insertEncryptedData", diff --git a/extension/dialog.js b/extension/dialog.js index 1467518..a5bc0d5 100644 --- a/extension/dialog.js +++ b/extension/dialog.js @@ -180,6 +180,10 @@ webpg.dialog = { var post_selection = unescape(webpg.dialog.qs.post_selection) || ""; var iframe_id = window.name; + + var signers = (webpg.dialog.qs.signers!=undefined + && unescape(webpg.dialog.qs.signers)!=null) ? + [unescape(webpg.dialog.qs.signers)] : null; webpg.utils.sendRequest({"msg": "encrypt", "data": unescape(webpg.dialog.qs.encrypt_data), @@ -187,6 +191,7 @@ webpg.dialog = { "post_selection": post_selection, "recipients": webpg.dialog.selectedKeys, "sign": (webpg.dialog.qs.dialog_type == "encryptsign"), + "signers": signers, "target_id": iframe_id, "iframe_id": iframe_id}); } diff --git a/extension/gmail.js b/extension/gmail.js index ce4d9b6..0c27cd8 100644 --- a/extension/gmail.js +++ b/extension/gmail.js @@ -17,7 +17,7 @@ webpg.gmail = { navDiv - The navigation div from the gmail interface we will be working with */ setup: function(navDiv) { - if (navDiv.find("#webpg-action-menu").length < 1) { + if (navDiv.find(".webpg-action-menu").length < 1) { // If we are running Mozilla, inject the CSS file if (webpg.utils.detectedBrowser['vendor'] == "mozilla") { var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"] @@ -208,6 +208,7 @@ webpg.gmail = { return; } webpg.utils.sendRequest({'msg': 'sign', + 'signers': webpg.gmail.signers, 'message_event': 'gmail', 'selectionData': { 'selectionText': webpg.utils.linkify(message) @@ -219,6 +220,9 @@ webpg.gmail = { response.result.data ); webpg.gmail.emulateMouseClick(webpg.gmail.oSendBtn[0]); + } else { + var result = response.result; + webpg.gmail.handleFailure(result); } }); break; @@ -244,6 +248,7 @@ webpg.gmail = { webpg.utils.sendRequest({'msg': 'encryptSign', 'data': message, 'recipients': users, + 'signers': webpg.gmail.signers, 'message_event': 'gmail' }, function(response) { if (!response.result.error && response.result.data) { @@ -544,117 +549,169 @@ webpg.gmail = { this.oSendBtn.hide(); var action_menu = '' + -'' + - '' + - 'WebPG' + -'' + -' ' + -'' + - ' ' + -''; - - var action_list = '' + -''; + '' + + '' + + '' + + 'WebPG' + + '' + + ' ' + + '' + + ' ' + + '' + + ''; + + var action_list = '' + + '' + + '' + + ''; if (webpg.gmail.gmailComposeType == "inline") { esBtn.html(action_menu); var canvasFrame = webpg.gmail.getCanvasFrame(); var action_list_el = webpg.gmail.getCanvasFrameDocument().createElement("span"); + webpg.jq(action_list_el).html(action_list); if (webpg.gmail.getCanvasFrame().find(".Hp").length < 1) { - webpg.jq(action_list_el).html(action_list); navDiv.context.ownerDocument.querySelector('.aDh').appendChild(action_list_el); } else { - webpg.jq(action_list_el).html(action_list); navDiv.context.ownerDocument.querySelector('div>.nH.nH .aaZ, div>.nH.nH .ip.adB').firstChild.appendChild(action_list_el); } + webpg.gmail.action_list = webpg.jq(action_list_el).find('ul.webpg-action-list'); + webpg.inline.createWebPGActionMenu(action_list_el, esBtn); } else { esBtn.html(action_menu + action_list); + webpg.gmail.action_list = esBtn.find('ul.webpg-action-list'); + webpg.inline.createWebPGActionMenu(esBtn, esBtn); } esBtn.click(function(e) { - var list = webpg.jq(this).closest('.webpg-modified').find('.webpg-action-list'); - list[0].style.display = (list[0].style.display == "inline") ? "none" : "inline"; - }).bind('mouseleave', function(e) { - if (webpg.gmail.gmailComposeType != "inline") { - var list = webpg.jq(this).closest('.webpg-modified').find('.webpg-action-list'); - if (list[0].style.display == "inline") - webpg.jq(this).click(); + if (e.target.className != "webpg-subaction-btn" + && e.target.parentElement.className != "webpg-subaction-btn") { + webpg.gmail.action_list.css({ + 'display': (webpg.gmail.action_list[0].style.display == 'inline') ? 'none' : 'inline' + }); + webpg.gmail.action_list.find('.webpg-subaction-list').hide(); + if (webpg.gmail.gmailComposeType == "inline") { + webpg.gmail.action_list.find('ul.webpg-subaction-list').css({'top': 'auto', 'bottom': '0'}); + } } }); - esBtn.closest('.webpg-modified').find(".webpg-action-btn").click(function(e) { - var newIcon = webpg.jq(this).find("img")[0]; - var newText = webpg.jq(this).find("a").text(); - + webpg.gmail.action_list.bind('mouseleave', function(e) { + webpg.jq(this).hide(); + }); + + webpg.gmail.action_list.find('a').click(function(e) { + var newIcon = (this.id.indexOf("0x") > -1) ? + webpg.jq(this).parent().parent().parent().find('a img')[0] : + webpg.jq(this).find("img")[0]; + var newText = (this.id.indexOf("0x") > -1) ? + webpg.jq(this).parent().parent().parent().find('a').first().text() : + webpg.jq(this).text(); + if (webpg.gmail.gmailComposeType == "inline") { - this.parentNode.style.display = "none"; newText = "WebPG"; + esBtn.click(); } - - webpg.jq(this).closest('.webpg-modified').find("#webpg-current-action") + + webpg.jq(this).closest('.webpg-modified').find(".webpg-current-action") .html("" + webpg.utils.escape(newText)); - var action = this.id.split("-")[1]; + var action = this.className.split("-")[2]; switch (action) { - case "crypt": + case "encrypt": webpg.gmail.removeStatusLine(); webpg.gmail.checkRecipients(); webpg.gmail.action = 1; + esBtn.attr('data-tooltip', _("Encrypt")); break; case "sign": webpg.gmail.removeStatusLine(); webpg.gmail.action = 2; + esBtn.attr('data-tooltip', _("Sign Only")); break; - case "scrypt": + case "cryptsign": webpg.gmail.removeStatusLine(); webpg.gmail.checkRecipients(); webpg.gmail.action = 3; + esBtn.attr('data-tooltip', _("Sign and Encrypt")); break; - case "symmetric": + case "symcrypt": webpg.gmail.removeStatusLine(); webpg.gmail.action = 4; + esBtn.attr('data-tooltip', _("Symmetric Encryption")); break; default: webpg.gmail.removeStatusLine(); webpg.gmail.action = 0; + esBtn.attr('data-tooltip', _("Do not use WebPG for this message")); + } + + webpg.gmail.signers = (this.id.search("0x") == 0) ? + [e.currentTarget.id.substr(2)] : null; + + if (this.id.search("0x") == 0) { + webpg.jq(this).parent().parent().find('a img').css({'opacity': '0'}); + webpg.jq(this).find('img').css({'opacity': '1.0'}); } }); }, diff --git a/extension/inline.js b/extension/inline.js index 3a96bc0..def6a44 100644 --- a/extension/inline.js +++ b/extension/inline.js @@ -647,6 +647,257 @@ webpg.inline = { } }, + createSecretKeySubmenu: function(purpose, action) { + var _ = webpg.utils.i18n.gettext; + var submenu = ""; + for (var key in webpg.inline.secret_keys) { + if (webpg.inline.secret_keys[key]['can_' + purpose] + && webpg.inline.secret_keys[key].revoked == false + && webpg.inline.secret_keys[key].expired == false + && webpg.inline.secret_keys[key].disabled == false) { + var keyObj = webpg.inline.secret_keys[key]; + var email = (keyObj.email.length > 1) ? + "<" + webpg.utils.escape(keyObj.email) + ">" : + "(" + _("no email address provided") + ")"; + var detail = webpg.utils.escape(keyObj.subkeys[0].size) + + webpg.utils.escape(keyObj.subkeys[0].algorithm_name)[0].toUpperCase() + + "/" + key.substr(-8); + var opacity = (keyObj.default == true) ? 1.0 : 0; + submenu += '' + + '
  • ' + + '' + + keyObj.name + ' ' + "(" + detail + ")
    " + email + + '' + + '
    ' + + '
  • ' + } + } + return submenu; + }, + + createWebPGActionMenu: function(toolbar, gmail) { + var _ = webpg.utils.i18n.gettext; + + if (!gmail) { + webpg.jq(toolbar).find('.webpg-action-menu').css({ + 'padding': '0 8px', + 'cursor': 'pointer', + 'height': '24px', + 'background': '#aaa url(' + webpg.utils.escape(webpg.utils.resourcePath) + 'skin/images/menumask.png) repeat-x', + 'border-radius': '0 4px 4px 0', + 'display': 'inline-block', + 'border-right': '1px solid #999', + }).hover( + function(e) { + if (webpg.jq(toolbar).find('.webpg-action-list')[0].style.display != 'inline') { + webpg.jq(this).css({ + 'background-color': '#f92', + }) + } + }, + function(e) { + if (webpg.jq(toolbar).find('.webpg-action-list')[0].style.display != 'inline') { + webpg.jq(this).css({ + 'background-color': '#aaa', + }) + } + } + ); + } + + webpg.jq(toolbar).find('.webpg-action-menu .webpg-action-list-icon').css({ + 'display': 'inline-block', 'width': '0', + 'height': '0', 'text-indent': '-9999px', + 'position': 'relative', 'top': '-3px', + 'border-left': '4px solid transparent', + 'border-right': '4px solid transparent', + 'border-top': '4px solid #000000', + 'opacity': '0.7', 'content': '\\2193', + }); + if (webpg.utils.detectedBrowser['vendor'] == 'mozilla' + && gmail) { + webpg.jq(toolbar).find('.webpg-action-menu .webpg-action-list-icon').css({ + 'top': '10px', + }); + } + webpg.jq(toolbar).find('.webpg-toolbar-sign-callout .webpg-action-list-icon').css({ + 'display': 'inline-block', 'width': '0', + 'height': '0', 'text-indent': '-9999px', + 'position': 'relative', 'top': '48%', + 'border-left': '4px solid transparent', + 'border-right': '4px solid transparent', + 'border-top': '4px solid #000000', + 'opacity': '0.7', 'content': "\\2193", + }); + webpg.jq(toolbar).find('.webpg-toolbar-sign-callout').css({ + 'display': (Object.keys(webpg.inline.secret_keys).length < 2) ? 'none' : 'inline-block', + }); + webpg.jq(toolbar).find('ul.webpg-action-list, ul.webpg-subaction-list').css({ + 'position': 'absolute', 'top': '100%', 'left': '-2px', + 'z-index': '4', 'float': 'left', 'display': 'none', + 'min-width': '200px', 'padding': '0', 'margin': '0', + 'list-style': 'none', 'background-color': '#ffffff', + 'border-color': '#ccc', 'border-color': 'rgba(0, 0, 0, 0.2)', + 'border-style': 'solid', 'border-width': '1px', + '-webkit-border-radius': '0 4px 4px 4px', + '-moz-border-radius': '0 4px 4px 4px', + 'border-radius': '0 4px 4px 4px', + '-webkit-box-shadow': '0 5px 10px rgba(0, 0, 0, 0.2)', + '-moz-box-shadow': '0 5px 10px rgba(0, 0, 0, 0.2)', + 'box-shadow': '0 5px 10px rgba(0, 0, 0, 0.2)', + '-webkit-background-clip': 'padding-box', + '-moz-background-clip': 'padding', + 'background-clip': 'padding-box', + '*border-right-width': '2px', + '*border-bottom-width': '2px', + 'text-align': 'left', + }); + if (gmail) { + if (webpg.gmail.gmailComposeType == "inline") { + webpg.jq('.nH.nn .no .nH.nn.aQK').css({'width': '600px'}).parent().parent().css({'width': '600px'}) + webpg.jq(toolbar).find('ul.webpg-action-list').css({ + 'top': 'auto', 'bottom': '36px', 'left': '6px' + }); + webpg.jq("*[g_editable='true']").focus(); + } + webpg.jq('.webpg-subaction-btn .webpg-action-list-icon').css({ 'top': '0' }) + } + webpg.jq(toolbar).find('.webpg-action-list li').css({ + 'border-style': 'solid', 'border-width': '1px', + '-webkit-border-radius': '4px 4px 4px 4px', + '-moz-border-radius': '4px 4px 4px 4px', + 'border-radius': '4px 4px 4px 4px', + 'border-color': 'transparent', + }); + webpg.jq(toolbar).find('.webpg-action-list li, .webpg-subaction-list li').css({ + 'font-size': '12px', + 'height': '28px', + 'line-height': '24px', + 'position': 'relative', + 'padding': '0 6px 2px 6px', + 'display': 'block', + 'float': 'none', + }).hover( + function(e) { + webpg.jq(this).css({ + 'background-color': '#e6e6e6', + 'background-image': 'url("' + webpg.utils.escape(webpg.utils.resourcePath) + 'skin/images/menumask.png")', + 'background-repeat': 'repeat-x', + 'border-color': '#ccc', 'border-color': 'rgba(0, 0, 0, 0.2)', + }) + }, + function(e) { + webpg.jq(this).css({ + 'background-color': 'transparent', + 'background-image': 'none', + 'border-color': 'transparent', + }) + } + ).find('.webpg-li-icon').css({ + 'width': '24px', + 'height': '24px', + 'padding': '0 4px 0 4px', + 'margin': '0', + 'position': 'relative', + 'top': '5px', + }); + webpg.jq(toolbar).find('.webpg-subaction-btn').css({ + 'top': '-1', 'padding': '0 8px 2px 8px', 'margin-right': '-5px', + 'border-style': 'solid', 'border-width': '1px', + '-webkit-border-radius': '0 4px 4px 0', + '-moz-border-radius': '0 4px 4px 0', + 'border-radius': '0 4px 4px 0', + }) + webpg.jq(toolbar).find('.webpg-subaction-list').css({ + 'top': '0', 'left': '100%', + }); + webpg.jq(toolbar).find('.webpg-action-divider').css({ + 'border-width': '1px 0 0 0', + 'border-style': 'solid', + 'border-color': 'rgba(0, 0, 0, 0.1)', + 'height': '0', + 'font-size': '1px', + 'padding': '0', + }); + webpg.jq(toolbar).find('img').css({ + 'display': 'inline-block', + 'margin': '0', + }); + webpg.jq(toolbar).find('.webpg-action-btn img').css({ + 'width': '20px', + 'height': '20px', + }); + webpg.jq(toolbar).find('.webpg-action-list a').css({ + 'display': 'block', + 'text-decoration': 'none', + 'color': 'black', + 'position': 'relative', + 'height': '32px', + 'text-shadow': 'none', + 'cursor': 'pointer', + 'white-space': 'nowrap', + }); + webpg.jq(toolbar).find('.webpg-subaction-list a').css({ + 'padding-top': '3px', + 'line-height': '12px', + 'padding-right': '30px', + }); + + if (!gmail) { + webpg.jq(toolbar).children(":first").click(function(e) { + webpg.jq(toolbar).find('.webpg-action-menu').css({ + 'background-color': '#fa3', + }) + var list = webpg.jq(toolbar).find('.webpg-action-list'); + list.css({ + 'display': (this.style.display == 'inline') ? 'none' : 'inline' + }); + }); + } + webpg.jq(toolbar).find('.webpg-subaction-btn').click(function(e) { + var list = webpg.jq(this).parent().parent().find('.webpg-subaction-list'); + list[0].seen = false; + list[0].style.display = (list[0].style.display == "inline") ? "none" : "inline"; + }).hover(function(e) { + var list = webpg.jq(this).parent().parent().find('.webpg-subaction-list'); + if (e.type == "mouseleave" && list[0].seen) + list[0].style.display = "none"; + }); + webpg.jq(toolbar).find('.webpg-subaction-list').hover(function(e) { + if (e.type == "mouseleave") + this.style.display = 'none'; + }); + webpg.jq(toolbar).find('.webpg-subaction-list li').hover( + function(e) { + this.parentElement.seen = true; + var toolbarStatus = (!gmail) ? webpg.jq(toolbar).find('.webpg-toolbar-status') : gmail.children().first(); + this.oldStatusText = toolbarStatus.html(); + if (e.type == "mouseenter" && toolbarStatus) { + var key = webpg.jq(this).find('a')[0].id.substr(2); + var keyObj = webpg.inline.secret_keys[key]; + if (keyObj) { + var detail = webpg.utils.escape(keyObj.subkeys[0].size) + + webpg.utils.escape(keyObj.subkeys[0].algorithm_name)[0].toUpperCase() + + "/" + key.substr(-8); + var keyText = (keyObj.email.length > 0) ? webpg.utils.escape(keyObj.email) : + webpg.utils.escape(keyObj.name); + keyText += " (" + detail + ")"; + toolbarStatus.text(_("Use") + " " + keyText); + } + } else { + if (this.oldStatusText) + toolbarStatus.text(this.oldStatusText); + } + }, + function(e) { + var toolbarStatus = (!gmail) ? webpg.jq(toolbar).find('.webpg-toolbar-status') : gmail.children().first(); + if (this.oldStatusText) + toolbarStatus.html(this.oldStatusText); + } + ); + + }, + addWebPGMenuBar: function(element) { var _ = webpg.utils.i18n.gettext; // Store the elements display setting in case modifying the dom @@ -663,7 +914,7 @@ webpg.inline = { "skin/images/menumask.png') repeat-x; border-collapse: separate;" + "color:#444; height:24px; margin: 1px 0 0 1px; display: block;" + "border: 1px solid gainsboro; top: 27px; clear: left; line-height: 12px;" + - "z-index: 2; left: -1px; text-shadow: none; text-decoration: none;"); + "left: -1px; text-shadow: none; text-decoration: none;"); toolbar.setAttribute("class", "webpg-toolbar"); var offset = (element.scrollHeight > element.offsetHeight) ? @@ -699,16 +950,38 @@ webpg.inline = { '' + '' + '
  • ' + - '' + + '' + '' + _('Sign only') + '' + + '' + + '' + '
  • ' + '
  • ' + '' + '' + _('Sign and Encrypt') + '' + + '' + + '' + '
  • ' + '
  • ' + '' + @@ -771,6 +1044,13 @@ webpg.inline = { detectElementValue(element); function setActive(e) { + if (e.toElement + && e.toElement.parentElement + && (e.toElement.parentElement.className == "webpg-subaction-list" + || (e.toElement.parentElement.parentElement + && e.toElement.parentElement.parentElement.className == "webpg-subaction-list"))) + return; + detectElementValue(element); // Get the current textarea value or selection var selection = { 'selectionText': element.value, @@ -873,126 +1153,11 @@ webpg.inline = { element.updateElementValue = detectElementValue; - webpg.jq(toolbar).find('.webpg-action-menu').css({ - 'padding': '0 8px', - 'cursor': 'pointer', - 'height': '24px', - 'background': '#aaa url(' + webpg.utils.escape(webpg.utils.resourcePath) + 'skin/images/menumask.png) repeat-x', - 'border-radius': '0 4px 4px 0', - 'display': 'inline-block', - 'border-right': '1px solid #999', - }).hover( - function(e) { - if (webpg.jq(toolbar).find('.webpg-action-list')[0].style.display != 'inline') { - webpg.jq(this).css({ - 'background-color': '#f92', - }) - } - }, - function(e) { - if (webpg.jq(toolbar).find('.webpg-action-list')[0].style.display != 'inline') { - webpg.jq(this).css({ - 'background-color': '#aaa', - }) - } - } - ); + webpg.inline.createWebPGActionMenu(toolbar); - webpg.jq(toolbar).find('.webpg-action-list-icon').css({ - 'display': 'inline-block', 'width': '0', - 'height': '0', 'text-indent': '-9999px', - 'position': 'relative', 'top': '-3px', - 'border-left': '4px solid transparent', - 'border-right': '4px solid transparent', - 'border-top': '4px solid #000000', - 'opacity': '0.7', 'content': '\\2193', - }); - webpg.jq(toolbar).find('ul.webpg-action-list').css({ - 'position': 'absolute', 'top': '100%', 'left': '-2px', - 'z-index': '4', 'float': 'left', 'display': 'none', - 'min-width': '200px', 'padding': '0', 'margin': '0', - 'list-style': 'none', 'background-color': '#ffffff', - 'border-color': '#ccc', 'border-color': 'rgba(0, 0, 0, 0.2)', - 'border-style': 'solid', 'border-width': '1px', - '-webkit-border-radius': '0 4px 4px 4px', - '-moz-border-radius': '0 4px 4px 4px', - 'border-radius': '0 4px 4px 4px', - '-webkit-box-shadow': '0 5px 10px rgba(0, 0, 0, 0.2)', - '-moz-box-shadow': '0 5px 10px rgba(0, 0, 0, 0.2)', - 'box-shadow': '0 5px 10px rgba(0, 0, 0, 0.2)', - '-webkit-background-clip': 'padding-box', - '-moz-background-clip': 'padding', - 'background-clip': 'padding-box', - '*border-right-width': '2px', - '*border-bottom-width': '2px', - 'text-align': 'left', - }); - webpg.jq(toolbar).find('.webpg-action-list li').css({ - 'font-size': '12px', - 'height': '28px', - 'line-height': '24px', - 'position': 'relative', - 'padding': '0 6px 2px 6px', - 'display': 'block', - 'float': 'none', - }).hover( - function(e) { - webpg.jq(this).css({ - 'background-color': '#e6e6e6', - 'background-image': 'url("' + webpg.utils.escape(webpg.utils.resourcePath) + 'skin/images/menumask.png")', - 'background-repeat': 'repeat-x', - }) - }, - function(e) { - webpg.jq(this).css({ - 'background-color': 'transparent', - 'background-image': 'none', - }) - } - ).find('.webpg-li-icon').css({ - 'width': '24px', - 'height': '24px', - 'padding': '0 4px 0 4px', - 'margin': '0', - 'position': 'relative', - 'top': '5px', - }); - webpg.jq(toolbar).find('.webpg-action-divider').css({ - 'border-width': '1px 0 0 0', - 'border-style': 'solid', - 'border-color': 'rgba(0, 0, 0, 0.1)', - 'height': '0', - 'font-size': '1px', - 'padding': '0', - }); - webpg.jq(toolbar).find('img').css({ - 'display': 'inline-block', - 'margin': '0', - }); - webpg.jq(toolbar).find('.webpg-action-btn img').css({ - 'width': '20px', - 'height': '20px', - }); - webpg.jq(toolbar).find('.webpg-action-list a').css({ - 'display': 'block', - 'text-decoration': 'none', - 'color': 'black', - 'position': 'relative', - 'height': '32px', - 'text-shadow': 'none', - 'cursor': 'pointer', - }); - - webpg.jq(toolbar).children(":first").click(function(e) { - webpg.jq(toolbar).find('.webpg-action-menu').css({ - 'background-color': '#fa3', - }) - var list = webpg.jq(toolbar).find('.webpg-action-list'); - list[0].style.display = (list[0].style.display == "inline") ? "none" : "inline"; - }); webpg.jq(toolbar).bind('mouseleave', function() { if (webpg.jq(toolbar).find('.webpg-action-list')[0].style.display == "inline") { - webpg.jq(toolbar).find('.webpg-action-list').hide(); + webpg.jq(toolbar).find('.webpg-action-list, .webpg-subaction-list').hide(); webpg.jq(toolbar).find('.webpg-action-menu').css({ 'background-color': '#aaa', }) @@ -1046,7 +1211,12 @@ webpg.inline = { if (action) { if (action != webpg.constants.overlayActions.EDITOR) webpg.overlay.block_target = true; - webpg.overlay.onContextCommand(null, action, {'source': 'toolbar', 'dialog': (isSecure(element) == true)}, selection); + signers = (e.currentTarget + && e.currentTarget.id + && e.currentTarget.id.search("0x") == 0) ? + [e.currentTarget.id.substr(2)] : null; + + webpg.overlay.onContextCommand(null, action, {'source': 'toolbar', 'dialog': (isSecure(element) == true), 'signers': signers}, selection); } webpg.inline.action_selected = (action != webpg.constants.overlayActions.OPTS && action != webpg.constants.overlayActions.MANAGER); @@ -1057,7 +1227,7 @@ webpg.inline = { if (webpg.utils.detectedBrowser['vendor'] == 'mozilla') { webpg.jq(toolbar).css({ 'top': '28px' }); - webpg.jq(toolbar).find('.webpg-action-list-icon').css({ 'top': '6px' }); + webpg.jq(toolbar).find('.webpg-action-menu .webpg-action-list-icon').css({ 'top': '6px' }); } }, diff --git a/extension/key_manager.js b/extension/key_manager.js index 735fadb..86a9c46 100644 --- a/extension/key_manager.js +++ b/extension/key_manager.js @@ -1779,6 +1779,10 @@ webpg.keymanager = { } console.log(".*-key-option-button pressed..", params); if (refresh) { + var default_key = webpg.preferences.default_key.get(); + webpg.background.webpg.secret_keys = webpg.plugin.getPrivateKeyList(); + for (var sKey in webpg.background.webpg.secret_keys) + webpg.background.webpg.secret_keys[sKey].default = (sKey == default_key); if (params[1] == "subkey") params[1] = "private"; webpg.keymanager.buildKeylistProxy(null, params[1], params[2], null, null); @@ -2148,6 +2152,8 @@ webpg.keymanager = { }).click(function(e) { var keyid = this.id.substr(-16); webpg.preferences.default_key.set(keyid); + for (var sKey in webpg.background.webpg.secret_keys) + webpg.background.webpg.secret_keys[sKey].default = (sKey == keyid); var enable_element = webpg.jq('#check-' + this.id.substr(-16))[0]; var enabled_keys = webpg.preferences.enabled_keys.get(); if (enabled_keys.indexOf(keyid) == -1) { diff --git a/extension/manifest.json b/extension/manifest.json index deabf76..18a11e9 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -13,6 +13,7 @@ "dialog.js", "skin/gmail_overlay.css", "skin/images/menumask.png", + "skin/images/check-small.png", "skin/images/badges/32x32/webpg.png", "skin/images/badges/48x48/webpg.png", "skin/images/badges/20x20/stock_keypair.png", diff --git a/extension/plugins/Darwin_x86-gcc/npwebpg-ext-v0.6.5-Darwin_x86_64-gcc.plugin/Contents/MacOS/webpgPlugin b/extension/plugins/Darwin_x86-gcc/npwebpg-ext-v0.6.5-Darwin_x86_64-gcc.plugin/Contents/MacOS/webpgPlugin index cd5e07e..6721463 100755 Binary files a/extension/plugins/Darwin_x86-gcc/npwebpg-ext-v0.6.5-Darwin_x86_64-gcc.plugin/Contents/MacOS/webpgPlugin and b/extension/plugins/Darwin_x86-gcc/npwebpg-ext-v0.6.5-Darwin_x86_64-gcc.plugin/Contents/MacOS/webpgPlugin differ diff --git a/extension/plugins/Linux_x86-gcc/npwebpg-ext-v0.6.5-Linux_x86-gcc.so b/extension/plugins/Linux_x86-gcc/npwebpg-ext-v0.6.5-Linux_x86-gcc.so index a153c49..660aebd 100755 Binary files a/extension/plugins/Linux_x86-gcc/npwebpg-ext-v0.6.5-Linux_x86-gcc.so and b/extension/plugins/Linux_x86-gcc/npwebpg-ext-v0.6.5-Linux_x86-gcc.so differ diff --git a/extension/plugins/Linux_x86_64-gcc/npwebpg-ext-v0.6.5-Linux_x86_64-gcc.so b/extension/plugins/Linux_x86_64-gcc/npwebpg-ext-v0.6.5-Linux_x86_64-gcc.so index b2c6549..4573c97 100755 Binary files a/extension/plugins/Linux_x86_64-gcc/npwebpg-ext-v0.6.5-Linux_x86_64-gcc.so and b/extension/plugins/Linux_x86_64-gcc/npwebpg-ext-v0.6.5-Linux_x86_64-gcc.so differ diff --git a/extension/plugins/WINNT_x86-msvc/npwebpg-ext-v0.6.5-WINNT_x86-msvc.dll b/extension/plugins/WINNT_x86-msvc/npwebpg-ext-v0.6.5-WINNT_x86-msvc.dll index ed0641a..77b29d3 100755 Binary files a/extension/plugins/WINNT_x86-msvc/npwebpg-ext-v0.6.5-WINNT_x86-msvc.dll and b/extension/plugins/WINNT_x86-msvc/npwebpg-ext-v0.6.5-WINNT_x86-msvc.dll differ diff --git a/extension/skin/gmail_overlay.css b/extension/skin/gmail_overlay.css index 08d2a4a..f9ecfeb 100644 --- a/extension/skin/gmail_overlay.css +++ b/extension/skin/gmail_overlay.css @@ -3,7 +3,7 @@ display:inline-block; width: auto; } -#webpg-action-menu img { +#webpg-action-menu .webpg-current-action img { position:relative; top:4px; left:-4px; @@ -11,6 +11,9 @@ #webpg-action-menu.rtl img { padding-left: 8px; } +.webpg-subaction-btn { + top: -1px; +} .webpg-action-list-icon { display:inline-block; width:0; @@ -25,40 +28,6 @@ opacity:0.7; content:"\2193"; } -.webpg-action-list { - position:absolute; - top:100%; - left:0; - z-index:9999; - float:left; - display:none; - min-width:130px; - _width:130px; - padding:0; - margin:0; - list-style:none; - background-color:#ffffff; - border-color:#ccc; - border-color:rgba(0, 0, 0, 0.2); - border-style:solid; - border-width:1px; - -webkit-border-radius:4px; - -moz-border-radius:4px; - border-radius:4px; - -webkit-box-shadow:0 5px 10px rgba(0, 0, 0, 0.2); - -moz-box-shadow:0 5px 10px rgba(0, 0, 0, 0.2); - box-shadow:0 5px 10px rgba(0, 0, 0, 0.2); - -webkit-background-clip:padding-box; - -moz-background-clip:padding; - background-clip:padding-box; - *border-right-width:2px; - *border-bottom-width:2px; - text-align:left; -} -.webpg-action-list.webpg-gmail-compose-inline { - bottom: 36px; - top: auto; -} .webpg-li-icon { width:20px; height:20px; @@ -68,46 +37,13 @@ display:inline-block; position:relative; } -.webpg-action-list li { - font-size:12px; - height: 28px; - line-height: 24px; - position:relative; - padding:0 6px 2px 6px; - display:block; - float: none; -} -.webpg-action-list li:hover { - background-color:#e6e6e6; - background-position:0 -15px; - -webkit-transition:background-position 0.1s linear; - -moz-transition:background-position 0.1s linear; - -ms-transition:background-position 0.1s linear; - -o-transition:background-position 0.1s linear; - transition:background-position 0.1s linear; -} -.webpg-action-btn a { - text-decoration:none !important; - display:block; - color:black; -} -.webpg-action-list a { - display: block; - text-decoration:none; - color:black !important; - position: relative; - height: 32px; - text-shadow: none; - cursor: pointer; +.webpg-subaction-list { + background: #fff; } .webpg-status-line { color:#f11; font-size:13px; text-shadow:#886 0.5px 1px 1px; -/* background-color:#fff;*/ -/* -webkit-box-shadow:0 5px 10px rgba(0, 0, 0, 0.2);*/ -/* -moz-box-shadow:0 5px 10px rgba(0, 0, 0, 0.2);*/ -/* box-shadow:0 5px 10px rgba(0, 0, 0, 0.2);*/ border-radius:3px; } .webpg-gmail-status-line { @@ -130,11 +66,11 @@ div.webpg-gmail-status-line { #webpg-action-menu.webpg-gmail-compose-inline { top:0; } - #webpg-current-action { + .webpg-current-action { position:relative; top:-3px; } .webpg-action-list-icon { - top:12px; + top: 10px; } } diff --git a/extension/webpg_overlay.js b/extension/webpg_overlay.js index 2d65482..b9d3d26 100644 --- a/extension/webpg_overlay.js +++ b/extension/webpg_overlay.js @@ -84,15 +84,25 @@ webpg.overlay = { if (response.result.decorate_inline == "true") { var mode = response.result.mode; if (webpg.utils.detectedBrowser['vendor'] == "mozilla") { - if (!webpg.plugin) { + if (!browserWindow) var browserWindow = webpg.utils.mozilla.getChromeWindow(); + if (!webpg.plugin) webpg.plugin = browserWindow.webpg.plugin; - } + // Add a reference to the secret keys information store + webpg.inline.secret_keys = browserWindow.webpg.secret_keys; // Begin parsing the document for PGP Data webpg.inline.init(webpg.doc, mode); } else if (webpg.utils.detectedBrowser['product'] == "chrome") { - webpg.inline.init(document, mode); + webpg.utils.sendRequest({ + 'msg': "private_keylist" }, + function(response) { + // Add a reference to the secret keys information store + webpg.inline.secret_keys = (response.result) ? + response.result : []; + webpg.inline.init(document, mode); + } + ); } } } @@ -294,6 +304,8 @@ webpg.overlay = { theURL += "&import_data=" + escape(request.data); if (request.dialog_type == "editor") theURL += "&editor_data=" + escape(request.data); + if (request.signers != null) + theURL += "&signers=" + escape(request.signers); var win = (webpg.utils.detectedBrowser['vendor'] == 'mozilla') ? content : window; @@ -396,7 +408,8 @@ webpg.overlay = { webpg.overlay.block_target = true; webpg.utils.sendRequest({ "msg": "sign", - "selectionData": selection + "selectionData": selection, + "signers": sender.signers, }); break; @@ -433,7 +446,8 @@ webpg.overlay = { 'data': selection.selectionText, 'pre_selection': selection.pre_selection, 'post_selection': selection.post_selection, - 'dialog_type': dialog_type + 'dialog_type': dialog_type, + 'signers': sender.signers, }); break;