OpenPGP (Compose) (#53) UNSTABLE

This commit is contained in:
RainLoop Team 2014-03-20 02:39:36 +04:00
parent 2bf7c2e033
commit 67b5a72a71
22 changed files with 496 additions and 247 deletions

View file

@ -282,6 +282,7 @@ module.exports = function (grunt) {
"dev/ViewModels/PopupsAddOpenPgpKeyViewModel.js", "dev/ViewModels/PopupsAddOpenPgpKeyViewModel.js",
"dev/ViewModels/PopupsViewOpenPgpKeyViewModel.js", "dev/ViewModels/PopupsViewOpenPgpKeyViewModel.js",
"dev/ViewModels/PopupsGenerateNewOpenPgpKeyViewModel.js", "dev/ViewModels/PopupsGenerateNewOpenPgpKeyViewModel.js",
"dev/ViewModels/PopupsComposeOpenPgpViewModel.js",
"dev/ViewModels/PopupsIdentityViewModel.js", "dev/ViewModels/PopupsIdentityViewModel.js",
"dev/ViewModels/PopupsLanguagesViewModel.js", "dev/ViewModels/PopupsLanguagesViewModel.js",
"dev/ViewModels/PopupsAskViewModel.js", "dev/ViewModels/PopupsAskViewModel.js",

View file

@ -324,7 +324,7 @@ RainLoopApp.prototype.folders = function (fCallback)
RainLoopApp.prototype.reloadOpenPgpKeys = function () RainLoopApp.prototype.reloadOpenPgpKeys = function ()
{ {
if (Globals.bAllowOpenPGP) if (RL.data().allowOpenPGP())
{ {
var var
aKeys = [], aKeys = [],
@ -963,8 +963,8 @@ RainLoopApp.prototype.bootstart = function ()
if (window.openpgp) if (window.openpgp)
{ {
RL.data().openpgpKeyring = new window.openpgp.Keyring(new OpenPgpLocalStorageDriver()); RL.data().openpgpKeyring = new window.openpgp.Keyring(new OpenPgpLocalStorageDriver());
RL.data().allowOpenPGP(true);
Globals.bAllowOpenPGP = true;
RL.pub('openpgp.init'); RL.pub('openpgp.init');
RL.reloadOpenPgpKeys(); RL.reloadOpenPgpKeys();
@ -974,7 +974,7 @@ RainLoopApp.prototype.bootstart = function ()
} }
else else
{ {
Globals.bAllowOpenPGP = false; RL.data().allowOpenPGP(false);
} }
kn.startScreens([MailBoxScreen, SettingsScreen]); kn.startScreens([MailBoxScreen, SettingsScreen]);

View file

@ -65,11 +65,6 @@ Globals.bDisableNanoScroll = Globals.bMobileDevice;
*/ */
Globals.bAllowPdfPreview = !Globals.bMobileDevice; Globals.bAllowPdfPreview = !Globals.bMobileDevice;
/**
* @type {boolean}
*/
Globals.bAllowOpenPGP = false;
/** /**
* @type {boolean} * @type {boolean}
*/ */

View file

@ -456,7 +456,11 @@ ko.bindingHandlers.emailsTags = {
'parseHook': function (aInput) { 'parseHook': function (aInput) {
return _.map(aInput, function (sInputValue) { return _.map(aInput, function (sInputValue) {
var sValue = Utils.trim(sInputValue), oEmail = null; var
sValue = Utils.trim(sInputValue),
oEmail = null
;
if ('' !== sValue) if ('' !== sValue)
{ {
oEmail = new EmailModel(); oEmail = new EmailModel();

View file

@ -4,14 +4,16 @@
* @param {Object} oElement * @param {Object} oElement
* @param {Function=} fOnBlur * @param {Function=} fOnBlur
* @param {Function=} fOnReady * @param {Function=} fOnReady
* @param {Function=} fOnModeChange
*/ */
function NewHtmlEditorWrapper(oElement, fOnBlur, fOnReady) function NewHtmlEditorWrapper(oElement, fOnBlur, fOnReady, fOnModeChange)
{ {
var self = this; var self = this;
self.editor = null; self.editor = null;
self.iBlurTimer = 0; self.iBlurTimer = 0;
self.fOnBlur = fOnBlur || null; self.fOnBlur = fOnBlur || null;
self.fOnReady = fOnReady || null; self.fOnReady = fOnReady || null;
self.fOnModeChange = fOnModeChange || null;
self.$element = $(oElement); self.$element = $(oElement);
@ -162,6 +164,11 @@ NewHtmlEditorWrapper.prototype.init = function ()
self.editor.on('mode', function() { self.editor.on('mode', function() {
self.blurTrigger(); self.blurTrigger();
if (self.fOnModeChange)
{
self.fOnModeChange('plain' !== self.editor.mode);
}
}); });
self.editor.on('focus', function() { self.editor.on('focus', function() {

View file

@ -359,7 +359,7 @@ MessageModel.prototype.initUpdateByMessageJson = function (oJsonMessage)
this.sInReplyTo = oJsonMessage.InReplyTo; this.sInReplyTo = oJsonMessage.InReplyTo;
this.sReferences = oJsonMessage.References; this.sReferences = oJsonMessage.References;
if (Globals.bAllowOpenPGP) if (RL.data().allowOpenPGP())
{ {
this.isPgpSigned(!!oJsonMessage.PgpSigned); this.isPgpSigned(!!oJsonMessage.PgpSigned);
this.isPgpEncrypted(!!oJsonMessage.PgpEncrypted); this.isPgpEncrypted(!!oJsonMessage.PgpEncrypted);

View file

@ -344,6 +344,7 @@ function WebMailDataStorage()
// other // other
this.useKeyboardShortcuts = ko.observable(true); this.useKeyboardShortcuts = ko.observable(true);
this.allowOpenPGP = ko.observable(false);
this.openpgpkeys = ko.observableArray([]); this.openpgpkeys = ko.observableArray([]);
this.openpgpKeyring = null; this.openpgpKeyring = null;
@ -868,7 +869,8 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
bIsHtml = false; bIsHtml = false;
sPlain = oData.Result.Plain.toString(); sPlain = oData.Result.Plain.toString();
if (Globals.bAllowOpenPGP && (oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) && if ((oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) &&
RL.data().allowOpenPGP() &&
Utils.isNormal(oData.Result.PlainRaw)) Utils.isNormal(oData.Result.PlainRaw))
{ {
bPgpEncrypted = /---BEGIN PGP MESSAGE---/.test(oData.Result.PlainRaw); bPgpEncrypted = /---BEGIN PGP MESSAGE---/.test(oData.Result.PlainRaw);
@ -968,7 +970,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
} }
} }
if (Globals.bAllowOpenPGP && oMessage.body) if (oMessage.body && RL.data().allowOpenPGP())
{ {
oMessage.isPgpSigned(!!oMessage.body.data('rl-plain-pgp-signed')); oMessage.isPgpSigned(!!oMessage.body.data('rl-plain-pgp-signed'));
oMessage.isPgpEncrypted(!!oMessage.body.data('rl-plain-pgp-encrypted')); oMessage.isPgpEncrypted(!!oMessage.body.data('rl-plain-pgp-encrypted'));

View file

@ -1,5 +1,5 @@
.popups { .popups {
.b-open-pgp-key-view-content, .b-open-pgp-key-generate-content, .b-open-pgp-key-add-content { .b-open-pgp-key-view-content, .b-open-pgp-key-generate-content, .b-open-pgp-key-add-content, .b-compose-open-pgp-content {
.modal-header { .modal-header {
background-color: #fff; background-color: #fff;

View file

@ -55,6 +55,10 @@ select {
padding-right: 12px; padding-right: 12px;
} }
.btn-group.btn-group-custom-margin > .btn + .btn {
margin-left: 0px;
}
.dropdown-menu { .dropdown-menu {
.border-radius(@btnBorderRadius); .border-radius(@btnBorderRadius);
} }

View file

@ -0,0 +1,64 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function PopupsComposeOpenPgpViewModel()
{
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsComposeOpenPgp');
this.notification = ko.observable('');
this.sign = ko.observable(true);
this.encrypt = ko.observable(true);
this.password = ko.observable('');
this.password.focus = ko.observable(true);
// commands
this.doCommand = Utils.createCommand(this, function () {
this.cancelCommand();
}, function () {
return '' === this.notification();
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsComposeOpenPgpViewModel', PopupsComposeOpenPgpViewModel);
PopupsComposeOpenPgpViewModel.prototype.clearPopup = function ()
{
this.notification('');
this.password('');
this.password.focus(false);
};
PopupsComposeOpenPgpViewModel.prototype.onHide = function ()
{
this.clearPopup();
};
PopupsComposeOpenPgpViewModel.prototype.onShow = function (fCallback, sText, sFromEmail, sTo, sCc, sBcc)
{
this.clearPopup();
if ('' === sTo + sCc + sBcc)
{
this.notification('Please specify at least one recipient');
}
// TODO
};
PopupsComposeOpenPgpViewModel.prototype.onFocus = function ()
{
if (this.sign())
{
this.password.focus(true);
}
};

View file

@ -28,6 +28,8 @@ function PopupsComposeViewModel()
} }
; ;
this.allowOpenPGP = oRainLoopData.allowOpenPGP;
this.resizer = ko.observable(false).extend({'throttle': 50}); this.resizer = ko.observable(false).extend({'throttle': 50});
this.to = ko.observable(''); this.to = ko.observable('');
@ -37,6 +39,7 @@ function PopupsComposeViewModel()
this.replyTo = ko.observable(''); this.replyTo = ko.observable('');
this.subject = ko.observable(''); this.subject = ko.observable('');
this.isHtml = ko.observable(false);
this.requestReadReceipt = ko.observable(false); this.requestReadReceipt = ko.observable(false);
@ -355,6 +358,23 @@ function PopupsComposeViewModel()
Utils.extendAsViewModel('PopupsComposeViewModel', PopupsComposeViewModel); Utils.extendAsViewModel('PopupsComposeViewModel', PopupsComposeViewModel);
PopupsComposeViewModel.prototype.openOpenPgpPopup = function ()
{
if (this.allowOpenPGP() && this.oEditor && !this.oEditor.isHtml())
{
kn.showScreenPopup(PopupsComposeOpenPgpViewModel, [
function () {
},
this.oEditor.getData(),
this.currentIdentityResultEmail(),
this.to(),
this.cc(),
this.bcc()
]);
}
};
PopupsComposeViewModel.prototype.reloadDraftFolder = function () PopupsComposeViewModel.prototype.reloadDraftFolder = function ()
{ {
var sDraftFolder = RL.data().draftFolder(); var sDraftFolder = RL.data().draftFolder();
@ -597,6 +617,8 @@ PopupsComposeViewModel.prototype.editor = function (fOnInit)
_.delay(function () { _.delay(function () {
self.oEditor = new NewHtmlEditorWrapper(self.composeEditorArea(), null, function () { self.oEditor = new NewHtmlEditorWrapper(self.composeEditorArea(), null, function () {
fOnInit(self.oEditor); fOnInit(self.oEditor);
}, function (bHtml) {
self.isHtml(!!bHtml);
}); });
}, 300); }, 300);
} }

View file

@ -21,12 +21,11 @@
</ul> </ul>
</div> </div>
<div class="btn-group">&nbsp;</div> <div class="btn-group">&nbsp;</div>
<div class="btn-group"> <div class="btn-group btn-group-custom-margin">
<a class="btn btn-danger buttonDelete" data-placement="bottom" data-bind="command: deleteCommand, tooltip: 'MESSAGE_LIST/BUTTON_DELETE'"> <a class="btn btn-danger buttonDelete" data-placement="bottom" data-bind="command: deleteCommand, tooltip: 'MESSAGE_LIST/BUTTON_DELETE'">
<i class="icon-trash icon-white"></i> <i class="icon-trash icon-white"></i>
<span data-bind="text: 1 < messageListCheckedOrSelectedUidsWithSubMails().length ? ' (' + messageListCheckedOrSelectedUidsWithSubMails().length + ')' : ''"></span> <span data-bind="text: 1 < messageListCheckedOrSelectedUidsWithSubMails().length ? ' (' + messageListCheckedOrSelectedUidsWithSubMails().length + ')' : ''"></span>
</a> </a>
<!--<span style="font-size:10px;" data-bind="visible: !isSpamFolder() && !isSpamDisabled()">&nbsp;</span>-->
<a class="btn buttonSpam" data-placement="bottom" data-bind="visible: !isSpamFolder() && !isSpamDisabled(), command: spamCommand, tooltip: 'MESSAGE_LIST/BUTTON_SPAM'"> <a class="btn buttonSpam" data-placement="bottom" data-bind="visible: !isSpamFolder() && !isSpamDisabled(), command: spamCommand, tooltip: 'MESSAGE_LIST/BUTTON_SPAM'">
<i class="icon-bug"></i> <i class="icon-bug"></i>
</a> </a>

View file

@ -25,11 +25,10 @@
</a> </a>
</div> </div>
<div class="btn-group">&nbsp;</div> <div class="btn-group">&nbsp;</div>
<div class="btn-group"> <div class="btn-group btn-group-custom-margin">
<a class="btn btn-danger buttonDelete" data-placement="bottom" data-bind="command: $root.deleteCommand, tooltip: 'MESSAGE/BUTTON_DELETE'"> <a class="btn btn-danger buttonDelete" data-placement="bottom" data-bind="command: $root.deleteCommand, tooltip: 'MESSAGE/BUTTON_DELETE'">
<i class="icon-trash icon-white"></i> <i class="icon-trash icon-white"></i>
</a> </a>
<!--<span style="font-size:10px;" data-bind="visible: !$root.isDraftFolder()">&nbsp;</span>-->
<a class="btn buttonSpam" data-placement="bottom" data-bind="visible: !$root.isDraftFolder(), command: $root.spamCommand, tooltip: 'MESSAGE/BUTTON_SPAM'"> <a class="btn buttonSpam" data-placement="bottom" data-bind="visible: !$root.isDraftFolder(), command: $root.spamCommand, tooltip: 'MESSAGE/BUTTON_SPAM'">
<i class="icon-bug"></i> <i class="icon-bug"></i>
</a> </a>

View file

@ -119,6 +119,14 @@
<span class="i18n" data-i18n-text="COMPOSE/BUTTON_REQUEST_READ_RECEIPT"></span> <span class="i18n" data-i18n-text="COMPOSE/BUTTON_REQUEST_READ_RECEIPT"></span>
</a> </a>
</li> </li>
<li class="divider"></li>
<li class="e-item" data-bind="visible: allowOpenPGP, click: openOpenPgpPopup, css: {'disable': isHtml()}">
<a class="e-link">
<i class="icon-key"></i>
&nbsp;&nbsp;
OpenPGP (Plain Text Only)
</a>
</li>
</ul> </ul>
</div> </div>
<div class="btn-group pull-right">&nbsp;</div> <div class="btn-group pull-right">&nbsp;</div>

View file

@ -0,0 +1,46 @@
<div class="popups">
<div class="modal hide b-compose-open-pgp-content 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>
<span class="i18n" data-i18n-text="POPUPS_COMPOSE_OPEN_PGP/TITLE_COMPOSE_OPEN_PGP"></span>
</h3>
</div>
<div class="modal-body">
<div class="form-horizontal">
<div class="alert" data-bind="visible: '' !== notification()">
<span data-bind="text: notification"></span>
</div>
<br />
<div class="control-group">
<label data-bind="click: function () { sign(!sign()); }">
<i data-bind="css: sign() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="POPUPS_COMPOSE_OPEN_PGP/LABEL_SIGN"></span>
</label>
<label data-bind="click: function () { encrypt(!encrypt()); }">
<i data-bind="css: encrypt() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="POPUPS_COMPOSE_OPEN_PGP/LABEL_ENCRYPT"></span>
</label>
</div>
<div class="control-group">
<label class="i18n control-label" data-i18n-text="POPUPS_COMPOSE_OPEN_PGP/LABEL_PASSWORD"></label>
<div class="controls">
<input class="inputPassword input-large" type="password" autocomplete="off"
data-bind="value: password, hasfocus: password.focus" />
</div>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn buttonDo" data-bind="command: doCommand">
<i class="icon-key"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="POPUPS_COMPOSE_OPEN_PGP/BUTTON_DO"></span>
</a>
</div>
</div>
</div>
</div>

View file

@ -5438,6 +5438,9 @@ select {
padding-left: 12px; padding-left: 12px;
padding-right: 12px; padding-right: 12px;
} }
.btn-group.btn-group-custom-margin > .btn + .btn {
margin-left: 0px;
}
.dropdown-menu { .dropdown-menu {
-webkit-border-radius: 2px; -webkit-border-radius: 2px;
-moz-border-radius: 2px; -moz-border-radius: 2px;
@ -6552,22 +6555,26 @@ html.rl-no-preview-pane #rl-right .ui-resizable-handle {
} }
.popups .b-open-pgp-key-view-content .modal-header, .popups .b-open-pgp-key-view-content .modal-header,
.popups .b-open-pgp-key-generate-content .modal-header, .popups .b-open-pgp-key-generate-content .modal-header,
.popups .b-open-pgp-key-add-content .modal-header { .popups .b-open-pgp-key-add-content .modal-header,
.popups .b-compose-open-pgp-content .modal-header {
background-color: #fff; background-color: #fff;
} }
.popups .b-open-pgp-key-view-content.modal, .popups .b-open-pgp-key-view-content.modal,
.popups .b-open-pgp-key-generate-content.modal, .popups .b-open-pgp-key-generate-content.modal,
.popups .b-open-pgp-key-add-content.modal { .popups .b-open-pgp-key-add-content.modal,
.popups .b-compose-open-pgp-content.modal {
width: 570px; width: 570px;
} }
.popups .b-open-pgp-key-view-content .inputKey, .popups .b-open-pgp-key-view-content .inputKey,
.popups .b-open-pgp-key-generate-content .inputKey, .popups .b-open-pgp-key-generate-content .inputKey,
.popups .b-open-pgp-key-add-content .inputKey { .popups .b-open-pgp-key-add-content .inputKey,
.popups .b-compose-open-pgp-content .inputKey {
font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
} }
.popups .b-open-pgp-key-view-content .key-viewer, .popups .b-open-pgp-key-view-content .key-viewer,
.popups .b-open-pgp-key-generate-content .key-viewer, .popups .b-open-pgp-key-generate-content .key-viewer,
.popups .b-open-pgp-key-add-content .key-viewer { .popups .b-open-pgp-key-add-content .key-viewer,
.popups .b-compose-open-pgp-content .key-viewer {
max-height: 500px; max-height: 500px;
overflow: auto; overflow: auto;
} }

File diff suppressed because one or more lines are too long

View file

@ -143,11 +143,6 @@ Globals.bDisableNanoScroll = Globals.bMobileDevice;
*/ */
Globals.bAllowPdfPreview = !Globals.bMobileDevice; Globals.bAllowPdfPreview = !Globals.bMobileDevice;
/**
* @type {boolean}
*/
Globals.bAllowOpenPGP = false;
/** /**
* @type {boolean} * @type {boolean}
*/ */
@ -3025,7 +3020,11 @@ ko.bindingHandlers.emailsTags = {
'parseHook': function (aInput) { 'parseHook': function (aInput) {
return _.map(aInput, function (sInputValue) { return _.map(aInput, function (sInputValue) {
var sValue = Utils.trim(sInputValue), oEmail = null; var
sValue = Utils.trim(sInputValue),
oEmail = null
;
if ('' !== sValue) if ('' !== sValue)
{ {
oEmail = new EmailModel(); oEmail = new EmailModel();

File diff suppressed because one or more lines are too long

View file

@ -143,11 +143,6 @@ Globals.bDisableNanoScroll = Globals.bMobileDevice;
*/ */
Globals.bAllowPdfPreview = !Globals.bMobileDevice; Globals.bAllowPdfPreview = !Globals.bMobileDevice;
/**
* @type {boolean}
*/
Globals.bAllowOpenPGP = false;
/** /**
* @type {boolean} * @type {boolean}
*/ */
@ -3025,7 +3020,11 @@ ko.bindingHandlers.emailsTags = {
'parseHook': function (aInput) { 'parseHook': function (aInput) {
return _.map(aInput, function (sInputValue) { return _.map(aInput, function (sInputValue) {
var sValue = Utils.trim(sInputValue), oEmail = null; var
sValue = Utils.trim(sInputValue),
oEmail = null
;
if ('' !== sValue) if ('' !== sValue)
{ {
oEmail = new EmailModel(); oEmail = new EmailModel();
@ -3606,13 +3605,14 @@ Plugins.settingsGet = function (sPluginSection, sName)
function NewHtmlEditorWrapper(oElement, fOnBlur, fOnReady) function NewHtmlEditorWrapper(oElement, fOnBlur, fOnReady, fOnModeChange)
{ {
var self = this; var self = this;
self.editor = null; self.editor = null;
self.iBlurTimer = 0; self.iBlurTimer = 0;
self.fOnBlur = fOnBlur || null; self.fOnBlur = fOnBlur || null;
self.fOnReady = fOnReady || null; self.fOnReady = fOnReady || null;
self.fOnModeChange = fOnModeChange || null;
self.$element = $(oElement); self.$element = $(oElement);
@ -3763,6 +3763,11 @@ NewHtmlEditorWrapper.prototype.init = function ()
self.editor.on('mode', function() { self.editor.on('mode', function() {
self.blurTrigger(); self.blurTrigger();
if (self.fOnModeChange)
{
self.fOnModeChange('plain' !== self.editor.mode);
}
}); });
self.editor.on('focus', function() { self.editor.on('focus', function() {
@ -6321,7 +6326,7 @@ MessageModel.prototype.initUpdateByMessageJson = function (oJsonMessage)
this.sInReplyTo = oJsonMessage.InReplyTo; this.sInReplyTo = oJsonMessage.InReplyTo;
this.sReferences = oJsonMessage.References; this.sReferences = oJsonMessage.References;
if (Globals.bAllowOpenPGP) if (RL.data().allowOpenPGP())
{ {
this.isPgpSigned(!!oJsonMessage.PgpSigned); this.isPgpSigned(!!oJsonMessage.PgpSigned);
this.isPgpEncrypted(!!oJsonMessage.PgpEncrypted); this.isPgpEncrypted(!!oJsonMessage.PgpEncrypted);
@ -7699,6 +7704,8 @@ function PopupsComposeViewModel()
} }
; ;
this.allowOpenPGP = oRainLoopData.allowOpenPGP;
this.resizer = ko.observable(false).extend({'throttle': 50}); this.resizer = ko.observable(false).extend({'throttle': 50});
this.to = ko.observable(''); this.to = ko.observable('');
@ -7708,6 +7715,7 @@ function PopupsComposeViewModel()
this.replyTo = ko.observable(''); this.replyTo = ko.observable('');
this.subject = ko.observable(''); this.subject = ko.observable('');
this.isHtml = ko.observable(false);
this.requestReadReceipt = ko.observable(false); this.requestReadReceipt = ko.observable(false);
@ -8026,6 +8034,23 @@ function PopupsComposeViewModel()
Utils.extendAsViewModel('PopupsComposeViewModel', PopupsComposeViewModel); Utils.extendAsViewModel('PopupsComposeViewModel', PopupsComposeViewModel);
PopupsComposeViewModel.prototype.openOpenPgpPopup = function ()
{
if (this.allowOpenPGP() && this.oEditor && !this.oEditor.isHtml())
{
kn.showScreenPopup(PopupsComposeOpenPgpViewModel, [
function () {
},
this.oEditor.getData(),
this.currentIdentityResultEmail(),
this.to(),
this.cc(),
this.bcc()
]);
}
};
PopupsComposeViewModel.prototype.reloadDraftFolder = function () PopupsComposeViewModel.prototype.reloadDraftFolder = function ()
{ {
var sDraftFolder = RL.data().draftFolder(); var sDraftFolder = RL.data().draftFolder();
@ -8268,6 +8293,8 @@ PopupsComposeViewModel.prototype.editor = function (fOnInit)
_.delay(function () { _.delay(function () {
self.oEditor = new NewHtmlEditorWrapper(self.composeEditorArea(), null, function () { self.oEditor = new NewHtmlEditorWrapper(self.composeEditorArea(), null, function () {
fOnInit(self.oEditor); fOnInit(self.oEditor);
}, function (bHtml) {
self.isHtml(!!bHtml);
}); });
}, 300); }, 300);
} }
@ -10191,6 +10218,69 @@ PopupsGenerateNewOpenPgpKeyViewModel.prototype.onFocus = function ()
this.email.focus(true); this.email.focus(true);
}; };
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function PopupsComposeOpenPgpViewModel()
{
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsComposeOpenPgp');
this.notification = ko.observable('');
this.sign = ko.observable(true);
this.encrypt = ko.observable(true);
this.password = ko.observable('');
this.password.focus = ko.observable(true);
// commands
this.doCommand = Utils.createCommand(this, function () {
this.cancelCommand();
}, function () {
return '' === this.notification();
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsComposeOpenPgpViewModel', PopupsComposeOpenPgpViewModel);
PopupsComposeOpenPgpViewModel.prototype.clearPopup = function ()
{
this.notification('');
this.password('');
this.password.focus(false);
};
PopupsComposeOpenPgpViewModel.prototype.onHide = function ()
{
this.clearPopup();
};
PopupsComposeOpenPgpViewModel.prototype.onShow = function (fCallback, sText, sFromEmail, sTo, sCc, sBcc)
{
this.clearPopup();
if ('' === sTo + sCc + sBcc)
{
this.notification('Please specify at least one recipient');
}
// TODO
};
PopupsComposeOpenPgpViewModel.prototype.onFocus = function ()
{
if (this.sign())
{
this.password.focus(true);
}
};
/** /**
* @constructor * @constructor
* @extends KnoinAbstractViewModel * @extends KnoinAbstractViewModel
@ -13716,6 +13806,7 @@ function WebMailDataStorage()
// other // other
this.useKeyboardShortcuts = ko.observable(true); this.useKeyboardShortcuts = ko.observable(true);
this.allowOpenPGP = ko.observable(false);
this.openpgpkeys = ko.observableArray([]); this.openpgpkeys = ko.observableArray([]);
this.openpgpKeyring = null; this.openpgpKeyring = null;
@ -14240,7 +14331,8 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
bIsHtml = false; bIsHtml = false;
sPlain = oData.Result.Plain.toString(); sPlain = oData.Result.Plain.toString();
if (Globals.bAllowOpenPGP && (oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) && if ((oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) &&
RL.data().allowOpenPGP() &&
Utils.isNormal(oData.Result.PlainRaw)) Utils.isNormal(oData.Result.PlainRaw))
{ {
bPgpEncrypted = /---BEGIN PGP MESSAGE---/.test(oData.Result.PlainRaw); bPgpEncrypted = /---BEGIN PGP MESSAGE---/.test(oData.Result.PlainRaw);
@ -14340,7 +14432,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
} }
} }
if (Globals.bAllowOpenPGP && oMessage.body) if (oMessage.body && RL.data().allowOpenPGP())
{ {
oMessage.isPgpSigned(!!oMessage.body.data('rl-plain-pgp-signed')); oMessage.isPgpSigned(!!oMessage.body.data('rl-plain-pgp-signed'));
oMessage.isPgpEncrypted(!!oMessage.body.data('rl-plain-pgp-encrypted')); oMessage.isPgpEncrypted(!!oMessage.body.data('rl-plain-pgp-encrypted'));
@ -16909,7 +17001,7 @@ RainLoopApp.prototype.folders = function (fCallback)
RainLoopApp.prototype.reloadOpenPgpKeys = function () RainLoopApp.prototype.reloadOpenPgpKeys = function ()
{ {
if (Globals.bAllowOpenPGP) if (RL.data().allowOpenPGP())
{ {
var var
aKeys = [], aKeys = [],
@ -17548,8 +17640,8 @@ RainLoopApp.prototype.bootstart = function ()
if (window.openpgp) if (window.openpgp)
{ {
RL.data().openpgpKeyring = new window.openpgp.Keyring(new OpenPgpLocalStorageDriver()); RL.data().openpgpKeyring = new window.openpgp.Keyring(new OpenPgpLocalStorageDriver());
RL.data().allowOpenPGP(true);
Globals.bAllowOpenPGP = true;
RL.pub('openpgp.init'); RL.pub('openpgp.init');
RL.reloadOpenPgpKeys(); RL.reloadOpenPgpKeys();
@ -17559,7 +17651,7 @@ RainLoopApp.prototype.bootstart = function ()
} }
else else
{ {
Globals.bAllowOpenPGP = false; RL.data().allowOpenPGP(false);
} }
kn.startScreens([MailBoxScreen, SettingsScreen]); kn.startScreens([MailBoxScreen, SettingsScreen]);

File diff suppressed because one or more lines are too long