OpenPGP Key Storage (Settings) (#53)

Import, Delete, Generate, View
This commit is contained in:
RainLoop Team 2014-03-13 02:29:33 +04:00
parent 5a5c6af2c6
commit 5ece4cc0ec
47 changed files with 1333 additions and 539 deletions

View file

@ -253,6 +253,7 @@ module.exports = function (grunt) {
"dev/Storages/LocalStorages/CookieDriver.js",
"dev/Storages/LocalStorages/LocalStorageDriver.js",
"dev/Storages/LocalStorages/OpenPgpLocalStorageDriver.js",
"dev/Storages/LocalStorage.js",
"dev/Knoin/AbstractBoot.js",
@ -269,6 +270,7 @@ module.exports = function (grunt) {
"dev/Models/FolderModel.js",
"dev/Models/AccountModel.js",
"dev/Models/IdentityModel.js",
"dev/Models/OpenPgpKeyModel.js",
"dev/ViewModels/PopupsFolderClearViewModel.js",
"dev/ViewModels/PopupsFolderCreateViewModel.js",
@ -277,10 +279,12 @@ module.exports = function (grunt) {
"dev/ViewModels/PopupsContactsViewModel.js",
"dev/ViewModels/PopupsAdvancedSearchViewModel.js",
"dev/ViewModels/PopupsAddAccountViewModel.js",
"dev/ViewModels/PopupsAddOpenPgpKeyViewModel.js",
"dev/ViewModels/PopupsViewOpenPgpKeyViewModel.js",
"dev/ViewModels/PopupsGenerateNewOpenPgpKeyViewModel.js",
"dev/ViewModels/PopupsIdentityViewModel.js",
"dev/ViewModels/PopupsLanguagesViewModel.js",
"dev/ViewModels/PopupsAskViewModel.js",
"dev/ViewModels/PopupsPgpKey.js",
"dev/ViewModels/LoginViewModel.js",
@ -301,6 +305,7 @@ module.exports = function (grunt) {
"dev/Settings/Identity.js",
"dev/Settings/Identities.js",
"dev/Settings/Social.js",
"dev/Settings/OpenPGP.js",
"dev/Settings/ChangePassword.js",
"dev/Settings/Folders.js",
"dev/Settings/Themes.js",

View file

@ -190,6 +190,36 @@ RainLoopApp.prototype.folders = function (fCallback)
}, this));
};
RainLoopApp.prototype.reloadOpenPgpKeys = function ()
{
if (Globals.bAllowOpenPGP)
{
var
aKeys = [],
oOpenpgpKeyring = RL.data().openpgpKeyring,
oOpenpgpKeys = oOpenpgpKeyring ? oOpenpgpKeyring.keys : []
;
_.each(oOpenpgpKeys, function (oItem, iIndex) {
if (oItem)
{
var
aIDs = _.map(oItem.getKeyIds(), function (oID) {
return oID ? oID.toHex() : '';
})
;
aKeys.push(
new OpenPgpKeyModel(iIndex, aIDs.join(', '), oItem.getUserIds().join(', '),
oItem.isPrivate(), oItem.armor())
);
}
});
RL.data().openpgpkeys(aKeys);
}
};
RainLoopApp.prototype.accountsAndIdentities = function ()
{
var oRainLoopData = RL.data();
@ -739,6 +769,11 @@ RainLoopApp.prototype.bootstart = function ()
{
Utils.removeSettingsViewModel(SettingsIdentities);
}
if (!RL.settingsGet('OpenPGP'))
{
Utils.removeSettingsViewModel(SettingsOpenPGP);
}
if (!bGoogle && !bFacebook && !bTwitter)
{
@ -795,9 +830,12 @@ RainLoopApp.prototype.bootstart = function ()
'success': function () {
if (window.openpgp)
{
// window.console.log(window.openpgp);
RL.data().openpgpKeyring = new window.openpgp.Keyring(new OpenPgpLocalStorageDriver());
Globals.bAllowOpenPGP = true;
RL.pub('openpgp.init');
RL.reloadOpenPgpKeys();
}
}
});

View file

@ -331,12 +331,13 @@ Utils.i18nToNode = function (oElement)
{
jqThis.attr('placeholder', Utils.i18n(sKey));
}
sKey = jqThis.data('i18n-title');
if (sKey)
{
jqThis.attr('title', Utils.i18n(sKey));
}
}
// sKey = jqThis.data('i18n-title');
// if (sKey)
// {
// jqThis.attr('title', Utils.i18n(sKey));
// }
});
});
};
@ -1695,3 +1696,23 @@ Utils.computedPagenatorHelper = function (koCurrentPage, koPageCount)
return aResult;
};
};
Utils.selectElement = function (element)
{
/* jshint onevar: false */
if (window.getSelection)
{
var sel = window.getSelection();
sel.removeAllRanges();
var range = document.createRange();
range.selectNodeContents(element);
sel.addRange(range);
}
else if (document.selection)
{
var textRange = document.body.createTextRange();
textRange.moveToElementText(element);
textRange.select();
}
/* jshint onevar: true */
};

View file

@ -7,6 +7,7 @@
*/
function KnoinAbstractViewModel(sPosition, sTemplate)
{
this.bDisabeCloseOnEsc = false;
this.sPosition = Utils.pString(sPosition);
this.sTemplate = Utils.pString(sTemplate);
@ -59,3 +60,17 @@ KnoinAbstractViewModel.prototype.viewModelPosition = function ()
KnoinAbstractViewModel.prototype.cancelCommand = KnoinAbstractViewModel.prototype.closeCommand = function ()
{
};
KnoinAbstractViewModel.prototype.registerPopupEscapeKey = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
return false;
}
return true;
});
};

View file

@ -115,6 +115,10 @@ Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen)
ko.applyBindings(oViewModel, oViewModelDom[0]);
Utils.delegateRun(oViewModel, 'onBuild', [oViewModelDom]);
if (oViewModel && 'Popups' === sPosition && !oViewModel.bDisabeCloseOnEsc)
{
oViewModel.registerPopupEscapeKey();
}
Plugins.runHook('view-model-post-build', [ViewModelClass.__name, oViewModel, oViewModelDom]);
}

View file

@ -0,0 +1,26 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @param {string} iIndex
* @param {string} sID
* @param {string} sUserID
* @param {boolean} bIsPrivate
* @param {string} sArmor
* @constructor
*/
function OpenPgpKeyModel(iIndex, sID, sUserID, bIsPrivate, sArmor)
{
this.index = iIndex;
this.id = sID;
this.user = sUserID;
this.armor = sArmor;
this.isPrivate = !!bIsPrivate;
this.deleteAccess = ko.observable(false);
}
OpenPgpKeyModel.prototype.index = 0;
OpenPgpKeyModel.prototype.id = '';
OpenPgpKeyModel.prototype.user = '';
OpenPgpKeyModel.prototype.armor = '';
OpenPgpKeyModel.prototype.isPrivate = false;

83
dev/Settings/OpenPGP.js Normal file
View file

