2014-03-13 06:29:33 +08:00
|
|
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
function SettingsOpenPGP()
|
|
|
|
{
|
|
|
|
this.openpgpkeys = RL.data().openpgpkeys;
|
2014-03-21 07:47:13 +08:00
|
|
|
this.openpgpkeysPublic = RL.data().openpgpkeysPublic;
|
|
|
|
this.openpgpkeysPrivate = RL.data().openpgpkeysPrivate;
|
2014-03-13 06:29:33 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2014-04-27 00:09:38 +08:00
|
|
|
if (oOpenPgpKeyToRemove && RL.data().openpgpKeyring)
|
2014-03-13 06:29:33 +08:00
|
|
|
{
|
2014-04-27 00:09:38 +08:00
|
|
|
this.openpgpkeys.remove(function (oOpenPgpKey) {
|
|
|
|
return oOpenPgpKeyToRemove === oOpenPgpKey;
|
2014-03-21 00:05:35 +08:00
|
|
|
});
|
|
|
|
|
2014-04-27 00:09:38 +08:00
|
|
|
RL.data().openpgpKeyring[oOpenPgpKeyToRemove.isPrivate ? 'privateKeys' : 'publicKeys']
|
|
|
|
.removeForId(oOpenPgpKeyToRemove.guid);
|
2014-03-21 00:05:35 +08:00
|
|
|
|
2014-04-27 00:09:38 +08:00
|
|
|
RL.data().openpgpKeyring.store();
|
2014-03-13 06:29:33 +08:00
|
|
|
|
|
|
|
RL.reloadOpenPgpKeys();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|