OpenPGP - part 3 - unstable (#53)

This commit is contained in:
RainLoop Team 2014-01-29 03:53:30 +04:00
parent 0bb69d4494
commit 3d3ad8d459
14 changed files with 456 additions and 206 deletions

View file

@ -280,6 +280,7 @@ module.exports = function (grunt) {
"dev/ViewModels/PopupsIdentityViewModel.js",
"dev/ViewModels/PopupsLanguagesViewModel.js",
"dev/ViewModels/PopupsAskViewModel.js",
"dev/ViewModels/PopupsPgpKey.js",
"dev/ViewModels/LoginViewModel.js",

View file

@ -41,6 +41,7 @@
@import "SystemDropDown.less";
@import "Login.less";
@import "Ask.less";
@import "Pgp.less";
@import "FolderList.less";
@import "FolderClear.less";
@import "FolderCreate.less";

View file

@ -192,10 +192,6 @@ html.rl-no-preview-pane {
background-color: #ffffd9;
}
.pgpSigned, .pgpEncrypted {
cursor: default;
}
.attachmentsPlace {
padding: 10px;

18
dev/Styles/Pgp.less Normal file
View file

@ -0,0 +1,18 @@
.popups {
.b-pgp-key {
width: 620px;
.modal-header {
background-color: #fff;
}
.inputPassphrase, .inputKey {
width: 575px;
}
.inputKey {
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
}
}
}

View file

@ -201,6 +201,38 @@ MailBoxMessageViewViewModel.prototype.replyOrforward = function (sType)
kn.showScreenPopup(PopupsComposeViewModel, [sType, RL.data().message()]);
};
MailBoxMessageViewViewModel.prototype.receivePrivateKey = function ()
{
var self = this;
kn.showScreenPopup(PopupsPgpKey, [true, function (sPrivatePassphrase, sPrivateKey) {
var oMessage = self.message(), mPgpMessage, mPgpKey, mDecPgpKey;
if (oMessage)
{
try
{
mPgpMessage = window.openpgp.message.readArmored(oMessage.plainRaw);
mPgpKey = window.openpgp.key.readArmored(sPrivateKey);
if (mPgpMessage && mPgpKey && mPgpKey.keys && mPgpKey.keys[0])
{
mDecPgpKey = mPgpKey.keys[0];
if ('' !== sPrivatePassphrase)
{
mDecPgpKey.decrypt(sPrivatePassphrase);
}
oMessage.body.html(
'<pre class="b-plain-openpgp encrypted">' +
window.openpgp.decryptMessage(mDecPgpKey, mPgpMessage) +
'</pre>'
);
}
}
catch (oExt) {}
}
}]);
};
MailBoxMessageViewViewModel.prototype.onBuild = function (oDom)
{
var

View file

@ -0,0 +1,64 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function PopupsPgpKey()
{
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsPgpKey');
this.key = ko.observable('');
this.passphrase = ko.observable('');
this.bPrivate = null;
this.fCallback = null;
// commands
this.sendPgp = Utils.createCommand(this, function () {
var sKey = Utils.trim(this.key());
if (this.fCallback && sKey)
{
this.fCallback(this.passphrase(), sKey);
}
this.cancelCommand();
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsPgpKey', PopupsPgpKey);
PopupsPgpKey.prototype.clearPopup = function ()
{
// this.key('');
// this.passphrase('');
this.bPrivate = null;
this.fCallback = null;
};
PopupsPgpKey.prototype.onBuild = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && self.modalVisibility() && Enums.EventKeyCode.Esc === oEvent.keyCode)
{
Utils.delegateRun(self, 'closeCommand');
bResult = false;
}
return bResult;
});
};
PopupsPgpKey.prototype.onShow = function (bPrivate, fCallback)
{
this.clearPopup();
this.bPrivate = bPrivate;
this.fCallback = fCallback;
};

View file

@ -194,15 +194,15 @@
&nbsp;&nbsp;
<span class="i18n text" data-i18n-text="MESSAGE/BUTTON_NOTIFY_READ_RECEIPT"></span>
</div>
<div class="pgpSigned" data-bind="visible: message() && message().isPgpSigned(), click: function() {}">
<div class="pgpSigned" data-bind="visible: message() && message().isPgpSigned(), click: receivePrivateKey">
<i class="icon-lock"></i>
&nbsp;&nbsp;
PGP signed
PGP signed (click to verify)
</div>
<div class="pgpEncrypted" data-bind="visible: message() && message().isPgpEncrypted(), click: function() {}">
<div class="pgpEncrypted" data-bind="visible: message() && message().isPgpEncrypted(), click: receivePrivateKey">
<i class="icon-lock"></i>
&nbsp;&nbsp;
PGP encrypted
PGP encrypted (click to decrypt)
</div>
<div class="attachmentsPlace" data-bind="visible: message() && message().hasVisibleAttachments()">
<ul class="attachmentList" data-bind="foreach: message() ? message().attachments() : []">

View file

@ -0,0 +1,34 @@
<div class="popups">
<div class="modal hide b-pgp-key g-ui-user-select-none" data-bind="modal: modalVisibility">
<div>
<div class="modal-header">
<button type="button" class="close" data-bind="command: cancelCommand">&times;</button>
<h3>
PGP
</h3>
</div>
<div class="modal-body">
<div class="form-horizontal">
<br />
<div class="control-group">
Passphrase
<br />
<input class="uiInput inputPassphrase" type="password" data-bind="value: passphrase" />
</div>
<div class="control-group">
Secret key
<br />
<textarea class="input-xxlarge inputKey" data-bind="value: key" rows="10" spellcheck="false"></textarea>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn buttonAction" data-bind="command: sendPgp">
<i class="icon-lock"></i>
&nbsp;&nbsp;
Decrypt
</a>
</div>
</div>
</div>
</div>

View file

@ -6285,6 +6285,19 @@ html.rl-no-preview-pane #rl-right .ui-resizable-handle {
.popups .b-ask-content .desc-place {
font-size: 18px;
}
.popups .b-pgp-key {
width: 620px;
}
.popups .b-pgp-key .modal-header {
background-color: #fff;
}
.popups .b-pgp-key .inputPassphrase,
.popups .b-pgp-key .inputKey {
width: 575px;
}
.popups .b-pgp-key .inputKey {
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
}
.b-folders .b-toolbar {
position: absolute;
top: 0;
@ -7075,10 +7088,6 @@ showImages html.rl-no-preview-pane .messageView.message-selected {
.messageView .b-content .messageItem .readReceipt {
background-color: #ffffd9;
}
.messageView .b-content .messageItem .pgpSigned,
.messageView .b-content .messageItem .pgpEncrypted {
cursor: default;
}
.messageView .b-content .messageItem .attachmentsPlace {
padding: 10px;
}

File diff suppressed because one or more lines are too long

View file

@ -10761,6 +10761,69 @@ PopupsAskViewModel.prototype.onBuild = function ()
};
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function PopupsPgpKey()
{
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsPgpKey');
this.key = ko.observable('');
this.passphrase = ko.observable('');
this.bPrivate = null;
this.fCallback = null;
// commands
this.sendPgp = Utils.createCommand(this, function () {
var sKey = Utils.trim(this.key());
if (this.fCallback && sKey)
{
this.fCallback(this.passphrase(), sKey);
}
this.cancelCommand();
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsPgpKey', PopupsPgpKey);
PopupsPgpKey.prototype.clearPopup = function ()
{
// this.key('');
// this.passphrase('');
this.bPrivate = null;
this.fCallback = null;
};
PopupsPgpKey.prototype.onBuild = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && self.modalVisibility() && Enums.EventKeyCode.Esc === oEvent.keyCode)
{
Utils.delegateRun(self, 'closeCommand');
bResult = false;
}
return bResult;
});
};
PopupsPgpKey.prototype.onShow = function (bPrivate, fCallback)
{
this.clearPopup();
this.bPrivate = bPrivate;
this.fCallback = fCallback;
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -12354,6 +12417,38 @@ MailBoxMessageViewViewModel.prototype.replyOrforward = function (sType)
kn.showScreenPopup(PopupsComposeViewModel, [sType, RL.data().message()]);
};
MailBoxMessageViewViewModel.prototype.receivePrivateKey = function ()
{
var self = this;
kn.showScreenPopup(PopupsPgpKey, [true, function (sPrivatePassphrase, sPrivateKey) {
var oMessage = self.message(), mPgpMessage, mPgpKey, mDecPgpKey;
if (oMessage)
{
try
{
mPgpMessage = window.openpgp.message.readArmored(oMessage.plainRaw);
mPgpKey = window.openpgp.key.readArmored(sPrivateKey);
if (mPgpMessage && mPgpKey && mPgpKey.keys && mPgpKey.keys[0])
{
mDecPgpKey = mPgpKey.keys[0];
if ('' !== sPrivatePassphrase)
{
mDecPgpKey.decrypt(sPrivatePassphrase);
}
oMessage.body.html(
'<pre class="b-plain-openpgp encrypted">' +
window.openpgp.decryptMessage(mDecPgpKey, mPgpMessage) +
'</pre>'
);
}
}
catch (oExt) {}
}
}]);
};
MailBoxMessageViewViewModel.prototype.onBuild = function (oDom)
{
var

File diff suppressed because one or more lines are too long