@ -0,0 +1,83 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsOpenPGP()
{
this.openpgpkeys = RL.data().openpgpkeys;
this.openpgpkeysPublic = ko.computed(function () {
return _.filter(this.openpgpkeys(), function (oItem) {
return !!(oItem && !oItem.isPrivate);
});
}, this);
this.openpgpkeysPrivate = ko.computed(function () {
return _.filter(this.openpgpkeys(), function (oItem) {
return !!(oItem && oItem.isPrivate);
});
}, this);
this.openPgpKeyForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.deleteAccess(false);
}
}, function (oNext) {
if (oNext)
{
oNext.deleteAccess(true);
}
}
]});
}
Utils.addSettingsViewModel(SettingsOpenPGP, 'SettingsOpenPGP', 'SETTINGS_LABELS/LABEL_OPEN_PGP_NAME', 'openpgp');
SettingsOpenPGP.prototype.addOpenPgpKey = function ()
{
kn.showScreenPopup(PopupsAddOpenPgpKeyViewModel);
};
SettingsOpenPGP.prototype.generateOpenPgpKey = function ()
{
kn.showScreenPopup(PopupsGenerateNewOpenPgpKeyViewModel);
};
SettingsOpenPGP.prototype.viewOpenPgpKey = function (oOpenPgpKey)
{
if (oOpenPgpKey)
{
kn.showScreenPopup(PopupsViewOpenPgpKeyViewModel, [oOpenPgpKey]);
}
};
/**
* @param {OpenPgpKeyModel} oOpenPgpKeyToRemove
*/
SettingsOpenPGP.prototype.deleteOpenPgpKey = function (oOpenPgpKeyToRemove)
{
if (oOpenPgpKeyToRemove && oOpenPgpKeyToRemove.deleteAccess())
{
this.openPgpKeyForDeletion(null);
var
oOpenpgpKeyring = RL.data().openpgpKeyring,
fRemoveAccount = function (oOpenPgpKey) {
return oOpenPgpKeyToRemove === oOpenPgpKey;
}
;
if (oOpenPgpKeyToRemove && oOpenpgpKeyring)
{
this.openpgpkeys.remove(fRemoveAccount);
oOpenpgpKeyring.removeKey(oOpenPgpKeyToRemove.index);
oOpenpgpKeyring.store();
RL.reloadOpenPgpKeys();
}
}
};

View file

@ -12,7 +12,6 @@ LocalStorageDriver.supported = function ()
return !!window.localStorage;
};
/**
* @param {string} sKey
* @param {*} mData
@ -21,14 +20,14 @@ LocalStorageDriver.supported = function ()
LocalStorageDriver.prototype.set = function (sKey, mData)
{
var
mCokieValue = window.localStorage[Consts.Values.ClientSideCookieIndexName] || null,
mCookieValue = window.localStorage[Consts.Values.ClientSideCookieIndexName] || null,
bResult = false,
mResult = null
;
try
{
mResult = null === mCokieValue ? null : JSON.parse(mCokieValue);
mResult = null === mCookieValue ? null : JSON.parse(mCookieValue);
if (!mResult)
{
mResult = {};

View file

@ -0,0 +1,60 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function OpenPgpLocalStorageDriver()
{
}
/*
* Declare the localstore itemname
*/
OpenPgpLocalStorageDriver.prototype.item = 'armoredRainLoopKeys';
/**
* Load the keyring from HTML5 local storage and initializes this instance.
* @return {Array<module:key~Key>} array of keys retrieved from localstore
*/
OpenPgpLocalStorageDriver.prototype.load = function ()
{
var
iIndex = 0,
iLen = 0,
aKeys = [],
aArmoredKeys = JSON.parse(window.localStorage.getItem(this.item))
;
if (aArmoredKeys && 0 < aArmoredKeys.length)
{
for (iLen = aArmoredKeys.length; iIndex < iLen; iIndex++)
{
aKeys.push(
window.openpgp.key.readArmored(aArmoredKeys[iIndex]).keys[0]
);
}
}
return aKeys;
};
/**
* Saves the current state of the keyring to HTML5 local storage.
* The privateKeys array and publicKeys array gets Stringified using JSON
* @param {Array<module:key~Key>} aKeys array of keys to save in localstore
*/
OpenPgpLocalStorageDriver.prototype.store = function (aKeys)
{
var
iIndex = 0,
iLen = aKeys.length,
aArmoredKeys = []
;
for (; iIndex < iLen; iIndex++)
{
aArmoredKeys.push(aKeys[iIndex].armor());
}
window.localStorage.setItem(this.item, JSON.stringify(aArmoredKeys));
};

View file

@ -343,6 +343,9 @@ function WebMailDataStorage()
// other
this.useKeyboardShortcuts = ko.observable(true);
this.openpgpkeys = ko.observableArray([]);
this.openpgpKeyring = null;
// google
this.googleActions = ko.observable(false);

View file

@ -42,13 +42,13 @@
@import "SystemDropDown.less";
@import "Login.less";
@import "Ask.less";
@import "Pgp.less";
@import "FolderList.less";
@import "FolderClear.less";
@import "FolderCreate.less";
@import "FolderSystem.less";
@import "Languages.less";
@import "AddAccount.less";
@import "OpenPgpKey.less";
@import "Identity.less";
@import "AdvancedSearch.less";
@import "MessageList.less";
@ -68,6 +68,7 @@
@import "SettingsAccounts.less";
@import "SettingsIdentity.less";
@import "SettingsIdentities.less";
@import "SettingsOpenPGP.less";
@import "SettingsFolders.less";
@import "SettingsThemes.less";

View file

@ -0,0 +1,21 @@
.popups {
.b-open-pgp-key-view-content, .b-open-pgp-key-generate-content, .b-open-pgp-key-add-content {
.modal-header {
background-color: #fff;
}
&.modal {
width: 570px;
}
.inputKey {
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
}
.key-viewer {
max-height: 500px;
overflow: auto;
}
}
}

View file

@ -1,18 +0,0 @@
.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

@ -0,0 +1,55 @@
.b-settings-open-pgp {
.process-place {
text-align: center;
width: 600px;
padding: 14px 0;
}
.list-table {
width: 750px;
td {
padding: 4px 8px;
line-height: 30px;
}
.open-pgp-key-img {
font-size: 12px;
margin-right: 5px;
}
.open-pgp-key-id, .open-pgp-key-user {
display: inline-block;
word-break: break-all;
.box-sizing(border-box);
line-height: 22px;
cursor: default;
}
}
.open-pgp-key-item {
.button-delete {
margin-right: 15px;
margin-top: 5px;
visibility: hidden;
.opacity(0);
}
.delete-access {
&.button-delete {
visibility: visible;
margin-right: 0;
.opacity(100);
}
}
.delete-open-pgp-key, .view-open-pgp-key {
cursor: pointer;
.opacity(50);
}
}
}

View file

@ -209,38 +209,6 @@ 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

@ -115,15 +115,4 @@ PopupsAddAccountViewModel.prototype.onFocus = function ()
PopupsAddAccountViewModel.prototype.onBuild = function ()
{
this.allowCustomLogin(!!RL.settingsGet('AllowCustomLogin'));
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
});
};

View file

