2022-01-30 09:35:53 +08:00
|
|
|
import { GnuPGUserStore } from 'Stores/User/GnuPG';
|
|
|
|
import { OpenPGPUserStore } from 'Stores/User/OpenPGP';
|
2021-03-11 05:41:35 +08:00
|
|
|
import { SettingsUserStore } from 'Stores/User/Settings';
|
2017-06-29 00:25:53 +08:00
|
|
|
|
2020-09-15 01:40:56 +08:00
|
|
|
import Remote from 'Remote/User/Fetch';
|
2014-10-04 19:58:01 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
import { showScreenPopup } from 'Knoin/Knoin';
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2022-01-27 23:00:52 +08:00
|
|
|
import { OpenPgpImportPopupView } from 'View/Popup/OpenPgpImport';
|
|
|
|
import { OpenPgpGeneratePopupView } from 'View/Popup/OpenPgpGenerate';
|
2021-01-26 05:00:13 +08:00
|
|
|
|
2022-01-24 23:47:53 +08:00
|
|
|
import { Capa } from 'Common/Enums';
|
2022-02-08 20:48:11 +08:00
|
|
|
import { SettingsCapa } from 'Common/Globals';
|
2022-01-24 23:47:53 +08:00
|
|
|
|
2021-09-23 02:17:44 +08:00
|
|
|
export class OpenPgpUserSettings /*extends AbstractViewSettings*/ {
|
2016-07-16 05:29:42 +08:00
|
|
|
constructor() {
|
2022-01-30 09:35:53 +08:00
|
|
|
this.gnupgPublicKeys = GnuPGUserStore.publicKeys;
|
|
|
|
this.gnupgPrivateKeys = GnuPGUserStore.privateKeys;
|
2014-09-02 08:15:31 +08:00
|
|
|
|
2022-01-30 09:35:53 +08:00
|
|
|
this.openpgpkeysPublic = OpenPGPUserStore.publicKeys;
|
|
|
|
this.openpgpkeysPrivate = OpenPGPUserStore.privateKeys;
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2022-02-08 20:48:11 +08:00
|
|
|
this.canOpenPGP = SettingsCapa(Capa.OpenPGP);
|
2022-01-30 09:35:53 +08:00
|
|
|
this.canGnuPG = GnuPGUserStore.isSupported();
|
2022-01-24 20:43:53 +08:00
|
|
|
this.canMailvelope = !!window.mailvelope;
|
2022-01-20 23:38:27 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
this.allowDraftAutosave = SettingsUserStore.allowDraftAutosave;
|
2021-03-18 23:12:24 +08:00
|
|
|
|
|
|
|
this.allowDraftAutosave.subscribe(value => Remote.saveSetting('AllowDraftAutosave', value ? 1 : 0))
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
addOpenPgpKey() {
|
2022-01-27 23:00:52 +08:00
|
|
|
showScreenPopup(OpenPgpImportPopupView);
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
generateOpenPgpKey() {
|
2022-01-27 23:00:52 +08:00
|
|
|
showScreenPopup(OpenPgpGeneratePopupView);
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
|
|
|
|
2022-01-24 20:43:53 +08:00
|
|
|
onBuild() {
|
2022-01-27 00:08:10 +08:00
|
|
|
/**
|
|
|
|
* Create an iframe to display the Mailvelope keyring settings.
|
|
|
|
* The iframe will be injected into the container identified by selector.
|
|
|
|
*/
|
|
|
|
window.mailvelope && mailvelope.createSettingsContainer('#mailvelope-settings'/*[, keyring], options*/);
|
2022-01-24 20:43:53 +08:00
|
|
|
}
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|