mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-14 19:54:43 +08:00
92 lines
No EOL
1.9 KiB
JavaScript
92 lines
No EOL
1.9 KiB
JavaScript
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
var
|
|
_ = require('_'),
|
|
ko = require('ko'),
|
|
|
|
Utils = require('Common/Utils'),
|
|
|
|
kn = require('Knoin/Knoin'),
|
|
|
|
PgpStore = require('Stores/User/Pgp')
|
|
;
|
|
|
|
/**
|
|
* @constructor
|
|
*/
|
|
function OpenPgpUserSettings()
|
|
{
|
|
this.openpgpkeys = PgpStore.openpgpkeys;
|
|
this.openpgpkeysPublic = PgpStore.openpgpkeysPublic;
|
|
this.openpgpkeysPrivate = PgpStore.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);
|
|
}
|
|
}
|
|
]});
|
|
}
|
|
|
|
OpenPgpUserSettings.prototype.addOpenPgpKey = function ()
|
|
{
|
|
kn.showScreenPopup(require('View/Popup/AddOpenPgpKey'));
|
|
};
|
|
|
|
OpenPgpUserSettings.prototype.generateOpenPgpKey = function ()
|
|
{
|
|
kn.showScreenPopup(require('View/Popup/NewOpenPgpKey'));
|
|
};
|
|
|
|
OpenPgpUserSettings.prototype.viewOpenPgpKey = function (oOpenPgpKey)
|
|
{
|
|
if (oOpenPgpKey)
|
|
{
|
|
kn.showScreenPopup(require('View/Popup/ViewOpenPgpKey'), [oOpenPgpKey]);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @param {OpenPgpKeyModel} oOpenPgpKeyToRemove
|
|
*/
|
|
OpenPgpUserSettings.prototype.deleteOpenPgpKey = function (oOpenPgpKeyToRemove)
|
|
{
|
|
if (oOpenPgpKeyToRemove && oOpenPgpKeyToRemove.deleteAccess())
|
|
{
|
|
this.openPgpKeyForDeletion(null);
|
|
|
|
if (oOpenPgpKeyToRemove && PgpStore.openpgpKeyring)
|
|
{
|
|
var oFindedItem = _.find(PgpStore.openpgpkeys(), function (oOpenPgpKey) {
|
|
return oOpenPgpKeyToRemove === oOpenPgpKey;
|
|
});
|
|
|
|
if (oFindedItem)
|
|
{
|
|
PgpStore.openpgpkeys.remove(oFindedItem);
|
|
Utils.delegateRunOnDestroy(oFindedItem);
|
|
|
|
PgpStore.openpgpKeyring[oFindedItem.isPrivate ? 'privateKeys' : 'publicKeys']
|
|
.removeForId(oFindedItem.guid);
|
|
|
|
PgpStore.openpgpKeyring.store();
|
|
}
|
|
|
|
require('App/User').reloadOpenPgpKeys();
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = OpenPgpUserSettings;
|
|
|
|
}()); |