@ -0,0 +1,61 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function PopupsAddOpenPgpKeyViewModel()
{
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAddOpenPgpKey');
this.key = ko.observable('');
this.key.error = ko.observable(false);
this.key.focus = ko.observable(false);
this.key.subscribe(function () {
this.key.error(false);
}, this);
this.addOpenPgpKeyCommand = Utils.createCommand(this, function () {
var
sKey = Utils.trim(this.key()),
oOpenpgpKeyring = RL.data().openpgpKeyring
;
this.key.error('' === sKey);
if (!oOpenpgpKeyring || this.key.error())
{
return false;
}
oOpenpgpKeyring.importKey(sKey);
oOpenpgpKeyring.store();
RL.reloadOpenPgpKeys();
Utils.delegateRun(this, 'cancelCommand');
return true;
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsAddOpenPgpKeyViewModel', PopupsAddOpenPgpKeyViewModel);
PopupsAddOpenPgpKeyViewModel.prototype.clearPopup = function ()
{
this.key('');
this.key.error(false);
};
PopupsAddOpenPgpKeyViewModel.prototype.onShow = function ()
{
this.clearPopup();
};
PopupsAddOpenPgpKeyViewModel.prototype.onFocus = function ()
{
this.key.focus(true);
};

View file

@ -129,17 +129,3 @@ PopupsAdvancedSearchViewModel.prototype.onFocus = function ()
{
this.fromFocus(true);
};
PopupsAdvancedSearchViewModel.prototype.onBuild = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
});
};

View file

@ -18,6 +18,8 @@ function PopupsAskViewModel()
this.fYesAction = null;
this.fNoAction = null;
this.bDisabeCloseOnEsc = true;
Knoin.constructorEnd(this);
}

View file

@ -389,6 +389,8 @@ function PopupsComposeViewModel()
// this.driveCallback = _.bind(this.driveCallback, this);
this.bDisabeCloseOnEsc = true;
Knoin.constructorEnd(this);
}

View file

@ -600,25 +600,6 @@ PopupsContactsViewModel.prototype.onBuild = function (oDom)
})
;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && self.modalVisibility())
{
if (Enums.EventKeyCode.Esc === oEvent.keyCode)
{
Utils.delegateRun(self, 'closeCommand');
bResult = false;
}
else if (oEvent.ctrlKey && Enums.EventKeyCode.S === oEvent.keyCode)
{
self.saveCommand();
bResult = false;
}
}
return bResult;
});
this.initUploader();
};

View file

@ -196,20 +196,6 @@ PopupsDomainViewModel.prototype.onFocus = function ()
}
};
PopupsDomainViewModel.prototype.onBuild = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
});
};
PopupsDomainViewModel.prototype.clearForm = function ()
{
this.edit(false);

View file

@ -95,17 +95,3 @@ PopupsFolderClearViewModel.prototype.onShow = function (oFolder)
this.selectedFolder(oFolder);
}
};
PopupsFolderClearViewModel.prototype.onBuild = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
});
};

View file

@ -109,17 +109,3 @@ PopupsFolderCreateViewModel.prototype.onFocus = function ()
{
this.folderName.focused(true);
};
PopupsFolderCreateViewModel.prototype.onBuild = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
});
};

View file

@ -104,17 +104,3 @@ PopupsFolderSystemViewModel.prototype.onShow = function (iNotificationType)
this.notification(sNotification);
};
PopupsFolderSystemViewModel.prototype.onBuild = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
});
};

View file

@ -0,0 +1,90 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function PopupsGenerateNewOpenPgpKeyViewModel()
{
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsGenerateNewOpenPgpKey');
this.email = ko.observable('');
this.email.focus = ko.observable('');
this.email.error = ko.observable(false);
this.name = ko.observable('');
this.password = ko.observable('');
this.keyBitLength = ko.observable(2048);
this.submitRequest = ko.observable(false);
this.email.subscribe(function () {
this.email.error(false);
}, this);
this.generateOpenPgpKeyCommand = Utils.createCommand(this, function () {
var
self = this,
sUserID = '',
mKeyPair = null,
oOpenpgpKeyring = RL.data().openpgpKeyring
;
this.email.error('' === Utils.trim(this.email()));
if (!oOpenpgpKeyring || this.email.error())
{
return false;
}
sUserID = this.email();
if ('' !== this.name())
{
sUserID = this.name() + ' <' + sUserID + '>';
}
this.submitRequest(true);
_.delay(function () {
mKeyPair = window.openpgp.generateKeyPair(1, Utils.pInt(self.keyBitLength()), sUserID, Utils.trim(self.password()));
if (mKeyPair && mKeyPair.privateKeyArmored)
{
oOpenpgpKeyring.importKey(mKeyPair.privateKeyArmored);
oOpenpgpKeyring.importKey(mKeyPair.publicKeyArmored);
oOpenpgpKeyring.store();
RL.reloadOpenPgpKeys();
Utils.delegateRun(self, 'cancelCommand');
}
self.submitRequest(false);
}, 100);
return true;
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsGenerateNewOpenPgpKeyViewModel', PopupsGenerateNewOpenPgpKeyViewModel);
PopupsGenerateNewOpenPgpKeyViewModel.prototype.clearPopup = function ()
{
this.name('');
this.password('');
this.email('');
this.email.error(false);
this.keyBitLength(2048);
};
PopupsGenerateNewOpenPgpKeyViewModel.prototype.onShow = function ()
{
this.clearPopup();
};
PopupsGenerateNewOpenPgpKeyViewModel.prototype.onFocus = function ()
{
this.email.focus(true);
};

View file

@ -147,17 +147,3 @@ PopupsIdentityViewModel.prototype.onFocus = function ()
this.email.focused(true);
}
};
PopupsIdentityViewModel.prototype.onBuild = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
});
};

View file

