2014-08-21 23:08:34 +08:00
|
|
|
|
2014-09-05 06:49:03 +08:00
|
|
|
(function () {
|
2014-09-02 08:15:31 +08:00
|
|
|
|
2014-08-25 23:49:01 +08:00
|
|
|
'use strict';
|
2014-08-21 23:08:34 +08:00
|
|
|
|
|
|
|
var
|
2014-08-25 23:49:01 +08:00
|
|
|
ko = require('ko'),
|
2014-09-02 08:15:31 +08:00
|
|
|
|
2014-09-06 05:44:29 +08:00
|
|
|
kn = require('Knoin/Knoin'),
|
2014-09-02 08:15:31 +08:00
|
|
|
|
2014-09-06 05:44:29 +08:00
|
|
|
Data = require('Storage/App/Data')
|
2014-08-21 23:08:34 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
*/
|
2014-09-06 05:44:29 +08:00
|
|
|
function OpenPGPAppSetting()
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
2014-08-22 23:08:56 +08:00
|
|
|
this.openpgpkeys = Data.openpgpkeys;
|
|
|
|
this.openpgpkeysPublic = Data.openpgpkeysPublic;
|
|
|
|
this.openpgpkeysPrivate = Data.openpgpkeysPrivate;
|
2014-08-21 23:08:34 +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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]});
|
|
|
|
}
|
|
|
|
|
2014-09-06 05:44:29 +08:00
|
|
|
OpenPGPAppSetting.prototype.addOpenPgpKey = function ()
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
2014-09-06 05:44:29 +08:00
|
|
|
kn.showScreenPopup(require('View/Popup/AddOpenPgpKey'));
|
2014-08-21 23:08:34 +08:00
|
|
|
};
|
|
|
|
|
2014-09-06 05:44:29 +08:00
|
|
|
OpenPGPAppSetting.prototype.generateOpenPgpKey = function ()
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
2014-09-06 05:44:29 +08:00
|
|
|
kn.showScreenPopup(require('View/Popup/NewOpenPgpKey'));
|
2014-08-21 23:08:34 +08:00
|
|
|
};
|
|
|
|
|
2014-09-06 05:44:29 +08:00
|
|
|
OpenPGPAppSetting.prototype.viewOpenPgpKey = function (oOpenPgpKey)
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
|
|
|
if (oOpenPgpKey)
|
|
|
|
{
|
2014-09-06 05:44:29 +08:00
|
|
|
kn.showScreenPopup(require('View/Popup/ViewOpenPgpKey'), [oOpenPgpKey]);
|
2014-08-21 23:08:34 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {OpenPgpKeyModel} oOpenPgpKeyToRemove
|
|
|
|
*/
|
2014-09-06 05:44:29 +08:00
|
|
|
OpenPGPAppSetting.prototype.deleteOpenPgpKey = function (oOpenPgpKeyToRemove)
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
|
|
|
if (oOpenPgpKeyToRemove && oOpenPgpKeyToRemove.deleteAccess())
|
|
|
|
{
|
|
|
|
this.openPgpKeyForDeletion(null);
|
|
|
|
|
2014-08-22 23:08:56 +08:00
|
|
|
if (oOpenPgpKeyToRemove && Data.openpgpKeyring)
|
2014-08-21 23:08:34 +08:00
|
|
|
{
|
|
|
|
this.openpgpkeys.remove(function (oOpenPgpKey) {
|
|
|
|
return oOpenPgpKeyToRemove === oOpenPgpKey;
|
|
|
|
});
|
|
|
|
|
2014-08-22 23:08:56 +08:00
|
|
|
Data.openpgpKeyring[oOpenPgpKeyToRemove.isPrivate ? 'privateKeys' : 'publicKeys']
|
2014-08-21 23:08:34 +08:00
|
|
|
.removeForId(oOpenPgpKeyToRemove.guid);
|
|
|
|
|
2014-08-22 23:08:56 +08:00
|
|
|
Data.openpgpKeyring.store();
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2014-09-06 05:44:29 +08:00
|
|
|
require('App/App').reloadOpenPgpKeys();
|
2014-08-21 23:08:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-09-06 05:44:29 +08:00
|
|
|
module.exports = OpenPGPAppSetting;
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2014-09-05 06:49:03 +08:00
|
|
|
}());
|