mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-09 08:17:53 +08:00
89 lines
No EOL
2.1 KiB
JavaScript
89 lines
No EOL
2.1 KiB
JavaScript
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
|
|
(function (module, require) {
|
|
|
|
'use strict';
|
|
|
|
var
|
|
ko = require('ko'),
|
|
|
|
kn = require('kn'),
|
|
|
|
Data = require('../../Storages/WebMailDataStorage.js'),
|
|
|
|
PopupsAddOpenPgpKeyViewModel = require('../../ViewModels/Popups/PopupsAddOpenPgpKeyViewModel.js'),
|
|
PopupsGenerateNewOpenPgpKeyViewModel = require('../../ViewModels/Popups/PopupsGenerateNewOpenPgpKeyViewModel.js'),
|
|
PopupsViewOpenPgpKeyViewModel = require('../../ViewModels/Popups/PopupsViewOpenPgpKeyViewModel.js')
|
|
;
|
|
|
|
/**
|
|
* @constructor
|
|
*/
|
|
function SettingsOpenPGP()
|
|
{
|
|
this.openpgpkeys = Data.openpgpkeys;
|
|
this.openpgpkeysPublic = Data.openpgpkeysPublic;
|
|
this.openpgpkeysPrivate = Data.openpgpkeysPrivate;
|
|
|
|
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);
|
|
}
|
|
}
|
|
]});
|
|
}
|
|
|
|
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);
|
|
|
|
if (oOpenPgpKeyToRemove && Data.openpgpKeyring)
|
|
{
|
|
this.openpgpkeys.remove(function (oOpenPgpKey) {
|
|
return oOpenPgpKeyToRemove === oOpenPgpKey;
|
|
});
|
|
|
|
Data.openpgpKeyring[oOpenPgpKeyToRemove.isPrivate ? 'privateKeys' : 'publicKeys']
|
|
.removeForId(oOpenPgpKeyToRemove.guid);
|
|
|
|
Data.openpgpKeyring.store();
|
|
|
|
var App = require('../../Apps/RainLoopApp.js');
|
|
App.reloadOpenPgpKeys();
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = SettingsOpenPGP;
|
|
|
|
}(module, require)); |