@ -54,20 +54,6 @@ PopupsLanguagesViewModel.prototype.onHide = function ()
this.exp(false);
};
PopupsLanguagesViewModel.prototype.onBuild = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
});
};
PopupsLanguagesViewModel.prototype.changeLanguage = function (sLang)
{
RL.data().mainLanguage(sLang);

View file

@ -1,64 +0,0 @@
/* 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

@ -59,6 +59,8 @@ function PopupsPluginViewModel()
}, this.hasConfiguration);
this.bDisabeCloseOnEsc = true;
Knoin.constructorEnd(this);
}

View file

@ -0,0 +1,41 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function PopupsViewOpenPgpKeyViewModel()
{
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsViewOpenPgpKey');
this.key = ko.observable('');
this.keyDom = ko.observable(null);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsViewOpenPgpKeyViewModel', PopupsViewOpenPgpKeyViewModel);
PopupsViewOpenPgpKeyViewModel.prototype.clearPopup = function ()
{
this.key('');
};
PopupsViewOpenPgpKeyViewModel.prototype.selectKey = function ()
{
var oEl = this.keyDom();
if (oEl)
{
Utils.selectElement(oEl);
}
};
PopupsViewOpenPgpKeyViewModel.prototype.onShow = function (oOpenPgpKey)
{
this.clearPopup();
if (oOpenPgpKey)
{
this.key(oOpenPgpKey.armor);
}
};

View file

@ -2,7 +2,7 @@
"name": "RainLoop",
"title": "RainLoop Webmail",
"version": "1.6.3",
"release": "716",
"release": "804",
"description": "Simple, modern & fast web-based email client",
"homepage": "http://rainloop.net",
"main": "Gruntfile.js",

View file

@ -599,7 +599,11 @@ class Http
*/
public function GetPath()
{
$sUrl = \ltrim(\substr($this->GetServer('SCRIPT_NAME', ''), 0, \strrpos($this->GetServer('SCRIPT_NAME', ''), '/')), '/');
// phpinfo();
// exit();
$sUrl = \trim(\substr($this->GetServer('REQUEST_URI', ''), 0,
\strrpos($this->GetServer('REQUEST_URI', ''), \basename($this->GetServer('SCRIPT_NAME', '')))), '/');
return '' === $sUrl ? '/' : '/'.$sUrl.'/';
}

View file

@ -989,8 +989,8 @@ class Actions
{
$sUrl = \rtrim(\trim($this->Http()->GetScheme().'://'.$this->Http()->GetHost(true, false).$this->Http()->GetPath()), '/\\');
$sUrl = \preg_replace('/index\.php(.*)$/i', '', $sUrl);
$aResult['ContactsSyncPabUrl'] = $sUrl.'/index.php/dav';
$aResult['ContactsSyncPabUrl'] = $sUrl.'/index.php/dav/';
}
else
{

View file

@ -12,7 +12,7 @@
</label>
</div>
</div>
<!-- <div class="control-group">
<div class="control-group">
<div class="controls">
<label data-bind="click: function () { openPGP(!openPGP()); }">
<i data-bind="css: openPGP() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
@ -20,7 +20,7 @@
Allow OpenPGP (unstable)
</label>
</div>
</div>-->
</div>
<div class="control-group">
<div class="controls">
<a href="#" target="_blank" class="g-ui-link" data-bind="link: phpInfoLink()">Show PHP information</a>

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: receivePrivateKey">
<div class="pgpSigned" data-bind="visible: message() && message().isPgpSigned()">
<i class="icon-lock"></i>
&nbsp;&nbsp;
PGP signed (click to verify)
PGP signed
</div>
<div class="pgpEncrypted" data-bind="visible: message() && message().isPgpEncrypted(), click: receivePrivateKey">
<div class="pgpEncrypted" data-bind="visible: message() && message().isPgpEncrypted()">
<i class="icon-lock"></i>
&nbsp;&nbsp;
PGP encrypted (click to decrypt)
PGP encrypted
</div>
<div class="attachmentsPlace" data-bind="visible: message() && message().hasVisibleAttachments()">
<ul class="attachmentList" data-bind="foreach: message() ? message().attachments() : []">

View file

@ -0,0 +1,26 @@
<div class="popups">
<div class="modal hide b-open-pgp-key-add-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_IMPORT_OPEN_PGP_KEY/TITLE_IMPORT_OPEN_PGP_KEY"></span>
</h3>
</div>
<div class="modal-body">
<div class="form-horizontal">
<div class="control-group">
<textarea class="inputKey input-xxlarge" rows="14" autocomplete="off" data-bind="value: key, hasfocus: key.focus"></textarea>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn buttonAddAccount" data-bind="command: addOpenPgpKeyCommand">
<i class="icon-list-add"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="POPUPS_IMPORT_OPEN_PGP_KEY/BUTTON_IMPORT_OPEN_PGP_KEY"></span>
</a>
</div>
</div>
</div>
</div>

View file

@ -0,0 +1,50 @@
<div class="popups">
<div class="modal hide b-open-pgp-key-generate-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_GENERATE_OPEN_PGP_KEYS/TITLE_GENERATE_OPEN_PGP_KEYS"></span>
</h3>
</div>
<div class="modal-body">
<div class="form-horizontal">
<div class="control-group" data-bind="css: {'error': email.error}">
<label class="i18n control-label" data-i18n-text="POPUPS_GENERATE_OPEN_PGP_KEYS/LABEL_EMAIL"></label>
<div class="controls">
<input class="inputEmail input-large" type="email" autocomplete="off"
data-bind="value: email, hasfocus: email.focus" />
</div>
</div>
<div class="control-group">
<label class="i18n control-label" data-i18n-text="POPUPS_GENERATE_OPEN_PGP_KEYS/LABEL_NAME"></label>
<div class="controls">
<input class="inputName input-large" type="text" autocomplete="off"
data-bind="value: name" />
</div>
</div>
<div class="control-group">
<label class="i18n control-label" data-i18n-text="POPUPS_GENERATE_OPEN_PGP_KEYS/LABEL_PASSWORD"></label>
<div class="controls">
<input class="inputPassword input-large" type="password" autocomplete="off"
data-bind="value: password" />
</div>
</div>
<div class="control-group">
<label class="i18n control-label" data-i18n-text="POPUPS_GENERATE_OPEN_PGP_KEYS/LABEL_KEY_BIT_LENGTH"></label>
<div class="controls">
<select data-bind="value: keyBitLength, options: [1024, 2048]"></select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn buttonHenerateOpenPgpKey" data-bind="command: generateOpenPgpKeyCommand">
<i data-bind="css: {'icon-key': !submitRequest(), 'icon-spinner animated': submitRequest()}"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="POPUPS_GENERATE_OPEN_PGP_KEYS/BUTTON_GENERATE_OPEN_PGP_KEYS"></span>
</a>
</div>
</div>
</div>
</div>

View file

@ -0,0 +1,31 @@
<div class="popups">
<div class="modal hide b-open-pgp-key-view-content" data-bind="modal: modalVisibility">
<div>
<div class="modal-header g-ui-user-select-none">
<button type="button" class="close" data-bind="command: cancelCommand">&times;</button>
<h3>
<span class="i18n" data-i18n-text="POPUPS_VIEW_OPEN_PGP_KEY/TITLE_VIEW_OPEN_PGP_KEY"></span>
</h3>
</div>
<div class="modal-body">
<div class="form-horizontal">
<div class="control-group">
<pre class="key-viewer" data-bind="initDom: keyDom, text: key"></pre>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn buttonClose" data-bind="command: cancelCommand">
<i class="icon-remove"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="POPUPS_VIEW_OPEN_PGP_KEY/BUTTON_CLOSE"></span>
</a>
<a class="btn buttonClose" data-bind="click: selectKey">
<i class="icon-key"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="POPUPS_VIEW_OPEN_PGP_KEY/BUTTON_SELECT"></span>
</a>
</div>
</div>
</div>
</div>

View file

@ -0,0 +1,73 @@
<div class="b-settings-open-pgp g-ui-user-select-none">
<div class="form-horizontal">
<div class="legend">
<span class="i18n" data-i18n-text="SETTINGS_OPEN_PGP/LEGEND_OPEN_PGP"></span>
</div>
</div>
<a class="btn" data-bind="click: addOpenPgpKey">
<i class="icon-list-add"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="SETTINGS_OPEN_PGP/BUTTON_ADD_OPEN_PGP_KEY"></span>
</a>
&nbsp;&nbsp;
<a class="btn" data-bind="click: generateOpenPgpKey">
<i class="icon-key"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="SETTINGS_OPEN_PGP/BUTTON_GENERATE_OPEN_PGP_KEYS"></span>
</a>
<br />
<br />
<br />
<table class="table table-hover list-table" data-bind="i18nUpdate: openpgpkeys">
<colgroup>
<col />
<col style="width: 1%" />
<col style="width: 1%" />
</colgroup>
<tbody>
<!-- ko foreach: openpgpkeysPrivate -->
<tr class="open-pgp-key-item">
<td>
<i class="open-pgp-key-img icon-lock i18n" data-i18n-title="SETTINGS_OPEN_PGP/TITLE_PRIVATE"></i>
<span class="open-pgp-key-user" data-bind="text: user"></span>
<a class="btn btn-small btn-small-small btn-danger pull-right button-delete" data-bind="css: {'delete-access': deleteAccess()}, click: function(oOpenPGP) { $root.deleteOpenPgpKey(oOpenPGP); }">
<span class="i18n" data-i18n-text="SETTINGS_OPEN_PGP/DELETING_ASK"></span>
</a>
</td>
<td>
<span class="delete-open-pgp-key" data-bind="visible: !deleteAccess(), click: function (oOpenPGP) { $root.openPgpKeyForDeletion(oOpenPGP); }">
<i class="icon-trash"></i>
</span>
</td>
<td>
<span class="view-open-pgp-key" data-bind="click: function (oOpenPgpKey) { $root.viewOpenPgpKey(oOpenPgpKey); }">
<i class="icon-eye"></i>
</span>
</td>
</tr>
<!-- /ko -->
<!-- ko foreach: openpgpkeysPublic -->
<tr class="open-pgp-key-item">
<td>
<span class="open-pgp-key-img icon-key i18n" data-i18n-title="SETTINGS_OPEN_PGP/TITLE_PUBLIC"></span>
<span class="open-pgp-key-user" data-bind="text: user"></span>
(<span class="open-pgp-key-id" data-bind="text: id"></span>)
<a class="btn btn-small btn-small-small btn-danger pull-right button-delete" data-bind="css: {'delete-access': deleteAccess()}, click: function(oOpenPGP) { $root.deleteOpenPgpKey(oOpenPGP); }">
<span class="i18n" data-i18n-text="SETTINGS_OPEN_PGP/DELETING_ASK"></span>
</a>
</td>
<td>
<span class="delete-open-pgp-key" data-bind="visible: !deleteAccess(), click: function (oOpenPgpKey) { $root.openPgpKeyForDeletion(oOpenPgpKey); }">
<i class="icon-trash"></i>
</span>
</td>
<td>
<span class="view-open-pgp-key" data-bind="click: function (oOpenPgpKey) { $root.viewOpenPgpKey(oOpenPgpKey); }">
<i class="icon-eye"></i>
</span>
</td>
</tr>
<!-- /ko -->
</tbody>
</table>
</div>

View file

@ -235,6 +235,23 @@ DANGER_DESC_HTML_1 = "This action will result in removing all mails from <strong
DANGER_DESC_HTML_2 = "Once started, the process cannot be aborted or cancelled."
TITLE_CLEARING_PROCESS = "Purging the folder..."
[POPUPS_IMPORT_OPEN_PGP_KEY]
TITLE_IMPORT_OPEN_PGP_KEY = "Import OpenPGP key"
BUTTON_IMPORT_OPEN_PGP_KEY = "Import"
[POPUPS_VIEW_OPEN_PGP_KEY]
TITLE_VIEW_OPEN_PGP_KEY = "View OpenPGP key"
BUTTON_SELECT = "Select"
BUTTON_CLOSE = "Close"
[POPUPS_GENERATE_OPEN_PGP_KEYS]
TITLE_GENERATE_OPEN_PGP_KEYS = "Generate OpenPGP keys"
LABEL_EMAIL = "Email"
LABEL_NAME = "Name"
LABEL_PASSWORD = "Password"
LABEL_KEY_BIT_LENGTH = "Key length"
BUTTON_GENERATE_OPEN_PGP_KEYS = "Generate"
[POPUPS_SYSTEM_FOLDERS]
TITLE_SYSTEM_FOLDERS = "Select system folders"
SELECT_CHOOSE_ONE = "Choose one"
@ -289,6 +306,7 @@ LABEL_IDENTITIES_NAME = "Identities"
LABEL_SOCIAL_NAME = "Social"
LABEL_THEMES_NAME = "Themes"
LABEL_CHANGE_PASSWORD_NAME = "Password"
LABEL_OPEN_PGP_NAME = "OpenPGP"
BUTTON_BACK = "Back"
[SETTINGS_IDENTITY]
@ -397,6 +415,14 @@ LABEL_NEW_PASSWORD = "New password"
LABEL_REPEAT_PASSWORD = "New password again"
BUTTON_UPDATE_PASSWORD = "Set New Password"
[SETTINGS_OPEN_PGP]
LEGEND_OPEN_PGP = "OpenPGP"
BUTTON_ADD_OPEN_PGP_KEY = "Import OpenPGP Key"
BUTTON_GENERATE_OPEN_PGP_KEYS = "Generate OpenPGP Keys"
TITLE_PRIVATE = "Private"
TITLE_PUBLIC = "Public"
DELETING_ASK = "Are you sure?"
[NOTIFICATIONS]
INVALID_TOKEN = "Invalid token"
AUTH_ERROR = "Authentication failed"

View file

@ -6383,19 +6383,6 @@ 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;
@ -6563,6 +6550,27 @@ html.rl-no-preview-pane #rl-right .ui-resizable-handle {
.popups .b-account-add-content .modal-header {
background-color: #fff;
}
.popups .b-open-pgp-key-view-content .modal-header,
.popups .b-open-pgp-key-generate-content .modal-header,
.popups .b-open-pgp-key-add-content .modal-header {
background-color: #fff;
}
.popups .b-open-pgp-key-view-content.modal,
.popups .b-open-pgp-key-generate-content.modal,
.popups .b-open-pgp-key-add-content.modal {
width: 570px;
}
.popups .b-open-pgp-key-view-content .inputKey,
.popups .b-open-pgp-key-generate-content .inputKey,
.popups .b-open-pgp-key-add-content .inputKey {
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
}
.popups .b-open-pgp-key-view-content .key-viewer,
.popups .b-open-pgp-key-generate-content .key-viewer,
.popups .b-open-pgp-key-add-content .key-viewer {
max-height: 500px;
overflow: auto;
}
.popups .b-identity-content .modal-header {
background-color: #fff;
}
@ -8268,6 +8276,51 @@ html.rl-message-fullscreen .messageView .b-content .buttonFull {
opacity: 0.5;
filter: alpha(opacity=50);
}
.b-settings-open-pgp .process-place {
text-align: center;
width: 600px;
padding: 14px 0;
}
.b-settings-open-pgp .list-table {
width: 750px;
}
.b-settings-open-pgp .list-table td {
padding: 4px 8px;
line-height: 30px;
}
.b-settings-open-pgp .list-table .open-pgp-key-img {
font-size: 12px;
margin-right: 5px;
}
.b-settings-open-pgp .list-table .open-pgp-key-id,
.b-settings-open-pgp .list-table .open-pgp-key-user {
display: inline-block;
word-break: break-all;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
line-height: 22px;
cursor: default;
}
.b-settings-open-pgp .open-pgp-key-item .button-delete {
margin-right: 15px;
margin-top: 5px;
visibility: hidden;
opacity: 0;
filter: alpha(opacity=0);
}
.b-settings-open-pgp .open-pgp-key-item .delete-access.button-delete {
visibility: visible;
margin-right: 0;
opacity: 1;
filter: alpha(opacity=100);
}
.b-settings-open-pgp .open-pgp-key-item .delete-open-pgp-key,
.b-settings-open-pgp .open-pgp-key-item .view-open-pgp-key {
cursor: pointer;
opacity: 0.5;
filter: alpha(opacity=50);
}
/*.folderPaddingHelper(@i) {
(~".folder-padding.deep-@{i}") {
width: 15px * @i + 10px;

File diff suppressed because one or more lines are too long

View file

@ -1020,12 +1020,13 @@ Utils.i18nToNode = function (oElement)
{
jqThis.attr('placeholder', Utils.i18n(sKey));
}
sKey = jqThis.data('i18n-title');
if (sKey)
{
jqThis.attr('title', Utils.i18n(sKey));
}
}
// sKey = jqThis.data('i18n-title');
// if (sKey)
// {
// jqThis.attr('title', Utils.i18n(sKey));
// }
});
});
};
@ -2385,6 +2386,26 @@ Utils.computedPagenatorHelper = function (koCurrentPage, koPageCount)
};
};
Utils.selectElement = function (element)
{
/* jshint onevar: false */
if (window.getSelection)
{
var sel = window.getSelection();
sel.removeAllRanges();
var range = document.createRange();
range.selectNodeContents(element);
sel.addRange(range);
}
else if (document.selection)
{
var textRange = document.body.createTextRange();
textRange.moveToElementText(element);
textRange.select();
}
/* jshint onevar: true */
};
// Base64 encode / decode
// http://www.webtoolkit.info/
@ -3671,7 +3692,6 @@ LocalStorageDriver.supported = function ()
return !!window.localStorage;
};
/**
* @param {string} sKey
* @param {*} mData
@ -3680,14 +3700,14 @@ LocalStorageDriver.supported = function ()
LocalStorageDriver.prototype.set = function (sKey, mData)
{
var
mCokieValue = window.localStorage[Consts.Values.ClientSideCookieIndexName] || null,
mCookieValue = window.localStorage[Consts.Values.ClientSideCookieIndexName] || null,
bResult = false,
mResult = null
;
try
{
mResult = null === mCokieValue ? null : JSON.parse(mCokieValue);
mResult = null === mCookieValue ? null : JSON.parse(mCookieValue);
if (!mResult)
{
mResult = {};
@ -3794,6 +3814,7 @@ KnoinAbstractBoot.prototype.bootstart = function ()
*/
function KnoinAbstractViewModel(sPosition, sTemplate)
{
this.bDisabeCloseOnEsc = false;
this.sPosition = Utils.pString(sPosition);
this.sTemplate = Utils.pString(sTemplate);
@ -3847,6 +3868,20 @@ KnoinAbstractViewModel.prototype.cancelCommand = KnoinAbstractViewModel.prototyp
{
};
KnoinAbstractViewModel.prototype.registerPopupEscapeKey = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
return false;
}
return true;
});
};
/**
* @param {string} sScreenName
* @param {?=} aViewModels = []
@ -4038,6 +4073,10 @@ Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen)
ko.applyBindings(oViewModel, oViewModelDom[0]);
Utils.delegateRun(oViewModel, 'onBuild', [oViewModelDom]);
if (oViewModel && 'Popups' === sPosition && !oViewModel.bDisabeCloseOnEsc)
{
oViewModel.registerPopupEscapeKey();
}
Plugins.runHook('view-model-post-build', [ViewModelClass.__name, oViewModel, oViewModelDom]);
}
@ -4872,20 +4911,6 @@ PopupsDomainViewModel.prototype.onFocus = function ()
}
};
PopupsDomainViewModel.prototype.onBuild = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
});
};
PopupsDomainViewModel.prototype.clearForm = function ()
{
this.edit(false);
@ -4967,6 +4992,8 @@ function PopupsPluginViewModel()
}, this.hasConfiguration);
this.bDisabeCloseOnEsc = true;
Knoin.constructorEnd(this);
}
@ -5215,20 +5242,6 @@ PopupsLanguagesViewModel.prototype.onHide = function ()
this.exp(false);
};
PopupsLanguagesViewModel.prototype.onBuild = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
});
};
PopupsLanguagesViewModel.prototype.changeLanguage = function (sLang)
{
RL.data().mainLanguage(sLang);
@ -5253,6 +5266,8 @@ function PopupsAskViewModel()
this.fYesAction = null;
this.fNoAction = null;
this.bDisabeCloseOnEsc = true;
Knoin.constructorEnd(this);
}

File diff suppressed because one or more lines are too long

View file

@ -1020,12 +1020,13 @@ Utils.i18nToNode = function (oElement)
{
jqThis.attr('placeholder', Utils.i18n(sKey));
}
sKey = jqThis.data('i18n-title');
if (sKey)
{
jqThis.attr('title', Utils.i18n(sKey));
}
}
// sKey = jqThis.data('i18n-title');
// if (sKey)
// {
// jqThis.attr('title', Utils.i18n(sKey));
// }
});
});
};
@ -2385,6 +2386,26 @@ Utils.computedPagenatorHelper = function (koCurrentPage, koPageCount)
};
};
Utils.selectElement = function (element)
{
/* jshint onevar: false */
if (window.getSelection)
{
var sel = window.getSelection();
sel.removeAllRanges();
var range = document.createRange();
range.selectNodeContents(element);
sel.addRange(range);
}
else if (document.selection)
{
var textRange = document.body.createTextRange();
textRange.moveToElementText(element);
textRange.select();
}
/* jshint onevar: true */
};
// Base64 encode / decode
// http://www.webtoolkit.info/
@ -4418,7 +4439,6 @@ LocalStorageDriver.supported = function ()
return !!window.localStorage;
};
/**
* @param {string} sKey
* @param {*} mData
@ -4427,14 +4447,14 @@ LocalStorageDriver.supported = function ()
LocalStorageDriver.prototype.set = function (sKey, mData)
{
var
mCokieValue = window.localStorage[Consts.Values.ClientSideCookieIndexName] || null,
mCookieValue = window.localStorage[Consts.Values.ClientSideCookieIndexName] || null,
bResult = false,
mResult = null
;
try
{
mResult = null === mCokieValue ? null : JSON.parse(mCokieValue);
mResult = null === mCookieValue ? null : JSON.parse(mCookieValue);
if (!mResult)
{
mResult = {};
@ -4478,6 +4498,65 @@ LocalStorageDriver.prototype.get = function (sKey)
return mResult;
};
/**
* @constructor
*/
function OpenPgpLocalStorageDriver()
{
}
/*
* Declare the localstore itemname
*/
OpenPgpLocalStorageDriver.prototype.item = 'armoredRainLoopKeys';
/**
* Load the keyring from HTML5 local storage and initializes this instance.
* @return {Array<module:key~Key>} array of keys retrieved from localstore
*/
OpenPgpLocalStorageDriver.prototype.load = function ()
{
var
iIndex = 0,
iLen = 0,
aKeys = [],
aArmoredKeys = JSON.parse(window.localStorage.getItem(this.item))
;
if (aArmoredKeys && 0 < aArmoredKeys.length)
{
for (iLen = aArmoredKeys.length; iIndex < iLen; iIndex++)
{
aKeys.push(
window.openpgp.key.readArmored(aArmoredKeys[iIndex]).keys[0]
);
}
}
return aKeys;
};
/**
* Saves the current state of the keyring to HTML5 local storage.
* The privateKeys array and publicKeys array gets Stringified using JSON
* @param {Array<module:key~Key>} aKeys array of keys to save in localstore
*/
OpenPgpLocalStorageDriver.prototype.store = function (aKeys)
{
var
iIndex = 0,
iLen = aKeys.length,
aArmoredKeys = []
;
for (; iIndex < iLen; iIndex++)
{
aArmoredKeys.push(aKeys[iIndex].armor());
}
window.localStorage.setItem(this.item, JSON.stringify(aArmoredKeys));
};
/**
* @constructor
*/
@ -4541,6 +4620,7 @@ KnoinAbstractBoot.prototype.bootstart = function ()
*/
function KnoinAbstractViewModel(sPosition, sTemplate)
{
this.bDisabeCloseOnEsc = false;
this.sPosition = Utils.pString(sPosition);
this.sTemplate = Utils.pString(sTemplate);
@ -4594,6 +4674,20 @@ KnoinAbstractViewModel.prototype.cancelCommand = KnoinAbstractViewModel.prototyp
{
};
KnoinAbstractViewModel.prototype.registerPopupEscapeKey = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
return false;
}
return true;
});
};
/**
* @param {string} sScreenName
* @param {?=} aViewModels = []
@ -4785,6 +4879,10 @@ Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen)
ko.applyBindings(oViewModel, oViewModelDom[0]);
Utils.delegateRun(oViewModel, 'onBuild', [oViewModelDom]);
if (oViewModel && 'Popups' === sPosition && !oViewModel.bDisabeCloseOnEsc)
{
oViewModel.registerPopupEscapeKey();
}
Plugins.runHook('view-model-post-build', [ViewModelClass.__name, oViewModel, oViewModelDom]);
}
@ -7237,6 +7335,31 @@ IdentityModel.prototype.formattedNameForEmail = function ()
return '' === sName ? this.email() : '"' + Utils.quoteName(sName) + '" <' + this.email() + '>';
};
/**
* @param {string} iIndex
* @param {string} sID
* @param {string} sUserID
* @param {boolean} bIsPrivate
* @param {string} sArmor
* @constructor
*/
function OpenPgpKeyModel(iIndex, sID, sUserID, bIsPrivate, sArmor)
{
this.index = iIndex;
this.id = sID;
this.user = sUserID;
this.armor = sArmor;
this.isPrivate = !!bIsPrivate;
this.deleteAccess = ko.observable(false);
}
OpenPgpKeyModel.prototype.index = 0;
OpenPgpKeyModel.prototype.id = '';
OpenPgpKeyModel.prototype.user = '';
OpenPgpKeyModel.prototype.armor = '';
OpenPgpKeyModel.prototype.isPrivate = false;
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -7333,20 +7456,6 @@ PopupsFolderClearViewModel.prototype.onShow = function (oFolder)
}
};
PopupsFolderClearViewModel.prototype.onBuild = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
});
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -7457,20 +7566,6 @@ PopupsFolderCreateViewModel.prototype.onFocus = function ()
this.folderName.focused(true);
};
PopupsFolderCreateViewModel.prototype.onBuild = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
});
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -7575,20 +7670,6 @@ PopupsFolderSystemViewModel.prototype.onShow = function (iNotificationType)
this.notification(sNotification);
};
PopupsFolderSystemViewModel.prototype.onBuild = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
});
};
/**
* @constructor
@ -7979,6 +8060,8 @@ function PopupsComposeViewModel()
// this.driveCallback = _.bind(this.driveCallback, this);
this.bDisabeCloseOnEsc = true;
Knoin.constructorEnd(this);
}
@ -9672,25 +9755,6 @@ PopupsContactsViewModel.prototype.onBuild = function (oDom)
})
;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && self.modalVisibility())
{
if (Enums.EventKeyCode.Esc === oEvent.keyCode)
{
Utils.delegateRun(self, 'closeCommand');
bResult = false;
}
else if (oEvent.ctrlKey && Enums.EventKeyCode.S === oEvent.keyCode)
{
self.saveCommand();
bResult = false;
}
}
return bResult;
});
this.initUploader();
};
@ -9842,20 +9906,6 @@ PopupsAdvancedSearchViewModel.prototype.onFocus = function ()
this.fromFocus(true);
};
PopupsAdvancedSearchViewModel.prototype.onBuild = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
});
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -9971,17 +10021,195 @@ PopupsAddAccountViewModel.prototype.onFocus = function ()
PopupsAddAccountViewModel.prototype.onBuild = function ()
{
this.allowCustomLogin(!!RL.settingsGet('AllowCustomLogin'));
};
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function PopupsAddOpenPgpKeyViewModel()
{
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAddOpenPgpKey');
this.key = ko.observable('');
this.key.error = ko.observable(false);
this.key.focus = ko.observable(false);
this.key.subscribe(function () {
this.key.error(false);
}, this);
this.addOpenPgpKeyCommand = Utils.createCommand(this, function () {
var
sKey = Utils.trim(this.key()),
oOpenpgpKeyring = RL.data().openpgpKeyring
;
this.key.error('' === sKey);
if (!oOpenpgpKeyring || this.key.error())
{
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
return false;
}
return bResult;
oOpenpgpKeyring.importKey(sKey);
oOpenpgpKeyring.store();
RL.reloadOpenPgpKeys();
Utils.delegateRun(this, 'cancelCommand');
return true;
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsAddOpenPgpKeyViewModel', PopupsAddOpenPgpKeyViewModel);
PopupsAddOpenPgpKeyViewModel.prototype.clearPopup = function ()
{
this.key('');
this.key.error(false);
};
PopupsAddOpenPgpKeyViewModel.prototype.onShow = function ()
{
this.clearPopup();
};
PopupsAddOpenPgpKeyViewModel.prototype.onFocus = function ()
{
this.key.focus(true);
};
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function PopupsViewOpenPgpKeyViewModel()
{
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsViewOpenPgpKey');
this.key = ko.observable('');
this.keyDom = ko.observable(null);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsViewOpenPgpKeyViewModel', PopupsViewOpenPgpKeyViewModel);
PopupsViewOpenPgpKeyViewModel.prototype.clearPopup = function ()
{
this.key('');
};
PopupsViewOpenPgpKeyViewModel.prototype.selectKey = function ()
{
var oEl = this.keyDom();
if (oEl)
{
Utils.selectElement(oEl);
}
};
PopupsViewOpenPgpKeyViewModel.prototype.onShow = function (oOpenPgpKey)
{
this.clearPopup();
if (oOpenPgpKey)
{
this.key(oOpenPgpKey.armor);
}
};
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function PopupsGenerateNewOpenPgpKeyViewModel()
{
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsGenerateNewOpenPgpKey');
this.email = ko.observable('');
this.email.focus = ko.observable('');
this.email.error = ko.observable(false);
this.name = ko.observable('');
this.password = ko.observable('');
this.keyBitLength = ko.observable(2048);
this.submitRequest = ko.observable(false);
this.email.subscribe(function () {
this.email.error(false);
}, this);
this.generateOpenPgpKeyCommand = Utils.createCommand(this, function () {
var
self = this,
sUserID = '',
mKeyPair = null,
oOpenpgpKeyring = RL.data().openpgpKeyring
;
this.email.error('' === Utils.trim(this.email()));
if (!oOpenpgpKeyring || this.email.error())
{
return false;
}
sUserID = this.email();
if ('' !== this.name())
{
sUserID = this.name() + ' <' + sUserID + '>';
}
this.submitRequest(true);
_.delay(function () {
mKeyPair = window.openpgp.generateKeyPair(1, Utils.pInt(self.keyBitLength()), sUserID, Utils.trim(self.password()));
if (mKeyPair && mKeyPair.privateKeyArmored)
{
oOpenpgpKeyring.importKey(mKeyPair.privateKeyArmored);
oOpenpgpKeyring.importKey(mKeyPair.publicKeyArmored);
oOpenpgpKeyring.store();
RL.reloadOpenPgpKeys();
Utils.delegateRun(self, 'cancelCommand');
}
self.submitRequest(false);
}, 100);
return true;
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsGenerateNewOpenPgpKeyViewModel', PopupsGenerateNewOpenPgpKeyViewModel);
PopupsGenerateNewOpenPgpKeyViewModel.prototype.clearPopup = function ()
{
this.name('');
this.password('');
this.email('');
this.email.error(false);
this.keyBitLength(2048);
};
PopupsGenerateNewOpenPgpKeyViewModel.prototype.onShow = function ()
{
this.clearPopup();
};
PopupsGenerateNewOpenPgpKeyViewModel.prototype.onFocus = function ()
{
this.email.focus(true);
};
/**
@ -10132,20 +10360,6 @@ PopupsIdentityViewModel.prototype.onFocus = function ()
}
};
PopupsIdentityViewModel.prototype.onBuild = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
});
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -10200,20 +10414,6 @@ PopupsLanguagesViewModel.prototype.onHide = function ()
this.exp(false);
};
PopupsLanguagesViewModel.prototype.onBuild = function ()
{
var self = this;
$window.on('keydown', function (oEvent) {
var bResult = true;
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
bResult = false;
}
return bResult;
});
};
PopupsLanguagesViewModel.prototype.changeLanguage = function (sLang)
{
RL.data().mainLanguage(sLang);
@ -10238,6 +10438,8 @@ function PopupsAskViewModel()
this.fYesAction = null;
this.fNoAction = null;
this.bDisabeCloseOnEsc = true;
Knoin.constructorEnd(this);
}
@ -10338,69 +10540,6 @@ 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
@ -12024,38 +12163,6 @@ 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
@ -12850,6 +12957,87 @@ function SettingsSocialScreen()
Utils.addSettingsViewModel(SettingsSocialScreen, 'SettingsSocial', 'SETTINGS_LABELS/LABEL_SOCIAL_NAME', 'social');
/**
* @constructor
*/
function SettingsOpenPGP()
{
this.openpgpkeys = RL.data().openpgpkeys;
this.openpgpkeysPublic = ko.computed(function () {
return _.filter(this.openpgpkeys(), function (oItem) {
return !!(oItem && !oItem.isPrivate);
});
}, this);
this.openpgpkeysPrivate = ko.computed(function () {
return _.filter(this.openpgpkeys(), function (oItem) {
return !!(oItem && oItem.isPrivate);
});
}, this);
this.openPgpKeyForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.deleteAccess(false);
}
}, function (oNext) {
if (oNext)
{
oNext.deleteAccess(true);
}
}
]});
}
Utils.addSettingsViewModel(SettingsOpenPGP, 'SettingsOpenPGP', 'SETTINGS_LABELS/LABEL_OPEN_PGP_NAME', 'openpgp');
SettingsOpenPGP.prototype.addOpenPgpKey = function ()
{
kn.showScreenPopup(PopupsAddOpenPgpKeyViewModel);
};
SettingsOpenPGP.prototype.generateOpenPgpKey = function ()
{
kn.showScreenPopup(PopupsGenerateNewOpenPgpKeyViewModel);
};
SettingsOpenPGP.prototype.viewOpenPgpKey = function (oOpenPgpKey)
{
if (oOpenPgpKey)
{
kn.showScreenPopup(PopupsViewOpenPgpKeyViewModel, [oOpenPgpKey]);
}
};
/**
* @param {OpenPgpKeyModel} oOpenPgpKeyToRemove
*/
SettingsOpenPGP.prototype.deleteOpenPgpKey = function (oOpenPgpKeyToRemove)
{
if (oOpenPgpKeyToRemove && oOpenPgpKeyToRemove.deleteAccess())
{
this.openPgpKeyForDeletion(null);
var
oOpenpgpKeyring = RL.data().openpgpKeyring,
fRemoveAccount = function (oOpenPgpKey) {
return oOpenPgpKeyToRemove === oOpenPgpKey;
}
;
if (oOpenPgpKeyToRemove && oOpenpgpKeyring)
{
this.openpgpkeys.remove(fRemoveAccount);
oOpenpgpKeyring.removeKey(oOpenPgpKeyToRemove.index);
oOpenpgpKeyring.store();
RL.reloadOpenPgpKeys();
}
}
};
/**
* @constructor
*/
@ -13752,6 +13940,9 @@ function WebMailDataStorage()
// other
this.useKeyboardShortcuts = ko.observable(true);
this.openpgpkeys = ko.observableArray([]);
this.openpgpKeyring = null;
// google
this.googleActions = ko.observable(false);
@ -16708,6 +16899,36 @@ RainLoopApp.prototype.folders = function (fCallback)
}, this));
};
RainLoopApp.prototype.reloadOpenPgpKeys = function ()
{
if (Globals.bAllowOpenPGP)
{
var
aKeys = [],
oOpenpgpKeyring = RL.data().openpgpKeyring,
oOpenpgpKeys = oOpenpgpKeyring ? oOpenpgpKeyring.keys : []
;
_.each(oOpenpgpKeys, function (oItem, iIndex) {
if (oItem)
{
var
aIDs = _.map(oItem.getKeyIds(), function (oID) {
return oID ? oID.toHex() : '';
})
;
aKeys.push(
new OpenPgpKeyModel(iIndex, aIDs.join(', '), oItem.getUserIds().join(', '),
oItem.isPrivate(), oItem.armor())
);
}
});
RL.data().openpgpkeys(aKeys);
}
};
RainLoopApp.prototype.accountsAndIdentities = function ()
{
var oRainLoopData = RL.data();
@ -17257,6 +17478,11 @@ RainLoopApp.prototype.bootstart = function ()
{
Utils.removeSettingsViewModel(SettingsIdentities);
}
if (!RL.settingsGet('OpenPGP'))
{
Utils.removeSettingsViewModel(SettingsOpenPGP);
}
if (!bGoogle && !bFacebook && !bTwitter)
{
@ -17313,9 +17539,12 @@ RainLoopApp.prototype.bootstart = function ()
'success': function () {
if (window.openpgp)
{
// window.console.log(window.openpgp);
RL.data().openpgpKeyring = new window.openpgp.Keyring(new OpenPgpLocalStorageDriver());
Globals.bAllowOpenPGP = true;
RL.pub('openpgp.init');
RL.reloadOpenPgpKeys();
}
}
});

File diff suppressed because one or more lines are too long