aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/codeql-analysis.yml40
-rw-r--r--.github/workflows/debug.yml18
-rw-r--r--.github/workflows/release-deb-package.yml2
-rw-r--r--.github/workflows/release.yml28
-rw-r--r--.gitignore2
-rw-r--r--.gitmodules6
-rw-r--r--CMakeLists.txt92
-rw-r--r--Doxyfile2579
-rw-r--r--cmake/cotire.cmake4212
-rw-r--r--manual/.nojekyll0
-rw-r--r--manual/CNAME1
-rw-r--r--manual/_coverpage.md33
-rw-r--r--manual/_media/_coverpage/gpgfrontend-logo.pngbin0 -> 17878 bytes
-rw-r--r--manual/_media/icon.svg1
-rw-r--r--manual/_media/trademark.pngbin0 -> 17878 bytes
-rw-r--r--manual/_navbar.md9
-rw-r--r--manual/_sidebar.md29
-rw-r--r--manual/about/code-binary-verify.md152
-rw-r--r--manual/basic-concepts.md58
-rw-r--r--manual/contract.md136
-rw-r--r--manual/faq.md46
-rw-r--r--manual/features/introduce.md4
-rw-r--r--manual/features/short-ciphertext.md14
-rw-r--r--manual/features/sync-all-public-keys.md26
-rw-r--r--manual/index.html33
-rw-r--r--manual/manual/advance-key-opera.md3
-rw-r--r--manual/manual/email-operations.md1
-rw-r--r--manual/manual/encrypt-decrypt-file.md52
-rw-r--r--manual/manual/encrypt-decrypt-text.md83
-rw-r--r--manual/manual/generate-key.md118
-rw-r--r--manual/manual/import-export-key-pair.md100
-rw-r--r--manual/manual/key-server-operations.md113
-rwxr-xr-xmanual/manual/sign-verify-file.md48
-rw-r--r--manual/manual/sign-verify-text.md46
-rw-r--r--manual/manual/understand-interface.md134
-rw-r--r--manual/manual/view-keypair-info.md174
-rw-r--r--manual/overview.md77
-rw-r--r--manual/quick-start.md123
-rw-r--r--manual/translate-interface.md37
-rw-r--r--src/CMakeLists.txt147
-rw-r--r--src/GpgFrontend.h.in41
-rw-r--r--src/GpgFrontendBuildInfo.h.in16
-rw-r--r--src/GpgFrontendBuildInstallInfo.h.in16
-rw-r--r--src/advance/CMakeLists.txt6
-rw-r--r--src/advance/UnknownSignersChecker.cpp75
-rw-r--r--src/advance/UnknownSignersChecker.h49
-rw-r--r--src/before_exit.cpp24
-rw-r--r--src/core/CMakeLists.txt101
-rw-r--r--src/core/GpgConstants.cpp (renamed from src/gpg/GpgConstants.cpp)29
-rw-r--r--src/core/GpgConstants.h (renamed from src/gpg/GpgConstants.h)16
-rw-r--r--src/core/GpgContext.cpp (renamed from src/gpg/GpgContext.cpp)18
-rw-r--r--src/core/GpgContext.h (renamed from src/gpg/GpgContext.h)16
-rw-r--r--src/core/GpgCoreInit.cpp (renamed from src/gpg/GpgCoreInit.cpp)16
-rw-r--r--src/core/GpgCoreInit.h (renamed from src/gpg/GpgCoreInit.h)16
-rw-r--r--src/core/GpgFrontendCore.h61
-rw-r--r--src/core/GpgFunctionObject.h (renamed from src/gpg/GpgFunctionObject.h)16
-rw-r--r--src/core/GpgGenKeyInfo.cpp (renamed from src/gpg/GpgGenKeyInfo.cpp)18
-rw-r--r--src/core/GpgGenKeyInfo.h (renamed from src/gpg/GpgGenKeyInfo.h)16
-rw-r--r--src/core/GpgInfo.cpp (renamed from src/gpg/GpgInfo.cpp)18
-rw-r--r--src/core/GpgInfo.h (renamed from src/gpg/GpgInfo.h)18
-rw-r--r--src/core/GpgModel.h (renamed from src/gpg/GpgModel.h)22
-rw-r--r--src/core/function/ArchiveFileOperator.cpp238
-rw-r--r--src/core/function/ArchiveFileOperator.h79
-rw-r--r--src/core/function/DataObjectOperator.cpp169
-rw-r--r--src/core/function/DataObjectOperator.h82
-rw-r--r--src/core/function/FileOperator.cpp119
-rw-r--r--src/core/function/FileOperator.h92
-rw-r--r--src/core/function/GlobalSettingStation.cpp141
-rw-r--r--src/core/function/GlobalSettingStation.h232
-rw-r--r--src/core/function/KeyPackageOperator.cpp120
-rw-r--r--src/core/function/KeyPackageOperator.h107
-rw-r--r--src/core/function/PassphraseGenerator.cpp29
-rw-r--r--src/core/function/PassphraseGenerator.h83
-rw-r--r--src/core/function/aes/aes_ssl.h74
-rw-r--r--src/core/function/aes/aes_ssl_cbc.cpp99
-rw-r--r--src/core/function/gpg/GpgBasicOperator.cpp (renamed from src/gpg/function/BasicOperator.cpp)38
-rw-r--r--src/core/function/gpg/GpgBasicOperator.h (renamed from src/gpg/function/BasicOperator.h)30
-rw-r--r--src/core/function/gpg/GpgCommandExecutor.cpp (renamed from src/gpg/function/GpgCommandExecutor.cpp)18
-rw-r--r--src/core/function/gpg/GpgCommandExecutor.h (renamed from src/gpg/function/GpgCommandExecutor.h)20
-rw-r--r--src/core/function/gpg/GpgFileOpera.cpp (renamed from src/gpg/function/GpgFileOpera.cpp)96
-rw-r--r--src/core/function/gpg/GpgFileOpera.h (renamed from src/gpg/function/GpgFileOpera.h)26
-rw-r--r--src/core/function/gpg/GpgKeyGetter.cpp (renamed from src/gpg/function/GpgKeyGetter.cpp)18
-rw-r--r--src/core/function/gpg/GpgKeyGetter.h (renamed from src/gpg/function/GpgKeyGetter.h)22
-rw-r--r--src/core/function/gpg/GpgKeyImportExporter.cpp (renamed from src/gpg/function/GpgKeyImportExporter.cpp)20
-rw-r--r--src/core/function/gpg/GpgKeyImportExporter.h (renamed from src/gpg/function/GpgKeyImportExporter.h)24
-rw-r--r--src/core/function/gpg/GpgKeyManager.cpp (renamed from src/gpg/function/GpgKeyManager.cpp)24
-rw-r--r--src/core/function/gpg/GpgKeyManager.h (renamed from src/gpg/function/GpgKeyManager.h)22
-rw-r--r--src/core/function/gpg/GpgKeyOpera.cpp (renamed from src/gpg/function/GpgKeyOpera.cpp)26
-rw-r--r--src/core/function/gpg/GpgKeyOpera.h (renamed from src/gpg/function/GpgKeyOpera.h)22
-rw-r--r--src/core/function/gpg/GpgUIDOperator.cpp (renamed from src/gpg/function/UIDOperator.cpp)26
-rw-r--r--src/core/function/gpg/GpgUIDOperator.h (renamed from src/gpg/function/UIDOperator.h)26
-rw-r--r--src/core/function/result_analyse/GpgDecryptResultAnalyse.cpp (renamed from src/gpg/result_analyse/DecryptResultAnalyse.cpp)26
-rw-r--r--src/core/function/result_analyse/GpgDecryptResultAnalyse.h (renamed from src/gpg/result_analyse/DecryptResultAnalyse.h)30
-rw-r--r--src/core/function/result_analyse/GpgEncryptResultAnalyse.cpp (renamed from src/gpg/result_analyse/EncryptResultAnalyse.cpp)22
-rw-r--r--src/core/function/result_analyse/GpgEncryptResultAnalyse.h (renamed from src/gpg/result_analyse/EncryptResultAnalyse.h)30
-rw-r--r--src/core/function/result_analyse/GpgResultAnalyse.cpp46
-rw-r--r--src/core/function/result_analyse/GpgResultAnalyse.h (renamed from src/gpg/result_analyse/ResultAnalyse.h)28
-rw-r--r--src/core/function/result_analyse/GpgSignResultAnalyse.cpp (renamed from src/gpg/result_analyse/SignResultAnalyse.cpp)24
-rw-r--r--src/core/function/result_analyse/GpgSignResultAnalyse.h (renamed from src/gpg/result_analyse/SignResultAnalyse.h)28
-rw-r--r--src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp (renamed from src/gpg/result_analyse/VerifyResultAnalyse.cpp)32
-rw-r--r--src/core/function/result_analyse/GpgVerifyResultAnalyse.h (renamed from src/gpg/result_analyse/VerifyResultAnalyse.h)30
-rw-r--r--src/core/model/GpgData.cpp (renamed from src/gpg/model/GpgData.cpp)18
-rw-r--r--src/core/model/GpgData.h (renamed from src/gpg/model/GpgData.h)18
-rw-r--r--src/core/model/GpgKey.cpp (renamed from src/gpg/model/GpgKey.cpp)18
-rw-r--r--src/core/model/GpgKey.h (renamed from src/gpg/model/GpgKey.h)16
-rw-r--r--src/core/model/GpgKeySignature.cpp (renamed from src/gpg/model/GpgKeySignature.cpp)18
-rw-r--r--src/core/model/GpgKeySignature.h (renamed from src/gpg/model/GpgKeySignature.h)18
-rw-r--r--src/core/model/GpgSignature.cpp (renamed from src/gpg/model/GpgSignature.cpp)16
-rw-r--r--src/core/model/GpgSignature.h (renamed from src/gpg/model/GpgSignature.h)18
-rw-r--r--src/core/model/GpgSubKey.cpp (renamed from src/gpg/model/GpgSubKey.cpp)18
-rw-r--r--src/core/model/GpgSubKey.h (renamed from src/gpg/model/GpgSubKey.h)18
-rw-r--r--src/core/model/GpgTOFUInfo.cpp (renamed from src/gpg/model/GpgTOFUInfo.cpp)16
-rw-r--r--src/core/model/GpgTOFUInfo.h (renamed from src/gpg/model/GpgTOFUInfo.h)18
-rw-r--r--src/core/model/GpgUID.cpp (renamed from src/gpg/model/GpgUID.cpp)18
-rw-r--r--src/core/model/GpgUID.h (renamed from src/gpg/model/GpgUID.h)16
-rw-r--r--src/gpg/CMakeLists.txt40
-rw-r--r--src/gpg/result_analyse/ResultAnalyse.cpp42
-rw-r--r--src/init.cpp72
-rw-r--r--src/main.cpp105
-rw-r--r--src/server/BaseAPI.cpp69
-rw-r--r--src/server/BaseAPI.h66
-rw-r--r--src/server/CMakeLists.txt7
-rw-r--r--src/server/ComUtils.cpp213
-rw-r--r--src/server/ComUtils.h88
-rw-r--r--src/server/api/PubkeyGetter.cpp95
-rw-r--r--src/server/api/PubkeyGetter.h52
-rw-r--r--src/server/api/PubkeyUploader.cpp106
-rw-r--r--src/server/api/PubkeyUploader.h51
-rw-r--r--src/signal.cpp21
-rw-r--r--src/ui/CMakeLists.txt96
-rw-r--r--src/ui/FindWidget.cpp165
-rw-r--r--src/ui/GpgFrontendUI.h55
-rw-r--r--src/ui/KeyImportDetailDialog.h55
-rwxr-xr-xsrc/ui/KeyMgmt.cpp401
-rwxr-xr-xsrc/ui/KeyMgmt.h201
-rw-r--r--src/ui/KeyServerImportDialog.h93
-rw-r--r--src/ui/MainWindow.h407
-rwxr-xr-xsrc/ui/QuitDialog.h53
-rw-r--r--src/ui/ShowCopyDialog.cpp59
-rw-r--r--src/ui/ShowCopyDialog.h50
-rw-r--r--src/ui/SignalStation.cpp16
-rw-r--r--src/ui/SignalStation.h47
-rw-r--r--src/ui/UserInterfaceUtils.cpp146
-rw-r--r--src/ui/UserInterfaceUtils.h178
-rw-r--r--src/ui/data_struct/SettingsObject.cpp61
-rw-r--r--src/ui/details/SignatureDetailsDialog.cpp16
-rw-r--r--src/ui/details/SignatureDetailsDialog.h17
-rw-r--r--src/ui/details/VerifyDetailsDialog.cpp18
-rw-r--r--src/ui/details/VerifyDetailsDialog.h16
-rwxr-xr-xsrc/ui/dialog/QuitDialog.cpp (renamed from src/ui/QuitDialog.cpp)70
-rwxr-xr-xsrc/ui/dialog/QuitDialog.h82
-rw-r--r--src/ui/dialog/WaitingDialog.cpp (renamed from src/ui/WaitingDialog.cpp)18
-rw-r--r--src/ui/dialog/WaitingDialog.h (renamed from src/ui/WaitingDialog.h)32
-rw-r--r--src/ui/dialog/Wizard.cpp (renamed from src/ui/Wizard.cpp)56
-rw-r--r--src/ui/dialog/Wizard.h (renamed from src/ui/Wizard.h)118
-rw-r--r--src/ui/help/AboutDialog.cpp26
-rw-r--r--src/ui/help/AboutDialog.h20
-rw-r--r--src/ui/import_export/ExportKeyPackageDialog.cpp145
-rw-r--r--src/ui/import_export/ExportKeyPackageDialog.h (renamed from src/ui/widgets/ExportKeyPackageDialog.h)40
-rw-r--r--src/ui/import_export/KeyImportDetailDialog.cpp (renamed from src/ui/KeyImportDetailDialog.cpp)114
-rw-r--r--src/ui/import_export/KeyImportDetailDialog.h91
-rw-r--r--src/ui/import_export/KeyServerImportDialog.cpp (renamed from src/ui/KeyServerImportDialog.cpp)335
-rw-r--r--src/ui/import_export/KeyServerImportDialog.h183
-rw-r--r--src/ui/import_export/KeyUploadDialog.cpp (renamed from src/ui/KeyUploadDialog.cpp)38
-rw-r--r--src/ui/import_export/KeyUploadDialog.h (renamed from src/ui/KeyUploadDialog.h)51
-rw-r--r--src/ui/key_generate/KeygenDialog.cpp (renamed from src/ui/keygen/KeygenDialog.cpp)64
-rw-r--r--src/ui/key_generate/KeygenDialog.h (renamed from src/ui/keygen/KeygenDialog.h)14
-rw-r--r--src/ui/key_generate/SubkeyGenerateDialog.cpp (renamed from src/ui/keygen/SubkeyGenerateDialog.cpp)58
-rw-r--r--src/ui/key_generate/SubkeyGenerateDialog.h (renamed from src/ui/keygen/SubkeyGenerateDialog.h)14
-rw-r--r--src/ui/keypair_details/EditSubKeyDialog.cpp25
-rw-r--r--src/ui/keypair_details/EditSubKeyDialog.h30
-rw-r--r--src/ui/keypair_details/KeyDetailsDialog.cpp32
-rw-r--r--src/ui/keypair_details/KeyDetailsDialog.h20
-rw-r--r--src/ui/keypair_details/KeyNewUIDDialog.cpp73
-rw-r--r--src/ui/keypair_details/KeyNewUIDDialog.h53
-rw-r--r--src/ui/keypair_details/KeyPairDetailTab.cpp211
-rw-r--r--src/ui/keypair_details/KeyPairDetailTab.h87
-rw-r--r--src/ui/keypair_details/KeyPairOperaTab.cpp96
-rw-r--r--src/ui/keypair_details/KeyPairOperaTab.h80
-rw-r--r--src/ui/keypair_details/KeyPairSubkeyTab.cpp248
-rw-r--r--src/ui/keypair_details/KeyPairSubkeyTab.h138
-rw-r--r--src/ui/keypair_details/KeyPairUIDTab.cpp339
-rw-r--r--src/ui/keypair_details/KeyPairUIDTab.h216
-rw-r--r--src/ui/keypair_details/KeySetExpireDateDialog.cpp85
-rw-r--r--src/ui/keypair_details/KeySetExpireDateDialog.h65
-rw-r--r--src/ui/keypair_details/KeyUIDSignDialog.cpp92
-rw-r--r--src/ui/keypair_details/KeyUIDSignDialog.h49
-rw-r--r--src/ui/mail/EmailListEditor.cpp (renamed from src/ui/smtp/EmailListEditor.cpp)72
-rw-r--r--src/ui/mail/EmailListEditor.h (renamed from src/ui/smtp/EmailListEditor.h)53
-rw-r--r--src/ui/mail/IMAPFolder.cpp (renamed from src/ui/smtp/IMAPFolder.cpp)17
-rw-r--r--src/ui/mail/IMAPFolder.h (renamed from src/ui/smtp/IMAPFolder.h)44
-rw-r--r--src/ui/mail/ReceiveMailDialog.cpp (renamed from src/ui/smtp/ReceiveMailDialog.cpp)22
-rw-r--r--src/ui/mail/ReceiveMailDialog.h (renamed from src/ui/smtp/ReceiveMailDialog.h)41
-rw-r--r--src/ui/mail/RecipientsPicker.cpp (renamed from src/ui/smtp/RecipientsPicker.cpp)28
-rw-r--r--src/ui/mail/RecipientsPicker.h (renamed from src/ui/smtp/RecipientsPicker.h)35
-rw-r--r--src/ui/mail/SendMailDialog.cpp (renamed from src/ui/smtp/SendMailDialog.cpp)210
-rw-r--r--src/ui/mail/SendMailDialog.h132
-rw-r--r--src/ui/mail/SenderPicker.cpp (renamed from src/ui/smtp/SenderPicker.cpp)30
-rw-r--r--src/ui/mail/SenderPicker.h (renamed from src/ui/smtp/SenderPicker.h)35
-rw-r--r--src/ui/main_window/MainWindow.cpp (renamed from src/ui/MainWindow.cpp)135
-rw-r--r--src/ui/main_window/MainWindow.h416
-rw-r--r--src/ui/main_window/MainWindowFileSlotFunction.cpp319
-rw-r--r--src/ui/main_window/MainWindowServerSlotFunction.cpp262
-rw-r--r--src/ui/main_window/MainWindowSlotFunction.cpp209
-rw-r--r--src/ui/main_window/MainWindowSlotUI.cpp200
-rw-r--r--src/ui/main_window/MainWindowUI.cpp758
-rw-r--r--src/ui/settings/GlobalSettingStation.cpp266
-rw-r--r--src/ui/settings/GlobalSettingStation.h169
-rw-r--r--src/ui/settings/SettingsAdvanced.cpp110
-rw-r--r--src/ui/settings/SettingsAdvanced.h29
-rw-r--r--src/ui/settings/SettingsAppearance.cpp220
-rw-r--r--src/ui/settings/SettingsAppearance.h58
-rw-r--r--src/ui/settings/SettingsDialog.cpp115
-rwxr-xr-xsrc/ui/settings/SettingsDialog.h80
-rw-r--r--src/ui/settings/SettingsGeneral.cpp101
-rw-r--r--src/ui/settings/SettingsGeneral.h64
-rw-r--r--src/ui/settings/SettingsKeyServer.cpp234
-rw-r--r--src/ui/settings/SettingsKeyServer.h78
-rw-r--r--src/ui/settings/SettingsNetwork.cpp184
-rw-r--r--src/ui/settings/SettingsNetwork.h59
-rw-r--r--src/ui/settings/SettingsSendMail.cpp214
-rw-r--r--src/ui/settings/SettingsSendMail.h87
-rw-r--r--src/ui/smtp/SendMailDialog.h80
-rw-r--r--src/ui/struct/SettingsObject.cpp104
-rw-r--r--src/ui/struct/SettingsObject.h (renamed from src/ui/data_struct/SettingsObject.h)25
-rw-r--r--src/ui/struct/SoftwareVersion.cpp (renamed from src/ui/data_struct/SoftwareVersion.cpp)16
-rw-r--r--src/ui/struct/SoftwareVersion.h (renamed from src/ui/data_struct/SoftwareVersion.h)16
-rw-r--r--src/ui/thread/CtxCheckThread.cpp22
-rw-r--r--src/ui/thread/CtxCheckThread.h28
-rw-r--r--src/ui/thread/FileReadThread.cpp20
-rw-r--r--src/ui/thread/FileReadThread.h38
-rw-r--r--src/ui/thread/ListedKeyServerTestThread.cpp (renamed from src/ui/thread/TestListedKeyServerThread.cpp)16
-rw-r--r--src/ui/thread/ListedKeyServerTestThread.h (renamed from src/ui/thread/TestListedKeyServerThread.h)41
-rw-r--r--src/ui/thread/ProxyConnectionTestThread.cpp12
-rw-r--r--src/ui/thread/ProxyConnectionTestThread.h38
-rw-r--r--src/ui/thread/SMTPConnectionTestThread.cpp (renamed from src/ui/thread/SMTPTestThread.cpp)20
-rw-r--r--src/ui/thread/SMTPConnectionTestThread.h93
-rw-r--r--src/ui/thread/SMTPSendMailThread.cpp52
-rw-r--r--src/ui/thread/SMTPSendMailThread.h153
-rw-r--r--src/ui/thread/SMTPTestThread.h67
-rw-r--r--src/ui/thread/VersionCheckThread.cpp18
-rw-r--r--src/ui/thread/VersionCheckThread.h41
-rw-r--r--src/ui/widgets/ExportKeyPackageDialog.cpp169
-rw-r--r--src/ui/widgets/FilePage.cpp521
-rw-r--r--src/ui/widgets/FilePage.h172
-rw-r--r--src/ui/widgets/FindWidget.cpp171
-rw-r--r--src/ui/widgets/FindWidget.h (renamed from src/ui/FindWidget.h)55
-rw-r--r--src/ui/widgets/GroupKeyList.cpp25
-rw-r--r--src/ui/widgets/GroupKeyList.h34
-rw-r--r--src/ui/widgets/HelpPage.cpp39
-rw-r--r--src/ui/widgets/HelpPage.h65
-rw-r--r--src/ui/widgets/InfoBoardWidget.cpp142
-rw-r--r--src/ui/widgets/InfoBoardWidget.h91
-rw-r--r--src/ui/widgets/KeyList.cpp372
-rw-r--r--src/ui/widgets/KeyList.h362
-rw-r--r--src/ui/widgets/PlainTextEditorPage.cpp142
-rw-r--r--src/ui/widgets/PlainTextEditorPage.h75
-rw-r--r--src/ui/widgets/SignersPicker.cpp26
-rw-r--r--src/ui/widgets/SignersPicker.h34
-rw-r--r--src/ui/widgets/TOFUInfoPage.cpp10
-rw-r--r--src/ui/widgets/TOFUInfoPage.h25
-rw-r--r--src/ui/widgets/TextEdit.cpp354
-rw-r--r--src/ui/widgets/TextEdit.h154
-rw-r--r--src/ui/widgets/VerifyKeyDetailBox.cpp50
-rw-r--r--src/ui/widgets/VerifyKeyDetailBox.h45
-rw-r--r--test/CMakeLists.txt26
-rw-r--r--test/GpgCoreTest.cpp16
-rw-r--r--test/GpgCoreTestBasicOpera.cpp20
-rw-r--r--test/GpgCoreTestImportExport.cpp16
-rw-r--r--test/GpgCoreTestKeyModel.cpp16
-rw-r--r--test/GpgCoreTestKeyModelAlone.cpp16
-rw-r--r--test/GpgCoreTestKeygen.cpp16
-rw-r--r--test/GpgCoreTestKeygenAlone.cpp16
-rw-r--r--test/GpgFrontendTest.h16
-rw-r--r--third_party/CMakeLists.txt47
-rw-r--r--third_party/encoding-detect/TextEncodingDetect.cpp (renamed from src/ui/encoding/TextEncodingDetect.cpp)0
-rw-r--r--third_party/encoding-detect/TextEncodingDetect.h (renamed from src/ui/encoding/TextEncodingDetect.h)0
m---------third_party/libarchive0
m---------third_party/libconfig0
-rw-r--r--ui/FilePage.ui37
280 files changed, 19665 insertions, 8428 deletions
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 31a0dfa0..5ecd6340 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -45,6 +45,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
+ with:
+ submodules: recursive
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
@@ -60,8 +62,8 @@ jobs:
run: |
sudo apt-get update
sudo apt-get -y install build-essential binutils git autoconf automake gettext texinfo
- sudo apt-get -y install gcc g++ libconfig++-dev libboost-all-dev
- sudo apt-get -y install gpgsm
+ sudo apt-get -y install gcc g++ libconfig++-dev libboost-all-dev ninja-build
+ sudo apt-get -y install gpg
- name: Cache Qt
id: cache-qt
@@ -75,44 +77,14 @@ jobs:
with:
cached: ${{ steps.cache-qt.outputs.cache-hit }}
- - name: Build gpg-error (Linux)
- run: |
- cd ${{github.workspace}}/..
- git clone https://github.com/saturneric/libgpg-error
- cd libgpg-error
- ./autogen.sh
- ./configure --enable-maintainer-mode --enable-static=yes && make -j2
- sudo make install
- cd ${{github.workspace}}
-
- - name: Build assuan (Linux)
- run: |
- cd ${{github.workspace}}/..
- git clone https://github.com/saturneric/libassuan
- cd libassuan
- ./autogen.sh
- ./configure --enable-maintainer-mode --enable-static=yes && make -j2
- sudo make install
- cd ${{github.workspace}}
-
- - name: Build GpgME (Linux)
- run: |
- cd ${{github.workspace}}/..
- git clone https://github.com/saturneric/gpgme
- cd gpgme
- ./autogen.sh
- ./configure --enable-maintainer-mode --enable-static=yes --enable-languages=cpp && make -j2
- sudo make install
- cd ${{github.workspace}}
-
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
- run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DEXECUTABLE_OUTPUT_PATH=${{env.EXECUTABLE_OUTPUT_PATH}}
+ run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DGPGFRONTEND_BUILD_TYPE_TEST_UI=ON
- name: Build GpgFrontend
# Build your program with the given configuration
- run: cmake --build ${{github.workspace}}/build --config {{$env.BUILD_TYPE}} -- -j 2
+ run: cmake --build ${{github.workspace}}/build --config {{$env.BUILD_TYPE}} -- -v
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml
index 28ed97a0..a81963b2 100644
--- a/.github/workflows/debug.yml
+++ b/.github/workflows/debug.yml
@@ -27,6 +27,12 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
+ - name: Set git to use LF(Windows) or CRLF(MacOS) line endings
+ run: |
+ git config --global core.autocrlf false
+ git config --global core.eol lf
+ if: matrix.os == 'windows-latest' || matrix.os == 'macos-10.15'
+
- uses: actions/checkout@v2
with:
submodules: recursive
@@ -90,7 +96,17 @@ jobs:
pacman --noconfirm -S --needed mingw-w64-x86_64-gcc mingw-w64-x86_64-make mingw-w64-x86_64-cmake autoconf
pacman --noconfirm -S --needed make texinfo mingw-w64-x86_64-libconfig mingw-w64-x86_64-boost automake
pacman --noconfirm -S --needed mingw-w64-x86_64-qt5 libintl msys2-runtime-devel gettext-devel
- pacman --noconfirm -S --needed mingw-w64-x86_64-gpgme mingw-w64-x86_64-ninja mingw-w64-x86_64-gnupg
+ pacman --noconfirm -S --needed mingw-w64-x86_64-ninja mingw-w64-x86_64-gnupg mingw-w64-x86_64-gpgme
+ pacman --noconfirm -S --needed mingw-w64-x86_64-libarchive
+ if: matrix.os == 'windows-latest'
+
+ - name: Build GpgME (Windows)
+ shell: msys2 {0}
+ run: |
+ cd $(echo "/${{github.workspace}}/third_party/gpgme" | sed 's/\\/\//g' | sed 's/://')
+ ./autogen.sh
+ ./configure --enable-maintainer-mode --enable-static=yes --disable-gpg-test --enable-languages=cpp LDFLAGS="-static" && make -j2
+ make install
if: matrix.os == 'windows-latest'
- name: Build GpgFrontend (Linux)
diff --git a/.github/workflows/release-deb-package.yml b/.github/workflows/release-deb-package.yml
index 21e3b8e7..02fb69bc 100644
--- a/.github/workflows/release-deb-package.yml
+++ b/.github/workflows/release-deb-package.yml
@@ -46,7 +46,7 @@ jobs:
- name: Build & Package GpgFrontend (Linux DEB Package)
# Build your program with the given configuration
run: |
- cmake -B ${{github.workspace}}/build-deb-${{matrix.os}} -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DGENERATE_LINUX_INSTALL_SOFTWARE=ON
+ cmake -B ${{github.workspace}}/build-deb-${{matrix.os}} -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DGENERATE_LINUX_INSTALL_SOFTWARE=ON -DCMAKE_INSTALL_PREFIX:PATH=${{github.workspace}}
cmake --build ${{github.workspace}}/build-deb-${{matrix.os}} --config {{$env.BUILD_TYPE}} -- -v
cd ${{github.workspace}}/build-deb-${{matrix.os}}
ninja package
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 9c8fd1a0..9b0f00dd 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -23,9 +23,14 @@ jobs:
build:
strategy:
matrix:
- os: [ 'ubuntu-18.04', 'macos-10.15', 'windows-latest' ]
+ os: [ 'ubuntu-18.04', 'macos-10.15', 'windows-2019' ]
runs-on: ${{ matrix.os }}
steps:
+ - name: Set git to use LF(Windows) or CRLF(MacOS) line endings
+ run: |
+ git config --global core.autocrlf false
+ git config --global core.eol lf
+ if: matrix.os == 'windows-2019' || matrix.os == 'macos-10.15'
- uses: actions/checkout@v2
with:
@@ -90,16 +95,25 @@ jobs:
with:
install: git msys2-devel base-devel binutils mingw-w64-x86_64-toolchain
release: false
- if: matrix.os == 'windows-latest'
+ if: matrix.os == 'windows-2019'
- name: Set up Dependence (Windows)
shell: msys2 {0}
run: |
pacman --noconfirm -S --needed mingw-w64-x86_64-gcc mingw-w64-x86_64-make mingw-w64-x86_64-cmake autoconf
pacman --noconfirm -S --needed make texinfo mingw-w64-x86_64-libconfig mingw-w64-x86_64-boost automake
- pacman --noconfirm -S --needed mingw-w64-x86_64-qt5 libintl msys2-runtime-devel gettext-devel
- pacman --noconfirm -S --needed mingw-w64-x86_64-gpgme mingw-w64-x86_64-ninja mingw-w64-x86_64-gnupg
- if: matrix.os == 'windows-latest'
+ pacman --noconfirm -S --needed mingw-w64-x86_64-qt5 libintl msys2-runtime-devel gettext-devel mingw-w64-x86_64-gpgme
+ pacman --noconfirm -S --needed mingw-w64-x86_64-ninja mingw-w64-x86_64-gnupg mingw-w64-x86_64-libarchive
+ if: matrix.os == 'windows-2019'
+
+ - name: Build GpgME (Windows)
+ shell: msys2 {0}
+ run: |
+ cd $(echo "/${{github.workspace}}/third_party/gpgme" | sed 's/\\/\//g' | sed 's/://')
+ ./autogen.sh
+ ./configure --enable-maintainer-mode --enable-static=yes --disable-gpg-test --enable-languages=cpp LDFLAGS="-static" && make -j2
+ make install
+ if: matrix.os == 'windows-2019'
- name: Build GpgFrontend (Linux)
# Build your GpgFrontend with the given configuration
@@ -155,7 +169,7 @@ jobs:
cmake -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DGPGFRONTEND_BUILD_TYPE_STABLE=ON ..
# Build your program with the given configuration
cmake --build . --config ${{env.BUILD_TYPE}} -- -j 2
- if: matrix.os == 'windows-latest'
+ if: matrix.os == 'windows-2019'
- name: Upload Artifact(Linux)
uses: actions/upload-artifact@master
@@ -176,4 +190,4 @@ jobs:
with:
name: gpgfrontend-${{matrix.os}}-${{env.BUILD_TYPE}}-${{steps.vars.outputs.sha_short}}
path: ${{github.workspace}}/build/release/*
- if: matrix.os == 'windows-latest'
+ if: matrix.os == 'windows-2019'
diff --git a/.gitignore b/.gitignore
index 243ab625..501d044a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
src/GpgFrontend.h
src/GpgFrontendBuildInfo.h
src/GpgFrontendBuildInstallInfo.h
+docs/
# gettext
*.mo
@@ -112,4 +113,3 @@ target_wrapper.*
# QtCreator
*.autosave
-
diff --git a/.gitmodules b/.gitmodules
index 4b7f9e8b..3815e764 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -22,3 +22,9 @@
[submodule "third_party/smtp-mime"]
path = third_party/smtp-mime
url = https://github.com/saturneric/SmtpClient-for-Qt.git
+[submodule "third_party/libarchive"]
+ path = third_party/libarchive
+ url = https://github.com/saturneric/libarchive.git
+[submodule "third_party/libconfig"]
+ path = third_party/libconfig
+ url = https://github.com/saturneric/libconfig
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4153273a..7ceb9d00 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,33 @@
+#
+# Copyright (C) 2021 Saturneric
+#
+# This file is part of GpgFrontend.
+#
+# GpgFrontend is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# GpgFrontend is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+#
+# The initial version of the source code is inherited from
+# the gpg4usb project, which is under GPL-3.0-or-later.
+#
+# All the source code of GpgFrontend was modified and released by
+# Saturneric<[email protected]> starting on May 12, 2021.
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
cmake_minimum_required(VERSION 3.16)
# define project
-project(GpgFrontend VERSION 2.0.4 LANGUAGES CXX)
+project(GpgFrontend VERSION 2.0.5 LANGUAGES CXX)
# show cmake version
message(STATUS "GpgFrontend Build Configuration Started CMAKE Version ${CMAKE_VERSION}")
@@ -28,10 +54,10 @@ option(GPGFRONTEND_BUILD_TYPE_TEST_ALL
"Generate a graphical interface with all functions" OFF)
option(GPGFRONTEND_BUILD_TYPE_STABLE
"Generate release version" ON)
-option(GENERATE_LINUX_INSTALL_SOFTWARE "Generate an installable version" OFF)
-option(GENERATE_APP_PACKAGE_DEB "Generate DEB package" OFF)
-option(CONFIGURE_FOR_XCODE_BUILD "Generate a version that can be successfully compiled and packaged in Xcode" OFF)
-option(USE_QT_DEFAULT_ENV "Build with the qt version provided by the qt-default package" OFF)
+option(GPGFRONTEND_GENERATE_LINUX_INSTALL_SOFTWARE "Generate an installable version" OFF)
+option(GPGFRONTEND_GENERATE_APP_PACKAGE_DEB "Generate DEB package" OFF)
+option(GPGFRONTEND_CONFIGURE_FOR_XCODE_BUILD "Generate a version that can be successfully compiled and packaged in Xcode" OFF)
+option(GPGFRONTEND_USE_QT_DEFAULT_ENV "Build with the qt version provided by the qt-default package" ON)
# analyse options
if (GPGFRONTEND_BUILD_TYPE_TEST_CORE)
@@ -54,6 +80,7 @@ if (GPGFRONTEND_BUILD_TYPE_TEST_ALL)
set(GPGFRONTEND_BUILD_CONFIG "test_all")
endif ()
+# stable features
if (GPGFRONTEND_BUILD_TYPE_STABLE)
set(GPGFRONTEND_BUILD_TYPE_TEST_CORE 0)
@@ -65,7 +92,8 @@ if (GPGFRONTEND_BUILD_TYPE_STABLE)
set(STABLE_APPLICATION_BUILD 1)
endif ()
-if (GENERATE_LINUX_INSTALL_SOFTWARE)
+# linux package build
+if (GPGFRONTEND_GENERATE_LINUX_INSTALL_SOFTWARE)
set(GPGFRONTEND_BUILD_TYPE_TEST_CORE 0)
set(GPGFRONTEND_BUILD_TYPE_TEST_CORE_AND_COVERAGE 0)
@@ -74,16 +102,18 @@ if (GENERATE_LINUX_INSTALL_SOFTWARE)
unset(GPGFRONTEND_BUILD_CONFIG)
set(LINUX_INSTALL_SOFTWARE 1)
- set(GENERATE_APP_PACKAGE_DEB 1)
+ set(GPGFRONTEND_GENERATE_APP_PACKAGE_DEB 1)
endif ()
-if (GENERATE_LINUX_INSTALL_SOFTWARE AND GENERATE_APP_PACKAGE_DEB)
+# linux package build
+if (GPGFRONTEND_GENERATE_LINUX_INSTALL_SOFTWARE AND GPGFRONTEND_GENERATE_APP_PACKAGE_DEB)
set(APP_PACKAGE_DEB 1)
endif ()
-if (CONFIGURE_FOR_XCODE_BUILD)
- set(GENERATE_LINUX_INSTALL_SOFTWARE 0)
- set(GENERATE_APP_PACKAGE_DEB 0)
+# xcode archive build
+if (GPGFRONTEND_CONFIGURE_FOR_XCODE_BUILD)
+ set(GPGFRONTEND_GENERATE_LINUX_INSTALL_SOFTWARE 0)
+ set(GPGFRONTEND_GENERATE_APP_PACKAGE_DEB 0)
set(LINUX_INSTALL_SOFTWARE 0)
set(APP_PACKAGE_DEB 0)
@@ -97,21 +127,33 @@ if (CONFIGURE_FOR_XCODE_BUILD)
endif ()
# C++
-#Detect Compiler
+
+# options for ccache
+find_program(CCACHE_FOUND ccache)
+if(CCACHE_FOUND)
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
+endif(CCACHE_FOUND)
+
+# detect compiler
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- # using Clang
- message(STATUS "Using Complier Clang")
+ # using clang
+ message(STATUS "Using Compiler clang")
+ message(STATUS "clang version ${CMAKE_CXX_COMPILER_VERSION}")
set(USING_COMPILER_CLANG 1)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- # using GCC
- message(STATUS "Using Complier Gcc")
+ # using gcc
+ message(STATUS "Using Compiler gcc")
+ message(STATUS "gcc version ${CMAKE_CXX_COMPILER_VERSION}")
set(USING_COMPILER_GCC 1)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
# using Intel C++
- message(STATUS "Using Complier Intel")
+ message(STATUS "Using Compiler Intel")
+ message(WARNING "Compilation with this compiler is untested, which may create some problems that need to be solved by the user.")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# using Visual Studio C++
- message(STATUS "Using Complier Msvc")
+ message(STATUS "Using Compiler MSVC")
+ message(WARNING "Compilation with this compiler is untested, which may create some problems that need to be solved by the user.")
endif ()
# Using Standard C++-17 (Consider compatibility)
@@ -178,7 +220,7 @@ if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
else ()
set(BUILD_FLAG 1)
ADD_DEFINITIONS(-DDEBUG)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
# Generate branch coverage information using gcc
if (TEST_COVERAGE_BUILD)
if (USING_COMPILER_GCC)
@@ -223,6 +265,7 @@ message(STATUS "GpgFrontend Build Timestamp ${BUILD_TIMESTAMP}")
message(STATUS "GpgFrontend Build Version ${BUILD_VERSION}")
message(STATUS "GpgFrontend Git Repo Version ${GIT_VERSION}")
+# Windows
IF (MINGW)
message(STATUS "GpgFrontend Configuration For OS Platform Microsoft Windows")
message(STATUS "Build Environment MINGW")
@@ -243,6 +286,7 @@ IF (MINGW)
)
endif ()
+# macOS
if (APPLE)
message(STATUS "GpgFrontend Configuration For OS Platform MacOS")
@@ -266,7 +310,6 @@ if (APPLE)
)
link_directories(
/usr/local/lib
- /usr/local/opt/openssl/lib
)
endif ()
@@ -312,7 +355,7 @@ if (LINUX_INSTALL_SOFTWARE)
include(GNUInstallDirs)
set(INSTALL_GPGFRONTEND_APP 1)
set(APP_INSTALL_FLAG LINUX_INSTALL)
- set(USE_QT_DEFAULT_ENV ON)
+ set(GPGFRONTEND_USE_QT_DEFAULT_ENV ON)
add_compile_definitions(LINUX_INSTALL_BUILD)
set(Boost_USE_STATIC_LIBS ON)
else ()
@@ -336,6 +379,7 @@ if (FULL_APPLICATION_BUILD)
set(BASIC_ENV_CONFIG 1)
set(MULTI_LANG_SUPPORT 1)
elseif (MINIMUM_APPLICATION_BUILD)
+ message(STATUS "Build Minimum Application")
set(QT5_ENV_SUPPORT 1)
set(GPG_CORE 1)
set(UI_CORE 1)
@@ -346,6 +390,7 @@ elseif (MINIMUM_APPLICATION_BUILD)
# set(APP_IMAGE_UPDATE 1)
# endif ()
elseif (STABLE_APPLICATION_BUILD)
+ message(STATUS "Build Stable Application")
set(QT5_ENV_SUPPORT 1)
set(GPG_CORE 1)
set(UI_CORE 1)
@@ -365,14 +410,14 @@ elseif (TEST_CORE_BUILD)
endif ()
# Introduce boost
-find_package(Boost COMPONENTS date_time filesystem REQUIRED)
+find_package(Boost COMPONENTS date_time system REQUIRED)
# Introduce OpenSSL
find_package(OpenSSL REQUIRED)
if (QT5_ENV_SUPPORT)
# Support Qt version Both 5.12.x and 5.15.x
- if (USE_QT_DEFAULT_ENV)
+ if (GPGFRONTEND_USE_QT_DEFAULT_ENV)
find_package(Qt5 COMPONENTS Core Test Widgets PrintSupport Network REQUIRED)
else ()
find_package(Qt5 5.15 COMPONENTS Core Test Widgets PrintSupport Network REQUIRED)
@@ -412,6 +457,7 @@ add_subdirectory(third_party)
# source code
add_subdirectory(src)
+# build to test gpgfrontend core
if (TEST_CORE_BUILD)
include(CTest)
enable_testing()
diff --git a/Doxyfile b/Doxyfile
new file mode 100644
index 00000000..f00643e1
--- /dev/null
+++ b/Doxyfile
@@ -0,0 +1,2579 @@
+# Doxyfile 1.8.17
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project.
+#
+# All text after a double hash (##) is considered a comment and is placed in
+# front of the TAG it is preceding.
+#
+# All text after a single hash (#) is considered a comment and will be ignored.
+# The format is:
+# TAG = value [value, ...]
+# For lists, items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (\" \").
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the configuration
+# file that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# https://www.gnu.org/software/libiconv/ for the list of possible encodings.
+# The default value is: UTF-8.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by
+# double-quotes, unless you are using Doxywizard) that should identify the
+# project for which the documentation is generated. This name is used in the
+# title of most generated pages and in a few other places.
+# The default value is: My Project.
+
+PROJECT_NAME = "GpgFrontend Project"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
+# could be handy for archiving the generated documentation or if some version
+# control system is used.
+
+PROJECT_NUMBER =
+
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer a
+# quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF = "A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool."
+
+# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
+# in the documentation. The maximum height of the logo should not exceed 55
+# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
+# the logo to the output directory.
+
+PROJECT_LOGO =
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
+# into which the generated documentation will be written. If a relative path is
+# entered, it will be relative to the location where doxygen was started. If
+# left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = ./docs
+
+# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
+# directories (in 2 levels) under the output directory of each output format and
+# will distribute the generated files over these directories. Enabling this
+# option can be useful when feeding doxygen a huge amount of source files, where
+# putting all generated files in the same directory would otherwise causes
+# performance problems for the file system.
+# The default value is: NO.
+
+CREATE_SUBDIRS = NO
+
+# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII
+# characters to appear in the names of generated files. If set to NO, non-ASCII
+# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode
+# U+3044.
+# The default value is: NO.
+
+ALLOW_UNICODE_NAMES = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,
+# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),
+# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,
+# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),
+# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,
+# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,
+# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,
+# Ukrainian and Vietnamese.
+# The default value is: English.
+
+OUTPUT_LANGUAGE = English
+
+# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all generated output in the proper direction.
+# Possible values are: None, LTR, RTL and Context.
+# The default value is: None.
+
+OUTPUT_TEXT_DIRECTION = None
+
+# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
+# descriptions after the members that are listed in the file and class
+# documentation (similar to Javadoc). Set to NO to disable this.
+# The default value is: YES.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief
+# description of a member or function before the detailed description
+#
+# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+# The default value is: YES.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator that is
+# used to form the text in various listings. Each string in this list, if found
+# as the leading text of the brief description, will be stripped from the text
+# and the result, after processing the whole list, is used as the annotated
+# text. Otherwise, the brief description is used as-is. If left blank, the
+# following values are used ($name is automatically replaced with the name of
+# the entity):The $name class, The $name widget, The $name file, is, provides,
+# specifies, contains, represents, a, an and the.
+
+ABBREVIATE_BRIEF = "The $name class" \
+ "The $name widget" \
+ "The $name file" \
+ is \
+ provides \
+ specifies \
+ contains \
+ represents \
+ a \
+ an \
+ the
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# doxygen will generate a detailed section even if there is only a brief
+# description.
+# The default value is: NO.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+# The default value is: NO.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path
+# before files name in the file list and in the header files. If set to NO the
+# shortest path that makes the file name unique will be used
+# The default value is: YES.
+
+FULL_PATH_NAMES = YES
+
+# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
+# Stripping is only done if one of the specified strings matches the left-hand
+# part of the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the path to
+# strip.
+#
+# Note that you can specify absolute paths here, but also relative paths, which
+# will be relative from the directory where doxygen is started.
+# This tag requires that the tag FULL_PATH_NAMES is set to YES.
+
+STRIP_FROM_PATH =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
+# path mentioned in the documentation of a class, which tells the reader which
+# header file to include in order to use a class. If left blank only the name of
+# the header file containing the class definition is used. Otherwise one should
+# specify the list of include paths that are normally passed to the compiler
+# using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
+# less readable) file names. This can be useful is your file systems doesn't
+# support long names like on DOS, Mac, or CD-ROM.
+# The default value is: NO.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the
+# first line (until the first dot) of a Javadoc-style comment as the brief
+# description. If set to NO, the Javadoc-style will behave just like regular Qt-
+# style comments (thus requiring an explicit @brief command for a brief
+# description.)
+# The default value is: NO.
+
+JAVADOC_AUTOBRIEF = NO
+
+# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line
+# such as
+# /***************
+# as being the beginning of a Javadoc-style comment "banner". If set to NO, the
+# Javadoc-style will behave just like regular comments and it will not be
+# interpreted by doxygen.
+# The default value is: NO.
+
+JAVADOC_BANNER = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
+# line (until the first dot) of a Qt-style comment as the brief description. If
+# set to NO, the Qt-style will behave just like regular Qt-style comments (thus
+# requiring an explicit \brief command for a brief description.)
+# The default value is: NO.
+
+QT_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a
+# multi-line C++ special comment block (i.e. a block of //! or /// comments) as
+# a brief description. This used to be the default behavior. The new default is
+# to treat a multi-line C++ comment block as a detailed description. Set this
+# tag to YES if you prefer the old behavior instead.
+#
+# Note that setting this tag to YES also means that rational rose comments are
+# not recognized any more.
+# The default value is: NO.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
+# documentation from any documented member that it re-implements.
+# The default value is: YES.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new
+# page for each member. If set to NO, the documentation of a member will be part
+# of the file/class/namespace that contains it.
+# The default value is: NO.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen
+# uses this value to replace tabs by spaces in code fragments.
+# Minimum value: 1, maximum value: 16, default value: 4.
+
+TAB_SIZE = 4
+
+# This tag can be used to specify a number of aliases that act as commands in
+# the documentation. An alias has the form:
+# name=value
+# For example adding
+# "sideeffect=@par Side Effects:\n"
+# will allow you to put the command \sideeffect (or @sideeffect) in the
+# documentation, which will result in a user-defined paragraph with heading
+# "Side Effects:". You can put \n's in the value part of an alias to insert
+# newlines (in the resulting output). You can put ^^ in the value part of an
+# alias to insert a newline as if a physical newline was in the original file.
+# When you need a literal { or } or , in the value part of an alias you have to
+# escape them by means of a backslash (\), this can lead to conflicts with the
+# commands \{ and \} for these it is advised to use the version @{ and @} or use
+# a double escape (\\{ and \\})
+
+ALIASES =
+
+# This tag can be used to specify a number of word-keyword mappings (TCL only).
+# A mapping has the form "name=value". For example adding "class=itcl::class"
+# will allow you to use the command class in the itcl::class meaning.
+
+TCL_SUBST =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
+# only. Doxygen will then generate output that is more tailored for C. For
+# instance, some of the names that are used will be different. The list of all
+# members will be omitted, etc.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_FOR_C = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or
+# Python sources only. Doxygen will then generate output that is more tailored
+# for that language. For instance, namespaces will be presented as packages,
+# qualified scopes will look different, etc.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources. Doxygen will then generate output that is tailored for Fortran.
+# The default value is: NO.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for VHDL.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice
+# sources only. Doxygen will then generate output that is more tailored for that
+# language. For instance, namespaces will be presented as modules, types will be
+# separated into more groups, etc.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_SLICE = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given
+# extension. Doxygen has a built-in mapping, but you can override or extend it
+# using this tag. The format is ext=language, where ext is a file extension, and
+# language is one of the parsers supported by doxygen: IDL, Java, JavaScript,
+# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice,
+# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran:
+# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser
+# tries to guess whether the code is fixed or free formatted code, this is the
+# default for Fortran type files), VHDL, tcl. For instance to make doxygen treat
+# .inc files as Fortran files (default is PHP), and .f files as C (default is
+# Fortran), use: inc=Fortran f=C.
+#
+# Note: For files without extension you can use no_extension as a placeholder.
+#
+# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
+# the files are not read by doxygen.
+
+EXTENSION_MAPPING =
+
+# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
+# according to the Markdown format, which allows for more readable
+# documentation. See https://daringfireball.net/projects/markdown/ for details.
+# The output of markdown processing is further processed by doxygen, so you can
+# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in
+# case of backward compatibilities issues.
+# The default value is: YES.
+
+MARKDOWN_SUPPORT = YES
+
+# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up
+# to that level are automatically included in the table of contents, even if
+# they do not have an id attribute.
+# Note: This feature currently applies only to Markdown headings.
+# Minimum value: 0, maximum value: 99, default value: 5.
+# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
+
+TOC_INCLUDE_HEADINGS = 5
+
+# When enabled doxygen tries to link words that correspond to documented
+# classes, or namespaces to their corresponding documentation. Such a link can
+# be prevented in individual cases by putting a % sign in front of the word or
+# globally by setting AUTOLINK_SUPPORT to NO.
+# The default value is: YES.
+
+AUTOLINK_SUPPORT = YES
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should set this
+# tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string);
+# versus func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+# The default value is: NO.
+
+BUILTIN_STL_SUPPORT = YES
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+# The default value is: NO.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
+# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen
+# will parse them like normal C++ but will assume all classes use public instead
+# of private inheritance when no explicit protection keyword is present.
+# The default value is: NO.
+
+SIP_SUPPORT = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate
+# getter and setter methods for a property. Setting this option to YES will make
+# doxygen to replace the get and set methods by a property in the documentation.
+# This will only work if the methods are indeed getting or setting a simple
+# type. If this is not the case, or you want to show the methods anyway, you
+# should set this option to NO.
+# The default value is: YES.
+
+IDL_PROPERTY_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+# The default value is: NO.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# If one adds a struct or class to a group and this option is enabled, then also
+# any nested class or struct is added to the same group. By default this option
+# is disabled and one has to add nested compounds explicitly via \ingroup.
+# The default value is: NO.
+
+GROUP_NESTED_COMPOUNDS = NO
+
+# Set the SUBGROUPING tag to YES to allow class member groups of the same type
+# (for instance a group of public functions) to be put as a subgroup of that
+# type (e.g. under the Public Functions section). Set it to NO to prevent
+# subgrouping. Alternatively, this can be done per class using the
+# \nosubgrouping command.
+# The default value is: YES.
+
+SUBGROUPING = YES
+
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions
+# are shown inside the group in which they are included (e.g. using \ingroup)
+# instead of on a separate page (for HTML and Man pages) or section (for LaTeX
+# and RTF).
+#
+# Note that this feature does not work in combination with
+# SEPARATE_MEMBER_PAGES.
+# The default value is: NO.
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions
+# with only public data fields or simple typedef fields will be shown inline in
+# the documentation of the scope in which they are defined (i.e. file,
+# namespace, or group documentation), provided this scope is documented. If set
+# to NO, structs, classes, and unions are shown on a separate page (for HTML and
+# Man pages) or section (for LaTeX and RTF).
+# The default value is: NO.
+
+INLINE_SIMPLE_STRUCTS = NO
+
+# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or
+# enum is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically be
+# useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+# The default value is: NO.
+
+TYPEDEF_HIDES_STRUCT = NO
+
+# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This
+# cache is used to resolve symbols given their name and scope. Since this can be
+# an expensive process and often the same symbol appears multiple times in the
+# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small
+# doxygen will become slower. If the cache is too large, memory is wasted. The
+# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
+# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536
+# symbols. At the end of a run doxygen will report the cache usage and suggest
+# the optimal cache size from a speed point of view.
+# Minimum value: 0, maximum value: 9, default value: 0.
+
+LOOKUP_CACHE_SIZE = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in
+# documentation are documented, even if no documentation was available. Private
+# class members and static file members will be hidden unless the
+# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.
+# Note: This will also disable the warnings about undocumented members that are
+# normally produced when WARNINGS is set to YES.
+# The default value is: NO.
+
+EXTRACT_ALL = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
+# be included in the documentation.
+# The default value is: NO.
+
+EXTRACT_PRIVATE = YES
+
+# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual
+# methods of a class will be included in the documentation.
+# The default value is: NO.
+
+EXTRACT_PRIV_VIRTUAL = NO
+
+# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
+# scope will be included in the documentation.
+# The default value is: NO.
+
+EXTRACT_PACKAGE = NO
+
+# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be
+# included in the documentation.
+# The default value is: NO.
+
+EXTRACT_STATIC = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
+# locally in source files will be included in the documentation. If set to NO,
+# only classes defined in header files are included. Does not have any effect
+# for Java sources.
+# The default value is: YES.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. If set to YES, local methods,
+# which are defined in the implementation section but not in the interface are
+# included in the documentation. If set to NO, only methods in the interface are
+# included.
+# The default value is: NO.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base name of
+# the file that contains the anonymous namespace. By default anonymous namespace
+# are hidden.
+# The default value is: NO.
+
+EXTRACT_ANON_NSPACES = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
+# undocumented members inside documented classes or files. If set to NO these
+# members will be included in the various overviews, but no documentation
+# section is generated. This option has no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy. If set
+# to NO, these classes will be included in the various overviews. This option
+# has no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
+# declarations. If set to NO, these declarations will be included in the
+# documentation.
+# The default value is: NO.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any
+# documentation blocks found inside the body of a function. If set to NO, these
+# blocks will be appended to the function's detailed documentation block.
+# The default value is: NO.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation that is typed after a
+# \internal command is included. If the tag is set to NO then the documentation
+# will be excluded. Set it to YES to include the internal documentation.
+# The default value is: NO.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
+# names in lower-case letters. If set to YES, upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# (including Cygwin) ands Mac users are advised to set this option to NO.
+# The default value is: system dependent.
+
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with
+# their full class and namespace scopes in the documentation. If set to YES, the
+# scope will be hidden.
+# The default value is: NO.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will
+# append additional text to a page's title, such as Class Reference. If set to
+# YES the compound reference will be hidden.
+# The default value is: NO.
+
+HIDE_COMPOUND_REFERENCE= NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
+# the files that are included by a file in the documentation of that file.
+# The default value is: YES.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
+# grouped member an include statement to the documentation, telling the reader
+# which file to include in order to use the member.
+# The default value is: NO.
+
+SHOW_GROUPED_MEMB_INC = NO
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include
+# files with double quotes in the documentation rather than with sharp brackets.
+# The default value is: NO.
+
+FORCE_LOCAL_INCLUDES = NO
+
+# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
+# documentation for inline members.
+# The default value is: YES.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the
+# (detailed) documentation of file and class members alphabetically by member
+# name. If set to NO, the members will appear in declaration order.
+# The default value is: YES.
+
+SORT_MEMBER_DOCS = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
+# descriptions of file, namespace and class members alphabetically by member
+# name. If set to NO, the members will appear in declaration order. Note that
+# this will also influence the order of the classes in the class list.
+# The default value is: NO.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
+# (brief and detailed) documentation of class members so that constructors and
+# destructors are listed first. If set to NO the constructors will appear in the
+# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.
+# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief
+# member documentation.
+# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting
+# detailed member documentation.
+# The default value is: NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy
+# of group names into alphabetical order. If set to NO the group names will
+# appear in their defined order.
+# The default value is: NO.
+
+SORT_GROUP_NAMES = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by
+# fully-qualified names, including namespaces. If set to NO, the class list will
+# be sorted only by class name, not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the alphabetical
+# list.
+# The default value is: NO.
+
+SORT_BY_SCOPE_NAME = NO
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper
+# type resolution of all parameters of a function it will reject a match between
+# the prototype and the implementation of a member function even if there is
+# only one candidate or it is obvious which candidate to choose by doing a
+# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still
+# accept a match between prototype and implementation in such cases.
+# The default value is: NO.
+
+STRICT_PROTO_MATCHING = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo
+# list. This list is created by putting \todo commands in the documentation.
+# The default value is: YES.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test
+# list. This list is created by putting \test commands in the documentation.
+# The default value is: YES.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug
+# list. This list is created by putting \bug commands in the documentation.
+# The default value is: YES.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO)
+# the deprecated list. This list is created by putting \deprecated commands in
+# the documentation.
+# The default value is: YES.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional documentation
+# sections, marked by \if <section_label> ... \endif and \cond <section_label>
+# ... \endcond blocks.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the
+# initial value of a variable or macro / define can have for it to appear in the
+# documentation. If the initializer consists of more lines than specified here
+# it will be hidden. Use a value of 0 to hide initializers completely. The
+# appearance of the value of individual variables and macros / defines can be
+# controlled using \showinitializer or \hideinitializer command in the
+# documentation regardless of this setting.
+# Minimum value: 0, maximum value: 10000, default value: 30.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at
+# the bottom of the documentation of classes and structs. If set to YES, the
+# list will mention the files that were used to generate the documentation.
+# The default value is: YES.
+
+SHOW_USED_FILES = YES
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This
+# will remove the Files entry from the Quick Index and from the Folder Tree View
+# (if specified).
+# The default value is: YES.
+
+SHOW_FILES = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
+# page. This will remove the Namespaces entry from the Quick Index and from the
+# Folder Tree View (if specified).
+# The default value is: YES.
+
+SHOW_NAMESPACES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command command input-file, where command is the value of the
+# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided
+# by doxygen. Whatever the program writes to standard output is used as the file
+# version. For an example see the documentation.
+
+FILE_VERSION_FILTER =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. To create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option. You can
+# optionally specify a file name after the option, if omitted DoxygenLayout.xml
+# will be used as the name of the layout file.
+#
+# Note that if you run doxygen from a directory containing a file called
+# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
+# tag is left empty.
+
+LAYOUT_FILE =
+
+# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
+# the reference definitions. This must be a list of .bib files. The .bib
+# extension is automatically appended if omitted. This requires the bibtex tool
+# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info.
+# For LaTeX the style of the bibliography can be controlled using
+# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
+# search path. See also \cite for info how to create references.
+
+CITE_BIB_FILES =
+
+#---------------------------------------------------------------------------
+# Configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated to
+# standard output by doxygen. If QUIET is set to YES this implies that the
+# messages are off.
+# The default value is: NO.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES
+# this implies that the warnings are on.
+#
+# Tip: Turn warnings on while writing the documentation.
+# The default value is: YES.
+
+WARNINGS = YES
+
+# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate
+# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag
+# will automatically be disabled.
+# The default value is: YES.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some parameters
+# in a documented function, or documenting parameters that don't exist or using
+# markup commands wrongly.
+# The default value is: YES.
+
+WARN_IF_DOC_ERROR = YES
+
+# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
+# are documented, but have no documentation for their parameters or return
+# value. If set to NO, doxygen will only warn about wrong or incomplete
+# parameter documentation, but not about the absence of documentation. If
+# EXTRACT_ALL is set to YES then this flag will automatically be disabled.
+# The default value is: NO.
+
+WARN_NO_PARAMDOC = NO
+
+# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
+# a warning is encountered.
+# The default value is: NO.
+
+WARN_AS_ERROR = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that doxygen
+# can produce. The string should contain the $file, $line, and $text tags, which
+# will be replaced by the file and line number from which the warning originated
+# and the warning text. Optionally the format may contain $version, which will
+# be replaced by the version of the file (if it could be obtained via
+# FILE_VERSION_FILTER)
+# The default value is: $file:$line: $text.
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning and error
+# messages should be written. If left blank the output is written to standard
+# error (stderr).
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag is used to specify the files and/or directories that contain
+# documented source files. You may enter file names like myfile.cpp or
+# directories like /usr/src/myproject. Separate the files or directories with
+# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
+# Note: If this tag is empty the current directory is searched.
+
+INPUT = ./src
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
+# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
+# documentation (see: https://www.gnu.org/software/libiconv/) for the list of
+# possible encodings.
+# The default value is: UTF-8.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
+# *.h) to filter out the source-files in the directories.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# read by doxygen.
+#
+# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
+# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
+# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
+# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment),
+# *.doc (to be provided as doxygen C comment), *.txt (to be provided as doxygen
+# C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f, *.for, *.tcl, *.vhd,
+# *.vhdl, *.ucf, *.qsf and *.ice.
+
+FILE_PATTERNS = *.c \
+ *.cc \
+ *.cxx \
+ *.cpp \
+ *.c++ \
+ *.java \
+ *.ii \
+ *.ixx \
+ *.ipp \
+ *.i++ \
+ *.inl \
+ *.idl \
+ *.ddl \
+ *.odl \
+ *.h \
+ *.hh \
+ *.hxx \
+ *.hpp \
+ *.h++ \
+ *.cs \
+ *.d \
+ *.php \
+ *.php4 \
+ *.php5 \
+ *.phtml \
+ *.inc \
+ *.m \
+ *.markdown \
+ *.md \
+ *.mm \
+ *.dox \
+ *.doc \
+ *.txt \
+ *.py \
+ *.pyw \
+ *.f90 \
+ *.f95 \
+ *.f03 \
+ *.f08 \
+ *.f \
+ *.for \
+ *.tcl \
+ *.vhd \
+ *.vhdl \
+ *.ucf \
+ *.qsf \
+ *.ice
+
+# The RECURSIVE tag can be used to specify whether or not subdirectories should
+# be searched for input files as well.
+# The default value is: NO.
+
+RECURSIVE = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should be
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+#
+# Note that relative paths are relative to the directory from which doxygen is
+# run.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
+# directories that are symbolic links (a Unix file system feature) are excluded
+# from the input.
+# The default value is: NO.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories.
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories for example use the pattern */test/*
+
+EXCLUDE_PATTERNS =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories use the pattern */test/*
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or directories
+# that contain example code fragments that are included (see the \include
+# command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
+# *.h) to filter out the source-files in the directories. If left blank all
+# files are included.
+
+EXAMPLE_PATTERNS = *
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude commands
+# irrespective of the value of the RECURSIVE tag.
+# The default value is: NO.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or directories
+# that contain images that are to be included in the documentation (see the
+# \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command:
+#
+# <filter> <input-file>
+#
+# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the
+# name of an input file. Doxygen will then use the output that the filter
+# program writes to standard output. If FILTER_PATTERNS is specified, this tag
+# will be ignored.
+#
+# Note that the filter must not add or remove lines; it is applied before the
+# code is scanned, but not when the output code is generated. If lines are added
+# or removed, the anchors will not be placed correctly.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis. Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match. The filters are a list of the form: pattern=filter
+# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how
+# filters are used. If the FILTER_PATTERNS tag is empty or if none of the
+# patterns match the file name, INPUT_FILTER is applied.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will also be used to filter the input files that are used for
+# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).
+# The default value is: NO.
+
+FILTER_SOURCE_FILES = NO
+
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and
+# it is also possible to disable source filtering for a specific pattern using
+# *.ext= (so without naming a filter).
+# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.
+
+FILTER_SOURCE_PATTERNS =
+
+# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that
+# is part of the input, its contents will be placed on the main page
+# (index.html). This can be useful if you have a project on for instance GitHub
+# and want to reuse the introduction page also for the doxygen output.
+
+USE_MDFILE_AS_MAINPAGE =
+
+#---------------------------------------------------------------------------
+# Configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will be
+# generated. Documented entities will be cross-referenced with these sources.
+#
+# Note: To get rid of all source code in the generated output, make sure that
+# also VERBATIM_HEADERS is set to NO.
+# The default value is: NO.
+
+SOURCE_BROWSER = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body of functions,
+# classes and enums directly into the documentation.
+# The default value is: NO.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any
+# special comment blocks from generated source code fragments. Normal C, C++ and
+# Fortran comments will always remain visible.
+# The default value is: YES.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES then for each documented
+# entity all documented functions referencing it will be listed.
+# The default value is: NO.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES then for each documented function
+# all documented entities called/used by that function will be listed.
+# The default value is: NO.
+
+REFERENCES_RELATION = YES
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set
+# to YES then the hyperlinks from functions in REFERENCES_RELATION and
+# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will
+# link to the documentation.
+# The default value is: YES.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the
+# source code will show a tooltip with additional information such as prototype,
+# brief description and links to the definition and documentation. Since this
+# will make the HTML file larger and loading of large files a bit slower, you
+# can opt to disable this feature.
+# The default value is: YES.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
+
+SOURCE_TOOLTIPS = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code will
+# point to the HTML generated by the htags(1) tool instead of doxygen built-in
+# source browser. The htags tool is part of GNU's global source tagging system
+# (see https://www.gnu.org/software/global/global.html). You will need version
+# 4.8.6 or higher.
+#
+# To use it do the following:
+# - Install the latest version of global
+# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file
+# - Make sure the INPUT points to the root of the source tree
+# - Run doxygen as normal
+#
+# Doxygen will invoke htags (and that will in turn invoke gtags), so these
+# tools must be available from the command line (i.e. in the search path).
+#
+# The result: instead of the source browser generated by doxygen, the links to
+# source code will now point to the output of htags.
+# The default value is: NO.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a
+# verbatim copy of the header file for each class for which an include is
+# specified. Set to NO to disable this.
+# See also: Section \class.
+# The default value is: YES.
+
+VERBATIM_HEADERS = YES
+
+# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the
+# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the
+# cost of reduced performance. This can be particularly helpful with template
+# rich C++ code for which doxygen's built-in parser lacks the necessary type
+# information.
+# Note: The availability of this option depends on whether or not doxygen was
+# generated with the -Duse_libclang=ON option for CMake.
+# The default value is: NO.
+
+CLANG_ASSISTED_PARSING = NO
+
+# If clang assisted parsing is enabled you can provide the compiler with command
+# line options that you would normally use when invoking the compiler. Note that
+# the include paths will already be set by doxygen for the files and directories
+# specified with INPUT and INCLUDE_PATH.
+# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.
+
+CLANG_OPTIONS =
+
+# If clang assisted parsing is enabled you can provide the clang parser with the
+# path to the compilation database (see:
+# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) used when the files
+# were built. This is equivalent to specifying the "-p" option to a clang tool,
+# such as clang-check. These options will then be passed to the parser.
+# Note: The availability of this option depends on whether or not doxygen was
+# generated with the -Duse_libclang=ON option for CMake.
+
+CLANG_DATABASE_PATH =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all
+# compounds will be generated. Enable this if the project contains a lot of
+# classes, structs, unions or interfaces.
+# The default value is: YES.
+
+ALPHABETICAL_INDEX = YES
+
+# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
+# which the alphabetical index list will be split.
+# Minimum value: 1, maximum value: 20, default value: 5.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all classes will
+# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
+# can be used to specify a prefix (or a list of prefixes) that should be ignored
+# while generating the index headers.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output
+# The default value is: YES.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
+# generated HTML page (for example: .htm, .php, .asp).
+# The default value is: .html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a user-defined HTML header file for
+# each generated HTML page. If the tag is left blank doxygen will generate a
+# standard header.
+#
+# To get valid HTML the header file that includes any scripts and style sheets
+# that doxygen needs, which is dependent on the configuration options used (e.g.
+# the setting GENERATE_TREEVIEW). It is highly recommended to start with a
+# default header using
+# doxygen -w html new_header.html new_footer.html new_stylesheet.css
+# YourConfigFile
+# and then modify the file new_header.html. See also section "Doxygen usage"
+# for information on how to generate the default header that doxygen normally
+# uses.
+# Note: The header is subject to change so you typically have to regenerate the
+# default header when upgrading to a newer version of doxygen. For a description
+# of the possible markers and block names see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
+# generated HTML page. If the tag is left blank doxygen will generate a standard
+# footer. See HTML_HEADER for more information on how to generate a default
+# footer and what special commands can be used inside the footer. See also
+# section "Doxygen usage" for information on how to generate the default footer
+# that doxygen normally uses.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
+# sheet that is used by each HTML page. It can be used to fine-tune the look of
+# the HTML output. If left blank doxygen will generate a default style sheet.
+# See also section "Doxygen usage" for information on how to generate the style
+# sheet that doxygen normally uses.
+# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as
+# it is more robust and this tag (HTML_STYLESHEET) will in the future become
+# obsolete.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_STYLESHEET =
+
+# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
+# cascading style sheets that are included after the standard style sheets
+# created by doxygen. Using this option one can overrule certain style aspects.
+# This is preferred over using HTML_STYLESHEET since it does not replace the
+# standard style sheet and is therefore more robust against future updates.
+# Doxygen will copy the style sheet files to the output directory.
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
+# list). For an example see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_EXTRA_STYLESHEET =
+
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that the
+# files will be copied as-is; there are no commands or markers available.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_EXTRA_FILES =
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
+# will adjust the colors in the style sheet and background images according to
+# this color. Hue is specified as an angle on a colorwheel, see
+# https://en.wikipedia.org/wiki/Hue for more information. For instance the value
+# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
+# purple, and 360 is red again.
+# Minimum value: 0, maximum value: 359, default value: 220.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_HUE = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors
+# in the HTML output. For a value of 0 the output will use grayscales only. A
+# value of 255 will produce the most vivid colors.
+# Minimum value: 0, maximum value: 255, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_SAT = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the
+# luminance component of the colors in the HTML output. Values below 100
+# gradually make the output lighter, whereas values above 100 make the output
+# darker. The value divided by 100 is the actual gamma applied, so 80 represents
+# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not
+# change the gamma.
+# Minimum value: 40, maximum value: 240, default value: 80.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_GAMMA = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting this
+# to YES can help to show when doxygen was last run and thus if the
+# documentation is up to date.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_TIMESTAMP = NO
+
+# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
+# documentation will contain a main index with vertical navigation menus that
+# are dynamically created via JavaScript. If disabled, the navigation index will
+# consists of multiple levels of tabs that are statically embedded in every HTML
+# page. Disable this option to support browsers that do not have JavaScript,
+# like the Qt help browser.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_DYNAMIC_MENUS = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_DYNAMIC_SECTIONS = NO
+
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries
+# shown in the various tree structured indices initially; the user can expand
+# and collapse entries dynamically later on. Doxygen will expand the tree to
+# such a level that at most the specified number of entries are visible (unless
+# a fully collapsed tree already exceeds this amount). So setting the number of
+# entries 1 will produce a full collapsed tree by default. 0 is a special value
+# representing an infinite number of entries and will result in a full expanded
+# tree by default.
+# Minimum value: 0, maximum value: 9999, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_INDEX_NUM_ENTRIES = 100
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files will be
+# generated that can be used as input for Apple's Xcode 3 integrated development
+# environment (see: https://developer.apple.com/xcode/), introduced with OSX
+# 10.5 (Leopard). To create a documentation set, doxygen will generate a
+# Makefile in the HTML output directory. Running make will produce the docset in
+# that directory and running make install will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
+# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy
+# genXcode/_index.html for more information.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_DOCSET = NO
+
+# This tag determines the name of the docset feed. A documentation feed provides
+# an umbrella under which multiple documentation sets from a single provider
+# (such as a company or product suite) can be grouped.
+# The default value is: Doxygen generated docs.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_FEEDNAME = "Doxygen generated docs"
+
+# This tag specifies a string that should uniquely identify the documentation
+# set bundle. This should be a reverse domain-name style string, e.g.
+# com.mycompany.MyDocSet. Doxygen will append .docset to the name.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_BUNDLE_ID = org.doxygen.Project
+
+# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+# The default value is: org.doxygen.Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_PUBLISHER_ID = org.doxygen.Publisher
+
+# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.
+# The default value is: Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_PUBLISHER_NAME = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
+# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
+# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
+# (see: https://www.microsoft.com/en-us/download/details.aspx?id=21138) on
+# Windows.
+#
+# The HTML Help Workshop contains a compiler that can convert all HTML output
+# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
+# files are now used as the Windows 98 help format, and will replace the old
+# Windows help format (.hlp) on all Windows platforms in the future. Compressed
+# HTML files also contain an index, a table of contents, and you can search for
+# words in the documentation. The HTML workshop also contains a viewer for
+# compressed HTML files.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_HTMLHELP = NO
+
+# The CHM_FILE tag can be used to specify the file name of the resulting .chm
+# file. You can add a path in front of the file if the result should not be
+# written to the html output directory.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+CHM_FILE =
+
+# The HHC_LOCATION tag can be used to specify the location (absolute path
+# including file name) of the HTML help compiler (hhc.exe). If non-empty,
+# doxygen will try to run the HTML help compiler on the generated index.hhp.
+# The file has to be specified with full path.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+HHC_LOCATION =
+
+# The GENERATE_CHI flag controls if a separate .chi index file is generated
+# (YES) or that it should be included in the master .chm file (NO).
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+GENERATE_CHI = NO
+
+# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc)
+# and project file content.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+CHM_INDEX_ENCODING =
+
+# The BINARY_TOC flag controls whether a binary table of contents is generated
+# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it
+# enables the Previous and Next buttons.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members to
+# the table of contents of the HTML help documentation and to the tree view.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+TOC_EXPAND = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that
+# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help
+# (.qch) of the generated HTML documentation.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_QHP = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify
+# the file name of the resulting .qch file. The path specified is relative to
+# the HTML output folder.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QCH_FILE =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
+# Project output. For more information please see Qt Help Project / Namespace
+# (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace).
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_NAMESPACE = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
+# Help Project output. For more information please see Qt Help Project / Virtual
+# Folders (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-
+# folders).
+# The default value is: doc.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_VIRTUAL_FOLDER = doc
+
+# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
+# filter to add. For more information please see Qt Help Project / Custom
+# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-
+# filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_CUST_FILTER_NAME =
+
+# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see Qt Help Project / Custom
+# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-
+# filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_CUST_FILTER_ATTRS =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's filter section matches. Qt Help Project / Filter Attributes (see:
+# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_SECT_FILTER_ATTRS =
+
+# The QHG_LOCATION tag can be used to specify the location of Qt's
+# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the
+# generated .qhp file.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHG_LOCATION =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be
+# generated, together with the HTML files, they form an Eclipse help plugin. To
+# install this plugin and make it available under the help contents menu in
+# Eclipse, the contents of the directory containing the HTML and XML files needs
+# to be copied into the plugins directory of eclipse. The name of the directory
+# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.
+# After copying Eclipse needs to be restarted before the help appears.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_ECLIPSEHELP = NO
+
+# A unique identifier for the Eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have this
+# name. Each documentation set should have its own identifier.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.
+
+ECLIPSE_DOC_ID = org.doxygen.Project
+
+# If you want full control over the layout of the generated HTML pages it might
+# be necessary to disable the index and replace it with your own. The
+# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top
+# of each HTML page. A value of NO enables the index and the value YES disables
+# it. Since the tabs in the index contain the same information as the navigation
+# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+DISABLE_INDEX = NO
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information. If the tag
+# value is set to YES, a side panel will be generated containing a tree-like
+# index structure (just like the one that is generated for HTML Help). For this
+# to work a browser that supports JavaScript, DHTML, CSS and frames is required
+# (i.e. any modern browser). Windows users are probably better off using the
+# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can
+# further fine-tune the look of the index. As an example, the default style
+# sheet generated by doxygen has an example that shows how to put an image at
+# the root of the tree instead of the PROJECT_NAME. Since the tree basically has
+# the same information as the tab index, you could consider setting
+# DISABLE_INDEX to YES when enabling this option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_TREEVIEW = YES
+
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
+# doxygen will group on one line in the generated HTML documentation.
+#
+# Note that a value of 0 will completely suppress the enum values from appearing
+# in the overview section.
+# Minimum value: 0, maximum value: 20, default value: 4.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+ENUM_VALUES_PER_LINE = 4
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used
+# to set the initial width (in pixels) of the frame in which the tree is shown.
+# Minimum value: 0, maximum value: 1500, default value: 250.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+TREEVIEW_WIDTH = 250
+
+# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to
+# external symbols imported via tag files in a separate window.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+EXT_LINKS_IN_WINDOW = NO
+
+# Use this tag to change the font size of LaTeX formulas included as images in
+# the HTML documentation. When you change the font size after a successful
+# doxygen run you need to manually remove any form_*.png images from the HTML
+# output directory to force them to be regenerated.
+# Minimum value: 8, maximum value: 50, default value: 10.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+FORMULA_FONTSIZE = 10
+
+# Use the FORMULA_TRANSPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are not
+# supported properly for IE 6.0, but are supported on all modern browsers.
+#
+# Note that when changing this option you need to delete any form_*.png files in
+# the HTML output directory before the changes have effect.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+FORMULA_TRANSPARENT = YES
+
+# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands
+# to create new LaTeX commands to be used in formulas as building blocks. See
+# the section "Including formulas" for details.
+
+FORMULA_MACROFILE =
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
+# https://www.mathjax.org) which uses client side JavaScript for the rendering
+# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
+# installed or if you want to formulas look prettier in the HTML output. When
+# enabled you may also need to install MathJax separately and configure the path
+# to it using the MATHJAX_RELPATH option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+USE_MATHJAX = NO
+
+# When MathJax is enabled you can set the default output format to be used for
+# the MathJax output. See the MathJax site (see:
+# http://docs.mathjax.org/en/latest/output.html) for more details.
+# Possible values are: HTML-CSS (which is slower, but has the best
+# compatibility), NativeMML (i.e. MathML) and SVG.
+# The default value is: HTML-CSS.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_FORMAT = HTML-CSS
+
+# When MathJax is enabled you need to specify the location relative to the HTML
+# output directory using the MATHJAX_RELPATH option. The destination directory
+# should contain the MathJax.js script. For instance, if the mathjax directory
+# is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
+# Content Delivery Network so you can quickly see the result without installing
+# MathJax. However, it is strongly recommended to install a local copy of
+# MathJax from https://www.mathjax.org before deployment.
+# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_RELPATH = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
+# extension names that should be enabled during MathJax rendering. For example
+# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_EXTENSIONS =
+
+# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces
+# of code that will be used on startup of the MathJax code. See the MathJax site
+# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an
+# example see the documentation.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_CODEFILE =
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box for
+# the HTML output. The underlying search engine uses javascript and DHTML and
+# should work on any modern browser. Note that when using HTML help
+# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)
+# there is already a search function so this one should typically be disabled.
+# For large projects the javascript based search engine can be slow, then
+# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to
+# search using the keyboard; to jump to the search box use <access key> + S
+# (what the <access key> is depends on the OS and browser, but it is typically
+# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down
+# key> to jump into the search results window, the results can be navigated
+# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel
+# the search. The filter options can be selected when the cursor is inside the
+# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys>
+# to select a filter and <Enter> or <escape> to activate or cancel the filter
+# option.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+SEARCHENGINE = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a web server instead of a web client using JavaScript. There
+# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
+# setting. When disabled, doxygen will generate a PHP script for searching and
+# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
+# and searching needs to be provided by external tools. See the section
+# "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SERVER_BASED_SEARCH = NO
+
+# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP
+# script for searching. Instead the search results are written to an XML file
+# which needs to be processed by an external indexer. Doxygen will invoke an
+# external search engine pointed to by the SEARCHENGINE_URL option to obtain the
+# search results.
+#
+# Doxygen ships with an example indexer (doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: https://xapian.org/).
+#
+# See the section "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTERNAL_SEARCH = NO
+
+# The SEARCHENGINE_URL should point to a search engine hosted by a web server
+# which will return the search results when EXTERNAL_SEARCH is enabled.
+#
+# Doxygen ships with an example indexer (doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: https://xapian.org/). See the section "External Indexing and
+# Searching" for details.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SEARCHENGINE_URL =
+
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed
+# search data is written to a file for indexing by an external tool. With the
+# SEARCHDATA_FILE tag the name of this file can be specified.
+# The default file is: searchdata.xml.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SEARCHDATA_FILE = searchdata.xml
+
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the
+# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is
+# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple
+# projects and redirect the results back to the right project.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTERNAL_SEARCH_ID =
+
+# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen
+# projects other than the one defined by this configuration file, but that are
+# all added to the same external search index. Each project needs to have a
+# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of
+# to a relative location where the documentation can be found. The format is:
+# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTRA_SEARCH_MAPPINGS =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
+# The default value is: YES.
+
+GENERATE_LATEX = YES
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: latex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked.
+#
+# Note that when not enabling USE_PDFLATEX the default is latex when enabling
+# USE_PDFLATEX the default is pdflatex and when in the later case latex is
+# chosen this is overwritten by pdflatex. For specific output languages the
+# default can have been set differently, this depends on the implementation of
+# the output language.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_CMD_NAME =
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate
+# index for LaTeX.
+# Note: This tag is used in the Makefile / make.bat.
+# See also: LATEX_MAKEINDEX_CMD for the part in the generated output file
+# (.tex).
+# The default file is: makeindex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to
+# generate index for LaTeX. In case there is no backslash (\) as first character
+# it will be automatically added in the LaTeX code.
+# Note: This tag is used in the generated output file (.tex).
+# See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat.
+# The default value is: makeindex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_MAKEINDEX_CMD = makeindex
+
+# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used by the
+# printer.
+# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x
+# 14 inches) and executive (7.25 x 10.5 inches).
+# The default value is: a4.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+PAPER_TYPE = a4
+
+# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
+# that should be included in the LaTeX output. The package can be specified just
+# by its name or with the correct syntax as to be used with the LaTeX
+# \usepackage command. To get the times font for instance you can specify :
+# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times}
+# To use the option intlimits with the amsmath package you can specify:
+# EXTRA_PACKAGES=[intlimits]{amsmath}
+# If left blank no extra packages will be included.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the
+# generated LaTeX document. The header should contain everything until the first
+# chapter. If it is left blank doxygen will generate a standard header. See
+# section "Doxygen usage" for information on how to let doxygen write the
+# default header to a separate file.
+#
+# Note: Only use a user-defined header if you know what you are doing! The
+# following commands have a special meaning inside the header: $title,
+# $datetime, $date, $doxygenversion, $projectname, $projectnumber,
+# $projectbrief, $projectlogo. Doxygen will replace $title with the empty
+# string, for the replacement values of the other commands the user is referred
+# to HTML_HEADER.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_HEADER =
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the
+# generated LaTeX document. The footer should contain everything after the last
+# chapter. If it is left blank doxygen will generate a standard footer. See
+# LATEX_HEADER for more information on how to generate a default footer and what
+# special commands can be used inside the footer.
+#
+# Note: Only use a user-defined footer if you know what you are doing!
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_FOOTER =
+
+# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined
+# LaTeX style sheets that are included after the standard style sheets created
+# by doxygen. Using this option one can overrule certain style aspects. Doxygen
+# will copy the style sheet files to the output directory.
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
+# list).
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EXTRA_STYLESHEET =
+
+# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the LATEX_OUTPUT output
+# directory. Note that the files will be copied as-is; there are no commands or
+# markers available.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EXTRA_FILES =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is
+# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will
+# contain links (just like the HTML output) instead of page references. This
+# makes the output suitable for online browsing using a PDF viewer.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+PDF_HYPERLINKS = YES
+
+# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
+# the PDF file directly from the LaTeX files. Set this option to YES, to get a
+# higher quality PDF documentation.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+USE_PDFLATEX = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode
+# command to the generated LaTeX files. This will instruct LaTeX to keep running
+# if errors occur, instead of asking the user for help. This option is also used
+# when generating formulas in HTML.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_BATCHMODE = NO
+
+# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the
+# index chapters (such as File Index, Compound Index, etc.) in the output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_HIDE_INDICES = NO
+
+# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source
+# code with syntax highlighting in the LaTeX output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_SOURCE_CODE = NO
+
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
+# bibliography, e.g. plainnat, or ieeetr. See
+# https://en.wikipedia.org/wiki/BibTeX and \cite for more info.
+# The default value is: plain.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_BIB_STYLE = plain
+
+# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated
+# page will contain the date and time when the page was generated. Setting this
+# to NO can help when comparing the output of multiple runs.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_TIMESTAMP = NO
+
+# The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute)
+# path from which the emoji images will be read. If a relative path is entered,
+# it will be relative to the LATEX_OUTPUT directory. If left blank the
+# LATEX_OUTPUT directory will be used.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EMOJI_DIRECTORY =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES, doxygen will generate RTF output. The
+# RTF output is optimized for Word 97 and may not look too pretty with other RTF
+# readers/editors.
+# The default value is: NO.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: rtf.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES, doxygen generates more compact RTF
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will
+# contain hyperlink fields. The RTF file will contain links (just like the HTML
+# output) instead of page references. This makes the output suitable for online
+# browsing using Word or some other Word compatible readers that support those
+# fields.
+#
+# Note: WordPad (write) and others do not support links.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# configuration file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+#
+# See also section "Doxygen usage" for information on how to generate the
+# default style sheet that doxygen normally uses.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an RTF document. Syntax is
+# similar to doxygen's configuration file. A template extensions file can be
+# generated using doxygen -e rtf extensionFile.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_EXTENSIONS_FILE =
+
+# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code
+# with syntax highlighting in the RTF output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_SOURCE_CODE = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for
+# classes and files.
+# The default value is: NO.
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it. A directory man3 will be created inside the directory specified by
+# MAN_OUTPUT.
+# The default directory is: man.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to the generated
+# man pages. In case the manual section does not start with a number, the number
+# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is
+# optional.
+# The default value is: .3.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_EXTENSION = .3
+
+# The MAN_SUBDIR tag determines the name of the directory created within
+# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by
+# MAN_EXTENSION with the initial . removed.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_SUBDIR =
+
+# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it
+# will generate one additional man file for each entity documented in the real
+# man page(s). These additional files only source the real man page, but without
+# them the man command would be unable to find the correct page.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that
+# captures the structure of the code including all documentation.
+# The default value is: NO.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: xml.
+# This tag requires that the tag GENERATE_XML is set to YES.
+
+XML_OUTPUT = xml
+
+# If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program
+# listings (including syntax highlighting and cross-referencing information) to
+# the XML output. Note that enabling this will significantly increase the size
+# of the XML output.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_XML is set to YES.
+
+XML_PROGRAMLISTING = YES
+
+# If the XML_NS_MEMB_FILE_SCOPE tag is set to YES, doxygen will include
+# namespace members in file scope as well, matching the HTML output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_XML is set to YES.
+
+XML_NS_MEMB_FILE_SCOPE = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the DOCBOOK output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_DOCBOOK tag is set to YES, doxygen will generate Docbook files
+# that can be used to generate PDF.
+# The default value is: NO.
+
+GENERATE_DOCBOOK = NO
+
+# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in
+# front of it.
+# The default directory is: docbook.
+# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
+
+DOCBOOK_OUTPUT = docbook
+
+# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the
+# program listings (including syntax highlighting and cross-referencing
+# information) to the DOCBOOK output. Note that enabling this will significantly
+# increase the size of the DOCBOOK output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
+
+DOCBOOK_PROGRAMLISTING = NO
+
+#---------------------------------------------------------------------------
+# Configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
+# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures
+# the structure of the code including all documentation. Note that this feature
+# is still experimental and incomplete at the moment.
+# The default value is: NO.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES, doxygen will generate a Perl module
+# file that captures the structure of the code including all documentation.
+#
+# Note that this feature is still experimental and incomplete at the moment.
+# The default value is: NO.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES, doxygen will generate the necessary
+# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI
+# output from the Perl module output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES, the Perl module output will be nicely
+# formatted so it can be parsed by a human reader. This is useful if you want to
+# understand what is going on. On the other hand, if this tag is set to NO, the
+# size of the Perl module output will be much smaller and Perl will parse it
+# just the same.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file are
+# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful
+# so different doxyrules.make files included by the same Makefile don't
+# overwrite each other's variables.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all
+# C-preprocessor directives found in the sources and include files.
+# The default value is: YES.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names
+# in the source code. If set to NO, only conditional compilation will be
+# performed. Macro expansion can be done in a controlled way by setting
+# EXPAND_ONLY_PREDEF to YES.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
+# the macro expansion is limited to the macros specified with the PREDEFINED and
+# EXPAND_AS_DEFINED tags.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES, the include files in the
+# INCLUDE_PATH will be searched if a #include is found.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by the
+# preprocessor.
+# This tag requires that the tag SEARCH_INCLUDES is set to YES.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will be
+# used.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that are
+# defined before the preprocessor is started (similar to the -D option of e.g.
+# gcc). The argument of the tag is a list of macros of the form: name or
+# name=definition (no spaces). If the definition and the "=" are omitted, "=1"
+# is assumed. To prevent a macro definition from being undefined via #undef or
+# recursively expanded use the := operator instead of the = operator.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
+# tag can be used to specify a list of macro names that should be expanded. The
+# macro definition that is found in the sources will be used. Use the PREDEFINED
+# tag if you want to use a different macro definition that overrules the
+# definition found in the source code.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
+# remove all references to function-like macros that are alone on a line, have
+# an all uppercase name, and do not end with a semicolon. Such function macros
+# are typically used for boiler-plate code, and will confuse the parser if not
+# removed.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration options related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES tag can be used to specify one or more tag files. For each tag
+# file the location of the external documentation should be added. The format of
+# a tag file without this location is as follows:
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where loc1 and loc2 can be relative or absolute paths or URLs. See the
+# section "Linking to external documentation" for more information about the use
+# of tag files.
+# Note: Each tag file must have a unique name (where the name does NOT include
+# the path). If a tag file is not located in the directory in which doxygen is
+# run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
+# tag file that is based on the input files it reads. See section "Linking to
+# external documentation" for more information about the usage of tag files.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES, all external class will be listed in
+# the class index. If set to NO, only the inherited external classes will be
+# listed.
+# The default value is: NO.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will be
+# listed.
+# The default value is: YES.
+
+EXTERNAL_GROUPS = YES
+
+# If the EXTERNAL_PAGES tag is set to YES, all external pages will be listed in
+# the related pages index. If set to NO, only the current project's pages will
+# be listed.
+# The default value is: YES.
+
+EXTERNAL_PAGES = YES
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram
+# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to
+# NO turns the diagrams off. Note that this option also works with HAVE_DOT
+# disabled, but it is recommended to install and use dot, since it yields more
+# powerful graphs.
+# The default value is: YES.
+
+CLASS_DIAGRAMS = YES
+
+# You can include diagrams made with dia in doxygen documentation. Doxygen will
+# then run dia to produce the diagram and insert it in the documentation. The
+# DIA_PATH tag allows you to specify the directory where the dia binary resides.
+# If left empty dia is assumed to be found in the default search path.
+
+DIA_PATH =
+
+# If set to YES the inheritance and collaboration graphs will hide inheritance
+# and usage relations if the target is undocumented or is not a class.
+# The default value is: YES.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz (see:
+# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent
+# Bell Labs. The other options in this section have no effect if this option is
+# set to NO
+# The default value is: YES.
+
+HAVE_DOT = YES
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
+# to run in parallel. When set to 0 doxygen will base this on the number of
+# processors available in the system. You can set it explicitly to a value
+# larger than 0 to get control over the balance between CPU load and processing
+# speed.
+# Minimum value: 0, maximum value: 32, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_NUM_THREADS = 0
+
+# When you want a differently looking font in the dot files that doxygen
+# generates you can specify the font name using DOT_FONTNAME. You need to make
+# sure dot is able to find the font, which can be done by putting it in a
+# standard location or by setting the DOTFONTPATH environment variable or by
+# setting DOT_FONTPATH to the directory containing the font.
+# The default value is: Helvetica.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTNAME = Helvetica
+
+# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of
+# dot graphs.
+# Minimum value: 4, maximum value: 24, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTSIZE = 10
+
+# By default doxygen will tell dot to use the default font as specified with
+# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set
+# the path where dot can find it using this tag.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTPATH =
+
+# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for
+# each documented class showing the direct and indirect inheritance relations.
+# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a
+# graph for each documented class showing the direct and indirect implementation
+# dependencies (inheritance, containment, and class references variables) of the
+# class with other documented classes.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
+# groups, showing the direct groups dependencies.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES, doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+UML_LOOK = YES
+
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside the
+# class node. If there are many fields or methods and many nodes the graph may
+# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the
+# number of items for each type to make the size more manageable. Set this to 0
+# for no limit. Note that the threshold may be exceeded by 50% before the limit
+# is enforced. So when you set the threshold to 10, up to 15 fields may appear,
+# but if the number exceeds 15, the total amount of fields shown is limited to
+# 10.
+# Minimum value: 0, maximum value: 100, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+UML_LIMIT_NUM_FIELDS = 10
+
+# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and
+# collaboration graphs will show the relations between templates and their
+# instances.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+TEMPLATE_RELATIONS = YES
+
+# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to
+# YES then doxygen will generate a graph for each documented file showing the
+# direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INCLUDE_GRAPH = YES
+
+# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
+# set to YES then doxygen will generate a graph for each documented file showing
+# the direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH tag is set to YES then doxygen will generate a call
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable call graphs for selected
+# functions only using the \callgraph command. Disabling a call graph can be
+# accomplished by means of the command \hidecallgraph.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CALL_GRAPH = NO
+
+# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable caller graphs for selected
+# functions only using the \callergraph command. Disabling a caller graph can be
+# accomplished by means of the command \hidecallergraph.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CALLER_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical
+# hierarchy of all classes instead of a textual one.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the
+# dependencies a directory has on other directories in a graphical way. The
+# dependency relations are determined by the #include relations between the
+# files in the directories.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. For an explanation of the image formats see the section
+# output formats in the documentation of the dot tool (Graphviz (see:
+# http://www.graphviz.org/)).
+# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
+# to make the SVG files visible in IE 9+ (other browsers do not have this
+# requirement).
+# Possible values are: png, png:cairo, png:cairo:cairo, png:cairo:gd, png:gd,
+# png:gd:gd, jpg, jpg:cairo, jpg:cairo:gd, jpg:gd, jpg:gd:gd, gif, gif:cairo,
+# gif:cairo:gd, gif:gd, gif:gd:gd, svg, png:gd, png:gd:gd, png:cairo,
+# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and
+# png:gdiplus:gdiplus.
+# The default value is: png.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_IMAGE_FORMAT = png
+
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
+# enable generation of interactive SVG images that allow zooming and panning.
+#
+# Note that this requires a modern browser other than Internet Explorer. Tested
+# and working are Firefox, Chrome, Safari, and Opera.
+# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make
+# the SVG files visible. Older versions of IE do not have SVG support.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INTERACTIVE_SVG = YES
+
+# The DOT_PATH tag can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the \dotfile
+# command).
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOTFILE_DIRS =
+
+# The MSCFILE_DIRS tag can be used to specify one or more directories that
+# contain msc files that are included in the documentation (see the \mscfile
+# command).
+
+MSCFILE_DIRS =
+
+# The DIAFILE_DIRS tag can be used to specify one or more directories that
+# contain dia files that are included in the documentation (see the \diafile
+# command).
+
+DIAFILE_DIRS =
+
+# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the
+# path where java can find the plantuml.jar file. If left blank, it is assumed
+# PlantUML is not used or called during a preprocessing step. Doxygen will
+# generate a warning when it encounters a \startuml command in this case and
+# will not generate output for the diagram.
+
+PLANTUML_JAR_PATH =
+
+# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a
+# configuration file for plantuml.
+
+PLANTUML_CFG_FILE =
+
+# When using plantuml, the specified paths are searched for files specified by
+# the !include statement in a plantuml block.
+
+PLANTUML_INCLUDE_PATH =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes
+# that will be shown in the graph. If the number of nodes in a graph becomes
+# larger than this value, doxygen will truncate the graph, which is visualized
+# by representing a node as a red box. Note that doxygen if the number of direct
+# children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that
+# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+# Minimum value: 0, maximum value: 10000, default value: 50.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs
+# generated by dot. A depth value of 3 means that only nodes reachable from the
+# root by following a path via at most 3 edges will be shown. Nodes that lay
+# further from the root node will be omitted. Note that setting this option to 1
+# or 2 may greatly reduce the computation time needed for large code bases. Also
+# note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+# Minimum value: 0, maximum value: 1000, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not seem
+# to support this out of the box.
+#
+# Warning: Depending on the platform used, enabling this option may lead to
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
+# read).
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10) support
+# this, this feature is disabled by default.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_MULTI_TARGETS = NO
+
+# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page
+# explaining the meaning of the various boxes and arrows in the dot generated
+# graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot
+# files that are used to generate the various graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_CLEANUP = YES
diff --git a/cmake/cotire.cmake b/cmake/cotire.cmake
new file mode 100644
index 00000000..7551e4a7
--- /dev/null
+++ b/cmake/cotire.cmake
@@ -0,0 +1,4212 @@
+# - cotire (compile time reducer)
+#
+# See the cotire manual for usage hints.
+#
+#=============================================================================
+# Copyright 2012-2018 Sascha Kratky
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation
+# files (the "Software"), to deal in the Software without
+# restriction, including without limitation the rights to use,
+# copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following
+# conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#=============================================================================
+
+if(__COTIRE_INCLUDED)
+ return()
+endif()
+set(__COTIRE_INCLUDED TRUE)
+
+# call cmake_minimum_required, but prevent modification of the CMake policy stack in include mode
+# cmake_minimum_required also sets the policy version as a side effect, which we have to avoid
+if (NOT CMAKE_SCRIPT_MODE_FILE)
+ cmake_policy(PUSH)
+endif()
+cmake_minimum_required(VERSION 2.8.12)
+if (NOT CMAKE_SCRIPT_MODE_FILE)
+ cmake_policy(POP)
+endif()
+
+set (COTIRE_CMAKE_MODULE_FILE "cotire.cmake")
+set (COTIRE_CMAKE_MODULE_VERSION "1.8.1")
+
+# activate select policies
+if (POLICY CMP0025)
+ # Compiler id for Apple Clang is now AppleClang
+ cmake_policy(SET CMP0025 NEW)
+endif()
+
+if (POLICY CMP0026)
+ # disallow use of the LOCATION target property
+ cmake_policy(SET CMP0026 NEW)
+endif()
+
+if (POLICY CMP0038)
+ # targets may not link directly to themselves
+ cmake_policy(SET CMP0038 NEW)
+endif()
+
+if (POLICY CMP0039)
+ # utility targets may not have link dependencies
+ cmake_policy(SET CMP0039 NEW)
+endif()
+
+if (POLICY CMP0040)
+ # target in the TARGET signature of add_custom_command() must exist
+ cmake_policy(SET CMP0040 NEW)
+endif()
+
+if (POLICY CMP0045)
+ # error on non-existent target in get_target_property
+ cmake_policy(SET CMP0045 NEW)
+endif()
+
+if (POLICY CMP0046)
+ # error on non-existent dependency in add_dependencies
+ cmake_policy(SET CMP0046 NEW)
+endif()
+
+if (POLICY CMP0049)
+ # do not expand variables in target source entries
+ cmake_policy(SET CMP0049 NEW)
+endif()
+
+if (POLICY CMP0050)
+ # disallow add_custom_command SOURCE signatures
+ cmake_policy(SET CMP0050 NEW)
+endif()
+
+if (POLICY CMP0051)
+ # include TARGET_OBJECTS expressions in a target's SOURCES property
+ cmake_policy(SET CMP0051 NEW)
+endif()
+
+if (POLICY CMP0053)
+ # simplify variable reference and escape sequence evaluation
+ cmake_policy(SET CMP0053 NEW)
+endif()
+
+if (POLICY CMP0054)
+ # only interpret if() arguments as variables or keywords when unquoted
+ cmake_policy(SET CMP0054 NEW)
+endif()
+
+if (POLICY CMP0055)
+ # strict checking for break() command
+ cmake_policy(SET CMP0055 NEW)
+endif()
+
+include(CMakeParseArguments)
+include(ProcessorCount)
+
+function (cotire_get_configuration_types _configsVar)
+ set (_configs "")
+ if (CMAKE_CONFIGURATION_TYPES)
+ list (APPEND _configs ${CMAKE_CONFIGURATION_TYPES})
+ endif()
+ if (CMAKE_BUILD_TYPE)
+ list (APPEND _configs "${CMAKE_BUILD_TYPE}")
+ endif()
+ if (_configs)
+ list (REMOVE_DUPLICATES _configs)
+ set (${_configsVar} ${_configs} PARENT_SCOPE)
+ else()
+ set (${_configsVar} "None" PARENT_SCOPE)
+ endif()
+endfunction()
+
+function (cotire_get_source_file_extension _sourceFile _extVar)
+ # get_filename_component returns extension from first occurrence of . in file name
+ # this function computes the extension from last occurrence of . in file name
+ string (FIND "${_sourceFile}" "." _index REVERSE)
+ if (_index GREATER -1)
+ math (EXPR _index "${_index} + 1")
+ string (SUBSTRING "${_sourceFile}" ${_index} -1 _sourceExt)
+ else()
+ set (_sourceExt "")
+ endif()
+ set (${_extVar} "${_sourceExt}" PARENT_SCOPE)
+endfunction()
+
+macro (cotire_check_is_path_relative_to _path _isRelativeVar)
+ set (${_isRelativeVar} FALSE)
+ if (IS_ABSOLUTE "${_path}")
+ foreach (_dir ${ARGN})
+ file (RELATIVE_PATH _relPath "${_dir}" "${_path}")
+ if (NOT _relPath OR (NOT IS_ABSOLUTE "${_relPath}" AND NOT "${_relPath}" MATCHES "^\\.\\."))
+ set (${_isRelativeVar} TRUE)
+ break()
+ endif()
+ endforeach()
+ endif()
+endmacro()
+
+function (cotire_filter_language_source_files _language _target _sourceFilesVar _excludedSourceFilesVar _cotiredSourceFilesVar)
+ if (CMAKE_${_language}_SOURCE_FILE_EXTENSIONS)
+ set (_languageExtensions "${CMAKE_${_language}_SOURCE_FILE_EXTENSIONS}")
+ else()
+ set (_languageExtensions "")
+ endif()
+ if (CMAKE_${_language}_IGNORE_EXTENSIONS)
+ set (_ignoreExtensions "${CMAKE_${_language}_IGNORE_EXTENSIONS}")
+ else()
+ set (_ignoreExtensions "")
+ endif()
+ if (COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS)
+ set (_excludeExtensions "${COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS}")
+ else()
+ set (_excludeExtensions "")
+ endif()
+ if (COTIRE_DEBUG AND _languageExtensions)
+ message (STATUS "${_language} source file extensions: ${_languageExtensions}")
+ endif()
+ if (COTIRE_DEBUG AND _ignoreExtensions)
+ message (STATUS "${_language} ignore extensions: ${_ignoreExtensions}")
+ endif()
+ if (COTIRE_DEBUG AND _excludeExtensions)
+ message (STATUS "${_language} exclude extensions: ${_excludeExtensions}")
+ endif()
+ if (CMAKE_VERSION VERSION_LESS "3.1.0")
+ set (_allSourceFiles ${ARGN})
+ else()
+ # as of CMake 3.1 target sources may contain generator expressions
+ # since we cannot obtain required property information about source files added
+ # through generator expressions at configure time, we filter them out
+ string (GENEX_STRIP "${ARGN}" _allSourceFiles)
+ endif()
+ set (_filteredSourceFiles "")
+ set (_excludedSourceFiles "")
+ foreach (_sourceFile ${_allSourceFiles})
+ get_source_file_property(_sourceIsHeaderOnly "${_sourceFile}" HEADER_FILE_ONLY)
+ get_source_file_property(_sourceIsExternal "${_sourceFile}" EXTERNAL_OBJECT)
+ get_source_file_property(_sourceIsSymbolic "${_sourceFile}" SYMBOLIC)
+ if (NOT _sourceIsHeaderOnly AND NOT _sourceIsExternal AND NOT _sourceIsSymbolic)
+ cotire_get_source_file_extension("${_sourceFile}" _sourceExt)
+ if (_sourceExt)
+ list (FIND _ignoreExtensions "${_sourceExt}" _ignoreIndex)
+ if (_ignoreIndex LESS 0)
+ list (FIND _excludeExtensions "${_sourceExt}" _excludeIndex)
+ if (_excludeIndex GREATER -1)
+ list (APPEND _excludedSourceFiles "${_sourceFile}")
+ else()
+ list (FIND _languageExtensions "${_sourceExt}" _sourceIndex)
+ if (_sourceIndex GREATER -1)
+ # consider source file unless it is excluded explicitly
+ get_source_file_property(_sourceIsExcluded "${_sourceFile}" COTIRE_EXCLUDED)
+ if (_sourceIsExcluded)
+ list (APPEND _excludedSourceFiles "${_sourceFile}")
+ else()
+ list (APPEND _filteredSourceFiles "${_sourceFile}")
+ endif()
+ else()
+ get_source_file_property(_sourceLanguage "${_sourceFile}" LANGUAGE)
+ if ("${_sourceLanguage}" STREQUAL "${_language}")
+ # add to excluded sources, if file is not ignored and has correct language without having the correct extension
+ list (APPEND _excludedSourceFiles "${_sourceFile}")
+ endif()
+ endif()
+ endif()
+ endif()
+ endif()
+ endif()
+ endforeach()
+ # separate filtered source files from already cotired ones
+ # the COTIRE_TARGET property of a source file may be set while a target is being processed by cotire
+ set (_sourceFiles "")
+ set (_cotiredSourceFiles "")
+ foreach (_sourceFile ${_filteredSourceFiles})
+ get_source_file_property(_sourceIsCotired "${_sourceFile}" COTIRE_TARGET)
+ if (_sourceIsCotired)
+ list (APPEND _cotiredSourceFiles "${_sourceFile}")
+ else()
+ get_source_file_property(_sourceCompileFlags "${_sourceFile}" COMPILE_FLAGS)
+ if (_sourceCompileFlags)
+ # add to excluded sources, if file has custom compile flags
+ list (APPEND _excludedSourceFiles "${_sourceFile}")
+ else()
+ get_source_file_property(_sourceCompileOptions "${_sourceFile}" COMPILE_OPTIONS)
+ if (_sourceCompileOptions)
+ # add to excluded sources, if file has list of custom compile options
+ list (APPEND _excludedSourceFiles "${_sourceFile}")
+ else()
+ list (APPEND _sourceFiles "${_sourceFile}")
+ endif()
+ endif()
+ endif()
+ endforeach()
+ if (COTIRE_DEBUG)
+ if (_sourceFiles)
+ message (STATUS "Filtered ${_target} ${_language} sources: ${_sourceFiles}")
+ endif()
+ if (_excludedSourceFiles)
+ message (STATUS "Excluded ${_target} ${_language} sources: ${_excludedSourceFiles}")
+ endif()
+ if (_cotiredSourceFiles)
+ message (STATUS "Cotired ${_target} ${_language} sources: ${_cotiredSourceFiles}")
+ endif()
+ endif()
+ set (${_sourceFilesVar} ${_sourceFiles} PARENT_SCOPE)
+ set (${_excludedSourceFilesVar} ${_excludedSourceFiles} PARENT_SCOPE)
+ set (${_cotiredSourceFilesVar} ${_cotiredSourceFiles} PARENT_SCOPE)
+endfunction()
+
+function (cotire_get_objects_with_property_on _filteredObjectsVar _property _type)
+ set (_filteredObjects "")
+ foreach (_object ${ARGN})
+ get_property(_isSet ${_type} "${_object}" PROPERTY ${_property} SET)
+ if (_isSet)
+ get_property(_propertyValue ${_type} "${_object}" PROPERTY ${_property})
+ if (_propertyValue)
+ list (APPEND _filteredObjects "${_object}")
+ endif()
+ endif()
+ endforeach()
+ set (${_filteredObjectsVar} ${_filteredObjects} PARENT_SCOPE)
+endfunction()
+
+function (cotire_get_objects_with_property_off _filteredObjectsVar _property _type)
+ set (_filteredObjects "")
+ foreach (_object ${ARGN})
+ get_property(_isSet ${_type} "${_object}" PROPERTY ${_property} SET)
+ if (_isSet)
+ get_property(_propertyValue ${_type} "${_object}" PROPERTY ${_property})
+ if (NOT _propertyValue)
+ list (APPEND _filteredObjects "${_object}")
+ endif()
+ endif()
+ endforeach()
+ set (${_filteredObjectsVar} ${_filteredObjects} PARENT_SCOPE)
+endfunction()
+
+function (cotire_get_source_file_property_values _valuesVar _property)
+ set (_values "")
+ foreach (_sourceFile ${ARGN})
+ get_source_file_property(_propertyValue "${_sourceFile}" ${_property})
+ if (_propertyValue)
+ list (APPEND _values "${_propertyValue}")
+ endif()
+ endforeach()
+ set (${_valuesVar} ${_values} PARENT_SCOPE)
+endfunction()
+
+function (cotire_resolve_config_properties _configurations _propertiesVar)
+ set (_properties "")
+ foreach (_property ${ARGN})
+ if ("${_property}" MATCHES "<CONFIG>")
+ foreach (_config ${_configurations})
+ string (TOUPPER "${_config}" _upperConfig)
+ string (REPLACE "<CONFIG>" "${_upperConfig}" _configProperty "${_property}")
+ list (APPEND _properties ${_configProperty})
+ endforeach()
+ else()
+ list (APPEND _properties ${_property})
+ endif()
+ endforeach()
+ set (${_propertiesVar} ${_properties} PARENT_SCOPE)
+endfunction()
+
+function (cotire_copy_set_properties _configurations _type _source _target)
+ cotire_resolve_config_properties("${_configurations}" _properties ${ARGN})
+ foreach (_property ${_properties})
+ get_property(_isSet ${_type} ${_source} PROPERTY ${_property} SET)
+ if (_isSet)
+ get_property(_propertyValue ${_type} ${_source} PROPERTY ${_property})
+ set_property(${_type} ${_target} PROPERTY ${_property} "${_propertyValue}")
+ endif()
+ endforeach()
+endfunction()
+
+function (cotire_get_target_usage_requirements _target _config _targetRequirementsVar)
+ set (_targetRequirements "")
+ get_target_property(_librariesToProcess ${_target} LINK_LIBRARIES)
+ while (_librariesToProcess)
+ # remove from head
+ list (GET _librariesToProcess 0 _library)
+ list (REMOVE_AT _librariesToProcess 0)
+ if (_library MATCHES "^\\$<\\$<CONFIG:${_config}>:([A-Za-z0-9_:-]+)>$")
+ set (_library "${CMAKE_MATCH_1}")
+ elseif (_config STREQUAL "None" AND _library MATCHES "^\\$<\\$<CONFIG:>:([A-Za-z0-9_:-]+)>$")
+ set (_library "${CMAKE_MATCH_1}")
+ endif()
+ if (TARGET ${_library})
+ list (FIND _targetRequirements ${_library} _index)
+ if (_index LESS 0)
+ list (APPEND _targetRequirements ${_library})
+ # BFS traversal of transitive libraries
+ get_target_property(_libraries ${_library} INTERFACE_LINK_LIBRARIES)
+ if (_libraries)
+ list (APPEND _librariesToProcess ${_libraries})
+ list (REMOVE_DUPLICATES _librariesToProcess)
+ endif()
+ endif()
+ endif()
+ endwhile()
+ set (${_targetRequirementsVar} ${_targetRequirements} PARENT_SCOPE)
+endfunction()
+
+function (cotire_filter_compile_flags _language _flagFilter _matchedOptionsVar _unmatchedOptionsVar)
+ if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel")
+ set (_flagPrefix "[/-]")
+ else()
+ set (_flagPrefix "--?")
+ endif()
+ set (_optionFlag "")
+ set (_matchedOptions "")
+ set (_unmatchedOptions "")
+ foreach (_compileFlag ${ARGN})
+ if (_compileFlag)
+ if (_optionFlag AND NOT "${_compileFlag}" MATCHES "^${_flagPrefix}")
+ # option with separate argument
+ list (APPEND _matchedOptions "${_compileFlag}")
+ set (_optionFlag "")
+ elseif ("${_compileFlag}" MATCHES "^(${_flagPrefix})(${_flagFilter})$")
+ # remember option
+ set (_optionFlag "${CMAKE_MATCH_2}")
+ elseif ("${_compileFlag}" MATCHES "^(${_flagPrefix})(${_flagFilter})(.+)$")
+ # option with joined argument
+ list (APPEND _matchedOptions "${CMAKE_MATCH_3}")
+ set (_optionFlag "")
+ else()
+ # flush remembered option
+ if (_optionFlag)
+ list (APPEND _matchedOptions "${_optionFlag}")
+ set (_optionFlag "")
+ endif()
+ # add to unfiltered options
+ list (APPEND _unmatchedOptions "${_compileFlag}")
+ endif()
+ endif()
+ endforeach()
+ if (_optionFlag)
+ list (APPEND _matchedOptions "${_optionFlag}")
+ endif()
+ if (COTIRE_DEBUG AND _matchedOptions)
+ message (STATUS "Filter ${_flagFilter} matched: ${_matchedOptions}")
+ endif()
+ if (COTIRE_DEBUG AND _unmatchedOptions)
+ message (STATUS "Filter ${_flagFilter} unmatched: ${_unmatchedOptions}")
+ endif()
+ set (${_matchedOptionsVar} ${_matchedOptions} PARENT_SCOPE)
+ set (${_unmatchedOptionsVar} ${_unmatchedOptions} PARENT_SCOPE)
+endfunction()
+
+function (cotire_is_target_supported _target _isSupportedVar)
+ if (NOT TARGET "${_target}")
+ set (${_isSupportedVar} FALSE PARENT_SCOPE)
+ return()
+ endif()
+ get_target_property(_imported ${_target} IMPORTED)
+ if (_imported)
+ set (${_isSupportedVar} FALSE PARENT_SCOPE)
+ return()
+ endif()
+ get_target_property(_targetType ${_target} TYPE)
+ if (NOT _targetType MATCHES "EXECUTABLE|(STATIC|SHARED|MODULE|OBJECT)_LIBRARY")
+ set (${_isSupportedVar} FALSE PARENT_SCOPE)
+ return()
+ endif()
+ set (${_isSupportedVar} TRUE PARENT_SCOPE)
+endfunction()
+
+function (cotire_get_target_compile_flags _config _language _target _flagsVar)
+ string (TOUPPER "${_config}" _upperConfig)
+ # collect options from CMake language variables
+ set (_compileFlags "")
+ if (CMAKE_${_language}_FLAGS)
+ set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_FLAGS}")
+ endif()
+ if (CMAKE_${_language}_FLAGS_${_upperConfig})
+ set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_FLAGS_${_upperConfig}}")
+ endif()
+ if (_target)
+ # add target compile flags
+ get_target_property(_targetflags ${_target} COMPILE_FLAGS)
+ if (_targetflags)
+ set (_compileFlags "${_compileFlags} ${_targetflags}")
+ endif()
+ endif()
+ if (UNIX)
+ separate_arguments(_compileFlags UNIX_COMMAND "${_compileFlags}")
+ elseif(WIN32)
+ separate_arguments(_compileFlags WINDOWS_COMMAND "${_compileFlags}")
+ else()
+ separate_arguments(_compileFlags)
+ endif()
+ # target compile options
+ if (_target)
+ get_target_property(_targetOptions ${_target} COMPILE_OPTIONS)
+ if (_targetOptions)
+ list (APPEND _compileFlags ${_targetOptions})
+ endif()
+ endif()
+ # interface compile options from linked library targets
+ if (_target)
+ set (_linkedTargets "")
+ cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets)
+ foreach (_linkedTarget ${_linkedTargets})
+ get_target_property(_targetOptions ${_linkedTarget} INTERFACE_COMPILE_OPTIONS)
+ if (_targetOptions)
+ list (APPEND _compileFlags ${_targetOptions})
+ endif()
+ endforeach()
+ endif()
+ # handle language standard properties
+ if (CMAKE_${_language}_STANDARD_DEFAULT)
+ # used compiler supports language standard levels
+ if (_target)
+ get_target_property(_targetLanguageStandard ${_target} ${_language}_STANDARD)
+ if (_targetLanguageStandard)
+ set (_type "EXTENSION")
+ get_property(_isSet TARGET ${_target} PROPERTY ${_language}_EXTENSIONS SET)
+ if (_isSet)
+ get_target_property(_targetUseLanguageExtensions ${_target} ${_language}_EXTENSIONS)
+ if (NOT _targetUseLanguageExtensions)
+ set (_type "STANDARD")
+ endif()
+ endif()
+ if (CMAKE_${_language}${_targetLanguageStandard}_${_type}_COMPILE_OPTION)
+ list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_${_type}_COMPILE_OPTION}")
+ endif()
+ endif()
+ endif()
+ endif()
+ # handle the POSITION_INDEPENDENT_CODE target property
+ if (_target)
+ get_target_property(_targetPIC ${_target} POSITION_INDEPENDENT_CODE)
+ if (_targetPIC)
+ get_target_property(_targetType ${_target} TYPE)
+ if (_targetType STREQUAL "EXECUTABLE" AND CMAKE_${_language}_COMPILE_OPTIONS_PIE)
+ list (APPEND _compileFlags "${CMAKE_${_language}_COMPILE_OPTIONS_PIE}")
+ elseif (CMAKE_${_language}_COMPILE_OPTIONS_PIC)
+ list (APPEND _compileFlags "${CMAKE_${_language}_COMPILE_OPTIONS_PIC}")
+ endif()
+ endif()
+ endif()
+ # handle visibility target properties
+ if (_target)
+ get_target_property(_targetVisibility ${_target} ${_language}_VISIBILITY_PRESET)
+ if (_targetVisibility AND CMAKE_${_language}_COMPILE_OPTIONS_VISIBILITY)
+ list (APPEND _compileFlags "${CMAKE_${_language}_COMPILE_OPTIONS_VISIBILITY}${_targetVisibility}")
+ endif()
+ get_target_property(_targetVisibilityInlines ${_target} VISIBILITY_INLINES_HIDDEN)
+ if (_targetVisibilityInlines AND CMAKE_${_language}_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN)
+ list (APPEND _compileFlags "${CMAKE_${_language}_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN}")
+ endif()
+ endif()
+ # platform specific flags
+ if (APPLE)
+ get_target_property(_architectures ${_target} OSX_ARCHITECTURES_${_upperConfig})
+ if (NOT _architectures)
+ get_target_property(_architectures ${_target} OSX_ARCHITECTURES)
+ endif()
+ if (_architectures)
+ foreach (_arch ${_architectures})
+ list (APPEND _compileFlags "-arch" "${_arch}")
+ endforeach()
+ endif()
+ if (CMAKE_OSX_SYSROOT)
+ if (CMAKE_${_language}_SYSROOT_FLAG)
+ list (APPEND _compileFlags "${CMAKE_${_language}_SYSROOT_FLAG}" "${CMAKE_OSX_SYSROOT}")
+ else()
+ list (APPEND _compileFlags "-isysroot" "${CMAKE_OSX_SYSROOT}")
+ endif()
+ endif()
+ if (CMAKE_OSX_DEPLOYMENT_TARGET)
+ if (CMAKE_${_language}_OSX_DEPLOYMENT_TARGET_FLAG)
+ list (APPEND _compileFlags "${CMAKE_${_language}_OSX_DEPLOYMENT_TARGET_FLAG}${CMAKE_OSX_DEPLOYMENT_TARGET}")
+ else()
+ list (APPEND _compileFlags "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
+ endif()
+ endif()
+ endif()
+ if (COTIRE_DEBUG AND _compileFlags)
+ message (STATUS "Target ${_target} compile flags: ${_compileFlags}")
+ endif()
+ set (${_flagsVar} ${_compileFlags} PARENT_SCOPE)
+endfunction()
+
+function (cotire_get_target_include_directories _config _language _target _includeDirsVar _systemIncludeDirsVar)
+ set (_includeDirs "")
+ set (_systemIncludeDirs "")
+ # default include dirs
+ if (CMAKE_INCLUDE_CURRENT_DIR)
+ list (APPEND _includeDirs "${CMAKE_CURRENT_BINARY_DIR}")
+ list (APPEND _includeDirs "${CMAKE_CURRENT_SOURCE_DIR}")
+ endif()
+ set (_targetFlags "")
+ cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags)
+ # parse additional include directories from target compile flags
+ if (CMAKE_INCLUDE_FLAG_${_language})
+ string (STRIP "${CMAKE_INCLUDE_FLAG_${_language}}" _includeFlag)
+ string (REGEX REPLACE "^[-/]+" "" _includeFlag "${_includeFlag}")
+ if (_includeFlag)
+ set (_dirs "")
+ cotire_filter_compile_flags("${_language}" "${_includeFlag}" _dirs _ignore ${_targetFlags})
+ if (_dirs)
+ list (APPEND _includeDirs ${_dirs})
+ endif()
+ endif()
+ endif()
+ # parse additional system include directories from target compile flags
+ if (CMAKE_INCLUDE_SYSTEM_FLAG_${_language})
+ string (STRIP "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" _includeFlag)
+ string (REGEX REPLACE "^[-/]+" "" _includeFlag "${_includeFlag}")
+ if (_includeFlag)
+ set (_dirs "")
+ cotire_filter_compile_flags("${_language}" "${_includeFlag}" _dirs _ignore ${_targetFlags})
+ if (_dirs)
+ list (APPEND _systemIncludeDirs ${_dirs})
+ endif()
+ endif()
+ endif()
+ # target include directories
+ get_directory_property(_dirs DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" INCLUDE_DIRECTORIES)
+ if (_target)
+ get_target_property(_targetDirs ${_target} INCLUDE_DIRECTORIES)
+ if (_targetDirs)
+ list (APPEND _dirs ${_targetDirs})
+ endif()
+ get_target_property(_targetDirs ${_target} INTERFACE_SYSTEM_INCLUDE_DIRECTORIES)
+ if (_targetDirs)
+ list (APPEND _systemIncludeDirs ${_targetDirs})
+ endif()
+ endif()
+ # interface include directories from linked library targets
+ if (_target)
+ set (_linkedTargets "")
+ cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets)
+ foreach (_linkedTarget ${_linkedTargets})
+ get_target_property(_linkedTargetType ${_linkedTarget} TYPE)
+ if (CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE AND NOT CMAKE_VERSION VERSION_LESS "3.4.0" AND
+ _linkedTargetType MATCHES "(STATIC|SHARED|MODULE|OBJECT)_LIBRARY")
+ # CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE refers to CMAKE_CURRENT_BINARY_DIR and CMAKE_CURRENT_SOURCE_DIR
+ # at the time, when the target was created. These correspond to the target properties BINARY_DIR and SOURCE_DIR
+ # which are only available with CMake 3.4 or later.
+ get_target_property(_targetDirs ${_linkedTarget} BINARY_DIR)
+ if (_targetDirs)
+ list (APPEND _dirs ${_targetDirs})
+ endif()
+ get_target_property(_targetDirs ${_linkedTarget} SOURCE_DIR)
+ if (_targetDirs)
+ list (APPEND _dirs ${_targetDirs})
+ endif()
+ endif()
+ get_target_property(_targetDirs ${_linkedTarget} INTERFACE_INCLUDE_DIRECTORIES)
+ if (_targetDirs)
+ list (APPEND _dirs ${_targetDirs})
+ endif()
+ get_target_property(_targetDirs ${_linkedTarget} INTERFACE_SYSTEM_INCLUDE_DIRECTORIES)
+ if (_targetDirs)
+ list (APPEND _systemIncludeDirs ${_targetDirs})
+ endif()
+ endforeach()
+ endif()
+ if (dirs)
+ list (REMOVE_DUPLICATES _dirs)
+ endif()
+ list (LENGTH _includeDirs _projectInsertIndex)
+ foreach (_dir ${_dirs})
+ if (CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE)
+ cotire_check_is_path_relative_to("${_dir}" _isRelative "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}")
+ if (_isRelative)
+ list (LENGTH _includeDirs _len)
+ if (_len EQUAL _projectInsertIndex)
+ list (APPEND _includeDirs "${_dir}")
+ else()
+ list (INSERT _includeDirs _projectInsertIndex "${_dir}")
+ endif()
+ math (EXPR _projectInsertIndex "${_projectInsertIndex} + 1")
+ else()
+ list (APPEND _includeDirs "${_dir}")
+ endif()
+ else()
+ list (APPEND _includeDirs "${_dir}")
+ endif()
+ endforeach()
+ list (REMOVE_DUPLICATES _includeDirs)
+ list (REMOVE_DUPLICATES _systemIncludeDirs)
+ if (CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES)
+ list (REMOVE_ITEM _includeDirs ${CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES})
+ endif()
+ if (WIN32 AND NOT MINGW)
+ # convert Windows paths in include directories to CMake paths
+ if (_includeDirs)
+ set (_paths "")
+ foreach (_dir ${_includeDirs})
+ file (TO_CMAKE_PATH "${_dir}" _path)
+ list (APPEND _paths "${_path}")
+ endforeach()
+ set (_includeDirs ${_paths})
+ endif()
+ if (_systemIncludeDirs)
+ set (_paths "")
+ foreach (_dir ${_systemIncludeDirs})
+ file (TO_CMAKE_PATH "${_dir}" _path)
+ list (APPEND _paths "${_path}")
+ endforeach()
+ set (_systemIncludeDirs ${_paths})
+ endif()
+ endif()
+ if (COTIRE_DEBUG AND _includeDirs)
+ message (STATUS "Target ${_target} include dirs: ${_includeDirs}")
+ endif()
+ set (${_includeDirsVar} ${_includeDirs} PARENT_SCOPE)
+ if (COTIRE_DEBUG AND _systemIncludeDirs)
+ message (STATUS "Target ${_target} system include dirs: ${_systemIncludeDirs}")
+ endif()
+ set (${_systemIncludeDirsVar} ${_systemIncludeDirs} PARENT_SCOPE)
+endfunction()
+
+function (cotire_get_target_export_symbol _target _exportSymbolVar)
+ set (_exportSymbol "")
+ get_target_property(_targetType ${_target} TYPE)
+ get_target_property(_enableExports ${_target} ENABLE_EXPORTS)
+ if (_targetType MATCHES "(SHARED|MODULE)_LIBRARY" OR
+ (_targetType STREQUAL "EXECUTABLE" AND _enableExports))
+ get_target_property(_exportSymbol ${_target} DEFINE_SYMBOL)
+ if (NOT _exportSymbol)
+ set (_exportSymbol "${_target}_EXPORTS")
+ endif()
+ string (MAKE_C_IDENTIFIER "${_exportSymbol}" _exportSymbol)
+ endif()
+ set (${_exportSymbolVar} ${_exportSymbol} PARENT_SCOPE)
+endfunction()
+
+function (cotire_get_target_compile_definitions _config _language _target _definitionsVar)
+ string (TOUPPER "${_config}" _upperConfig)
+ set (_configDefinitions "")
+ # CMAKE_INTDIR for multi-configuration build systems
+ if (NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
+ list (APPEND _configDefinitions "CMAKE_INTDIR=\"${_config}\"")
+ endif()
+ # target export define symbol
+ cotire_get_target_export_symbol("${_target}" _defineSymbol)
+ if (_defineSymbol)
+ list (APPEND _configDefinitions "${_defineSymbol}")
+ endif()
+ # directory compile definitions
+ get_directory_property(_definitions DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMPILE_DEFINITIONS)
+ if (_definitions)
+ list (APPEND _configDefinitions ${_definitions})
+ endif()
+ get_directory_property(_definitions DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMPILE_DEFINITIONS_${_upperConfig})
+ if (_definitions)
+ list (APPEND _configDefinitions ${_definitions})
+ endif()
+ # target compile definitions
+ get_target_property(_definitions ${_target} COMPILE_DEFINITIONS)
+ if (_definitions)
+ list (APPEND _configDefinitions ${_definitions})
+ endif()
+ get_target_property(_definitions ${_target} COMPILE_DEFINITIONS_${_upperConfig})
+ if (_definitions)
+ list (APPEND _configDefinitions ${_definitions})
+ endif()
+ # interface compile definitions from linked library targets
+ set (_linkedTargets "")
+ cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets)
+ foreach (_linkedTarget ${_linkedTargets})
+ get_target_property(_definitions ${_linkedTarget} INTERFACE_COMPILE_DEFINITIONS)
+ if (_definitions)
+ list (APPEND _configDefinitions ${_definitions})
+ endif()
+ endforeach()
+ # parse additional compile definitions from target compile flags
+ # and do not look at directory compile definitions, which we already handled
+ set (_targetFlags "")
+ cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags)
+ cotire_filter_compile_flags("${_language}" "D" _definitions _ignore ${_targetFlags})
+ if (_definitions)
+ list (APPEND _configDefinitions ${_definitions})
+ endif()
+ list (REMOVE_DUPLICATES _configDefinitions)
+ if (COTIRE_DEBUG AND _configDefinitions)
+ message (STATUS "Target ${_target} compile definitions: ${_configDefinitions}")
+ endif()
+ set (${_definitionsVar} ${_configDefinitions} PARENT_SCOPE)
+endfunction()
+
+function (cotire_get_target_compiler_flags _config _language _target _compilerFlagsVar)
+ # parse target compile flags omitting compile definitions and include directives
+ set (_targetFlags "")
+ cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags)
+ set (_flagFilter "D")
+ if (CMAKE_INCLUDE_FLAG_${_language})
+ string (STRIP "${CMAKE_INCLUDE_FLAG_${_language}}" _includeFlag)
+ string (REGEX REPLACE "^[-/]+" "" _includeFlag "${_includeFlag}")
+ if (_includeFlag)
+ set (_flagFilter "${_flagFilter}|${_includeFlag}")
+ endif()
+ endif()
+ if (CMAKE_INCLUDE_SYSTEM_FLAG_${_language})
+ string (STRIP "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" _includeFlag)
+ string (REGEX REPLACE "^[-/]+" "" _includeFlag "${_includeFlag}")
+ if (_includeFlag)
+ set (_flagFilter "${_flagFilter}|${_includeFlag}")
+ endif()
+ endif()
+ set (_compilerFlags "")
+ cotire_filter_compile_flags("${_language}" "${_flagFilter}" _ignore _compilerFlags ${_targetFlags})
+ if (COTIRE_DEBUG AND _compilerFlags)
+ message (STATUS "Target ${_target} compiler flags: ${_compilerFlags}")
+ endif()
+ set (${_compilerFlagsVar} ${_compilerFlags} PARENT_SCOPE)
+endfunction()
+
+function (cotire_add_sys_root_paths _pathsVar)
+ if (APPLE)
+ if (CMAKE_OSX_SYSROOT AND CMAKE_${_language}_HAS_ISYSROOT)
+ foreach (_path IN LISTS ${_pathsVar})
+ if (IS_ABSOLUTE "${_path}")
+ get_filename_component(_path "${CMAKE_OSX_SYSROOT}/${_path}" ABSOLUTE)
+ if (EXISTS "${_path}")
+ list (APPEND ${_pathsVar} "${_path}")
+ endif()
+ endif()
+ endforeach()
+ endif()
+ endif()
+ set (${_pathsVar} ${${_pathsVar}} PARENT_SCOPE)
+endfunction()
+
+function (cotire_get_source_extra_properties _sourceFile _pattern _resultVar)
+ set (_extraProperties ${ARGN})
+ set (_result "")
+ if (_extraProperties)
+ list (FIND _extraProperties "${_sourceFile}" _index)
+ if (_index GREATER -1)
+ math (EXPR _index "${_index} + 1")
+ list (LENGTH _extraProperties _len)
+ math (EXPR _len "${_len} - 1")
+ foreach (_index RANGE ${_index} ${_len})
+ list (GET _extraProperties ${_index} _value)
+ if (_value MATCHES "${_pattern}")
+ list (APPEND _result "${_value}")
+ else()
+ break()
+ endif()
+ endforeach()
+ endif()
+ endif()
+ set (${_resultVar} ${_result} PARENT_SCOPE)
+endfunction()
+
+function (cotire_get_source_compile_definitions _config _language _sourceFile _definitionsVar)
+ set (_compileDefinitions "")
+ if (NOT CMAKE_SCRIPT_MODE_FILE)
+ string (TOUPPER "${_config}" _upperConfig)
+ get_source_file_property(_definitions "${_sourceFile}" COMPILE_DEFINITIONS)
+ if (_definitions)
+ list (APPEND _compileDefinitions ${_definitions})
+ endif()
+ get_source_file_property(_definitions "${_sourceFile}" COMPILE_DEFINITIONS_${_upperConfig})
+ if (_definitions)
+ list (APPEND _compileDefinitions ${_definitions})
+ endif()
+ endif()
+ cotire_get_source_extra_properties("${_sourceFile}" "^[a-zA-Z0-9_]+(=.*)?$" _definitions ${ARGN})
+ if (_definitions)
+ list (APPEND _compileDefinitions ${_definitions})
+ endif()
+ if (COTIRE_DEBUG AND _compileDefinitions)
+ message (STATUS "Source ${_sourceFile} compile definitions: ${_compileDefinitions}")
+ endif()
+ set (${_definitionsVar} ${_compileDefinitions} PARENT_SCOPE)
+endfunction()
+
+function (cotire_get_source_files_compile_definitions _config _language _definitionsVar)
+ set (_configDefinitions "")
+ foreach (_sourceFile ${ARGN})
+ cotire_get_source_compile_definitions("${_config}" "${_language}" "${_sourceFile}" _sourceDefinitions)
+ if (_sourceDefinitions)
+ list (APPEND _configDefinitions "${_sourceFile}" ${_sourceDefinitions} "-")
+ endif()
+ endforeach()
+ set (${_definitionsVar} ${_configDefinitions} PARENT_SCOPE)
+endfunction()
+
+function (cotire_get_source_undefs _sourceFile _property _sourceUndefsVar)
+ set (_sourceUndefs "")
+ if (NOT CMAKE_SCRIPT_MODE_FILE)
+ get_source_file_property(_undefs "${_sourceFile}" ${_property})
+ if (_undefs)
+ list (APPEND _sourceUndefs ${_undefs})
+ endif()
+ endif()
+ cotire_get_source_extra_properties("${_sourceFile}" "^[a-zA-Z0-9_]+$" _undefs ${ARGN})
+ if (_undefs)
+ list (APPEND _sourceUndefs ${_undefs})
+ endif()
+ if (COTIRE_DEBUG AND _sourceUndefs)
+ message (STATUS "Source ${_sourceFile} ${_property} undefs: ${_sourceUndefs}")
+ endif()
+ set (${_sourceUndefsVar} ${_sourceUndefs} PARENT_SCOPE)
+endfunction()
+
+function (cotire_get_source_files_undefs _property _sourceUndefsVar)
+ set (_sourceUndefs "")
+ foreach (_sourceFile ${ARGN})
+ cotire_get_source_undefs("${_sourceFile}" ${_property} _undefs)
+ if (_undefs)
+ list (APPEND _sourceUndefs "${_sourceFile}" ${_undefs} "-")
+ endif()
+ endforeach()
+ set (${_sourceUndefsVar} ${_sourceUndefs} PARENT_SCOPE)
+endfunction()
+
+macro (cotire_set_cmd_to_prologue _cmdVar)
+ set (${_cmdVar} "${CMAKE_COMMAND}")
+ if (COTIRE_DEBUG)
+ list (APPEND ${_cmdVar} "--warn-uninitialized")
+ endif()
+ list (APPEND ${_cmdVar} "-DCOTIRE_BUILD_TYPE:STRING=$<CONFIGURATION>")
+ if (XCODE)
+ list (APPEND ${_cmdVar} "-DXCODE:BOOL=TRUE")
+ endif()
+ if (COTIRE_VERBOSE)
+ list (APPEND ${_cmdVar} "-DCOTIRE_VERBOSE:BOOL=ON")
+ elseif("${CMAKE_GENERATOR}" MATCHES "Makefiles")
+ list (APPEND ${_cmdVar} "-DCOTIRE_VERBOSE:BOOL=$(VERBOSE)")
+ endif()
+endmacro()
+
+function (cotire_init_compile_cmd _cmdVar _language _compilerLauncher _compilerExe _compilerArg1)
+ if (NOT _compilerLauncher)
+ set (_compilerLauncher ${CMAKE_${_language}_COMPILER_LAUNCHER})
+ endif()
+ if (NOT _compilerExe)
+ set (_compilerExe "${CMAKE_${_language}_COMPILER}")
+ endif()
+ if (NOT _compilerArg1)
+ set (_compilerArg1 ${CMAKE_${_language}_COMPILER_ARG1})
+ endif()
+ if (WIN32)
+ file (TO_NATIVE_PATH "${_compilerExe}" _compilerExe)
+ endif()
+ string (STRIP "${_compilerArg1}" _compilerArg1)
+ if ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
+ # compiler launcher is only supported for Makefile and Ninja
+ set (${_cmdVar} ${_compilerLauncher} "${_compilerExe}" ${_compilerArg1} PARENT_SCOPE)
+ else()
+ set (${_cmdVar} "${_compilerExe}" ${_compilerArg1} PARENT_SCOPE)
+ endif()
+endfunction()
+
+macro (cotire_add_definitions_to_cmd _cmdVar _language)
+ foreach (_definition ${ARGN})
+ if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel")
+ list (APPEND ${_cmdVar} "/D${_definition}")
+ else()
+ list (APPEND ${_cmdVar} "-D${_definition}")
+ endif()
+ endforeach()
+endmacro()
+
+function (cotire_add_includes_to_cmd _cmdVar _language _includesVar _systemIncludesVar)
+ set (_includeDirs ${${_includesVar}} ${${_systemIncludesVar}})
+ if (_includeDirs)
+ list (REMOVE_DUPLICATES _includeDirs)
+ foreach (_include ${_includeDirs})
+ if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel")
+ file (TO_NATIVE_PATH "${_include}" _include)
+ list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}")
+ else()
+ set (_index -1)
+ if ("${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" MATCHES ".+")
+ list (FIND ${_systemIncludesVar} "${_include}" _index)
+ endif()
+ if (_index GREATER -1)
+ list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}")
+ else()
+ list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}")
+ endif()
+ endif()
+ endforeach()
+ endif()
+ set (${_cmdVar} ${${_cmdVar}} PARENT_SCOPE)
+endfunction()
+
+function (cotire_add_frameworks_to_cmd _cmdVar _language _includesVar _systemIncludesVar)
+ if (APPLE)
+ set (_frameworkDirs "")
+ foreach (_include ${${_includesVar}})
+ if (IS_ABSOLUTE "${_include}" AND _include MATCHES "\\.framework$")
+ get_filename_component(_frameworkDir "${_include}" DIRECTORY)
+ list (APPEND _frameworkDirs "${_frameworkDir}")
+ endif()
+ endforeach()
+ set (_systemFrameworkDirs "")
+ foreach (_include ${${_systemIncludesVar}})
+ if (IS_ABSOLUTE "${_include}" AND _include MATCHES "\\.framework$")
+ get_filename_component(_frameworkDir "${_include}" DIRECTORY)
+ list (APPEND _systemFrameworkDirs "${_frameworkDir}")
+ endif()
+ endforeach()
+ if (_systemFrameworkDirs)
+ list (APPEND _frameworkDirs ${_systemFrameworkDirs})
+ endif()
+ if (_frameworkDirs)
+ list (REMOVE_DUPLICATES _frameworkDirs)
+ foreach (_frameworkDir ${_frameworkDirs})
+ set (_index -1)
+ if ("${CMAKE_${_language}_SYSTEM_FRAMEWORK_SEARCH_FLAG}" MATCHES ".+")
+ list (FIND _systemFrameworkDirs "${_frameworkDir}" _index)
+ endif()
+ if (_index GREATER -1)
+ list (APPEND ${_cmdVar} "${CMAKE_${_language}_SYSTEM_FRAMEWORK_SEARCH_FLAG}${_frameworkDir}")
+ else()
+ list (APPEND ${_cmdVar} "${CMAKE_${_language}_FRAMEWORK_SEARCH_FLAG}${_frameworkDir}")
+ endif()
+ endforeach()
+ endif()
+ endif()
+ set (${_cmdVar} ${${_cmdVar}} PARENT_SCOPE)
+endfunction()
+
+macro (cotire_add_compile_flags_to_cmd _cmdVar)
+ foreach (_flag ${ARGN})
+ list (APPEND ${_cmdVar} "${_flag}")
+ endforeach()
+endmacro()
+
+function (cotire_check_file_up_to_date _fileIsUpToDateVar _file)
+ if (EXISTS "${_file}")
+ set (_triggerFile "")
+ foreach (_dependencyFile ${ARGN})
+ if (EXISTS "${_dependencyFile}")
+ # IS_NEWER_THAN returns TRUE if both files have the same timestamp
+ # thus we do the comparison in both directions to exclude ties
+ if ("${_dependencyFile}" IS_NEWER_THAN "${_file}" AND
+ NOT "${_file}" IS_NEWER_THAN "${_dependencyFile}")
+ set (_triggerFile "${_dependencyFile}")
+ break()
+ endif()
+ endif()
+ endforeach()
+ if (_triggerFile)
+ if (COTIRE_VERBOSE)
+ get_filename_component(_fileName "${_file}" NAME)
+ message (STATUS "${_fileName} update triggered by ${_triggerFile} change.")
+ endif()
+ set (${_fileIsUpToDateVar} FALSE PARENT_SCOPE)
+ else()
+ if (COTIRE_VERBOSE)
+ get_filename_component(_fileName "${_file}" NAME)
+ message (STATUS "${_fileName} is up-to-date.")
+ endif()
+ set (${_fileIsUpToDateVar} TRUE PARENT_SCOPE)
+ endif()
+ else()
+ if (COTIRE_VERBOSE)
+ get_filename_component(_fileName "${_file}" NAME)
+ message (STATUS "${_fileName} does not exist yet.")
+ endif()
+ set (${_fileIsUpToDateVar} FALSE PARENT_SCOPE)
+ endif()
+endfunction()
+
+macro (cotire_find_closest_relative_path _headerFile _includeDirs _relPathVar)
+ set (${_relPathVar} "")
+ foreach (_includeDir ${_includeDirs})
+ if (IS_DIRECTORY "${_includeDir}")
+ file (RELATIVE_PATH _relPath "${_includeDir}" "${_headerFile}")
+ if (NOT IS_ABSOLUTE "${_relPath}" AND NOT "${_relPath}" MATCHES "^\\.\\.")
+ string (LENGTH "${${_relPathVar}}" _closestLen)
+ string (LENGTH "${_relPath}" _relLen)
+ if (_closestLen EQUAL 0 OR _relLen LESS _closestLen)
+ set (${_relPathVar} "${_relPath}")
+ endif()
+ endif()
+ elseif ("${_includeDir}" STREQUAL "${_headerFile}")
+ # if path matches exactly, return short non-empty string
+ set (${_relPathVar} "1")
+ break()
+ endif()
+ endforeach()
+endmacro()
+
+macro (cotire_check_header_file_location _headerFile _insideIncludeDirs _outsideIncludeDirs _headerIsInside)
+ # check header path against ignored and honored include directories
+ cotire_find_closest_relative_path("${_headerFile}" "${_insideIncludeDirs}" _insideRelPath)
+ if (_insideRelPath)
+ # header is inside, but could be become outside if there is a shorter outside match
+ cotire_find_closest_relative_path("${_headerFile}" "${_outsideIncludeDirs}" _outsideRelPath)
+ if (_outsideRelPath)
+ string (LENGTH "${_insideRelPath}" _insideRelPathLen)
+ string (LENGTH "${_outsideRelPath}" _outsideRelPathLen)
+ if (_outsideRelPathLen LESS _insideRelPathLen)
+ set (${_headerIsInside} FALSE)
+ else()
+ set (${_headerIsInside} TRUE)
+ endif()
+ else()
+ set (${_headerIsInside} TRUE)
+ endif()
+ else()
+ # header is outside
+ set (${_headerIsInside} FALSE)
+ endif()
+endmacro()
+
+macro (cotire_check_ignore_header_file_path _headerFile _headerIsIgnoredVar)
+ if (NOT EXISTS "${_headerFile}")
+ set (${_headerIsIgnoredVar} TRUE)
+ elseif (IS_DIRECTORY "${_headerFile}")
+ set (${_headerIsIgnoredVar} TRUE)
+ elseif ("${_headerFile}" MATCHES "\\.\\.|[_-]fixed")
+ # heuristic: ignore headers with embedded parent directory references or "-fixed" or "_fixed" in path
+ # these often stem from using GCC #include_next tricks, which may break the precompiled header compilation
+ # with the error message "error: no include path in which to search for header"
+ set (${_headerIsIgnoredVar} TRUE)
+ else()
+ set (${_headerIsIgnoredVar} FALSE)
+ endif()
+endmacro()
+
+macro (cotire_check_ignore_header_file_ext _headerFile _ignoreExtensionsVar _headerIsIgnoredVar)
+ # check header file extension
+ cotire_get_source_file_extension("${_headerFile}" _headerFileExt)
+ set (${_headerIsIgnoredVar} FALSE)
+ if (_headerFileExt)
+ list (FIND ${_ignoreExtensionsVar} "${_headerFileExt}" _index)
+ if (_index GREATER -1)
+ set (${_headerIsIgnoredVar} TRUE)
+ endif()
+ endif()
+endmacro()
+
+macro (cotire_parse_line _line _headerFileVar _headerDepthVar)
+ if (MSVC)
+ # cl.exe /showIncludes produces different output, depending on the language pack used, e.g.:
+ # English: "Note: including file: C:\directory\file"
+ # German: "Hinweis: Einlesen der Datei: C:\directory\file"
+ # We use a very general regular expression, relying on the presence of the : characters
+ if (_line MATCHES "( +)([a-zA-Z]:[^:]+)$")
+ string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar})
+ get_filename_component(${_headerFileVar} "${CMAKE_MATCH_2}" ABSOLUTE)
+ else()
+ set (${_headerFileVar} "")
+ set (${_headerDepthVar} 0)
+ endif()
+ else()
+ if (_line MATCHES "^(\\.+) (.*)$")
+ # GCC like output
+ string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar})
+ if (IS_ABSOLUTE "${CMAKE_MATCH_2}")
+ set (${_headerFileVar} "${CMAKE_MATCH_2}")
+ else()
+ get_filename_component(${_headerFileVar} "${CMAKE_MATCH_2}" REALPATH)
+ endif()
+ else()
+ set (${_headerFileVar} "")
+ set (${_headerDepthVar} 0)
+ endif()
+ endif()
+endmacro()
+
+function (cotire_parse_includes _language _scanOutput _ignoredIncludeDirs _honoredIncludeDirs _ignoredExtensions _selectedIncludesVar _unparsedLinesVar)
+ if (WIN32)
+ # prevent CMake macro invocation errors due to backslash characters in Windows paths
+ string (REPLACE "\\" "/" _scanOutput "${_scanOutput}")
+ endif()
+ # canonize slashes
+ string (REPLACE "//" "/" _scanOutput "${_scanOutput}")
+ # prevent semicolon from being interpreted as a line separator
+ string (REPLACE ";" "\\;" _scanOutput "${_scanOutput}")
+ # then separate lines
+ string (REGEX REPLACE "\n" ";" _scanOutput "${_scanOutput}")
+ list (LENGTH _scanOutput _len)
+ # remove duplicate lines to speed up parsing
+ list (REMOVE_DUPLICATES _scanOutput)
+ list (LENGTH _scanOutput _uniqueLen)
+ if (COTIRE_VERBOSE OR COTIRE_DEBUG)
+ message (STATUS "Scanning ${_uniqueLen} unique lines of ${_len} for includes")
+ if (_ignoredExtensions)
+ message (STATUS "Ignored extensions: ${_ignoredExtensions}")
+ endif()
+ if (_ignoredIncludeDirs)
+ message (STATUS "Ignored paths: ${_ignoredIncludeDirs}")
+ endif()
+ if (_honoredIncludeDirs)
+ message (STATUS "Included paths: ${_honoredIncludeDirs}")
+ endif()
+ endif()
+ set (_sourceFiles ${ARGN})
+ set (_selectedIncludes "")
+ set (_unparsedLines "")
+ # stack keeps track of inside/outside project status of processed header files
+ set (_headerIsInsideStack "")
+ foreach (_line IN LISTS _scanOutput)
+ if (_line)
+ cotire_parse_line("${_line}" _headerFile _headerDepth)
+ if (_headerFile)
+ cotire_check_header_file_location("${_headerFile}" "${_ignoredIncludeDirs}" "${_honoredIncludeDirs}" _headerIsInside)
+ if (COTIRE_DEBUG)
+ message (STATUS "${_headerDepth}: ${_headerFile} ${_headerIsInside}")
+ endif()
+ # update stack
+ list (LENGTH _headerIsInsideStack _stackLen)
+ if (_headerDepth GREATER _stackLen)
+ math (EXPR _stackLen "${_stackLen} + 1")
+ foreach (_index RANGE ${_stackLen} ${_headerDepth})
+ list (APPEND _headerIsInsideStack ${_headerIsInside})
+ endforeach()
+ else()
+ foreach (_index RANGE ${_headerDepth} ${_stackLen})
+ list (REMOVE_AT _headerIsInsideStack -1)
+ endforeach()
+ list (APPEND _headerIsInsideStack ${_headerIsInside})
+ endif()
+ if (COTIRE_DEBUG)
+ message (STATUS "${_headerIsInsideStack}")
+ endif()
+ # header is a candidate if it is outside project
+ if (NOT _headerIsInside)
+ # get parent header file's inside/outside status
+ if (_headerDepth GREATER 1)
+ math (EXPR _index "${_headerDepth} - 2")
+ list (GET _headerIsInsideStack ${_index} _parentHeaderIsInside)
+ else()
+ set (_parentHeaderIsInside TRUE)
+ endif()
+ # select header file if parent header file is inside project
+ # (e.g., a project header file that includes a standard header file)
+ if (_parentHeaderIsInside)
+ cotire_check_ignore_header_file_path("${_headerFile}" _headerIsIgnored)
+ if (NOT _headerIsIgnored)
+ cotire_check_ignore_header_file_ext("${_headerFile}" _ignoredExtensions _headerIsIgnored)
+ if (NOT _headerIsIgnored)
+ list (APPEND _selectedIncludes "${_headerFile}")
+ else()
+ # fix header's inside status on stack, it is ignored by extension now
+ list (REMOVE_AT _headerIsInsideStack -1)
+ list (APPEND _headerIsInsideStack TRUE)
+ endif()
+ endif()
+ if (COTIRE_DEBUG)
+ message (STATUS "${_headerFile} ${_ignoredExtensions} ${_headerIsIgnored}")
+ endif()
+ endif()
+ endif()
+ else()
+ if (MSVC)
+ # for cl.exe do not keep unparsed lines which solely consist of a source file name
+ string (FIND "${_sourceFiles}" "${_line}" _index)
+ if (_index LESS 0)
+ list (APPEND _unparsedLines "${_line}")
+ endif()
+ else()
+ list (APPEND _unparsedLines "${_line}")
+ endif()
+ endif()
+ endif()
+ endforeach()
+ list (REMOVE_DUPLICATES _selectedIncludes)
+ set (${_selectedIncludesVar} ${_selectedIncludes} PARENT_SCOPE)
+ set (${_unparsedLinesVar} ${_unparsedLines} PARENT_SCOPE)
+endfunction()
+
+function (cotire_scan_includes _includesVar)
+ set(_options "")
+ set(_oneValueArgs COMPILER_ID COMPILER_EXECUTABLE COMPILER_ARG1 COMPILER_VERSION LANGUAGE UNPARSED_LINES SCAN_RESULT)
+ set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES
+ IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS INCLUDE_PRIORITY_PATH COMPILER_LAUNCHER)
+ cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
+ set (_sourceFiles ${_option_UNPARSED_ARGUMENTS})
+ if (NOT _option_LANGUAGE)
+ set (_option_LANGUAGE "CXX")
+ endif()
+ if (NOT _option_COMPILER_ID)
+ set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}")
+ endif()
+ if (NOT _option_COMPILER_VERSION)
+ set (_option_COMPILER_VERSION "${CMAKE_${_option_LANGUAGE}_COMPILER_VERSION}")
+ endif()
+ cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_LAUNCHER}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}")
+ cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS})
+ cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS})
+ cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES)
+ cotire_add_frameworks_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES)
+ cotire_add_makedep_flags("${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" _cmd)
+ # only consider existing source files for scanning
+ set (_existingSourceFiles "")
+ foreach (_sourceFile ${_sourceFiles})
+ if (EXISTS "${_sourceFile}")
+ list (APPEND _existingSourceFiles "${_sourceFile}")
+ endif()
+ endforeach()
+ if (NOT _existingSourceFiles)
+ set (${_includesVar} "" PARENT_SCOPE)
+ return()
+ endif()
+ # add source files to be scanned
+ if (WIN32)
+ foreach (_sourceFile ${_existingSourceFiles})
+ file (TO_NATIVE_PATH "${_sourceFile}" _sourceFileNative)
+ list (APPEND _cmd "${_sourceFileNative}")
+ endforeach()
+ else()
+ list (APPEND _cmd ${_existingSourceFiles})
+ endif()
+ if (COTIRE_VERBOSE)
+ message (STATUS "execute_process: ${_cmd}")
+ endif()
+ if (MSVC_IDE OR _option_COMPILER_ID MATCHES "MSVC")
+ # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared
+ unset (ENV{VS_UNICODE_OUTPUT})
+ endif()
+ execute_process(
+ COMMAND ${_cmd}
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ RESULT_VARIABLE _result
+ OUTPUT_QUIET
+ ERROR_VARIABLE _output)
+ if (_result)
+ message (STATUS "Result ${_result} scanning includes of ${_existingSourceFiles}.")
+ endif()
+ cotire_parse_includes(
+ "${_option_LANGUAGE}" "${_output}"
+ "${_option_IGNORE_PATH}" "${_option_INCLUDE_PATH}"
+ "${_option_IGNORE_EXTENSIONS}"
+ _includes _unparsedLines
+ ${_sourceFiles})
+ if (_option_INCLUDE_PRIORITY_PATH)
+ set (_sortedIncludes "")
+ foreach (_priorityPath ${_option_INCLUDE_PRIORITY_PATH})
+ foreach (_include ${_includes})
+ string (FIND ${_include} ${_priorityPath} _position)
+ if (_position GREATER -1)
+ list (APPEND _sortedIncludes ${_include})
+ endif()
+ endforeach()
+ endforeach()
+ if (_sortedIncludes)
+ list (INSERT _includes 0 ${_sortedIncludes})
+ list (REMOVE_DUPLICATES _includes)
+ endif()
+ endif()
+ set (${_includesVar} ${_includes} PARENT_SCOPE)
+ if (_option_UNPARSED_LINES)
+ set (${_option_UNPARSED_LINES} ${_unparsedLines} PARENT_SCOPE)
+ endif()
+ if (_option_SCAN_RESULT)
+ set (${_option_SCAN_RESULT} ${_result} PARENT_SCOPE)
+ endif()
+endfunction()
+
+macro (cotire_append_undefs _contentsVar)
+ set (_undefs ${ARGN})
+ if (_undefs)
+ list (REMOVE_DUPLICATES _undefs)
+ foreach (_definition ${_undefs})
+ list (APPEND ${_contentsVar} "#undef ${_definition}")
+ endforeach()
+ endif()
+endmacro()
+
+macro (cotire_comment_str _language _commentText _commentVar)
+ if ("${_language}" STREQUAL "CMAKE")
+ set (${_commentVar} "# ${_commentText}")
+ else()
+ set (${_commentVar} "/* ${_commentText} */")
+ endif()
+endmacro()
+
+function (cotire_write_file _language _file _contents _force)
+ get_filename_component(_moduleName "${COTIRE_CMAKE_MODULE_FILE}" NAME)
+ cotire_comment_str("${_language}" "${_moduleName} ${COTIRE_CMAKE_MODULE_VERSION} generated file" _header1)
+ cotire_comment_str("${_language}" "${_file}" _header2)
+ set (_contents "${_header1}\n${_header2}\n${_contents}")
+ if (COTIRE_DEBUG)
+ message (STATUS "${_contents}")
+ endif()
+ if (_force OR NOT EXISTS "${_file}")
+ file (WRITE "${_file}" "${_contents}")
+ else()
+ file (READ "${_file}" _oldContents)
+ if (NOT "${_oldContents}" STREQUAL "${_contents}")
+ file (WRITE "${_file}" "${_contents}")
+ else()
+ if (COTIRE_DEBUG)
+ message (STATUS "${_file} unchanged")
+ endif()
+ endif()
+ endif()
+endfunction()
+
+function (cotire_generate_unity_source _unityFile)
+ set(_options "")
+ set(_oneValueArgs LANGUAGE)
+ set(_multiValueArgs
+ DEPENDS SOURCES_COMPILE_DEFINITIONS
+ PRE_UNDEFS SOURCES_PRE_UNDEFS POST_UNDEFS SOURCES_POST_UNDEFS PROLOGUE EPILOGUE)
+ cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
+ if (_option_DEPENDS)
+ cotire_check_file_up_to_date(_unityFileIsUpToDate "${_unityFile}" ${_option_DEPENDS})
+ if (_unityFileIsUpToDate)
+ return()
+ endif()
+ endif()
+ set (_sourceFiles ${_option_UNPARSED_ARGUMENTS})
+ if (NOT _option_PRE_UNDEFS)
+ set (_option_PRE_UNDEFS "")
+ endif()
+ if (NOT _option_SOURCES_PRE_UNDEFS)
+ set (_option_SOURCES_PRE_UNDEFS "")
+ endif()
+ if (NOT _option_POST_UNDEFS)
+ set (_option_POST_UNDEFS "")
+ endif()
+ if (NOT _option_SOURCES_POST_UNDEFS)
+ set (_option_SOURCES_POST_UNDEFS "")
+ endif()
+ set (_contents "")
+ if (_option_PROLOGUE)
+ list (APPEND _contents ${_option_PROLOGUE})
+ endif()
+ if (_option_LANGUAGE AND _sourceFiles)
+ if ("${_option_LANGUAGE}" STREQUAL "CXX")
+ list (APPEND _contents "#ifdef __cplusplus")
+ elseif ("${_option_LANGUAGE}" STREQUAL "C")
+ list (APPEND _contents "#ifndef __cplusplus")
+ endif()
+ endif()
+ set (_compileUndefinitions "")
+ foreach (_sourceFile ${_sourceFiles})
+ cotire_get_source_compile_definitions(
+ "${_option_CONFIGURATION}" "${_option_LANGUAGE}" "${_sourceFile}" _compileDefinitions
+ ${_option_SOURCES_COMPILE_DEFINITIONS})
+ cotire_get_source_undefs("${_sourceFile}" COTIRE_UNITY_SOURCE_PRE_UNDEFS _sourcePreUndefs ${_option_SOURCES_PRE_UNDEFS})
+ cotire_get_source_undefs("${_sourceFile}" COTIRE_UNITY_SOURCE_POST_UNDEFS _sourcePostUndefs ${_option_SOURCES_POST_UNDEFS})
+ if (_option_PRE_UNDEFS)
+ list (APPEND _compileUndefinitions ${_option_PRE_UNDEFS})
+ endif()
+ if (_sourcePreUndefs)
+ list (APPEND _compileUndefinitions ${_sourcePreUndefs})
+ endif()
+ if (_compileUndefinitions)
+ cotire_append_undefs(_contents ${_compileUndefinitions})
+ set (_compileUndefinitions "")
+ endif()
+ if (_sourcePostUndefs)
+ list (APPEND _compileUndefinitions ${_sourcePostUndefs})
+ endif()
+ if (_option_POST_UNDEFS)
+ list (APPEND _compileUndefinitions ${_option_POST_UNDEFS})
+ endif()
+ foreach (_definition ${_compileDefinitions})
+ if (_definition MATCHES "^([a-zA-Z0-9_]+)=(.+)$")
+ list (APPEND _contents "#define ${CMAKE_MATCH_1} ${CMAKE_MATCH_2}")
+ list (INSERT _compileUndefinitions 0 "${CMAKE_MATCH_1}")
+ else()
+ list (APPEND _contents "#define ${_definition}")
+ list (INSERT _compileUndefinitions 0 "${_definition}")
+ endif()
+ endforeach()
+ # use absolute path as source file location
+ get_filename_component(_sourceFileLocation "${_sourceFile}" ABSOLUTE)
+ if (WIN32)
+ file (TO_NATIVE_PATH "${_sourceFileLocation}" _sourceFileLocation)
+ endif()
+ list (APPEND _contents "#include \"${_sourceFileLocation}\"")
+ endforeach()
+ if (_compileUndefinitions)
+ cotire_append_undefs(_contents ${_compileUndefinitions})
+ set (_compileUndefinitions "")
+ endif()
+ if (_option_LANGUAGE AND _sourceFiles)
+ list (APPEND _contents "#endif")
+ endif()
+ if (_option_EPILOGUE)
+ list (APPEND _contents ${_option_EPILOGUE})
+ endif()
+ list (APPEND _contents "")
+ string (REPLACE ";" "\n" _contents "${_contents}")
+ if (COTIRE_VERBOSE)
+ message ("${_contents}")
+ endif()
+ cotire_write_file("${_option_LANGUAGE}" "${_unityFile}" "${_contents}" TRUE)
+endfunction()
+
+function (cotire_generate_prefix_header _prefixFile)
+ set(_options "")
+ set(_oneValueArgs LANGUAGE COMPILER_EXECUTABLE COMPILER_ARG1 COMPILER_ID COMPILER_VERSION)
+ set(_multiValueArgs DEPENDS COMPILE_DEFINITIONS COMPILE_FLAGS
+ INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH
+ IGNORE_EXTENSIONS INCLUDE_PRIORITY_PATH COMPILER_LAUNCHER)
+ cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
+ if (NOT _option_COMPILER_ID)
+ set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}")
+ endif()
+ if (NOT _option_COMPILER_VERSION)
+ set (_option_COMPILER_VERSION "${CMAKE_${_option_LANGUAGE}_COMPILER_VERSION}")
+ endif()
+ if (_option_DEPENDS)
+ cotire_check_file_up_to_date(_prefixFileIsUpToDate "${_prefixFile}" ${_option_DEPENDS})
+ if (_prefixFileIsUpToDate)
+ # create empty log file
+ set (_unparsedLinesFile "${_prefixFile}.log")
+ file (WRITE "${_unparsedLinesFile}" "")
+ return()
+ endif()
+ endif()
+ set (_prologue "")
+ set (_epilogue "")
+ if (_option_COMPILER_ID MATCHES "Clang")
+ set (_prologue "#pragma clang system_header")
+ elseif (_option_COMPILER_ID MATCHES "GNU")
+ set (_prologue "#pragma GCC system_header")
+ elseif (_option_COMPILER_ID MATCHES "MSVC")
+ set (_prologue "#pragma warning(push, 0)")
+ set (_epilogue "#pragma warning(pop)")
+ elseif (_option_COMPILER_ID MATCHES "Intel")
+ # Intel compiler requires hdrstop pragma to stop generating PCH file
+ set (_epilogue "#pragma hdrstop")
+ endif()
+ set (_sourceFiles ${_option_UNPARSED_ARGUMENTS})
+ cotire_scan_includes(_selectedHeaders ${_sourceFiles}
+ LANGUAGE "${_option_LANGUAGE}"
+ COMPILER_LAUNCHER "${_option_COMPILER_LAUNCHER}"
+ COMPILER_EXECUTABLE "${_option_COMPILER_EXECUTABLE}"
+ COMPILER_ARG1 "${_option_COMPILER_ARG1}"
+ COMPILER_ID "${_option_COMPILER_ID}"
+ COMPILER_VERSION "${_option_COMPILER_VERSION}"
+ COMPILE_DEFINITIONS ${_option_COMPILE_DEFINITIONS}
+ COMPILE_FLAGS ${_option_COMPILE_FLAGS}
+ INCLUDE_DIRECTORIES ${_option_INCLUDE_DIRECTORIES}
+ SYSTEM_INCLUDE_DIRECTORIES ${_option_SYSTEM_INCLUDE_DIRECTORIES}
+ IGNORE_PATH ${_option_IGNORE_PATH}
+ INCLUDE_PATH ${_option_INCLUDE_PATH}
+ IGNORE_EXTENSIONS ${_option_IGNORE_EXTENSIONS}
+ INCLUDE_PRIORITY_PATH ${_option_INCLUDE_PRIORITY_PATH}
+ UNPARSED_LINES _unparsedLines
+ SCAN_RESULT _scanResult)
+ cotire_generate_unity_source("${_prefixFile}"
+ PROLOGUE ${_prologue} EPILOGUE ${_epilogue} LANGUAGE "${_option_LANGUAGE}" ${_selectedHeaders})
+ set (_unparsedLinesFile "${_prefixFile}.log")
+ if (_unparsedLines)
+ if (COTIRE_VERBOSE OR _scanResult OR NOT _selectedHeaders)
+ list (LENGTH _unparsedLines _skippedLineCount)
+ if (WIN32)
+ file (TO_NATIVE_PATH "${_unparsedLinesFile}" _unparsedLinesLogPath)
+ else()
+ set (_unparsedLinesLogPath "${_unparsedLinesFile}")
+ endif()
+ message (STATUS "${_skippedLineCount} line(s) skipped, see ${_unparsedLinesLogPath}")
+ endif()
+ string (REPLACE ";" "\n" _unparsedLines "${_unparsedLines}")
+ endif()
+ file (WRITE "${_unparsedLinesFile}" "${_unparsedLines}\n")
+endfunction()
+
+function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flagsVar)
+ set (_flags ${${_flagsVar}})
+ if (_compilerID MATCHES "MSVC")
+ # cl.exe options used
+ # /nologo suppresses display of sign-on banner
+ # /TC treat all files named on the command line as C source files
+ # /TP treat all files named on the command line as C++ source files
+ # /EP preprocess to stdout without #line directives
+ # /showIncludes list include files
+ set (_sourceFileTypeC "/TC")
+ set (_sourceFileTypeCXX "/TP")
+ if (_flags)
+ # append to list
+ list (APPEND _flags /nologo "${_sourceFileType${_language}}" /EP /showIncludes)
+ else()
+ # return as a flag string
+ set (_flags "${_sourceFileType${_language}} /EP /showIncludes")
+ endif()
+ elseif (_compilerID MATCHES "GNU")
+ # GCC options used
+ # -H print the name of each header file used
+ # -E invoke preprocessor
+ # -fdirectives-only do not expand macros, requires GCC >= 4.3
+ if (_flags)
+ # append to list
+ list (APPEND _flags -H -E)
+ if (NOT "${_compilerVersion}" VERSION_LESS "4.3.0")
+ list (APPEND _flags -fdirectives-only)
+ endif()
+ else()
+ # return as a flag string
+ set (_flags "-H -E")
+ if (NOT "${_compilerVersion}" VERSION_LESS "4.3.0")
+ set (_flags "${_flags} -fdirectives-only")
+ endif()
+ endif()
+ elseif (_compilerID MATCHES "Clang")
+ if (UNIX)
+ # Clang options used
+ # -H print the name of each header file used
+ # -E invoke preprocessor
+ # -fno-color-diagnostics do not print diagnostics in color
+ # -Eonly just run preprocessor, no output
+ if (_flags)
+ # append to list
+ list (APPEND _flags -H -E -fno-color-diagnostics -Xclang -Eonly)
+ else()
+ # return as a flag string
+ set (_flags "-H -E -fno-color-diagnostics -Xclang -Eonly")
+ endif()
+ elseif (WIN32)
+ # Clang-cl.exe options used
+ # /TC treat all files named on the command line as C source files
+ # /TP treat all files named on the command line as C++ source files
+ # /EP preprocess to stdout without #line directives
+ # -H print the name of each header file used
+ # -fno-color-diagnostics do not print diagnostics in color
+ # -Eonly just run preprocessor, no output
+ set (_sourceFileTypeC "/TC")
+ set (_sourceFileTypeCXX "/TP")
+ if (_flags)
+ # append to list
+ list (APPEND _flags "${_sourceFileType${_language}}" /EP -fno-color-diagnostics -Xclang -H -Xclang -Eonly)
+ else()
+ # return as a flag string
+ set (_flags "${_sourceFileType${_language}} /EP -fno-color-diagnostics -Xclang -H -Xclang -Eonly")
+ endif()
+ endif()
+ elseif (_compilerID MATCHES "Intel")
+ if (WIN32)
+ # Windows Intel options used
+ # /nologo do not display compiler version information
+ # /QH display the include file order
+ # /EP preprocess to stdout, omitting #line directives
+ # /TC process all source or unrecognized file types as C source files
+ # /TP process all source or unrecognized file types as C++ source files
+ set (_sourceFileTypeC "/TC")
+ set (_sourceFileTypeCXX "/TP")
+ if (_flags)
+ # append to list
+ list (APPEND _flags /nologo "${_sourceFileType${_language}}" /EP /QH)
+ else()
+ # return as a flag string
+ set (_flags "${_sourceFileType${_language}} /EP /QH")
+ endif()
+ else()
+ # Linux / Mac OS X Intel options used
+ # -H print the name of each header file used
+ # -EP preprocess to stdout, omitting #line directives
+ # -Kc++ process all source or unrecognized file types as C++ source files
+ if (_flags)
+ # append to list
+ if ("${_language}" STREQUAL "CXX")
+ list (APPEND _flags -Kc++)
+ endif()
+ list (APPEND _flags -H -EP)
+ else()
+ # return as a flag string
+ if ("${_language}" STREQUAL "CXX")
+ set (_flags "-Kc++ ")
+ endif()
+ set (_flags "${_flags}-H -EP")
+ endif()
+ endif()
+ else()
+ message (FATAL_ERROR "cotire: unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.")
+ endif()
+ set (${_flagsVar} ${_flags} PARENT_SCOPE)
+endfunction()
+
+function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersion _prefixFile _pchFile _hostFile _flagsVar)
+ set (_flags ${${_flagsVar}})
+ if (_compilerID MATCHES "MSVC")
+ file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative)
+ file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative)
+ file (TO_NATIVE_PATH "${_hostFile}" _hostFileNative)
+ # cl.exe options used
+ # /Yc creates a precompiled header file
+ # /Fp specifies precompiled header binary file name
+ # /FI forces inclusion of file
+ # /TC treat all files named on the command line as C source files
+ # /TP treat all files named on the command line as C++ source files
+ # /Zs syntax check only
+ # /Zm precompiled header memory allocation scaling factor
+ set (_sourceFileTypeC "/TC")
+ set (_sourceFileTypeCXX "/TP")
+ if (_flags)
+ # append to list
+ list (APPEND _flags /nologo "${_sourceFileType${_language}}"
+ "/Yc${_prefixFileNative}" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}" /Zs "${_hostFileNative}")
+ if (COTIRE_PCH_MEMORY_SCALING_FACTOR)
+ list (APPEND _flags "/Zm${COTIRE_PCH_MEMORY_SCALING_FACTOR}")
+ endif()
+ else()
+ # return as a flag string
+ set (_flags "/Yc\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"")
+ if (COTIRE_PCH_MEMORY_SCALING_FACTOR)
+ set (_flags "${_flags} /Zm${COTIRE_PCH_MEMORY_SCALING_FACTOR}")
+ endif()
+ endif()
+ elseif (_compilerID MATCHES "GNU")
+ # GCC options used
+ # -x specify the source language
+ # -c compile but do not link
+ # -o place output in file
+ # note that we cannot use -w to suppress all warnings upon pre-compiling, because turning off a warning may
+ # alter compile flags as a side effect (e.g., -Wwrite-string implies -fconst-strings)
+ set (_xLanguage_C "c-header")
+ set (_xLanguage_CXX "c++-header")
+ if (_flags)
+ # append to list
+ list (APPEND _flags -x "${_xLanguage_${_language}}" -c "${_prefixFile}" -o "${_pchFile}")
+ else()
+ # return as a flag string
+ set (_flags "-x ${_xLanguage_${_language}} -c \"${_prefixFile}\" -o \"${_pchFile}\"")
+ endif()
+ elseif (_compilerID MATCHES "Clang")
+ if (UNIX)
+ # Clang options used
+ # -x specify the source language
+ # -c compile but do not link
+ # -o place output in file
+ # -fno-pch-timestamp disable inclusion of timestamp in precompiled headers (clang 4.0.0+)
+ set (_xLanguage_C "c-header")
+ set (_xLanguage_CXX "c++-header")
+ if (_flags)
+ # append to list
+ list (APPEND _flags -x "${_xLanguage_${_language}}" -c "${_prefixFile}" -o "${_pchFile}")
+ if (NOT "${_compilerVersion}" VERSION_LESS "4.0.0")
+ list (APPEND _flags -Xclang -fno-pch-timestamp)
+ endif()
+ else()
+ # return as a flag string
+ set (_flags "-x ${_xLanguage_${_language}} -c \"${_prefixFile}\" -o \"${_pchFile}\"")
+ if (NOT "${_compilerVersion}" VERSION_LESS "4.0.0")
+ set (_flags "${_flags} -Xclang -fno-pch-timestamp")
+ endif()
+ endif()
+ elseif (WIN32)
+ file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative)
+ file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative)
+ file (TO_NATIVE_PATH "${_hostFile}" _hostFileNative)
+ # Clang-cl.exe options used
+ # /Yc creates a precompiled header file
+ # /Fp specifies precompiled header binary file name
+ # /FI forces inclusion of file
+ # /Zs syntax check only
+ # /TC treat all files named on the command line as C source files
+ # /TP treat all files named on the command line as C++ source files
+ set (_sourceFileTypeC "/TC")
+ set (_sourceFileTypeCXX "/TP")
+ if (_flags)
+ # append to list
+ list (APPEND _flags "${_sourceFileType${_language}}"
+ "/Yc${_prefixFileNative}" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}" /Zs "${_hostFileNative}")
+ else()
+ # return as a flag string
+ set (_flags "/Yc\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"")
+ endif()
+ endif()
+ elseif (_compilerID MATCHES "Intel")
+ if (WIN32)
+ file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative)
+ file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative)
+ file (TO_NATIVE_PATH "${_hostFile}" _hostFileNative)
+ # Windows Intel options used
+ # /nologo do not display compiler version information
+ # /Yc create a precompiled header (PCH) file
+ # /Fp specify a path or file name for precompiled header files
+ # /FI tells the preprocessor to include a specified file name as the header file
+ # /TC process all source or unrecognized file types as C source files
+ # /TP process all source or unrecognized file types as C++ source files
+ # /Zs syntax check only
+ # /Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2)
+ set (_sourceFileTypeC "/TC")
+ set (_sourceFileTypeCXX "/TP")
+ if (_flags)
+ # append to list
+ list (APPEND _flags /nologo "${_sourceFileType${_language}}"
+ "/Yc" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}" /Zs "${_hostFileNative}")
+ if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0")
+ list (APPEND _flags "/Wpch-messages")
+ endif()
+ else()
+ # return as a flag string
+ set (_flags "/Yc /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"")
+ if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0")
+ set (_flags "${_flags} /Wpch-messages")
+ endif()
+ endif()
+ else()
+ # Linux / Mac OS X Intel options used
+ # -pch-dir location for precompiled header files
+ # -pch-create name of the precompiled header (PCH) to create
+ # -Kc++ process all source or unrecognized file types as C++ source files
+ # -fsyntax-only check only for correct syntax
+ # -Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2)
+ get_filename_component(_pchDir "${_pchFile}" DIRECTORY)
+ get_filename_component(_pchName "${_pchFile}" NAME)
+ set (_xLanguage_C "c-header")
+ set (_xLanguage_CXX "c++-header")
+ set (_pchSuppressMessages FALSE)
+ if ("${CMAKE_${_language}_FLAGS}" MATCHES ".*-Wno-pch-messages.*")
+ set(_pchSuppressMessages TRUE)
+ endif()
+ if (_flags)
+ # append to list
+ if ("${_language}" STREQUAL "CXX")
+ list (APPEND _flags -Kc++)
+ endif()
+ list (APPEND _flags -include "${_prefixFile}" -pch-dir "${_pchDir}" -pch-create "${_pchName}" -fsyntax-only "${_hostFile}")
+ if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0")
+ if (NOT _pchSuppressMessages)
+ list (APPEND _flags -Wpch-messages)
+ endif()
+ endif()
+ else()
+ # return as a flag string
+ set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-create \"${_pchName}\"")
+ if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0")
+ if (NOT _pchSuppressMessages)
+ set (_flags "${_flags} -Wpch-messages")
+ endif()
+ endif()
+ endif()
+ endif()
+ else()
+ message (FATAL_ERROR "cotire: unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.")
+ endif()
+ set (${_flagsVar} ${_flags} PARENT_SCOPE)
+endfunction()
+
+function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerVersion _prefixFile _pchFile _flagsVar)
+ set (_flags ${${_flagsVar}})
+ if (_compilerID MATCHES "MSVC")
+ file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative)
+ # cl.exe options used
+ # /Yu uses a precompiled header file during build
+ # /Fp specifies precompiled header binary file name
+ # /FI forces inclusion of file
+ # /Zm precompiled header memory allocation scaling factor
+ if (_pchFile)
+ file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative)
+ if (_flags)
+ # append to list
+ list (APPEND _flags "/Yu${_prefixFileNative}" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}")
+ if (COTIRE_PCH_MEMORY_SCALING_FACTOR)
+ list (APPEND _flags "/Zm${COTIRE_PCH_MEMORY_SCALING_FACTOR}")
+ endif()
+ else()
+ # return as a flag string
+ set (_flags "/Yu\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"")
+ if (COTIRE_PCH_MEMORY_SCALING_FACTOR)
+ set (_flags "${_flags} /Zm${COTIRE_PCH_MEMORY_SCALING_FACTOR}")
+ endif()
+ endif()
+ else()
+ # no precompiled header, force inclusion of prefix header
+ if (_flags)
+ # append to list
+ list (APPEND _flags "/FI${_prefixFileNative}")
+ else()
+ # return as a flag string
+ set (_flags "/FI\"${_prefixFileNative}\"")
+ endif()
+ endif()
+ elseif (_compilerID MATCHES "GNU")
+ # GCC options used
+ # -include process include file as the first line of the primary source file
+ # -Winvalid-pch warns if precompiled header is found but cannot be used
+ # note: ccache requires the -include flag to be used in order to process precompiled header correctly
+ if (_flags)
+ # append to list
+ list (APPEND _flags -Winvalid-pch -include "${_prefixFile}")
+ else()
+ # return as a flag string
+ set (_flags "-Winvalid-pch -include \"${_prefixFile}\"")
+ endif()
+ elseif (_compilerID MATCHES "Clang")
+ if (UNIX)
+ # Clang options used
+ # -include process include file as the first line of the primary source file
+ # note: ccache requires the -include flag to be used in order to process precompiled header correctly
+ if (_flags)
+ # append to list
+ list (APPEND _flags -include "${_prefixFile}")
+ else()
+ # return as a flag string
+ set (_flags "-include \"${_prefixFile}\"")
+ endif()
+ elseif (WIN32)
+ file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative)
+ # Clang-cl.exe options used
+ # /Yu uses a precompiled header file during build
+ # /Fp specifies precompiled header binary file name
+ # /FI forces inclusion of file
+ if (_pchFile)
+ file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative)
+ if (_flags)
+ # append to list
+ list (APPEND _flags "/Yu${_prefixFileNative}" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}")
+ else()
+ # return as a flag string
+ set (_flags "/Yu\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"")
+ endif()
+ else()
+ # no precompiled header, force inclusion of prefix header
+ if (_flags)
+ # append to list
+ list (APPEND _flags "/FI${_prefixFileNative}")
+ else()
+ # return as a flag string
+ set (_flags "/FI\"${_prefixFileNative}\"")
+ endif()
+ endif()
+ endif()
+ elseif (_compilerID MATCHES "Intel")
+ if (WIN32)
+ file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative)
+ # Windows Intel options used
+ # /Yu use a precompiled header (PCH) file
+ # /Fp specify a path or file name for precompiled header files
+ # /FI tells the preprocessor to include a specified file name as the header file
+ # /Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2)
+ if (_pchFile)
+ file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative)
+ if (_flags)
+ # append to list
+ list (APPEND _flags "/Yu" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}")
+ if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0")
+ list (APPEND _flags "/Wpch-messages")
+ endif()
+ else()
+ # return as a flag string
+ set (_flags "/Yu /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"")
+ if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0")
+ set (_flags "${_flags} /Wpch-messages")
+ endif()
+ endif()
+ else()
+ # no precompiled header, force inclusion of prefix header
+ if (_flags)
+ # append to list
+ list (APPEND _flags "/FI${_prefixFileNative}")
+ else()
+ # return as a flag string
+ set (_flags "/FI\"${_prefixFileNative}\"")
+ endif()
+ endif()
+ else()
+ # Linux / Mac OS X Intel options used
+ # -pch-dir location for precompiled header files
+ # -pch-use name of the precompiled header (PCH) to use
+ # -include process include file as the first line of the primary source file
+ # -Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2)
+ if (_pchFile)
+ get_filename_component(_pchDir "${_pchFile}" DIRECTORY)
+ get_filename_component(_pchName "${_pchFile}" NAME)
+ set (_pchSuppressMessages FALSE)
+ if ("${CMAKE_${_language}_FLAGS}" MATCHES ".*-Wno-pch-messages.*")
+ set(_pchSuppressMessages TRUE)
+ endif()
+ if (_flags)
+ # append to list
+ list (APPEND _flags -include "${_prefixFile}" -pch-dir "${_pchDir}" -pch-use "${_pchName}")
+ if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0")
+ if (NOT _pchSuppressMessages)
+ list (APPEND _flags -Wpch-messages)
+ endif()
+ endif()
+ else()
+ # return as a flag string
+ set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-use \"${_pchName}\"")
+ if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0")
+ if (NOT _pchSuppressMessages)
+ set (_flags "${_flags} -Wpch-messages")
+ endif()
+ endif()
+ endif()
+ else()
+ # no precompiled header, force inclusion of prefix header
+ if (_flags)
+ # append to list
+ list (APPEND _flags -include "${_prefixFile}")
+ else()
+ # return as a flag string
+ set (_flags "-include \"${_prefixFile}\"")
+ endif()
+ endif()
+ endif()
+ else()
+ message (FATAL_ERROR "cotire: unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.")
+ endif()
+ set (${_flagsVar} ${_flags} PARENT_SCOPE)
+endfunction()
+
+function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile)
+ set(_options "")
+ set(_oneValueArgs COMPILER_EXECUTABLE COMPILER_ARG1 COMPILER_ID COMPILER_VERSION LANGUAGE)
+ set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES SYS COMPILER_LAUNCHER)
+ cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
+ if (NOT _option_LANGUAGE)
+ set (_option_LANGUAGE "CXX")
+ endif()
+ if (NOT _option_COMPILER_ID)
+ set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}")
+ endif()
+ if (NOT _option_COMPILER_VERSION)
+ set (_option_COMPILER_VERSION "${CMAKE_${_option_LANGUAGE}_COMPILER_VERSION}")
+ endif()
+ cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_LAUNCHER}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}")
+ cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS})
+ cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS})
+ cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES)
+ cotire_add_frameworks_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES)
+ cotire_add_pch_compilation_flags(
+ "${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}"
+ "${_prefixFile}" "${_pchFile}" "${_hostFile}" _cmd)
+ if (COTIRE_VERBOSE)
+ message (STATUS "execute_process: ${_cmd}")
+ endif()
+ if (MSVC_IDE OR _option_COMPILER_ID MATCHES "MSVC")
+ # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared
+ unset (ENV{VS_UNICODE_OUTPUT})
+ elseif (_option_COMPILER_ID MATCHES "Clang" AND _option_COMPILER_VERSION VERSION_LESS "4.0.0")
+ if (_option_COMPILER_LAUNCHER MATCHES "ccache" OR
+ _option_COMPILER_EXECUTABLE MATCHES "ccache")
+ # Newer versions of Clang embed a compilation timestamp into the precompiled header binary,
+ # which results in "file has been modified since the precompiled header was built" errors if ccache is used.
+ # We work around the problem by disabling ccache upon pre-compiling the prefix header.
+ set (ENV{CCACHE_DISABLE} "true")
+ endif()
+ endif()
+ execute_process(
+ COMMAND ${_cmd}
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ RESULT_VARIABLE _result)
+ if (_result)
+ message (FATAL_ERROR "cotire: error ${_result} precompiling ${_prefixFile}.")
+ endif()
+endfunction()
+
+function (cotire_check_precompiled_header_support _language _target _msgVar)
+ set (_unsupportedCompiler
+ "Precompiled headers not supported for ${_language} compiler ${CMAKE_${_language}_COMPILER_ID}")
+ if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC")
+ # PCH supported since Visual Studio C++ 6.0
+ # and CMake does not support an earlier version
+ set (${_msgVar} "" PARENT_SCOPE)
+ elseif (CMAKE_${_language}_COMPILER_ID MATCHES "GNU")
+ # GCC PCH support requires version >= 3.4
+ if ("${CMAKE_${_language}_COMPILER_VERSION}" VERSION_LESS "3.4.0")
+ set (${_msgVar} "${_unsupportedCompiler} version ${CMAKE_${_language}_COMPILER_VERSION}." PARENT_SCOPE)
+ else()
+ set (${_msgVar} "" PARENT_SCOPE)
+ endif()
+ elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Clang")
+ if (UNIX)
+ # all Unix Clang versions have PCH support
+ set (${_msgVar} "" PARENT_SCOPE)
+ elseif (WIN32)
+ # only clang-cl is supported under Windows
+ get_filename_component(_compilerName "${CMAKE_${_language}_COMPILER}" NAME_WE)
+ if (NOT _compilerName MATCHES "cl$")
+ set (${_msgVar} "${_unsupportedCompiler} version ${CMAKE_${_language}_COMPILER_VERSION}. Use clang-cl instead." PARENT_SCOPE)
+ endif()
+ endif()
+ elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Intel")
+ # Intel PCH support requires version >= 8.0.0
+ if ("${CMAKE_${_language}_COMPILER_VERSION}" VERSION_LESS "8.0.0")
+ set (${_msgVar} "${_unsupportedCompiler} version ${CMAKE_${_language}_COMPILER_VERSION}." PARENT_SCOPE)
+ else()
+ set (${_msgVar} "" PARENT_SCOPE)
+ endif()
+ else()
+ set (${_msgVar} "${_unsupportedCompiler}." PARENT_SCOPE)
+ endif()
+ # check if ccache is used as a compiler launcher
+ get_target_property(_launcher ${_target} ${_language}_COMPILER_LAUNCHER)
+ get_filename_component(_realCompilerExe "${CMAKE_${_language}_COMPILER}" REALPATH)
+ if (_realCompilerExe MATCHES "ccache" OR _launcher MATCHES "ccache")
+ # verify that ccache configuration is compatible with precompiled headers
+ # always check environment variable CCACHE_SLOPPINESS, because earlier versions of ccache
+ # do not report the "sloppiness" setting correctly upon printing ccache configuration
+ if (DEFINED ENV{CCACHE_SLOPPINESS})
+ if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "pch_defines" OR
+ NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros")
+ set (${_msgVar}
+ "ccache requires the environment variable CCACHE_SLOPPINESS to be set to \"pch_defines,time_macros\"."
+ PARENT_SCOPE)
+ endif()
+ else()
+ if (_realCompilerExe MATCHES "ccache")
+ set (_ccacheExe "${_realCompilerExe}")
+ else()
+ set (_ccacheExe "${_launcher}")
+ endif()
+ # ccache 3.7.0 replaced --print-config with --show-config
+ # use -p instead, which seems to work for all version for now, sigh
+ execute_process(
+ COMMAND "${_ccacheExe}" "-p"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+ RESULT_VARIABLE _result
+ OUTPUT_VARIABLE _ccacheConfig OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET)
+ if (_result)
+ set (${_msgVar} "ccache configuration cannot be determined." PARENT_SCOPE)
+ elseif (NOT _ccacheConfig MATCHES "sloppiness.*=.*time_macros" OR
+ NOT _ccacheConfig MATCHES "sloppiness.*=.*pch_defines")
+ set (${_msgVar}
+ "ccache requires configuration setting \"sloppiness\" to be set to \"pch_defines,time_macros\"."
+ PARENT_SCOPE)
+ endif()
+ endif()
+ endif()
+ if (APPLE)
+ # PCH compilation not supported by GCC / Clang for multi-architecture builds (e.g., i386, x86_64)
+ cotire_get_configuration_types(_configs)
+ foreach (_config ${_configs})
+ set (_targetFlags "")
+ cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags)
+ cotire_filter_compile_flags("${_language}" "arch" _architectures _ignore ${_targetFlags})
+ list (LENGTH _architectures _numberOfArchitectures)
+ if (_numberOfArchitectures GREATER 1)
+ string (REPLACE ";" ", " _architectureStr "${_architectures}")
+ set (${_msgVar}
+ "Precompiled headers not supported on Darwin for multi-architecture builds (${_architectureStr})."
+ PARENT_SCOPE)
+ break()
+ endif()
+ endforeach()
+ endif()
+endfunction()
+
+macro (cotire_get_intermediate_dir _cotireDir)
+ # ${CMAKE_CFG_INTDIR} may reference a build-time variable when using a generator which supports configuration types
+ get_filename_component(${_cotireDir} "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${COTIRE_INTDIR}" ABSOLUTE)
+endmacro()
+
+macro (cotire_setup_file_extension_variables)
+ set (_unityFileExt_C ".c")
+ set (_unityFileExt_CXX ".cxx")
+ set (_prefixFileExt_C ".h")
+ set (_prefixFileExt_CXX ".hxx")
+ set (_prefixSourceFileExt_C ".c")
+ set (_prefixSourceFileExt_CXX ".cxx")
+endmacro()
+
+function (cotire_make_single_unity_source_file_path _language _target _unityFileVar)
+ cotire_setup_file_extension_variables()
+ if (NOT DEFINED _unityFileExt_${_language})
+ set (${_unityFileVar} "" PARENT_SCOPE)
+ return()
+ endif()
+ set (_unityFileBaseName "${_target}_${_language}${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}")
+ set (_unityFileName "${_unityFileBaseName}${_unityFileExt_${_language}}")
+ cotire_get_intermediate_dir(_baseDir)
+ set (_unityFile "${_baseDir}/${_unityFileName}")
+ set (${_unityFileVar} "${_unityFile}" PARENT_SCOPE)
+endfunction()
+
+function (cotire_make_unity_source_file_paths _language _target _maxIncludes _unityFilesVar)
+ cotire_setup_file_extension_variables()
+ if (NOT DEFINED _unityFileExt_${_language})
+ set (${_unityFileVar} "" PARENT_SCOPE)
+ return()
+ endif()
+ set (_unityFileBaseName "${_target}_${_language}${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}")
+ cotire_get_intermediate_dir(_baseDir)
+ set (_startIndex 0)
+ set (_index 0)
+ set (_unityFiles "")
+ set (_sourceFiles ${ARGN})
+ foreach (_sourceFile ${_sourceFiles})
+ get_source_file_property(_startNew "${_sourceFile}" COTIRE_START_NEW_UNITY_SOURCE)
+ math (EXPR _unityFileCount "${_index} - ${_startIndex}")
+ if (_startNew OR (_maxIncludes GREATER 0 AND NOT _unityFileCount LESS _maxIncludes))
+ if (_index GREATER 0)
+ # start new unity file segment
+ math (EXPR _endIndex "${_index} - 1")
+ set (_unityFileName "${_unityFileBaseName}_${_startIndex}_${_endIndex}${_unityFileExt_${_language}}")
+ list (APPEND _unityFiles "${_baseDir}/${_unityFileName}")
+ endif()
+ set (_startIndex ${_index})
+ endif()
+ math (EXPR _index "${_index} + 1")
+ endforeach()
+ list (LENGTH _sourceFiles _numberOfSources)
+ if (_startIndex EQUAL 0)
+ # there is only a single unity file
+ cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFiles)
+ elseif (_startIndex LESS _numberOfSources)
+ # end with final unity file segment
+ math (EXPR _endIndex "${_index} - 1")
+ set (_unityFileName "${_unityFileBaseName}_${_startIndex}_${_endIndex}${_unityFileExt_${_language}}")
+ list (APPEND _unityFiles "${_baseDir}/${_unityFileName}")
+ endif()
+ set (${_unityFilesVar} ${_unityFiles} PARENT_SCOPE)
+ if (COTIRE_DEBUG AND _unityFiles)
+ message (STATUS "unity files: ${_unityFiles}")
+ endif()
+endfunction()
+
+function (cotire_unity_to_prefix_file_path _language _target _unityFile _prefixFileVar)
+ cotire_setup_file_extension_variables()
+ if (NOT DEFINED _unityFileExt_${_language})
+ set (${_prefixFileVar} "" PARENT_SCOPE)
+ return()
+ endif()
+ set (_unityFileBaseName "${_target}_${_language}${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}")
+ set (_prefixFileBaseName "${_target}_${_language}${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}")
+ string (REPLACE "${_unityFileBaseName}" "${_prefixFileBaseName}" _prefixFile "${_unityFile}")
+ string (REGEX REPLACE "${_unityFileExt_${_language}}$" "${_prefixFileExt_${_language}}" _prefixFile "${_prefixFile}")
+ set (${_prefixFileVar} "${_prefixFile}" PARENT_SCOPE)
+endfunction()
+
+function (cotire_prefix_header_to_source_file_path _language _prefixHeaderFile _prefixSourceFileVar)
+ cotire_setup_file_extension_variables()
+ if (NOT DEFINED _prefixSourceFileExt_${_language})
+ set (${_prefixSourceFileVar} "" PARENT_SCOPE)
+ return()
+ endif()
+ string (REGEX REPLACE "${_prefixFileExt_${_language}}$" "${_prefixSourceFileExt_${_language}}" _prefixSourceFile "${_prefixHeaderFile}")
+ set (${_prefixSourceFileVar} "${_prefixSourceFile}" PARENT_SCOPE)
+endfunction()
+
+function (cotire_make_prefix_file_name _language _target _prefixFileBaseNameVar _prefixFileNameVar)
+ cotire_setup_file_extension_variables()
+ if (NOT _language)
+ set (_prefixFileBaseName "${_target}${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}")
+ set (_prefixFileName "${_prefixFileBaseName}${_prefixFileExt_C}")
+ elseif (DEFINED _prefixFileExt_${_language})
+ set (_prefixFileBaseName "${_target}_${_language}${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}")
+ set (_prefixFileName "${_prefixFileBaseName}${_prefixFileExt_${_language}}")
+ else()
+ set (_prefixFileBaseName "")
+ set (_prefixFileName "")
+ endif()
+ set (${_prefixFileBaseNameVar} "${_prefixFileBaseName}" PARENT_SCOPE)
+ set (${_prefixFileNameVar} "${_prefixFileName}" PARENT_SCOPE)
+endfunction()
+
+function (cotire_make_prefix_file_path _language _target _prefixFileVar)
+ cotire_make_prefix_file_name("${_language}" "${_target}" _prefixFileBaseName _prefixFileName)
+ set (${_prefixFileVar} "" PARENT_SCOPE)
+ if (_prefixFileName)
+ if (NOT _language)
+ set (_language "C")
+ endif()
+ if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang|Intel|MSVC")
+ cotire_get_intermediate_dir(_baseDir)
+ set (${_prefixFileVar} "${_baseDir}/${_prefixFileName}" PARENT_SCOPE)
+ endif()
+ endif()
+endfunction()
+
+function (cotire_make_pch_file_path _language _target _pchFileVar)
+ cotire_make_prefix_file_name("${_language}" "${_target}" _prefixFileBaseName _prefixFileName)
+ set (${_pchFileVar} "" PARENT_SCOPE)
+ if (_prefixFileBaseName AND _prefixFileName)
+ cotire_check_precompiled_header_support("${_language}" "${_target}" _msg)
+ if (NOT _msg)
+ if (XCODE)
+ # For Xcode, we completely hand off the compilation of the prefix header to the IDE
+ return()
+ endif()
+ cotire_get_intermediate_dir(_baseDir)
+ if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC")
+ # MSVC uses the extension .pch added to the prefix header base name
+ set (${_pchFileVar} "${_baseDir}/${_prefixFileBaseName}.pch" PARENT_SCOPE)
+ elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Clang")
+ # Clang looks for a precompiled header corresponding to the prefix header with the extension .pch appended
+ set (${_pchFileVar} "${_baseDir}/${_prefixFileName}.pch" PARENT_SCOPE)
+ elseif (CMAKE_${_language}_COMPILER_ID MATCHES "GNU")
+ # GCC looks for a precompiled header corresponding to the prefix header with the extension .gch appended
+ set (${_pchFileVar} "${_baseDir}/${_prefixFileName}.gch" PARENT_SCOPE)
+ elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Intel")
+ # Intel uses the extension .pchi added to the prefix header base name
+ set (${_pchFileVar} "${_baseDir}/${_prefixFileBaseName}.pchi" PARENT_SCOPE)
+ endif()
+ endif()
+ endif()
+endfunction()
+
+function (cotire_select_unity_source_files _unityFile _sourcesVar)
+ set (_sourceFiles ${ARGN})
+ if (_sourceFiles AND "${_unityFile}" MATCHES "${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}_([0-9]+)_([0-9]+)")
+ set (_startIndex ${CMAKE_MATCH_1})
+ set (_endIndex ${CMAKE_MATCH_2})
+ list (LENGTH _sourceFiles _numberOfSources)
+ if (NOT _startIndex LESS _numberOfSources)
+ math (EXPR _startIndex "${_numberOfSources} - 1")
+ endif()
+ if (NOT _endIndex LESS _numberOfSources)
+ math (EXPR _endIndex "${_numberOfSources} - 1")
+ endif()
+ set (_files "")
+ foreach (_index RANGE ${_startIndex} ${_endIndex})
+ list (GET _sourceFiles ${_index} _file)
+ list (APPEND _files "${_file}")
+ endforeach()
+ else()
+ set (_files ${_sourceFiles})
+ endif()
+ set (${_sourcesVar} ${_files} PARENT_SCOPE)
+endfunction()
+
+function (cotire_get_unity_source_dependencies _language _target _dependencySourcesVar)
+ set (_dependencySources "")
+ # depend on target's generated source files
+ get_target_property(_targetSourceFiles ${_target} SOURCES)
+ cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${_targetSourceFiles})
+ if (_generatedSources)
+ # but omit all generated source files that have the COTIRE_EXCLUDED property set to true
+ cotire_get_objects_with_property_on(_excludedGeneratedSources COTIRE_EXCLUDED SOURCE ${_generatedSources})
+ if (_excludedGeneratedSources)
+ list (REMOVE_ITEM _generatedSources ${_excludedGeneratedSources})
+ endif()
+ # and omit all generated source files that have the COTIRE_DEPENDENCY property set to false explicitly
+ cotire_get_objects_with_property_off(_excludedNonDependencySources COTIRE_DEPENDENCY SOURCE ${_generatedSources})
+ if (_excludedNonDependencySources)
+ list (REMOVE_ITEM _generatedSources ${_excludedNonDependencySources})
+ endif()
+ if (_generatedSources)
+ list (APPEND _dependencySources ${_generatedSources})
+ endif()
+ endif()
+ if (COTIRE_DEBUG AND _dependencySources)
+ message (STATUS "${_language} ${_target} unity source dependencies: ${_dependencySources}")
+ endif()
+ set (${_dependencySourcesVar} ${_dependencySources} PARENT_SCOPE)
+endfunction()
+
+function (cotire_get_prefix_header_dependencies _language _target _dependencySourcesVar)
+ set (_dependencySources "")
+ # depend on target source files marked with custom COTIRE_DEPENDENCY property
+ get_target_property(_targetSourceFiles ${_target} SOURCES)
+ cotire_get_objects_with_property_on(_dependencySources COTIRE_DEPENDENCY SOURCE ${_targetSourceFiles})
+ if (COTIRE_DEBUG AND _dependencySources)
+ message (STATUS "${_language} ${_target} prefix header dependencies: ${_dependencySources}")
+ endif()
+ set (${_dependencySourcesVar} ${_dependencySources} PARENT_SCOPE)
+endfunction()
+
+function (cotire_generate_target_script _language _configurations _target _targetScriptVar _targetConfigScriptVar)
+ set (_targetSources ${ARGN})
+ cotire_get_prefix_header_dependencies(${_language} ${_target} COTIRE_TARGET_PREFIX_DEPENDS ${_targetSources})
+ cotire_get_unity_source_dependencies(${_language} ${_target} COTIRE_TARGET_UNITY_DEPENDS ${_targetSources})
+ # set up variables to be configured
+ set (COTIRE_TARGET_LANGUAGE "${_language}")
+ get_target_property(COTIRE_TARGET_IGNORE_PATH ${_target} COTIRE_PREFIX_HEADER_IGNORE_PATH)
+ cotire_add_sys_root_paths(COTIRE_TARGET_IGNORE_PATH)
+ get_target_property(COTIRE_TARGET_INCLUDE_PATH ${_target} COTIRE_PREFIX_HEADER_INCLUDE_PATH)
+ cotire_add_sys_root_paths(COTIRE_TARGET_INCLUDE_PATH)
+ get_target_property(COTIRE_TARGET_PRE_UNDEFS ${_target} COTIRE_UNITY_SOURCE_PRE_UNDEFS)
+ get_target_property(COTIRE_TARGET_POST_UNDEFS ${_target} COTIRE_UNITY_SOURCE_POST_UNDEFS)
+ get_target_property(COTIRE_TARGET_MAXIMUM_NUMBER_OF_INCLUDES ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES)
+ get_target_property(COTIRE_TARGET_INCLUDE_PRIORITY_PATH ${_target} COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH)
+ cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_PRE_UNDEFS COTIRE_TARGET_SOURCES_PRE_UNDEFS ${_targetSources})
+ cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_POST_UNDEFS COTIRE_TARGET_SOURCES_POST_UNDEFS ${_targetSources})
+ set (COTIRE_TARGET_CONFIGURATION_TYPES "${_configurations}")
+ foreach (_config ${_configurations})
+ string (TOUPPER "${_config}" _upperConfig)
+ cotire_get_target_include_directories(
+ "${_config}" "${_language}" "${_target}" COTIRE_TARGET_INCLUDE_DIRECTORIES_${_upperConfig} COTIRE_TARGET_SYSTEM_INCLUDE_DIRECTORIES_${_upperConfig})
+ cotire_get_target_compile_definitions(
+ "${_config}" "${_language}" "${_target}" COTIRE_TARGET_COMPILE_DEFINITIONS_${_upperConfig})
+ cotire_get_target_compiler_flags(
+ "${_config}" "${_language}" "${_target}" COTIRE_TARGET_COMPILE_FLAGS_${_upperConfig})
+ cotire_get_source_files_compile_definitions(
+ "${_config}" "${_language}" COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${_upperConfig} ${_targetSources})
+ endforeach()
+ get_target_property(COTIRE_TARGET_${_language}_COMPILER_LAUNCHER ${_target} ${_language}_COMPILER_LAUNCHER)
+ # set up COTIRE_TARGET_SOURCES
+ set (COTIRE_TARGET_SOURCES "")
+ foreach (_sourceFile ${_targetSources})
+ get_source_file_property(_generated "${_sourceFile}" GENERATED)
+ if (_generated)
+ # use absolute paths for generated files only, retrieving the LOCATION property is an expensive operation
+ get_source_file_property(_sourceLocation "${_sourceFile}" LOCATION)
+ list (APPEND COTIRE_TARGET_SOURCES "${_sourceLocation}")
+ else()
+ list (APPEND COTIRE_TARGET_SOURCES "${_sourceFile}")
+ endif()
+ endforeach()
+ # copy variable definitions to cotire target script
+ get_cmake_property(_vars VARIABLES)
+ string (REGEX MATCHALL "COTIRE_[A-Za-z0-9_]+" _matchVars "${_vars}")
+ # omit COTIRE_*_INIT variables
+ string (REGEX MATCHALL "COTIRE_[A-Za-z0-9_]+_INIT" _initVars "${_matchVars}")
+ if (_initVars)
+ list (REMOVE_ITEM _matchVars ${_initVars})
+ endif()
+ # omit COTIRE_VERBOSE which is passed as a CMake define on command line
+ list (REMOVE_ITEM _matchVars COTIRE_VERBOSE)
+ set (_contents "")
+ set (_contentsHasGeneratorExpressions FALSE)
+ foreach (_var IN LISTS _matchVars ITEMS
+ XCODE MSVC CMAKE_GENERATOR CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES
+ CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER_VERSION
+ CMAKE_${_language}_COMPILER_LAUNCHER CMAKE_${_language}_COMPILER CMAKE_${_language}_COMPILER_ARG1
+ CMAKE_INCLUDE_FLAG_${_language} CMAKE_INCLUDE_FLAG_SEP_${_language}
+ CMAKE_INCLUDE_SYSTEM_FLAG_${_language}
+ CMAKE_${_language}_FRAMEWORK_SEARCH_FLAG
+ CMAKE_${_language}_SYSTEM_FRAMEWORK_SEARCH_FLAG
+ CMAKE_${_language}_SOURCE_FILE_EXTENSIONS)
+ if (DEFINED ${_var})
+ string (REPLACE "\"" "\\\"" _value "${${_var}}")
+ set (_contents "${_contents}set (${_var} \"${_value}\")\n")
+ if (NOT _contentsHasGeneratorExpressions)
+ if ("${_value}" MATCHES "\\$<.*>")
+ set (_contentsHasGeneratorExpressions TRUE)
+ endif()
+ endif()
+ endif()
+ endforeach()
+ # generate target script file
+ get_filename_component(_moduleName "${COTIRE_CMAKE_MODULE_FILE}" NAME)
+ set (_targetCotireScript "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${_language}_${_moduleName}")
+ cotire_write_file("CMAKE" "${_targetCotireScript}" "${_contents}" FALSE)
+ if (_contentsHasGeneratorExpressions)
+ # use file(GENERATE ...) to expand generator expressions in the target script at CMake generate-time
+ set (_configNameOrNoneGeneratorExpression "$<$<CONFIG:>:None>$<$<NOT:$<CONFIG:>>:$<CONFIGURATION>>")
+ set (_targetCotireConfigScript "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${_language}_${_configNameOrNoneGeneratorExpression}_${_moduleName}")
+ file (GENERATE OUTPUT "${_targetCotireConfigScript}" INPUT "${_targetCotireScript}")
+ else()
+ set (_targetCotireConfigScript "${_targetCotireScript}")
+ endif()
+ set (${_targetScriptVar} "${_targetCotireScript}" PARENT_SCOPE)
+ set (${_targetConfigScriptVar} "${_targetCotireConfigScript}" PARENT_SCOPE)
+endfunction()
+
+function (cotire_setup_pch_file_compilation _language _target _targetScript _prefixFile _pchFile _hostFile)
+ set (_sourceFiles ${ARGN})
+ if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel" OR
+ (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "Clang"))
+ # for MSVC, Intel and Clang-cl, we attach the precompiled header compilation to the host file
+ # the remaining files include the precompiled header, see cotire_setup_pch_file_inclusion
+ if (_sourceFiles)
+ set (_flags "")
+ cotire_add_pch_compilation_flags(
+ "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}"
+ "${_prefixFile}" "${_pchFile}" "${_hostFile}" _flags)
+ set_property (SOURCE ${_hostFile} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ")
+ if (COTIRE_DEBUG)
+ message (STATUS "set_property: SOURCE ${_hostFile} APPEND_STRING COMPILE_FLAGS ${_flags}")
+ endif()
+ set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_OUTPUTS "${_pchFile}")
+ # make object file generated from host file depend on prefix header
+ set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}")
+ # mark host file as cotired to prevent it from being used in another cotired target
+ set_property (SOURCE ${_hostFile} PROPERTY COTIRE_TARGET "${_target}")
+ endif()
+ elseif ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
+ # for makefile based generator, we add a custom command to precompile the prefix header
+ if (_targetScript)
+ cotire_set_cmd_to_prologue(_cmds)
+ list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "precompile" "${_targetScript}" "${_prefixFile}" "${_pchFile}" "${_hostFile}")
+ if (MSVC_IDE)
+ file (TO_NATIVE_PATH "${_pchFile}" _pchFileLogPath)
+ else()
+ file (RELATIVE_PATH _pchFileLogPath "${CMAKE_BINARY_DIR}" "${_pchFile}")
+ endif()
+ # make precompiled header compilation depend on the actual compiler executable used to force
+ # re-compilation when the compiler executable is updated. This prevents "created by a different GCC executable"
+ # warnings when the precompiled header is included.
+ get_filename_component(_realCompilerExe "${CMAKE_${_language}_COMPILER}" ABSOLUTE)
+ if (COTIRE_DEBUG)
+ message (STATUS "add_custom_command: OUTPUT ${_pchFile} ${_cmds} DEPENDS ${_prefixFile} ${_realCompilerExe} IMPLICIT_DEPENDS ${_language} ${_prefixFile}")
+ endif()
+ set_property (SOURCE "${_pchFile}" PROPERTY GENERATED TRUE)
+ add_custom_command(
+ OUTPUT "${_pchFile}"
+ COMMAND ${_cmds}
+ DEPENDS "${_prefixFile}" "${_realCompilerExe}"
+ IMPLICIT_DEPENDS ${_language} "${_prefixFile}"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ COMMENT "Building ${_language} precompiled header ${_pchFileLogPath}"
+ VERBATIM)
+ endif()
+ endif()
+endfunction()
+
+function (cotire_setup_pch_file_inclusion _language _target _wholeTarget _prefixFile _pchFile _hostFile)
+ if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel" OR
+ (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "Clang"))
+ # for MSVC, Intel and clang-cl, we include the precompiled header in all but the host file
+ # the host file does the precompiled header compilation, see cotire_setup_pch_file_compilation
+ set (_sourceFiles ${ARGN})
+ list (LENGTH _sourceFiles _numberOfSourceFiles)
+ if (_numberOfSourceFiles GREATER 0)
+ # mark sources as cotired to prevent them from being used in another cotired target
+ set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}")
+ set (_flags "")
+ cotire_add_prefix_pch_inclusion_flags(
+ "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}"
+ "${_prefixFile}" "${_pchFile}" _flags)
+ set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ")
+ if (COTIRE_DEBUG)
+ message (STATUS "set_property: SOURCE ${_sourceFiles} APPEND_STRING COMPILE_FLAGS ${_flags}")
+ endif()
+ # make object files generated from source files depend on precompiled header
+ set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_pchFile}")
+ endif()
+ elseif ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
+ set (_sourceFiles ${_hostFile} ${ARGN})
+ if (NOT _wholeTarget)
+ # for makefile based generator, we force the inclusion of the prefix header for a subset
+ # of the source files, if this is a multi-language target or has excluded files
+ set (_flags "")
+ cotire_add_prefix_pch_inclusion_flags(
+ "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}"
+ "${_prefixFile}" "${_pchFile}" _flags)
+ set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ")
+ if (COTIRE_DEBUG)
+ message (STATUS "set_property: SOURCE ${_sourceFiles} APPEND_STRING COMPILE_FLAGS ${_flags}")
+ endif()
+ # mark sources as cotired to prevent them from being used in another cotired target
+ set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}")
+ endif()
+ # make object files generated from source files depend on precompiled header
+ set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_pchFile}")
+ endif()
+endfunction()
+
+function (cotire_setup_prefix_file_inclusion _language _target _prefixFile)
+ set (_sourceFiles ${ARGN})
+ # force the inclusion of the prefix header for the given source files
+ set (_flags "")
+ set (_pchFile "")
+ cotire_add_prefix_pch_inclusion_flags(
+ "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}"
+ "${_prefixFile}" "${_pchFile}" _flags)
+ set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ")
+ if (COTIRE_DEBUG)
+ message (STATUS "set_property: SOURCE ${_sourceFiles} APPEND_STRING COMPILE_FLAGS ${_flags}")
+ endif()
+ # mark sources as cotired to prevent them from being used in another cotired target
+ set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}")
+ # make object files generated from source files depend on prefix header
+ set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}")
+endfunction()
+
+function (cotire_get_first_set_property_value _propertyValueVar _type _object)
+ set (_properties ${ARGN})
+ foreach (_property ${_properties})
+ get_property(_propertyValue ${_type} "${_object}" PROPERTY ${_property})
+ if (_propertyValue)
+ set (${_propertyValueVar} ${_propertyValue} PARENT_SCOPE)
+ return()
+ endif()
+ endforeach()
+ set (${_propertyValueVar} "" PARENT_SCOPE)
+endfunction()
+
+function (cotire_setup_combine_command _language _targetScript _joinedFile _cmdsVar)
+ set (_files ${ARGN})
+ set (_filesPaths "")
+ foreach (_file ${_files})
+ get_filename_component(_filePath "${_file}" ABSOLUTE)
+ list (APPEND _filesPaths "${_filePath}")
+ endforeach()
+ cotire_set_cmd_to_prologue(_prefixCmd)
+ list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "combine")
+ if (_targetScript)
+ list (APPEND _prefixCmd "${_targetScript}")
+ endif()
+ list (APPEND _prefixCmd "${_joinedFile}" ${_filesPaths})
+ if (COTIRE_DEBUG)
+ message (STATUS "add_custom_command: OUTPUT ${_joinedFile} COMMAND ${_prefixCmd} DEPENDS ${_files}")
+ endif()
+ set_property (SOURCE "${_joinedFile}" PROPERTY GENERATED TRUE)
+ if (MSVC_IDE)
+ file (TO_NATIVE_PATH "${_joinedFile}" _joinedFileLogPath)
+ else()
+ file (RELATIVE_PATH _joinedFileLogPath "${CMAKE_BINARY_DIR}" "${_joinedFile}")
+ endif()
+ get_filename_component(_joinedFileBaseName "${_joinedFile}" NAME_WE)
+ get_filename_component(_joinedFileExt "${_joinedFile}" EXT)
+ if (_language AND _joinedFileBaseName MATCHES "${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}$")
+ set (_comment "Generating ${_language} unity source ${_joinedFileLogPath}")
+ elseif (_language AND _joinedFileBaseName MATCHES "${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}$")
+ if (_joinedFileExt MATCHES "^\\.c")
+ set (_comment "Generating ${_language} prefix source ${_joinedFileLogPath}")
+ else()
+ set (_comment "Generating ${_language} prefix header ${_joinedFileLogPath}")
+ endif()
+ else()
+ set (_comment "Generating ${_joinedFileLogPath}")
+ endif()
+ add_custom_command(
+ OUTPUT "${_joinedFile}"
+ COMMAND ${_prefixCmd}
+ DEPENDS ${_files}
+ COMMENT "${_comment}"
+ WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
+ VERBATIM)
+ list (APPEND ${_cmdsVar} COMMAND ${_prefixCmd})
+ set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE)
+endfunction()
+
+function (cotire_setup_target_pch_usage _languages _target _wholeTarget)
+ if (XCODE)
+ # for Xcode, we attach a pre-build action to generate the unity sources and prefix headers
+ set (_prefixFiles "")
+ foreach (_language ${_languages})
+ get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER)
+ if (_prefixFile)
+ list (APPEND _prefixFiles "${_prefixFile}")
+ endif()
+ endforeach()
+ set (_cmds ${ARGN})
+ list (LENGTH _prefixFiles _numberOfPrefixFiles)
+ if (_numberOfPrefixFiles GREATER 1)
+ # we also generate a generic, single prefix header which includes all language specific prefix headers
+ set (_language "")
+ set (_targetScript "")
+ cotire_make_prefix_file_path("${_language}" ${_target} _prefixHeader)
+ cotire_setup_combine_command("${_language}" "${_targetScript}" "${_prefixHeader}" _cmds ${_prefixFiles})
+ else()
+ set (_prefixHeader "${_prefixFiles}")
+ endif()
+ if (COTIRE_DEBUG)
+ message (STATUS "add_custom_command: TARGET ${_target} PRE_BUILD ${_cmds}")
+ endif()
+ # because CMake PRE_BUILD command does not support dependencies,
+ # we check dependencies explicity in cotire script mode when the pre-build action is run
+ add_custom_command(
+ TARGET "${_target}"
+ PRE_BUILD ${_cmds}
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ COMMENT "Updating target ${_target} prefix headers"
+ VERBATIM)
+ # make Xcode precompile the generated prefix header with ProcessPCH and ProcessPCH++
+ set_target_properties(${_target} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES")
+ set_target_properties(${_target} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${_prefixHeader}")
+ elseif ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
+ # for makefile based generator, we force inclusion of the prefix header for all target source files
+ # if this is a single-language target without any excluded files
+ if (_wholeTarget)
+ set (_language "${_languages}")
+ # for MSVC, Intel and clang-cl, precompiled header inclusion is always done on the source file level
+ # see cotire_setup_pch_file_inclusion
+ if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel" AND NOT
+ (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "Clang"))
+ get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER)
+ if (_prefixFile)
+ get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER)
+ set (_options COMPILE_OPTIONS)
+ cotire_add_prefix_pch_inclusion_flags(
+ "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}"
+ "${_prefixFile}" "${_pchFile}" _options)
+ set_property(TARGET ${_target} APPEND PROPERTY ${_options})
+ if (COTIRE_DEBUG)
+ message (STATUS "set_property: TARGET ${_target} APPEND PROPERTY ${_options}")
+ endif()
+ endif()
+ endif()
+ endif()
+ endif()
+endfunction()
+
+function (cotire_setup_unity_generation_commands _language _target _targetScript _targetConfigScript _unityFiles _cmdsVar)
+ set (_dependencySources "")
+ cotire_get_unity_source_dependencies(${_language} ${_target} _dependencySources ${ARGN})
+ foreach (_unityFile ${_unityFiles})
+ set_property (SOURCE "${_unityFile}" PROPERTY GENERATED TRUE)
+ # set up compiled unity source dependencies via OBJECT_DEPENDS
+ # this ensures that missing source files are generated before the unity file is compiled
+ if (COTIRE_DEBUG AND _dependencySources)
+ message (STATUS "${_unityFile} OBJECT_DEPENDS ${_dependencySources}")
+ endif()
+ if (_dependencySources)
+ # the OBJECT_DEPENDS property requires a list of full paths
+ set (_objectDependsPaths "")
+ foreach (_sourceFile ${_dependencySources})
+ get_source_file_property(_sourceLocation "${_sourceFile}" LOCATION)
+ list (APPEND _objectDependsPaths "${_sourceLocation}")
+ endforeach()
+ set_property (SOURCE "${_unityFile}" PROPERTY OBJECT_DEPENDS ${_objectDependsPaths})
+ endif()
+ if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel")
+ # unity file compilation results in potentially huge object file,
+ # thus use /bigobj by default unter cl.exe and Windows Intel
+ set_property (SOURCE "${_unityFile}" APPEND_STRING PROPERTY COMPILE_FLAGS "/bigobj")
+ endif()
+ cotire_set_cmd_to_prologue(_unityCmd)
+ list (APPEND _unityCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "unity" "${_targetConfigScript}" "${_unityFile}")
+ if (CMAKE_VERSION VERSION_LESS "3.1.0")
+ set (_unityCmdDepends "${_targetScript}")
+ else()
+ # CMake 3.1.0 supports generator expressions in arguments to DEPENDS
+ set (_unityCmdDepends "${_targetConfigScript}")
+ endif()
+ if (MSVC_IDE)
+ file (TO_NATIVE_PATH "${_unityFile}" _unityFileLogPath)
+ else()
+ file (RELATIVE_PATH _unityFileLogPath "${CMAKE_BINARY_DIR}" "${_unityFile}")
+ endif()
+ if (COTIRE_DEBUG)
+ message (STATUS "add_custom_command: OUTPUT ${_unityFile} COMMAND ${_unityCmd} DEPENDS ${_unityCmdDepends}")
+ endif()
+ add_custom_command(
+ OUTPUT "${_unityFile}"
+ COMMAND ${_unityCmd}
+ DEPENDS ${_unityCmdDepends}
+ COMMENT "Generating ${_language} unity source ${_unityFileLogPath}"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ VERBATIM)
+ list (APPEND ${_cmdsVar} COMMAND ${_unityCmd})
+ endforeach()
+ set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE)
+endfunction()
+
+function (cotire_setup_prefix_generation_command _language _target _targetScript _prefixFile _unityFiles _cmdsVar)
+ set (_sourceFiles ${ARGN})
+ set (_dependencySources "")
+ cotire_get_prefix_header_dependencies(${_language} ${_target} _dependencySources ${_sourceFiles})
+ cotire_set_cmd_to_prologue(_prefixCmd)
+ list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "prefix" "${_targetScript}" "${_prefixFile}" ${_unityFiles})
+ set_property (SOURCE "${_prefixFile}" PROPERTY GENERATED TRUE)
+ # make prefix header generation depend on the actual compiler executable used to force
+ # re-generation when the compiler executable is updated. This prevents "file not found"
+ # errors for compiler version specific system header files.
+ get_filename_component(_realCompilerExe "${CMAKE_${_language}_COMPILER}" ABSOLUTE)
+ if (COTIRE_DEBUG)
+ message (STATUS "add_custom_command: OUTPUT ${_prefixFile} COMMAND ${_prefixCmd} DEPENDS ${_unityFile} ${_dependencySources} ${_realCompilerExe}")
+ endif()
+ if (MSVC_IDE)
+ file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileLogPath)
+ else()
+ file (RELATIVE_PATH _prefixFileLogPath "${CMAKE_BINARY_DIR}" "${_prefixFile}")
+ endif()
+ get_filename_component(_prefixFileExt "${_prefixFile}" EXT)
+ if (_prefixFileExt MATCHES "^\\.c")
+ set (_comment "Generating ${_language} prefix source ${_prefixFileLogPath}")
+ else()
+ set (_comment "Generating ${_language} prefix header ${_prefixFileLogPath}")
+ endif()
+ # prevent pre-processing errors upon generating the prefix header when a target's generated include file does not yet exist
+ # we do not add a file-level dependency for the target's generated files though, because we only want to depend on their existence
+ # thus we make the prefix header generation depend on a custom helper target which triggers the generation of the files
+ set (_preTargetName "${_target}${COTIRE_PCH_TARGET_SUFFIX}_pre")
+ if (TARGET ${_preTargetName})
+ # custom helper target has already been generated while processing a different language
+ list (APPEND _dependencySources ${_preTargetName})
+ else()
+ get_target_property(_targetSourceFiles ${_target} SOURCES)
+ cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${_targetSourceFiles})
+ if (_generatedSources)
+ add_custom_target("${_preTargetName}" DEPENDS ${_generatedSources})
+ cotire_init_target("${_preTargetName}")
+ list (APPEND _dependencySources ${_preTargetName})
+ endif()
+ endif()
+ add_custom_command(
+ OUTPUT "${_prefixFile}" "${_prefixFile}.log"
+ COMMAND ${_prefixCmd}
+ DEPENDS ${_unityFiles} ${_dependencySources} "${_realCompilerExe}"
+ COMMENT "${_comment}"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ VERBATIM)
+ list (APPEND ${_cmdsVar} COMMAND ${_prefixCmd})
+ set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE)
+endfunction()
+
+function (cotire_setup_prefix_generation_from_unity_command _language _target _targetScript _prefixFile _unityFiles _cmdsVar)
+ set (_sourceFiles ${ARGN})
+ if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang")
+ # GNU and Clang require indirect compilation of the prefix header to make them honor the system_header pragma
+ cotire_prefix_header_to_source_file_path(${_language} "${_prefixFile}" _prefixSourceFile)
+ else()
+ set (_prefixSourceFile "${_prefixFile}")
+ endif()
+ cotire_setup_prefix_generation_command(
+ ${_language} ${_target} "${_targetScript}"
+ "${_prefixSourceFile}" "${_unityFiles}" ${_cmdsVar} ${_sourceFiles})
+ if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang")
+ # set up generation of a prefix source file which includes the prefix header
+ cotire_setup_combine_command(${_language} "${_targetScript}" "${_prefixFile}" _cmds ${_prefixSourceFile})
+ endif()
+ set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE)
+endfunction()
+
+function (cotire_setup_prefix_generation_from_provided_command _language _target _targetScript _prefixFile _cmdsVar)
+ set (_prefixHeaderFiles ${ARGN})
+ if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang")
+ # GNU and Clang require indirect compilation of the prefix header to make them honor the system_header pragma
+ cotire_prefix_header_to_source_file_path(${_language} "${_prefixFile}" _prefixSourceFile)
+ else()
+ set (_prefixSourceFile "${_prefixFile}")
+ endif()
+ cotire_setup_combine_command(${_language} "${_targetScript}" "${_prefixSourceFile}" _cmds ${_prefixHeaderFiles})
+ if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang")
+ # set up generation of a prefix source file which includes the prefix header
+ cotire_setup_combine_command(${_language} "${_targetScript}" "${_prefixFile}" _cmds ${_prefixSourceFile})
+ endif()
+ set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE)
+endfunction()
+
+function (cotire_init_cotire_target_properties _target)
+ get_property(_isSet TARGET ${_target} PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER SET)
+ if (NOT _isSet)
+ set_property(TARGET ${_target} PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER TRUE)
+ endif()
+ get_property(_isSet TARGET ${_target} PROPERTY COTIRE_ADD_UNITY_BUILD SET)
+ if (NOT _isSet)
+ set_property(TARGET ${_target} PROPERTY COTIRE_ADD_UNITY_BUILD TRUE)
+ endif()
+ get_property(_isSet TARGET ${_target} PROPERTY COTIRE_ADD_CLEAN SET)
+ if (NOT _isSet)
+ set_property(TARGET ${_target} PROPERTY COTIRE_ADD_CLEAN FALSE)
+ endif()
+ get_property(_isSet TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH SET)
+ if (NOT _isSet)
+ set_property(TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH "${CMAKE_SOURCE_DIR}")
+ cotire_check_is_path_relative_to("${CMAKE_BINARY_DIR}" _isRelative "${CMAKE_SOURCE_DIR}")
+ if (NOT _isRelative)
+ set_property(TARGET ${_target} APPEND PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH "${CMAKE_BINARY_DIR}")
+ endif()
+ endif()
+ get_property(_isSet TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PATH SET)
+ if (NOT _isSet)
+ set_property(TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PATH "")
+ endif()
+ get_property(_isSet TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH SET)
+ if (NOT _isSet)
+ set_property(TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH "")
+ endif()
+ get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_PRE_UNDEFS SET)
+ if (NOT _isSet)
+ set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_PRE_UNDEFS "")
+ endif()
+ get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_POST_UNDEFS SET)
+ if (NOT _isSet)
+ set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_POST_UNDEFS "")
+ endif()
+ get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT SET)
+ if (NOT _isSet)
+ set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY")
+ endif()
+ get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES SET)
+ if (NOT _isSet)
+ if (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES)
+ set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES "${COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES}")
+ else()
+ set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES "")
+ endif()
+ endif()
+endfunction()
+
+function (cotire_make_target_message _target _languages _disableMsg _targetMsgVar)
+ get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER)
+ get_target_property(_targetAddSCU ${_target} COTIRE_ADD_UNITY_BUILD)
+ string (REPLACE ";" " " _languagesStr "${_languages}")
+ math (EXPR _numberOfExcludedFiles "${ARGC} - 4")
+ if (_numberOfExcludedFiles EQUAL 0)
+ set (_excludedStr "")
+ elseif (COTIRE_VERBOSE OR _numberOfExcludedFiles LESS 4)
+ string (REPLACE ";" ", " _excludedStr "excluding ${ARGN}")
+ else()
+ set (_excludedStr "excluding ${_numberOfExcludedFiles} files")
+ endif()
+ set (_targetMsg "")
+ if (NOT _languages)
+ set (_targetMsg "Target ${_target} cannot be cotired.")
+ if (_disableMsg)
+ set (_targetMsg "${_targetMsg} ${_disableMsg}")
+ endif()
+ elseif (NOT _targetUsePCH AND NOT _targetAddSCU)
+ set (_targetMsg "${_languagesStr} target ${_target} cotired without unity build and precompiled header.")
+ if (_disableMsg)
+ set (_targetMsg "${_targetMsg} ${_disableMsg}")
+ endif()
+ elseif (NOT _targetUsePCH)
+ if (_excludedStr)
+ set (_targetMsg "${_languagesStr} target ${_target} cotired without precompiled header ${_excludedStr}.")
+ else()
+ set (_targetMsg "${_languagesStr} target ${_target} cotired without precompiled header.")
+ endif()
+ if (_disableMsg)
+ set (_targetMsg "${_targetMsg} ${_disableMsg}")
+ endif()
+ elseif (NOT _targetAddSCU)
+ if (_excludedStr)
+ set (_targetMsg "${_languagesStr} target ${_target} cotired without unity build ${_excludedStr}.")
+ else()
+ set (_targetMsg "${_languagesStr} target ${_target} cotired without unity build.")
+ endif()
+ if (_disableMsg)
+ set (_targetMsg "${_targetMsg} ${_disableMsg}")
+ endif()
+ else()
+ if (_excludedStr)
+ set (_targetMsg "${_languagesStr} target ${_target} cotired ${_excludedStr}.")
+ else()
+ set (_targetMsg "${_languagesStr} target ${_target} cotired.")
+ endif()
+ endif()
+ set (${_targetMsgVar} "${_targetMsg}" PARENT_SCOPE)
+endfunction()
+
+function (cotire_choose_target_languages _target _targetLanguagesVar _wholeTargetVar)
+ set (_languages ${ARGN})
+ set (_allSourceFiles "")
+ set (_allExcludedSourceFiles "")
+ set (_allCotiredSourceFiles "")
+ set (_targetLanguages "")
+ set (_pchEligibleTargetLanguages "")
+ get_target_property(_targetType ${_target} TYPE)
+ get_target_property(_targetSourceFiles ${_target} SOURCES)
+ get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER)
+ get_target_property(_targetAddSCU ${_target} COTIRE_ADD_UNITY_BUILD)
+ set (_disableMsg "")
+ foreach (_language ${_languages})
+ get_target_property(_prefixHeader ${_target} COTIRE_${_language}_PREFIX_HEADER)
+ get_target_property(_unityBuildFile ${_target} COTIRE_${_language}_UNITY_SOURCE)
+ if (_prefixHeader OR _unityBuildFile)
+ message (STATUS "cotire: target ${_target} has already been cotired.")
+ set (${_targetLanguagesVar} "" PARENT_SCOPE)
+ return()
+ endif()
+ if (_targetUsePCH AND "${_language}" MATCHES "^C|CXX$" AND DEFINED CMAKE_${_language}_COMPILER_ID)
+ if (CMAKE_${_language}_COMPILER_ID)
+ cotire_check_precompiled_header_support("${_language}" "${_target}" _disableMsg)
+ if (_disableMsg)
+ set (_targetUsePCH FALSE)
+ endif()
+ endif()
+ endif()
+ set (_sourceFiles "")
+ set (_excludedSources "")
+ set (_cotiredSources "")
+ cotire_filter_language_source_files(${_language} ${_target} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles})
+ if (_sourceFiles OR _excludedSources OR _cotiredSources)
+ list (APPEND _targetLanguages ${_language})
+ endif()
+ if (_sourceFiles)
+ list (APPEND _allSourceFiles ${_sourceFiles})
+ endif()
+ list (LENGTH _sourceFiles _numberOfSources)
+ if (NOT _numberOfSources LESS ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES})
+ list (APPEND _pchEligibleTargetLanguages ${_language})
+ endif()
+ if (_excludedSources)
+ list (APPEND _allExcludedSourceFiles ${_excludedSources})
+ endif()
+ if (_cotiredSources)
+ list (APPEND _allCotiredSourceFiles ${_cotiredSources})
+ endif()
+ endforeach()
+ set (_targetMsgLevel STATUS)
+ if (NOT _targetLanguages)
+ string (REPLACE ";" " or " _languagesStr "${_languages}")
+ set (_disableMsg "No ${_languagesStr} source files.")
+ set (_targetUsePCH FALSE)
+ set (_targetAddSCU FALSE)
+ endif()
+ if (_targetUsePCH)
+ if (_allCotiredSourceFiles)
+ cotire_get_source_file_property_values(_cotireTargets COTIRE_TARGET ${_allCotiredSourceFiles})
+ list (REMOVE_DUPLICATES _cotireTargets)
+ string (REPLACE ";" ", " _cotireTargetsStr "${_cotireTargets}")
+ set (_disableMsg "Target sources already include a precompiled header for target(s) ${_cotireTargets}.")
+ set (_disableMsg "${_disableMsg} Set target property COTIRE_ENABLE_PRECOMPILED_HEADER to FALSE for targets ${_target},")
+ set (_disableMsg "${_disableMsg} ${_cotireTargetsStr} to get a workable build system.")
+ set (_targetMsgLevel SEND_ERROR)
+ set (_targetUsePCH FALSE)
+ elseif (NOT _pchEligibleTargetLanguages)
+ set (_disableMsg "Too few applicable sources.")
+ set (_targetUsePCH FALSE)
+ elseif (XCODE AND _allExcludedSourceFiles)
+ # for Xcode, we cannot apply the precompiled header to individual sources, only to the whole target
+ set (_disableMsg "Exclusion of source files not supported for generator Xcode.")
+ set (_targetUsePCH FALSE)
+ elseif (XCODE AND "${_targetType}" STREQUAL "OBJECT_LIBRARY")
+ # for Xcode, we cannot apply the required PRE_BUILD action to generate the prefix header to an OBJECT_LIBRARY target
+ set (_disableMsg "Required PRE_BUILD action not supported for OBJECT_LIBRARY targets for generator Xcode.")
+ set (_targetUsePCH FALSE)
+ endif()
+ endif()
+ if (_targetAddSCU)
+ # disable unity builds if automatic Qt processing is used
+ get_target_property(_targetAutoMoc ${_target} AUTOMOC)
+ get_target_property(_targetAutoUic ${_target} AUTOUIC)
+ get_target_property(_targetAutoRcc ${_target} AUTORCC)
+ if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc)
+ if (_disableMsg)
+ set (_disableMsg "${_disableMsg} Target uses automatic CMake Qt processing.")
+ else()
+ set (_disableMsg "Target uses automatic CMake Qt processing.")
+ endif()
+ set (_targetAddSCU FALSE)
+ endif()
+ endif()
+ set_property(TARGET ${_target} PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER ${_targetUsePCH})
+ set_property(TARGET ${_target} PROPERTY COTIRE_ADD_UNITY_BUILD ${_targetAddSCU})
+ cotire_make_target_message(${_target} "${_targetLanguages}" "${_disableMsg}" _targetMsg ${_allExcludedSourceFiles})
+ if (_targetMsg)
+ if (NOT DEFINED COTIREMSG_${_target})
+ set (COTIREMSG_${_target} "")
+ endif()
+ if (COTIRE_VERBOSE OR NOT "${_targetMsgLevel}" STREQUAL "STATUS" OR
+ NOT "${COTIREMSG_${_target}}" STREQUAL "${_targetMsg}")
+ # cache message to avoid redundant messages on re-configure
+ set (COTIREMSG_${_target} "${_targetMsg}" CACHE INTERNAL "${_target} cotire message.")
+ message (${_targetMsgLevel} "${_targetMsg}")
+ endif()
+ endif()
+ list (LENGTH _targetLanguages _numberOfLanguages)
+ if (_numberOfLanguages GREATER 1 OR _allExcludedSourceFiles)
+ set (${_wholeTargetVar} FALSE PARENT_SCOPE)
+ else()
+ set (${_wholeTargetVar} TRUE PARENT_SCOPE)
+ endif()
+ set (${_targetLanguagesVar} ${_targetLanguages} PARENT_SCOPE)
+endfunction()
+
+function (cotire_compute_unity_max_number_of_includes _target _maxIncludesVar)
+ set (_sourceFiles ${ARGN})
+ get_target_property(_maxIncludes ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES)
+ if (_maxIncludes MATCHES "(-j|--parallel|--jobs) ?([0-9]*)")
+ if (DEFINED CMAKE_MATCH_2)
+ set (_numberOfThreads "${CMAKE_MATCH_2}")
+ else()
+ set (_numberOfThreads "")
+ endif()
+ if (NOT _numberOfThreads)
+ # use all available cores
+ ProcessorCount(_numberOfThreads)
+ endif()
+ list (LENGTH _sourceFiles _numberOfSources)
+ math (EXPR _maxIncludes "(${_numberOfSources} + ${_numberOfThreads} - 1) / ${_numberOfThreads}")
+ elseif (NOT _maxIncludes MATCHES "[0-9]+")
+ set (_maxIncludes 0)
+ endif()
+ if (COTIRE_DEBUG)
+ message (STATUS "${_target} unity source max includes: ${_maxIncludes}")
+ endif()
+ set (${_maxIncludesVar} ${_maxIncludes} PARENT_SCOPE)
+endfunction()
+
+function (cotire_process_target_language _language _configurations _target _wholeTarget _cmdsVar)
+ set (${_cmdsVar} "" PARENT_SCOPE)
+ get_target_property(_targetSourceFiles ${_target} SOURCES)
+ set (_sourceFiles "")
+ set (_excludedSources "")
+ set (_cotiredSources "")
+ cotire_filter_language_source_files(${_language} ${_target} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles})
+ if (NOT _sourceFiles AND NOT _cotiredSources)
+ return()
+ endif()
+ set (_cmds "")
+ # check for user provided unity source file list
+ get_property(_unitySourceFiles TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE_INIT)
+ if (NOT _unitySourceFiles)
+ set (_unitySourceFiles ${_sourceFiles} ${_cotiredSources})
+ endif()
+ cotire_generate_target_script(
+ ${_language} "${_configurations}" ${_target} _targetScript _targetConfigScript ${_unitySourceFiles})
+ # set up unity files for parallel compilation
+ cotire_compute_unity_max_number_of_includes(${_target} _maxIncludes ${_unitySourceFiles})
+ cotire_make_unity_source_file_paths(${_language} ${_target} ${_maxIncludes} _unityFiles ${_unitySourceFiles})
+ list (LENGTH _unityFiles _numberOfUnityFiles)
+ if (_numberOfUnityFiles EQUAL 0)
+ return()
+ elseif (_numberOfUnityFiles GREATER 1)
+ cotire_setup_unity_generation_commands(
+ ${_language} ${_target} "${_targetScript}" "${_targetConfigScript}" "${_unityFiles}" _cmds ${_unitySourceFiles})
+ endif()
+ # set up single unity file for prefix header generation
+ cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFile)
+ cotire_setup_unity_generation_commands(
+ ${_language} ${_target} "${_targetScript}" "${_targetConfigScript}" "${_unityFile}" _cmds ${_unitySourceFiles})
+ cotire_make_prefix_file_path(${_language} ${_target} _prefixFile)
+ # set up prefix header
+ if (_prefixFile)
+ # check for user provided prefix header files
+ get_property(_prefixHeaderFiles TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER_INIT)
+ if (_prefixHeaderFiles)
+ cotire_setup_prefix_generation_from_provided_command(
+ ${_language} ${_target} "${_targetConfigScript}" "${_prefixFile}" _cmds ${_prefixHeaderFiles})
+ else()
+ cotire_setup_prefix_generation_from_unity_command(
+ ${_language} ${_target} "${_targetConfigScript}" "${_prefixFile}" "${_unityFile}" _cmds ${_unitySourceFiles})
+ endif()
+ # check if selected language has enough sources at all
+ list (LENGTH _sourceFiles _numberOfSources)
+ if (_numberOfSources LESS ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES})
+ set (_targetUsePCH FALSE)
+ else()
+ get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER)
+ endif()
+ if (_targetUsePCH)
+ cotire_make_pch_file_path(${_language} ${_target} _pchFile)
+ if (_pchFile)
+ # first file in _sourceFiles is passed as the host file
+ cotire_setup_pch_file_compilation(
+ ${_language} ${_target} "${_targetConfigScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles})
+ cotire_setup_pch_file_inclusion(
+ ${_language} ${_target} ${_wholeTarget} "${_prefixFile}" "${_pchFile}" ${_sourceFiles})
+ endif()
+ elseif (_prefixHeaderFiles)
+ # user provided prefix header must be included unconditionally
+ cotire_setup_prefix_file_inclusion(${_language} ${_target} "${_prefixFile}" ${_sourceFiles})
+ endif()
+ endif()
+ # mark target as cotired for language
+ set_property(TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE "${_unityFiles}")
+ if (_prefixFile)
+ set_property(TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER "${_prefixFile}")
+ if (_targetUsePCH AND _pchFile)
+ set_property(TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER "${_pchFile}")
+ endif()
+ endif()
+ set (${_cmdsVar} ${_cmds} PARENT_SCOPE)
+endfunction()
+
+function (cotire_setup_clean_target _target)
+ set (_cleanTargetName "${_target}${COTIRE_CLEAN_TARGET_SUFFIX}")
+ if (NOT TARGET "${_cleanTargetName}")
+ cotire_set_cmd_to_prologue(_cmds)
+ get_filename_component(_outputDir "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" ABSOLUTE)
+ list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "cleanup" "${_outputDir}" "${COTIRE_INTDIR}" "${_target}")
+ add_custom_target(${_cleanTargetName}
+ COMMAND ${_cmds}
+ WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
+ COMMENT "Cleaning up target ${_target} cotire generated files"
+ VERBATIM)
+ cotire_init_target("${_cleanTargetName}")
+ endif()
+endfunction()
+
+function (cotire_setup_pch_target _languages _configurations _target)
+ if ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
+ # for makefile based generators, we add a custom target to trigger the generation of the cotire related files
+ set (_dependsFiles "")
+ foreach (_language ${_languages})
+ set (_props COTIRE_${_language}_PREFIX_HEADER COTIRE_${_language}_UNITY_SOURCE)
+ if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel" AND NOT
+ (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "Clang"))
+ # MSVC, Intel and clang-cl only create precompiled header as a side effect
+ list (INSERT _props 0 COTIRE_${_language}_PRECOMPILED_HEADER)
+ endif()
+ cotire_get_first_set_property_value(_dependsFile TARGET ${_target} ${_props})
+ if (_dependsFile)
+ list (APPEND _dependsFiles "${_dependsFile}")
+ endif()
+ endforeach()
+ if (_dependsFiles)
+ set (_pchTargetName "${_target}${COTIRE_PCH_TARGET_SUFFIX}")
+ add_custom_target("${_pchTargetName}" DEPENDS ${_dependsFiles})
+ cotire_init_target("${_pchTargetName}")
+ cotire_add_to_pch_all_target(${_pchTargetName})
+ endif()
+ else()
+ # for other generators, we add the "clean all" target to clean up the precompiled header
+ cotire_setup_clean_all_target()
+ endif()
+endfunction()
+
+function (cotire_filter_object_libraries _target _objectLibrariesVar)
+ set (_objectLibraries "")
+ foreach (_source ${ARGN})
+ if (_source MATCHES "^\\$<TARGET_OBJECTS:.+>$")
+ list (APPEND _objectLibraries "${_source}")
+ endif()
+ endforeach()
+ set (${_objectLibrariesVar} ${_objectLibraries} PARENT_SCOPE)
+endfunction()
+
+function (cotire_collect_unity_target_sources _target _languages _unityTargetSourcesVar)
+ get_target_property(_targetSourceFiles ${_target} SOURCES)
+ set (_unityTargetSources ${_targetSourceFiles})
+ foreach (_language ${_languages})
+ get_property(_unityFiles TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE)
+ if (_unityFiles)
+ # remove source files that are included in the unity source
+ set (_sourceFiles "")
+ set (_excludedSources "")
+ set (_cotiredSources "")
+ cotire_filter_language_source_files(${_language} ${_target} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles})
+ if (_sourceFiles OR _cotiredSources)
+ list (REMOVE_ITEM _unityTargetSources ${_sourceFiles} ${_cotiredSources})
+ endif()
+ # add unity source files instead
+ list (APPEND _unityTargetSources ${_unityFiles})
+ endif()
+ endforeach()
+ # handle object libraries which are part of the target's sources
+ get_target_property(_linkLibrariesStrategy ${_target} COTIRE_UNITY_LINK_LIBRARIES_INIT)
+ if ("${_linkLibrariesStrategy}" MATCHES "^COPY_UNITY$")
+ cotire_filter_object_libraries(${_target} _objectLibraries ${_targetSourceFiles})
+ if (_objectLibraries)
+ cotire_map_libraries("${_linkLibrariesStrategy}" _unityObjectLibraries ${_objectLibraries})
+ list (REMOVE_ITEM _unityTargetSources ${_objectLibraries})
+ list (APPEND _unityTargetSources ${_unityObjectLibraries})
+ endif()
+ endif()
+ set (${_unityTargetSourcesVar} ${_unityTargetSources} PARENT_SCOPE)
+endfunction()
+
+function (cotire_setup_unity_target_pch_usage _languages _target)
+ foreach (_language ${_languages})
+ get_property(_unityFiles TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE)
+ if (_unityFiles)
+ get_property(_userPrefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER_INIT)
+ get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER)
+ if (_userPrefixFile AND _prefixFile)
+ # user provided prefix header must be included unconditionally by unity sources
+ cotire_setup_prefix_file_inclusion(${_language} ${_target} "${_prefixFile}" ${_unityFiles})
+ endif()
+ endif()
+ endforeach()
+endfunction()
+
+function (cotire_setup_unity_build_target _languages _configurations _target)
+ get_target_property(_unityTargetName ${_target} COTIRE_UNITY_TARGET_NAME)
+ if (NOT _unityTargetName)
+ set (_unityTargetName "${_target}${COTIRE_UNITY_BUILD_TARGET_SUFFIX}")
+ endif()
+ # determine unity target sub type
+ get_target_property(_targetType ${_target} TYPE)
+ if ("${_targetType}" STREQUAL "EXECUTABLE")
+ set (_unityTargetSubType "")
+ elseif (_targetType MATCHES "(STATIC|SHARED|MODULE|OBJECT)_LIBRARY")
+ set (_unityTargetSubType "${CMAKE_MATCH_1}")
+ else()
+ message (WARNING "cotire: target ${_target} has unknown target type ${_targetType}.")
+ return()
+ endif()
+ # determine unity target sources
+ set (_unityTargetSources "")
+ cotire_collect_unity_target_sources(${_target} "${_languages}" _unityTargetSources)
+ # prevent AUTOMOC, AUTOUIC and AUTORCC properties from being set when the unity target is created
+ set (CMAKE_AUTOMOC OFF)
+ set (CMAKE_AUTOUIC OFF)
+ set (CMAKE_AUTORCC OFF)
+ if (COTIRE_DEBUG)
+ message (STATUS "add target ${_targetType} ${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}")
+ endif()
+ # generate unity target
+ if ("${_targetType}" STREQUAL "EXECUTABLE")
+ add_executable(${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources})
+ else()
+ add_library(${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources})
+ endif()
+ # copy output location properties
+ set (_outputDirProperties
+ ARCHIVE_OUTPUT_DIRECTORY ARCHIVE_OUTPUT_DIRECTORY_<CONFIG>
+ LIBRARY_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY_<CONFIG>
+ RUNTIME_OUTPUT_DIRECTORY RUNTIME_OUTPUT_DIRECTORY_<CONFIG>)
+ if (COTIRE_UNITY_OUTPUT_DIRECTORY)
+ set (_setDefaultOutputDir TRUE)
+ if (IS_ABSOLUTE "${COTIRE_UNITY_OUTPUT_DIRECTORY}")
+ set (_outputDir "${COTIRE_UNITY_OUTPUT_DIRECTORY}")
+ else()
+ # append relative COTIRE_UNITY_OUTPUT_DIRECTORY to target's actual output directory
+ cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties})
+ cotire_resolve_config_properties("${_configurations}" _properties ${_outputDirProperties})
+ foreach (_property ${_properties})
+ get_property(_outputDir TARGET ${_target} PROPERTY ${_property})
+ if (_outputDir)
+ get_filename_component(_outputDir "${_outputDir}/${COTIRE_UNITY_OUTPUT_DIRECTORY}" ABSOLUTE)
+ set_property(TARGET ${_unityTargetName} PROPERTY ${_property} "${_outputDir}")
+ set (_setDefaultOutputDir FALSE)
+ endif()
+ endforeach()
+ if (_setDefaultOutputDir)
+ get_filename_component(_outputDir "${CMAKE_CURRENT_BINARY_DIR}/${COTIRE_UNITY_OUTPUT_DIRECTORY}" ABSOLUTE)
+ endif()
+ endif()
+ if (_setDefaultOutputDir)
+ set_target_properties(${_unityTargetName} PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY "${_outputDir}"
+ LIBRARY_OUTPUT_DIRECTORY "${_outputDir}"
+ RUNTIME_OUTPUT_DIRECTORY "${_outputDir}")
+ endif()
+ else()
+ cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName}
+ ${_outputDirProperties})
+ endif()
+ # copy output name
+ cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName}
+ ARCHIVE_OUTPUT_NAME ARCHIVE_OUTPUT_NAME_<CONFIG>
+ LIBRARY_OUTPUT_NAME LIBRARY_OUTPUT_NAME_<CONFIG>
+ OUTPUT_NAME OUTPUT_NAME_<CONFIG>
+ RUNTIME_OUTPUT_NAME RUNTIME_OUTPUT_NAME_<CONFIG>
+ PREFIX <CONFIG>_POSTFIX SUFFIX
+ IMPORT_PREFIX IMPORT_SUFFIX)
+ # copy compile stuff
+ cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName}
+ COMPILE_DEFINITIONS COMPILE_DEFINITIONS_<CONFIG>
+ COMPILE_FLAGS COMPILE_OPTIONS
+ Fortran_FORMAT Fortran_MODULE_DIRECTORY
+ INCLUDE_DIRECTORIES
+ INTERPROCEDURAL_OPTIMIZATION INTERPROCEDURAL_OPTIMIZATION_<CONFIG>
+ POSITION_INDEPENDENT_CODE
+ C_COMPILER_LAUNCHER CXX_COMPILER_LAUNCHER
+ C_INCLUDE_WHAT_YOU_USE CXX_INCLUDE_WHAT_YOU_USE
+ C_VISIBILITY_PRESET CXX_VISIBILITY_PRESET VISIBILITY_INLINES_HIDDEN
+ C_CLANG_TIDY CXX_CLANG_TIDY)
+ # copy compile features
+ cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName}
+ C_EXTENSIONS C_STANDARD C_STANDARD_REQUIRED
+ CXX_EXTENSIONS CXX_STANDARD CXX_STANDARD_REQUIRED
+ COMPILE_FEATURES)
+ # copy interface stuff
+ cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName}
+ COMPATIBLE_INTERFACE_BOOL COMPATIBLE_INTERFACE_NUMBER_MAX COMPATIBLE_INTERFACE_NUMBER_MIN
+ COMPATIBLE_INTERFACE_STRING
+ INTERFACE_COMPILE_DEFINITIONS INTERFACE_COMPILE_FEATURES INTERFACE_COMPILE_OPTIONS
+ INTERFACE_INCLUDE_DIRECTORIES INTERFACE_SOURCES
+ INTERFACE_POSITION_INDEPENDENT_CODE INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
+ INTERFACE_AUTOUIC_OPTIONS NO_SYSTEM_FROM_IMPORTED)
+ # copy link stuff
+ cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName}
+ BUILD_WITH_INSTALL_RPATH BUILD_WITH_INSTALL_NAME_DIR
+ INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH SKIP_BUILD_RPATH
+ LINKER_LANGUAGE LINK_DEPENDS LINK_DEPENDS_NO_SHARED
+ LINK_FLAGS LINK_FLAGS_<CONFIG>
+ LINK_INTERFACE_LIBRARIES LINK_INTERFACE_LIBRARIES_<CONFIG>
+ LINK_INTERFACE_MULTIPLICITY LINK_INTERFACE_MULTIPLICITY_<CONFIG>
+ LINK_SEARCH_START_STATIC LINK_SEARCH_END_STATIC
+ STATIC_LIBRARY_FLAGS STATIC_LIBRARY_FLAGS_<CONFIG>
+ NO_SONAME SOVERSION VERSION
+ LINK_WHAT_YOU_USE BUILD_RPATH)
+ # copy cmake stuff
+ cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName}
+ IMPLICIT_DEPENDS_INCLUDE_TRANSFORM RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK)
+ # copy Apple platform specific stuff
+ cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName}
+ BUNDLE BUNDLE_EXTENSION FRAMEWORK FRAMEWORK_VERSION INSTALL_NAME_DIR
+ MACOSX_BUNDLE MACOSX_BUNDLE_INFO_PLIST MACOSX_FRAMEWORK_INFO_PLIST MACOSX_RPATH
+ OSX_ARCHITECTURES OSX_ARCHITECTURES_<CONFIG> PRIVATE_HEADER PUBLIC_HEADER RESOURCE XCTEST
+ IOS_INSTALL_COMBINED XCODE_EXPLICIT_FILE_TYPE XCODE_PRODUCT_TYPE)
+ # copy Windows platform specific stuff
+ cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName}
+ GNUtoMS
+ COMPILE_PDB_NAME COMPILE_PDB_NAME_<CONFIG>
+ COMPILE_PDB_OUTPUT_DIRECTORY COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>
+ PDB_NAME PDB_NAME_<CONFIG> PDB_OUTPUT_DIRECTORY PDB_OUTPUT_DIRECTORY_<CONFIG>
+ VS_DESKTOP_EXTENSIONS_VERSION VS_DOTNET_REFERENCES VS_DOTNET_TARGET_FRAMEWORK_VERSION
+ VS_GLOBAL_KEYWORD VS_GLOBAL_PROJECT_TYPES VS_GLOBAL_ROOTNAMESPACE
+ VS_IOT_EXTENSIONS_VERSION VS_IOT_STARTUP_TASK
+ VS_KEYWORD VS_MOBILE_EXTENSIONS_VERSION
+ VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER
+ VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION
+ VS_WINRT_COMPONENT VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES
+ WIN32_EXECUTABLE WINDOWS_EXPORT_ALL_SYMBOLS
+ DEPLOYMENT_REMOTE_DIRECTORY VS_CONFIGURATION_TYPE
+ VS_SDK_REFERENCES VS_USER_PROPS VS_DEBUGGER_WORKING_DIRECTORY)
+ # copy Android platform specific stuff
+ cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName}
+ ANDROID_API ANDROID_API_MIN ANDROID_GUI
+ ANDROID_ANT_ADDITIONAL_OPTIONS ANDROID_ARCH ANDROID_ASSETS_DIRECTORIES
+ ANDROID_JAR_DEPENDENCIES ANDROID_JAR_DIRECTORIES ANDROID_JAVA_SOURCE_DIR
+ ANDROID_NATIVE_LIB_DEPENDENCIES ANDROID_NATIVE_LIB_DIRECTORIES
+ ANDROID_PROCESS_MAX ANDROID_PROGUARD ANDROID_PROGUARD_CONFIG_PATH
+ ANDROID_SECURE_PROPS_PATH ANDROID_SKIP_ANT_STEP ANDROID_STL_TYPE)
+ # copy CUDA platform specific stuff
+ cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName}
+ CUDA_PTX_COMPILATION CUDA_SEPARABLE_COMPILATION CUDA_RESOLVE_DEVICE_SYMBOLS
+ CUDA_EXTENSIONS CUDA_STANDARD CUDA_STANDARD_REQUIRED)
+ # use output name from original target
+ get_target_property(_targetOutputName ${_unityTargetName} OUTPUT_NAME)
+ if (NOT _targetOutputName)
+ set_property(TARGET ${_unityTargetName} PROPERTY OUTPUT_NAME "${_target}")
+ endif()
+ # use export symbol from original target
+ cotire_get_target_export_symbol("${_target}" _defineSymbol)
+ if (_defineSymbol)
+ set_property(TARGET ${_unityTargetName} PROPERTY DEFINE_SYMBOL "${_defineSymbol}")
+ if ("${_targetType}" STREQUAL "EXECUTABLE")
+ set_property(TARGET ${_unityTargetName} PROPERTY ENABLE_EXPORTS TRUE)
+ endif()
+ endif()
+ # enable parallel compilation for MSVC
+ if (MSVC AND "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
+ list (LENGTH _unityTargetSources _numberOfUnityTargetSources)
+ if (_numberOfUnityTargetSources GREATER 1)
+ set_property(TARGET ${_unityTargetName} APPEND PROPERTY COMPILE_OPTIONS "/MP")
+ endif()
+ endif()
+ cotire_init_target(${_unityTargetName})
+ cotire_add_to_unity_all_target(${_unityTargetName})
+ set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_TARGET_NAME "${_unityTargetName}")
+endfunction(cotire_setup_unity_build_target)
+
+function (cotire_target _target)
+ set(_options "")
+ set(_oneValueArgs "")
+ set(_multiValueArgs LANGUAGES CONFIGURATIONS)
+ cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
+ if (NOT _option_LANGUAGES)
+ get_property (_option_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
+ endif()
+ if (NOT _option_CONFIGURATIONS)
+ cotire_get_configuration_types(_option_CONFIGURATIONS)
+ endif()
+ # check if cotire can be applied to target at all
+ cotire_is_target_supported(${_target} _isSupported)
+ if (NOT _isSupported)
+ get_target_property(_imported ${_target} IMPORTED)
+ get_target_property(_targetType ${_target} TYPE)
+ if (_imported)
+ message (WARNING "cotire: imported ${_targetType} target ${_target} cannot be cotired.")
+ else()
+ message (STATUS "cotire: ${_targetType} target ${_target} cannot be cotired.")
+ endif()
+ return()
+ endif()
+ # resolve alias
+ get_target_property(_aliasName ${_target} ALIASED_TARGET)
+ if (_aliasName)
+ if (COTIRE_DEBUG)
+ message (STATUS "${_target} is an alias. Applying cotire to aliased target ${_aliasName} instead.")
+ endif()
+ set (_target ${_aliasName})
+ endif()
+ # check if target needs to be cotired for build type
+ # when using configuration types, the test is performed at build time
+ cotire_init_cotire_target_properties(${_target})
+ if (NOT CMAKE_CONFIGURATION_TYPES)
+ if (CMAKE_BUILD_TYPE)
+ list (FIND _option_CONFIGURATIONS "${CMAKE_BUILD_TYPE}" _index)
+ else()
+ list (FIND _option_CONFIGURATIONS "None" _index)
+ endif()
+ if (_index EQUAL -1)
+ if (COTIRE_DEBUG)
+ message (STATUS "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} not cotired (${_option_CONFIGURATIONS})")
+ endif()
+ return()
+ endif()
+ endif()
+ # when not using configuration types, immediately create cotire intermediate dir
+ if (NOT CMAKE_CONFIGURATION_TYPES)
+ cotire_get_intermediate_dir(_baseDir)
+ file (MAKE_DIRECTORY "${_baseDir}")
+ endif()
+ # choose languages that apply to the target
+ cotire_choose_target_languages("${_target}" _targetLanguages _wholeTarget ${_option_LANGUAGES})
+ if (NOT _targetLanguages)
+ return()
+ endif()
+ set (_cmds "")
+ foreach (_language ${_targetLanguages})
+ cotire_process_target_language("${_language}" "${_option_CONFIGURATIONS}" ${_target} ${_wholeTarget} _cmd)
+ if (_cmd)
+ list (APPEND _cmds ${_cmd})
+ endif()
+ endforeach()
+ get_target_property(_targetAddSCU ${_target} COTIRE_ADD_UNITY_BUILD)
+ if (_targetAddSCU)
+ cotire_setup_unity_build_target("${_targetLanguages}" "${_option_CONFIGURATIONS}" ${_target})
+ endif()
+ get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER)
+ if (_targetUsePCH)
+ cotire_setup_target_pch_usage("${_targetLanguages}" ${_target} ${_wholeTarget} ${_cmds})
+ cotire_setup_pch_target("${_targetLanguages}" "${_option_CONFIGURATIONS}" ${_target})
+ if (_targetAddSCU)
+ cotire_setup_unity_target_pch_usage("${_targetLanguages}" ${_target})
+ endif()
+ endif()
+ get_target_property(_targetAddCleanTarget ${_target} COTIRE_ADD_CLEAN)
+ if (_targetAddCleanTarget)
+ cotire_setup_clean_target(${_target})
+ endif()
+endfunction(cotire_target)
+
+function (cotire_map_libraries _strategy _mappedLibrariesVar)
+ set (_mappedLibraries "")
+ foreach (_library ${ARGN})
+ if (_library MATCHES "^\\$<LINK_ONLY:(.+)>$")
+ set (_libraryName "${CMAKE_MATCH_1}")
+ set (_linkOnly TRUE)
+ set (_objectLibrary FALSE)
+ elseif (_library MATCHES "^\\$<TARGET_OBJECTS:(.+)>$")
+ set (_libraryName "${CMAKE_MATCH_1}")
+ set (_linkOnly FALSE)
+ set (_objectLibrary TRUE)
+ else()
+ set (_libraryName "${_library}")
+ set (_linkOnly FALSE)
+ set (_objectLibrary FALSE)
+ endif()
+ if ("${_strategy}" MATCHES "COPY_UNITY")
+ cotire_is_target_supported(${_libraryName} _isSupported)
+ if (_isSupported)
+ # use target's corresponding unity target, if available
+ get_target_property(_libraryUnityTargetName ${_libraryName} COTIRE_UNITY_TARGET_NAME)
+ if (TARGET "${_libraryUnityTargetName}")
+ if (_linkOnly)
+ list (APPEND _mappedLibraries "$<LINK_ONLY:${_libraryUnityTargetName}>")
+ elseif (_objectLibrary)
+ list (APPEND _mappedLibraries "$<TARGET_OBJECTS:${_libraryUnityTargetName}>")
+ else()
+ list (APPEND _mappedLibraries "${_libraryUnityTargetName}")
+ endif()
+ else()
+ list (APPEND _mappedLibraries "${_library}")
+ endif()
+ else()
+ list (APPEND _mappedLibraries "${_library}")
+ endif()
+ else()
+ list (APPEND _mappedLibraries "${_library}")
+ endif()
+ endforeach()
+ list (REMOVE_DUPLICATES _mappedLibraries)
+ set (${_mappedLibrariesVar} ${_mappedLibraries} PARENT_SCOPE)
+endfunction()
+
+function (cotire_target_link_libraries _target)
+ cotire_is_target_supported(${_target} _isSupported)
+ if (NOT _isSupported)
+ return()
+ endif()
+ get_target_property(_unityTargetName ${_target} COTIRE_UNITY_TARGET_NAME)
+ if (TARGET "${_unityTargetName}")
+ get_target_property(_linkLibrariesStrategy ${_target} COTIRE_UNITY_LINK_LIBRARIES_INIT)
+ if (COTIRE_DEBUG)
+ message (STATUS "unity target ${_unityTargetName} link strategy: ${_linkLibrariesStrategy}")
+ endif()
+ if ("${_linkLibrariesStrategy}" MATCHES "^(COPY|COPY_UNITY)$")
+ get_target_property(_linkLibraries ${_target} LINK_LIBRARIES)
+ if (_linkLibraries)
+ cotire_map_libraries("${_linkLibrariesStrategy}" _unityLinkLibraries ${_linkLibraries})
+ set_target_properties(${_unityTargetName} PROPERTIES LINK_LIBRARIES "${_unityLinkLibraries}")
+ if (COTIRE_DEBUG)
+ message (STATUS "unity target ${_unityTargetName} link libraries: ${_unityLinkLibraries}")
+ endif()
+ endif()
+ get_target_property(_interfaceLinkLibraries ${_target} INTERFACE_LINK_LIBRARIES)
+ if (_interfaceLinkLibraries)
+ cotire_map_libraries("${_linkLibrariesStrategy}" _unityLinkInterfaceLibraries ${_interfaceLinkLibraries})
+ set_target_properties(${_unityTargetName} PROPERTIES INTERFACE_LINK_LIBRARIES "${_unityLinkInterfaceLibraries}")
+ if (COTIRE_DEBUG)
+ message (STATUS "unity target ${_unityTargetName} interface link libraries: ${_unityLinkInterfaceLibraries}")
+ endif()
+ endif()
+ get_target_property(_manualDependencies ${_target} MANUALLY_ADDED_DEPENDENCIES)
+ if (_manualDependencies)
+ cotire_map_libraries("${_linkLibrariesStrategy}" _unityManualDependencies ${_manualDependencies})
+ if (_unityManualDependencies)
+ add_dependencies("${_unityTargetName}" ${_unityManualDependencies})
+ endif()
+ endif()
+ endif()
+ endif()
+endfunction(cotire_target_link_libraries)
+
+function (cotire_cleanup _binaryDir _cotireIntermediateDirName _targetName)
+ if (_targetName)
+ file (GLOB_RECURSE _cotireFiles "${_binaryDir}/${_targetName}*.*")
+ else()
+ file (GLOB_RECURSE _cotireFiles "${_binaryDir}/*.*")
+ endif()
+ # filter files in intermediate directory
+ set (_filesToRemove "")
+ foreach (_file ${_cotireFiles})
+ get_filename_component(_dir "${_file}" DIRECTORY)
+ get_filename_component(_dirName "${_dir}" NAME)
+ if ("${_dirName}" STREQUAL "${_cotireIntermediateDirName}")
+ list (APPEND _filesToRemove "${_file}")
+ endif()
+ endforeach()
+ if (_filesToRemove)
+ if (COTIRE_VERBOSE)
+ message (STATUS "cleaning up ${_filesToRemove}")
+ endif()
+ file (REMOVE ${_filesToRemove})
+ endif()
+endfunction()
+
+function (cotire_init_target _targetName)
+ if (COTIRE_TARGETS_FOLDER)
+ set_target_properties(${_targetName} PROPERTIES FOLDER "${COTIRE_TARGETS_FOLDER}")
+ endif()
+ set_target_properties(${_targetName} PROPERTIES EXCLUDE_FROM_ALL TRUE)
+ if (MSVC_IDE)
+ set_target_properties(${_targetName} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE)
+ endif()
+endfunction()
+
+function (cotire_add_to_pch_all_target _pchTargetName)
+ set (_targetName "${COTIRE_PCH_ALL_TARGET_NAME}")
+ if (NOT TARGET "${_targetName}")
+ add_custom_target("${_targetName}"
+ WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
+ VERBATIM)
+ cotire_init_target("${_targetName}")
+ endif()
+ cotire_setup_clean_all_target()
+ add_dependencies(${_targetName} ${_pchTargetName})
+endfunction()
+
+function (cotire_add_to_unity_all_target _unityTargetName)
+ set (_targetName "${COTIRE_UNITY_BUILD_ALL_TARGET_NAME}")
+ if (NOT TARGET "${_targetName}")
+ add_custom_target("${_targetName}"
+ WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
+ VERBATIM)
+ cotire_init_target("${_targetName}")
+ endif()
+ cotire_setup_clean_all_target()
+ add_dependencies(${_targetName} ${_unityTargetName})
+endfunction()
+
+function (cotire_setup_clean_all_target)
+ set (_targetName "${COTIRE_CLEAN_ALL_TARGET_NAME}")
+ if (NOT TARGET "${_targetName}")
+ cotire_set_cmd_to_prologue(_cmds)
+ list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "cleanup" "${CMAKE_BINARY_DIR}" "${COTIRE_INTDIR}")
+ add_custom_target(${_targetName}
+ COMMAND ${_cmds}
+ WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
+ COMMENT "Cleaning up all cotire generated files"
+ VERBATIM)
+ cotire_init_target("${_targetName}")
+ endif()
+endfunction()
+
+function (cotire)
+ set(_options "")
+ set(_oneValueArgs "")
+ set(_multiValueArgs LANGUAGES CONFIGURATIONS)
+ cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
+ set (_targets ${_option_UNPARSED_ARGUMENTS})
+ foreach (_target ${_targets})
+ if (TARGET ${_target})
+ cotire_target(${_target} LANGUAGES ${_option_LANGUAGES} CONFIGURATIONS ${_option_CONFIGURATIONS})
+ else()
+ message (WARNING "cotire: ${_target} is not a target.")
+ endif()
+ endforeach()
+ foreach (_target ${_targets})
+ if (TARGET ${_target})
+ cotire_target_link_libraries(${_target})
+ endif()
+ endforeach()
+endfunction()
+
+if (CMAKE_SCRIPT_MODE_FILE)
+
+ # cotire is being run in script mode
+ # locate -P on command args
+ set (COTIRE_ARGC -1)
+ foreach (_index RANGE ${CMAKE_ARGC})
+ if (COTIRE_ARGC GREATER -1)
+ set (COTIRE_ARGV${COTIRE_ARGC} "${CMAKE_ARGV${_index}}")
+ math (EXPR COTIRE_ARGC "${COTIRE_ARGC} + 1")
+ elseif ("${CMAKE_ARGV${_index}}" STREQUAL "-P")
+ set (COTIRE_ARGC 0)
+ endif()
+ endforeach()
+
+ # include target script if available
+ if ("${COTIRE_ARGV2}" MATCHES "\\.cmake$")
+ # the included target scripts sets up additional variables relating to the target (e.g., COTIRE_TARGET_SOURCES)
+ include("${COTIRE_ARGV2}")
+ endif()
+
+ if (COTIRE_DEBUG)
+ message (STATUS "${COTIRE_ARGV0} ${COTIRE_ARGV1} ${COTIRE_ARGV2} ${COTIRE_ARGV3} ${COTIRE_ARGV4} ${COTIRE_ARGV5}")
+ endif()
+
+ if (NOT COTIRE_BUILD_TYPE)
+ set (COTIRE_BUILD_TYPE "None")
+ endif()
+ string (TOUPPER "${COTIRE_BUILD_TYPE}" _upperConfig)
+ set (_includeDirs ${COTIRE_TARGET_INCLUDE_DIRECTORIES_${_upperConfig}})
+ set (_systemIncludeDirs ${COTIRE_TARGET_SYSTEM_INCLUDE_DIRECTORIES_${_upperConfig}})
+ set (_compileDefinitions ${COTIRE_TARGET_COMPILE_DEFINITIONS_${_upperConfig}})
+ set (_compileFlags ${COTIRE_TARGET_COMPILE_FLAGS_${_upperConfig}})
+ # check if target has been cotired for actual build type COTIRE_BUILD_TYPE
+ list (FIND COTIRE_TARGET_CONFIGURATION_TYPES "${COTIRE_BUILD_TYPE}" _index)
+ if (_index GREATER -1)
+ set (_sources ${COTIRE_TARGET_SOURCES})
+ set (_sourcesDefinitions ${COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${_upperConfig}})
+ else()
+ if (COTIRE_DEBUG)
+ message (STATUS "COTIRE_BUILD_TYPE=${COTIRE_BUILD_TYPE} not cotired (${COTIRE_TARGET_CONFIGURATION_TYPES})")
+ endif()
+ set (_sources "")
+ set (_sourcesDefinitions "")
+ endif()
+ set (_targetPreUndefs ${COTIRE_TARGET_PRE_UNDEFS})
+ set (_targetPostUndefs ${COTIRE_TARGET_POST_UNDEFS})
+ set (_sourcesPreUndefs ${COTIRE_TARGET_SOURCES_PRE_UNDEFS})
+ set (_sourcesPostUndefs ${COTIRE_TARGET_SOURCES_POST_UNDEFS})
+
+ if ("${COTIRE_ARGV1}" STREQUAL "unity")
+
+ if (XCODE)
+ # executing pre-build action under Xcode, check dependency on target script
+ set (_dependsOption DEPENDS "${COTIRE_ARGV2}")
+ else()
+ # executing custom command, no need to re-check for dependencies
+ set (_dependsOption "")
+ endif()
+
+ cotire_select_unity_source_files("${COTIRE_ARGV3}" _sources ${_sources})
+
+ cotire_generate_unity_source(
+ "${COTIRE_ARGV3}" ${_sources}
+ LANGUAGE "${COTIRE_TARGET_LANGUAGE}"
+ SOURCES_COMPILE_DEFINITIONS ${_sourcesDefinitions}
+ PRE_UNDEFS ${_targetPreUndefs}
+ POST_UNDEFS ${_targetPostUndefs}
+ SOURCES_PRE_UNDEFS ${_sourcesPreUndefs}
+ SOURCES_POST_UNDEFS ${_sourcesPostUndefs}
+ ${_dependsOption})
+
+ elseif ("${COTIRE_ARGV1}" STREQUAL "prefix")
+
+ if (XCODE)
+ # executing pre-build action under Xcode, check dependency on unity file and prefix dependencies
+ set (_dependsOption DEPENDS "${COTIRE_ARGV4}" ${COTIRE_TARGET_PREFIX_DEPENDS})
+ else()
+ # executing custom command, no need to re-check for dependencies
+ set (_dependsOption "")
+ endif()
+
+ set (_files "")
+ foreach (_index RANGE 4 ${COTIRE_ARGC})
+ if (COTIRE_ARGV${_index})
+ list (APPEND _files "${COTIRE_ARGV${_index}}")
+ endif()
+ endforeach()
+
+ cotire_generate_prefix_header(
+ "${COTIRE_ARGV3}" ${_files}
+ COMPILER_LAUNCHER "${COTIRE_TARGET_${COTIRE_TARGET_LANGUAGE}_COMPILER_LAUNCHER}"
+ COMPILER_EXECUTABLE "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER}"
+ COMPILER_ARG1 ${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ARG1}
+ COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}"
+ COMPILER_VERSION "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}"
+ LANGUAGE "${COTIRE_TARGET_LANGUAGE}"
+ IGNORE_PATH "${COTIRE_TARGET_IGNORE_PATH};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH}"
+ INCLUDE_PATH ${COTIRE_TARGET_INCLUDE_PATH}
+ IGNORE_EXTENSIONS "${CMAKE_${COTIRE_TARGET_LANGUAGE}_SOURCE_FILE_EXTENSIONS};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS}"
+ INCLUDE_PRIORITY_PATH ${COTIRE_TARGET_INCLUDE_PRIORITY_PATH}
+ INCLUDE_DIRECTORIES ${_includeDirs}
+ SYSTEM_INCLUDE_DIRECTORIES ${_systemIncludeDirs}
+ COMPILE_DEFINITIONS ${_compileDefinitions}
+ COMPILE_FLAGS ${_compileFlags}
+ ${_dependsOption})
+
+ elseif ("${COTIRE_ARGV1}" STREQUAL "precompile")
+
+ set (_files "")
+ foreach (_index RANGE 5 ${COTIRE_ARGC})
+ if (COTIRE_ARGV${_index})
+ list (APPEND _files "${COTIRE_ARGV${_index}}")
+ endif()
+ endforeach()
+
+ cotire_precompile_prefix_header(
+ "${COTIRE_ARGV3}" "${COTIRE_ARGV4}" "${COTIRE_ARGV5}"
+ COMPILER_LAUNCHER "${COTIRE_TARGET_${COTIRE_TARGET_LANGUAGE}_COMPILER_LAUNCHER}"
+ COMPILER_EXECUTABLE "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER}"
+ COMPILER_ARG1 ${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ARG1}
+ COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}"
+ COMPILER_VERSION "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}"
+ LANGUAGE "${COTIRE_TARGET_LANGUAGE}"
+ INCLUDE_DIRECTORIES ${_includeDirs}
+ SYSTEM_INCLUDE_DIRECTORIES ${_systemIncludeDirs}
+ COMPILE_DEFINITIONS ${_compileDefinitions}
+ COMPILE_FLAGS ${_compileFlags})
+
+ elseif ("${COTIRE_ARGV1}" STREQUAL "combine")
+
+ if (COTIRE_TARGET_LANGUAGE)
+ set (_combinedFile "${COTIRE_ARGV3}")
+ set (_startIndex 4)
+ else()
+ set (_combinedFile "${COTIRE_ARGV2}")
+ set (_startIndex 3)
+ endif()
+ set (_files "")
+ foreach (_index RANGE ${_startIndex} ${COTIRE_ARGC})
+ if (COTIRE_ARGV${_index})
+ list (APPEND _files "${COTIRE_ARGV${_index}}")
+ endif()
+ endforeach()
+
+ if (XCODE)
+ # executing pre-build action under Xcode, check dependency on files to be combined
+ set (_dependsOption DEPENDS ${_files})
+ else()
+ # executing custom command, no need to re-check for dependencies
+ set (_dependsOption "")
+ endif()
+
+ if (COTIRE_TARGET_LANGUAGE)
+ cotire_generate_unity_source(
+ "${_combinedFile}" ${_files}
+ LANGUAGE "${COTIRE_TARGET_LANGUAGE}"
+ ${_dependsOption})
+ else()
+ cotire_generate_unity_source("${_combinedFile}" ${_files} ${_dependsOption})
+ endif()
+
+ elseif ("${COTIRE_ARGV1}" STREQUAL "cleanup")
+
+ cotire_cleanup("${COTIRE_ARGV2}" "${COTIRE_ARGV3}" "${COTIRE_ARGV4}")
+
+ else()
+ message (FATAL_ERROR "cotire: unknown command \"${COTIRE_ARGV1}\".")
+ endif()
+
+else()
+
+ # cotire is being run in include mode
+ # set up all variable and property definitions
+
+ if (NOT DEFINED COTIRE_DEBUG_INIT)
+ if (DEFINED COTIRE_DEBUG)
+ set (COTIRE_DEBUG_INIT ${COTIRE_DEBUG})
+ else()
+ set (COTIRE_DEBUG_INIT FALSE)
+ endif()
+ endif()
+ option (COTIRE_DEBUG "Enable cotire debugging output?" ${COTIRE_DEBUG_INIT})
+
+ if (NOT DEFINED COTIRE_VERBOSE_INIT)
+ if (DEFINED COTIRE_VERBOSE)
+ set (COTIRE_VERBOSE_INIT ${COTIRE_VERBOSE})
+ else()
+ set (COTIRE_VERBOSE_INIT FALSE)
+ endif()
+ endif()
+ option (COTIRE_VERBOSE "Enable cotire verbose output?" ${COTIRE_VERBOSE_INIT})
+
+ set (COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS "inc;inl;ipp" CACHE STRING
+ "Ignore headers with the listed file extensions from the generated prefix header.")
+
+ set (COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH "" CACHE STRING
+ "Ignore headers from these directories when generating the prefix header.")
+
+ set (COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS "m;mm" CACHE STRING
+ "Ignore sources with the listed file extensions from the generated unity source.")
+
+ set (COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES "2" CACHE STRING
+ "Minimum number of sources in target required to enable use of precompiled header.")
+
+ if (NOT DEFINED COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT)
+ if (DEFINED COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES)
+ set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT ${COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES})
+ elseif ("${CMAKE_GENERATOR}" MATCHES "JOM|Ninja|Visual Studio")
+ # enable parallelization for generators that run multiple jobs by default
+ set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT "-j")
+ else()
+ set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT "0")
+ endif()
+ endif()
+ set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES "${COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT}" CACHE STRING
+ "Maximum number of source files to include in a single unity source file.")
+
+ if (NOT COTIRE_PREFIX_HEADER_FILENAME_SUFFIX)
+ set (COTIRE_PREFIX_HEADER_FILENAME_SUFFIX "_prefix")
+ endif()
+ if (NOT COTIRE_UNITY_SOURCE_FILENAME_SUFFIX)
+ set (COTIRE_UNITY_SOURCE_FILENAME_SUFFIX "_unity")
+ endif()
+ if (NOT COTIRE_INTDIR)
+ set (COTIRE_INTDIR "cotire")
+ endif()
+ if (NOT COTIRE_PCH_ALL_TARGET_NAME)
+ set (COTIRE_PCH_ALL_TARGET_NAME "all_pch")
+ endif()
+ if (NOT COTIRE_UNITY_BUILD_ALL_TARGET_NAME)
+ set (COTIRE_UNITY_BUILD_ALL_TARGET_NAME "all_unity")
+ endif()
+ if (NOT COTIRE_CLEAN_ALL_TARGET_NAME)
+ set (COTIRE_CLEAN_ALL_TARGET_NAME "clean_cotire")
+ endif()
+ if (NOT COTIRE_CLEAN_TARGET_SUFFIX)
+ set (COTIRE_CLEAN_TARGET_SUFFIX "_clean_cotire")
+ endif()
+ if (NOT COTIRE_PCH_TARGET_SUFFIX)
+ set (COTIRE_PCH_TARGET_SUFFIX "_pch")
+ endif()
+ if (MSVC)
+ # MSVC default PCH memory scaling factor of 100 percent (75 MB) is too small for template heavy C++ code
+ # use a bigger default factor of 170 percent (128 MB)
+ if (NOT DEFINED COTIRE_PCH_MEMORY_SCALING_FACTOR)
+ set (COTIRE_PCH_MEMORY_SCALING_FACTOR "170")
+ endif()
+ endif()
+ if (NOT COTIRE_UNITY_BUILD_TARGET_SUFFIX)
+ set (COTIRE_UNITY_BUILD_TARGET_SUFFIX "_unity")
+ endif()
+ if (NOT DEFINED COTIRE_TARGETS_FOLDER)
+ set (COTIRE_TARGETS_FOLDER "cotire")
+ endif()
+ if (NOT DEFINED COTIRE_UNITY_OUTPUT_DIRECTORY)
+ if ("${CMAKE_GENERATOR}" MATCHES "Ninja")
+ # generated Ninja build files do not work if the unity target produces the same output file as the cotired target
+ set (COTIRE_UNITY_OUTPUT_DIRECTORY "unity")
+ else()
+ set (COTIRE_UNITY_OUTPUT_DIRECTORY "")
+ endif()
+ endif()
+
+ # define cotire cache variables
+
+ define_property(
+ CACHED_VARIABLE PROPERTY "COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH"
+ BRIEF_DOCS "Ignore headers from these directories when generating the prefix header."
+ FULL_DOCS
+ "The variable can be set to a semicolon separated list of include directories."
+ "If a header file is found in one of these directories or sub-directories, it will be excluded from the generated prefix header."
+ "If not defined, defaults to empty list."
+ )
+
+ define_property(
+ CACHED_VARIABLE PROPERTY "COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS"
+ BRIEF_DOCS "Ignore includes with the listed file extensions from the generated prefix header."
+ FULL_DOCS
+ "The variable can be set to a semicolon separated list of file extensions."
+ "If a header file extension matches one in the list, it will be excluded from the generated prefix header."
+ "Includes with an extension in CMAKE_<LANG>_SOURCE_FILE_EXTENSIONS are always ignored."
+ "If not defined, defaults to inc;inl;ipp."
+ )
+
+ define_property(
+ CACHED_VARIABLE PROPERTY "COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS"
+ BRIEF_DOCS "Exclude sources with the listed file extensions from the generated unity source."
+ FULL_DOCS
+ "The variable can be set to a semicolon separated list of file extensions."
+ "If a source file extension matches one in the list, it will be excluded from the generated unity source file."
+ "Source files with an extension in CMAKE_<LANG>_IGNORE_EXTENSIONS are always excluded."
+ "If not defined, defaults to m;mm."
+ )
+
+ define_property(
+ CACHED_VARIABLE PROPERTY "COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES"
+ BRIEF_DOCS "Minimum number of sources in target required to enable use of precompiled header."
+ FULL_DOCS
+ "The variable can be set to an integer > 0."
+ "If a target contains less than that number of source files, cotire will not enable the use of the precompiled header for the target."
+ "If not defined, defaults to 2."
+ )
+
+ define_property(
+ CACHED_VARIABLE PROPERTY "COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES"
+ BRIEF_DOCS "Maximum number of source files to include in a single unity source file."
+ FULL_DOCS
+ "This may be set to an integer >= 0."
+ "If 0, cotire will only create a single unity source file."
+ "If a target contains more than that number of source files, cotire will create multiple unity source files for it."
+ "Can be set to \"-j\" to optimize the count of unity source files for the number of available processor cores."
+ "Can be set to \"-j jobs\" to optimize the number of unity source files for the given number of simultaneous jobs."
+ "Is used to initialize the target property COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES."
+ "Defaults to \"-j\" for the generators Visual Studio, JOM or Ninja. Defaults to 0 otherwise."
+ )
+
+ # define cotire directory properties
+
+ define_property(
+ DIRECTORY PROPERTY "COTIRE_ENABLE_PRECOMPILED_HEADER"
+ BRIEF_DOCS "Modify build command of cotired targets added in this directory to make use of the generated precompiled header."
+ FULL_DOCS
+ "See target property COTIRE_ENABLE_PRECOMPILED_HEADER."
+ )
+
+ define_property(
+ DIRECTORY PROPERTY "COTIRE_ADD_UNITY_BUILD"
+ BRIEF_DOCS "Add a new target that performs a unity build for cotired targets added in this directory."
+ FULL_DOCS
+ "See target property COTIRE_ADD_UNITY_BUILD."
+ )
+
+ define_property(
+ DIRECTORY PROPERTY "COTIRE_ADD_CLEAN"
+ BRIEF_DOCS "Add a new target that cleans all cotire generated files for cotired targets added in this directory."
+ FULL_DOCS
+ "See target property COTIRE_ADD_CLEAN."
+ )
+
+ define_property(
+ DIRECTORY PROPERTY "COTIRE_PREFIX_HEADER_IGNORE_PATH"
+ BRIEF_DOCS "Ignore headers from these directories when generating the prefix header."
+ FULL_DOCS
+ "See target property COTIRE_PREFIX_HEADER_IGNORE_PATH."
+ )
+
+ define_property(
+ DIRECTORY PROPERTY "COTIRE_PREFIX_HEADER_INCLUDE_PATH"
+ BRIEF_DOCS "Honor headers from these directories when generating the prefix header."
+ FULL_DOCS
+ "See target property COTIRE_PREFIX_HEADER_INCLUDE_PATH."
+ )
+
+ define_property(
+ DIRECTORY PROPERTY "COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH"
+ BRIEF_DOCS "Header paths matching one of these directories are put at the top of the prefix header."
+ FULL_DOCS
+ "See target property COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH."
+ )
+
+ define_property(
+ DIRECTORY PROPERTY "COTIRE_UNITY_SOURCE_PRE_UNDEFS"
+ BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file before the inclusion of each source file."
+ FULL_DOCS
+ "See target property COTIRE_UNITY_SOURCE_PRE_UNDEFS."
+ )
+
+ define_property(
+ DIRECTORY PROPERTY "COTIRE_UNITY_SOURCE_POST_UNDEFS"
+ BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file after the inclusion of each source file."
+ FULL_DOCS
+ "See target property COTIRE_UNITY_SOURCE_POST_UNDEFS."
+ )
+
+ define_property(
+ DIRECTORY PROPERTY "COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES"
+ BRIEF_DOCS "Maximum number of source files to include in a single unity source file."
+ FULL_DOCS
+ "See target property COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES."
+ )
+
+ define_property(
+ DIRECTORY PROPERTY "COTIRE_UNITY_LINK_LIBRARIES_INIT"
+ BRIEF_DOCS "Define strategy for setting up the unity target's link libraries."
+ FULL_DOCS
+ "See target property COTIRE_UNITY_LINK_LIBRARIES_INIT."
+ )
+
+ # define cotire target properties
+
+ define_property(
+ TARGET PROPERTY "COTIRE_ENABLE_PRECOMPILED_HEADER" INHERITED
+ BRIEF_DOCS "Modify this target's build command to make use of the generated precompiled header."
+ FULL_DOCS
+ "If this property is set to TRUE, cotire will modify the build command to make use of the generated precompiled header."
+ "Irrespective of the value of this property, cotire will setup custom commands to generate the unity source and prefix header for the target."
+ "For makefile based generators cotire will also set up a custom target to manually invoke the generation of the precompiled header."
+ "The target name will be set to this target's name with the suffix _pch appended."
+ "Inherited from directory."
+ "Defaults to TRUE."
+ )
+
+ define_property(
+ TARGET PROPERTY "COTIRE_ADD_UNITY_BUILD" INHERITED
+ BRIEF_DOCS "Add a new target that performs a unity build for this target."
+ FULL_DOCS
+ "If this property is set to TRUE, cotire creates a new target of the same type that uses the generated unity source file instead of the target sources."
+ "Most of the relevant target properties will be copied from this target to the new unity build target."
+ "Target dependencies and linked libraries have to be manually set up for the new unity build target."
+ "The unity target name will be set to this target's name with the suffix _unity appended."
+ "Inherited from directory."
+ "Defaults to TRUE."
+ )
+
+ define_property(
+ TARGET PROPERTY "COTIRE_ADD_CLEAN" INHERITED
+ BRIEF_DOCS "Add a new target that cleans all cotire generated files for this target."
+ FULL_DOCS
+ "If this property is set to TRUE, cotire creates a new target that clean all files (unity source, prefix header, precompiled header)."
+ "The clean target name will be set to this target's name with the suffix _clean_cotire appended."
+ "Inherited from directory."
+ "Defaults to FALSE."
+ )
+
+ define_property(
+ TARGET PROPERTY "COTIRE_PREFIX_HEADER_IGNORE_PATH" INHERITED
+ BRIEF_DOCS "Ignore headers from these directories when generating the prefix header."
+ FULL_DOCS
+ "The property can be set to a list of directories."
+ "If a header file is found in one of these directories or sub-directories, it will be excluded from the generated prefix header."
+ "Inherited from directory."
+ "If not set, this property is initialized to \${CMAKE_SOURCE_DIR};\${CMAKE_BINARY_DIR}."
+ )
+
+ define_property(
+ TARGET PROPERTY "COTIRE_PREFIX_HEADER_INCLUDE_PATH" INHERITED
+ BRIEF_DOCS "Honor headers from these directories when generating the prefix header."
+ FULL_DOCS
+ "The property can be set to a list of directories."
+ "If a header file is found in one of these directories or sub-directories, it will be included in the generated prefix header."
+ "If a header file is both selected by COTIRE_PREFIX_HEADER_IGNORE_PATH and COTIRE_PREFIX_HEADER_INCLUDE_PATH,"
+ "the option which yields the closer relative path match wins."
+ "Inherited from directory."
+ "If not set, this property is initialized to the empty list."
+ )
+
+ define_property(
+ TARGET PROPERTY "COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH" INHERITED
+ BRIEF_DOCS "Header paths matching one of these directories are put at the top of prefix header."
+ FULL_DOCS
+ "The property can be set to a list of directories."
+ "Header file paths matching one of these directories will be inserted at the beginning of the generated prefix header."
+ "Header files are sorted according to the order of the directories in the property."
+ "If not set, this property is initialized to the empty list."
+ )
+
+ define_property(
+ TARGET PROPERTY "COTIRE_UNITY_SOURCE_PRE_UNDEFS" INHERITED
+ BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file before the inclusion of each target source file."
+ FULL_DOCS
+ "This may be set to a semicolon-separated list of preprocessor symbols."
+ "cotire will add corresponding #undef directives to the generated unit source file before each target source file."
+ "Inherited from directory."
+ "Defaults to empty string."
+ )
+
+ define_property(
+ TARGET PROPERTY "COTIRE_UNITY_SOURCE_POST_UNDEFS" INHERITED
+ BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file after the inclusion of each target source file."
+ FULL_DOCS
+ "This may be set to a semicolon-separated list of preprocessor symbols."
+ "cotire will add corresponding #undef directives to the generated unit source file after each target source file."
+ "Inherited from directory."
+ "Defaults to empty string."
+ )
+
+ define_property(
+ TARGET PROPERTY "COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES" INHERITED
+ BRIEF_DOCS "Maximum number of source files to include in a single unity source file."
+ FULL_DOCS
+ "This may be set to an integer > 0."
+ "If a target contains more than that number of source files, cotire will create multiple unity build files for it."
+ "If not set, cotire will only create a single unity source file."
+ "Inherited from directory."
+ "Defaults to empty."
+ )
+
+ define_property(
+ TARGET PROPERTY "COTIRE_<LANG>_UNITY_SOURCE_INIT"
+ BRIEF_DOCS "User provided unity source file to be used instead of the automatically generated one."
+ FULL_DOCS
+ "If set, cotire will only add the given file(s) to the generated unity source file."
+ "If not set, cotire will add all the target source files to the generated unity source file."
+ "The property can be set to a user provided unity source file."
+ "Defaults to empty."
+ )
+
+ define_property(
+ TARGET PROPERTY "COTIRE_<LANG>_PREFIX_HEADER_INIT"
+ BRIEF_DOCS "User provided prefix header file to be used instead of the automatically generated one."
+ FULL_DOCS
+ "If set, cotire will add the given header file(s) to the generated prefix header file."
+ "If not set, cotire will generate a prefix header by tracking the header files included by the unity source file."
+ "The property can be set to a user provided prefix header file (e.g., stdafx.h)."
+ "Defaults to empty."
+ )
+
+ define_property(
+ TARGET PROPERTY "COTIRE_UNITY_LINK_LIBRARIES_INIT" INHERITED
+ BRIEF_DOCS "Define strategy for setting up unity target's link libraries."
+ FULL_DOCS
+ "If this property is empty or set to NONE, the generated unity target's link libraries have to be set up manually."
+ "If this property is set to COPY, the unity target's link libraries will be copied from this target."
+ "If this property is set to COPY_UNITY, the unity target's link libraries will be copied from this target with considering existing unity targets."
+ "Inherited from directory."
+ "Defaults to empty."
+ )
+
+ define_property(
+ TARGET PROPERTY "COTIRE_<LANG>_UNITY_SOURCE"
+ BRIEF_DOCS "Read-only property. The generated <LANG> unity source file(s)."
+ FULL_DOCS
+ "cotire sets this property to the path of the generated <LANG> single computation unit source file for the target."
+ "Defaults to empty string."
+ )
+
+ define_property(
+ TARGET PROPERTY "COTIRE_<LANG>_PREFIX_HEADER"
+ BRIEF_DOCS "Read-only property. The generated <LANG> prefix header file."
+ FULL_DOCS
+ "cotire sets this property to the full path of the generated <LANG> language prefix header for the target."
+ "Defaults to empty string."
+ )
+
+ define_property(
+ TARGET PROPERTY "COTIRE_<LANG>_PRECOMPILED_HEADER"
+ BRIEF_DOCS "Read-only property. The generated <LANG> precompiled header file."
+ FULL_DOCS
+ "cotire sets this property to the full path of the generated <LANG> language precompiled header binary for the target."
+ "Defaults to empty string."
+ )
+
+ define_property(
+ TARGET PROPERTY "COTIRE_UNITY_TARGET_NAME"
+ BRIEF_DOCS "The name of the generated unity build target corresponding to this target."
+ FULL_DOCS
+ "This property can be set to the desired name of the unity target that will be created by cotire."
+ "If not set, the unity target name will be set to this target's name with the suffix _unity appended."
+ "After this target has been processed by cotire, the property is set to the actual name of the generated unity target."
+ "Defaults to empty string."
+ )
+
+ # define cotire source properties
+
+ define_property(
+ SOURCE PROPERTY "COTIRE_EXCLUDED"
+ BRIEF_DOCS "Do not modify source file's build command."
+ FULL_DOCS
+ "If this property is set to TRUE, the source file's build command will not be modified to make use of the precompiled header."
+ "The source file will also be excluded from the generated unity source file."
+ "Source files that have their COMPILE_FLAGS property set will be excluded by default."
+ "Defaults to FALSE."
+ )
+
+ define_property(
+ SOURCE PROPERTY "COTIRE_DEPENDENCY"
+ BRIEF_DOCS "Add this source file to dependencies of the automatically generated prefix header file."
+ FULL_DOCS
+ "If this property is set to TRUE, the source file is added to dependencies of the generated prefix header file."
+ "If the file is modified, cotire will re-generate the prefix header source upon build."
+ "Defaults to FALSE."
+ )
+
+ define_property(
+ SOURCE PROPERTY "COTIRE_UNITY_SOURCE_PRE_UNDEFS"
+ BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file before the inclusion of this source file."
+ FULL_DOCS
+ "This may be set to a semicolon-separated list of preprocessor symbols."
+ "cotire will add corresponding #undef directives to the generated unit source file before this file is included."
+ "Defaults to empty string."
+ )
+
+ define_property(
+ SOURCE PROPERTY "COTIRE_UNITY_SOURCE_POST_UNDEFS"
+ BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file after the inclusion of this source file."
+ FULL_DOCS
+ "This may be set to a semicolon-separated list of preprocessor symbols."
+ "cotire will add corresponding #undef directives to the generated unit source file after this file is included."
+ "Defaults to empty string."
+ )
+
+ define_property(
+ SOURCE PROPERTY "COTIRE_START_NEW_UNITY_SOURCE"
+ BRIEF_DOCS "Start a new unity source file which includes this source file as the first one."
+ FULL_DOCS
+ "If this property is set to TRUE, cotire will complete the current unity file and start a new one."
+ "The new unity source file will include this source file as the first one."
+ "This property essentially works as a separator for unity source files."
+ "Defaults to FALSE."
+ )
+
+ define_property(
+ SOURCE PROPERTY "COTIRE_TARGET"
+ BRIEF_DOCS "Read-only property. Mark this source file as cotired for the given target."
+ FULL_DOCS
+ "cotire sets this property to the name of target, that the source file's build command has been altered for."
+ "Defaults to empty string."
+ )
+
+ message (STATUS "cotire ${COTIRE_CMAKE_MODULE_VERSION} loaded.")
+
+endif()
diff --git a/manual/.nojekyll b/manual/.nojekyll
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/manual/.nojekyll
diff --git a/manual/CNAME b/manual/CNAME
new file mode 100644
index 00000000..91bbe11c
--- /dev/null
+++ b/manual/CNAME
@@ -0,0 +1 @@
+gpgfrontend.pub \ No newline at end of file
diff --git a/manual/_coverpage.md b/manual/_coverpage.md
new file mode 100644
index 00000000..53544d54
--- /dev/null
+++ b/manual/_coverpage.md
@@ -0,0 +1,33 @@
+![gpgfrontend-logo](_media/_coverpage/gpgfrontend-logo.png)
+
+# GpgFrontend
+
+![Language](https://img.shields.io/badge/language-C%2B%2B-green)
+![GitHub release (latest by date)](https://img.shields.io/github/v/release/saturneric/gpgfrontend)
+![License](https://img.shields.io/badge/License-GPL--3.0-orange)
+[![Codacy Badge](https://app.codacy.com/project/badge/Grade/d1750e052a85430a8f1f84e58a0fceda)](https://www.codacy.com/gh/saturneric/GpgFrontend/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=saturneric/GpgFrontend&amp;utm_campaign=Badge_Grade)
+
+**A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free [OpenPGP(pgp)](https://www.openpgp.org/)
+Crypto Tool.**
+
+**Also, it's one of the excellent GUI Frontends for Modern GnuPG(gpg).**
+
+## Brief Introduction
+
+You can quickly make encrypted documents or email.
+
+You can digitally sign your text or documents.
+
+You can easily and intuitively manage all your keys on your computer.
+
+## Features
+
+- Cross-Platform, can run on **Windows, Linux and macOS**.
+- Open source, installation-free and free forever.
+- Supports multiple languages. Languages spoken by most people in the world.
+
+[Download](https://github.com/saturneric/GpgFrontend/releases/latest)
+[Manual](overview.md)
+
+<!-- 背景色 -->
+![color](#ffffff)
diff --git a/manual/_media/_coverpage/gpgfrontend-logo.png b/manual/_media/_coverpage/gpgfrontend-logo.png
new file mode 100644
index 00000000..7e9841be
--- /dev/null
+++ b/manual/_media/_coverpage/gpgfrontend-logo.png
Binary files differ
diff --git a/manual/_media/icon.svg b/manual/_media/icon.svg
new file mode 100644
index 00000000..67375a64
--- /dev/null
+++ b/manual/_media/icon.svg
@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1641046753295" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="732" width="64" height="64" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><style type="text/css"></style></defs><path d="M763.52 968.96H261.248C147.2 968.96 54.784 876.544 54.784 762.496V260.224C54.784 146.176 147.2 53.76 261.248 53.76h502.272c114.048 0 206.464 92.416 206.464 206.464v502.272c0 114.048-92.416 206.464-206.464 206.464z" fill="#89898E" p-id="733"></path><path d="M671.36 365.44c0-88.576-72.32-160.128-161.536-158.976-81.024 1.152-150.656 66.688-156.288 147.456-5.504 79.104 46.336 146.56 118.016 165.12h0.128v224.128c0 5.12 1.92 9.984 5.376 13.824l45.568 49.92c4.48 4.992 12.288 4.992 16.768 0l65.664-71.68c4.608-4.992 4.352-12.672-0.384-17.408l-33.536-33.536c-5.248-5.248-5.248-13.952 0-19.2l36.096-36.096c7.04-7.04 7.04-18.304 0-25.216l-43.392-43.392c-4.224-4.224-6.528-9.856-6.528-15.744v-26.368c65.92-19.328 114.048-80.384 114.048-152.832zM512.256 294.4c22.528 0 40.832 18.176 40.832 40.576 0 22.528-18.304 40.576-40.832 40.576-22.272 0-40.576-18.176-40.576-40.576 0-22.528 18.304-40.576 40.576-40.576z" fill="#FFFFFF" p-id="734"></path></svg> \ No newline at end of file
diff --git a/manual/_media/trademark.png b/manual/_media/trademark.png
new file mode 100644
index 00000000..7e9841be
--- /dev/null
+++ b/manual/_media/trademark.png
Binary files differ
diff --git a/manual/_navbar.md b/manual/_navbar.md
new file mode 100644
index 00000000..6c0b410e
--- /dev/null
+++ b/manual/_navbar.md
@@ -0,0 +1,9 @@
+<!-- _navbar.md -->
+
+* [Source Code(Global CDN)](https://global.git.codesdream.com/GpgFrontend.git)
+* [源代码(国内服务器)](https://git.codesdream.com/GpgFrontend.git)
+* [GitHub Repository](https://github.com/saturneric/GpgFrontend)
+* [Manual](overview.md)
+* [Download](https://github.com/saturneric/GpgFrontend/releases/latest)
+* [Contract](contract.md)
+
diff --git a/manual/_sidebar.md b/manual/_sidebar.md
new file mode 100644
index 00000000..399909b7
--- /dev/null
+++ b/manual/_sidebar.md
@@ -0,0 +1,29 @@
+- Getting Start
+ - [Overview](overview.md)
+ - [Quick Start](quick-start.md)
+ - [Basic concepts](basic-concepts.md)
+- Manual
+ - [Understand Interface](manual/understand-interface.md)
+ - [Encrypt & Decrypt Text](manual/encrypt-decrypt-text.md)
+ - Symmetric Encrypt & Decrypt Text
+ - [Sign & Verify Text](manual/sign-verify-text.md)
+ - [Encrypt & Decrypt File](manual/encrypt-decrypt-file.md)
+ - [Sign & Verify File](manual/sign-verify-file.md)
+ - [Generate Key Pair & Subkey](manual/generate-key.md)
+ - [View Key Pair Details](manual/view-keypair-info.md)
+ - [Import & Export Key Pair](manual/import-export-key-pair.md)
+ - [Key Server Operations](manual/key-server-operations.md)
+ - [Email Operations](manual/email-operations.md)
+ - [Advanced Key Operation](manual/advance-key-opera.md)
+- Features Guides
+ - [Introduce](features/introduce.md)
+ - [Short Cipher-text](features/short-ciphertext.md)
+ - [Sync ALL Public Key](features/sync-all-public-keys.md)
+ - Export As Key Package
+- Contribute
+ - [Translate Interface](translate-interface.md)
+ - Contribute Code
+- About
+ - [FAQ](faq.md)
+ - [Code & Binary Verify](about/code-binary-verify.md)
+ - [Contract](contract.md)
diff --git a/manual/about/code-binary-verify.md b/manual/about/code-binary-verify.md
new file mode 100644
index 00000000..02b2474e
--- /dev/null
+++ b/manual/about/code-binary-verify.md
@@ -0,0 +1,152 @@
+# Code & Binary Verify
+
+Some users of this software have relatively high requirements for security, so here are instructions on how to verify
+whether the code and executable files have been tampered with.If you find that the signature is incorrect, please stop
+using it immediately.
+
+## Code compilation
+
+When you see the document, every binary file version released on github is automatically compiled after submission using **Github Actions**. The generation of the final code is completely done by Github Actions. I will not compile the code on my local machine, but may use my machine to sign the packaged code. The code for all release versions comes from the main branch of the Github repository.
+
+All commands and environment configuration at compile time can be consulted in the project
+code(`.github/workflow/release.yml`).
+
+## Introduction of third-party libraries
+
+For safety reasons, GnuPG will not be available in the major releases of GpgFrontned. GpgFrontnend will not use insecure or non-open source third-party libraries. The compiled version of the third-party library comes from the public code repository.
+
+## Verify Code
+
+If you have the need, interest or time, you are welcome to review the code that I use and write. When you have any
+questions, please feel free to [Contact ME](../contract.md).
+
+I will sign most new git commit. The key I use is the key that I use to perform Git related operations:
+Saturneric\<[email protected]\>. It will be given at the end of this description. For information about signing git commits, you
+can see it on the github interface.
+
+The fingerprint of the key is now given:
+
+```text
+E3379489C39B7270E70E2E303AAF1C64137CEE57
+```
+
+## Verify Release Binary Verify
+
+### ZIP package Sign
+
+Starting from version 1.0.5, I will use the Gpg key to sign the ZIP package that contains the binary executable file.
+Each ZIP compressed package will be accompanied by a signature file in the Release (end with sig suffix). You can use
+the gpg command tool to verify them before use.
+
+The key used for binary signature is Saturneric\<[email protected]\>. This is my official key and will be given below.
+
+The fingerprint of the key is now given:
+
+```text
+E3379489C39B7270E70E2E303AAF1C64137CEE57
+```
+
+## Check on About Interface
+
+There is an About interface under the help option in the top menu.You can check the version and platform of this binary
+file. More importantly, you can view the github repository branch and commit hash code corresponding to the source code
+used for compilation of this binary version on the second line.
+
+![About Interface](https://github.com/saturneric/Blob/blob/master/screenshots/check-build.png?raw=true)
+
+## Pubkey Mentioned Above
+
+#### Fingerprint
+
+```text
+E3379489C39B7270E70E2E303AAF1C64137CEE57
+```
+
+#### Pubkey Content (OpenPGP)
+
+```text
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+
+mQGNBGCVnvEBDACuEcjxckb4rocHGU7VPT/OOOOZapNG/0ViB3XhmzNh7q8QJiq6
+M4z0fpC5sf1pHXbbKtehLETrAUTFuaEp19askZI0ISoz5+qKGZuaM3bDZWBjwUpt
+woVgUphfeZy2DFsnmTtVj9CRU9Nma6smXVFud3Roj2ImZ0NFrkdETvprfLJ7jqk/
+mXgznNbbJdqmQ4l0I1E91VmrqHHHSakh3grzRDj/GuDookQl2JZfLA0J55qOYdkF
+5mmnqbYURGVcP2oot/wSrrWH0F/WatwRx9w+jZjrJWgKjJoqWwvzG8WGop1XkRn1
+Ea3Nzj/KsSL7C5YRu03BL7wNu6UNIJ/zsAnNLp87nCY85w+HnNGHkL3QcnqNQbQP
+3aySOkIjXdT8AlGIV5r5wO/RBg4e+xASGzQXx9lYbjJiiIOP2uLxYGGFbalDoiCa
+sonlXzMZTJrK7VvZ2UsnSnBJ8l/EPsY/AeZdWbmswQaFsJlfNsZZ6T5Rfyjtu8a3
+fwPJTTsbfIB6N3EAEQEAAbQbU2F0dXJuZXJpYyA8ZXJpY0Bia3R1cy5jb20+iQHO
+BBMBCAA4AhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAFiEE4zeUicObcnDnDi4w
+Oq8cZBN87lcFAmCWg1kACgkQOq8cZBN87leJfQv/ShjV9PRi8ixlJ1Ez1TDG+4N9
+EHoi2IwVK1UF51kA9lxyD+8n1ZHpcz7bRXV+YhHAO4A2l1ENrkCJVIZK9OO+Z64l
+TPKCV9JVSkxcpnr6sqKJ76Zplwah1ZkwAG9tdK9H95wgeIkO4oSRutX/cCJ35Gko
+FfhbV+/OyPYTT2562SZeQ2VqnptGLm0eF+FVt0HP4uxvRyGfgHQD46Ki6dr/JOXQ
+j57S06CIHGj1RT4uQVSx53gbFvfIgweHsWraRWwY8jMrgOazlo/KRHG4N04eQdzM
+K+WA80ODKuXdhnlGFMhn3RCFZpRV+Upso9syJ1FFChzsuX69+mRPvAojEDnREgd9
+s61nx5xWy6vKMB9oZiomNuPw2EScBwS9EK0M6APqgBaIdL6HOC7kjxBLfqgyhulD
+qGZXWNvFj5P2FNMVwSvK1cYftYz+QWqB5BhbJT2H/HpF2xNsH7jfTxwUp6KrN1Bz
+geNWgpQDXS5ZXU7dk22BwSah3nXs+LJi3Sloeh/piQHUBBMBCAA+FiEE4zeUicOb
+cnDnDi4wOq8cZBN87lcFAmCVnvECGwMFCQPC1M8FCwkIBwIGFQoJCAsCBBYCAwEC
+HgECF4AACgkQOq8cZBN87le3zAv/fMnxVMORS5rz/vsc0X8YSldmM1MqdIKSNghK
+nQKKnzTBtTKA/oHEyPhjnQRaCfi4eUGeUsdZq8fwbN6sWSmbhJ6cOVgIps9YcS/U
+sCV4egUHGy/+ozgDSh563v82ROWxXjszcnFz0F2d4stgroe8A//3OgQDv1wuhMJe
+vtSZe8W8ebj7mt0zNjccGQzNkWo82mOyZfjgvK//vWisW4JwP8gfEKBgAktj5MCY
+iGS2NbWPAToDIPCA6hKPb3sHQIY2/tGkKwyvr4oxwYRkNq4T5PWcV0p3qRsQudHp
+ZXGiL3VNIW04ihLcn8uxSE6sQK2eq5wp/6Wnt1EWG1xb0pU2nPFuAlULHsGxM+bB
+YJOk5WzYST1xdgXW3QxVsIoTuVqA+ehqrzvu+gGCz4uenFt6OAswqR7ii8D/Tpso
+RAU0nTEOAVpCxXAMgsdUS6jOjtyfTHixGlVL6U3dY3wTuqWdbxmYX/g00PnOTYF0
+1plvf21NHMeYLk68+1nRbtqoLnPVuQGNBGCVnvEBDAC8zNpSGRHUp+X7hit0bCDP
+P8HR+rxH50rOVFtQNyXw32lkIrwnHq0Y7FR4t7OSWTkX1xvxhXMILQdTBxKKrBtF
+IpQ44cO1UcklkYdCwE/F0lasLLfleo2NlG7ISwNEOxmJcWiwmkLHN3CnqXpXXqpG
+DTRavbuhE7yRewp/jNSCsikrvL7NedB5Ef5EZmSkvx7kXibXKzgKcyft5OlylRMU
+JS8gzzTPA+xMH/Cl1zFCSgymJw1DK1wx+u0ye2Oj7NDdrYtRR1qLpCq7kaGIPvIW
+556/58sj+/YRGeP5JTjhYFk/K8QQr8cK6HWuJQVASJUP+KBk8CiaqzbOPjlq69eG
+Oymraa8H7JvSR5ArJWPczOxQyiEbYABOtJk1ZSz4v4pa7+RLUfwFOYuTMyBoY3rJ
+uGhVxA77oHftfjteH1YcKyJXrWnJEA2UbUmyRa5cwZ8S7HXOIvMhCQS897Tzjpab
+lfnIKE0n99c2ylJ4y4fHYSXYDKiCPKniFio8CxfqY+cAEQEAAYkBvAQYAQgAJhYh
+BOM3lInDm3Jw5w4uMDqvHGQTfO5XBQJglZ7xAhsMBQkDwtTPAAoJEDqvHGQTfO5X
+FbAL/0XZJW6XUca9d7f6Ft/0crMILRKID5uuSaLN1jG7BuLTwyWPhi7eSWbZQmlD
+Fun/E3vHFj3U/WG13DJL6M89f3707R6rKxT1B17Ht53bO9zHqJ9KesP1G+mR3phk
+hnxoQFlFvfSASZbDFtwEm3eZs55UBY4EPYf9MV+qPT0iNu1KPVX427uQfI0Ic/m4
+xFAO2XI11wMunDQoXi7rjknjYWxqVyGgqgRLrBD1Bb/aLenKN9Wn4FajEDaYrgpH
+46HHyhAOJ2RZbenWO689rZY6/0qPwDGRL7B2xiktu2G+e5JMJjuRhwEB0g63G8M1
+MVuRGr/PvrBjs58kF47rxWpp2xmo8dqCHjNS3ze9pl6oyshPa1J5zeDTNk3Ujgr9
+IJEzWLDWv9PP9ApcSD15Ia60bxSvsC8FJAZh81JEadLywx0QNBLmnMP3Dxpd21LK
+W8cWXa31F6E6eNf/45h7UGxVBRoOdPQ/Kwg4z69V9T/AXOuK65XgtG5ajwlmoQcv
+Vx7KIrkCDQRgloMRARAAtRIaNwOpLKA1ogvpzgx8/A8PeXCKvKPZ/ls+8sJ8RSZb
+b8lmd+HN52sotj3h9XGZXO1123WLW5F7n/M3HazRBRLlIoUf5kWnuQmXXmUZ6DEC
+mq9VoZ30CPHWDEZv/BoScXEHMZNEppziebe2r57SqY9cIONt7B2wzi3sVcYOtDye
+c+9BUQoEEv/grSfRN/1Lzezb8Ac9XY0Jet9XK/ImKbGCoxMNzszGQeFO2Neg4hVG
+65NIHjTRwzMUOp2D9GV14z/mu2xj5z0mP8zTLw2nzjSW8b0s9ewsvawH45s+XBS8
+ndMU3R+pnHqZBJXU1OR9XjSSMZhaNk+cpOgVwlmbGhNUZ4jSPNVZr/fABpgpY7Bh
+ctY42Q3DZVSMwSmiGZA2Uoy7kKx2qtm1Q0ogh6x5mq9QKHODuh+Uc1XhbqxheySv
+/jWxvnWhRqaRMBIY+H6vFbXRkQvYjdtwwHZvBRyF5VOsdSUbdLunjyIeKTl2wMqR
+hm0y2li+nbTE+zbCcguGPtIMZq6V08M3OZZGxT1jZZocOi3y0qwuApaQvAvk7GpC
+mjjbSsq/ykbPUMSQHqAh77YY/9/v2kBh5u21fBPmtPyndAeZTNyukJ2dq8pecVgP
+eqT/sSs/Gn56T1cekPEIuUkUxQ4K1sLah1z4G+jg8VqCPIj4yBH6pfd6zBEPx70A
+EQEAAYkD8gQYAQgAJhYhBOM3lInDm3Jw5w4uMDqvHGQTfO5XBQJgloMRAhsCBQkH
+hh93AkAJEDqvHGQTfO5XwXQgBBkBCAAdFiEExEoeTMpVzDyCCrnkOlA5Ga/6SF8F
+AmCWgxEACgkQOlA5Ga/6SF9U+hAAs59FJP2pCQDnrFCrmk38mVePAyPNceSm7IEl
+zJWuoxf6XOkz7SP7Vh4mPxyRj3yltEnFN5tLvDOF8W+AwMMMHrK9TnXxnJ2HwCbY
+ifLgAGmNrMq+IoagTJDAZvlkp4m3gHe6zDYv9UIbFKdnB48FbwtahNm9LjMbqNDc
+nLBt+IuiO/PXUu6c56Wl+L9ntOSVLb1ySnRisI4iYx4J80GcFaMjlJFjQ5uGt0jh
+Ardq4zFLYgJfTTl6cM8WTANiKO2a6DgpZxb1knfKOjdasqeQcEs4ZcB6Nf9Bcw/X
+Qe2Ee85FA+qClxuIMTT5l6fDw+DXgZfSR0clwA4rMY7hCUvuRxCjc1LDOCbyHe/Z
+PUAntlNNKrXEicXxi8Odpzcq0/rDR53OMyzFhGXpbbxa89F/B96H249IW/waefN6
+VKpSb693VOyl8AtQ2tRAvy7YxYyhUQIKKCuahjdoib3GmFNE67rjW9MUVfefIhvp
+nBJaY8tp8YhYrDF0U9DMuYrTLcPu5VsR7gvlFY30If1XCavpAnq+eNaxIdTDIKfJ
+Q2cgALPBfzogEOeR+RY4Lo46dIGCaEYTpbImcJdum0GVACoMb0T1oOXIHWd1hy46
+ianYKGxMmjfS1f13cr6F1U18l8QKMBZhNTBazw2IdXaugdnbqryEsp20zPQ+caGR
++E1wZmOLMAv+JMPJSK7Ra9cQf6GEos1XurjhaoegPh0Y9U4p1Dk1pQduI7togmJ/
+bhvIpawfi52rI/4I4g1HqjcU8iG6ZjTVE7kVVvDISex71czbmV9isWvW0HJlDgTQ
+piZbTCPqvgyEZRF0eIA+VTXOKD/qUwxvw3jo75KEcmW+sezqctREgH02EBPuD5GC
+Qyxi7+nNq37FTNYReydCEGEDfJXZ6x12FkW9nPe2fkxx7WT/ceVT2jGtSG4re5vk
+wYtnfgKvfHXYmTudoMuVmIsJc9zcdvhL1Nmrd1BOyeJmQCNyvwP48OkU5TqIGHc4
+PcbwniPKO8tozjuwE+iO2TjgwWc/Eg5hLPGYlyqalysP4nOO/KYLBwvgTrPse40N
+jg4/3Ew4DKxsrHtCGfhx+i5pXVYwbWklPd7mDmmvxnM5gFEqs0VMMGsjElCzDsmm
+v3fSDNozRpd0LXK7J4QGwtOBVivNf7XDQOx5ZXbh/HTQuTG2/8FMCbwUwPYFLx07
+hHHFn9+/wu20
+=bgvm
+-----END PGP PUBLIC KEY BLOCK-----
+
+``` \ No newline at end of file
diff --git a/manual/basic-concepts.md b/manual/basic-concepts.md
new file mode 100644
index 00000000..638c19e3
--- /dev/null
+++ b/manual/basic-concepts.md
@@ -0,0 +1,58 @@
+# Basic Concepts
+
+If you don't know GPG, or PGP, you may need to learn some basic concepts here before using Gpg Frontend. This reduces
+the chance of you making mistakes, such as distributing your private key to the world.
+
+## The most basic concepts you must know
+
+First, you need to generate a key pair, which you can imagine as a key ring. Each key pair has at least two keys, a
+public key and a corresponding private key. These two keys form a key pair. There can also be multiple public keys and
+their (one-to-one correspondence) private keys in a key pair, which will be described later. The public key can be
+released to the outside world. Others can use your public key to encrypt the information they want to give you. The
+private key is kept by yourself. If it is leaked, your encryption will no longer be meaningful.
+
+What you need to know is that the public key is used to encrypt information, and the ciphertext encrypted by others
+using the public key you released is guaranteed to be decrypted only by the corresponding private key of your key pair.
+This process involves some The principle of cryptography, you can trust this process unless no one knows your private
+key except you. The reverse of this process is also valid, you can encrypt a message with your private key, and someone
+else decrypts the message with your public key. The significance of this inverse process is that if the person using the
+public key cannot normally decrypt a message encrypted with the private key, then it is certain that the message does
+not come from the person who owns the private key corresponding to the public key. . This process can also be trusted.
+It can be seen that this reverse process establishes a process of signing and then verifying. Information encrypted with
+the private key can be seen as a signature. Others can use the public key to verify that the signature is valid.
+
+If you just want to use the tool, you don't need to understand the cryptography behind it, you just need to remember the
+above.
+
+If you want to know more, you can read on.
+
+## Multiple pairs of public and private keys in a key pair
+
+In a key pair, there is at least one pair of public key and private key, but there is no limit to the maximum number of
+pairs. You can generate another pair of public and private keys (we call them subkeys), and then add them to the key
+pair, but it is worth noting that the newly added public and private key pairs are the same as the first pair. Pairs
+have a public key and private key (which we call the primary key) pair associated.
+
+You can specify which process a subkey pair is used for. For example, the first key pair is used for encryption and
+decryption, the second key pair is used for signing and verification, or the third key pair can be used for encryption
+and decryption. Used to do the above two key pairs at the same time. Please specify these things when generating the
+subkey.
+
+The master key is automatically generated when the key pair is generated, and the subkey can be added by the user at
+will.
+
+When generating the master key or subkey, you can choose some algorithms such as RSA, DSA, etc. You do not need to
+understand the specific principles of these. You just need to know that subkeys generated by certain algorithms cannot
+perform certain processes (such as encryption and decryption), but can only perform certain processes (such as signing
+and verification). It is worth mentioning that for RSA, you can choose the key length when using the algorithm, you can
+think that the key
+
+## The first pair of public and private keys in a key pair (primary key)
+
+The first pair of public and private keys (master key) in a key pair is very critical, because subsequent public and
+private keys (sub-keys) are linked to them, you can think that if someone else gets yours Master key (including public
+and private key information), he can generate sub-keys based on the information of the master key, and then he can use
+the sub-keys he generated to impersonate you and communicate with others.
+
+Therefore, the private key of the master key (the public key can be released to others) must not be leaked. The
+disclosure of its private key means that the entire key pair is no longer safe and must be stopped immediately.
diff --git a/manual/contract.md b/manual/contract.md
new file mode 100644
index 00000000..bb9de59b
--- /dev/null
+++ b/manual/contract.md
@@ -0,0 +1,136 @@
+# Contract
+
+Contents related to business and politics are rejected. This tool belongs to all mankind. If you have any questions
+about technology and improving this software, please feel free to contact me.
+
+It is recommended to use plain text to contact me by email, but HTML is not recommended.
+
+## About ME
+
+Name: Saturneric, Eric or Erich.
+
+
+Tips: BKTUS(Bakantu Union) is not a company, it is my personal domain name.
+
+## Languages
+
+You can write to me in the following language.
+
+1. English
+2. Chinese
+3. Deutsch
+
+## GPG Public Key Info
+
+This is the PGP public key that I support for a long time. You can use this public key to establish encrypted
+communication with me. Please use plain text for encrypted communication, do not use rich text formats such as HTML.
+
+```
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+
+mQGNBGCVnvEBDACuEcjxckb4rocHGU7VPT/OOOOZapNG/0ViB3XhmzNh7q8QJiq6
+M4z0fpC5sf1pHXbbKtehLETrAUTFuaEp19askZI0ISoz5+qKGZuaM3bDZWBjwUpt
+woVgUphfeZy2DFsnmTtVj9CRU9Nma6smXVFud3Roj2ImZ0NFrkdETvprfLJ7jqk/
+mXgznNbbJdqmQ4l0I1E91VmrqHHHSakh3grzRDj/GuDookQl2JZfLA0J55qOYdkF
+5mmnqbYURGVcP2oot/wSrrWH0F/WatwRx9w+jZjrJWgKjJoqWwvzG8WGop1XkRn1
+Ea3Nzj/KsSL7C5YRu03BL7wNu6UNIJ/zsAnNLp87nCY85w+HnNGHkL3QcnqNQbQP
+3aySOkIjXdT8AlGIV5r5wO/RBg4e+xASGzQXx9lYbjJiiIOP2uLxYGGFbalDoiCa
+sonlXzMZTJrK7VvZ2UsnSnBJ8l/EPsY/AeZdWbmswQaFsJlfNsZZ6T5Rfyjtu8a3
+fwPJTTsbfIB6N3EAEQEAAbQbU2F0dXJuZXJpYyA8ZXJpY0Bia3R1cy5jb20+iQHO
+BBMBCAA4AhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAFiEE4zeUicObcnDnDi4w
+Oq8cZBN87lcFAmCWg1kACgkQOq8cZBN87leJfQv/ShjV9PRi8ixlJ1Ez1TDG+4N9
+EHoi2IwVK1UF51kA9lxyD+8n1ZHpcz7bRXV+YhHAO4A2l1ENrkCJVIZK9OO+Z64l
+TPKCV9JVSkxcpnr6sqKJ76Zplwah1ZkwAG9tdK9H95wgeIkO4oSRutX/cCJ35Gko
+FfhbV+/OyPYTT2562SZeQ2VqnptGLm0eF+FVt0HP4uxvRyGfgHQD46Ki6dr/JOXQ
+j57S06CIHGj1RT4uQVSx53gbFvfIgweHsWraRWwY8jMrgOazlo/KRHG4N04eQdzM
+K+WA80ODKuXdhnlGFMhn3RCFZpRV+Upso9syJ1FFChzsuX69+mRPvAojEDnREgd9
+s61nx5xWy6vKMB9oZiomNuPw2EScBwS9EK0M6APqgBaIdL6HOC7kjxBLfqgyhulD
+qGZXWNvFj5P2FNMVwSvK1cYftYz+QWqB5BhbJT2H/HpF2xNsH7jfTxwUp6KrN1Bz
+geNWgpQDXS5ZXU7dk22BwSah3nXs+LJi3Sloeh/piQHUBBMBCAA+FiEE4zeUicOb
+cnDnDi4wOq8cZBN87lcFAmCVnvECGwMFCQPC1M8FCwkIBwIGFQoJCAsCBBYCAwEC
+HgECF4AACgkQOq8cZBN87le3zAv/fMnxVMORS5rz/vsc0X8YSldmM1MqdIKSNghK
+nQKKnzTBtTKA/oHEyPhjnQRaCfi4eUGeUsdZq8fwbN6sWSmbhJ6cOVgIps9YcS/U
+sCV4egUHGy/+ozgDSh563v82ROWxXjszcnFz0F2d4stgroe8A//3OgQDv1wuhMJe
+vtSZe8W8ebj7mt0zNjccGQzNkWo82mOyZfjgvK//vWisW4JwP8gfEKBgAktj5MCY
+iGS2NbWPAToDIPCA6hKPb3sHQIY2/tGkKwyvr4oxwYRkNq4T5PWcV0p3qRsQudHp
+ZXGiL3VNIW04ihLcn8uxSE6sQK2eq5wp/6Wnt1EWG1xb0pU2nPFuAlULHsGxM+bB
+YJOk5WzYST1xdgXW3QxVsIoTuVqA+ehqrzvu+gGCz4uenFt6OAswqR7ii8D/Tpso
+RAU0nTEOAVpCxXAMgsdUS6jOjtyfTHixGlVL6U3dY3wTuqWdbxmYX/g00PnOTYF0
+1plvf21NHMeYLk68+1nRbtqoLnPViQG5BBABCgAjFiEEnGCv/tNBLyJzYTX+0QUx
+Uz7XYkoFAmG6ODgFg2shizAACgkQ0QUxUz7XYkq+BQwAxEzCMKxa21iKv9P7S6Vh
+/ZrPMWPzRMoNjMGFeNHxYzyO6lKojoCVsdHaRvqqSota8wVGHglsg4FEZgkqEy+S
+kTwMsorqzVhxAtzG9K1pU+wGouT5UPBXFGjusbLfxigxvuIGEVD2025FroE4xvMG
+WnyD7r0leWkbF0z1crms2jbPcH0E7nbiiVHA6iOuBV5jo6qm1UxvJH3izSCocrDC
+/yqPXg5cng6BPnctcWFzXbVGcB1HQ4LdiN4HWvB7q1mwRG2+qwL+UBybGsMpP+oa
+YlIGP0FxNureXJgg8bVGcOOLITmuQ1xTOFu/1lUzk1QBqNql0mvqqScSYsAJxQcy
+d95MFFeRLnQ3fJU18YrvlLtJIFxrLE+9IVCQsM3XGblXLCltIEgAunp1ylaVtb/w
+4ScbQ/a5vWILh80L3dxcvVe1RlZe6cRwOb4aXRQm7osVaZ/boiaJ1nHYGdrh+qxi
+QprHmOXeSPVV708VRaY9t8tSiLCRwVQO1e5e8GeXzIv/uQINBGCWgxEBEAC1Eho3
+A6ksoDWiC+nODHz8Dw95cIq8o9n+Wz7ywnxFJltvyWZ34c3nayi2PeH1cZlc7XXb
+dYtbkXuf8zcdrNEFEuUihR/mRae5CZdeZRnoMQKar1WhnfQI8dYMRm/8GhJxcQcx
+k0SmnOJ5t7avntKpj1wg423sHbDOLexVxg60PJ5z70FRCgQS/+CtJ9E3/UvN7Nvw
+Bz1djQl631cr8iYpsYKjEw3OzMZB4U7Y16DiFUbrk0geNNHDMxQ6nYP0ZXXjP+a7
+bGPnPSY/zNMvDafONJbxvSz17Cy9rAfjmz5cFLyd0xTdH6mcepkEldTU5H1eNJIx
+mFo2T5yk6BXCWZsaE1RniNI81Vmv98AGmCljsGFy1jjZDcNlVIzBKaIZkDZSjLuQ
+rHaq2bVDSiCHrHmar1Aoc4O6H5RzVeFurGF7JK/+NbG+daFGppEwEhj4fq8VtdGR
+C9iN23DAdm8FHIXlU6x1JRt0u6ePIh4pOXbAypGGbTLaWL6dtMT7NsJyC4Y+0gxm
+rpXTwzc5lkbFPWNlmhw6LfLSrC4ClpC8C+TsakKaONtKyr/KRs9QxJAeoCHvthj/
+3+/aQGHm7bV8E+a0/Kd0B5lM3K6QnZ2ryl5xWA96pP+xKz8afnpPVx6Q8Qi5SRTF
+DgrWwtqHXPgb6ODxWoI8iPjIEfql93rMEQ/HvQARAQABiQPyBBgBCAAmAhsCFiEE
+4zeUicObcnDnDi4wOq8cZBN87lcFAmG6N+8FCQTmG90CQMF0IAQZAQgAHRYhBMRK
+HkzKVcw8ggq55DpQORmv+khfBQJgloMRAAoJEDpQORmv+khfVPoQALOfRST9qQkA
+56xQq5pN/JlXjwMjzXHkpuyBJcyVrqMX+lzpM+0j+1YeJj8ckY98pbRJxTebS7wz
+hfFvgMDDDB6yvU518Zydh8Am2Iny4ABpjazKviKGoEyQwGb5ZKeJt4B3usw2L/VC
+GxSnZwePBW8LWoTZvS4zG6jQ3JywbfiLojvz11LunOelpfi/Z7TklS29ckp0YrCO
+ImMeCfNBnBWjI5SRY0ObhrdI4QK3auMxS2ICX005enDPFkwDYijtmug4KWcW9ZJ3
+yjo3WrKnkHBLOGXAejX/QXMP10HthHvORQPqgpcbiDE0+Zenw8Pg14GX0kdHJcAO
+KzGO4QlL7kcQo3NSwzgm8h3v2T1AJ7ZTTSq1xInF8YvDnac3KtP6w0edzjMsxYRl
+6W28WvPRfwfeh9uPSFv8GnnzelSqUm+vd1TspfALUNrUQL8u2MWMoVECCigrmoY3
+aIm9xphTROu641vTFFX3nyIb6ZwSWmPLafGIWKwxdFPQzLmK0y3D7uVbEe4L5RWN
+9CH9Vwmr6QJ6vnjWsSHUwyCnyUNnIACzwX86IBDnkfkWOC6OOnSBgmhGE6WyJnCX
+bptBlQAqDG9E9aDlyB1ndYcuOomp2ChsTJo30tX9d3K+hdVNfJfECjAWYTUwWs8N
+iHV2roHZ26q8hLKdtMz0PnGhkfhNcGZjCRA6rxxkE3zuV1CBC/0aOW74yuxVTBhi
+c+UNCjbHAZxc6gB8DnhuFp/h0FFfWR5SPKE7KjiZSAH38fzp9i1JT2KMfcDBrs4m
+PPCaN7KHViU8Z9YF2FDCn+xqhDvm9j64FNYnTihWttgMM3AbZI+LPbwGl+Uaa4vF
+n+sXrUqag8hu7fnCzoE+YPj03CUxSzCw4jXHh0Dyan33msEN6n6G6/XRG073HXxt
+xiEaAeNDE+izq98WIfH1c4DVpKFPlD9DVdaCWHzl6vzU3d04g+sUQuMqrScm+rcm
+BYCa+SRWnyl2q0dhnG1XjONOBNAZGorB9ooKH5HBFUVeFNsM4ufA+oRp+1XlaqXo
+Tc7l+JeDEsVK1fmQljNRhBshaxk8fLPmCi1rmApME33aEGDsg8uc3IZXPe3r8cmY
+D/AVSQI5MdPpXqq1VWv+faXL0lZtECtfOXp6l81OX5hqCC7hp6eW7gMofi02YiXU
+aBwg2Kx/x2IxG7u9givkBV4oysiedKLNYWUTqjB2aKcRyWISCn+4MwRhujfiFgkr
+BgEEAdpHDwEBB0DvyZqcMWkH1WlSfOywXkKTbITdzBKzaf4jtd3g+kjaC4kCMwQY
+AQoAJhYhBOM3lInDm3Jw5w4uMDqvHGQTfO5XBQJhujfiAhsiBQkDwtdvAIEJEDqv
+HGQTfO5XdiAEGRYIAB0WIQQKoW+sJgfi4tfYq0XFuG82AZ5SpwUCYbo34gAKCRDF
+uG82AZ5Sp8xMAQCc6Q7vJXYXIoShHk4RmT1vkAy68k8XgHn9Kw+jbAze4gD9F22u
+wWfbsFjiMLUOE2uWlwuLmJN827DBaVw5eOx9HA1F1AwAgFTv4dNTS0jKKIncUN4Y
+XX4fA7UbBrwLY8jTAV49V+D+hoFfv09hG+q4xwKwe1yFrgacsHOXnXpTJz6ipU08
+GP9vTheyxSfQUvaWXLzHcGXkaV6aCBsDVWdQ8MHXujOsx/hjQSTDruygmEyc1nFi
+aF1BLQDtTXW7GIiQX/l/uLVlnMNI4kdt7YUxjkUL6xD+U5q43B4KyGVIU9+ps4Mr
+9wCWS/lot66VLT4FUVTFDF0c8hwEdxVZagZvExlv2SaW3XidRWL5xVAElRs/fgRn
+dKFCFDJ1rOLUwj25r6zgu2zXlQ2RHWjgzhLzZmhzv3IX0mI9s5D6bJWy+6/HNCs8
+bTSq0Af79FCdZfPT8GVlY9NWcwsMthxiYJ/cbc/D+w4dX771lP2dU/KZkKuGxdhA
+jGWqnGt8lqL3PEIsf1ylPDx6b7peFABWfGlPVUmpik2lTemlqWNPLX5gGmiiktGm
+lZ6+bATms7izrrSs521ZKWoUT5TI+qQ7Paq/qsF5zIBGuQGNBGCVnvEBDAC8zNpS
+GRHUp+X7hit0bCDPP8HR+rxH50rOVFtQNyXw32lkIrwnHq0Y7FR4t7OSWTkX1xvx
+hXMILQdTBxKKrBtFIpQ44cO1UcklkYdCwE/F0lasLLfleo2NlG7ISwNEOxmJcWiw
+mkLHN3CnqXpXXqpGDTRavbuhE7yRewp/jNSCsikrvL7NedB5Ef5EZmSkvx7kXibX
+KzgKcyft5OlylRMUJS8gzzTPA+xMH/Cl1zFCSgymJw1DK1wx+u0ye2Oj7NDdrYtR
+R1qLpCq7kaGIPvIW556/58sj+/YRGeP5JTjhYFk/K8QQr8cK6HWuJQVASJUP+KBk
+8CiaqzbOPjlq69eGOymraa8H7JvSR5ArJWPczOxQyiEbYABOtJk1ZSz4v4pa7+RL
+UfwFOYuTMyBoY3rJuGhVxA77oHftfjteH1YcKyJXrWnJEA2UbUmyRa5cwZ8S7HXO
+IvMhCQS897TzjpablfnIKE0n99c2ylJ4y4fHYSXYDKiCPKniFio8CxfqY+cAEQEA
+AYkBvAQYAQgAJhYhBOM3lInDm3Jw5w4uMDqvHGQTfO5XBQJglZ7xAhsMBQkDwtTP
+AAoJEDqvHGQTfO5XFbAL/0XZJW6XUca9d7f6Ft/0crMILRKID5uuSaLN1jG7BuLT
+wyWPhi7eSWbZQmlDFun/E3vHFj3U/WG13DJL6M89f3707R6rKxT1B17Ht53bO9zH
+qJ9KesP1G+mR3phkhnxoQFlFvfSASZbDFtwEm3eZs55UBY4EPYf9MV+qPT0iNu1K
+PVX427uQfI0Ic/m4xFAO2XI11wMunDQoXi7rjknjYWxqVyGgqgRLrBD1Bb/aLenK
+N9Wn4FajEDaYrgpH46HHyhAOJ2RZbenWO689rZY6/0qPwDGRL7B2xiktu2G+e5JM
+JjuRhwEB0g63G8M1MVuRGr/PvrBjs58kF47rxWpp2xmo8dqCHjNS3ze9pl6oyshP
+a1J5zeDTNk3Ujgr9IJEzWLDWv9PP9ApcSD15Ia60bxSvsC8FJAZh81JEadLywx0Q
+NBLmnMP3Dxpd21LKW8cWXa31F6E6eNf/45h7UGxVBRoOdPQ/Kwg4z69V9T/AXOuK
+65XgtG5ajwlmoQcvVx7KIg==
+=syqc
+-----END PGP PUBLIC KEY BLOCK-----
+```
+
diff --git a/manual/faq.md b/manual/faq.md
new file mode 100644
index 00000000..b53c149a
--- /dev/null
+++ b/manual/faq.md
@@ -0,0 +1,46 @@
+# FAQ
+
+## What is GpgFrontend?
+
+GpgFrontend is a cross-platform encryption tool that conforms to the OpenPGP standard. It is committed to making OpenPGP
+easier to use, so that more people can use the tool to protect their privacy.
+
+## Relationship with OpenPGP(pgp) and Gnupg(gpg)?
+
+OpenPGP is a data encryption and decryption standard, and GpgFrontend supports it. GnuPG is a cryptographic software
+used to encrypt, sign communication content and manage keys for asymmetric cryptography. It follows the OpenPGP
+standard. GpgFrontend drives gnupg at runtime to implement operations such as encryption and decryption.
+
+## How to obtain and use GpgFrontend?
+
+The various versions of GpgFrontend will be released in the GitHub repository, and you can find and download the latest
+version in Releases. After downloading, you can refer to the instructions in ReadME and you can start using it in just a
+few steps.
+
+## I found some flaws in GpgFrontend, what should I do?
+
+If you find a defect in GpgFrontend, you are welcome to create an issue in the GitHub repository to describe the
+problem. When I see your issue, I will respond as soon as possible. If you do not have a GitHub account, please email my
+personal mailbox. For contact information, please see [Contract](contract.md).
+
+## Can I modify the code of GpgFrontend?
+
+If you have any good ideas, you are free to modify the code of GpgFrontend. You are welcome to submit a Pull Request to
+add your good ideas to the next version.
+
+You can contribute completely anonymously, and you can email me patches.
+
+## Why should I install GnuPG additionally?
+
+The source code of GpgFrontend does not contain operations such as encryption and decryption, which requires Gnupg to
+provide support. In addition, for users with higher security requirements, they can let GpgFrontend drive their trusted
+copy of Gnupg. This design improves the security of GpgFrontend.
+
+## What is the release version with BETA?
+
+The release version with the word "beta" means that some modules of this version have not yet been thoroughly tested. In
+addition, some support for the beta version may not be complete. But rest assured, I will test after the beta version is
+released, and release a stable version at an appropriate time.
+
+But starting from 2.0.0, BETA versions will not be released unless there are special circumstances.
+
diff --git a/manual/features/introduce.md b/manual/features/introduce.md
new file mode 100644
index 00000000..eb250877
--- /dev/null
+++ b/manual/features/introduce.md
@@ -0,0 +1,4 @@
+# Introduce Features
+
+GpgFrontend provides some advanced functions that can meet the needs of certain scenarios.
+These features will be gradually introduced as the version is updated.
diff --git a/manual/features/short-ciphertext.md b/manual/features/short-ciphertext.md
new file mode 100644
index 00000000..8e301966
--- /dev/null
+++ b/manual/features/short-ciphertext.md
@@ -0,0 +1,14 @@
+# Short Cipher-text
+
+**NOTICE: As of version 2.0.0, GpgFrontend has eliminated this feature.**
+
+The short ciphertext function allows OpenPGP to transfer ciphertext quickly and conveniently in instant messaging software.
+After successfully configuring the own key and obtaining the Service Token, you can use the short cipher text function.
+
+After the encryption and signature operations, you can click the short crypto button in the additional operations menu.
+GpgFrontend will return a very short ciphertext, and you can publish the short ciphertext anywhere.
+
+You can paste the ciphertext into the text tab of GpgFrontend and select decryption and verification operations.
+At this time, GpgFrontend will perform the corresponding operations.
+
+Note: The short ciphertext is valid within seven days of being generated. The short ciphertext function has restrictions on the length of the ciphertext.
diff --git a/manual/features/sync-all-public-keys.md b/manual/features/sync-all-public-keys.md
new file mode 100644
index 00000000..cfc87d60
--- /dev/null
+++ b/manual/features/sync-all-public-keys.md
@@ -0,0 +1,26 @@
+# Public Key Sync
+
+Sometimes, you need to keep your local key consistent with the one on the key server. This is critical in cases where a
+key owner revokes its key, at which point you need to stop using the key immediately. This avoids potential
+man-in-the-middle attacks. Or, if the key owner creates a new subkey for signing, gpg will not be able to verify the
+validity of the ciphertext if the ciphertext he sends to you signs with the subkey and you do not have local information
+about the subkey.
+
+## How to use
+
+It's very simple, after clicking the Sync Public Key button in the the Key Management interface, things will be done
+automatically.
+
+![image-20220109194459557](_media/sync-all-public-keys/image-20220109194459557.png)
+
+This feature will check all the public keys you now have (only the public key, not any private keys) and then search for
+it in the key server. If the corresponding public key is found in the key server, GpgFrontend will import the latest
+public key from the key server to the local.
+
+### Which Key Server Was Used
+
+How do I know which key server GpgFrontend accessed? It's simple, GpgFrontend will exchange keys using the default key
+server you set up. If you need to change the key server you need to access, you just need to add your key server in the
+settings and set it as the default.
+
+![image-20220109194546570](_media/sync-all-public-keys/image-20220109194546570.png)
diff --git a/manual/index.html b/manual/index.html
new file mode 100644
index 00000000..2e07158b
--- /dev/null
+++ b/manual/index.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <title>GpgFrontend - An OpenPGP Frontend Tool</title>
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
+ <meta name="description" content="Description">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
+ <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
+ <link rel="shortcut icon" href="/_media/icon.svg" type="image/x-icon">
+</head>
+<body>
+ <div id="app"></div>
+ <script>
+ window.$docsify = {
+ logo: '/_media/trademark.png',
+ name: 'GpgFrontend',
+ loadNavbar: true,
+ loadSidebar: true,
+ coverpage: true,
+ onlyCover: true,
+ subMaxLevel: 3,
+ alias: {
+ '/.*/_sidebar.md': '/_sidebar.md'
+ }
+ }
+ </script>
+ <script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
+ <script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/emoji.min.js"></script>
+ <script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-bash.min.js"></script>
+ <script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-php.min.js"></script>
+</body>
+</html>
diff --git a/manual/manual/advance-key-opera.md b/manual/manual/advance-key-opera.md
new file mode 100644
index 00000000..c8b646a4
--- /dev/null
+++ b/manual/manual/advance-key-opera.md
@@ -0,0 +1,3 @@
+# Advance Key Operation
+
+Some advanced key operations will be introduced in this module. \ No newline at end of file
diff --git a/manual/manual/email-operations.md b/manual/manual/email-operations.md
new file mode 100644
index 00000000..6d460e60
--- /dev/null
+++ b/manual/manual/email-operations.md
@@ -0,0 +1 @@
+# Email Operations \ No newline at end of file
diff --git a/manual/manual/encrypt-decrypt-file.md b/manual/manual/encrypt-decrypt-file.md
new file mode 100644
index 00000000..230480b1
--- /dev/null
+++ b/manual/manual/encrypt-decrypt-file.md
@@ -0,0 +1,52 @@
+# Encrypt & Sign File
+
+Gpg Frontend provides a convenient and fast way to operate on files. The concept of encryption and decryption files is
+almost the same as text, except that the input and output of file operations can be binary.
+
+## File Extension Introduction
+
+For ciphertext in ASCII format, its filename suffix is usually asc, and you can directly open such files with a text
+editor. However, if the ciphertext is binary, its file extension will be gpg. Usually, binary ciphertext files are
+smaller than ASCII format.
+
+Before v2.0.4, the ciphertext files generated by GpgFrontend are all in ASCII format. But starting from v2.0.4,
+GpgFrontend will generate ciphertext files in binary format by default. you can change this setting in settings.
+
+![image-20220112073548736](_media/encrypt-decrypt-file/image-20220112073548736.png)
+
+## File Browser
+
+In the top menu file option, you can open the file browser(Ctrl/Command + B). Then by using the file browser, first
+enter your working directory. Then right-click the file you need to operate, and then select the operation you want in
+the pop-up menu.
+
+![image-20220112072034647](_media/encrypt-decrypt-file/image-20220112072034647.png)
+
+There are two control buttons at the top of the file tab. The one on the left is the up level, and the one on the right
+is to enter or refresh the corresponding path in the input box on the left.
+
+On the far right is a button with useful options that you can tick to show system files or hidden files.
+
+![image-20220112072335503](_media/encrypt-decrypt-file/image-20220112072335503.png)
+
+### Encrypt & Sign
+
+This method provides encryption and signature functions, which GpgFrontend recommend, so that the receiver can know that
+the ciphertext comes from you. You can select one or more recipients' public key and your own private key to complete
+this operation.
+
+This operation generates a file with the gpg extension. The file with this suffix contains both encrypted content and
+signed content.
+
+![Peek 2022-01-12 07-26](_media/encrypt-decrypt-file/Peek-2022-01-12-07-26.gif)
+
+### Decrypt & Verify
+
+This ciphertext is verified while decrypting, which can improve security. In addition, you can also perform Only Verify
+operations and this operation will verify without decryption. To use this operation, you need to select a file with a
+gpg or asc extension, which contains the ciphertext and signature content.
+
+In order to encourage users to check whether the ciphertext is signed or not when decrypting, Gpg Frontend does not
+provide a separate decryption operation here.
+
+![Peek 2022-01-12 07-24](_media/encrypt-decrypt-file/Peek-2022-01-12-07-24.gif)
diff --git a/manual/manual/encrypt-decrypt-text.md b/manual/manual/encrypt-decrypt-text.md
new file mode 100644
index 00000000..ad36880a
--- /dev/null
+++ b/manual/manual/encrypt-decrypt-text.md
@@ -0,0 +1,83 @@
+# Encrypt & Decrypt Text
+
+To start encryption and decryption operations, you need to prepare your plain text. In addition, you also need a public
+key that can perform encryption operations. How to generate such a key can be found in the chapter on generating a key
+pair.
+
+## Encrypt
+
+The Encrypt operation itself uses a public key and does not require a private key. Remember that whoever you want to
+send it to encrypts it with whose public key. For people who don't use gpg very often, they often get confused and use
+their own keys to encrypt ciphertext.
+
+Note that if you want to encrypt your text and send it to "foo", you need to know foo's public key first. Then you need
+to encrypt your text with foo's public key instead of using your public key. Before encrypting, check to see if the
+public key has cryptographic capabilities. This can be viewed in the usage column of the key toolbox (the letter E
+stands for encryption).
+
+It is worth mentioning that if you only use foo's public key to encrypt the ciphertext, no one but foo's own private key
+can decrypt the ciphertext. There is a situation where you want ciphertexts to be decrypted by multiple people (
+including yourself), please check their corresponding public keys before doing so. After an encryption operation, if you
+misuse (some people's public keys are found to be missing), you can use the undo operation to restore your original
+ciphertext before closing GpgFrontend.
+
+### Only Encrypt
+
+In this case, you only encrypt the ciphertext, and the ciphertext will be shorter. Because in operation, the ciphertext
+does not contain additional signature information to determine the identity of the encryptor. If you don't want to
+receive your graphemes knowing your identity, use this method to generate your ciphertexts.
+
+After the encrypted operation, there is no additional information display in the information board except for the prompt
+of whether the operation is successful.
+
+![Peek 2022-01-12 07-16](_media/encrypt-decrypt-text/Peek 2022-01-12 07-16.gif)
+
+### Encrypt Sign
+
+By encrypting and signing at the same time, not only can the text be protected, but the recipient can also know that
+thecipher text is from your hand. This encryption is often used in scenarios where both parties need to ensure that the
+decrypted text is credible, and in general, in that scenario, the upper reaches know each other. The ciphertext
+generated by this operation is longer because of the additional signature information attached to it.
+
+Before doing so, you only need to select the public key(s) you need to use for encryption. Halfway through the
+encryption operation, you'll be asked to choose the private key you need to use for signing. That is, the signer. If you
+don't find the key you want in the Signaler list, confirm that your private key can be used for encryption and is valid.
+To check whether the key can be used for signing, please check the usage column in the key toolbox on the right (letter
+S stands for signature). You can select the public key to use for encryption, or you can select the public key to use
+for signing.
+
+For this type of ciphertext, you can use the validate operation to see if the ciphertext is trustworthy before
+decryption.
+
+When the operation is complete, information about the cryptographic operation and the signature operation is displayed
+in the Infomation Board. You can view information about the signature, such as the pattern of your signature and the
+algorithm used (you can indirectly see which subkey you used to sign). Please note the distinction between the dates
+used in your signature messages in UTC and not your local time.
+
+![GIF](https://github.com/saturneric/Blob/blob/master/gif/encrypt-sign.gif?raw=true)
+
+## Decrypt
+
+Paste the ciphertext you obtained directly, gpg will automatically select the appropriate key in the list for
+decryption. Always remember to decrypt with the private key.
+
+![Peek 2022-01-12 07-18](_media/encrypt-decrypt-text/Peek-2022-01-12-07-18.gif)
+
+Whether a key pair can be used for decryption will not be displayed in the usage column. You only need to remember that
+a valid private key can be used to decrypt the ciphertext encrypted with the related public key.
+
+Regarding whether this key is a public key or a private key, you can check the type column in the key toolbox. However,
+you do not need to check the corresponding key before decryption. And when all your local keys cannot be used for
+decryption, the program will prompt decryption failure.
+
+## Decrypt Verify
+
+While decrypting, you can learn some information about the encryptor of the key (if you signed it during encryption).
+
+Whether a key pair can be used for verification will not be displayed in the usage column, you only need to remember a
+valid public key can be used for verification.
+
+This is a good habit regardless of whether the encryptor has signed in advance. Because you cannot infer from the format
+of the ciphertext whether it has been signed or not. So, use decryption operations with verification whenever possible.
+
+![Peek 2022-01-12 07-10](_media/sign-verify-text/Peek-2022-01-12-07-10.gif)
diff --git a/manual/manual/generate-key.md b/manual/manual/generate-key.md
new file mode 100644
index 00000000..848e6a8c
--- /dev/null
+++ b/manual/manual/generate-key.md
@@ -0,0 +1,118 @@
+# Generate Key Pair & Subkey
+
+For GpgFrontend, to understand the key, you must first understand two concepts: key pair and subkey.
+
+A key pair can be compared to a key ring. When it is generated, there is a key in the ring called the primary key. This
+primary key can do the intended operation (encryption, decryption, etc.). At the same time, keep this in mind, only
+through the primary key can you open the keychain to add new keys to it.
+
+The sub-keys can be analogous to the keys you add to the key pair later, and each of them can independently perform
+operations such as encryption and decryption. It can be considered that the primary key mentioned above is a special
+subkey.
+
+When there is no primary key in the key pair, you will not be able to open the key ring to add a new sub key, but you
+can still use this sub key if it is changed to exist for your operations. This mechanism is very helpful to the security
+of the key.
+
+Let's see how to generate them next.
+
+## Generate Key Pair
+
+You can quickly grasp the operation of generating a key pair through the following animation.
+
+![GIF](https://github.com/saturneric/Blob/blob/master/gif/generate-key-pair.gif?raw=true)
+
+### Name & Email & Comment
+
+These three fields are used to facilitate people to distinguish this key pair from the card key pair. For these three
+options, except for name and email, which are required, comments are optional.
+
+In addition, the length of the name is required to be greater than 5 letters, as long as the email conforms to the
+format (no actual existence is required).
+
+![uid](https://github.com/saturneric/Blob/blob/master/screenshots/uid.png?raw=true)
+
+### Expiration Date
+
+You can set an expiration date for the key pair. After this date, the key may still be used normally, but the operation
+it does will be logically invalid (especially for signature operations). GpgFrontend recommends and defaults this date
+to two years later. If you wish, check the Never expire checkbox to make this key pair never expire.
+
+But don't worry, you can change this option at any time after generation, even long after the expiration date (as long
+as the primary key exists).
+
+![expiration-date](https://github.com/saturneric/Blob/blob/master/screenshots/expriation-date.png?raw=true)
+
+### Key Size & Algo
+
+These two options are related. In general, different encryption algorithms have different optional lengths. GpgFrontend
+will give you sufficient hints on the UI so that you will not go wrong.
+
+Just remember that the larger the key length, the more secure, but it will be slower when performing operations.
+
+![keysize-algo](https://github.com/saturneric/Blob/blob/master/screenshots/keysize-algo.png?raw=true)
+
+### Passphrase
+
+You can set a key to protect the primary key, which is very important when the primary key is leaked. When the Do not
+set password check box is not checked, an interface for you to enter the password will pop up during the process of
+generating the password. Just follow the prompts. After setting the password, when you need to use the primary key for
+operation, you may enter the password to unlock it
+(some systems have a password networkAccessManager to take over this process).
+
+You can also check the checkbox to not set a protection password for the primary key, but due to security
+considerations, this is not recommended.
+
+### Usage
+
+In the option of generating a key pair, you can specify the usage for the first subkey of the key pair, which is the
+primary key. There are four options:
+
+![usages](https://github.com/saturneric/Blob/blob/master/screenshots/usages.png?raw=true)
+
+- Encryption: After generation, it can be used for encryption operations.
+
+- Signing: After generation, it can be used for signature operations.
+
+- Certification: Popular understanding can be used to unlock this key ring (key pair). Only the primary key can check
+ this function.
+
+- Authentication: It can perform authentication operations like SSH keys.
+
+The third of these four uses (authentication purposes) can only be owned by the primary key. In addition, some usages
+are not available when using certain algorithms for encryption. For example, when the DSA algorithm is selected, the
+encryption uses are disabled.
+
+## Generate Subkey
+
+We can add sub-keys to the generated key pair. The subkey does not need to fill in the name, email and comment options.
+The rest is basically the same as generating the key pair.
+
+![GIF](https://github.com/saturneric/Blob/blob/master/gif/generate-subkey.gif?raw=true)
+
+### Extra note
+
+Here are some tips you might want to know. These tips will help you better understand the above concepts and use this
+tool correctly.
+
+#### primary key & Subkey
+
+A key pair can have multiple subkeys and one primary key. Using this design reduces the risk of key leakage. For subkey,
+After the subkey is leaked, you can revoke it at any time to reduce the loss. However, when the primary key is leaked,
+the entire key pair will be insecure (the popular reason is that the main force can be used to manage this key pair).
+
+Therefore, the recommended approach is to generate multiple subkeys after creating the key pair, and export the master
+key separately and store it in a safe place. This operation is not yet supported by GpgFrontend, you need to use the gpg
+command to perform it. But gpgfrontend can identify and prompt the user whether the primary key exists or not. This is
+very important, because some special operations (adding subkeys, signing other keys, etc.) cannot be performed without
+the primary key.
+
+#### Some practical tips
+
+The purpose of the primary key cannot be changed after it is generated. If the primary key of this key pair does not
+have a certain purpose, but a certain sub-key has this purpose, this key pair can still be used for operations
+corresponding to this purpose.
+
+For example, when you generated the key pair, you didn't check the encryption usage. Don't worry, you can generate a
+subkey and check the encryption usage. In this way, this key pair can still perform encryption operations.
+
diff --git a/manual/manual/import-export-key-pair.md b/manual/manual/import-export-key-pair.md
new file mode 100644
index 00000000..96e5ee35
--- /dev/null
+++ b/manual/manual/import-export-key-pair.md
@@ -0,0 +1,100 @@
+# Import & Export Key Pair
+
+GpgFrontend provides multiple ways for users to import or export key paris. Here we will introduce some classic
+operations. Read the guide.
+
+## Import Key Pair
+
+You can find the import options in the toolbar. You can choose several import methods according to your actual
+situation. Let’s introduce these methods.
+
+![image-20220110194143231](_media/import-export-key-pair/image-20220110194143231.png)
+
+In fact, you can find this action menu in key management, and here you can do more actions.
+
+![image-20220110200530182](_media/import-export-key-pair/image-20220110200530182.png)
+
+### File
+
+When you select this option, you need to select a public key or private key file that meets the standard. The file you
+choose should be in text format, with any extension.
+
+### Editor
+
+You can paste the contents of the key file on a blank text label page. Then click this option, GpgFrontend will
+automatically recognize and import the corresponding key.
+
+### Clipboard
+
+You can copy the contents of the key to your system clipboard somewhere else. Then, after selecting this option, the
+corresponding key will be imported.
+
+### Keyserver
+
+After selecting this option, you can enter the email or ID corresponding to the key in the pop-up selection, and then
+select the appropriate key server. Then after clicking the search button, GpgFrontend will list the public keys that can
+be imported in the key server. You can import them together, or you can choose to double-click the table row to import
+the corresponding public key. Note: The keys imported in this way are all public keys.
+
+A detailed description of this part can be found [Here](./key-server-operations.md).
+
+### Dropdown on Key Toolbox
+
+You can drag the key file directly to the key toolbox, and then follow the prompts of GpgFrontend to import the key.
+
+## Export Key Pair
+
+Deriving the public key of a key pair with the private key means deriving either the public key or the private key or
+both of all the keys present in the key pair. If there are very many keys in the key pair, the exported data will be
+very long. Similar to import, there are multiple export methods.
+
+For Gpg Frontend, the exported data is encoded in ASCII, which ensures data compatibility between computers.
+
+### Export Public Key
+
+you can find this operation in many places.The following will introduce them one by one.
+
+#### Append Public Key to Editor
+
+Right-click a row in the key toolbox, and click Append Select Key(s) to Editor in the pop-up menu item. You will find
+that the public key that the key is right appears at the end of your text label page. You can freely copy the content to
+any place.
+
+#### Export on the Key Pair at Operations Tab
+
+You can do this as shown in the screenshot below, which will store the data to a file. Please select a suitable
+directory to store this file containing the public key data before going anywhere.
+
+![image-20220110194707813](_media/import-export-key-pair/image-20220110194707813.png)
+
+### Export multiple public keys at once
+
+You can export all public key data in multiple key pairs at one time, and you can select the key pairs you want to
+export on the key management interface. Then, you can click Export to Clipboard.
+
+![image-20220110195325342](_media/import-export-key-pair/image-20220110195325342.png)
+
+### Export Private Key
+
+You can find private key options everywhere in the detail's page that contains the private key (primary key or subkey).
+Then you can select a location, and GpgFrontend will export the corresponding private key content to that location
+later.
+
+![image-20220110200109284](_media/import-export-key-pair/image-20220110200109284.png)
+
+Exporting the private key also exports the public key and private key data, because the private key data without the
+public key is meaningless by itself, you cannot deduce the public key from the private key.
+
+Generally speaking, the private key content will be bundled with the public key content to export and export. Please
+note: the private key file can never be disclosed to others. If it is leaked, it means that all ciphertexts encrypted by
+the key are no longer safe.
+
+You can export the private key data in your key pair in two ways.
+
+1. Full export: Include all key data and UID and UID signature in the key pair.
+2. Minimal export: Only all key data in the key pair is included.
+
+### Securely export and transfer as a Key Package
+
+You can package the private key data or public key data of multiple key pairs into a Key Package to allow them to be
+securely transferred between your PC devices. This part of the function will be introduced in the feature. \ No newline at end of file
diff --git a/manual/manual/key-server-operations.md b/manual/manual/key-server-operations.md
new file mode 100644
index 00000000..856b01e6
--- /dev/null
+++ b/manual/manual/key-server-operations.md
@@ -0,0 +1,113 @@
+# Key Server Operations
+
+You want to use encrypted communication, but in some cases, you only know the email address to which your message is
+sent, but you don't know what the public key of the owner of the email address is.
+
+This is one situation, and another situation is that your key is accidentally leaked. How do you notify the person who
+holds your public key to stop using your public key to continue sending you encrypted information? For these people, you
+may not even know their names or contact information. In the above cases, you may be able to use the key server to
+complete the sharing of key information. You can upload your public key information to the key server, or search or pull
+the public key you need from the key server by email address and key ID.
+
+Once the public key information is uploaded to the key server, it will be transmitted between the key servers until
+finally all the key servers store your public key for access by people all over the world.
+
+GpgFrontend provides the ability to interact with the key server. Through mouse operation, you can quickly use the key
+server to share your public key, or search and import the public key you want. It should be noted that once the public
+key information is uploaded to the key server, it means that the public key information cannot be deleted from the key
+server and will always be retained. but when you add a subkey to your key pair, the public key of the old key pair can
+be overwritten by updating.
+
+## Import Public Key From Key Server
+
+In the main page or in the key manager's Import key operation mode, there is a key server option. After selecting this
+option you can see such an interface.
+
+![import-keys-fomr-keyserver](_media/key-server-operations/import-keys-fomr-keyserver.png)
+
+You can get a list of public keys associated with a key server by searching for Key ID, fingerprint or email address via
+the search box. If there is a suitable public key in the list, you can import it by double-clicking it.
+
+![import-keys-fomr-keyserver-1](_media/key-server-operations/import-keys-fomr-keyserver-1.png)
+
+When the import is complete, you can check whether the public key is actually imported through the pop-up window (no
+need to import when the local public key is newer), and you can also check some brief information about the public key.
+
+![image-20220109191357259](_media/key-server-operations/image-20220109191357259.png)
+
+It is worth noting that the public key you imported may be expired or revoked. You can view the status of the key
+through the category tab in the key management interface. In addition to the search box, you also noticed that you can
+choose which key server to grab the public key information from by clicking on the drop-down box. How to set or add this
+candidate list, please refer to the last section of this document: Key server related settings.
+
+## Export My Public Key To The Keyserver
+
+When the current key pair has a master key, you can publish the public key information to the key server. Note that in
+order to be able to let users know what they are actually doing, GpgFrontend specifies that this can only be done if a
+master key exists for the local key pair. This avoids confusion about the function.
+
+### How To Use
+
+You can find the entry of this operation through the operation tab of the key pair detail interface, as shown in the
+following figure.
+
+![image-20220109192532368](_media/key-server-operations/image-20220109192532368.png)
+
+Perform the operation by clicking Upload key pair to key server. Note that the naming of operations here is a bit
+confusing, but this is where your public key information (not your private key) will be uploaded.
+
+### Synchronize public key information from a key server
+
+Sometimes, before you perform an encryption operation, you want to know if the public key you are using is still valid.
+At this point, you can get the latest information about the key from the key server (if the public key server has one).
+
+As above, you can find this action in the Actions tab of the key pair details screen, as shown in the image below.
+
+### Extra Information
+
+Gpg Frontend will upload the public key information to the default key server you set. The private key information is
+not uploaded and should not be manually uploaded anywhere by the user.
+
+Refer to the last section of this document on how to set the default key server.
+
+![image-20220109192532368](_media/key-server-operations/image-20220109192532368.png)
+
+By clicking Synchronize key pair with key server, the public key information can be automatically pulled from the key
+server and compared with the local key information. After the operation is complete, you can check in the pop-up window
+whether the key has actually been updated. It is worth noting that you will not be able to perform this operation if the
+private key exists locally, the reason is that you already have the key pair and you should publish the latest
+information for the key pair instead of accepting outdated information from the key server .
+
+### Extra Information
+
+Gpg Frontend will automatically communicate with the default keyserver you set and get the information it wants. Refer
+to the last section of this document on how to set the default key server.
+
+## Sync ALL Public Key
+
+This is an advanced function provided by Gpg Frontend, it can synchronize all your local public key information at one
+time, if you want to know, please read [this document](../features/sync-all-public-keys.md).
+
+## Key Server Related Settings
+
+如何What about setting a list of keyservers? Or set a default keyserver? At this point, you need to open the Settings
+interface and find the Key Servers tab. Here you can see operations related to the key server candidate list, and see
+which key server is the default key server.
+
+![image-20220109195518834](_media/key-server-operations/image-20220109195518834.png)
+
+You can enter the http or https address of the key server you want to add in the input box, and then click Add to add a
+candidate key server. In order to prevent man-in-the-middle attacks, users are strongly recommended to use the https
+protocol. If you want to delete a candidate key server, you can right-click the row of the corresponding key server in
+the table and click Delete in the pop-up menu. If you want to edit an existing candidate key server address, you can
+double-click its address in the table and edit it.
+
+If you want to test the network connectivity of the servers in the key server candidate list, you can click the Test
+button at the bottom. Note that the test here only tells you if the keyserver is reachable, not whether the address is a
+valid keyserver.
+
+### Set Default Key Server
+
+If you want to set a candidate key server as your default key server, you can right-click the row of the corresponding
+key server in the table, and click Set as Default in the pop-up menu. You can see if a candidate keyserver is the
+default keyserver in the first column of the table. \ No newline at end of file
diff --git a/manual/manual/sign-verify-file.md b/manual/manual/sign-verify-file.md
new file mode 100755
index 00000000..b62d62ae
--- /dev/null
+++ b/manual/manual/sign-verify-file.md
@@ -0,0 +1,48 @@
+# Sign & Verify File
+
+Gpg Frontend provides a convenient and fast way to operate on files. The concept of signing and verifying files is
+almost the same as text, except that the input and output of file operations can be binary.
+
+## File Extension Introduction
+
+For ciphertext in ASCII format, its filename suffix is usually asc, and you can directly open such files with a text
+editor. However, if the ciphertext is binary, its file extension will be sig or gpg. Usually, binary ciphertext files
+are smaller than ASCII format.
+
+Before v2.0.4, the ciphertext files generated by GpgFrontend are all in ASCII format. But starting from v2.0.4,
+GpgFrontend will generate ciphertext files in binary format by default. you can change this setting in settings.
+
+![image-20220112073548736](_media/encrypt-decrypt-file/image-20220112073548736.png)
+
+## File Browser
+
+In the top menu file option, you can open the file browser(Ctrl/Command + B). Then by using the file browser, first
+enter your working directory. Then right-click the file you need to operate, and then select the operation you want in
+the pop-up menu.
+
+![image-20220112072034647](_media/encrypt-decrypt-file/image-20220112072034647.png)
+
+There are two control buttons at the top of the file tab. The one on the left is the up level, and the one on the right
+is to enter or refresh the corresponding path in the input box on the left.
+
+On the far right is a button with useful options that you can tick to show system files or hidden files.
+
+![image-20220112072335503](_media/encrypt-decrypt-file/image-20220112072335503.png)
+
+### Sign
+
+Through the right-click menu, you can quickly sign a file. This operation will generate a file with a sig or asc suffix,
+which contains the signature content. In this case, you need to pass this file along with the original file so that the
+other party can verify it.
+
+![Peek 2022-01-12 07-39](_media/sign-verify-file/Peek-2022-01-12-07-39.gif)
+
+### Verify
+
+This operation needs to select a file with a gpg suffix (maybe invalid for the ciphertext of a binary file) or a file
+with a sig suffix for verification.
+
+When selecting a file with the sig suffix, make sure that the source file is also in this directory. This means that the
+name of the source file is just missing a sig suffix.
+
+![Peek 2022-01-12 07-40](_media/sign-verify-file/Peek-2022-01-12-07-40.gif) \ No newline at end of file
diff --git a/manual/manual/sign-verify-text.md b/manual/manual/sign-verify-text.md
new file mode 100644
index 00000000..f3ed699f
--- /dev/null
+++ b/manual/manual/sign-verify-text.md
@@ -0,0 +1,46 @@
+# Sign & Verify Text
+
+In general, the process of signing and verifying is the reverse process of encryption and decryption. When signing, the
+private key is used, and when verifying, the public key is used. And just like signing one name after another on a
+document, multiple private keys can be selected when signing. But there are some differences. Digital signatures can be
+used to verify whether the content of the signature has changed, while handwritten signatures are difficult to do.
+
+## Only Sign
+
+By signing the text, you can show that you are the only and unchangeable certification with this text. You can just sign
+the text without encrypting the text like the following.
+
+![Peek 2022-01-12 06-50](_media/sign-verify-text/Peek-2022-01-12-06-50.gif)
+
+To check whether the key can be used for signing, please check the usage column in the key toolbox on the right (letter
+S stands for signature).
+
+## Sign With Encrypt
+
+You can also encrypt this short text while signing, which is equivalent to signing while encrypting. A typical usage
+method is to check two key pairs, one is someone else's public key, which is used for encryption; the other is your own
+private key, which is used for signing. If you do not check any key that can be used for signing, this is possible (
+equivalent to encryption only). The only difference is that you will receive a warning.
+
+![Peek 2022-01-12 06-54](_media/sign-verify-text/Peek-2022-01-12-06-54-16419417228411.gif)
+
+## Verify
+
+After obtaining a plaintext and its signature, you can verify the signature. Please keep in mind that this form of
+signature is not suitable for use in emails as it will make the email less readable, if you need to sign your email,
+please use the "New Message" function to generate the OpenPGP/MIME format sign for your email.
+
+![Peek 2022-01-12 06-56](_media/sign-verify-text/Peek-2022-01-12-06-56.gif)
+
+To verify a signature with text, you need to have the corresponding public key for all included signatures. If a
+suitable public key for a signature is not found locally during verification, Gpg Frontend will remind you to import it.
+
+![image-20220112070325556](_media/sign-verify-text/image-20220112070325556.png)
+
+## Verify With Decrypt
+
+After obtaining a ciphertext, you can try to verify it while decrypting it. This is a good habit regardless of whether
+the encryptor has signed in advance. Because you cannot infer from the format of the ciphertext whether it has been
+signed or not. So, use decryption operations with verification whenever possible.
+
+![Peek 2022-01-12 07-10](_media/sign-verify-text/Peek-2022-01-12-07-10.gif)
diff --git a/manual/manual/understand-interface.md b/manual/manual/understand-interface.md
new file mode 100644
index 00000000..fcbc269c
--- /dev/null
+++ b/manual/manual/understand-interface.md
@@ -0,0 +1,134 @@
+# Understand Interface
+
+As a novice, you only need to quickly grasp the meaning of a few important parts of the page. You will gradually
+discover other functions in the next exploration. The interface may not be the same for different versions.
+
+![Interface](https://github.com/saturneric/Blob/blob/master/screenshots/interface-introduce.png?raw=true)
+
+## Text Editor
+
+In the text editing area, you can type text at will. Or create a new tab through the New option in the top file menu.
+Tabs can be moved, closed, and so on.
+
+You can operate your text through the options in the Operations Bar. Or you can use some common shortcuts(ctrl+c/v/s) to
+copy-paste save or even find operations.
+
+The text edited in the text box is UTF8 encoded and does not have any formatting. Not providing any formatting (plain
+text) ensures that the reality of redaction in a message is not confusing. I plan to join rich text editors in the
+future, but the details are still under consideration.
+
+### Large text file support
+
+Here, GpgFrontend supports opening some of the larger files without being stuck. However, when opening a relatively
+large file, you cannot edit this tab until the file has been totally read. Although this will make you unable to edit
+the file, you can still view it.
+
+## Information Board
+
+The result of your operation on the current tab page will be printed in the Information Board: success or failure. In
+addition to the success and failure information, its text will also contain other information to help you understand the
+details of your encryption, decryption, signature and other operations. Depending on your language settings, the output
+in the dashboard will vary.
+
+I used the information board as a solution to be able to display more information in the same space. In the future, a
+graphical interface display of this information will be introduced, which can help users understand the actual role of
+this information.
+
+### Font Color
+
+- **Green**: When the operation succeeds and the results of the operation are verified and no problems are found, the
+ font color will be green.
+- **Yellow**: When the operation succeeds and there are some problems with the result testing of the operation at that
+ time, the font turns yellow, which is a reminder to the user. At this time, the user needs to check the details of the
+ operation.
+- **Red**: When the operation is unsuccessful or there is a serious conflict with the result of the operation, the font
+ color will turn red, and the user will need to carefully check the details of the operation to ensure security.
+
+### Font Size
+
+When you feel that the font of the information board is too small, you can set the font size in the Application column
+of the settings. The font size defaults to 10 and can be set to a range of between 9 and 18.
+
+### Information Board Actions Menu
+
+The dashboard actions menu provides some commonly used actions for information board content. This enables users to
+quickly record large pieces of content in the Information Board for other uses.
+
+#### Copy
+
+This enables users to quickly record large pieces of content in the Information Board for other uses.
+
+#### Save File
+
+The operation stores the contents of the information board in the file system in UTF-8 format. Although the output file
+does not have a suffix name, in fact this file is in plain text format.
+
+#### Clear
+
+This action immediately empties the information board. The empty operation includes the contents of the information
+board and all the statuses. The emptying operation occurs automatically when you make the next operation (encryption,
+etc.).
+
+### Optional Actions Menu
+
+There will also be a column of Optional Actions Menu below the Information Board. If there are other auxiliary
+operations that can be done after your operation is completed (display more detailed information, send encrypted text
+through email, etc.), the entry points for these auxiliary operations will be displayed here.
+
+## Key ToolBox
+
+Here is a list of key pairs stored on your machine that can be used for Gpg operations. The key lists in the Toolbox
+have multiple categories that correspond to different usage scenarios. The toolbox also provides some commonly used
+operations, all of which are in the Key List Menu.
+
+### Usage
+
+Most operations related to Gpg need to specify a key pair (such as encryption, decryption, signature, etc.). You can
+select the check box in the first column of the table in the key toolbox to specify one or more keys for your operation.
+Classifications that contain only public keys are often used in cryptographic scenarios.
+
+### Classification
+
+The Toolbox provides a categorical display through tabs. All classifications do not include all expired or revoked keys.
+If you want to view expired or revoked keys, use the Key Manager. The default classification contains all private and
+public keys. The operation takes only the key from the currently selected classification as input.
+
+### Columns
+
+It is important to understand this list. Now let me take you to understand it step by step.
+
+- Select: Turn the checkbox in this column to let Gpg Frontend know that you specify the key of this row for your next
+ operation.
+
+- Type: See this column to let you know the type of key and whether the primary key exists in your key pair.
+ - `pub` means this is a public key, Can be used for encryption or verification operations.
+ - `pub/sec` The key pair contains both public and private keys. It can be used for almost all operations(Need to
+ combine the usage column to determine this).
+ - `pub/sec#` The key pair contains a public key and a private key, but the primary key is not in the key pair. This
+ shows that you will not be able to do some special (add subkeys, sign other key pairs, etc.)
+ - `pub/sec^` A key pair has one or more keys (subkeys or master keys) in the smart card.
+ - `pub/sec#^`The above two situations occur at the same time.
+- Name: The identity information of the key pair.
+- Email Address: The identity information of the key pair.
+- Usage: This determines which operations the key pair can use. Composed of four capital letters, each capital letter
+ represents a usage.
+ - `C` Certificate. Generally, the key pair that contains the primary key will have this usage
+ - `E` Encrypt. The key pair can be used for encryption operations.
+ - `S` Sign. The key pair can be used for sign operations.
+ - `A` Authenticate. The key pair can be used to perform operations like SSH authentication.
+
+- Validity: One of the concepts of Gpg, simply put it represents the degree of trust in this key.
+
+## Operations Bar
+
+Here, you can perform corresponding operations by clicking the buttons above. For example, after typing text in a text
+editor and setting the key you want to use in the key toolbox, you can click the encryption button to perform the
+operation.
+
+Some operations need to specify the key, and some are not used, which will be explained in other corresponding parts of
+the document.
+
+### Customize
+
+Some operations you may not use for a long time, at which point you can uncheck the relevant function group in the view
+of the top menu. Conversely, for some of the operations you use frequently, you can also add here. \ No newline at end of file
diff --git a/manual/manual/view-keypair-info.md b/manual/manual/view-keypair-info.md
new file mode 100644
index 00000000..008f8d37
--- /dev/null
+++ b/manual/manual/view-keypair-info.md
@@ -0,0 +1,174 @@
+# View Key Pair Details
+
+Right-click the key pair in the key toolbox or key management interface and click Show key details to view the
+information about the key pair.
+
+This part may involve a brief introduction to gpg-related concepts, and it will be relatively long.
+
+The screenshot below is my friend's public key that I got from the key server.
+
+![image-20220110185144734](_media/view-keypair-info/image-20220110185144734.png)
+
+Below is a private key I randomly generated. You can find that the biggest difference between him and the above is that
+the key pair with only the public key is only used for encryption, and if you have the private key, you can do more
+things (it also depends on your algorithm, DSA can only for signature).
+
+![image-20220110185215204](_media/view-keypair-info/image-20220110185215204.png)
+
+## General Info
+
+This interface provides some useful information to assist you in proper management of the key pair.
+
+### Owner
+
+Through this section, you can understand the owner of this key pair. This information is not fixed and unchangeable. You
+can create a new UID in the UID section and set it as the main UID to change it.
+
+According to the OpenPGP protocol, this part is divided into Name, Email, and Comment.
+
+![image-20220110185740491](_media/view-keypair-info/image-20220110185740491.png)
+
+### Primary key
+
+This part is the information of the primary key of the key pair. The primary key is very important, because without it,
+the key pair cannot perform related management operations such as adding and revoking sub-keys (similar to the key ring
+cannot be opened). Let's introduce the information of the primary key separately below. If you want to learn more, see
+the [Basic Concepts](../basic-concepts.md) section.
+
+The absence of the master key means that the private key of the master key does not exist, but neither the public key
+nor the private key exists. Please remember: Each subkey and primary key consists of a pair of public and private keys.
+
+![image-20220110185819775](_media/view-keypair-info/image-20220110185819775.png)
+
+#### Key ID
+
+The unique identifier of the key is fixed and unchanging. Note that this key ID is the key ID of the primary key. The
+key ID is uniquely determined after the key is generated. Compared with the fingerprint, the key ID will be shorter and
+more user-friendly.
+
+#### Algorithm
+
+Algorithm used for key generation. Note that this also refers to the generation algorithm of the primary key. The
+generation algorithm determines the properties and capabilities of the key. Algorithms such as RSA can be used for
+encryption and signature, but DSA can only be used for signature, but the DSA key length can be shorter.
+
+#### Key Size
+
+The length of the primary key. It can be said that the longer the key, the harder it is to crack the ciphertext, but at
+the same time, the more time it takes for a single operation. Generally speaking, a length of 2048 bits is safe enough (
+This refers to the key generated using the RSA algorithm).
+
+#### Normal Usage
+
+What can the key pair conceptually be used for (including the conceptual usage of the primary key and sub-key). When the
+primary key or subkey generation can be used to sign, but it has already expired or does not exist, the signature usage
+will still be displayed here.
+
+#### Actual Usage
+
+The actual usage of the primary key and all subkeys. It is the union of their usage. If there is only one primary key in
+the key pair that can be used for signing, but this primary key does not exist. Then the signature usage will not appear
+here, only in Normal Usage. In addition, when there is only one subkey that can be used for signing, if it has expired,
+the signature purpose will not be displayed here.
+
+#### Expires on
+
+The expiration time of the primary key. When the primary key expires, it will be invalid. You cannot use it for any
+operation. In addition, the subkeys in the key pair will also be unavailable. Fortunately, you can change the expiration
+time of the primary key at any time, or even set it to never expire. The prerequisite for this is that the primary key
+exists in the key pair.
+
+#### Last Update
+
+The time when the content of the key pair was last updated. Operations such as adding a UID or subkey will modify the
+content of the key pair.
+
+#### Secret Key Existence
+
+Shows whether the actual content of the primary key exists. When the primary key does not exist, if there are still
+available subkeys in the key pair, the key pair can still be used for normal operations. However, in the above case, the
+content of the key pair cannot be modified (that is, operations such as adding UID or subkey cannot be performed), and
+the key pair cannot sign other key pairs.
+
+### Fingerprint
+
+![image-20220110190639502](_media/view-keypair-info/image-20220110190639502.png)
+
+The fingerprint of the key pair is used for humans to quickly compare whether the key pair is the expected key pair.
+This field is unique for all keys in the world. You can absolutely do this with the key ID mentioned above.
+
+This also refers to the fingerprint of the primary key.
+
+## UID Info
+
+UID is used to identify the key, and this mechanism is mainly used to facilitate human identification. You can compare
+the UID to the accompanying name tag on a key ring, indicating who the key ring belongs to. Humans can roughly identify
+whether a key pair is what he expected by looking at the UID, but to accurately identify it, fingerprints or key id need
+to be compared. A key can have one or more UIDs. A key pair has one and only one primary UID.
+
+The primary UID on the interface is always the first in the list.
+
+![image-20220110190943207](_media/view-keypair-info/image-20220110190943207.png)
+
+UID has three elements, Name, Email, Comment. The name must be greater than or equal to five characters, and the email
+must conform to the format. Comment rules are relatively loose.
+
+### Signature of UID
+
+The bottom half of the interface is the signature of the UID you checked in the list of UIDs (not checked in the box).
+
+This is a key trust system. The person who gets your public key actually gets a copy of your key ring, but only the
+public key and your nameplate are on the key ring. He can sign your brand with his private key, which means he
+recognizes your brand and the public key on the entire key ring. He can then upload the keyring with his signature to
+the keyserver, and if a lot of people do this one after another, the public key on the keyserver will have a bunch of
+signatures. If there are a lot of signatures on the nameplate, it means that many people recognize the public key and
+endorse it, so that the public key can be trusted by everyone.
+
+You can use the primary key of another key pair to sign a UID. In repeating, in general. When the primary UID of a key
+pair has many valid signatures attached, it will be more trustworthy than without a valid key pair.
+
+## Subkey Info
+
+The sub-key mechanism is an important content of gpg, which enhances flexibility and security, but also brings a certain
+degree of complexity, making it difficult for beginners to understand.If you have absolutely no idea about this, you can
+refer to the [Basic Concepts](../basic-concepts.md) section first.
+
+![image-20220110192348006](_media/view-keypair-info/image-20220110192348006.png)
+
+In order to help you understand this concept and get a preliminary grasp, you only need to read the following points:
+
+- A key pair can be compared to a key ring, with a primary key(a pair of public and private keys) and multiple subkeys (
+ or no subkeys).
+- Each subkey and primary key consists of a pair of public and private keys.
+- The sub-key can do relate operations (such as signing, encryption) when the primary key is not present or cannot.
+- The functions of the sub-keys can overlap. When both sub-keys can be used for signing, the earliest generated one is
+ selected for this operation.
+- The sub-key can use more algorithms than the primary key, but generally they have the same effect on daily operations.
+- The disclosure of the subkey only affects the subkey, and the entire key pair is in danger after the disclosure of the
+ primary key.
+
+The primary key and all subkeys in the key pair are listed on the interface. The first key in the list must be the main
+key, regardless of whether it actually exists or not. Some information about the key is listed below. In fact, you can
+know by observation that the information of the primary key here is exactly the same as the information of the first
+tab.
+
+### Key In smart card
+
+Whether it is in the smart card refers to whether the key is moved to the smart card. Moving the key to the smart card
+will change the structure of the key and is irreversible.
+
+### Operations
+
+In this column, what you can do is different for a key pair that has only a public key or a key pair that includes a
+private key.
+
+Here's what you can do with a public key-only key pair.
+
+![image-20220110193420845](_media/view-keypair-info/image-20220110193420845.png)
+
+And the screenshot below lists what a key pair containing a private key can do.
+
+![image-20220110193555076](_media/view-keypair-info/image-20220110193555076.png)
+
+These operations will be scattered in the documentation to explain in detail.
+
diff --git a/manual/overview.md b/manual/overview.md
new file mode 100644
index 00000000..197ab7f0
--- /dev/null
+++ b/manual/overview.md
@@ -0,0 +1,77 @@
+# Overview of GpgFrontend
+---
+![Language](https://img.shields.io/badge/language-C%2B%2B-green)
+![GitHub release (latest by date)](https://img.shields.io/github/v/release/saturneric/gpgfrontend)
+![License](https://img.shields.io/badge/License-GPL--3.0-orange)
+![CodeSize](https://img.shields.io/github/languages/code-size/saturneric/GpgFrontend)
+[![Codacy Badge](https://app.codacy.com/project/badge/Grade/d1750e052a85430a8f1f84e58a0fceda)](https://www.codacy.com/gh/saturneric/GpgFrontend/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=saturneric/GpgFrontend&amp;utm_campaign=Badge_Grade)
+[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsaturneric%2FGpgFrontend.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsaturneric%2FGpgFrontend?ref=badge_shield)
+
+**GpgFrontend** is a Powerful, Easy-to-Use, Compact, Cross-Platform, and
+Installation-Free [OpenPGP](https://www.openpgp.org/) Crypto Tool.
+
+By using GpgFrontend, you can quickly encrypt and decrypt text or files. Or at the same time as the above operations,
+you can add your own signature to let others know that this document or this paragraph of text was issued by you.
+
+Furthermore, it visualizes most of the common operations of gpg commands. It aims to allow ordinary users to quickly use
+gpg and make professional users more convenient. GpgFrontend supports new features of GnuPG 2.x.
+
+**The corresponding release version for this
+Document: [v2.0.4](https://github.com/saturneric/GpgFrontend/releases/tag/v2.0.4)**
+
+## Interface
+
+Note: For different operating system and system style settings, GpgFrontend may look different.Documentation can also
+vary widely from release to release. Please check the corresponding program release version for the document.
+
+![image-20220109192100901](_media/overview/image-20220109192100901.png)
+
+## Origin
+
+The GpgFrontend project inherit from a relatively mature but not maintained [gpg4usb](https://www.gpg4usb.org/) project.
+It inherits the stable, easy-to-use, compact, and installation-free features of gpg4usb, and plans to support some new
+features of OpenPGP based on it and continue to improve it.
+
+## Purpose
+
+Let more people all over the world (even if they don't know the command line and programming) can use GnuPG to safely
+send information to the destination in a safe way. Free software belongs to the common wealth of all mankind, but there
+are still many people who cannot use these wealths due to the limitation of knowledge and usage habits. We should break
+this pattern. GpgFrontend is committed to improving the ease of use and intuitiveness of the free software GnuPG, so
+that more and more people can use it.
+
+The GpgFrontend project is as open source, and it also insists on using open source codes and libraries.
+
+### Free forever
+
+GpgFrontend will be free forever, and you don't need to worry about being asked to pay a fee to use the software one
+day.
+
+## Source Code
+
+The original code repository of Gpg Frontend is hosted on the server of Codes Dream, and each submission will be
+submitted to the code repository first. You can click [Here](https://global.git.codesdream.com/GpgFrontend.git) to visit
+the original code repository and track development progress.
+
+注意:中国用户请访问[这里](https://git.codesdream.com/GpgFrontend.git)
+
+### License
+
+GpgFrontend source code is under a GPL-3.0 license, which means that GpgFrontend is free software. You may exercise the
+rights set forth in the Licence under the conditions of compliance with the rules of the Licence.
+
+### Contribution
+
+At the same time, the addition of new functions does not affect the old basic functions. My personal strength is always
+limited. GpgFrontend welcomes volunteers to join. You can use the GitHub platform to file an issue, or submit a pull
+request.
+
+You can also submit questions and code contributions by email, please send me problem reports and patches.
+
+## Privacy Guarantee
+
+GpgFrontend has no servers and does not require servers to run. In addition to the public key transfers allowed by the
+OpenPGP protocol to the public key server unexpectedly, GpgFrontend does not collect and upload any additional
+information.
+
+For users with high security requirements, a version with no Internet access capability will be available in the future. \ No newline at end of file
diff --git a/manual/quick-start.md b/manual/quick-start.md
new file mode 100644
index 00000000..f3850100
--- /dev/null
+++ b/manual/quick-start.md
@@ -0,0 +1,123 @@
+# Quick Start
+
+Getting started with GpgFrontend is very simple, you only need a few very simple steps. Moreover, it is oriented to all
+PC platforms.
+
+## Get channels
+
+The current mainstream distribution channel is the Release feature available through GitHub. It's free and accessible to
+most people in the world, without me having to worry about servers and bandwidth, which allows me to save a lot of
+money.
+
+When you click on the [download](https://github.com/saturneric/GpgFrontend/releases/latest), you can see such an
+interface. It identifies the current version number of the latest release, the release date of that version, and so on.
+
+![image-20220101225029218](_media/quick-start/image-20220101225029218.png)
+
+You can see some notable features or fixes for the version in the main text, or if you're a programmer, you can also
+click change log to get how the source code differs from the previous version. It is worth mentioning that you can see
+two green tick marks, which represent that I have personally signed up to the source code of the version. This may be
+important for some people with high security needs.
+
+Then, if you swipe down, you can see a lot of Assets, which are releases for GpgFrontned for different operating
+systems. As you can see, the parts of the file name are separated by separators. You need to know that the second
+section(e.g. 6171479) provides a unique identification number for the version's source code, and when pointing out
+problems with a version, you need to provide the 7-digit unique identification number of the released version you are
+using.
+
+![image-20220101225652736](_media/quick-start/image-20220101225652736.png)
+
+Files with sig as the suffix are gpg separate signatures for the released version of the file of the same name. You can
+use gpg to check if the changed file is signed and approved by me.
+
+Follow your needs or follow the instructions below to click on the name of the corresponding release version to
+download.
+
+## Install & Run
+
+GpgFrontend is cross-platform, which is one of its differences. For your operating system, you'll need to choose
+different ways to lay out GpgFrontend. It is worth noting that GpgFrontend only supports 64-bit operating systems.
+Please check your hardware with your operating system.
+
+### Pre-conditions
+
+GpgFrontend runs dependent on the basic features provided by GnuPG, so you need to install GnuPG before you can install
+GpgFrontend. Why does GpgFronend require users to install GnuPG separately?Starting with GnuPG 2.0, gpg relies on
+separate modules to do all of its functions. This requires that when using gpg, these modules all need to be in the
+correct location on your operating system so that the gpg can find them.
+
+GnuPG is not included by default in some operating systems (e.g. Windows and macOS), so this situation has caused
+GpgFrontend to be temporarily unavailable in the Apple Store and Microsoft Store. I have plans to launch GnuPG-based
+version 1.4 in the future, which will enable GpgFrontend users to start using it when they get it.
+
+In general, the latest Linux distributions offer a GnuPG 2.0 environment. You can check by typing `gpg --version` in the
+command line tool. **In general, it is recommended to install versions of GnuPG 2.1 and above.**
+
+### Windows (No Setup)
+
+0. If you haven't installed gnupg,
+ please [Download](https://gnupg.org/ftp/gcrypt/binary/gnupg-w32-2.3.1_20210420.exe) `gnupg-w32-******.exe` and
+ install it.
+1. [Download](https://github.com/saturneric/GpgFrontend/releases/latest)`GpgFrontend-*******-Windows-NoSetup.zip`
+2. Unzip `GpgFrontend-*******-Windows-NoSetup.zip`
+3. Go into the directory and double click `GpgFrontend.exe`.
+
+### Windows(Setup)
+
+1. [Download](https://github.com/saturneric/GpgFrontend/releases/latest) `GpgFrontend-*******-Windows-Setup.exe`
+2. Install it and you can find GpgFrontend on your desktop.
+
+### macOS
+
+1. [Download](https://github.com/saturneric/GpgFrontend/releases) `GpgFrontend-*******-x86_64.dmg`
+2. Double-Click GpgFrontend.dmg to load it
+ - macOS will automatically decompress the zip file and then you will be able to see the dmg
+3. Double click and run it. All published app packages have passed Apple's check, which means you can open it directly.
+4. If it satisfies you, you can drag it into your Application folder.
+
+#### Debian/Ubuntu/CentOS (AppImage)
+
+AppImage is a format used in Linux systems to distribute portable software without the need for superuser privileges to
+install them. The core idea of AppImage is a file as an application. Each AppImage contains the application and all the
+files needed for the application to run. In other words, in addition to the underlying components of the operating
+system itself, AppImage runs without dependency. This is convenient for users.
+
+0. Install gnupg (If you have already followed please skip)
+ - For Debian/Ubuntu
+ ```shell
+ $ sudo apt update
+ $ sudo apt install gpg
+ ```
+ - For CentOS
+ ```shell
+ $ sudo yum install gnupg
+ ```
+1. [Download](https://github.com/saturneric/GpgFrontend/releases) `GpgFrontend-*******-x86_64.AppImage`
+2. Give `GpgFrontend-***.AppImage` permission to execute
+ ```shell
+ $ chmod u+x ./GpgFrontend-***-x86_64.AppImage
+ ```
+3. Just double-click `GpgFrontend-***-x86_64.AppImage` to run it.
+
+### Debian/Ubuntu (DEB)
+
+With deb, you can easily manage dependencies using the apt tool. Deb packages are small compared to AppImage.
+
+0. Install gnupg (If you have already followed please skip)
+
+ - For Debian/Ubuntu
+
+ ```shell
+ $ sudo apt update
+ $ sudo apt install gpg
+ ```
+
+1. [Download](https://github.com/saturneric/GpgFrontend/releases) `GpgFrontend-*******-x86_64.deb`
+
+2. Use apt to install GpgFrontned.
+
+ ```shell
+ $ apt install ./GpgFrontend-*******-x86_64.deb
+ ```
+
+3. At this point, you can find the GpgFrontend icon in your app menu. \ No newline at end of file
diff --git a/manual/translate-interface.md b/manual/translate-interface.md
new file mode 100644
index 00000000..0238835c
--- /dev/null
+++ b/manual/translate-interface.md
@@ -0,0 +1,37 @@
+# Translate Interface
+
+GpgFrontend is designed to support multiple languages, but requires volunteer contributions to achieve this goal.
+Fortunately, translation work does not require an understanding of difficult technology. Volunteers only need to move
+their fingers to complete.
+
+There are two ways to translate, through a translation tool with a GUI interface or directly through a text editor.
+
+## What you need to know about translation work
+
+From v2.0.1, Gpg Frontend uses the popular translation support
+library [GNU gettext](https://www.gnu.org/software/gettext/) in the GNU project. Before starting everything, you need to
+know something about this library. After you are sure about the content of the document, you can first try to see how
+GpgFrontned uses the tools provided by this library.
+
+### Facts
+
+Most of the translation work is carried out by Google Translate. In most cases, what you have to do is to correct some
+of the bad aspects of Google Translate.
+
+## About translation files
+
+1. Download or clone source code [Here](https://github.com/saturneric/GpgFrontend)
+2. You will find some po files(.po) at path `resource/locale/po`
+2. You will find some template file(.pot) at path `resource/locale/template`
+
+## Before starting your work
+
+In order to facilitate coordination, please contact me via email before you start this work. This is very important,
+please contact me first so that the work you do can be better used by GpgFrontend.
+
+## Hand in your work
+
+You can submit your great work in two ways:
+
+1. Raise a pull request and merge the changed translation file(s) to the repository.
+2. [Email ME](mailto:[email protected]). Please attach the changed ts file on the email. \ No newline at end of file
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d17be5e4..0769f11a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,6 +1,33 @@
+#
+# Copyright (C) 2021 Saturneric
+#
+# This file is part of GpgFrontend.
+#
+# GpgFrontend is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# GpgFrontend is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+#
+# The initial version of the source code is inherited from
+# the gpg4usb project, which is under GPL-3.0-or-later.
+#
+# All the source code of GpgFrontend was modified and released by
+# Saturneric<[email protected]> starting on May 12, 2021.
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+
if (GPG_CORE)
message(STATUS "Build Gpg Core")
- add_subdirectory(gpg)
+ add_subdirectory(core)
endif ()
if (UI_CORE)
@@ -226,86 +253,62 @@ if (APPLICATION_BUILD)
endif ()
+# link options for GpgFrontend
if (APPLICATION_BUILD)
-
- if (ADVANCE_SUPPORT)
- set(GPGFRONTEND_BEFORE_UI_LIBS ${GPGFRONTEND_BEFORE_UI_LIBS} advance)
- endif ()
- if (ADVANCE_SUPPORT)
- set(GPGFRONTEND_BEFORE_UI_LIBS ${GPGFRONTEND_BEFORE_UI_LIBS} server)
- endif ()
-
- set(GPGFRONTEND_LIBS ${GPGFRONTEND_AFTER_UI_LIBS} gpgfrontend_ui gpgfrontend_core ${GPGFRONTEND_BEFORE_UI_LIBS} easyloggingpp)
- set(QT_DEPENDENCY_LIBS Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core)
-
+ target_link_libraries(${AppName} gpgfrontend_ui)
IF (MINGW)
message(STATUS "Link Application Static Library For MINGW")
-
- target_link_libraries(${AppName}
- ${GPGFRONTEND_LIBS}
- ${QT_DEPENDENCY_LIBS}
- ${Boost_LIBRARIES}
- crypto ssl)
+ target_link_libraries(${AppName} crypto)
elseif (APPLE)
message(STATUS "Link Application Static Library For macOS")
- target_link_libraries(${AppName}
- ${GPGFRONTEND_LIBS}
- ${QT_DEPENDENCY_LIBS}
- ${Boost_LIBRARIES}
- crypto ssl intl)
+ target_link_libraries(${AppName} intl)
else ()
- message(STATUS "Link Application Static Library For UNIX ")
- if (APP_IMAGE_UPDATE)
- target_link_libraries(${AppName}
- libappimageupdate)
- endif ()
- target_link_libraries(${AppName}
- ${GPGFRONTEND_LIBS}
- ${QT_DEPENDENCY_LIBS}
- ${Boost_LIBRARIES}
- crypto ssl pthread)
+ message(STATUS "Link Application Static Library For Linux")
+ target_link_libraries(${AppName} crypto pthread)
endif ()
endif ()
-if (LINUX_INSTALL_SOFTWARE)
- if (LINUX)
- if (INSTALL_GPGFRONTEND_APP)
- install(TARGETS ${AppName}
- EXPORT GpgFrontendTargets
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
- )
- install(FILES ${CMAKE_SOURCE_DIR}/TRANSLATORS
- DESTINATION /usr/local/share/${AppName}/)
- install(FILES ${CMAKE_SOURCE_DIR}/resource/meta/pub.gpgfrontend.gpgfrontend.appdata.xml
- DESTINATION /usr/share/metainfo/)
- install(DIRECTORY ${CMAKE_SOURCE_DIR}/resource/desktop/
- DESTINATION /usr/share/applications/)
- install(DIRECTORY ${CMAKE_SOURCE_DIR}/resource/pixmaps/
- DESTINATION /usr/share/pixmaps/)
- install(DIRECTORY ${CMAKE_SOURCE_DIR}/resource/hicolor/
- DESTINATION /usr/share/icons/hicolor/)
- endif ()
- if (MULTI_LANG_SUPPORT)
- install(DIRECTORY ${LOCALE_OUTPUT_PATH}/
- DESTINATION ${CMAKE_INSTALL_FULL_LOCALEDIR})
- endif ()
- if (APP_PACKAGE_DEB)
- message(STATUS "Configure Deb Package")
- SET(CPACK_GENERATOR "DEB")
- set(CPACK_INSTALL_PREFIX "/usr/local/")
- set(CPACK_PACKAGE_NAME "gpgfrontend")
- set(CPACK_DEBIAN_PACKAGE_NAME "gpgfrontend")
- set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
- set(CPACK_PACKAGE_CONTACT "[email protected]")
- SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Saturneric")
- set(CPACK_DEBIAN_PACKAGE_DEPENDS "gpg (>= 2.2), libqt5core5a (>= 5.9), libqt5gui5 (>= 5.9), libqt5widgets5 (>= 5.9), libqt5network5 (>= 5.9), libqt5printsupport5 (>= 5.9), libconfig++-dev (>=1.5)")
- set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
- set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
- set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
- include(CPack)
- endif ()
+# using c++ standard 17
+target_compile_features(${AppName} PUBLIC cxx_std_17)
+
+# if building linux package
+if (LINUX AND LINUX_INSTALL_SOFTWARE)
+ if (INSTALL_GPGFRONTEND_APP)
+ install(TARGETS ${AppName}
+ EXPORT GpgFrontendTargets
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ )
+ install(FILES ${CMAKE_SOURCE_DIR}/TRANSLATORS
+ DESTINATION /usr/local/share/${AppName}/)
+ install(FILES ${CMAKE_SOURCE_DIR}/resource/meta/pub.gpgfrontend.gpgfrontend.appdata.xml
+ DESTINATION /usr/share/metainfo/)
+ install(DIRECTORY ${CMAKE_SOURCE_DIR}/resource/desktop/
+ DESTINATION /usr/share/applications/)
+ install(DIRECTORY ${CMAKE_SOURCE_DIR}/resource/pixmaps/
+ DESTINATION /usr/share/pixmaps/)
+ install(DIRECTORY ${CMAKE_SOURCE_DIR}/resource/hicolor/
+ DESTINATION /usr/share/icons/hicolor/)
+ endif ()
+ if (MULTI_LANG_SUPPORT)
+ install(DIRECTORY ${LOCALE_OUTPUT_PATH}/
+ DESTINATION ${CMAKE_INSTALL_FULL_LOCALEDIR})
+ endif ()
+ if (APP_PACKAGE_DEB)
+ message(STATUS "Configure Deb Package")
+ SET(CPACK_GENERATOR "DEB")
+ set(CPACK_INSTALL_PREFIX "/usr/local/")
+ set(CPACK_PACKAGE_NAME "gpgfrontend")
+ set(CPACK_DEBIAN_PACKAGE_NAME "gpgfrontend")
+ set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
+ set(CPACK_PACKAGE_CONTACT "[email protected]")
+ SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Saturneric")
+ set(CPACK_DEBIAN_PACKAGE_DEPENDS "gpg (>= 2.2), libqt5core5a (>= 5.9), libqt5gui5 (>= 5.9), libqt5widgets5 (>= 5.9), libqt5network5 (>= 5.9), libqt5printsupport5 (>= 5.9), libconfig++-dev (>=1.5)")
+ set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
+ set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
+ set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
+ include(CPack)
endif ()
endif ()
diff --git a/src/GpgFrontend.h.in b/src/GpgFrontend.h.in
index c6ff0518..78ab6e6a 100644
--- a/src/GpgFrontend.h.in
+++ b/src/GpgFrontend.h.in
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,36 +8,46 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef GPGFRONTEND_H_IN
#define GPGFRONTEND_H_IN
-// i18n
+// standard headers
+#include <cstdint>
+#include <optional>
+#include <filesystem>
+
#ifdef WINDOWS
#include <winsock2.h>
#include <windows.h>
#endif
+
+// i18n support
#include <libintl.h>
#define _(String) gettext (String)
#define gettext_noop(String) String
#define N_(String) gettext_noop (String)
+
+// fix macro bugs in mingw
#ifdef WINDOWS
#include <clocale>
#undef vsnprintf
@@ -43,23 +55,28 @@
#undef snprintf
#endif
-// logging
+
+// logging system
#define ELPP_DEFAULT_LOGGING_FLAGS 8192
#include <easylogging++.h>
+
+// build info
#define PROJECT_NAME "@CMAKE_PROJECT_NAME@"
#define OS_PLATFORM @OS_PLATFORM@
#define LOCALE_DIR "@LOCALE_DIR@"
-/**
- * Resources File(s) Path Vars
- */
-#if defined(MACOS) && defined(RELEASE)
+
+// macros to find resource files
+#if defined(MACOS) && defined(RELEASE)
#define RESOURCE_DIR(appDir) (appDir + "/../Resources/")
+#define RESOURCE_DIR_BOOST_PATH(appDir) (appDir / ".." / "Resources")
#elif defined(LINUX) && defined(RELEASE)
#define RESOURCE_DIR(appDir) (appDir + "/../share/")
+#define RESOURCE_DIR_BOOST_PATH(appDir) (appDir / ".." / "share")
#else
#define RESOURCE_DIR(appDir) (appDir)
+#define RESOURCE_DIR_BOOST_PATH(appDir) (appDir)
#endif
#endif // GPGFRONTEND_H_IN
diff --git a/src/GpgFrontendBuildInfo.h.in b/src/GpgFrontendBuildInfo.h.in
index 12bef1b8..eff6e966 100644
--- a/src/GpgFrontendBuildInfo.h.in
+++ b/src/GpgFrontendBuildInfo.h.in
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/src/GpgFrontendBuildInstallInfo.h.in b/src/GpgFrontendBuildInstallInfo.h.in
index 057f30fe..abc1af0f 100644
--- a/src/GpgFrontendBuildInstallInfo.h.in
+++ b/src/GpgFrontendBuildInstallInfo.h.in
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/src/advance/CMakeLists.txt b/src/advance/CMakeLists.txt
deleted file mode 100644
index 696fc8e5..00000000
--- a/src/advance/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-aux_source_directory(. ADVANCE_SOURCE)
-
-add_library(advance STATIC ${ADVANCE_SOURCE})
-
-target_link_libraries(advance
- Qt5::Network Qt5::Widgets Qt5::Core) \ No newline at end of file
diff --git a/src/advance/UnknownSignersChecker.cpp b/src/advance/UnknownSignersChecker.cpp
deleted file mode 100644
index fc70ee20..00000000
--- a/src/advance/UnknownSignersChecker.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#include "advance/UnknownSignersChecker.h"
-
-UnknownSignersChecker::UnknownSignersChecker(GpgFrontend::GpgContext *ctx,
- gpgme_verify_result_t result)
- : appPath(qApp->applicationDirPath()),
- settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini"),
- mCtx(ctx),
- mResult(result) {}
-
-void UnknownSignersChecker::start() {
- auto sign = mResult->signatures;
- bool canContinue = true;
-
- while (sign && canContinue) {
- switch (gpg_err_code(sign->status)) {
- case GPG_ERR_BAD_SIGNATURE:
- break;
- case GPG_ERR_NO_ERROR:
- if (!(sign->status & GPGME_SIGSUM_KEY_MISSING)) check_signer(sign);
- break;
- case GPG_ERR_NO_PUBKEY:
-
- case GPG_ERR_CERT_REVOKED:
- case GPG_ERR_SIG_EXPIRED:
- case GPG_ERR_KEY_EXPIRED:
- check_signer(sign);
- break;
- case GPG_ERR_GENERAL:
- canContinue = false;
- break;
- default:
- break;
- }
- sign = sign->next;
- }
-
- if (!unknownFprs.isEmpty()) {
- PubkeyGetter pubkeyGetter(mCtx, unknownFprs);
- pubkeyGetter.start();
- if (!pubkeyGetter.result()) {
- }
- }
-}
-
-void UnknownSignersChecker::check_signer(gpgme_signature_t sign) {
- auto key = mCtx->getKeyRefByFpr(sign->fpr);
- if (!key.good) {
- qDebug() << "Find Unknown FingerPrint " << sign->fpr;
- unknownFprs.append(sign->fpr);
- }
-}
diff --git a/src/advance/UnknownSignersChecker.h b/src/advance/UnknownSignersChecker.h
deleted file mode 100644
index de07eaf8..00000000
--- a/src/advance/UnknownSignersChecker.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#ifndef GPGFRONTEND_ZH_CN_TS_UNKNOWNSIGNERSCHECKER_H
-#define GPGFRONTEND_ZH_CN_TS_UNKNOWNSIGNERSCHECKER_H
-
-#include "server/api/PubkeyGetter.h"
-
-class UnknownSignersChecker : public QObject {
- Q_OBJECT
- public:
- UnknownSignersChecker(GpgFrontend::GpgContext *ctx,
- gpgme_verify_result_t result);
-
- void start();
-
- private:
- QString appPath;
- QSettings settings;
- GpgFrontend::GpgContext *mCtx;
- gpgme_verify_result_t mResult;
-
- QVector<QString> unknownFprs;
-
- void check_signer(gpgme_signature_t sign);
-};
-
-#endif // GPGFRONTEND_ZH_CN_TS_UNKNOWNSIGNERSCHECKER_H
diff --git a/src/before_exit.cpp b/src/before_exit.cpp
index 074db049..50604a54 100644
--- a/src/before_exit.cpp
+++ b/src/before_exit.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,25 +8,31 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "ui/settings/GlobalSettingStation.h"
+#include "core/function/GlobalSettingStation.h"
+/**
+ * @brief Actions performed before exiting the application
+ *
+ */
void before_exit() {
LOG(INFO) << "called";
- GpgFrontend::UI::GlobalSettingStation::GetInstance().ResetRootCerts();
+ GpgFrontend::GlobalSettingStation::GetInstance().ResetRootCerts();
}
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
new file mode 100644
index 00000000..192e1e0c
--- /dev/null
+++ b/src/core/CMakeLists.txt
@@ -0,0 +1,101 @@
+#
+# Copyright (C) 2021 Saturneric
+#
+# This file is part of GpgFrontend.
+#
+# GpgFrontend is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# GpgFrontend is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+#
+# The initial version of the source code is inherited from
+# the gpg4usb project, which is under GPL-3.0-or-later.
+#
+# All the source code of GpgFrontend was modified and released by
+# Saturneric<[email protected]> starting on May 12, 2021.
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+aux_source_directory(./function/result_analyse GPG_SOURCE)
+aux_source_directory(./function/gpg GPG_SOURCE)
+aux_source_directory(./function/aes GPG_SOURCE)
+aux_source_directory(./function GPG_SOURCE)
+aux_source_directory(./model GPG_SOURCE)
+aux_source_directory(. GPG_SOURCE)
+
+# define libgpgfrontend_core
+add_library(gpgfrontend_core STATIC ${GPG_SOURCE})
+
+set(UTILS_DIR ${CMAKE_SOURCE_DIR}/utils)
+set(GPGME_LIB_DIR ${UTILS_DIR}/gpgme/lib)
+
+# link third-party libraries
+target_link_libraries(gpgfrontend_core easyloggingpp config++)
+# link boost libraries
+target_link_libraries(gpgfrontend_core Boost::date_time Boost::system)
+# link gnupg libraries
+target_link_libraries(gpgfrontend_core gpgme assuan gpg-error)
+# link openssl
+target_link_libraries(gpgfrontend_core OpenSSL::SSL OpenSSL::Crypto)
+# link Qt AES
+target_link_libraries(gpgfrontend_core QtAES)
+# link vmime
+if (NOT LINUX)
+ # macOS
+ target_link_libraries(gpgfrontend_core
+ gpgfrontend_vmime intl iconv)
+ if (MINGW)
+ target_link_libraries(gpgfrontend_core ws2_32)
+ endif ()
+else ()
+ target_link_libraries(gpgfrontend_core
+ gpgfrontend_vmime anl ssl crypto)
+endif ()
+# link libarchive
+if (MINGW)
+ find_library(LIBARCHIVE_LIB libarchive.a)
+ target_link_libraries(gpgfrontend_core ${LIBARCHIVE_LIB} bcrypt lzma bz2 z)
+else ()
+ target_link_libraries(gpgfrontend_core archive_static)
+endif ()
+# link json
+target_link_libraries(gpgfrontend_core
+ nlohmann_json::nlohmann_json)
+# link Qt core
+target_link_libraries(gpgfrontend_core Qt5::Core)
+
+# set up pch
+target_precompile_headers(gpgfrontend_core
+ PUBLIC ${CMAKE_SOURCE_DIR}/src/GpgFrontend.h
+ PUBLIC GpgFrontendCore.h)
+
+# using std c++ 17
+target_compile_features(gpgfrontend_core PUBLIC cxx_std_17)
+
+# link for different platforms
+if (MINGW)
+ message(STATUS "Link GPG Static Library For MINGW")
+ target_link_libraries(gpgfrontend_core wsock32)
+elseif (APPLE)
+ message(STATUS "Link GPG Static Library For macOS")
+ target_link_libraries(gpgfrontend_core dl)
+ if (XCODE_BUILD)
+ set_target_properties(gpgfrontend_core
+ PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
+ endif ()
+else ()
+ # linux
+ message(STATUS "Link GPG Static Library For Unix")
+ target_link_libraries(gpgfrontend_core pthread dl)
+endif ()
diff --git a/src/gpg/GpgConstants.cpp b/src/core/GpgConstants.cpp
index 97fa9f8b..f35c257d 100644
--- a/src/gpg/GpgConstants.cpp
+++ b/src/core/GpgConstants.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,28 +8,29 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/GpgConstants.h"
+#include "core/GpgConstants.h"
#include <gpg-error.h>
#include <boost/algorithm/string/predicate.hpp>
-#include <boost/filesystem.hpp>
#include <string>
const char* GpgFrontend::GpgConstants::PGP_CRYPT_BEGIN =
@@ -43,7 +46,7 @@ const char* GpgFrontend::GpgConstants::PGP_SIGNATURE_BEGIN =
const char* GpgFrontend::GpgConstants::PGP_SIGNATURE_END =
"-----END PGP SIGNATURE-----"; ///<
const char* GpgFrontend::GpgConstants::PGP_PUBLIC_KEY_BEGIN =
- "------BEGIN PGP PUBLIC KEY BLOCK-----"; ///<
+ "-----BEGIN PGP PUBLIC KEY BLOCK-----"; ///<
const char* GpgFrontend::GpgConstants::PGP_PRIVATE_KEY_BEGIN =
"-----BEGIN PGP PRIVATE KEY BLOCK-----"; ///<
const char* GpgFrontend::GpgConstants::GPG_FRONTEND_SHORT_CRYPTO_HEAD =
@@ -112,7 +115,7 @@ static inline std::string trim(std::string& s) {
}
std::string GpgFrontend::read_all_data_in_file(const std::string& utf8_path) {
- using namespace boost::filesystem;
+ using namespace std::filesystem;
class path file_info(utf8_path.c_str());
if (!exists(file_info) || !is_regular_file(file_info)) return {};
std::ifstream in_file;
@@ -131,7 +134,7 @@ std::string GpgFrontend::read_all_data_in_file(const std::string& utf8_path) {
bool GpgFrontend::write_buffer_to_file(const std::string& utf8_path,
const std::string& out_buffer) {
- using namespace boost::filesystem;
+ using namespace std::filesystem;
class path file_info(utf8_path.c_str());
#ifndef WINDOWS
std::ofstream out_file(file_info.string(), std::ios::out | std::ios::trunc);
@@ -147,7 +150,7 @@ bool GpgFrontend::write_buffer_to_file(const std::string& utf8_path,
std::string GpgFrontend::get_file_extension(const std::string& path) {
// Create a path object from given string
- boost::filesystem::path path_obj(path);
+ std::filesystem::path path_obj(path);
// Check if file name in the path object has extension
if (path_obj.has_extension()) {
@@ -160,7 +163,7 @@ std::string GpgFrontend::get_file_extension(const std::string& path) {
std::string GpgFrontend::get_only_file_name_with_path(const std::string& path) {
// Create a path object from given string
- boost::filesystem::path path_obj(path);
+ std::filesystem::path path_obj(path);
// Check if file name in the path object has extension
if (path_obj.has_filename()) {
// Fetch the extension from path object and return
diff --git a/src/gpg/GpgConstants.h b/src/core/GpgConstants.h
index 00156388..8c6977ac 100644
--- a/src/gpg/GpgConstants.h
+++ b/src/core/GpgConstants.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/src/gpg/GpgContext.cpp b/src/core/GpgContext.cpp
index e3f10056..1897202f 100644
--- a/src/gpg/GpgContext.cpp
+++ b/src/core/GpgContext.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,23 +8,25 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/GpgContext.h"
+#include "core/GpgContext.h"
#include <gpg-error.h>
#include <gpgme.h>
diff --git a/src/gpg/GpgContext.h b/src/core/GpgContext.h
index 8ab2cf36..7de6bcad 100644
--- a/src/gpg/GpgContext.h
+++ b/src/core/GpgContext.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/src/gpg/GpgCoreInit.cpp b/src/core/GpgCoreInit.cpp
index 3f07d2b1..6d9963d6 100644
--- a/src/gpg/GpgCoreInit.cpp
+++ b/src/core/GpgCoreInit.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/src/gpg/GpgCoreInit.h b/src/core/GpgCoreInit.h
index 9aa3ed16..5ac804da 100644
--- a/src/gpg/GpgCoreInit.h
+++ b/src/core/GpgCoreInit.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/src/core/GpgFrontendCore.h b/src/core/GpgFrontendCore.h
new file mode 100644
index 00000000..5931695d
--- /dev/null
+++ b/src/core/GpgFrontendCore.h
@@ -0,0 +1,61 @@
+/**
+* Copyright (C) 2021 Saturneric
+*
+* This file is part of GpgFrontend.
+*
+* GpgFrontend is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* GpgFrontend is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+*
+* The initial version of the source code is inherited from
+* the gpg4usb project, which is under GPL-3.0-or-later.
+*
+* All the source code of GpgFrontend was modified and released by
+* Saturneric<[email protected]> starting on May 12, 2021.
+*
+* SPDX-License-Identifier: GPL-3.0-or-later
+*
+ */
+
+#ifndef GPGFRONTEND_GPGFRONTENDCORE_H
+#define GPGFRONTEND_GPGFRONTENDCORE_H
+
+#include "GpgFrontend.h"
+
+// std includes
+#include <filesystem>
+
+// boost includes
+#include <boost/format.hpp>
+
+// Qt includes
+#include <QtCore>
+
+// vmime includes
+#define VMIME_STATIC
+#undef VMIME_HAVE_MLANG
+#include <vmime/vmime.hpp>
+
+// libconfig includes
+#undef LIBCONFIGXX_STATIC
+#define LIBCONFIGXX_STATIC
+#include <libconfig.h++>
+
+
+// libarchive includes
+#include <libarchive/libarchive/archive.h>
+#include <libarchive/libarchive/archive_entry.h>
+
+#include "core/GpgModel.h"
+
+
+#endif // GPGFRONTEND_GPGFRONTENDCORE_H
diff --git a/src/gpg/GpgFunctionObject.h b/src/core/GpgFunctionObject.h
index 03abd77e..391b1585 100644
--- a/src/gpg/GpgFunctionObject.h
+++ b/src/core/GpgFunctionObject.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/src/gpg/GpgGenKeyInfo.cpp b/src/core/GpgGenKeyInfo.cpp
index ec552a80..6ca83c96 100644
--- a/src/gpg/GpgGenKeyInfo.cpp
+++ b/src/core/GpgGenKeyInfo.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,23 +8,25 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/GpgGenKeyInfo.h"
+#include "core/GpgGenKeyInfo.h"
#include <boost/date_time/gregorian/greg_date.hpp>
#include <boost/date_time/gregorian/greg_duration.hpp>
diff --git a/src/gpg/GpgGenKeyInfo.h b/src/core/GpgGenKeyInfo.h
index 2a904930..59ced710 100644
--- a/src/gpg/GpgGenKeyInfo.h
+++ b/src/core/GpgGenKeyInfo.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/src/gpg/GpgInfo.cpp b/src/core/GpgInfo.cpp
index 392dcf08..a77f0ed4 100644
--- a/src/gpg/GpgInfo.cpp
+++ b/src/core/GpgInfo.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,20 +8,22 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/GpgInfo.h"
+#include "core/GpgInfo.h"
diff --git a/src/gpg/GpgInfo.h b/src/core/GpgInfo.h
index 1a6ebaaa..71c5f9a9 100644
--- a/src/gpg/GpgInfo.h
+++ b/src/core/GpgInfo.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -27,6 +31,7 @@
#include <string>
+namespace GpgFrontend {
/**
* @brief Use to record some info about gnupg
*
@@ -40,5 +45,6 @@ class GpgInfo {
std::string CMSPath; ///<
std::string GpgMEVersion; ///<
};
+} // namespace GpgFrontend
#endif // GPGFRONTEND_ZH_CN_TS_GPGINFO_H
diff --git a/src/gpg/GpgModel.h b/src/core/GpgModel.h
index d1866494..e3d43332 100644
--- a/src/gpg/GpgModel.h
+++ b/src/core/GpgModel.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -29,9 +33,9 @@
#include <utility>
#include "GpgConstants.h"
-#include "gpg/model/GpgData.h"
-#include "gpg/model/GpgKey.h"
-#include "gpg/model/GpgSignature.h"
+#include "core/model/GpgData.h"
+#include "core/model/GpgKey.h"
+#include "core/model/GpgSignature.h"
namespace GpgFrontend {
diff --git a/src/core/function/ArchiveFileOperator.cpp b/src/core/function/ArchiveFileOperator.cpp
new file mode 100644
index 00000000..6315dcd5
--- /dev/null
+++ b/src/core/function/ArchiveFileOperator.cpp
@@ -0,0 +1,238 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#include "ArchiveFileOperator.h"
+
+int copy_data(struct archive *ar, struct archive *aw) {
+ int r;
+ const void *buff;
+ size_t size;
+ int64_t offset;
+
+ for (;;) {
+ r = archive_read_data_block(ar, &buff, &size, &offset);
+ if (r == ARCHIVE_EOF)
+ return (ARCHIVE_OK);
+ if (r != ARCHIVE_OK) {
+ LOG(ERROR) << "archive_read_data_block() failed: " << archive_error_string(ar);
+ return (r);
+ }
+ r = archive_write_data_block(aw, buff, size, offset);
+ if (r != ARCHIVE_OK) {
+ LOG(ERROR) << "archive_write_data_block() failed: " << archive_error_string(aw);
+ return (r);
+ }
+ }
+}
+
+void GpgFrontend::ArchiveFileOperator::CreateArchive(
+ const std::filesystem::path &base_path,
+ const std::filesystem::path &archive_path, int compress,
+ const std::vector<std::filesystem::path> &files) {
+ LOG(INFO) << "CreateArchive: " << archive_path.string();
+
+ auto current_base_path_backup = QDir::currentPath();
+ QDir::setCurrent(base_path.string().c_str());
+
+ auto relative_archive_path = std::filesystem::relative(archive_path, base_path);
+
+ std::vector<std::filesystem::path> relative_files;
+ relative_files.reserve(files.size());
+ for(const auto& file : files) {
+ relative_files.push_back(std::filesystem::relative(file, base_path));
+ }
+
+ struct archive *a;
+ struct archive_entry *entry;
+ ssize_t len;
+ int fd;
+
+ LOG(INFO) << "compress: " << compress;
+
+ a = archive_write_new();
+ switch (compress) {
+#ifndef NO_BZIP2_CREATE
+ case 'j':
+ case 'y':
+ archive_write_add_filter_bzip2(a);
+ break;
+#endif
+#ifndef NO_COMPRESS_CREATE
+ case 'Z':
+ archive_write_add_filter_compress(a);
+ break;
+#endif
+#ifndef NO_GZIP_CREATE
+ case 'z':
+ archive_write_add_filter_gzip(a);
+ break;
+#endif
+ default:
+ archive_write_add_filter_none(a);
+ break;
+ }
+ archive_write_set_format_ustar(a);
+ archive_write_set_format_pax_restricted(a);
+
+ auto filename = relative_archive_path.string();
+ if (!filename.empty() && filename == "-")
+ throw std::runtime_error("cannot write to stdout");
+
+ archive_write_open_filename(a, filename.c_str());
+
+ for (const auto &file : relative_files) {
+ struct archive *disk = archive_read_disk_new();
+#ifndef NO_LOOKUP
+ archive_read_disk_set_standard_lookup(disk);
+#endif
+ int r;
+
+ LOG(INFO) << "ReadFile: " << file.string();
+
+ r = archive_read_disk_open(disk, file.string().c_str());
+ if (r != ARCHIVE_OK) {
+ LOG(ERROR) << "archive_read_disk_open() failed: "
+ << archive_error_string(disk);
+ throw std::runtime_error("archive_read_disk_open() failed");
+ }
+
+ for (;;) {
+ bool needcr = false;
+
+ entry = archive_entry_new();
+ r = archive_read_next_header2(disk, entry);
+ if (r == ARCHIVE_EOF) break;
+ if (r != ARCHIVE_OK) {
+ LOG(ERROR) << "archive_read_next_header2() failed: "
+ << archive_error_string(disk);
+ throw std::runtime_error("archive_read_next_header2() failed");
+ }
+ archive_read_disk_descend(disk);
+ LOG(INFO) << "Adding: " << archive_entry_pathname(entry) << "size"
+ << archive_entry_size(entry) << " bytes"
+ << "file type" << archive_entry_filetype(entry);
+ r = archive_write_header(a, entry);
+ if (r < ARCHIVE_OK) {
+ LOG(ERROR) << "archive_write_header() failed: "
+ << archive_error_string(a);
+ throw std::runtime_error("archive_write_header() failed");
+ }
+ if (r == ARCHIVE_FATAL) throw std::runtime_error("archive fatal");
+ if (r > ARCHIVE_FAILED) {
+ ByteArray buff;
+ FileOperator::ReadFileStd(archive_entry_sourcepath(entry), buff);
+ archive_write_data(a, buff.c_str(), buff.size());
+ }
+ archive_entry_free(entry);
+ }
+ archive_read_close(disk);
+ archive_read_free(disk);
+ }
+ archive_write_close(a);
+ archive_write_free(a);
+
+ QDir::setCurrent(current_base_path_backup);
+}
+
+void GpgFrontend::ArchiveFileOperator::ExtractArchive(
+ const std::filesystem::path &archive_path,
+ const std::filesystem::path &base_path) {
+
+ LOG(INFO) << "ExtractArchive: " << archive_path.string();
+
+ auto current_base_path_backup = QDir::currentPath();
+ QDir::setCurrent(base_path.string().c_str());
+
+ struct archive *a;
+ struct archive *ext;
+ struct archive_entry *entry;
+ int r;
+
+ a = archive_read_new();
+ ext = archive_write_disk_new();
+ archive_write_disk_set_options(ext, 0);
+#ifndef NO_BZIP2_EXTRACT
+ archive_read_support_filter_bzip2(a);
+#endif
+#ifndef NO_GZIP_EXTRACT
+ archive_read_support_filter_gzip(a);
+#endif
+#ifndef NO_COMPRESS_EXTRACT
+ archive_read_support_filter_compress(a);
+#endif
+#ifndef NO_TAR_EXTRACT
+ archive_read_support_format_tar(a);
+#endif
+#ifndef NO_CPIO_EXTRACT
+ archive_read_support_format_cpio(a);
+#endif
+#ifndef NO_LOOKUP
+ archive_write_disk_set_standard_lookup(ext);
+#endif
+
+ auto filename = archive_path.string();
+
+ if (!filename.empty() && filename == "-") {
+ LOG(ERROR) << "cannot read from stdin";
+ }
+ if ((r = archive_read_open_filename(a, filename.c_str(), 10240))) {
+ LOG(ERROR) << "archive_read_open_filename() failed: "
+ << archive_error_string(a);
+ throw std::runtime_error("archive_read_open_filename() failed");
+ }
+ for (;;) {
+ r = archive_read_next_header(a, &entry);
+ if (r == ARCHIVE_EOF)
+ break;
+ if (r != ARCHIVE_OK) {
+ LOG(ERROR) << "archive_read_next_header() failed: "
+ << archive_error_string(a);
+ throw std::runtime_error("archive_read_next_header() failed");
+ }
+ LOG(INFO) << "Extracting: " << archive_entry_pathname(entry)
+ << "size" << archive_entry_size(entry) << " bytes"
+ << "file type" << archive_entry_filetype(entry);
+ r = archive_write_header(ext, entry);
+ if (r != ARCHIVE_OK) {
+ LOG(ERROR) << "archive_write_header() failed: "
+ << archive_error_string(ext);
+ } else {
+ r = copy_data(a, ext);
+ if (r != ARCHIVE_OK) {
+ LOG(ERROR) << "copy_data() failed: " << archive_error_string(ext);
+ }
+ }
+ }
+ archive_read_close(a);
+ archive_read_free(a);
+
+ archive_write_close(ext);
+ archive_write_free(ext);
+
+ QDir::setCurrent(current_base_path_backup);
+}
diff --git a/src/core/function/ArchiveFileOperator.h b/src/core/function/ArchiveFileOperator.h
new file mode 100644
index 00000000..8e1d9c44
--- /dev/null
+++ b/src/core/function/ArchiveFileOperator.h
@@ -0,0 +1,79 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#ifndef GPGFRONTEND_ARCHIVEFILEOPERATOR_H
+#define GPGFRONTEND_ARCHIVEFILEOPERATOR_H
+
+#include "core/GpgFrontendCore.h"
+#include "core/function/FileOperator.h"
+
+namespace GpgFrontend {
+
+struct ArchiveStruct {
+ struct archive *archive;
+ struct archive_entry *entry;
+ int fd;
+ bool is_open;
+ std::string name;
+};
+
+class ArchiveFileOperator {
+ public:
+ static void ListArchive(const std::filesystem::path &archive_path) {
+ struct archive *a;
+ struct archive_entry *entry;
+ int r;
+
+ a = archive_read_new();
+ archive_read_support_filter_all(a);
+ archive_read_support_format_all(a);
+ r = archive_read_open_filename(a, archive_path.string().c_str(),
+ 10240); // Note 1
+ if (r != ARCHIVE_OK) return;
+ while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
+ LOG(INFO) << "File: " << archive_entry_pathname(entry);
+ LOG(INFO) << "File Path: " << archive_entry_pathname(entry);
+ archive_read_data_skip(a); // Note 2
+ }
+ r = archive_read_free(a); // Note 3
+ if (r != ARCHIVE_OK) return;
+ }
+
+ static void CreateArchive(
+ const std::filesystem::path &base_path,
+ const std::filesystem::path &archive_path,
+ int compress,
+ const std::vector<std::filesystem::path> &files);
+
+ static void ExtractArchive(
+ const std::filesystem::path &archive_path,
+ const std::filesystem::path &base_path);
+};
+} // namespace GpgFrontend
+
+#endif // GPGFRONTEND_ARCHIVEFILEOPERATOR_H
diff --git a/src/core/function/DataObjectOperator.cpp b/src/core/function/DataObjectOperator.cpp
new file mode 100644
index 00000000..a3f7fc70
--- /dev/null
+++ b/src/core/function/DataObjectOperator.cpp
@@ -0,0 +1,169 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#include "DataObjectOperator.h"
+
+#include <qt-aes/qaesencryption.h>
+
+#include "core/function/FileOperator.h"
+#include "core/function/PassphraseGenerator.h"
+
+void GpgFrontend::DataObjectOperator::init_app_secure_key() {
+ LOG(INFO) << "Initializing application secure key";
+ FileOperator::WriteFileStd(app_secure_key_path_,
+ PassphraseGenerator::GetInstance().Generate(256));
+ std::filesystem::permissions(
+ app_secure_key_path_,
+ std::filesystem::perms::owner_read | std::filesystem::perms::owner_write);
+}
+
+GpgFrontend::DataObjectOperator::DataObjectOperator(int channel)
+ : SingletonFunctionObject<DataObjectOperator>(channel) {
+ if (!is_directory(app_secure_path_)) create_directory(app_secure_path_);
+
+ if (!exists(app_secure_key_path_)) {
+ init_app_secure_key();
+ }
+
+ std::string key;
+ if (!FileOperator::ReadFileStd(app_secure_key_path_.string(), key)) {
+ LOG(FATAL) << _("Failed to read app secure key file")
+ << app_secure_key_path_;
+ throw std::runtime_error(_("Failed to read app secure key file"));
+ }
+ hash_key_ = QCryptographicHash::hash(QByteArray::fromStdString(key),
+ QCryptographicHash::Sha256);
+ LOG(INFO) << "App secure key loaded" << hash_key_.size() << "bytes";
+
+ if (!exists(app_data_objs_path_)) create_directory(app_data_objs_path_);
+}
+
+std::string GpgFrontend::DataObjectOperator::SaveDataObj(
+ const std::string& _key, const nlohmann::json& value) {
+
+ std::string _hash_obj_key = {};
+ if (_key.empty()) {
+ _hash_obj_key =
+ QCryptographicHash::hash(
+ hash_key_ + QByteArray::fromStdString(
+ PassphraseGenerator::GetInstance().Generate(32) +
+ to_iso_extended_string(
+ boost::posix_time::second_clock::local_time())),
+ QCryptographicHash::Sha256)
+ .toHex()
+ .toStdString();
+ } else {
+ _hash_obj_key =
+ QCryptographicHash::hash(hash_key_ + QByteArray::fromStdString(_key),
+ QCryptographicHash::Sha256)
+ .toHex()
+ .toStdString();
+ }
+
+ const auto obj_path = app_data_objs_path_ / _hash_obj_key;
+
+ QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::ECB,
+ QAESEncryption::Padding::ISO);
+ auto encoded =
+ encryption.encode(QByteArray::fromStdString(to_string(value)), hash_key_);
+
+ LOG(INFO) << _("Saving data object") << _hash_obj_key << "to" << obj_path << encoded.size() << "bytes";
+
+ FileOperator::WriteFileStd(obj_path.string(), encoded.toStdString());
+
+ return _key.empty() ? _hash_obj_key : std::string();
+}
+
+std::optional<nlohmann::json> GpgFrontend::DataObjectOperator::GetDataObject(
+ const std::string& _key) {
+ try {
+ LOG(INFO) << _("Get data object") << _key;
+ auto _hash_obj_key =
+ QCryptographicHash::hash(hash_key_ + QByteArray::fromStdString(_key),
+ QCryptographicHash::Sha256)
+ .toHex()
+ .toStdString();
+
+ const auto obj_path = app_data_objs_path_ / _hash_obj_key;
+
+ if (!std::filesystem::exists(obj_path)) {
+ LOG(ERROR) << _("Data object not found") << _key;
+ return {};
+ }
+
+ std::string buffer;
+ if (!FileOperator::ReadFileStd(obj_path.string(), buffer)) {
+ LOG(ERROR) << _("Failed to read data object") << _key;
+ return {};
+ }
+
+ LOG(INFO) << _("Data object found") << _key;
+
+ auto encoded = QByteArray::fromStdString(buffer);
+ QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::ECB,
+ QAESEncryption::Padding::ISO);
+
+ LOG(INFO) << _("Decrypting data object") << encoded.size() << hash_key_.size();
+
+ auto decoded =
+ encryption.removePadding(encryption.decode(encoded, hash_key_));
+
+ LOG(INFO) << _("Data object decoded") << _key;
+
+ return nlohmann::json::parse(decoded.toStdString());
+ } catch (...) {
+ LOG(ERROR) << _("Failed to get data object") << _key;
+ return {};
+ }
+}
+
+std::optional<nlohmann::json>
+GpgFrontend::DataObjectOperator::GetDataObjectByRef(const std::string& _ref) {
+ if (_ref.size() != 64) return {};
+
+ try {
+ const auto& _hash_obj_key = _ref;
+ const auto obj_path = app_data_objs_path_ / _hash_obj_key;
+
+ if (!std::filesystem::exists(obj_path)) return {};
+
+ std::string buffer;
+ if (!FileOperator::ReadFileStd(obj_path.string(), buffer)) return {};
+ auto encoded = QByteArray::fromStdString(buffer);
+
+ QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::ECB,
+ QAESEncryption::Padding::ISO);
+
+ auto decoded =
+ encryption.removePadding(encryption.decode(encoded, hash_key_));
+
+ return nlohmann::json::parse(decoded.toStdString());
+ } catch (...) {
+ return {};
+ }
+}
diff --git a/src/core/function/DataObjectOperator.h b/src/core/function/DataObjectOperator.h
new file mode 100644
index 00000000..0ce4e313
--- /dev/null
+++ b/src/core/function/DataObjectOperator.h
@@ -0,0 +1,82 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#ifndef GPGFRONTEND_DATAOBJECTOPERATOR_H
+#define GPGFRONTEND_DATAOBJECTOPERATOR_H
+
+#include <json/single_include/nlohmann/json.hpp>
+
+#include "core/GpgFrontendCore.h"
+#include "core/GpgFunctionObject.h"
+#include "core/function/GlobalSettingStation.h"
+
+namespace GpgFrontend {
+
+class DataObjectOperator : public SingletonFunctionObject<DataObjectOperator> {
+ public:
+ /**
+ * @brief DataObjectOperator constructor
+ *
+ * @param channel channel
+ */
+ explicit DataObjectOperator(
+ int channel = SingletonFunctionObject::GetDefaultChannel());
+
+ std::string SaveDataObj(const std::string &_key, const nlohmann::json &value);
+
+ std::optional<nlohmann::json> GetDataObject(const std::string &_key);
+
+ std::optional<nlohmann::json> GetDataObjectByRef(const std::string &_ref);
+
+ private:
+ /**
+ * @brief init the secure key of application data object
+ *
+ */
+ void init_app_secure_key();
+
+ GlobalSettingStation &global_setting_station_ =
+ GlobalSettingStation::GetInstance(); ///< GlobalSettingStation
+ std::filesystem::path app_secure_path_ =
+ global_setting_station_.GetAppConfigPath() /
+ "secure"; ///< Where sensitive information is stored
+ std::filesystem::path app_secure_key_path_ =
+ app_secure_path_ / "app.key"; ///< Where the key of data object is stored
+ std::filesystem::path app_data_objs_path_ =
+ global_setting_station_.GetAppDataPath() / "data_objs"; ///< Where data
+ ///< object is
+ ///< stored
+
+ std::random_device rd_; ///< Random device
+ std::mt19937 mt_ = std::mt19937(rd_()); ///< Mersenne twister
+ QByteArray hash_key_; ///< Hash key
+};
+
+} // namespace GpgFrontend
+
+#endif // GPGFRONTEND_DATAOBJECTOPERATOR_H
diff --git a/src/core/function/FileOperator.cpp b/src/core/function/FileOperator.cpp
new file mode 100644
index 00000000..d0a3df23
--- /dev/null
+++ b/src/core/function/FileOperator.cpp
@@ -0,0 +1,119 @@
+/**
+* Copyright (C) 2021 Saturneric
+*
+* This file is part of GpgFrontend.
+*
+* GpgFrontend is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* GpgFrontend is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+*
+* The initial version of the source code is inherited from
+* the gpg4usb project, which is under GPL-3.0-or-later.
+*
+* All the source code of GpgFrontend was modified and released by
+* Saturneric<[email protected]> starting on May 12, 2021.
+*
+* SPDX-License-Identifier: GPL-3.0-or-later
+*
+*/
+
+#include "FileOperator.h"
+
+bool GpgFrontend::FileOperator::ReadFile(const QString& file_name,
+ QByteArray& data) {
+ QFile file(file_name);
+ if (!file.open(QIODevice::ReadOnly)) {
+ LOG(ERROR) << "failed to open file" << file_name.toStdString();
+ return false;
+ }
+ data = file.readAll();
+ file.close();
+ return true;
+}
+
+bool GpgFrontend::FileOperator::WriteFile(const QString& file_name,
+ const QByteArray& data) {
+ QFile file(file_name);
+ if (!file.open(QIODevice::WriteOnly)) {
+ LOG(ERROR) << "failed to open file" << file_name.toStdString();
+ return false;
+ }
+ file.write(data);
+ file.close();
+ return true;
+}
+
+bool GpgFrontend::FileOperator::ReadFileStd(
+ const std::filesystem::path& file_name, std::string& data) {
+ QByteArray byte_data;
+ bool res = ReadFile(QString::fromStdString(file_name.string()), byte_data);
+ data = byte_data.toStdString();
+ return res;
+}
+
+bool GpgFrontend::FileOperator::WriteFileStd(
+ const std::filesystem::path& file_name, const std::string& data) {
+ return WriteFile(QString::fromStdString(file_name.string()),
+ QByteArray::fromStdString(data));
+}
+
+std::string GpgFrontend::FileOperator::CalculateHash(
+ const std::filesystem::path& file_path) {
+ // Returns empty QByteArray() on failure.
+ QFileInfo info(QString::fromStdString(file_path.string()));
+ std::stringstream ss;
+
+ if (info.isFile() && info.isReadable()) {
+ ss << "[#] " << _("File Hash Information") << std::endl;
+ ss << " " << _("filename") << _(": ")
+ << file_path.filename().string().c_str() << std::endl;
+
+
+ QFile f(info.filePath());
+ f.open(QFile::ReadOnly);
+ auto buffer = f.readAll();
+ ss << " " << _("file size(bytes)") << _(": ")
+ << buffer.size() << std::endl;
+ f.close();
+ if (f.open(QFile::ReadOnly)) {
+ auto hash_md5 = QCryptographicHash(QCryptographicHash::Md5);
+ // md5
+ hash_md5.addData(buffer);
+ auto md5 = hash_md5.result().toHex().toStdString();
+ LOG(INFO) << "md5" << md5;
+ ss << " "
+ << "md5" << _(": ") << md5 << std::endl;
+
+ auto hash_sha1 = QCryptographicHash(QCryptographicHash::Sha1);
+ // sha1
+ hash_sha1.addData(buffer);
+ auto sha1 = hash_sha1.result().toHex().toStdString();
+ LOG(INFO) << "sha1" << sha1;
+ ss << " "
+ << "sha1" << _(": ") << sha1 << std::endl;
+
+ auto hash_sha256 = QCryptographicHash(QCryptographicHash::Sha256);
+ // sha1
+ hash_sha256.addData(buffer);
+ auto sha256 = hash_sha256.result().toHex().toStdString();
+ LOG(INFO) << "sha256" << sha256;
+ ss << " "
+ << "sha256" << _(": ") << sha256 << std::endl;
+
+ ss << std::endl;
+ }
+ } else {
+ ss << "[#] " << _("Error in Calculating File Hash ") << std::endl;
+ }
+
+ return ss.str();
+}
diff --git a/src/core/function/FileOperator.h b/src/core/function/FileOperator.h
new file mode 100644
index 00000000..aa2c3b73
--- /dev/null
+++ b/src/core/function/FileOperator.h
@@ -0,0 +1,92 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#ifndef GPGFRONTEND_FILEOPERATOR_H
+#define GPGFRONTEND_FILEOPERATOR_H
+
+#include "core/GpgFrontendCore.h"
+
+namespace GpgFrontend {
+
+/**
+ * @brief provides file operations
+ *
+ */
+class FileOperator {
+ public:
+ /**
+ * @brief read file content using std struct
+ *
+ *
+ * @param file_name file name
+ * @param data data read from file
+ * @return
+ */
+ static bool ReadFileStd(const std::filesystem::path &file_name,
+ std::string &data);
+
+ /**
+ * @brief write file content using std struct
+ *
+ * @param file_name file name
+ * @param data data to write to file
+ * @return
+ */
+ static bool WriteFileStd(const std::filesystem::path &file_name,
+ const std::string &data);
+
+ /**
+ * @brief read file content
+ *
+ * @param file_name file name
+ * @param data data read from file
+ * @return true if success
+ * @return false if failed
+ */
+ static bool ReadFile(const QString &file_name, QByteArray &data);
+
+ /**
+ * @brief write file content
+ *
+ * @param file_name file name
+ * @param data data to write to file
+ * @return true if success
+ * @return false if failed
+ */
+ static bool WriteFile(const QString &file_name, const QByteArray &data);
+
+ /**
+ * calculate the hash of a file
+ * @param file_path
+ * @return
+ */
+ static std::string CalculateHash(const std::filesystem::path &file_path);
+};
+} // namespace GpgFrontend
+
+#endif // GPGFRONTEND_FILEOPERATOR_H
diff --git a/src/core/function/GlobalSettingStation.cpp b/src/core/function/GlobalSettingStation.cpp
new file mode 100644
index 00000000..7b3e868e
--- /dev/null
+++ b/src/core/function/GlobalSettingStation.cpp
@@ -0,0 +1,141 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#include "GlobalSettingStation.h"
+
+#include <openssl/bio.h>
+#include <openssl/pem.h>
+
+#include <vmime/security/cert/openssl/X509Certificate_OpenSSL.hpp>
+#include <vmime/vmime.hpp>
+
+#include "core/function/FileOperator.h"
+
+void GpgFrontend::GlobalSettingStation::SyncSettings() noexcept {
+ using namespace libconfig;
+ try {
+ ui_cfg_.writeFile(ui_config_path_.string().c_str());
+ LOG(INFO) << _("Updated ui configuration successfully written to")
+ << ui_config_path_;
+
+ } catch (const FileIOException &fioex) {
+ LOG(ERROR) << _("I/O error while writing ui configuration file")
+ << ui_config_path_;
+ }
+}
+
+GpgFrontend::GlobalSettingStation::GlobalSettingStation(int channel) noexcept
+ : SingletonFunctionObject<GlobalSettingStation>(channel) {
+ using namespace std::filesystem;
+ using namespace libconfig;
+
+ el::Loggers::addFlag(el::LoggingFlag::AutoSpacing);
+
+ LOG(INFO) << _("App Path") << app_path_;
+ LOG(INFO) << _("App Configure Path") << app_configure_path_;
+ LOG(INFO) << _("App Data Path") << app_data_path_;
+ LOG(INFO) << _("App Log Path") << app_log_path_;
+ LOG(INFO) << _("App Locale Path") << app_locale_path_;
+
+ if (!is_directory(app_configure_path_)) create_directory(app_configure_path_);
+
+ if (!is_directory(app_data_path_)) create_directory(app_data_path_);
+
+ if (!is_directory(app_log_path_)) create_directory(app_log_path_);
+
+ if (!is_directory(ui_config_dir_path_)) create_directory(ui_config_dir_path_);
+
+ if (!exists(ui_config_path_)) {
+ try {
+ this->ui_cfg_.writeFile(ui_config_path_.string().c_str());
+ LOG(INFO) << _("UserInterface configuration successfully written to")
+ << ui_config_path_;
+
+ } catch (const FileIOException &fioex) {
+ LOG(ERROR)
+ << _("I/O error while writing UserInterface configuration file")
+ << ui_config_path_;
+ }
+ } else {
+ try {
+ this->ui_cfg_.readFile(ui_config_path_.string().c_str());
+ LOG(INFO) << _("UserInterface configuration successfully read from")
+ << ui_config_path_;
+ } catch (const FileIOException &fioex) {
+ LOG(ERROR) << _("I/O error while reading UserInterface configure file");
+ } catch (const ParseException &pex) {
+ LOG(ERROR) << _("Parse error at ") << pex.getFile() << ":"
+ << pex.getLine() << " - " << pex.getError();
+ }
+ }
+}
+
+void GpgFrontend::GlobalSettingStation::AddRootCert(
+ const std::filesystem::path &path) {
+ std::string out_buffer;
+ if (!FileOperator::ReadFileStd(path.string(), out_buffer)) {
+ LOG(ERROR) << _("Failed to read root certificate file") << path;
+ return;
+ }
+
+ auto mem_bio = std::shared_ptr<BIO>(
+ BIO_new_mem_buf(out_buffer.data(), static_cast<int>(out_buffer.size())),
+ [](BIO *_p) { BIO_free(_p); });
+
+ auto x509 = std::shared_ptr<X509>(
+ PEM_read_bio_X509(mem_bio.get(), nullptr, nullptr, nullptr),
+ [](X509 *_p) { X509_free(_p); });
+
+ if (!x509) return;
+
+ root_certs_.push_back(x509);
+}
+
+vmime::shared_ptr<vmime::security::cert::defaultCertificateVerifier>
+GpgFrontend::GlobalSettingStation::GetCertVerifier() const {
+ auto p_cv =
+ vmime::make_shared<vmime::security::cert::defaultCertificateVerifier>();
+
+ std::vector<vmime::shared_ptr<vmime::security::cert::X509Certificate>>
+ _root_certs;
+ for (const auto &cert : root_certs_) {
+ _root_certs.push_back(
+ std::make_shared<vmime::security::cert::X509Certificate_OpenSSL>(
+ cert.get()));
+ }
+ return p_cv;
+}
+
+const std::vector<std::shared_ptr<X509>>
+ &GpgFrontend::GlobalSettingStation::GetRootCerts() {
+ return root_certs_;
+}
+
+void GpgFrontend::GlobalSettingStation::init_app_secure_key() {}
+
+GpgFrontend::GlobalSettingStation::~GlobalSettingStation() noexcept = default;
diff --git a/src/core/function/GlobalSettingStation.h b/src/core/function/GlobalSettingStation.h
new file mode 100644
index 00000000..d6521c8a
--- /dev/null
+++ b/src/core/function/GlobalSettingStation.h
@@ -0,0 +1,232 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#ifndef GPGFRONTEND_GLOBALSETTINGSTATION_H
+#define GPGFRONTEND_GLOBALSETTINGSTATION_H
+
+#include <openssl/x509.h>
+
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
+
+#include "GpgFrontendBuildInstallInfo.h"
+#include "core/GpgFrontendCore.h"
+#include "core/GpgFunctionObject.h"
+
+namespace vmime::security::cert {
+class defaultCertificateVerifier;
+class X509Certificate;
+} // namespace vmime::security::cert
+
+namespace GpgFrontend {
+
+/**
+ * @brief
+ *
+ */
+class GlobalSettingStation
+ : public SingletonFunctionObject<GlobalSettingStation> {
+ public:
+ /**
+ * @brief Construct a new Global Setting Station object
+ *
+ */
+ explicit GlobalSettingStation(
+ int channel = SingletonFunctionObject::GetDefaultChannel()) noexcept;
+
+ /**
+ * @brief Destroy the Global Setting Station object
+ *
+ */
+ ~GlobalSettingStation() noexcept override;
+
+ /**
+ * @brief
+ *
+ * @return libconfig::Setting&
+ */
+ libconfig::Setting &GetUISettings() noexcept { return ui_cfg_.getRoot(); }
+
+ /**
+ * @brief Get the App Dir object
+ *
+ * @return std::filesystem::path
+ */
+ [[nodiscard]] std::filesystem::path GetAppDir() const { return app_path_; }
+
+ [[nodiscard]] std::filesystem::path GetAppDataPath() const {
+ return app_data_path_;
+ }
+
+ /**
+ * @brief Get the Log Dir object
+ *
+ * @return std::filesystem::path
+ */
+ [[nodiscard]] std::filesystem::path GetLogDir() const {
+ return app_log_path_;
+ }
+
+ /**
+ * @brief Get the Standalone Database Dir object
+ *
+ * @return std::filesystem::path
+ */
+ [[nodiscard]] std::filesystem::path GetStandaloneDatabaseDir() const {
+ auto db_path = app_configure_path_ / "db";
+ if (!std::filesystem::exists(db_path)) {
+ std::filesystem::create_directory(db_path);
+ }
+ return db_path;
+ }
+
+ [[nodiscard]] std::filesystem::path GetAppConfigPath() const {
+ return app_configure_path_;
+ }
+
+ /**
+ * @brief Get the Standalone Gpg Bin Dir object
+ *
+ * @return std::filesystem::path
+ */
+ [[nodiscard]] std::filesystem::path GetStandaloneGpgBinDir() const {
+ return app_resource_path_ / "gpg1.4" / "gpg";
+ }
+
+ /**
+ * @brief Get the Locale Dir object
+ *
+ * @return std::filesystem::path
+ */
+ [[nodiscard]] std::filesystem::path GetLocaleDir() const {
+ return app_locale_path_;
+ }
+
+ /**
+ * @brief Get the Resource Dir object
+ *
+ * @return std::filesystem::path
+ */
+ [[nodiscard]] std::filesystem::path GetResourceDir() const {
+ return app_resource_path_;
+ }
+
+ /**
+ * @brief Get the Certs Dir object
+ *
+ * @return std::filesystem::path
+ */
+ [[nodiscard]] std::filesystem::path GetCertsDir() const {
+ return app_resource_path_ / "certs";
+ }
+
+ /**
+ * @brief Get the Cert Verifier object
+ *
+ * @return std::shared_ptr<
+ * vmime::security::cert::defaultCertificateVerifier>
+ */
+ [[nodiscard]] std::shared_ptr<
+ vmime::security::cert::defaultCertificateVerifier>
+ GetCertVerifier() const;
+
+ /**
+ * @brief
+ *
+ * @param path
+ */
+ void AddRootCert(const std::filesystem::path &path);
+
+ /**
+ * @brief Get the Root Certs object
+ *
+ * @return const std::vector<std::shared_ptr<X509>>&
+ */
+ const std::vector<std::shared_ptr<X509>> &GetRootCerts();
+
+ /**
+ * @brief
+ *
+ */
+ void ResetRootCerts() { root_certs_.clear(); }
+
+ /**
+ * @brief sync the settings to the file
+ *
+ */
+ void SyncSettings() noexcept;
+
+ private:
+ std::filesystem::path app_path_ =
+ qApp->applicationDirPath().toStdString(); ///< Program Location
+ std::filesystem::path app_data_path_ =
+ QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
+ .toStdString(); ///< Program Data Location
+ std::filesystem::path app_log_path_ =
+ app_data_path_ / "logs"; ///< Program Data Location
+ std::filesystem::path app_data_objs_path_ =
+ app_data_path_ / "objs"; ///< Object storage path
+
+#ifdef LINUX_INSTALL_BUILD
+ std::filesystem::path app_resource_path_ =
+ std::filesystem::path(APP_LOCALSTATE_PATH) /
+ "gpgfrontend"; ///< Program Data Location
+#else
+ std::filesystem::path app_resource_path_ =
+ RESOURCE_DIR_BOOST_PATH(app_path_); ///< Program Data Location
+#endif
+
+#ifdef LINUX_INSTALL_BUILD
+ std::filesystem::path app_locale_path_ =
+ std::string(APP_LOCALE_PATH); ///< Program Data Location
+#else
+ std::filesystem::path app_locale_path_ =
+ app_resource_path_ / "locales"; ///< Program Data Location
+#endif
+
+ std::filesystem::path app_configure_path_ =
+ QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)
+ .toStdString(); ///< Program Configure Location
+ std::filesystem::path ui_config_dir_path_ =
+ app_configure_path_ /
+ "UserInterface"; ///< Configure File Directory Location
+ std::filesystem::path ui_config_path_ =
+ ui_config_dir_path_ / "ui.cfg"; ///< UI Configure File Location
+
+ libconfig::Config ui_cfg_; ///<
+ std::vector<std::shared_ptr<X509>> root_certs_; ///<
+
+ /**
+ * @brief
+ *
+ */
+ void init_app_secure_key();
+};
+} // namespace GpgFrontend
+
+#endif // GPGFRONTEND_GLOBALSETTINGSTATION_H
diff --git a/src/core/function/KeyPackageOperator.cpp b/src/core/function/KeyPackageOperator.cpp
new file mode 100644
index 00000000..2b2802f7
--- /dev/null
+++ b/src/core/function/KeyPackageOperator.cpp
@@ -0,0 +1,120 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#include "KeyPackageOperator.h"
+
+#include "FileOperator.h"
+#include "function/PassphraseGenerator.h"
+#include "function/gpg/GpgKeyGetter.h"
+#include "function/gpg/GpgKeyImportExporter.h"
+#include "qt-aes/qaesencryption.h"
+
+namespace GpgFrontend {
+
+bool KeyPackageOperator::GeneratePassphrase(
+ const std::filesystem::path& phrase_path, std::string& phrase) {
+ phrase = PassphraseGenerator::GetInstance().Generate(256);
+ LOG(INFO) << "Generated passphrase: " << phrase.size() << " bytes";
+ return FileOperator::WriteFileStd(phrase_path, phrase);
+}
+
+bool KeyPackageOperator::GenerateKeyPackage(
+ const std::filesystem::path& key_package_path,
+ const std::string& key_package_name, KeyIdArgsListPtr& key_ids,
+ std::string& phrase, bool secret) {
+ LOG(INFO) << "Generating key package: " << key_package_name;
+
+ ByteArrayPtr key_export_data = nullptr;
+ if (!GpgKeyImportExporter::GetInstance().ExportKeys(key_ids, key_export_data,
+ secret)) {
+ LOG(ERROR) << "Failed to export keys";
+ return false;
+ }
+
+ auto key = QByteArray::fromStdString(phrase);
+ auto data = QString::fromStdString(*key_export_data).toLocal8Bit().toBase64();
+
+ auto hash_key = QCryptographicHash::hash(key, QCryptographicHash::Sha256);
+ QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::ECB,
+ QAESEncryption::Padding::ISO);
+ auto encoded = encryption.encode(data, hash_key);
+
+ LOG(INFO) << "Writing key package: " << key_package_name;
+ return FileOperator::WriteFileStd(key_package_path, encoded.toStdString());
+}
+
+bool KeyPackageOperator::ImportKeyPackage(
+ const std::filesystem::path& key_package_path,
+ const std::filesystem::path& phrase_path,
+ GpgFrontend::GpgImportInformation& import_info) {
+
+ LOG(INFO) << "Importing key package: " << key_package_path.string();
+
+ std::string encrypted_data;
+ FileOperator::ReadFileStd(key_package_path, encrypted_data);
+
+ if (encrypted_data.empty()) {
+ LOG(ERROR) << "Failed to read key package: " << key_package_path.string();
+ return false;
+ };
+
+ std::string passphrase;
+ FileOperator::ReadFileStd(phrase_path, passphrase);
+ LOG(INFO) << "Passphrase: " << passphrase.size() << " bytes";
+ if (passphrase.size() != 256) {
+ LOG(ERROR) << "Failed to read passphrase: " << phrase_path.string();
+ return false;
+ }
+
+ auto hash_key = QCryptographicHash::hash(
+ QByteArray::fromStdString(passphrase), QCryptographicHash::Sha256);
+ auto encoded = QByteArray::fromStdString(encrypted_data);
+
+ QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::ECB,
+ QAESEncryption::Padding::ISO);
+
+ auto decoded = encryption.removePadding(encryption.decode(encoded, hash_key));
+ auto key_data = QByteArray::fromBase64(decoded);
+
+ LOG(INFO) << "key data" << key_data.size();
+ if (!key_data.startsWith(GpgConstants::PGP_PUBLIC_KEY_BEGIN) &&
+ !key_data.startsWith(GpgConstants::PGP_PRIVATE_KEY_BEGIN)) {
+ return false;
+ }
+
+ auto key_data_ptr = std::make_unique<ByteArray>(key_data.toStdString());
+ import_info =
+ GpgKeyImportExporter::GetInstance().ImportKey(std::move(key_data_ptr));
+ return true;
+}
+
+std::string KeyPackageOperator::GenerateKeyPackageName() {
+ return generate_key_package_name();
+}
+
+} // namespace GpgFrontend
diff --git a/src/core/function/KeyPackageOperator.h b/src/core/function/KeyPackageOperator.h
new file mode 100644
index 00000000..cd344688
--- /dev/null
+++ b/src/core/function/KeyPackageOperator.h
@@ -0,0 +1,107 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#ifndef GPGFRONTEND_KEYPACKAGEOPERATOR_H
+#define GPGFRONTEND_KEYPACKAGEOPERATOR_H
+
+#include "core/GpgFrontendCore.h"
+#include "core/function/gpg/GpgKeyImportExporter.h"
+
+namespace GpgFrontend {
+
+/**
+ * @brief give the possibility to import or export a key package
+ *
+ */
+class KeyPackageOperator {
+ public:
+ /**
+ * @brief generate passphrase for key package and save it to file
+ *
+ * @param phrase_path path to passphrase file
+ * @param phrase passphrase generated
+ * @return true if passphrase was generated and saved
+ * @return false if passphrase was not generated and saved
+ */
+ static bool GeneratePassphrase(const std::filesystem::path &phrase_path,
+ std::string &phrase);
+
+ /**
+ * @brief generate the name of the key package
+ *
+ * @return std::string name of the key package
+ */
+ static std::string GenerateKeyPackageName();
+
+ /**
+ * @brief generate key package
+ *
+ * @param key_package_path path to key package
+ * @param key_package_name name of the key package
+ * @param key_ids key ids to export
+ * @param phrase passphrase to encrypt key package
+ * @param secret true if secret key should be exported
+ * @return true if key package was generated
+ * @return false if key package was not generated
+ */
+ static bool GenerateKeyPackage(const std::filesystem::path &key_package_path,
+ const std::string &key_package_name,
+ KeyIdArgsListPtr &key_ids, std::string &phrase,
+ bool secret);
+
+ /**
+ * @brief import key package
+ *
+ * @param key_package_path path to key package
+ * @param phrase_path path to passphrase file
+ * @param import_info import info
+ * @return true if key package was imported
+ * @return false if key package was not imported
+ */
+ static bool ImportKeyPackage(const std::filesystem::path &key_package_path,
+ const std::filesystem::path &phrase_path,
+ GpgFrontend::GpgImportInformation &import_info);
+
+ private:
+ /**
+ * @brief generate key package name
+ *
+ * @return std::string key package name
+ */
+ static std::string generate_key_package_name() {
+ std::random_device rd_; ///< Random device
+ auto mt_ = std::mt19937(rd_()); ///< Mersenne twister
+
+ std::uniform_int_distribution<int> dist(999, 99999);
+ auto file_string = boost::format("KeyPackage_%1%") % dist(mt_);
+ return file_string.str();
+ }
+};
+} // namespace GpgFrontend
+
+#endif // GPGFRONTEND_KEYPACKAGEOPERATOR_H
diff --git a/src/core/function/PassphraseGenerator.cpp b/src/core/function/PassphraseGenerator.cpp
new file mode 100644
index 00000000..0267edda
--- /dev/null
+++ b/src/core/function/PassphraseGenerator.cpp
@@ -0,0 +1,29 @@
+/**
+* Copyright (C) 2021 Saturneric
+*
+* This file is part of GpgFrontend.
+*
+* GpgFrontend is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* GpgFrontend is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+*
+* The initial version of the source code is inherited from
+* the gpg4usb project, which is under GPL-3.0-or-later.
+*
+* All the source code of GpgFrontend was modified and released by
+* Saturneric<[email protected]> starting on May 12, 2021.
+*
+* SPDX-License-Identifier: GPL-3.0-or-later
+*
+ */
+
+#include "PassphraseGenerator.h"
diff --git a/src/core/function/PassphraseGenerator.h b/src/core/function/PassphraseGenerator.h
new file mode 100644
index 00000000..d1cc7607
--- /dev/null
+++ b/src/core/function/PassphraseGenerator.h
@@ -0,0 +1,83 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#ifndef GPGFRONTEND_PASSPHRASEGENERATOR_H
+#define GPGFRONTEND_PASSPHRASEGENERATOR_H
+
+#include "core/GpgFrontendCore.h"
+#include "core/GpgFunctionObject.h"
+
+namespace GpgFrontend {
+
+/**
+ * @brief The PassphraseGenerator class
+ *
+ * This class is used to generate a passphrase.
+ */
+class PassphraseGenerator
+ : public SingletonFunctionObject<PassphraseGenerator> {
+ public:
+ /**
+ * @brief PassphraseGenerator constructor
+ *
+ * @param channel The channel to use
+ */
+ explicit PassphraseGenerator(
+ int channel = SingletonFunctionObject::GetDefaultChannel())
+ : SingletonFunctionObject<PassphraseGenerator>(channel) {}
+
+ /**
+ * @brief generate passphrase
+ *
+ * @param len length of the passphrase
+ * @return std::string passphrase
+ */
+ std::string Generate(int len) {
+ std::uniform_int_distribution<int> dist(999, 99999);
+
+ auto file_string = boost::format("KeyPackage_%1%") % dist(mt_);
+ static const char alphanum[] =
+ "0123456789"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz";
+ std::string tmp_str;
+ tmp_str.reserve(len);
+
+ for (int i = 0; i < len; ++i) {
+ tmp_str += alphanum[dist(mt_) % (sizeof(alphanum) - 1)];
+ }
+ return tmp_str;
+ }
+
+ std::random_device rd_; ///< Random device
+ std::mt19937 mt_ = std::mt19937(rd_()); ///< Mersenne twister
+};
+
+} // namespace GpgFrontend
+
+#endif // GPGFRONTEND_PASSPHRASEGENERATOR_H
diff --git a/src/core/function/aes/aes_ssl.h b/src/core/function/aes/aes_ssl.h
new file mode 100644
index 00000000..b5f0820f
--- /dev/null
+++ b/src/core/function/aes/aes_ssl.h
@@ -0,0 +1,74 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#ifndef GPGFRONTEND_AES_SSL_H
+#define GPGFRONTEND_AES_SSL_H
+
+#include "GpgFrontend.h"
+
+#include <openssl/aes.h>
+#include <openssl/evp.h>
+
+namespace GpgFrontend::RawAPI {
+
+/**
+ * @brief
+ *
+ * @param key_data
+ * @param key_data_len
+ * @param salt
+ * @param e_ctx
+ * @param d_ctx
+ * @return int
+ */
+int aes_256_cbc_init(uint8_t *key_data, int key_data_len, uint8_t *salt,
+ EVP_CIPHER_CTX *e_ctx, EVP_CIPHER_CTX *d_ctx);
+
+/**
+ * @brief
+ *
+ * @param e
+ * @param plaintext
+ * @param len
+ * @return uint8_t*
+ */
+uint8_t *aes_256_cbc_encrypt(EVP_CIPHER_CTX *e, uint8_t *plaintext, int *len);
+
+/**
+ * @brief
+ *
+ * @param e
+ * @param ciphertext
+ * @param len
+ * @return uint8_t*
+ */
+uint8_t *aes_256_cbc_decrypt(EVP_CIPHER_CTX *e, uint8_t *ciphertext, int *len);
+
+} // namespace GpgFrontend::RawAPI
+
+#endif // GPGFRONTEND_AES_SSL_H
diff --git a/src/core/function/aes/aes_ssl_cbc.cpp b/src/core/function/aes/aes_ssl_cbc.cpp
new file mode 100644
index 00000000..95ae0ce2
--- /dev/null
+++ b/src/core/function/aes/aes_ssl_cbc.cpp
@@ -0,0 +1,99 @@
+/**
+ * AES encryption/decryption demo program using OpenSSL EVP apis
+ * gcc -Wall openssl_aes.c -lcrypto
+ * this is public domain code.
+ * Saju Pillai ([email protected])
+ **/
+
+#include "aes_ssl.h"
+
+namespace GpgFrontend::RawAPI {
+
+/**
+ * @brief Create a 256 bit key and IV using the supplied key_data. salt can be
+ * added for taste. Fills in the encryption and decryption ctx objects and
+ * returns 0 on success
+ *
+ * @param key_data
+ * @param key_data_len
+ * @param salt
+ * @param e_ctx
+ * @param d_ctx
+ * @return int
+ */
+int aes_256_cbc_init(uint8_t *key_data, int key_data_len, uint8_t *salt,
+ EVP_CIPHER_CTX *e_ctx, EVP_CIPHER_CTX *d_ctx) {
+ int i, nrounds = 5;
+ uint8_t key[32], iv[32];
+
+ /*
+ * Gen key & IV for AES 256 CBC mode. A SHA1 digest is used to hash the
+ * supplied key material. nrounds is the number of times the we hash the
+ * material. More rounds are more secure but slower.
+ */
+ i = EVP_BytesToKey(EVP_aes_256_cbc(), EVP_sha1(), salt, key_data,
+ key_data_len, nrounds, key, iv);
+ if (i != 32) {
+ printf("Key size is %d bits - should be 256 bits\n", i);
+ return -1;
+ }
+
+ EVP_CIPHER_CTX_init(e_ctx);
+ EVP_EncryptInit_ex(e_ctx, EVP_aes_256_cbc(), NULL, key, iv);
+ EVP_CIPHER_CTX_init(d_ctx);
+ EVP_DecryptInit_ex(d_ctx, EVP_aes_256_cbc(), NULL, key, iv);
+
+ return 0;
+}
+
+/**
+ * @brief Encrypt *len bytes of data All data going in & out is considered
+ * binary (uint8_t[])
+ *
+ * @param e
+ * @param plaintext
+ * @param len
+ * @return uint8_t*
+ */
+uint8_t *aes_256_cbc_encrypt(EVP_CIPHER_CTX *e, uint8_t *plaintext, int *len) {
+ /* max ciphertext len for a n bytes of plaintext is n + AES_BLOCK_SIZE -1
+ * bytes */
+ int c_len = *len + AES_BLOCK_SIZE, f_len = 0;
+ auto *ciphertext = (uint8_t *)malloc(c_len);
+
+ /* allows reusing of 'e' for multiple encryption cycles */
+ EVP_EncryptInit_ex(e, nullptr, nullptr, nullptr, nullptr);
+
+ /* update ciphertext, c_len is filled with the length of ciphertext generated,
+ *len is the size of plaintext in bytes */
+ EVP_EncryptUpdate(e, ciphertext, &c_len, plaintext, *len);
+
+ /* update ciphertext with the final remaining bytes */
+ EVP_EncryptFinal_ex(e, ciphertext + c_len, &f_len);
+
+ *len = c_len + f_len;
+ return ciphertext;
+}
+
+/**
+ * @brief Decrypt *len bytes of ciphertext
+ *
+ * @param e
+ * @param ciphertext
+ * @param len
+ * @return uint8_t*
+ */
+uint8_t *aes_256_cbc_decrypt(EVP_CIPHER_CTX *e, uint8_t *ciphertext, int *len) {
+ /* plaintext will always be equal to or lesser than length of ciphertext*/
+ int p_len = *len, f_len = 0;
+ auto *plaintext = (uint8_t *)malloc(p_len);
+
+ EVP_DecryptInit_ex(e, nullptr, nullptr, nullptr, nullptr);
+ EVP_DecryptUpdate(e, plaintext, &p_len, ciphertext, *len);
+ EVP_DecryptFinal_ex(e, plaintext + p_len, &f_len);
+
+ *len = p_len + f_len;
+ return plaintext;
+}
+
+} // namespace GpgFrontend::RawAPI \ No newline at end of file
diff --git a/src/gpg/function/BasicOperator.cpp b/src/core/function/gpg/GpgBasicOperator.cpp
index 1c2aac9c..b92404a9 100644
--- a/src/gpg/function/BasicOperator.cpp
+++ b/src/core/function/gpg/GpgBasicOperator.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,29 +8,31 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/function/BasicOperator.h"
+#include "GpgBasicOperator.h"
#include <vector>
-#include "gpg/function/GpgKeyGetter.h"
+#include "GpgKeyGetter.h"
-GpgFrontend::GpgError GpgFrontend::BasicOperator::Encrypt(
+GpgFrontend::GpgError GpgFrontend::GpgBasicOperator::Encrypt(
KeyListPtr keys, GpgFrontend::BypeArrayRef in_buffer,
GpgFrontend::ByteArrayPtr& out_buffer, GpgFrontend::GpgEncrResult& result) {
// gpgme_encrypt_result_t e_result;
@@ -54,7 +58,7 @@ GpgFrontend::GpgError GpgFrontend::BasicOperator::Encrypt(
return err;
}
-GpgFrontend::GpgError GpgFrontend::BasicOperator::Decrypt(
+GpgFrontend::GpgError GpgFrontend::GpgBasicOperator::Decrypt(
BypeArrayRef in_buffer, GpgFrontend::ByteArrayPtr& out_buffer,
GpgFrontend::GpgDecrResult& result) {
gpgme_error_t err;
@@ -71,7 +75,7 @@ GpgFrontend::GpgError GpgFrontend::BasicOperator::Decrypt(
return err;
}
-GpgFrontend::GpgError GpgFrontend::BasicOperator::Verify(
+GpgFrontend::GpgError GpgFrontend::GpgBasicOperator::Verify(
BypeArrayRef& in_buffer, ByteArrayPtr& sig_buffer,
GpgVerifyResult& result) const {
gpgme_error_t err;
@@ -91,7 +95,7 @@ GpgFrontend::GpgError GpgFrontend::BasicOperator::Verify(
return err;
}
-GpgFrontend::GpgError GpgFrontend::BasicOperator::Sign(KeyListPtr signers,
+GpgFrontend::GpgError GpgFrontend::GpgBasicOperator::Sign(KeyListPtr signers,
BypeArrayRef in_buffer,
ByteArrayPtr& out_buffer,
gpgme_sig_mode_t mode,
@@ -115,7 +119,7 @@ GpgFrontend::GpgError GpgFrontend::BasicOperator::Sign(KeyListPtr signers,
return err;
}
-gpgme_error_t GpgFrontend::BasicOperator::DecryptVerify(
+gpgme_error_t GpgFrontend::GpgBasicOperator::DecryptVerify(
BypeArrayRef in_buffer, ByteArrayPtr& out_buffer,
GpgDecrResult& decrypt_result, GpgVerifyResult& verify_result) {
gpgme_error_t err;
@@ -136,7 +140,7 @@ gpgme_error_t GpgFrontend::BasicOperator::DecryptVerify(
return err;
}
-gpgme_error_t GpgFrontend::BasicOperator::EncryptSign(
+gpgme_error_t GpgFrontend::GpgBasicOperator::EncryptSign(
KeyListPtr keys, KeyListPtr signers, BypeArrayRef in_buffer,
ByteArrayPtr& out_buffer, GpgEncrResult& encr_result,
GpgSignResult& sign_result) {
@@ -170,7 +174,7 @@ gpgme_error_t GpgFrontend::BasicOperator::EncryptSign(
return err;
}
-void GpgFrontend::BasicOperator::SetSigners(KeyArgsList& signers) {
+void GpgFrontend::GpgBasicOperator::SetSigners(KeyArgsList& signers) {
gpgme_signers_clear(ctx_);
for (const GpgKey& key : signers) {
DLOG(INFO) << "key" << key.GetFingerprint();
@@ -185,7 +189,7 @@ void GpgFrontend::BasicOperator::SetSigners(KeyArgsList& signers) {
}
std::unique_ptr<GpgFrontend::KeyArgsList>
-GpgFrontend::BasicOperator::GetSigners() {
+GpgFrontend::GpgBasicOperator::GetSigners() {
auto count = gpgme_signers_count(ctx_);
auto signers = std::make_unique<std::vector<GpgKey>>();
for (auto i = 0u; i < count; i++) {
@@ -195,7 +199,7 @@ GpgFrontend::BasicOperator::GetSigners() {
return signers;
}
-gpg_error_t GpgFrontend::BasicOperator::EncryptSymmetric(
+gpg_error_t GpgFrontend::GpgBasicOperator::EncryptSymmetric(
GpgFrontend::ByteArray& in_buffer, GpgFrontend::ByteArrayPtr& out_buffer,
GpgFrontend::GpgEncrResult& result) {
GpgData data_in(in_buffer.data(), in_buffer.size()), data_out;
diff --git a/src/gpg/function/BasicOperator.h b/src/core/function/gpg/GpgBasicOperator.h
index 725be764..9b9d9f63 100644
--- a/src/gpg/function/BasicOperator.h
+++ b/src/core/function/gpg/GpgBasicOperator.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,29 +8,31 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef GPGFRONTEND_ZH_CN_TS_BASICOPERATOR_H
#define GPGFRONTEND_ZH_CN_TS_BASICOPERATOR_H
-#include "gpg/GpgConstants.h"
-#include "gpg/GpgContext.h"
-#include "gpg/GpgFunctionObject.h"
-#include "gpg/GpgModel.h"
+#include "core/GpgConstants.h"
+#include "core/GpgContext.h"
+#include "core/GpgFunctionObject.h"
+#include "core/GpgModel.h"
namespace GpgFrontend {
@@ -36,16 +40,16 @@ namespace GpgFrontend {
* @brief Basic operation collection
*
*/
-class BasicOperator : public SingletonFunctionObject<BasicOperator> {
+class GpgBasicOperator : public SingletonFunctionObject<GpgBasicOperator> {
public:
/**
* @brief Construct a new Basic Operator object
*
* @param channel Channel corresponding to the context
*/
- explicit BasicOperator(
+ explicit GpgBasicOperator(
int channel = SingletonFunctionObject::GetDefaultChannel())
- : SingletonFunctionObject<BasicOperator>(channel) {}
+ : SingletonFunctionObject<GpgBasicOperator>(channel) {}
/**
* @brief Call the interface provided by gpgme for encryption operation
diff --git a/src/gpg/function/GpgCommandExecutor.cpp b/src/core/function/gpg/GpgCommandExecutor.cpp
index 4098fdb6..a6a67d08 100644
--- a/src/gpg/function/GpgCommandExecutor.cpp
+++ b/src/core/function/gpg/GpgCommandExecutor.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,22 +8,24 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/function/GpgCommandExecutor.h"
+#include "GpgCommandExecutor.h"
#ifndef WINDOWS
#include <boost/asio.hpp>
#endif
diff --git a/src/gpg/function/GpgCommandExecutor.h b/src/core/function/gpg/GpgCommandExecutor.h
index 66f7c1f9..49baf406 100644
--- a/src/gpg/function/GpgCommandExecutor.h
+++ b/src/core/function/gpg/GpgCommandExecutor.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -29,8 +33,8 @@
#include <boost/process.hpp>
#endif
-#include "gpg/GpgContext.h"
-#include "gpg/GpgFunctionObject.h"
+#include "core/GpgContext.h"
+#include "core/GpgFunctionObject.h"
namespace GpgFrontend {
diff --git a/src/gpg/function/GpgFileOpera.cpp b/src/core/function/gpg/GpgFileOpera.cpp
index 8babfa6d..7044353b 100644
--- a/src/gpg/function/GpgFileOpera.cpp
+++ b/src/core/function/gpg/GpgFileOpera.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,40 +8,47 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/function/GpgFileOpera.h"
+#include "GpgFileOpera.h"
#include <memory>
#include <string>
#include "GpgConstants.h"
-#include "gpg/function/BasicOperator.h"
+#include "GpgBasicOperator.h"
+#include "function/FileOperator.h"
GpgFrontend::GpgError GpgFrontend::GpgFileOpera::EncryptFile(
KeyListPtr keys, const std::string& in_path, const std::string& out_path,
GpgEncrResult& result, int _channel) {
- std::string in_buffer = read_all_data_in_file(in_path);
- std::unique_ptr<std::string> out_buffer;
- auto err = BasicOperator::GetInstance(_channel).Encrypt(
+ std::string in_buffer;
+ if(!FileOperator::ReadFileStd(in_path, in_buffer)) {
+ throw std::runtime_error("read file error");
+ }
+ std::unique_ptr<std::string> out_buffer = nullptr;
+
+ auto err = GpgBasicOperator::GetInstance(_channel).Encrypt(
std::move(keys), in_buffer, out_buffer, result);
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR)
- if (!write_buffer_to_file(out_path, *out_buffer)) {
+ if (!FileOperator::WriteFileStd(out_path, *out_buffer)) {
throw std::runtime_error("write_buffer_to_file error");
};
@@ -49,16 +58,19 @@ GpgFrontend::GpgError GpgFrontend::GpgFileOpera::EncryptFile(
GpgFrontend::GpgError GpgFrontend::GpgFileOpera::DecryptFile(
const std::string& in_path, const std::string& out_path,
GpgDecrResult& result) {
- std::string in_buffer = read_all_data_in_file(in_path);
+ std::string in_buffer;
+ if(!FileOperator::ReadFileStd(in_path, in_buffer)) {
+ throw std::runtime_error("read file error");
+ }
std::unique_ptr<std::string> out_buffer;
auto err =
- BasicOperator::GetInstance().Decrypt(in_buffer, out_buffer, result);
+ GpgBasicOperator::GetInstance().Decrypt(in_buffer, out_buffer, result);
assert(check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR);
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR)
- if (!write_buffer_to_file(out_path, *out_buffer)) {
+ if (!FileOperator::WriteFileStd(out_path, *out_buffer)) {
throw std::runtime_error("write_buffer_to_file error");
};
@@ -70,14 +82,17 @@ gpgme_error_t GpgFrontend::GpgFileOpera::SignFile(KeyListPtr keys,
const std::string& out_path,
GpgSignResult& result,
int _channel) {
- auto in_buffer = read_all_data_in_file(in_path);
+ std::string in_buffer;
+ if(!FileOperator::ReadFileStd(in_path, in_buffer)) {
+ throw std::runtime_error("read file error");
+ }
std::unique_ptr<std::string> out_buffer;
- auto err = BasicOperator::GetInstance(_channel).Sign(
+ auto err = GpgBasicOperator::GetInstance(_channel).Sign(
std::move(keys), in_buffer, out_buffer, GPGME_SIG_MODE_DETACH, result);
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR)
- if (!write_buffer_to_file(out_path, *out_buffer)) {
+ if (!FileOperator::WriteFileStd(out_path, *out_buffer)) {
throw std::runtime_error("write_buffer_to_file error");
};
@@ -87,13 +102,20 @@ gpgme_error_t GpgFrontend::GpgFileOpera::SignFile(KeyListPtr keys,
gpgme_error_t GpgFrontend::GpgFileOpera::VerifyFile(
const std::string& data_path, const std::string& sign_path,
GpgVerifyResult& result, int _channel) {
- auto in_buffer = read_all_data_in_file(data_path);
+ std::string in_buffer;
+ if(!FileOperator::ReadFileStd(data_path, in_buffer)) {
+ throw std::runtime_error("read file error");
+ }
std::unique_ptr<std::string> sign_buffer = nullptr;
if (!sign_path.empty()) {
+ std::string sign_buffer_str;
+ if (!FileOperator::ReadFileStd(sign_path, sign_buffer_str)) {
+ throw std::runtime_error("read file error");
+ }
sign_buffer =
- std::make_unique<std::string>(read_all_data_in_file(sign_path));
+ std::make_unique<std::string>(sign_buffer_str);
}
- auto err = BasicOperator::GetInstance(_channel).Verify(in_buffer, sign_buffer,
+ auto err = GpgBasicOperator::GetInstance(_channel).Verify(in_buffer, sign_buffer,
result);
return err;
}
@@ -102,15 +124,18 @@ gpg_error_t GpgFrontend::GpgFileOpera::EncryptSignFile(
KeyListPtr keys, KeyListPtr signer_keys, const std::string& in_path,
const std::string& out_path, GpgEncrResult& encr_res,
GpgSignResult& sign_res, int _channel) {
- auto in_buffer = read_all_data_in_file(in_path);
+ std::string in_buffer;
+ if(!FileOperator::ReadFileStd(in_path, in_buffer)) {
+ throw std::runtime_error("read file error");
+ }
std::unique_ptr<std::string> out_buffer = nullptr;
- auto err = BasicOperator::GetInstance(_channel).EncryptSign(
+ auto err = GpgBasicOperator::GetInstance(_channel).EncryptSign(
std::move(keys), std::move(signer_keys), in_buffer, out_buffer, encr_res,
sign_res);
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR)
- if (!write_buffer_to_file(out_path, *out_buffer)) {
+ if (!FileOperator::WriteFileStd(out_path, *out_buffer)) {
throw std::runtime_error("write_buffer_to_file error");
};
@@ -120,16 +145,18 @@ gpg_error_t GpgFrontend::GpgFileOpera::EncryptSignFile(
gpg_error_t GpgFrontend::GpgFileOpera::DecryptVerifyFile(
const std::string& in_path, const std::string& out_path,
GpgDecrResult& decr_res, GpgVerifyResult& verify_res) {
- auto in_buffer = read_all_data_in_file(in_path);
+ std::string in_buffer;
+ if(!FileOperator::ReadFileStd(in_path, in_buffer)) {
+ throw std::runtime_error("read file error");
+ }
std::unique_ptr<std::string> out_buffer = nullptr;
-
- auto err = BasicOperator::GetInstance().DecryptVerify(in_buffer, out_buffer,
+ auto err = GpgBasicOperator::GetInstance().DecryptVerify(in_buffer, out_buffer,
decr_res, verify_res);
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR)
- if (!write_buffer_to_file(out_path, *out_buffer)) {
- throw std::runtime_error("write_buffer_to_file error");
+ if (!FileOperator::WriteFileStd(out_path, *out_buffer)) {
+ throw std::runtime_error("write file error");
};
return err;
@@ -137,14 +164,17 @@ gpg_error_t GpgFrontend::GpgFileOpera::DecryptVerifyFile(
unsigned int GpgFrontend::GpgFileOpera::EncryptFileSymmetric(
const std::string& in_path, const std::string& out_path,
GpgFrontend::GpgEncrResult& result, int _channel) {
- std::string in_buffer = read_all_data_in_file(in_path);
- std::unique_ptr<std::string> out_buffer;
+ std::string in_buffer;
+ if(!FileOperator::ReadFileStd(in_path, in_buffer)) {
+ throw std::runtime_error("read file error");
+ }
- auto err = BasicOperator::GetInstance(_channel).EncryptSymmetric(
+ std::unique_ptr<std::string> out_buffer;
+ auto err = GpgBasicOperator::GetInstance(_channel).EncryptSymmetric(
in_buffer, out_buffer, result);
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR)
- if (!write_buffer_to_file(out_path, *out_buffer)) {
+ if (!FileOperator::WriteFileStd(out_path, *out_buffer)) {
throw std::runtime_error("write_buffer_to_file error");
};
diff --git a/src/gpg/function/GpgFileOpera.h b/src/core/function/gpg/GpgFileOpera.h
index e08c9ba6..f21bf04c 100644
--- a/src/gpg/function/GpgFileOpera.h
+++ b/src/core/function/gpg/GpgFileOpera.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,35 +8,37 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef GPGFRONTEND_GPGFILEOPERA_H
#define GPGFRONTEND_GPGFILEOPERA_H
-#include "gpg/GpgConstants.h"
-#include "gpg/GpgContext.h"
-#include "gpg/GpgModel.h"
+#include "core/GpgConstants.h"
+#include "core/GpgContext.h"
+#include "core/GpgModel.h"
namespace GpgFrontend {
/**
* @brief Executive files related to the basic operations that are provided by
- * BasicOperator
- * @class class: BasicOperator
+ * GpgBasicOperator
+ * @class class: GpgBasicOperator
*/
class GpgFileOpera : public SingletonFunctionObject<GpgFileOpera> {
public:
diff --git a/src/gpg/function/GpgKeyGetter.cpp b/src/core/function/gpg/GpgKeyGetter.cpp
index 62264378..1a4715e7 100644
--- a/src/gpg/function/GpgKeyGetter.cpp
+++ b/src/core/function/gpg/GpgKeyGetter.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,23 +8,25 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/function/GpgKeyGetter.h"
+#include "GpgKeyGetter.h"
#include <gpg-error.h>
diff --git a/src/gpg/function/GpgKeyGetter.h b/src/core/function/gpg/GpgKeyGetter.h
index 2668ce4a..cde027a0 100644
--- a/src/gpg/function/GpgKeyGetter.h
+++ b/src/core/function/gpg/GpgKeyGetter.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,28 +8,30 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef GPGFRONTEND_ZH_CN_TS_GPGKEYGETTER_H
#define GPGFRONTEND_ZH_CN_TS_GPGKEYGETTER_H
-#include "gpg/GpgContext.h"
-#include "gpg/GpgFunctionObject.h"
-#include "gpg/GpgModel.h"
+#include "core/GpgContext.h"
+#include "core/GpgFunctionObject.h"
+#include "core/GpgModel.h"
namespace GpgFrontend {
diff --git a/src/gpg/function/GpgKeyImportExporter.cpp b/src/core/function/gpg/GpgKeyImportExporter.cpp
index d85ec38f..0f1ebfa2 100644
--- a/src/gpg/function/GpgKeyImportExporter.cpp
+++ b/src/core/function/gpg/GpgKeyImportExporter.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,26 +8,28 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/function/GpgKeyImportExporter.h"
+#include "GpgKeyImportExporter.h"
#include "GpgConstants.h"
-#include "gpg/function/GpgKeyGetter.h"
+#include "GpgKeyGetter.h"
/**
* Import key pair
diff --git a/src/gpg/function/GpgKeyImportExporter.h b/src/core/function/gpg/GpgKeyImportExporter.h
index 51758c0a..d7e6deae 100644
--- a/src/gpg/function/GpgKeyImportExporter.h
+++ b/src/core/function/gpg/GpgKeyImportExporter.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -27,10 +31,10 @@
#include <string>
-#include "gpg/GpgConstants.h"
-#include "gpg/GpgContext.h"
-#include "gpg/GpgFunctionObject.h"
-#include "gpg/GpgModel.h"
+#include "core/GpgConstants.h"
+#include "core/GpgContext.h"
+#include "core/GpgFunctionObject.h"
+#include "core/GpgModel.h"
namespace GpgFrontend {
diff --git a/src/gpg/function/GpgKeyManager.cpp b/src/core/function/gpg/GpgKeyManager.cpp
index 12461ec2..c17df49e 100644
--- a/src/gpg/function/GpgKeyManager.cpp
+++ b/src/core/function/gpg/GpgKeyManager.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,29 +8,31 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/function/GpgKeyManager.h"
+#include "GpgKeyManager.h"
#include <boost/date_time/posix_time/conversion.hpp>
#include <string>
-#include "gpg/function/BasicOperator.h"
-#include "gpg/function/GpgKeyGetter.h"
+#include "GpgBasicOperator.h"
+#include "GpgKeyGetter.h"
bool GpgFrontend::GpgKeyManager::SignKey(
const GpgFrontend::GpgKey& target, GpgFrontend::KeyArgsList& keys,
@@ -36,7 +40,7 @@ bool GpgFrontend::GpgKeyManager::SignKey(
const std::unique_ptr<boost::posix_time::ptime>& expires) {
using namespace boost::posix_time;
- BasicOperator::GetInstance().SetSigners(keys);
+ GpgBasicOperator::GetInstance().SetSigners(keys);
unsigned int flags = 0;
unsigned int expires_time_t = 0;
diff --git a/src/gpg/function/GpgKeyManager.h b/src/core/function/gpg/GpgKeyManager.h
index ee8b4f6c..5bcac545 100644
--- a/src/gpg/function/GpgKeyManager.h
+++ b/src/core/function/gpg/GpgKeyManager.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,28 +8,30 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef GPGFRONTEND_ZH_CN_TS_GPGKEYMANAGER_H
#define GPGFRONTEND_ZH_CN_TS_GPGKEYMANAGER_H
-#include "gpg/GpgContext.h"
-#include "gpg/GpgFunctionObject.h"
-#include "gpg/GpgModel.h"
+#include "core/GpgContext.h"
+#include "core/GpgFunctionObject.h"
+#include "core/GpgModel.h"
namespace GpgFrontend {
diff --git a/src/gpg/function/GpgKeyOpera.cpp b/src/core/function/gpg/GpgKeyOpera.cpp
index 5e26fa54..23dcae9f 100644
--- a/src/gpg/function/GpgKeyOpera.cpp
+++ b/src/core/function/gpg/GpgKeyOpera.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,23 +8,25 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/function/GpgKeyOpera.h"
+#include "GpgKeyOpera.h"
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/conversion.hpp>
@@ -32,10 +36,10 @@
#include <string>
#include <vector>
-#include "gpg/GpgConstants.h"
-#include "gpg/GpgGenKeyInfo.h"
-#include "gpg/function/GpgCommandExecutor.h"
-#include "gpg/function/GpgKeyGetter.h"
+#include "core/GpgConstants.h"
+#include "core/GpgGenKeyInfo.h"
+#include "GpgCommandExecutor.h"
+#include "GpgKeyGetter.h"
/**
* Delete keys
diff --git a/src/gpg/function/GpgKeyOpera.h b/src/core/function/gpg/GpgKeyOpera.h
index ce0acc0d..04571c10 100644
--- a/src/gpg/function/GpgKeyOpera.h
+++ b/src/core/function/gpg/GpgKeyOpera.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,28 +8,30 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef _GPGKEYOPERA_H
#define _GPGKEYOPERA_H
-#include "gpg/GpgConstants.h"
-#include "gpg/GpgContext.h"
-#include "gpg/GpgModel.h"
+#include "core/GpgConstants.h"
+#include "core/GpgContext.h"
+#include "core/GpgModel.h"
namespace GpgFrontend {
/**
diff --git a/src/gpg/function/UIDOperator.cpp b/src/core/function/gpg/GpgUIDOperator.cpp
index 8c8f5c27..dd0c43f6 100644
--- a/src/gpg/function/UIDOperator.cpp
+++ b/src/core/function/gpg/GpgUIDOperator.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,27 +8,29 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/function/UIDOperator.h"
+#include "GpgUIDOperator.h"
#include "boost/format.hpp"
-bool GpgFrontend::UIDOperator::AddUID(const GpgFrontend::GpgKey& key,
+bool GpgFrontend::GpgUIDOperator::AddUID(const GpgFrontend::GpgKey& key,
const std::string& uid) {
auto err = gpgme_op_adduid(ctx_, gpgme_key_t(key), uid.c_str(), 0);
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR)
@@ -35,7 +39,7 @@ bool GpgFrontend::UIDOperator::AddUID(const GpgFrontend::GpgKey& key,
return false;
}
-bool GpgFrontend::UIDOperator::RevUID(const GpgFrontend::GpgKey& key,
+bool GpgFrontend::GpgUIDOperator::RevUID(const GpgFrontend::GpgKey& key,
const std::string& uid) {
auto err =
check_gpg_error(gpgme_op_revuid(ctx_, gpgme_key_t(key), uid.c_str(), 0));
@@ -45,7 +49,7 @@ bool GpgFrontend::UIDOperator::RevUID(const GpgFrontend::GpgKey& key,
return false;
}
-bool GpgFrontend::UIDOperator::SetPrimaryUID(const GpgFrontend::GpgKey& key,
+bool GpgFrontend::GpgUIDOperator::SetPrimaryUID(const GpgFrontend::GpgKey& key,
const std::string& uid) {
auto err = check_gpg_error(gpgme_op_set_uid_flag(
ctx_, gpgme_key_t(key), uid.c_str(), "primary", nullptr));
@@ -54,7 +58,7 @@ bool GpgFrontend::UIDOperator::SetPrimaryUID(const GpgFrontend::GpgKey& key,
else
return false;
}
-bool GpgFrontend::UIDOperator::AddUID(const GpgFrontend::GpgKey& key,
+bool GpgFrontend::GpgUIDOperator::AddUID(const GpgFrontend::GpgKey& key,
const std::string& name,
const std::string& comment,
const std::string& email) {
diff --git a/src/gpg/function/UIDOperator.h b/src/core/function/gpg/GpgUIDOperator.h
index a68fb0e9..479505e5 100644
--- a/src/gpg/function/UIDOperator.h
+++ b/src/core/function/gpg/GpgUIDOperator.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,38 +8,40 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef GPGFRONTEND_ZH_CN_TS_UIDOPERATOR_H
#define GPGFRONTEND_ZH_CN_TS_UIDOPERATOR_H
-#include "gpg/GpgContext.h"
-#include "gpg/GpgModel.h"
+#include "core/GpgContext.h"
+#include "core/GpgModel.h"
namespace GpgFrontend {
/**
* @brief
*
*/
-class UIDOperator : public SingletonFunctionObject<UIDOperator> {
+class GpgUIDOperator : public SingletonFunctionObject<GpgUIDOperator> {
public:
- explicit UIDOperator(
+ explicit GpgUIDOperator(
int channel = SingletonFunctionObject::GetDefaultChannel())
- : SingletonFunctionObject<UIDOperator>(channel) {}
+ : SingletonFunctionObject<GpgUIDOperator>(channel) {}
/**
* create a new uid in certain key pair
diff --git a/src/gpg/result_analyse/DecryptResultAnalyse.cpp b/src/core/function/result_analyse/GpgDecryptResultAnalyse.cpp
index 20be8244..ff3d2e27 100644
--- a/src/gpg/result_analyse/DecryptResultAnalyse.cpp
+++ b/src/core/function/result_analyse/GpgDecryptResultAnalyse.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,31 +8,33 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/result_analyse/DecryptResultAnalyse.h"
+#include "GpgDecryptResultAnalyse.h"
-#include "gpg/function/GpgKeyGetter.h"
+#include "function/gpg/GpgKeyGetter.h"
-GpgFrontend::DecryptResultAnalyse::DecryptResultAnalyse(GpgError m_error,
+GpgFrontend::GpgDecryptResultAnalyse::GpgDecryptResultAnalyse(GpgError m_error,
GpgDecrResult m_result)
: error_(m_error), result_(std::move(m_result)) {}
-void GpgFrontend::DecryptResultAnalyse::do_analyse() {
+void GpgFrontend::GpgDecryptResultAnalyse::do_analyse() {
stream_ << "[#] " << _("Decrypt Operation");
if (gpgme_err_code(error_) == GPG_ERR_NO_ERROR) {
@@ -68,7 +72,7 @@ void GpgFrontend::DecryptResultAnalyse::do_analyse() {
stream_ << std::endl;
}
-void GpgFrontend::DecryptResultAnalyse::print_recipient(
+void GpgFrontend::GpgDecryptResultAnalyse::print_recipient(
std::stringstream &stream, gpgme_recipient_t recipient) {
// check
if (recipient->keyid == nullptr) return;
diff --git a/src/gpg/result_analyse/DecryptResultAnalyse.h b/src/core/function/result_analyse/GpgDecryptResultAnalyse.h
index 7377e7d1..af42f995 100644
--- a/src/gpg/result_analyse/DecryptResultAnalyse.h
+++ b/src/core/function/result_analyse/GpgDecryptResultAnalyse.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,27 +8,29 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#ifndef GPGFRONTEND_DECRYPTRESULTANALYSE_H
-#define GPGFRONTEND_DECRYPTRESULTANALYSE_H
+#ifndef GPGFRONTEND_GPGDECRYPTRESULTANALYSE_H
+#define GPGFRONTEND_GPGDECRYPTRESULTANALYSE_H
-#include "ResultAnalyse.h"
-#include "gpg/GpgConstants.h"
+#include "GpgResultAnalyse.h"
+#include "core/GpgConstants.h"
namespace GpgFrontend {
@@ -34,7 +38,7 @@ namespace GpgFrontend {
* @brief
*
*/
-class DecryptResultAnalyse : public ResultAnalyse {
+class GpgDecryptResultAnalyse : public GpgResultAnalyse {
public:
/**
* @brief Construct a new Decrypt Result Analyse object
@@ -42,7 +46,7 @@ class DecryptResultAnalyse : public ResultAnalyse {
* @param m_error
* @param m_result
*/
- explicit DecryptResultAnalyse(GpgError m_error, GpgDecrResult m_result);
+ explicit GpgDecryptResultAnalyse(GpgError m_error, GpgDecrResult m_result);
protected:
/**
@@ -66,4 +70,4 @@ class DecryptResultAnalyse : public ResultAnalyse {
} // namespace GpgFrontend
-#endif // GPGFRONTEND_DECRYPTRESULTANALYSE_H
+#endif // GPGFRONTEND_GPGDECRYPTRESULTANALYSE_H
diff --git a/src/gpg/result_analyse/EncryptResultAnalyse.cpp b/src/core/function/result_analyse/GpgEncryptResultAnalyse.cpp
index eefd62a1..053a15a5 100644
--- a/src/gpg/result_analyse/EncryptResultAnalyse.cpp
+++ b/src/core/function/result_analyse/GpgEncryptResultAnalyse.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,29 +8,31 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/result_analyse/EncryptResultAnalyse.h"
+#include "GpgEncryptResultAnalyse.h"
-GpgFrontend::EncryptResultAnalyse::EncryptResultAnalyse(GpgError error,
+GpgFrontend::GpgEncryptResultAnalyse::GpgEncryptResultAnalyse(GpgError error,
GpgEncrResult result)
: error_(error), result_(std::move(result)) {}
-void GpgFrontend::EncryptResultAnalyse::do_analyse() {
+void GpgFrontend::GpgEncryptResultAnalyse::do_analyse() {
LOG(INFO) << _("Start Encrypt Result Analyse");
stream_ << "[#] " << _("Encrypt Operation") << " ";
diff --git a/src/gpg/result_analyse/EncryptResultAnalyse.h b/src/core/function/result_analyse/GpgEncryptResultAnalyse.h
index 9b03c37f..c5125fdc 100644
--- a/src/gpg/result_analyse/EncryptResultAnalyse.h
+++ b/src/core/function/result_analyse/GpgEncryptResultAnalyse.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,34 +8,36 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#ifndef GPGFRONTEND_ENCRYPTRESULTANALYSE_H
-#define GPGFRONTEND_ENCRYPTRESULTANALYSE_H
+#ifndef GPGFRONTEND_GPGENCRYPTRESULTANALYSE_H
+#define GPGFRONTEND_GPGENCRYPTRESULTANALYSE_H
-#include "ResultAnalyse.h"
-#include "gpg/GpgConstants.h"
+#include "GpgResultAnalyse.h"
+#include "core/GpgConstants.h"
namespace GpgFrontend {
/**
* @brief
*
*/
-class EncryptResultAnalyse : public ResultAnalyse {
+class GpgEncryptResultAnalyse : public GpgResultAnalyse {
public:
/**
* @brief Construct a new Encrypt Result Analyse object
@@ -41,7 +45,7 @@ class EncryptResultAnalyse : public ResultAnalyse {
* @param error
* @param result
*/
- explicit EncryptResultAnalyse(GpgError error, GpgEncrResult result);
+ explicit GpgEncryptResultAnalyse(GpgError error, GpgEncrResult result);
protected:
/**
@@ -56,4 +60,4 @@ class EncryptResultAnalyse : public ResultAnalyse {
};
} // namespace GpgFrontend
-#endif // GPGFRONTEND_ENCRYPTRESULTANALYSE_H
+#endif // GPGFRONTEND_GPGENCRYPTRESULTANALYSE_H
diff --git a/src/core/function/result_analyse/GpgResultAnalyse.cpp b/src/core/function/result_analyse/GpgResultAnalyse.cpp
new file mode 100644
index 00000000..40ba4c3e
--- /dev/null
+++ b/src/core/function/result_analyse/GpgResultAnalyse.cpp
@@ -0,0 +1,46 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#include "GpgResultAnalyse.h"
+
+const std::string GpgFrontend::GpgResultAnalyse::GetResultReport() const {
+ return stream_.str();
+}
+
+int GpgFrontend::GpgResultAnalyse::GetStatus() const { return status_; }
+
+void GpgFrontend::GpgResultAnalyse::set_status(int m_status) {
+ if (m_status < status_) status_ = m_status;
+}
+
+void GpgFrontend::GpgResultAnalyse::Analyse() {
+ if (!analysed_) {
+ do_analyse();
+ analysed_ = true;
+ }
+}
diff --git a/src/gpg/result_analyse/ResultAnalyse.h b/src/core/function/result_analyse/GpgResultAnalyse.h
index 97dc0783..888c6449 100644
--- a/src/gpg/result_analyse/ResultAnalyse.h
+++ b/src/core/function/result_analyse/GpgResultAnalyse.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,37 +8,39 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#ifndef GPGFRONTEND_RESULTANALYSE_H
-#define GPGFRONTEND_RESULTANALYSE_H
+#ifndef GPGFRONTEND_GPGRESULTANALYSE_H
+#define GPGFRONTEND_GPGRESULTANALYSE_H
#include <sstream>
#include <string>
-#include "gpg/GpgConstants.h"
+#include "core/GpgConstants.h"
namespace GpgFrontend {
-class ResultAnalyse {
+class GpgResultAnalyse {
public:
/**
* @brief Construct a new Result Analyse object
*
*/
- ResultAnalyse() = default;
+ GpgResultAnalyse() = default;
/**
* @brief Get the Result Report object
@@ -79,4 +83,4 @@ class ResultAnalyse {
} // namespace GpgFrontend
-#endif // GPGFRONTEND_RESULTANALYSE_H
+#endif // GPGFRONTEND_GPGRESULTANALYSE_H
diff --git a/src/gpg/result_analyse/SignResultAnalyse.cpp b/src/core/function/result_analyse/GpgSignResultAnalyse.cpp
index 511bd54d..e389523c 100644
--- a/src/gpg/result_analyse/SignResultAnalyse.cpp
+++ b/src/core/function/result_analyse/GpgSignResultAnalyse.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,31 +8,33 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/result_analyse/SignResultAnalyse.h"
+#include "GpgSignResultAnalyse.h"
-#include "gpg/function/GpgKeyGetter.h"
+#include "function/gpg/GpgKeyGetter.h"
-GpgFrontend::SignResultAnalyse::SignResultAnalyse(GpgError error,
+GpgFrontend::GpgSignResultAnalyse::GpgSignResultAnalyse(GpgError error,
GpgSignResult result)
: error_(error), result_(std::move(result)) {}
-void GpgFrontend::SignResultAnalyse::do_analyse() {
+void GpgFrontend::GpgSignResultAnalyse::do_analyse() {
LOG(INFO) << _("Start Sign Result Analyse");
stream_ << "[#] " << _("Sign Operation") << " ";
diff --git a/src/gpg/result_analyse/SignResultAnalyse.h b/src/core/function/result_analyse/GpgSignResultAnalyse.h
index 62f10d14..d593b33d 100644
--- a/src/gpg/result_analyse/SignResultAnalyse.h
+++ b/src/core/function/result_analyse/GpgSignResultAnalyse.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,26 +8,28 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#ifndef GPGFRONTEND_SIGNRESULTANALYSE_H
-#define GPGFRONTEND_SIGNRESULTANALYSE_H
+#ifndef GPGFRONTEND_GPGSIGNRESULTANALYSE_H
+#define GPGFRONTEND_GPGSIGNRESULTANALYSE_H
-#include "ResultAnalyse.h"
+#include "GpgResultAnalyse.h"
namespace GpgFrontend {
@@ -33,7 +37,7 @@ namespace GpgFrontend {
* @brief
*
*/
-class SignResultAnalyse : public ResultAnalyse {
+class GpgSignResultAnalyse : public GpgResultAnalyse {
public:
/**
* @brief Construct a new Sign Result Analyse object
@@ -41,7 +45,7 @@ class SignResultAnalyse : public ResultAnalyse {
* @param error
* @param result
*/
- explicit SignResultAnalyse(GpgError error, GpgSignResult result);
+ explicit GpgSignResultAnalyse(GpgError error, GpgSignResult result);
protected:
/**
@@ -58,4 +62,4 @@ class SignResultAnalyse : public ResultAnalyse {
} // namespace GpgFrontend
-#endif // GPGFRONTEND_SIGNRESULTANALYSE_H
+#endif // GPGFRONTEND_GPGSIGNRESULTANALYSE_H
diff --git a/src/gpg/result_analyse/VerifyResultAnalyse.cpp b/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp
index c1c8d2be..44031e67 100644
--- a/src/gpg/result_analyse/VerifyResultAnalyse.cpp
+++ b/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,35 +8,37 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/result_analyse/VerifyResultAnalyse.h"
+#include "GpgVerifyResultAnalyse.h"
#include <boost/format.hpp>
#include "GpgFrontend.h"
-#include "gpg/GpgConstants.h"
-#include "gpg/function/GpgKeyGetter.h"
+#include "core/GpgConstants.h"
+#include "function/gpg/GpgKeyGetter.h"
-GpgFrontend::VerifyResultAnalyse::VerifyResultAnalyse(GpgError error,
+GpgFrontend::GpgVerifyResultAnalyse::GpgVerifyResultAnalyse(GpgError error,
GpgVerifyResult result)
: error_(error), result_(std::move(result)) {}
-void GpgFrontend::VerifyResultAnalyse::do_analyse() {
+void GpgFrontend::GpgVerifyResultAnalyse::do_analyse() {
LOG(INFO) << _("started");
stream_ << "[#] " << _("Verify Operation") << " ";
@@ -168,7 +172,7 @@ void GpgFrontend::VerifyResultAnalyse::do_analyse() {
}
}
-bool GpgFrontend::VerifyResultAnalyse::print_signer(std::stringstream &stream,
+bool GpgFrontend::GpgVerifyResultAnalyse::print_signer(std::stringstream &stream,
gpgme_signature_t sign) {
bool keyFound = true;
auto key = GpgFrontend::GpgKeyGetter::GetInstance().GetKey(sign->fpr);
@@ -198,13 +202,13 @@ bool GpgFrontend::VerifyResultAnalyse::print_signer(std::stringstream &stream,
return keyFound;
}
-gpgme_signature_t GpgFrontend::VerifyResultAnalyse::GetSignatures() const {
+gpgme_signature_t GpgFrontend::GpgVerifyResultAnalyse::GetSignatures() const {
if (result_)
return result_->signatures;
else
return nullptr;
}
GpgFrontend::GpgVerifyResult
-GpgFrontend::VerifyResultAnalyse::TakeChargeOfResult() {
+GpgFrontend::GpgVerifyResultAnalyse::TakeChargeOfResult() {
return std::move(result_);
}
diff --git a/src/gpg/result_analyse/VerifyResultAnalyse.h b/src/core/function/result_analyse/GpgVerifyResultAnalyse.h
index c58c6afc..12e4b7ff 100644
--- a/src/gpg/result_analyse/VerifyResultAnalyse.h
+++ b/src/core/function/result_analyse/GpgVerifyResultAnalyse.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,34 +8,36 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#ifndef GPGFRONTEND_VERIFYRESULTANALYSE_H
-#define GPGFRONTEND_VERIFYRESULTANALYSE_H
+#ifndef GPGFRONTEND_GPGVERIFYRESULTANALYSE_H
+#define GPGFRONTEND_GPGVERIFYRESULTANALYSE_H
-#include "ResultAnalyse.h"
-#include "gpg/model/GpgKeySignature.h"
+#include "GpgResultAnalyse.h"
+#include "core/model/GpgKeySignature.h"
namespace GpgFrontend {
/**
* @brief
*
*/
-class VerifyResultAnalyse : public ResultAnalyse {
+class GpgVerifyResultAnalyse : public GpgResultAnalyse {
public:
/**
* @brief Construct a new Verify Result Analyse object
@@ -41,7 +45,7 @@ class VerifyResultAnalyse : public ResultAnalyse {
* @param error
* @param result
*/
- explicit VerifyResultAnalyse(GpgError error, GpgVerifyResult result);
+ explicit GpgVerifyResultAnalyse(GpgError error, GpgVerifyResult result);
/**
* @brief Get the Signatures object
@@ -81,4 +85,4 @@ class VerifyResultAnalyse : public ResultAnalyse {
} // namespace GpgFrontend
-#endif // GPGFRONTEND_VERIFYRESULTANALYSE_H
+#endif // GPGFRONTEND_GPGVERIFYRESULTANALYSE_H
diff --git a/src/gpg/model/GpgData.cpp b/src/core/model/GpgData.cpp
index 4a2e4ccb..7fda4416 100644
--- a/src/gpg/model/GpgData.cpp
+++ b/src/core/model/GpgData.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,23 +8,25 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/model/GpgData.h"
+#include "core/model/GpgData.h"
GpgFrontend::GpgData::GpgData() {
gpgme_data_t data;
diff --git a/src/gpg/model/GpgData.h b/src/core/model/GpgData.h
index 73ba830d..c06f78d6 100644
--- a/src/gpg/model/GpgData.h
+++ b/src/core/model/GpgData.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,26 +8,28 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef _GPGDATA_H
#define _GPGDATA_H
-#include "gpg/GpgConstants.h"
+#include "core/GpgConstants.h"
namespace GpgFrontend {
/**
diff --git a/src/gpg/model/GpgKey.cpp b/src/core/model/GpgKey.cpp
index 720167c5..b0952cfa 100644
--- a/src/gpg/model/GpgKey.cpp
+++ b/src/core/model/GpgKey.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,23 +8,25 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/model/GpgKey.h"
+#include "core/model/GpgKey.h"
GpgFrontend::GpgKey::GpgKey(gpgme_key_t &&key) : key_ref_(std::move(key)) {}
diff --git a/src/gpg/model/GpgKey.h b/src/core/model/GpgKey.h
index faf0d02e..14315d4c 100644
--- a/src/gpg/model/GpgKey.h
+++ b/src/core/model/GpgKey.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/src/gpg/model/GpgKeySignature.cpp b/src/core/model/GpgKeySignature.cpp
index 478b3d38..0c11a93b 100644
--- a/src/gpg/model/GpgKeySignature.cpp
+++ b/src/core/model/GpgKeySignature.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,23 +8,25 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/model/GpgKeySignature.h"
+#include "core/model/GpgKeySignature.h"
GpgFrontend::GpgKeySignature::GpgKeySignature(gpgme_key_sig_t sig)
: signature_ref_(sig, [&](gpgme_key_sig_t signature) {}) {}
diff --git a/src/gpg/model/GpgKeySignature.h b/src/core/model/GpgKeySignature.h
index dcae3581..33b84904 100644
--- a/src/gpg/model/GpgKeySignature.h
+++ b/src/core/model/GpgKeySignature.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -28,7 +32,7 @@
#include <boost/date_time.hpp>
#include <string>
-#include "gpg/GpgConstants.h"
+#include "core/GpgConstants.h"
/**
* @brief
diff --git a/src/gpg/model/GpgSignature.cpp b/src/core/model/GpgSignature.cpp
index 06180918..f8084442 100644
--- a/src/gpg/model/GpgSignature.cpp
+++ b/src/core/model/GpgSignature.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/src/gpg/model/GpgSignature.h b/src/core/model/GpgSignature.h
index 026d2d62..942f0097 100644
--- a/src/gpg/model/GpgSignature.h
+++ b/src/core/model/GpgSignature.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -28,7 +32,7 @@
#include <boost/date_time/gregorian/greg_date.hpp>
#include <boost/date_time/posix_time/conversion.hpp>
-#include "gpg/GpgConstants.h"
+#include "core/GpgConstants.h"
namespace GpgFrontend {
diff --git a/src/gpg/model/GpgSubKey.cpp b/src/core/model/GpgSubKey.cpp
index 83fbcaa2..767f9c5d 100644
--- a/src/gpg/model/GpgSubKey.cpp
+++ b/src/core/model/GpgSubKey.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,22 +8,24 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/model/GpgSubKey.h"
+#include "core/model/GpgSubKey.h"
GpgFrontend::GpgSubKey::GpgSubKey(gpgme_subkey_t subkey)
: _subkey_ref(subkey, [&](gpgme_subkey_t subkey) {}) {}
diff --git a/src/gpg/model/GpgSubKey.h b/src/core/model/GpgSubKey.h
index 5c5f8e6b..1aadcdac 100644
--- a/src/gpg/model/GpgSubKey.h
+++ b/src/core/model/GpgSubKey.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -28,7 +32,7 @@
#include <boost/date_time.hpp>
#include <string>
-#include "gpg/GpgConstants.h"
+#include "core/GpgConstants.h"
namespace GpgFrontend {
diff --git a/src/gpg/model/GpgTOFUInfo.cpp b/src/core/model/GpgTOFUInfo.cpp
index 0f18a1c2..8c83b360 100644
--- a/src/gpg/model/GpgTOFUInfo.cpp
+++ b/src/core/model/GpgTOFUInfo.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/src/gpg/model/GpgTOFUInfo.h b/src/core/model/GpgTOFUInfo.h
index 40a3a3d7..b2fea4cf 100644
--- a/src/gpg/model/GpgTOFUInfo.h
+++ b/src/core/model/GpgTOFUInfo.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,26 +8,28 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef GPGFRONTEND_GPGTOFU_H
#define GPGFRONTEND_GPGTOFU_H
-#include "gpg/GpgConstants.h"
+#include "core/GpgConstants.h"
namespace GpgFrontend {
/**
diff --git a/src/gpg/model/GpgUID.cpp b/src/core/model/GpgUID.cpp
index b8d86323..6d98c882 100644
--- a/src/gpg/model/GpgUID.cpp
+++ b/src/core/model/GpgUID.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,23 +8,25 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "gpg/model/GpgUID.h"
+#include "core/model/GpgUID.h"
GpgFrontend::GpgUID::GpgUID(gpgme_user_id_t uid)
: uid_ref_(uid, [&](gpgme_user_id_t uid) {}) {} \ No newline at end of file
diff --git a/src/gpg/model/GpgUID.h b/src/core/model/GpgUID.h
index 36c40f4f..7f8daf98 100644
--- a/src/gpg/model/GpgUID.h
+++ b/src/core/model/GpgUID.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/src/gpg/CMakeLists.txt b/src/gpg/CMakeLists.txt
deleted file mode 100644
index 693b9147..00000000
--- a/src/gpg/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-aux_source_directory(./result_analyse GPG_SOURCE)
-aux_source_directory(./function GPG_SOURCE)
-aux_source_directory(./model GPG_SOURCE)
-aux_source_directory(. GPG_SOURCE)
-
-add_library(gpgfrontend_core STATIC ${GPG_SOURCE})
-
-set(UTILS_DIR ${CMAKE_SOURCE_DIR}/utils)
-
-set(GPGME_LIB_DIR ${UTILS_DIR}/gpgme/lib)
-
-set(THIRD_PARTY_LIBS easyloggingpp config++)
-set(BOOST_LIBS Boost::date_time Boost::filesystem)
-
-if (MINGW)
- message(STATUS "Link GPG Static Library For MINGW")
- target_link_libraries(gpgfrontend_core ${THIRD_PARTY_LIBS}
- ${BOOST_LIBS}
- gpgme assuan gpg-error wsock32)
- target_compile_features(gpgfrontend_core PUBLIC cxx_std_17)
-elseif (APPLE)
- message(STATUS "Link GPG Static Library For macOS")
- target_link_libraries(gpgfrontend_core ${THIRD_PARTY_LIBS}
- gpgme assuan gpg-error
- ${BOOST_LIBS}
- dl)
- if (XCODE_BUILD)
- set_target_properties(gpgfrontend_core
- PROPERTIES
- ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
- LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
- LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
- endif ()
-else ()
- message(STATUS "Link GPG Static Library For Unix")
- target_link_libraries(gpgfrontend_core ${THIRD_PARTY_LIBS}
- gpgme assuan gpg-error
- ${BOOST_LIBS}
- pthread dl)
-endif ()
diff --git a/src/gpg/result_analyse/ResultAnalyse.cpp b/src/gpg/result_analyse/ResultAnalyse.cpp
deleted file mode 100644
index 21e46c9c..00000000
--- a/src/gpg/result_analyse/ResultAnalyse.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#include "gpg/result_analyse/ResultAnalyse.h"
-
-const std::string GpgFrontend::ResultAnalyse::GetResultReport() const {
- return stream_.str();
-}
-
-int GpgFrontend::ResultAnalyse::GetStatus() const { return status_; }
-
-void GpgFrontend::ResultAnalyse::set_status(int m_status) {
- if (m_status < status_) status_ = m_status;
-}
-
-void GpgFrontend::ResultAnalyse::Analyse() {
- if (!analysed_) {
- do_analyse();
- analysed_ = true;
- }
-}
diff --git a/src/init.cpp b/src/init.cpp
index da547674..ccfeca90 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,29 +8,37 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include <boost/date_time.hpp>
-#include "ui/settings/GlobalSettingStation.h"
+#include "core/function/GlobalSettingStation.h"
-std::vector<boost::filesystem::path> get_files_of_directory(
- const boost::filesystem::path& _path) {
- namespace fs = boost::filesystem;
+/**
+ * @brief Get the files of a given directory
+ *
+ * @param _path target directory
+ * @return std::vector<std::filesystem::path>
+ */
+std::vector<std::filesystem::path> get_files_of_directory(
+ const std::filesystem::path& _path) {
+ namespace fs = std::filesystem;
std::vector<fs::path> path_list;
if (!_path.empty()) {
fs::recursive_directory_iterator end;
@@ -41,6 +51,10 @@ std::vector<boost::filesystem::path> get_files_of_directory(
return path_list;
}
+/**
+ * @brief setup logging system and do proper initialization
+ *
+ */
void init_logging() {
using namespace boost::posix_time;
using namespace boost::gregorian;
@@ -52,11 +66,13 @@ void init_logging() {
defaultConf.setToDefault();
el::Loggers::reconfigureLogger("default", defaultConf);
+ // apply settings
defaultConf.setGlobally(el::ConfigurationType::Format,
"%datetime %level %func %msg");
+ // get the log directory
auto logfile_path =
- (GpgFrontend::UI::GlobalSettingStation::GetInstance().GetLogDir() /
+ (GpgFrontend::GlobalSettingStation::GetInstance().GetLogDir() /
to_iso_string(now));
logfile_path.replace_extension(".log");
defaultConf.setGlobally(el::ConfigurationType::Filename,
@@ -64,26 +80,39 @@ void init_logging() {
el::Loggers::reconfigureLogger("default", defaultConf);
- LOG(INFO) << _("logfile Path") << logfile_path;
+ LOG(INFO) << _("log file path") << logfile_path;
}
+/**
+ * @brief load all certificates from the given path
+ * and add them to the given certificate store in GlobalSettingStation
+ */
void init_certs() {
- std::vector<vmime::shared_ptr<vmime::security::cert::X509Certificate>>
- root_certs;
+ // get the certificate directory
auto cert_file_paths = get_files_of_directory(
- GpgFrontend::UI::GlobalSettingStation::GetInstance().GetCertsDir());
+ GpgFrontend::GlobalSettingStation::GetInstance().GetCertsDir());
- auto& _instance = GpgFrontend::UI::GlobalSettingStation::GetInstance();
+ // get the instance of the GlobalSettingStation
+ auto& _instance = GpgFrontend::GlobalSettingStation::GetInstance();
for (const auto& cert_file_path : cert_file_paths) {
+ // add the certificate to the store
_instance.AddRootCert(cert_file_path);
}
+
+ // show the number of loaded certificates
LOG(INFO) << _("root certs loaded") << _instance.GetRootCerts().size();
}
+/**
+ * @brief setup the locale and load the translations
+ *
+ */
void init_locale() {
+ // get the instance of the GlobalSettingStation
auto& settings =
- GpgFrontend::UI::GlobalSettingStation::GetInstance().GetUISettings();
+ GpgFrontend::GlobalSettingStation::GetInstance().GetUISettings();
+ // create general settings if not exist
if (!settings.exists("general") ||
settings.lookup("general").getType() != libconfig::Setting::TypeGroup)
settings.add("general", libconfig::Setting::TypeGroup);
@@ -93,7 +122,8 @@ void init_locale() {
if (!general.exists("lang"))
general.add("lang", libconfig::Setting::TypeString) = "";
- GpgFrontend::UI::GlobalSettingStation::GetInstance().SyncSettings();
+ // sync the settings to the file
+ GpgFrontend::GlobalSettingStation::GetInstance().SyncSettings();
LOG(INFO) << "current system locale" << setlocale(LC_ALL, nullptr);
@@ -104,9 +134,9 @@ void init_locale() {
};
LOG(INFO) << "lang from settings" << lang;
- LOG(INFO) << "PROJECT_NAME" << PROJECT_NAME;
+ LOG(INFO) << "project name" << PROJECT_NAME;
LOG(INFO) << "locales path"
- << GpgFrontend::UI::GlobalSettingStation::GetInstance()
+ << GpgFrontend::GlobalSettingStation::GetInstance()
.GetLocaleDir()
.c_str();
@@ -147,7 +177,7 @@ void init_locale() {
#endif
bindtextdomain(PROJECT_NAME,
- GpgFrontend::UI::GlobalSettingStation::GetInstance()
+ GpgFrontend::GlobalSettingStation::GetInstance()
.GetLocaleDir()
.string()
.c_str());
diff --git a/src/main.cpp b/src/main.cpp
index 36afdd4b..3f72be7f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,49 +8,90 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
+/**
+ * \mainpage GpgFrontend Develop Document Main Page
+ */
+
#include <csetjmp>
#include <csignal>
#include <cstdlib>
#include "GpgFrontendBuildInfo.h"
-#include "gpg/GpgFunctionObject.h"
-#include "ui/MainWindow.h"
+#include "core/GpgFunctionObject.h"
+#include "ui/main_window/MainWindow.h"
#include "ui/thread/CtxCheckThread.h"
#if !defined(RELEASE) && defined(WINDOWS)
-#include "ui/settings/GlobalSettingStation.h"
+#include "core/function/GlobalSettingStation.h"
#endif
-// Easy Logging Cpp
+/**
+ * \brief initialize the easylogging++ library.
+ */
INITIALIZE_EASYLOGGINGPP
-// Recover buff
+/**
+ * \brief Store the jump buff and make it possible to recover from a crash.
+ */
jmp_buf recover_env;
+/**
+ * @brief
+ *
+ */
extern void init_logging();
+
+/**
+ * @brief
+ *
+ */
extern void init_certs();
+
+/**
+ * @brief
+ *
+ */
extern void init_locale();
+
+/**
+ * @brief
+ *
+ * @param sig
+ */
extern void handle_signal(int sig);
+
+/**
+ * @brief
+ *
+ */
extern void before_exit();
+/**
+ *
+ * @param argc
+ * @param argv
+ * @return
+ */
int main(int argc, char* argv[]) {
- // Register Signals
+ // re
signal(SIGSEGV, handle_signal);
signal(SIGFPE, handle_signal);
signal(SIGILL, handle_signal);
@@ -56,10 +99,10 @@ int main(int argc, char* argv[]) {
// clean something before exit
atexit(before_exit);
- // Qt
+ // initialize qt resources
Q_INIT_RESOURCE(gpgfrontend);
- // Qt App
+ // create qt application
QApplication app(argc, argv);
#ifndef MACOS
@@ -71,13 +114,13 @@ int main(int argc, char* argv[]) {
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
- // config logging system
+ // initialize logging system
init_logging();
- // root certs for tls connection
+ // init certs for tls connection
init_certs();
- // App config
+ // set the extra information of the build
QApplication::setApplicationVersion(BUILD_VERSION);
QApplication::setApplicationName(PROJECT_NAME);
@@ -89,8 +132,8 @@ int main(int argc, char* argv[]) {
#if !defined(RELEASE) && defined(WINDOWS)
// css
- boost::filesystem::path css_path =
- GpgFrontend::UI::GlobalSettingStation::GetInstance().GetResourceDir() /
+ std::filesystem::path css_path =
+ GpgFrontend::GlobalSettingStation::GetInstance().GetResourceDir() /
"css" / "default.qss";
QFile file(css_path.string().c_str());
file.open(QFile::ReadOnly);
@@ -101,9 +144,9 @@ int main(int argc, char* argv[]) {
#ifdef GPG_STANDALONE_MODE
LOG(INFO) << "GPG_STANDALONE_MODE Enabled";
- auto gpg_path = GpgFrontend::UI::GlobalSettingStation::GetInstance()
+ auto gpg_path = GpgFrontend::GlobalSettingStation::GetInstance()
.GetStandaloneGpgBinDir();
- auto db_path = GpgFrontend::UI::GlobalSettingStation::GetInstance()
+ auto db_path = GpgFrontend::GlobalSettingStation::GetInstance()
.GetStandaloneDatabaseDir();
GpgFrontend::GpgContext::CreateInstance(
GpgFrontend::SingletonFunctionObject<
@@ -112,12 +155,12 @@ int main(int argc, char* argv[]) {
gpg_path.string()));
#endif
+ // create the thread to load the gpg context
auto* init_ctx_thread = new GpgFrontend::UI::CtxCheckThread();
-
QApplication::connect(init_ctx_thread, &QThread::finished, init_ctx_thread,
&QThread::deleteLater);
- // Waiting Dialog
+ // create and show loading window before starting the main window
auto* waiting_dialog = new QProgressDialog();
waiting_dialog->setMaximum(0);
waiting_dialog->setMinimum(0);
@@ -141,10 +184,11 @@ int main(int argc, char* argv[]) {
exit(0);
});
- // Show Waiting Dialog
+ // show the loading window
waiting_dialog->show();
waiting_dialog->setFocus();
+ // start the thread to load the gpg context
init_ctx_thread->start();
QEventLoop loop;
QApplication::connect(init_ctx_thread, &QThread::finished, &loop,
@@ -164,18 +208,22 @@ int main(int argc, char* argv[]) {
int r = setjmp(recover_env);
#endif
if (!r) {
+#ifdef RELEASE
try {
- // i18n
+#endif
+ // init the i18n support
init_locale();
QApplication::setQuitOnLastWindowClosed(true);
+ // create main window and show it
auto main_window = std::make_unique<GpgFrontend::UI::MainWindow>();
- main_window->init();
+ main_window->Init();
main_window->show();
return_from_event_loop_code = QApplication::exec();
-
+#ifdef RELEASE
} catch (...) {
+ // catch all unhandled exceptions and notify the user
QMessageBox::information(
nullptr, _("Unhandled Exception Thrown"),
_("Oops, an unhandled exception was thrown "
@@ -186,8 +234,10 @@ int main(int argc, char* argv[]) {
return_from_event_loop_code = RESTART_CODE;
continue;
}
+#endif
} else {
+ // when signal is caught, restart the main window
QMessageBox::information(
nullptr, _("A serious error has occurred"),
_("Oh no! GpgFrontend caught a serious error in the software, so it "
@@ -201,5 +251,6 @@ int main(int argc, char* argv[]) {
LOG(INFO) << "loop refresh";
} while (return_from_event_loop_code == RESTART_CODE);
+ // exit the program
return return_from_event_loop_code;
}
diff --git a/src/server/BaseAPI.cpp b/src/server/BaseAPI.cpp
deleted file mode 100644
index aa4c3f98..00000000
--- a/src/server/BaseAPI.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#include "server/BaseAPI.h"
-
-#include "rapidjson/writer.h"
-
-BaseAPI::BaseAPI(ComUtils::ServiceType serviceType)
- : utils(new ComUtils(nullptr)),
- reqUrl(utils->getUrl(serviceType)),
- request(reqUrl) {
- request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
-}
-
-BaseAPI::~BaseAPI() { utils->deleteLater(); }
-
-QNetworkReply *BaseAPI::send_json_data() {
- rapidjson::StringBuffer sb;
- rapidjson::Writer<rapidjson::StringBuffer> writer(sb);
- document.Accept(writer);
-
- QByteArray postData(sb.GetString());
- qDebug() << "postData" << QString::fromUtf8(postData);
-
- auto reply = utils->getNetworkManager().post(request, postData);
-
- while (reply->isRunning()) QApplication::processEvents();
-
- QByteArray replyData = reply->readAll().constData();
- if (utils->checkServerReply(replyData)) {
- good = true, deal_reply();
- }
-
- return reply;
-}
-
-void BaseAPI::start() {
- construct_json();
- send_json_data()->deleteLater();
-}
-
-void BaseAPI::refresh() {
- document.Clear();
- utils->clear();
- good = false;
-}
-
-bool BaseAPI::result() const { return good; }
diff --git a/src/server/BaseAPI.h b/src/server/BaseAPI.h
deleted file mode 100644
index 46766fed..00000000
--- a/src/server/BaseAPI.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#ifndef GPGFRONTEND_ZH_CN_TS_BASEAPI_H
-#define GPGFRONTEND_ZH_CN_TS_BASEAPI_H
-
-#include "ComUtils.h"
-#include "GpgFrontend.h"
-#include "rapidjson/document.h"
-
-class BaseAPI : public QObject {
- Q_OBJECT
- public:
- explicit BaseAPI(ComUtils::ServiceType serviceType);
-
- ~BaseAPI() override;
-
- void start();
-
- void refresh();
-
- [[nodiscard]] bool result() const;
-
- private:
- ComUtils *utils;
-
- QUrl reqUrl;
-
- QNetworkRequest request;
-
- QNetworkReply *send_json_data();
-
- protected:
- bool good = false;
-
- rapidjson::Document document;
-
- const ComUtils &getUtils() { return *utils; };
-
- virtual void construct_json() = 0;
-
- virtual void deal_reply() = 0;
-};
-
-#endif // GPGFRONTEND_ZH_CN_TS_BASEAPI_H
diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt
deleted file mode 100644
index 423e9d1e..00000000
--- a/src/server/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-aux_source_directory(./api SERVER_SOURCE)
-aux_source_directory(. SERVER_SOURCE)
-
-add_library(server STATIC ${SERVER_SOURCE})
-
-target_link_libraries(server
- Qt5::Network Qt5::Widgets Qt5::Core)
diff --git a/src/server/ComUtils.cpp b/src/server/ComUtils.cpp
deleted file mode 100644
index 6a5ce7b0..00000000
--- a/src/server/ComUtils.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#include "server/ComUtils.h"
-
-/**
- * check server reply if it can parse into a json object
- * @param reply reply data in byte array
- * @return if successful
- */
-bool GpgFrontend::ComUtils::checkServerReply(const QByteArray &reply) {
- if (reply.isEmpty()) {
- QMessageBox::critical(
- this, _("Error"),
- _("Nothing Reply. Please check the Internet connection."));
- return false;
- }
-
- qDebug() << "Reply" << reply;
-
- /**
- * Server Reply Format(Except Timeout)
- * {
- * "status": 200,
- * "msg": "OK",
- * "timestamp": 1628652783895
- * "data" : {
- * ...
- * }
- * }
- */
-
- // check if reply is a json object
- if (replyDoc.Parse(reply).HasParseError() || !replyDoc.IsObject()) {
- QMessageBox::critical(this, _("Error"), _("Unknown Error"));
- return false;
- }
-
- // check status(int) and message(string)
- if (replyDoc.HasMember("status") && replyDoc.HasMember("msg") &&
- replyDoc.HasMember("timestamp") && replyDoc.HasMember("data") &&
- replyDoc["status"].IsNumber() && replyDoc["msg"].IsString() &&
- replyDoc["timestamp"].IsNumber() && replyDoc["data"].IsObject()) {
- int status = replyDoc["status"].GetInt();
- QDateTime time;
- time.setMSecsSinceEpoch(replyDoc["timestamp"].GetInt64());
- auto message = replyDoc["msg"].GetString();
- dataVal = replyDoc["data"].GetObject();
-
- qDebug() << "Reply Date & Time" << time;
-
- // check reply timestamp
- if (time < QDateTime::currentDateTime().addSecs(-10)) {
- QMessageBox::critical(this, _("Network Error"), _("Outdated Reply"));
- return false;
- }
-
- // check status code if successful (200-299)
- // check data object
- if (status / 100 == 2) {
- is_good = true;
- return true;
- } else {
- if (dataVal.HasMember("exceptionMessage") &&
- dataVal["exceptionMessage"].IsString())
- QMessageBox::critical(this, message,
- dataVal["exceptionMessage"].GetString());
- else
- QMessageBox::critical(this, message, _("Unknown Reason"));
- }
-
- } else
- QMessageBox::critical(this, _("Network Error"), _("Unknown Reply Format"));
-
- return false;
-}
-
-/**
- * get value in data
- * @param key key of value
- * @return value in string format
- */
-QString GpgFrontend::ComUtils::getDataValueStr(const QString &key) const {
- if (is_good) {
- auto k_byte_array = key.toUtf8();
- if (dataVal.HasMember(k_byte_array.data())) {
- return dataVal[k_byte_array.data()].GetString();
- } else
- return {};
- } else
- return {};
-}
-
-/**
- * Get eventually url by service type
- * @param type service which server provides
- * @return url
- */
-QString GpgFrontend::ComUtils::getUrl(ComUtils::ServiceType type) const {
- auto host =
- settings
- .value("general/currentGpgfrontendServer", "service.gpgfrontend.pub")
- .toString();
-
- auto protocol = QString();
- // Localhost Debug Server
- if (host == "localhost")
- protocol = "http://";
- else
- protocol = "https://";
-
- auto url = protocol + host + ":9049/";
-
- switch (type) {
- case GetServiceToken:
- url += "/user";
- break;
- case ShortenCryptText:
- url += "/text/new";
- break;
- case GetFullCryptText:
- url += "/text/get";
- break;
- case UploadPubkey:
- url += "/key/upload";
- break;
- case GetPubkey:
- url += "/key/get";
- break;
- }
-
- qDebug() << "ComUtils getUrl" << url;
-
- return url;
-}
-
-bool GpgFrontend::ComUtils::checkDataValueStr(const QString &key) const {
- auto key_byte_array_data = key.toUtf8().constData();
- if (is_good) {
- return dataVal.HasMember(key_byte_array_data) &&
- dataVal[key_byte_array_data].IsString();
- } else
- return false;
-}
-
-bool GpgFrontend::ComUtils::checkServiceTokenFormat(const QString &uuid) const {
- return re_uuid.match(uuid).hasMatch();
-}
-
-QByteArray GpgFrontend::ComUtils::getSignStringBase64(
- GpgFrontend::GpgContext *ctx, const QString &str, const GpgKey &key) {
- std::vector<GpgKey> keys{key};
- QByteArray outSignText;
- auto signData = str.toUtf8();
-
- // The use of multi-threading brings an improvement in UI smoothness
- gpgme_error_t error;
- auto thread = QThread::create([&]() {
- error = ctx->sign(keys, signData, &outSignText, GPGME_SIG_MODE_NORMAL,
- nullptr, false);
- });
- thread->start();
- while (thread->isRunning()) QApplication::processEvents();
- thread->deleteLater();
-
- return outSignText.toBase64();
-}
-
-const rapidjson::Value &GpgFrontend::ComUtils::getDataValue(
- const QString &key) const {
- if (is_good) {
- auto k_byte_array = key.toUtf8();
- if (dataVal.HasMember(k_byte_array.data())) {
- return dataVal[k_byte_array.data()];
- }
- }
- throw std::runtime_error("Inner Error");
-}
-
-bool GpgFrontend::ComUtils::checkDataValue(const QString &key) const {
- auto key_byte_array_data = key.toUtf8().constData();
- if (is_good) {
- return dataVal.HasMember(key_byte_array_data);
- } else
- return false;
-}
-
-void GpgFrontend::ComUtils::clear() {
- this->dataVal.Clear();
- this->replyDoc.Clear();
- is_good = false;
-} \ No newline at end of file
diff --git a/src/server/ComUtils.h b/src/server/ComUtils.h
deleted file mode 100644
index f281f256..00000000
--- a/src/server/ComUtils.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#ifndef GPGFRONTEND_ZH_CN_TS_COMUTILS_H
-#define GPGFRONTEND_ZH_CN_TS_COMUTILS_H
-
-#include "GpgFrontend.h"
-#include "gpg/GpgContext.h"
-#include "rapidjson/document.h"
-
-namespace GpgFrontend {
-
-class ComUtils : public QWidget {
- Q_OBJECT
- public:
- enum ServiceType {
- GetServiceToken,
- ShortenCryptText,
- GetFullCryptText,
- UploadPubkey,
- GetPubkey
- };
-
- explicit ComUtils(QWidget *parent)
- : QWidget(parent),
- appPath(qApp->applicationDirPath()),
- settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini",
- QSettings::IniFormat) {}
-
- [[nodiscard]] QString getUrl(ServiceType type) const;
-
- bool checkServerReply(const QByteArray &reply);
-
- [[nodiscard]] QString getDataValueStr(const QString &key) const;
-
- [[nodiscard]] bool checkDataValueStr(const QString &key) const;
-
- [[nodiscard]] const rapidjson::Value &getDataValue(const QString &key) const;
-
- [[nodiscard]] bool checkDataValue(const QString &key) const;
-
- [[nodiscard]] bool checkServiceTokenFormat(const QString &serviceToken) const;
-
- static QByteArray getSignStringBase64(GpgFrontend::GpgContext *ctx,
- const QString &str, const GpgKey &key);
-
- [[nodiscard]] bool good() const { return is_good; }
-
- QNetworkAccessManager &getNetworkManager() { return networkMgr; }
-
- void clear();
-
- private:
- QString appPath;
- QSettings settings;
- rapidjson::Document replyDoc;
- rapidjson::Value dataVal;
- QNetworkAccessManager networkMgr;
- QRegularExpression re_uuid{
- R"(\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b)"};
-
- bool is_good = false;
-};
-
-} // namespace GpgFrontend
-
-#endif // GPGFRONTEND_ZH_CN_TS_COMUTILS_H
diff --git a/src/server/api/PubkeyGetter.cpp b/src/server/api/PubkeyGetter.cpp
deleted file mode 100644
index e2cb8708..00000000
--- a/src/server/api/PubkeyGetter.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#include "server/api/PubkeyGetter.h"
-
-PubkeyGetter::PubkeyGetter(GpgFrontend::GpgContext *ctx,
- const QVector<QString> &fprs)
- : BaseAPI(ComUtils::GetPubkey), mCtx(ctx), mFprs(fprs) {}
-
-void PubkeyGetter::construct_json() {
- document.SetArray();
- QStringList keyIds;
-
- rapidjson::Document::AllocatorType &allocator = document.GetAllocator();
-
- for (const auto &fprStr : mFprs) {
- rapidjson::Value fpr;
-
- auto fprByteArray = fprStr.toUtf8();
- fpr.SetString(fprByteArray.constData(), fprByteArray.count());
-
- document.PushBack(fpr, allocator);
- keyIds.clear();
- }
-}
-
-void PubkeyGetter::deal_reply() {
- const auto &utils = getUtils();
-
- /**
- * {
- * "pubkeys" : [
- * {
- * "publicKey" : ...,
- * "fpr" : ...,
- * "sha" : ...
- * },
- * ...
- * ]
- * }
- */
-
- if (!utils.checkDataValue("pubkeys")) {
- QMessageBox::critical(nullptr, _("Error"),
- _("The communication content with the server does "
- "not meet the requirements"));
- } else {
- auto &pubkeys = utils.getDataValue("pubkeys");
- qDebug() << "Pubkey Getter" << pubkeys.IsArray()
- << pubkeys.GetArray().Size();
- if (pubkeys.IsArray()) {
- for (const auto &pubkey : pubkeys.GetArray()) {
- if (pubkey.IsObject() && pubkey.HasMember("publicKey") &&
- pubkey.HasMember("fpr") && pubkey.HasMember("sha") &&
- pubkey["publicKey"].IsString() && pubkey["fpr"].IsString() &&
- pubkey["sha"].IsString()) {
- auto pubkeyData = QString(pubkey["publicKey"].GetString());
-
- QCryptographicHash shaGen(QCryptographicHash::Sha256);
- shaGen.addData(pubkeyData.toUtf8());
-
- if (shaGen.result().toHex() == pubkey["sha"].GetString()) {
- mCtx->importKey(pubkeyData.toUtf8());
- }
- }
- }
-
- } else {
- QMessageBox::critical(nullptr, _("Error"),
- _("The communication content with the server does "
- "not meet the requirements"));
- }
- }
-}
diff --git a/src/server/api/PubkeyGetter.h b/src/server/api/PubkeyGetter.h
deleted file mode 100644
index 6a3d50e9..00000000
--- a/src/server/api/PubkeyGetter.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#ifndef GPGFRONTEND_ZH_CN_TS_PUBKEYGETTER_H
-#define GPGFRONTEND_ZH_CN_TS_PUBKEYGETTER_H
-
-#include "GpgFrontend.h"
-#include "gpg/GpgContext.h"
-#include "server/BaseAPI.h"
-
-class ComUtils;
-
-/**
- * Get and Import Pubkey from server
- */
-class PubkeyGetter : public BaseAPI {
- public:
- PubkeyGetter(GpgFrontend::GpgContext *ctx, const QVector<QString> &fprs);
-
- private:
- GpgFrontend::GpgContext *mCtx;
-
- const QVector<QString> &mFprs;
-
- protected:
- void construct_json() final;
-
- void deal_reply() final;
-};
-
-#endif // GPGFRONTEND_ZH_CN_TS_PUBKEYGETTER_H
diff --git a/src/server/api/PubkeyUploader.cpp b/src/server/api/PubkeyUploader.cpp
deleted file mode 100644
index 35f764d8..00000000
--- a/src/server/api/PubkeyUploader.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#include "server/api/PubkeyUploader.h"
-
-PubkeyUploader::PubkeyUploader(GpgFrontend::GpgContext *ctx,
- const QVector<GpgKey> &keys)
- : BaseAPI(ComUtils::UploadPubkey), mCtx(ctx), mKeys(keys) {}
-
-void PubkeyUploader::construct_json() {
- document.SetArray();
- QStringList keyIds;
- QCryptographicHash shaGen(QCryptographicHash::Sha256);
-
- auto &allocator = document.GetAllocator();
-
- QVector<QByteArray> keysData;
- for (const auto &key : mKeys) {
- QByteArray keyDataBuf;
- keyIds << key.id;
-
- // The use of multi-threading brings an improvement in UI smoothness
- gpgme_error_t error;
- auto thread = QThread::create(
- [&]() { error = mCtx->exportKeys(&keyIds, &keyDataBuf); });
- thread->start();
- while (thread->isRunning()) QApplication::processEvents();
- thread->deleteLater();
- keysData.push_back(keyDataBuf);
- keyIds.clear();
- }
-
- int index = 0;
- for (const auto &keyData : keysData) {
- rapidjson::Value publicKeyObj, pubkey, sha, signedFpr;
-
- shaGen.addData(keyData);
- auto shaStr = shaGen.result().toHex();
- shaGen.reset();
-
- auto signFprStr =
- ComUtils::getSignStringBase64(mCtx, mKeys[index].fpr, mKeys[index]);
- qDebug() << "signFprStr" << signFprStr;
-
- pubkey.SetString(keyData.data(), keyData.count(), allocator);
- sha.SetString(shaStr.data(), shaStr.count(), allocator);
- signedFpr.SetString(signFprStr.data(), signFprStr.count(), allocator);
-
- publicKeyObj.SetObject();
- publicKeyObj.AddMember("publicKey", pubkey, allocator);
- publicKeyObj.AddMember("sha", sha, allocator);
- publicKeyObj.AddMember("signedFpr", signedFpr, allocator);
-
- document.PushBack(publicKeyObj, allocator);
- index++;
- }
-}
-
-void PubkeyUploader::deal_reply() {
- const auto &utils = getUtils();
-
- /**
- * {
- * "strings" : [
- * "...",
- * "..."
- * ]
- * }
- */
-
- if (!utils.checkDataValue("strings")) {
- QMessageBox::critical(nullptr, _("Error"),
- _("The communication content with the server does "
- "not meet the requirements"));
- } else {
- auto &strings = utils.getDataValue("strings");
- qDebug() << "Pubkey Uploader" << strings.IsArray()
- << strings.GetArray().Size();
- if (strings.IsArray() && strings.GetArray().Size() == mKeys.size()) {
- good = true;
- } else {
- good = false;
- }
- }
-}
diff --git a/src/server/api/PubkeyUploader.h b/src/server/api/PubkeyUploader.h
deleted file mode 100644
index efad27ac..00000000
--- a/src/server/api/PubkeyUploader.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#ifndef GPGFRONTEND_ZH_CN_TS_PUBKEYUPLOADER_H
-#define GPGFRONTEND_ZH_CN_TS_PUBKEYUPLOADER_H
-
-#include "GpgFrontend.h"
-#include "gpg/GpgContext.h"
-#include "rapidjson/document.h"
-#include "server/BaseAPI.h"
-
-/**
- * Upload pubkey into server
- */
-class PubkeyUploader : public BaseAPI {
- public:
- PubkeyUploader(GpgFrontend::GpgContext *ctx, const QVector<GpgKey> &keys);
-
- private:
- const QVector<GpgKey> &mKeys;
-
- GpgFrontend::GpgContext *mCtx;
-
- protected:
- void construct_json() final;
-
- void deal_reply() final;
-};
-
-#endif // GPGFRONTEND_ZH_CN_TS_PUBKEYUPLOADER_H
diff --git a/src/signal.cpp b/src/signal.cpp
index c43229b3..135bdead 100644
--- a/src/signal.cpp
+++ b/src/signal.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -28,6 +32,11 @@
extern jmp_buf recover_env;
+/**
+ * @brief handle the signal caught.
+ *
+ * @param sig signal number
+ */
void handle_signal(int sig) {
static int _repeat_handle_num = 1, last_sig = sig;
LOG(INFO) << "signal caught" << sig;
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index 0e3ed219..001a776d 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -1,67 +1,93 @@
+#
+# Copyright (C) 2021 Saturneric
+#
+# This file is part of GpgFrontend.
+#
+# GpgFrontend is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# GpgFrontend is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+#
+# The initial version of the source code is inherited from
+# the gpg4usb project, which is under GPL-3.0-or-later.
+#
+# All the source code of GpgFrontend was modified and released by
+# Saturneric<[email protected]> starting on May 12, 2021.
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
# tracking source files
aux_source_directory(. UI_SOURCE)
-aux_source_directory(./keypair_details UI_SOURCE)
-aux_source_directory(./widgets UI_SOURCE)
-aux_source_directory(./keygen UI_SOURCE)
-aux_source_directory(./main_window UI_SOURCE)
-aux_source_directory(./help UI_SOURCE)
-aux_source_directory(./settings UI_SOURCE)
-aux_source_directory(./thread UI_SOURCE)
-aux_source_directory(./details UI_SOURCE)
-aux_source_directory(./data_struct UI_SOURCE)
-aux_source_directory(./encoding UI_SOURCE)
+aux_source_directory(keypair_details UI_SOURCE)
+aux_source_directory(widgets UI_SOURCE)
+aux_source_directory(key_generate UI_SOURCE)
+aux_source_directory(main_window UI_SOURCE)
+aux_source_directory(help UI_SOURCE)
+aux_source_directory(settings UI_SOURCE)
+aux_source_directory(thread UI_SOURCE)
+aux_source_directory(details UI_SOURCE)
+aux_source_directory(struct UI_SOURCE)
+aux_source_directory(import_export UI_SOURCE)
+aux_source_directory(dialog UI_SOURCE)
if (SMTP_SUPPORT)
- aux_source_directory(./smtp UI_SOURCE)
+ aux_source_directory(mail UI_SOURCE)
endif ()
+# define libgpgfrontend_ui
add_library(gpgfrontend_ui STATIC ${UI_SOURCE})
-set(GPGFRONTEND_UI_LIB_NAME gpgfrontend_ui)
# link smtp-mime
if (SMTP_SUPPORT)
- target_link_libraries(${GPGFRONTEND_UI_LIB_NAME}
+ target_link_libraries(gpgfrontend_ui
smtp-mime)
endif ()
-# link json
-target_link_libraries(${GPGFRONTEND_UI_LIB_NAME}
- nlohmann_json::nlohmann_json)
-# Qt AES
-target_link_libraries(${GPGFRONTEND_UI_LIB_NAME}
- QtAES)
+
# link Qt
-target_link_libraries(${GPGFRONTEND_UI_LIB_NAME}
+target_link_libraries(gpgfrontend_ui
Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core)
# link vmime
if (NOT LINUX)
- target_link_libraries(${GPGFRONTEND_UI_LIB_NAME}
- gpgfrontend_vmime ssl crypto intl iconv)
- if(MINGW)
- target_link_libraries(${GPGFRONTEND_UI_LIB_NAME} ws2_32)
- endif()
+ # macOS
+ target_link_libraries(gpgfrontend_ui
+ gpgfrontend_vmime intl iconv)
+ if (MINGW)
+ target_link_libraries(gpgfrontend_ui ws2_32)
+ endif ()
else ()
- target_link_libraries(${GPGFRONTEND_UI_LIB_NAME}
+ target_link_libraries(gpgfrontend_ui
gpgfrontend_vmime anl ssl crypto)
endif ()
-# link easyloggingpp
-target_link_libraries(${GPGFRONTEND_UI_LIB_NAME}
- easyloggingpp)
-
# link gpgfrontend_core
-target_link_libraries(${GPGFRONTEND_UI_LIB_NAME}
+target_link_libraries(gpgfrontend_ui
gpgfrontend_core)
-# link openssl
-target_link_libraries(${GPGFRONTEND_UI_LIB_NAME} OpenSSL::SSL OpenSSL::Crypto)
+# link encoding_detect
+target_link_libraries(gpgfrontend_ui encoding_detect)
+
+# set up pch
+target_precompile_headers(gpgfrontend_ui PUBLIC GpgFrontendUI.h)
+# add ui generator include path
target_include_directories(gpgfrontend_ui PUBLIC
- ${CMAKE_CURRENT_BINARY_DIR}/${GPGFRONTEND_UI_LIB_NAME}_autogen/include)
+ ${CMAKE_CURRENT_BINARY_DIR}/gpgfrontend_ui_autogen/include)
+# using std c++ 17
+target_compile_features(gpgfrontend_ui PUBLIC cxx_std_17)
+# for xcode archive build
if (XCODE_BUILD)
- set_target_properties(${GPGFRONTEND_UI_LIB_NAME}
+ set_target_properties(gpgfrontend_ui
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
diff --git a/src/ui/FindWidget.cpp b/src/ui/FindWidget.cpp
deleted file mode 100644
index b95859a1..00000000
--- a/src/ui/FindWidget.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#include "ui/FindWidget.h"
-
-namespace GpgFrontend::UI {
-
-FindWidget::FindWidget(QWidget* parent, PlainTextEditorPage* edit)
- : QWidget(parent), mTextpage(edit) {
- findEdit = new QLineEdit(this);
- auto* closeButton = new QPushButton(
- this->style()->standardIcon(QStyle::SP_TitleBarCloseButton), QString(),
- this);
- auto* nextButton = new QPushButton(QIcon(":button_next.png"), QString());
- auto* previousButton = new QPushButton(QIcon(":button_previous.png"), "");
-
- auto* notificationWidgetLayout = new QHBoxLayout(this);
- notificationWidgetLayout->setContentsMargins(10, 0, 0, 0);
- notificationWidgetLayout->addWidget(new QLabel(QString(_("Find")) + ": "));
- notificationWidgetLayout->addWidget(findEdit, 2);
- notificationWidgetLayout->addWidget(nextButton);
- notificationWidgetLayout->addWidget(previousButton);
- notificationWidgetLayout->addWidget(closeButton);
-
- this->setLayout(notificationWidgetLayout);
- connect(findEdit, SIGNAL(textEdited(QString)), this, SLOT(slotFind()));
- connect(findEdit, SIGNAL(returnPressed()), this, SLOT(slotFindNext()));
- connect(nextButton, SIGNAL(clicked()), this, SLOT(slotFindNext()));
- connect(previousButton, SIGNAL(clicked()), this, SLOT(slotFindPrevious()));
- connect(closeButton, SIGNAL(clicked()), this, SLOT(slotClose()));
-
- // The timer is necessary for setting the focus
- QTimer::singleShot(0, findEdit, SLOT(setFocus()));
-}
-
-void FindWidget::setBackground() {
- auto cursor = mTextpage->getTextPage()->textCursor();
- // if match is found set background of QLineEdit to white, otherwise to red
- QPalette bgPalette(findEdit->palette());
-
- if (!findEdit->text().isEmpty() &&
- mTextpage->getTextPage()->document()->find(findEdit->text()).position() <
- 0) {
- bgPalette.setColor(QPalette::Base, "#ececba");
- } else {
- bgPalette.setColor(QPalette::Base, Qt::white);
- }
- findEdit->setPalette(bgPalette);
-}
-
-void FindWidget::slotFindNext() {
- QTextCursor cursor = mTextpage->getTextPage()->textCursor();
- cursor = mTextpage->getTextPage()->document()->find(
- findEdit->text(), cursor, QTextDocument::FindCaseSensitively);
-
- // if end of document is reached, restart search from beginning
- if (cursor.position() == -1) {
- cursor = mTextpage->getTextPage()->document()->find(
- findEdit->text(), cursor, QTextDocument::FindCaseSensitively);
- }
-
- // cursor should not stay at -1, otherwise text is not editable
- // todo: check how gedit handles this
- if (cursor.position() != -1) {
- mTextpage->getTextPage()->setTextCursor(cursor);
- }
- this->setBackground();
-}
-
-void FindWidget::slotFind() {
- QTextCursor cursor = mTextpage->getTextPage()->textCursor();
-
- if (cursor.anchor() == -1) {
- cursor = mTextpage->getTextPage()->document()->find(
- findEdit->text(), cursor, QTextDocument::FindCaseSensitively);
- } else {
- cursor = mTextpage->getTextPage()->document()->find(
- findEdit->text(), cursor.anchor(), QTextDocument::FindCaseSensitively);
- }
-
- // if end of document is reached, restart search from beginning
- if (cursor.position() == -1) {
- cursor = mTextpage->getTextPage()->document()->find(
- findEdit->text(), cursor, QTextDocument::FindCaseSensitively);
- }
-
- // cursor should not stay at -1, otherwise text is not editable
- // todo: check how gedit handles this
- if (cursor.position() != -1) {
- mTextpage->getTextPage()->setTextCursor(cursor);
- }
- this->setBackground();
-}
-
-void FindWidget::slotFindPrevious() {
- QTextDocument::FindFlags flags;
- flags |= QTextDocument::FindBackward;
- flags |= QTextDocument::FindCaseSensitively;
-
- QTextCursor cursor = mTextpage->getTextPage()->textCursor();
- cursor = mTextpage->getTextPage()->document()->find(findEdit->text(), cursor,
- flags);
-
- // if begin of document is reached, restart search from end
- if (cursor.position() == -1) {
- cursor = mTextpage->getTextPage()->document()->find(
- findEdit->text(), QTextCursor::End, flags);
- }
-
- // cursor should not stay at -1, otherwise text is not editable
- // todo: check how gedit handles this
- if (cursor.position() != -1) {
- mTextpage->getTextPage()->setTextCursor(cursor);
- }
- this->setBackground();
-}
-
-void FindWidget::keyPressEvent(QKeyEvent* e) {
- switch (e->key()) {
- case Qt::Key_Escape:
- this->slotClose();
- break;
- case Qt::Key_F3:
- if (e->modifiers() & Qt::ShiftModifier) {
- this->slotFindPrevious();
- } else {
- this->slotFindNext();
- }
- break;
- }
-}
-
-void FindWidget::slotClose() {
- QTextCursor cursor = mTextpage->getTextPage()->textCursor();
-
- if (cursor.position() == -1) {
- cursor.setPosition(0);
- mTextpage->getTextPage()->setTextCursor(cursor);
- }
- mTextpage->setFocus();
- close();
-}
-
-} // namespace GpgFrontend::UI
diff --git a/src/ui/GpgFrontendUI.h b/src/ui/GpgFrontendUI.h
index 49c83af0..ab6e9366 100644
--- a/src/ui/GpgFrontendUI.h
+++ b/src/ui/GpgFrontendUI.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,62 +8,51 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef GPGFRONTEND_GPGFRONTENDUI_H
#define GPGFRONTEND_GPGFRONTENDUI_H
-#include <optional>
-
+/**
+ * Basic dependency
+ */
#include <QtCore>
#include <QtNetwork>
#include <QtPrintSupport>
#include <QtWidgets>
+#include <optional>
+/**
+ * Project internal dependencies
+ */
#include "GpgFrontend.h"
-#include "gpg/GpgConstants.h"
-#include "gpg/GpgModel.h"
+#include "core/GpgConstants.h"
+#include "core/GpgModel.h"
-#undef LIBCONFIGXX_STATIC
-#define LIBCONFIGXX_STATIC
-#include <qt-aes/qaesencryption.h>
+/**
+ * 3rd party dependencies
+ */
-#include <libconfig.h++>
+#include <qt-aes/qaesencryption.h>
#ifdef SMTP_SUPPORT
#include <SmtpMime>
#endif
-#define VMIME_STATIC
-#undef VMIME_HAVE_MLANG
-#include <vmime/vmime.hpp>
-
-/**
- * Resources File(s) Path Vars
- */
-#if defined(MACOS) && defined(RELEASE)
-#define RESOURCE_DIR(appDir) (appDir + "/../Resources/")
-#define RESOURCE_DIR_BOOST_PATH(appDir) (appDir / ".." / "Resources")
-#elif defined(LINUX) && defined(RELEASE)
-#define RESOURCE_DIR(appDir) (appDir + "/../share/")
-#define RESOURCE_DIR_BOOST_PATH(appDir) (appDir / ".." / "share")
-#else
-#define RESOURCE_DIR(appDir) (appDir)
-#define RESOURCE_DIR_BOOST_PATH(appDir) (appDir)
-#endif
-
#endif // GPGFRONTEND_GPGFRONTENDUI_H
diff --git a/src/ui/KeyImportDetailDialog.h b/src/ui/KeyImportDetailDialog.h
deleted file mode 100644
index a75d466d..00000000
--- a/src/ui/KeyImportDetailDialog.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#ifndef __KEYIMPORTDETAILSDIALOG_H__
-#define __KEYIMPORTDETAILSDIALOG_H__
-
-#include <gpg/function/GpgKeyImportExporter.h>
-
-#include "gpg/GpgContext.h"
-#include "ui/GpgFrontendUI.h"
-
-namespace GpgFrontend::UI {
-class KeyImportDetailDialog : public QDialog {
- Q_OBJECT
-
- public:
- KeyImportDetailDialog(GpgImportInformation result, bool automatic,
- QWidget* parent = nullptr);
-
- private:
- void createGeneralInfoBox();
- void createKeysTable();
- void createButtonBox();
- static QString getStatusString(int keyStatus);
-
- QTableWidget* keysTable{};
- QGroupBox* generalInfoBox{};
- QGroupBox* keyInfoBox{};
- QDialogButtonBox* buttonBox{};
- GpgImportInformation mResult;
-};
-} // namespace GpgFrontend::UI
-
-#endif // __KEYIMPORTDETAILSDIALOG_H__
diff --git a/src/ui/KeyMgmt.cpp b/src/ui/KeyMgmt.cpp
index 2c23d1bf..57d8ba1f 100755
--- a/src/ui/KeyMgmt.cpp
+++ b/src/ui/KeyMgmt.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -26,23 +30,25 @@
#include <utility>
-#include "gpg/function/GpgKeyGetter.h"
-#include "gpg/function/GpgKeyImportExporter.h"
-#include "gpg/function/GpgKeyOpera.h"
+#include "core/function/gpg/GpgKeyGetter.h"
+#include "core/function/gpg/GpgKeyImportExporter.h"
+#include "core/function/gpg/GpgKeyOpera.h"
+#include "core/function/KeyPackageOperator.h"
#include "ui/SignalStation.h"
#include "ui/UserInterfaceUtils.h"
-#include "ui/keygen/SubkeyGenerateDialog.h"
-#include "ui/settings/GlobalSettingStation.h"
-#include "ui/widgets/ExportKeyPackageDialog.h"
+#include "ui/import_export/ExportKeyPackageDialog.h"
+#include "ui/key_generate/SubkeyGenerateDialog.h"
+#include "ui/main_window/MainWindow.h"
+#include "core/function/GlobalSettingStation.h"
namespace GpgFrontend::UI {
KeyMgmt::KeyMgmt(QWidget* parent) : QMainWindow(parent) {
/* the list of Keys available*/
key_list_ = new KeyList(KeyMenuAbility::ALL, this);
- key_list_->addListGroupTab(_("All"), KeyListRow::SECRET_OR_PUBLIC_KEY);
+ key_list_->AddListGroupTab(_("All"), KeyListRow::SECRET_OR_PUBLIC_KEY);
- key_list_->addListGroupTab(
+ key_list_->AddListGroupTab(
_("Only Public Key"), KeyListRow::SECRET_OR_PUBLIC_KEY,
KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress |
KeyListColumn::Usage | KeyListColumn::Validity,
@@ -51,7 +57,7 @@ KeyMgmt::KeyMgmt(QWidget* parent) : QMainWindow(parent) {
!(key.IsRevoked() || key.IsDisabled() || key.IsExpired());
});
- key_list_->addListGroupTab(
+ key_list_->AddListGroupTab(
_("Has Private Key"), KeyListRow::SECRET_OR_PUBLIC_KEY,
KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress |
KeyListColumn::Usage | KeyListColumn::Validity,
@@ -60,7 +66,7 @@ KeyMgmt::KeyMgmt(QWidget* parent) : QMainWindow(parent) {
!(key.IsRevoked() || key.IsDisabled() || key.IsExpired());
});
- key_list_->addListGroupTab(
+ key_list_->AddListGroupTab(
_("No Primary Key"), KeyListRow::SECRET_OR_PUBLIC_KEY,
KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress |
KeyListColumn::Usage | KeyListColumn::Validity,
@@ -69,30 +75,32 @@ KeyMgmt::KeyMgmt(QWidget* parent) : QMainWindow(parent) {
!(key.IsRevoked() || key.IsDisabled() || key.IsExpired());
});
- key_list_->addListGroupTab(
+ key_list_->AddListGroupTab(
_("Revoked"), KeyListRow::SECRET_OR_PUBLIC_KEY,
KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress |
KeyListColumn::Usage | KeyListColumn::Validity,
[](const GpgKey& key) -> bool { return key.IsRevoked(); });
- key_list_->addListGroupTab(
+ key_list_->AddListGroupTab(
_("Expired"), KeyListRow::SECRET_OR_PUBLIC_KEY,
KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress |
KeyListColumn::Usage | KeyListColumn::Validity,
[](const GpgKey& key) -> bool { return key.IsExpired(); });
setCentralWidget(key_list_);
- key_list_->setDoubleClickedAction([this](const GpgKey& key, QWidget* parent) {
+ key_list_->SetDoubleClickedAction([this](const GpgKey& key, QWidget* parent) {
new KeyDetailsDialog(key, parent);
});
- key_list_->slotRefresh();
+ key_list_->SlotRefresh();
+
+ create_actions();
+ create_menus();
+ create_tool_bars();
- createActions();
- createMenus();
- createToolBars();
- connect(this, SIGNAL(signalStatusBarChanged(QString)), this->parent(),
- SLOT(slotSetStatusBarText(QString)));
+ connect(this, &KeyMgmt::SignalStatusBarChanged,
+ qobject_cast<MainWindow*>(this->parent()),
+ &MainWindow::SlotSetStatusBarText);
auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
@@ -146,137 +154,143 @@ KeyMgmt::KeyMgmt(QWidget* parent) : QMainWindow(parent) {
this->statusBar()->show();
setWindowTitle(_("KeyPair Management"));
- key_list_->addMenuAction(deleteSelectedKeysAct);
- key_list_->addMenuAction(showKeyDetailsAct);
+ key_list_->AddMenuAction(delete_selected_keys_act_);
+ key_list_->AddMenuAction(show_key_details_act_);
- connect(this, SIGNAL(signalKeyStatusUpdated()), SignalStation::GetInstance(),
- SIGNAL(KeyDatabaseRefresh()));
- connect(SignalStation::GetInstance(), &SignalStation::signalRefreshStatusBar,
+ connect(this, &KeyMgmt::SignalKeyStatusUpdated, SignalStation::GetInstance(),
+ &SignalStation::SignalKeyDatabaseRefresh);
+ connect(SignalStation::GetInstance(), &SignalStation::SignalRefreshStatusBar,
this, [=](const QString& message, int timeout) {
statusBar()->showMessage(message, timeout);
});
}
-void KeyMgmt::createActions() {
- openKeyFileAct = new QAction(_("Open"), this);
- openKeyFileAct->setShortcut(QKeySequence(_("Ctrl+O")));
- openKeyFileAct->setToolTip(_("Open Key File"));
- connect(importKeyFromFileAct, &QAction::triggered, this,
- [&]() { CommonUtils::GetInstance()->slotImportKeyFromFile(this); });
-
- closeAct = new QAction(_("Close"), this);
- closeAct->setShortcut(QKeySequence(_("Ctrl+Q")));
- closeAct->setIcon(QIcon(":exit.png"));
- closeAct->setToolTip(_("Close"));
- connect(closeAct, SIGNAL(triggered()), this, SLOT(close()));
-
- generateKeyPairAct = new QAction(_("New Keypair"), this);
- generateKeyPairAct->setShortcut(QKeySequence(_("Ctrl+N")));
- generateKeyPairAct->setIcon(QIcon(":key_generate.png"));
- generateKeyPairAct->setToolTip(_("Generate KeyPair"));
- connect(generateKeyPairAct, SIGNAL(triggered()), this,
- SLOT(slotGenerateKeyDialog()));
-
- generateSubKeyAct = new QAction(_("New Subkey"), this);
- generateSubKeyAct->setShortcut(QKeySequence(_("Ctrl+Shift+N")));
- generateSubKeyAct->setIcon(QIcon(":key_generate.png"));
- generateSubKeyAct->setToolTip(_("Generate Subkey For Selected KeyPair"));
- connect(generateSubKeyAct, SIGNAL(triggered()), this,
- SLOT(slotGenerateSubKey()));
-
- importKeyFromFileAct = new QAction(_("File"), this);
- importKeyFromFileAct->setIcon(QIcon(":import_key_from_file.png"));
- importKeyFromFileAct->setToolTip(_("Import New Key From File"));
- connect(importKeyFromFileAct, &QAction::triggered, this,
- [&]() { CommonUtils::GetInstance()->slotImportKeyFromFile(this); });
-
- importKeyFromClipboardAct = new QAction(_("Clipboard"), this);
- importKeyFromClipboardAct->setIcon(QIcon(":import_key_from_clipboard.png"));
- importKeyFromClipboardAct->setToolTip(_("Import New Key From Clipboard"));
- connect(importKeyFromClipboardAct, &QAction::triggered, this, [&]() {
- CommonUtils::GetInstance()->slotImportKeyFromClipboard(this);
+void KeyMgmt::create_actions() {
+ open_key_file_act_ = new QAction(_("Open"), this);
+ open_key_file_act_->setShortcut(QKeySequence(_("Ctrl+O")));
+ open_key_file_act_->setToolTip(_("Open Key File"));
+ connect(open_key_file_act_, &QAction::triggered, this,
+ [&]() { CommonUtils::GetInstance()->SlotImportKeyFromFile(this); });
+
+ close_act_ = new QAction(_("Close"), this);
+ close_act_->setShortcut(QKeySequence(_("Ctrl+Q")));
+ close_act_->setIcon(QIcon(":exit.png"));
+ close_act_->setToolTip(_("Close"));
+ connect(close_act_, &QAction::triggered, this, &KeyMgmt::close);
+
+ generate_key_pair_act_ = new QAction(_("New Keypair"), this);
+ generate_key_pair_act_->setShortcut(QKeySequence(_("Ctrl+N")));
+ generate_key_pair_act_->setIcon(QIcon(":key_generate.png"));
+ generate_key_pair_act_->setToolTip(_("Generate KeyPair"));
+ connect(generate_key_pair_act_, &QAction::triggered, this,
+ &KeyMgmt::SlotGenerateKeyDialog);
+
+ generate_subkey_act_ = new QAction(_("New Subkey"), this);
+ generate_subkey_act_->setShortcut(QKeySequence(_("Ctrl+Shift+N")));
+ generate_subkey_act_->setIcon(QIcon(":key_generate.png"));
+ generate_subkey_act_->setToolTip(_("Generate Subkey For Selected KeyPair"));
+ connect(generate_subkey_act_, &QAction::triggered, this,
+ &KeyMgmt::SlotGenerateSubKey);
+
+ import_key_from_file_act_ = new QAction(_("File"), this);
+ import_key_from_file_act_->setIcon(QIcon(":import_key_from_file.png"));
+ import_key_from_file_act_->setToolTip(_("Import New Key From File"));
+ connect(import_key_from_file_act_, &QAction::triggered, this,
+ [&]() { CommonUtils::GetInstance()->SlotImportKeyFromFile(this); });
+
+ import_key_from_clipboard_act_ = new QAction(_("Clipboard"), this);
+ import_key_from_clipboard_act_->setIcon(
+ QIcon(":import_key_from_clipboard.png"));
+ import_key_from_clipboard_act_->setToolTip(
+ _("Import New Key From Clipboard"));
+ connect(import_key_from_clipboard_act_, &QAction::triggered, this, [&]() {
+ CommonUtils::GetInstance()->SlotImportKeyFromClipboard(this);
});
- importKeyFromKeyServerAct = new QAction(_("Keyserver"), this);
- importKeyFromKeyServerAct->setIcon(QIcon(":import_key_from_server.png"));
- importKeyFromKeyServerAct->setToolTip(_("Import New Key From Keyserver"));
- connect(importKeyFromKeyServerAct, &QAction::triggered, this, [&]() {
- CommonUtils::GetInstance()->slotImportKeyFromKeyServer(this);
+ import_key_from_key_server_act_ = new QAction(_("Keyserver"), this);
+ import_key_from_key_server_act_->setIcon(
+ QIcon(":import_key_from_server.png"));
+ import_key_from_key_server_act_->setToolTip(
+ _("Import New Key From Keyserver"));
+ connect(import_key_from_key_server_act_, &QAction::triggered, this, [&]() {
+ CommonUtils::GetInstance()->SlotImportKeyFromKeyServer(this);
});
- importKeysFromKeyPackageAct = new QAction(_("Key Package"), this);
- importKeysFromKeyPackageAct->setIcon(QIcon(":key_package.png"));
- importKeysFromKeyPackageAct->setToolTip(
+ import_keys_from_key_package_act_ = new QAction(_("Key Package"), this);
+ import_keys_from_key_package_act_->setIcon(QIcon(":key_package.png"));
+ import_keys_from_key_package_act_->setToolTip(
_("Import Key(s) From a Key Package"));
- connect(importKeysFromKeyPackageAct, &QAction::triggered, this,
- &KeyMgmt::slotImportKeyPackage);
-
- exportKeyToClipboardAct = new QAction(_("Export To Clipboard"), this);
- exportKeyToClipboardAct->setIcon(QIcon(":export_key_to_clipboard.png"));
- exportKeyToClipboardAct->setToolTip(_("Export Selected Key(s) To Clipboard"));
- connect(exportKeyToClipboardAct, SIGNAL(triggered()), this,
- SLOT(slotExportKeyToClipboard()));
-
- exportKeyToFileAct = new QAction(_("Export To Key Package"), this);
- exportKeyToFileAct->setIcon(QIcon(":key_package.png"));
- exportKeyToFileAct->setToolTip(_("Export Checked Key(s) To a Key Package"));
- connect(exportKeyToFileAct, SIGNAL(triggered()), this,
- SLOT(slotExportKeyToKeyPackage()));
-
- exportKeyAsOpenSSHFormat = new QAction(_("Export As OpenSSH"), this);
- exportKeyAsOpenSSHFormat->setIcon(QIcon(":ssh-key.png"));
- exportKeyAsOpenSSHFormat->setToolTip(
+ connect(import_keys_from_key_package_act_, &QAction::triggered, this,
+ &KeyMgmt::SlotImportKeyPackage);
+
+ export_key_to_clipboard_act_ = new QAction(_("Export To Clipboard"), this);
+ export_key_to_clipboard_act_->setIcon(QIcon(":export_key_to_clipboard.png"));
+ export_key_to_clipboard_act_->setToolTip(
+ _("Export Selected Key(s) To Clipboard"));
+ connect(export_key_to_clipboard_act_, &QAction::triggered, this,
+ &KeyMgmt::SlotExportKeyToClipboard);
+
+ export_key_to_file_act_ = new QAction(_("Export To Key Package"), this);
+ export_key_to_file_act_->setIcon(QIcon(":key_package.png"));
+ export_key_to_file_act_->setToolTip(
+ _("Export Checked Key(s) To a Key Package"));
+ connect(export_key_to_file_act_, &QAction::triggered, this,
+ &KeyMgmt::SlotExportKeyToKeyPackage);
+
+ export_key_as_open_ssh_format_ = new QAction(_("Export As OpenSSH"), this);
+ export_key_as_open_ssh_format_->setIcon(QIcon(":ssh-key.png"));
+ export_key_as_open_ssh_format_->setToolTip(
_("Export Selected Key(s) As OpenSSH Format to File"));
- connect(exportKeyAsOpenSSHFormat, SIGNAL(triggered()), this,
- SLOT(slotExportAsOpenSSHFormat()));
-
- deleteSelectedKeysAct = new QAction(_("Delete Selected Key(s)"), this);
- deleteSelectedKeysAct->setToolTip(_("Delete the Selected keys"));
- connect(deleteSelectedKeysAct, SIGNAL(triggered()), this,
- SLOT(slotDeleteSelectedKeys()));
-
- deleteCheckedKeysAct = new QAction(_("Delete Checked Key(s)"), this);
- deleteCheckedKeysAct->setToolTip(_("Delete the Checked keys"));
- deleteCheckedKeysAct->setIcon(QIcon(":button_delete.png"));
- connect(deleteCheckedKeysAct, SIGNAL(triggered()), this,
- SLOT(slotDeleteCheckedKeys()));
-
- showKeyDetailsAct = new QAction(_("Show Key Details"), this);
- showKeyDetailsAct->setToolTip(_("Show Details for this Key"));
- connect(showKeyDetailsAct, SIGNAL(triggered()), this,
- SLOT(slotShowKeyDetails()));
+ connect(export_key_as_open_ssh_format_, &QAction::triggered, this,
+ &KeyMgmt::SlotExportAsOpenSSHFormat);
+
+ delete_selected_keys_act_ = new QAction(_("Delete Selected Key(s)"), this);
+ delete_selected_keys_act_->setToolTip(_("Delete the Selected keys"));
+ connect(delete_selected_keys_act_, &QAction::triggered, this,
+ &KeyMgmt::SlotDeleteSelectedKeys);
+
+ delete_checked_keys_act_ = new QAction(_("Delete Checked Key(s)"), this);
+ delete_checked_keys_act_->setToolTip(_("Delete the Checked keys"));
+ delete_checked_keys_act_->setIcon(QIcon(":button_delete.png"));
+ connect(delete_checked_keys_act_, &QAction::triggered, this,
+ &KeyMgmt::SlotDeleteCheckedKeys);
+
+ show_key_details_act_ = new QAction(_("Show Key Details"), this);
+ show_key_details_act_->setToolTip(_("Show Details for this Key"));
+ connect(show_key_details_act_, &QAction::triggered, this,
+ &KeyMgmt::SlotShowKeyDetails);
}
-void KeyMgmt::createMenus() {
- fileMenu = menuBar()->addMenu(_("File"));
- fileMenu->addAction(openKeyFileAct);
- fileMenu->addAction(closeAct);
-
- keyMenu = menuBar()->addMenu(_("Key"));
- generateKeyMenu = keyMenu->addMenu(_("Generate Key"));
- generateKeyMenu->addAction(generateKeyPairAct);
- generateKeyMenu->addAction(generateSubKeyAct);
-
- importKeyMenu = keyMenu->addMenu(_("Import Key"));
- importKeyMenu->addAction(importKeyFromFileAct);
- importKeyMenu->addAction(importKeyFromClipboardAct);
- importKeyMenu->addAction(importKeyFromKeyServerAct);
- importKeyMenu->addAction(importKeysFromKeyPackageAct);
-
- keyMenu->addAction(exportKeyToFileAct);
- keyMenu->addAction(exportKeyToClipboardAct);
- keyMenu->addAction(exportKeyAsOpenSSHFormat);
- keyMenu->addSeparator();
- keyMenu->addAction(deleteCheckedKeysAct);
+void KeyMgmt::create_menus() {
+ file_menu_ = menuBar()->addMenu(_("File"));
+ file_menu_->addAction(open_key_file_act_);
+ file_menu_->addAction(close_act_);
+
+ key_menu_ = menuBar()->addMenu(_("Key"));
+ generate_key_menu_ = key_menu_->addMenu(_("Generate Key"));
+ generate_key_menu_->addAction(generate_key_pair_act_);
+ generate_key_menu_->addAction(generate_subkey_act_);
+
+ import_key_menu_ = key_menu_->addMenu(_("Import Key"));
+ import_key_menu_->addAction(import_key_from_file_act_);
+ import_key_menu_->addAction(import_key_from_clipboard_act_);
+ import_key_menu_->addAction(import_key_from_key_server_act_);
+ import_key_menu_->addAction(import_keys_from_key_package_act_);
+
+ key_menu_->addAction(export_key_to_file_act_);
+ key_menu_->addAction(export_key_to_clipboard_act_);
+ key_menu_->addAction(export_key_as_open_ssh_format_);
+ key_menu_->addSeparator();
+ key_menu_->addAction(delete_checked_keys_act_);
}
-void KeyMgmt::createToolBars() {
+void KeyMgmt::create_tool_bars() {
QToolBar* keyToolBar = addToolBar(_("Key"));
keyToolBar->setObjectName("keytoolbar");
// add button with popup menu for import
auto* generateToolButton = new QToolButton(this);
- generateToolButton->setMenu(generateKeyMenu);
+ generateToolButton->setMenu(generate_key_menu_);
generateToolButton->setPopupMode(QToolButton::InstantPopup);
generateToolButton->setIcon(QIcon(":key_generate.png"));
generateToolButton->setText(_("Generate"));
@@ -286,7 +300,7 @@ void KeyMgmt::createToolBars() {
// add button with popup menu for import
auto* toolButton = new QToolButton(this);
- toolButton->setMenu(importKeyMenu);
+ toolButton->setMenu(import_key_menu_);
toolButton->setPopupMode(QToolButton::InstantPopup);
toolButton->setIcon(QIcon(":key_import.png"));
toolButton->setToolTip(_("Import key"));
@@ -295,30 +309,30 @@ void KeyMgmt::createToolBars() {
keyToolBar->addWidget(toolButton);
keyToolBar->addSeparator();
- keyToolBar->addAction(deleteCheckedKeysAct);
+ keyToolBar->addAction(delete_checked_keys_act_);
keyToolBar->addSeparator();
- keyToolBar->addAction(exportKeyToFileAct);
- keyToolBar->addAction(exportKeyToClipboardAct);
- keyToolBar->addAction(exportKeyAsOpenSSHFormat);
+ keyToolBar->addAction(export_key_to_file_act_);
+ keyToolBar->addAction(export_key_to_clipboard_act_);
+ keyToolBar->addAction(export_key_as_open_ssh_format_);
}
-void KeyMgmt::slotDeleteSelectedKeys() {
- deleteKeysWithWarning(key_list_->getSelected());
+void KeyMgmt::SlotDeleteSelectedKeys() {
+ delete_keys_with_warning(key_list_->GetSelected());
}
-void KeyMgmt::slotDeleteCheckedKeys() {
- deleteKeysWithWarning(key_list_->getChecked());
+void KeyMgmt::SlotDeleteCheckedKeys() {
+ delete_keys_with_warning(key_list_->GetChecked());
}
-void KeyMgmt::deleteKeysWithWarning(KeyIdArgsListPtr key_ids) {
+void KeyMgmt::delete_keys_with_warning(KeyIdArgsListPtr uidList) {
/**
* TODO: Different Messages for private/public key, check if
* more than one selected... compare to seahorse "delete-dialog"
*/
- if (key_ids->empty()) return;
+ if (uidList->empty()) return;
QString keynames;
- for (const auto& key_id : *key_ids) {
+ for (const auto& key_id : *uidList) {
auto key = GpgKeyGetter::GetInstance().GetKey(key_id);
if (!key.IsGood()) continue;
keynames.append(QString::fromStdString(key.GetName()));
@@ -337,13 +351,13 @@ void KeyMgmt::deleteKeysWithWarning(KeyIdArgsListPtr key_ids) {
QMessageBox::No | QMessageBox::Yes);
if (ret == QMessageBox::Yes) {
- GpgKeyOpera::GetInstance().DeleteKeys(std::move(key_ids));
- emit signalKeyStatusUpdated();
+ GpgKeyOpera::GetInstance().DeleteKeys(std::move(uidList));
+ emit SignalKeyStatusUpdated();
}
}
-void KeyMgmt::slotShowKeyDetails() {
- auto keys_selected = key_list_->getSelected();
+void KeyMgmt::SlotShowKeyDetails() {
+ auto keys_selected = key_list_->GetSelected();
if (keys_selected->empty()) return;
auto key = GpgKeyGetter::GetInstance().GetKey(keys_selected->front());
@@ -356,8 +370,8 @@ void KeyMgmt::slotShowKeyDetails() {
new KeyDetailsDialog(key);
}
-void KeyMgmt::slotExportKeyToKeyPackage() {
- auto keys_checked = key_list_->getChecked();
+void KeyMgmt::SlotExportKeyToKeyPackage() {
+ auto keys_checked = key_list_->GetChecked();
if (keys_checked->empty()) {
QMessageBox::critical(
this, _("Forbidden"),
@@ -366,11 +380,11 @@ void KeyMgmt::slotExportKeyToKeyPackage() {
}
auto dialog = new ExportKeyPackageDialog(std::move(keys_checked), this);
dialog->exec();
- emit signalStatusBarChanged(QString(_("key(s) exported")));
+ emit SignalStatusBarChanged(QString(_("key(s) exported")));
}
-void KeyMgmt::slotExportKeyToClipboard() {
- auto keys_checked = key_list_->getChecked();
+void KeyMgmt::SlotExportKeyToClipboard() {
+ auto keys_checked = key_list_->GetChecked();
if (keys_checked->empty()) {
QMessageBox::critical(
this, _("Forbidden"),
@@ -386,18 +400,18 @@ void KeyMgmt::slotExportKeyToClipboard() {
QApplication::clipboard()->setText(QString::fromStdString(*key_export_data));
}
-void KeyMgmt::slotGenerateKeyDialog() {
+void KeyMgmt::SlotGenerateKeyDialog() {
auto* keyGenDialog = new KeyGenDialog(this);
keyGenDialog->show();
}
void KeyMgmt::closeEvent(QCloseEvent* event) {
- slotSaveWindowState();
+ SlotSaveWindowState();
QMainWindow::closeEvent(event);
}
-void KeyMgmt::slotGenerateSubKey() {
- auto keys_selected = key_list_->getSelected();
+void KeyMgmt::SlotGenerateSubKey() {
+ auto keys_selected = key_list_->GetSelected();
if (keys_selected->empty()) {
QMessageBox::information(
this, _("Invalid Operation"),
@@ -419,9 +433,9 @@ void KeyMgmt::slotGenerateSubKey() {
auto dialog = new SubkeyGenerateDialog(key.GetId(), this);
dialog->show();
}
-void KeyMgmt::slotSaveWindowState() {
+void KeyMgmt::SlotSaveWindowState() {
auto& settings =
- GpgFrontend::UI::GlobalSettingStation::GetInstance().GetUISettings();
+ GpgFrontend::GlobalSettingStation::GetInstance().GetUISettings();
if (!settings.exists("window") ||
settings.lookup("window").getType() != libconfig::Setting::TypeGroup)
@@ -466,9 +480,9 @@ void KeyMgmt::slotSaveWindowState() {
GlobalSettingStation::GetInstance().SyncSettings();
}
-void KeyMgmt::slotExportAsOpenSSHFormat() {
+void KeyMgmt::SlotExportAsOpenSSHFormat() {
ByteArrayPtr key_export_data = nullptr;
- auto keys_checked = key_list_->getChecked();
+ auto keys_checked = key_list_->GetChecked();
if (keys_checked->empty()) {
QMessageBox::critical(
@@ -507,63 +521,40 @@ void KeyMgmt::slotExportAsOpenSSHFormat() {
if (!file_name.isEmpty()) {
write_buffer_to_file(file_name.toStdString(), *key_export_data);
- emit signalStatusBarChanged(QString(_("key(s) exported")));
+ emit SignalStatusBarChanged(QString(_("key(s) exported")));
}
}
-void KeyMgmt::slotImportKeyPackage() {
+void KeyMgmt::SlotImportKeyPackage() {
+
+ LOG(INFO) << "Importing key package...";
+
auto key_package_file_name = QFileDialog::getOpenFileName(
this, _("Import Key Package"), {},
QString(_("Key Package")) + " (*.gfepack);;All Files (*)");
- if (key_package_file_name.isEmpty()) return;
-
- auto encrypted_data =
- read_all_data_in_file(key_package_file_name.toStdString());
-
- if (encrypted_data.empty()) {
- QMessageBox::critical(this, _("Error"),
- _("No data was read from the key package."));
- return;
- };
-
auto key_file_name = QFileDialog::getOpenFileName(
this, _("Import Key Package Passphrase File"), {},
QString(_("Key Package Passphrase File")) + " (*.key);;All Files (*)");
- auto passphrase = read_all_data_in_file(key_file_name.toStdString());
-
- LOG(INFO) << "passphrase size" << passphrase.size();
- if (passphrase.size() != 256) {
- QMessageBox::critical(
- this, _("Wrong Passphrase"),
- _("Please double check the passphrase you entered is correct."));
+ if(key_package_file_name.isEmpty() || key_file_name.isEmpty())
return;
- }
- auto hash_key = QCryptographicHash::hash(
- QByteArray::fromStdString(passphrase), QCryptographicHash::Sha256);
- auto encoded = QByteArray::fromStdString(encrypted_data);
-
- QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::ECB,
- QAESEncryption::Padding::ISO);
- auto decoded = encryption.removePadding(encryption.decode(encoded, hash_key));
- auto key_data = QByteArray::fromBase64(decoded);
+ GpgImportInformation info;
- if (!key_data.startsWith(GpgConstants::PGP_PUBLIC_KEY_BEGIN) &&
- !key_data.startsWith(GpgConstants::PGP_PRIVATE_KEY_BEGIN)) {
- QMessageBox::critical(
- this, _("Wrong Passphrase"),
- _("Please double check the passphrase you entered is correct."));
- return;
- }
+ LOG(INFO) << "Importing key package: " << key_package_file_name.toStdString();
- auto key_data_ptr = std::make_unique<ByteArray>(key_data.toStdString());
- auto info =
- GpgKeyImportExporter::GetInstance().ImportKey(std::move(key_data_ptr));
+ if (KeyPackageOperator::ImportKeyPackage(key_package_file_name.toStdString(),
+ key_file_name.toStdString(), info)) {
+ emit SignalStatusBarChanged(QString(_("key(s) imported")));
+ emit SignalKeyStatusUpdated();
- auto dialog = new KeyImportDetailDialog(info, false, this);
- dialog->exec();
+ auto dialog = new KeyImportDetailDialog(info, false, this);
+ dialog->exec();
+ } else {
+ QMessageBox::critical(this, _("Error"),
+ _("An error occur in importing key package."));
+ }
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/KeyMgmt.h b/src/ui/KeyMgmt.h
index 1e0ad5d2..ad58a5aa 100755
--- a/src/ui/KeyMgmt.h
+++ b/src/ui/KeyMgmt.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,100 +8,181 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef __KEYMGMT_H__
#define __KEYMGMT_H__
+#include "import_export/KeyImportDetailDialog.h"
+#include "import_export/KeyServerImportDialog.h"
#include "ui/GpgFrontendUI.h"
-#include "ui/KeyImportDetailDialog.h"
-#include "ui/KeyServerImportDialog.h"
-#include "ui/keygen/KeygenDialog.h"
+#include "ui/key_generate/KeygenDialog.h"
#include "ui/keypair_details/KeyDetailsDialog.h"
#include "ui/widgets/KeyList.h"
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class KeyMgmt : public QMainWindow {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Key Mgmt object
+ *
+ * @param parent
+ */
explicit KeyMgmt(QWidget* parent = nullptr);
public slots:
- void slotGenerateSubKey();
-
- void slotExportKeyToKeyPackage();
-
- void slotExportKeyToClipboard();
-
- void slotExportAsOpenSSHFormat();
-
- void slotDeleteSelectedKeys();
-
- void slotDeleteCheckedKeys();
-
- void slotGenerateKeyDialog();
-
- void slotShowKeyDetails();
-
- void slotSaveWindowState();
-
- void slotImportKeyPackage();
+ /**
+ * @brief
+ *
+ */
+ void SlotGenerateSubKey();
+
+ /**
+ * @brief
+ *
+ */
+ void SlotExportKeyToKeyPackage();
+
+ /**
+ * @brief
+ *
+ */
+ void SlotExportKeyToClipboard();
+
+ /**
+ * @brief
+ *
+ */
+ void SlotExportAsOpenSSHFormat();
+
+ /**
+ * @brief
+ *
+ */
+ void SlotDeleteSelectedKeys();
+
+ /**
+ * @brief
+ *
+ */
+ void SlotDeleteCheckedKeys();
+
+ /**
+ * @brief
+ *
+ */
+ void SlotGenerateKeyDialog();
+
+ /**
+ * @brief
+ *
+ */
+ void SlotShowKeyDetails();
+
+ /**
+ * @brief
+ *
+ */
+ void SlotSaveWindowState();
+
+ /**
+ * @brief
+ *
+ */
+ void SlotImportKeyPackage();
signals:
- void signalStatusBarChanged(QString);
+ /**
+ * @brief
+ *
+ */
+ void SignalStatusBarChanged(QString);
- void signalKeyStatusUpdated();
+ /**
+ * @brief
+ *
+ */
+ void SignalKeyStatusUpdated();
private:
- void createMenus();
-
- void createActions();
-
- void createToolBars();
-
- void deleteKeysWithWarning(GpgFrontend::KeyIdArgsListPtr uidList);
-
- KeyList* key_list_;
- QMenu* fileMenu{};
- QMenu* keyMenu{};
- QMenu* generateKeyMenu{};
- QMenu* importKeyMenu{};
- QAction* openKeyFileAct{};
- QAction* exportKeyToFileAct{};
- QAction* exportKeyAsOpenSSHFormat{};
- QAction* exportKeyToClipboardAct{};
- QAction* deleteCheckedKeysAct{};
- QAction* deleteSelectedKeysAct{};
- QAction* generateKeyDialogAct{};
- QAction* generateKeyPairAct{};
- QAction* generateSubKeyAct{};
- QAction* importKeyFromClipboardAct{};
- QAction* importKeyFromFileAct{};
- QAction* importKeyFromKeyServerAct{};
- QAction* importKeysFromKeyPackageAct{};
- QAction* closeAct{};
- QAction* showKeyDetailsAct{};
- KeyServerImportDialog* importDialog{};
+ /**
+ * @brief Create a menus object
+ *
+ */
+ void create_menus();
+
+ /**
+ * @brief Create a actions object
+ *
+ */
+ void create_actions();
+
+ /**
+ * @brief Create a tool bars object
+ *
+ */
+ void create_tool_bars();
+
+ /**
+ * @brief
+ *
+ * @param uidList
+ */
+ void delete_keys_with_warning(GpgFrontend::KeyIdArgsListPtr uidList);
+
+ KeyList* key_list_; ///<
+ QMenu* file_menu_{}; ///<
+ QMenu* key_menu_{}; ///<
+ QMenu* generate_key_menu_{}; ///<
+ QMenu* import_key_menu_{}; ///<
+ QAction* open_key_file_act_{}; ///<
+ QAction* export_key_to_file_act_{}; ///<
+ QAction* export_key_as_open_ssh_format_{}; ///<
+ QAction* export_key_to_clipboard_act_{}; ///<
+ QAction* delete_checked_keys_act_{}; ///<
+ QAction* delete_selected_keys_act_{}; ///<
+ QAction* generate_key_dialog_act_{}; ///<
+ QAction* generate_key_pair_act_{}; ///<
+ QAction* generate_subkey_act_{}; ///<
+ QAction* import_key_from_clipboard_act_{}; ///<
+ QAction* import_key_from_file_act_{}; ///<
+ QAction* import_key_from_key_server_act_{}; ///<
+ QAction* import_keys_from_key_package_act_{}; ///<
+ QAction* close_act_{}; ///<
+ QAction* show_key_details_act_{}; ///<
+ KeyServerImportDialog* import_dialog_{}; ///<
protected:
+ /**
+ * @brief
+ *
+ * @param event
+ */
void closeEvent(QCloseEvent* event) override;
};
diff --git a/src/ui/KeyServerImportDialog.h b/src/ui/KeyServerImportDialog.h
deleted file mode 100644
index e3761f5c..00000000
--- a/src/ui/KeyServerImportDialog.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#ifndef __KEY_SERVER_IMPORT_DIALOG_H__
-#define __KEY_SERVER_IMPORT_DIALOG_H__
-
-#include "KeyImportDetailDialog.h"
-#include "gpg/GpgContext.h"
-#include "ui/GpgFrontendUI.h"
-#include "ui/widgets/KeyList.h"
-
-namespace GpgFrontend::UI {
-
-class KeyServerImportDialog : public QDialog {
- Q_OBJECT
-
- public:
- KeyServerImportDialog(bool automatic, QWidget* parent);
-
- explicit KeyServerImportDialog(QWidget* parent);
-
- void slotImport(const KeyIdArgsListPtr& keys);
-
- void slotImport(const QStringList& keyIds, const QUrl& keyserverUrl);
-
- signals:
- void signalKeyImported();
-
- private slots:
-
- void slotImport();
-
- void slotSearchFinished();
-
- void slotImportFinished(const QString& keyid);
-
- void slotSearch();
-
- void slotSaveWindowState();
-
- private:
- void createKeysTable();
-
- void setMessage(const QString& text, bool error);
-
- void importKeys(ByteArrayPtr in_data);
-
- void setLoading(bool status);
-
- QPushButton* createButton(const QString& text, const char* member);
-
- QComboBox* createComboBox();
-
- bool mAutomatic = false;
-
- QLineEdit* searchLineEdit{};
- QComboBox* keyServerComboBox{};
- QProgressBar* waitingBar;
- QLabel* searchLabel{};
- QLabel* keyServerLabel{};
- QLabel* message{};
- QLabel* icon{};
- QPushButton* closeButton{};
- QPushButton* importButton{};
- QPushButton* searchButton{};
- QTableWidget* keysTable{};
- QNetworkAccessManager* qnam{};
-};
-
-} // namespace GpgFrontend::UI
-
-#endif // __KEY_SERVER_IMPORT_DIALOG_H__
diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h
deleted file mode 100644
index 9c4d5a1c..00000000
--- a/src/ui/MainWindow.h
+++ /dev/null
@@ -1,407 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#ifndef __GPGWIN_H__
-#define __GPGWIN_H__
-
-#include "gpg/GpgConstants.h"
-#include "gpg/result_analyse/DecryptResultAnalyse.h"
-#include "gpg/result_analyse/EncryptResultAnalyse.h"
-#include "gpg/result_analyse/SignResultAnalyse.h"
-#include "ui/FindWidget.h"
-#include "ui/GpgFrontendUI.h"
-#include "ui/KeyMgmt.h"
-#include "ui/KeyUploadDialog.h"
-#include "ui/WaitingDialog.h"
-#include "ui/Wizard.h"
-#include "ui/help/AboutDialog.h"
-#include "ui/settings/SettingsDialog.h"
-#include "ui/widgets/InfoBoardWidget.h"
-#include "ui/widgets/TextEdit.h"
-
-namespace GpgFrontend::UI {
-/**
- * @brief
- *
- */
-class MainWindow : public QMainWindow {
- Q_OBJECT
-
- public:
- /**
- * @brief
- *
- */
- MainWindow();
-
- /**
- * ONLY Called from main()
- */
- void init() noexcept;
-
- signals:
- void loaded();
-
- public slots:
-
- void slotSetStatusBarText(const QString& text);
-
- protected:
- /**
- * @details Close event shows a save dialog, if there are unsaved documents on
- * exit.
- * @param event
- */
- void closeEvent(QCloseEvent* event) override;
-
- public slots:
-
- /**
- * @details Open a new tab for path
- */
- void slotOpenFile(QString& path);
-
- /**
- * @details Open dialog for encrypting file.
- */
- void slotFileEncrypt();
-
- /**
- * @details Open dialog for decrypting file.
- */
- void slotFileDecrypt();
-
- /**
- * @details Open dialog for signing file.
- */
- void slotFileSign();
-
- /**
- * @details Open dialog for verifying file.
- */
- void slotFileVerify();
-
- /**
- * @details Open dialog for signing file.
- */
- void slotFileEncryptSign();
-
- /**
- * @details Open dialog for verifying file.
- */
- void slotFileDecryptVerify();
-
- private slots:
-
- /**
- * @details encrypt the text of currently active textedit-page
- * with the currently checked keys
- */
- void slotEncrypt();
-
- /**
- * @details encrypt and sign the text of currently active textedit-page
- * with the currently checked keys
- */
- void slotEncryptSign();
-
- /**
- * @details Show a passphrase dialog and decrypt the text of currently active
- * tab.
- */
- void slotDecrypt();
-
- /**
- * @details Sign the text of currently active tab with the checked private
- * keys
- */
- void slotSign();
-
- /**
- * @details Verify the text of currently active tab and show verify
- * information. If document is signed with a key, which is not in keylist,
- * show import missing key from keyserver in Menu of verifynotification.
- */
- void slotVerify();
-
- /**
- * @details decrypt and verify the text of currently active textedit-page
- * with the currently checked keys
- */
- void slotDecryptVerify();
-
- /**
- * @details Show the details of the first of the first of selected keys
- */
- void slotShowKeyDetails();
-
- /**
- * @details Refresh key information of selected keys from default keyserver
- */
- void refreshKeysFromKeyserver();
-
- /**
- * @details upload the selected key to the keyserver
- */
- void uploadKeyToServer();
-
- /**
- * @details Open find widget.
- */
- void slotFind();
-
- /**
- * @details start the wizard
- */
- void slotStartWizard();
-
- /**
- * @details Import keys from currently active tab to keylist if possible.
- */
- void slotImportKeyFromEdit();
-
- /**
- * @details Append the selected keys to currently active textedit.
- */
- void slotAppendSelectedKeys();
-
- /**
- * @details Copy the mailaddress of selected key to clipboard.
- * Method for keylists contextmenu.
- */
- void slotCopyMailAddressToClipboard();
-
- /**
- * @details Open key management dialog.
- */
- void slotOpenKeyManagement();
-
- /**
- * @details Open File Opera Tab
- */
- void slotOpenFileTab();
-
- /**
- * @details Open settings-dialog.
- */
- void slotOpenSettingsDialog();
-
- // /**
- // * @details Show a warn message in status bar, if there are files in
- // * attachment folder.
- // */
- // void slotCheckAttachmentFolder();
-
- /**
- * @details Replace double linebreaks by single linebreaks in currently active
- * tab.
- */
- void slotCleanDoubleLinebreaks();
-
- /**
- * @details Cut the existing PGP header and footer from current tab.
- */
- void slotCutPgpHeader();
-
- /**
- * @details Add PGP header and footer to current tab.
- */
- void slotAddPgpHeader();
-
- /**
- * @details Disable tab related actions, if number of tabs is 0.
- * @param number number of the opened tabs and -1, if no tab is opened
- */
- void slotDisableTabActions(int number);
-
- /**
- * @details get value of member restartNeeded to needed.
- * @param needed true, if application has to be restarted
- */
- void slotSetRestartNeeded(bool needed);
-
- /**
- * @details called when need to upgrade.
- */
- void slotVersionUpgrade(const SoftwareVersion& version);
-
- private:
- /**
- * @details Create actions for the main-menu and the context-menu of the
- * keylist.
- */
- void createActions();
-
- /**
- * @details create the menu of the main-window.
- */
- void createMenus();
-
- /**
- * @details Create edit-, crypt- and key-toolbars.
- */
- void createToolBars();
-
- /**
- * @details Create statusbar of mainwindow.
- */
- void createStatusBar();
-
- /**
- * @details Create keylist- and attachment-dockwindows.
- */
- void createDockWindows();
-
- /**
- * @details Create attachment-dockwindow.
- */
- void createAttachmentDock();
-
- /**
- * @details close attachment-dockwindow.
- */
- void closeAttachmentDock();
-
- /**
- * @details Load settings from ini-file.
- */
- void restoreSettings();
-
- /**
- * @details Save settings to ini-file.
- */
- void saveSettings();
-
-#ifdef ADVANCE_SUPPORT
-
- /**
- * @details Get full crypto text
- */
- QString getCryptText(const QString& shortenCryptoText);
-
- /**
- * @details Shorten crypto text
- */
- void shortenCryptText();
-
-#endif
-
- /**
- * @brief return true, if restart is needed
- */
- [[nodiscard]] bool getRestartNeeded() const;
-
- TextEdit* edit{}; /** Tabwidget holding the edit-windows */
- QMenu* fileMenu{}; /** Submenu for file-operations*/
- QMenu* editMenu{}; /** Submenu for text-operations*/
- QMenu* cryptMenu{}; /** Submenu for crypt-operations */
- QMenu* helpMenu{}; /** Submenu for help-operations */
- QMenu* keyMenu{}; /** Submenu for key-operations */
- QMenu* viewMenu{}; /** Submenu for view operations */
- QMenu* importKeyMenu{}; /** Sumenu for import operations */
-#ifdef SMTP_SUPPORT
- QMenu* emailMenu{}; /** Sumenu for email operations */
-#endif
-
- QMenu* steganoMenu{}; /** Submenu for steganographic operations*/
- QToolBar* cryptToolBar{}; /** Toolbar holding crypt actions */
- QToolBar* fileToolBar{}; /** Toolbar holding file actions */
- QToolBar* editToolBar{}; /** Toolbar holding edit actions */
- QToolBar* specialEditToolBar{}; /** Toolbar holding special edit actions */
- QToolBar* keyToolBar{}; /** Toolbar holding key operations */
- QToolBar* emailToolBar{}; /** Toolbar holding key operations */
- QToolButton*
- importButton{}; /** Toolbutton for import dropdown menu in toolbar */
- QDockWidget* keyListDock{}; /** Encrypt Dock*/
- QDockWidget* attachmentDock{}; /** Attachment Dock */
- QDockWidget* infoBoardDock{};
-
- QAction* newTabAct{}; /** Action to create new tab */
- QAction* switchTabUpAct{}; /** Action to switch tab up*/
- QAction* switchTabDownAct{}; /** Action to switch tab down */
- QAction* openAct{}; /** Action to open file */
- QAction* browserAct{}; /** Action to open file browser*/
- QAction* saveAct{}; /** Action to save file */
- QAction* saveAsAct{}; /** Action to save file as */
- QAction* printAct{}; /** Action to print */
- QAction* closeTabAct{}; /** Action to print */
- QAction* quitAct{}; /** Action to quit application */
- QAction* encryptAct{}; /** Action to encrypt text */
- QAction* encryptSignAct{}; /** Action to encrypt and sign text */
- QAction* decryptVerifyAct{}; /** Action to encrypt and sign text */
- QAction* decryptAct{}; /** Action to decrypt text */
- QAction* signAct{}; /** Action to sign text */
- QAction* verifyAct{}; /** Action to verify text */
- QAction* importKeyFromEditAct{}; /** Action to import key from edit */
- QAction*
- cleanDoubleLinebreaksAct{}; /** Action to remove double line breaks */
-
- QAction*
- appendSelectedKeysAct{}; /** Action to append selected keys to edit */
- QAction*
- copyMailAddressToClipboardAct{}; /** Action to copy mail to clipboard */
- QAction* openKeyManagementAct{}; /** Action to open key management */
- QAction* copyAct{}; /** Action to copy text */
- QAction* quoteAct{}; /** Action to quote text */
- QAction* cutAct{}; /** Action to cut text */
- QAction* pasteAct{}; /** Action to paste text */
- QAction* selectAllAct{}; /** Action to select whole text */
- QAction* findAct{}; /** Action to find text */
- QAction* undoAct{}; /** Action to undo last action */
- QAction* redoAct{}; /** Action to redo last action */
- QAction* zoomInAct{}; /** Action to zoom in */
- QAction* zoomOutAct{}; /** Action to zoom out */
- QAction* aboutAct{}; /** Action to open about dialog */
- QAction* checkUpdateAct{}; /** Action to open about dialog */
- QAction* translateAct{}; /** Action to open about dialog */
- QAction* openSettingsAct{}; /** Action to open settings dialog */
- QAction* showKeyDetailsAct{}; /** Action to open key-details dialog */
- QAction* startWizardAct{}; /** Action to open the wizard */
- QAction* cutPgpHeaderAct{}; /** Action for cutting the PGP header */
- QAction* addPgpHeaderAct{}; /** Action for adding the PGP header */
-
-#ifdef SMTP_SUPPORT
- QAction* sendMailAct{}; /** Action for sending a email */
- QAction* receiveMailAct{}; /** Action for receive emails */
-#endif
-
- QAction* importKeyFromFileAct{};
- QAction* importKeyFromClipboardAct{};
- QAction* importKeyFromKeyServerAct{};
-
- QLabel* statusBarIcon{};
-
- KeyList* mKeyList{};
- InfoBoardWidget* infoBoard{};
-
- QNetworkAccessManager* networkAccessManager{};
-
- bool attachmentDockCreated{};
- bool restartNeeded{};
- bool prohibit_update_checking_ = false;
-};
-
-} // namespace GpgFrontend::UI
-
-#endif // __GPGWIN_H__
diff --git a/src/ui/QuitDialog.h b/src/ui/QuitDialog.h
deleted file mode 100755
index 2b1dd37f..00000000
--- a/src/ui/QuitDialog.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#ifndef __QUITDIALOG_H__
-#define __QUITDIALOG_H__
-
-#include "ui/GpgFrontendUI.h"
-
-namespace GpgFrontend::UI {
-
-class QuitDialog : public QDialog {
- Q_OBJECT
-
- public:
- QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs);
-
- [[nodiscard]] bool isDiscarded() const;
-
- QList<int> getTabIdsToSave();
-
- private slots:
-
- void slotMyDiscard();
-
- private:
- bool discarded;
- QTableWidget* mFileList;
-};
-
-} // namespace GpgFrontend::UI
-
-#endif // __QUITDIALOG_H__
diff --git a/src/ui/ShowCopyDialog.cpp b/src/ui/ShowCopyDialog.cpp
deleted file mode 100644
index 0503e079..00000000
--- a/src/ui/ShowCopyDialog.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#include "ui/ShowCopyDialog.h"
-
-namespace GpgFrontend::UI {
-
-ShowCopyDialog::ShowCopyDialog(const QString& text, const QString& info,
- QWidget* parent)
- : QDialog(parent) {
- textEdit = new QTextEdit();
- textEdit->setReadOnly(true);
- textEdit->setLineWrapMode(QTextEdit::WidgetWidth);
- textEdit->setText(text);
- copyButton = new QPushButton("Copy");
- connect(copyButton, SIGNAL(clicked(bool)), this, SLOT(slotCopyText()));
-
- infoLabel = new QLabel();
- infoLabel->setText(info);
- infoLabel->setWordWrap(true);
-
- auto* layout = new QVBoxLayout();
- layout->addWidget(textEdit);
- layout->addWidget(copyButton);
- layout->addWidget(infoLabel);
-
- this->setWindowTitle("Short Ciphertext");
- this->resize(320, 120);
- this->setModal(true);
- this->setLayout(layout);
-}
-
-void ShowCopyDialog::slotCopyText() {
- QClipboard* cb = QApplication::clipboard();
- cb->setText(textEdit->toPlainText());
-}
-
-} // namespace GpgFrontend::UI
diff --git a/src/ui/ShowCopyDialog.h b/src/ui/ShowCopyDialog.h
deleted file mode 100644
index fefef7ab..00000000
--- a/src/ui/ShowCopyDialog.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#ifndef GPGFRONTEND_ZH_CN_TS_SHOWCOPYDIALOG_H
-#define GPGFRONTEND_ZH_CN_TS_SHOWCOPYDIALOG_H
-
-#include "ui/GpgFrontendUI.h"
-
-namespace GpgFrontend::UI {
-
-class ShowCopyDialog : public QDialog {
- Q_OBJECT
- public:
- explicit ShowCopyDialog(const QString& text, const QString& info = "",
- QWidget* parent = nullptr);
-
- private slots:
-
- void slotCopyText();
-
- private:
- QLabel* infoLabel;
- QTextEdit* textEdit;
- QPushButton* copyButton;
-};
-
-} // namespace GpgFrontend::UI
-
-#endif // GPGFRONTEND_ZH_CN_TS_SHOWCOPYDIALOG_H
diff --git a/src/ui/SignalStation.cpp b/src/ui/SignalStation.cpp
index 0c550f88..045b63f5 100644
--- a/src/ui/SignalStation.cpp
+++ b/src/ui/SignalStation.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/src/ui/SignalStation.h b/src/ui/SignalStation.h
index 394a7323..dbf978be 100644
--- a/src/ui/SignalStation.h
+++ b/src/ui/SignalStation.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -30,20 +34,45 @@
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class SignalStation : public QObject {
Q_OBJECT
static std::unique_ptr<SignalStation> _instance;
public:
+ /**
+ * @brief Get the Instance object
+ *
+ * @return SignalStation*
+ */
static SignalStation* GetInstance();
signals:
- void KeyDatabaseRefresh();
+ /**
+ * @brief
+ *
+ */
+ void SignalKeyDatabaseRefresh();
- void signalRefreshInfoBoard(const QString& text,
+ /**
+ * @brief
+ *
+ * @param text
+ * @param verify_label_status
+ */
+ void SignalRefreshInfoBoard(const QString& text,
InfoBoardStatus verify_label_status);
- void signalRefreshStatusBar(const QString& message, int timeout);
+ /**
+ * @brief
+ *
+ * @param message
+ * @param timeout
+ */
+ void SignalRefreshStatusBar(const QString& message, int timeout);
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp
index 1a343220..8353d28b 100644
--- a/src/ui/UserInterfaceUtils.cpp
+++ b/src/ui/UserInterfaceUtils.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -26,23 +30,24 @@
#include <utility>
-#include "gpg/result_analyse/ResultAnalyse.h"
+#include "core/function/FileOperator.h"
+#include "core/function/result_analyse/GpgResultAnalyse.h"
#include "ui/SignalStation.h"
-#include "ui/WaitingDialog.h"
-#include "ui/settings/GlobalSettingStation.h"
-#include "ui/smtp/SendMailDialog.h"
+#include "ui/dialog/WaitingDialog.h"
+#include "ui/mail/SendMailDialog.h"
+#include "core/function/GlobalSettingStation.h"
#include "ui/widgets/InfoBoardWidget.h"
#include "ui/widgets/TextEdit.h"
namespace GpgFrontend::UI {
std::unique_ptr<GpgFrontend::UI::CommonUtils>
- GpgFrontend::UI::CommonUtils::_instance = nullptr;
+ GpgFrontend::UI::CommonUtils::instance_ = nullptr;
#ifdef SMTP_SUPPORT
-void send_an_email(QWidget* parent, InfoBoardWidget* info_board,
- const QString& text, bool attach_signature) {
- info_board->addOptionalAction(_("Send Encrypted Mail"), [=]() {
+void send_an_email(QWidget *parent, InfoBoardWidget *info_board,
+ const QString &text, bool attach_signature) {
+ info_board->AddOptionalAction(_("Send Encrypted Mail"), [=]() {
bool smtp_enabled = false;
try {
smtp_enabled = GlobalSettingStation::GetInstance().GetUISettings().lookup(
@@ -52,8 +57,8 @@ void send_an_email(QWidget* parent, InfoBoardWidget* info_board,
}
if (smtp_enabled) {
auto dialog = new SendMailDialog(text, parent);
- dialog->setContentEncryption(false);
- dialog->setAttachSignature(attach_signature);
+ dialog->SetContentEncryption(false);
+ dialog->SetAttachSignature(attach_signature);
dialog->show();
} else {
QMessageBox::warning(nullptr, _("Function Disabled"),
@@ -64,17 +69,17 @@ void send_an_email(QWidget* parent, InfoBoardWidget* info_board,
}
#endif
-void show_verify_details(QWidget* parent, InfoBoardWidget* info_board,
- GpgError error, const GpgVerifyResult& verify_result) {
+void show_verify_details(QWidget *parent, InfoBoardWidget *info_board,
+ GpgError error, const GpgVerifyResult &verify_result) {
// take out result
- info_board->resetOptionActionsMenu();
- info_board->addOptionalAction("Show Verify Details", [=]() {
+ info_board->ResetOptionActionsMenu();
+ info_board->AddOptionalAction("Show Verify Details", [=]() {
VerifyDetailsDialog(parent, error, verify_result);
});
}
-void import_unknown_key_from_keyserver(QWidget* parent,
- const VerifyResultAnalyse& verify_res) {
+void import_unknown_key_from_keyserver(
+ QWidget *parent, const GpgVerifyResultAnalyse &verify_res) {
QMessageBox::StandardButton reply;
reply = QMessageBox::question(
parent, _("Public key not found locally"),
@@ -85,42 +90,42 @@ void import_unknown_key_from_keyserver(QWidget* parent,
if (reply == QMessageBox::Yes) {
auto dialog = KeyServerImportDialog(true, parent);
auto key_ids = std::make_unique<KeyIdArgsList>();
- auto* signature = verify_res.GetSignatures();
+ auto *signature = verify_res.GetSignatures();
while (signature != nullptr) {
LOG(INFO) << "signature fpr" << signature->fpr;
key_ids->push_back(signature->fpr);
signature = signature->next;
}
dialog.show();
- dialog.slotImport(key_ids);
+ dialog.SlotImport(key_ids);
}
}
-void refresh_info_board(InfoBoardWidget* info_board, int status,
- const std::string& report_text) {
+void refresh_info_board(InfoBoardWidget *info_board, int status,
+ const std::string &report_text) {
if (status < 0)
- info_board->slotRefresh(QString::fromStdString(report_text),
+ info_board->SlotRefresh(QString::fromStdString(report_text),
INFO_ERROR_CRITICAL);
else if (status > 0)
- info_board->slotRefresh(QString::fromStdString(report_text), INFO_ERROR_OK);
+ info_board->SlotRefresh(QString::fromStdString(report_text), INFO_ERROR_OK);
else
- info_board->slotRefresh(QString::fromStdString(report_text),
+ info_board->SlotRefresh(QString::fromStdString(report_text),
INFO_ERROR_WARN);
}
-void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board,
- const ResultAnalyse& result_analyse) {
- info_board->associateTabWidget(edit->tabWidget);
+void process_result_analyse(TextEdit *edit, InfoBoardWidget *info_board,
+ const GpgResultAnalyse &result_analyse) {
+ info_board->AssociateTabWidget(edit->tab_widget_);
refresh_info_board(info_board, result_analyse.GetStatus(),
result_analyse.GetResultReport());
}
-void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board,
- const ResultAnalyse& result_analyse_a,
- const ResultAnalyse& result_analyse_b) {
+void process_result_analyse(TextEdit *edit, InfoBoardWidget *info_board,
+ const GpgResultAnalyse &result_analyse_a,
+ const GpgResultAnalyse &result_analyse_b) {
LOG(INFO) << "process_result_analyse Started";
- info_board->associateTabWidget(edit->tabWidget);
+ info_board->AssociateTabWidget(edit->tab_widget_);
refresh_info_board(
info_board,
@@ -128,14 +133,14 @@ void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board,
result_analyse_a.GetResultReport() + result_analyse_b.GetResultReport());
}
-void process_operation(QWidget* parent, const std::string& waiting_title,
- const std::function<void()>& func) {
+void process_operation(QWidget *parent, const std::string &waiting_title,
+ const std::function<void()> &func) {
auto thread = QThread::create(func);
- QApplication::connect(thread, SIGNAL(finished()), thread,
- SLOT(deleteLater()));
+ QApplication::connect(thread, &QThread::finished, thread,
+ &QThread::deleteLater);
thread->start();
- auto* dialog =
+ auto *dialog =
new WaitingDialog(QString::fromStdString(waiting_title), parent);
while (thread->isRunning()) {
QApplication::processEvents();
@@ -143,17 +148,18 @@ void process_operation(QWidget* parent, const std::string& waiting_title,
dialog->close();
}
-CommonUtils* CommonUtils::GetInstance() {
- if (_instance == nullptr) {
- _instance = std::make_unique<CommonUtils>();
+CommonUtils *CommonUtils::GetInstance() {
+ if (instance_ == nullptr) {
+ instance_ = std::make_unique<CommonUtils>();
}
- return _instance.get();
+ return instance_.get();
}
CommonUtils::CommonUtils() : QWidget(nullptr) {
- connect(this, SIGNAL(signalKeyStatusUpdated()), SignalStation::GetInstance(),
- SIGNAL(KeyDatabaseRefresh()));
- connect(this, &CommonUtils::signalGnupgNotInstall, this, []() {
+ connect(this, &CommonUtils::SignalKeyStatusUpdated,
+ SignalStation::GetInstance(),
+ &SignalStation::SignalKeyDatabaseRefresh);
+ connect(this, &CommonUtils::SignalGnupgNotInstall, this, []() {
QMessageBox::critical(
nullptr, _("ENV Loading Failed"),
_("Gnupg(gpg) is not installed correctly, please follow the "
@@ -164,42 +170,48 @@ CommonUtils::CommonUtils() : QWidget(nullptr) {
});
}
-void CommonUtils::slotImportKeys(QWidget* parent,
- const std::string& in_buffer) {
+void CommonUtils::SlotImportKeys(QWidget *parent,
+ const std::string &in_buffer) {
GpgImportInformation result = GpgKeyImportExporter::GetInstance().ImportKey(
std::make_unique<ByteArray>(in_buffer));
- emit signalKeyStatusUpdated();
+ emit SignalKeyStatusUpdated();
new KeyImportDetailDialog(result, false, parent);
}
-void CommonUtils::slotImportKeyFromFile(QWidget* parent) {
+void CommonUtils::SlotImportKeyFromFile(QWidget *parent) {
QString file_name = QFileDialog::getOpenFileName(
this, _("Open Key"), QString(),
QString(_("Key Files")) + " (*.asc *.txt);;" + _("Keyring files") +
" (*.gpg);;All Files (*)");
if (!file_name.isNull()) {
- slotImportKeys(parent, read_all_data_in_file(file_name.toStdString()));
+ QByteArray key_buffer;
+ if (!FileOperator::ReadFile(file_name, key_buffer)) {
+ QMessageBox::critical(nullptr, _("File Open Failed"),
+ _("Failed to open file: ") + file_name);
+ return;
+ }
+ SlotImportKeys(parent, key_buffer.toStdString());
}
}
-void CommonUtils::slotImportKeyFromKeyServer(QWidget* parent) {
+void CommonUtils::SlotImportKeyFromKeyServer(QWidget *parent) {
auto dialog = new KeyServerImportDialog(false, parent);
dialog->show();
}
-void CommonUtils::slotImportKeyFromClipboard(QWidget* parent) {
- QClipboard* cb = QApplication::clipboard();
- slotImportKeys(parent,
+void CommonUtils::SlotImportKeyFromClipboard(QWidget *parent) {
+ QClipboard *cb = QApplication::clipboard();
+ SlotImportKeys(parent,
cb->text(QClipboard::Clipboard).toUtf8().toStdString());
}
-void CommonUtils::slotExecuteGpgCommand(
- const QStringList& arguments,
- const std::function<void(QProcess*)>& interact_func) {
+void CommonUtils::SlotExecuteGpgCommand(
+ const QStringList &arguments,
+ const std::function<void(QProcess *)> &interact_func) {
QEventLoop looper;
auto dialog = new WaitingDialog(_("Processing"), nullptr);
dialog->show();
- auto* gpg_process = new QProcess(&looper);
+ auto *gpg_process = new QProcess(&looper);
gpg_process->setProcessChannelMode(QProcess::MergedChannels);
connect(gpg_process,
@@ -239,13 +251,13 @@ void CommonUtils::slotExecuteGpgCommand(
dialog->deleteLater();
}
-void CommonUtils::slotImportKeyFromKeyServer(
- int ctx_channel, const KeyIdArgsList& key_ids,
- const ImportCallbackFunctiopn& callback) {
+void CommonUtils::SlotImportKeyFromKeyServer(
+ int ctx_channel, const KeyIdArgsList &key_ids,
+ const ImportCallbackFunctiopn &callback) {
std::string target_keyserver;
if (target_keyserver.empty()) {
try {
- auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ auto &settings = GlobalSettingStation::GetInstance().GetUISettings();
target_keyserver = settings.lookup("keyserver.default_server").c_str();
@@ -268,7 +280,7 @@ void CommonUtils::slotImportKeyFromKeyServer(
auto network_manager = std::make_unique<QNetworkAccessManager>();
// LOOP
decltype(key_ids.size()) current_index = 1, all_index = key_ids.size();
- for (const auto& key_id : key_ids) {
+ for (const auto &key_id : key_ids) {
// New Req Url
QUrl req_url(target_keyserver_url.scheme() + "://" +
target_keyserver_url.host() +
@@ -278,7 +290,7 @@ void CommonUtils::slotImportKeyFromKeyServer(
LOG(INFO) << "request url" << req_url.toString().toStdString();
// Waiting for reply
- QNetworkReply* reply = network_manager->get(QNetworkRequest(req_url));
+ QNetworkReply *reply = network_manager->get(QNetworkRequest(req_url));
QEventLoop loop;
connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
loop.exec();
diff --git a/src/ui/UserInterfaceUtils.h b/src/ui/UserInterfaceUtils.h
index d64b06b0..9d73e9b5 100644
--- a/src/ui/UserInterfaceUtils.h
+++ b/src/ui/UserInterfaceUtils.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,31 +8,33 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef GPGFRONTEND_USER_INTERFACE_UTILS_H
#define GPGFRONTEND_USER_INTERFACE_UTILS_H
-#include "gpg/GpgModel.h"
-#include "gpg/result_analyse/VerifyResultAnalyse.h"
+#include "core/GpgModel.h"
+#include "core/function/result_analyse/GpgVerifyResultAnalyse.h"
#include "ui/GpgFrontendUI.h"
namespace GpgFrontend {
-class ResultAnalyse;
+class GpgResultAnalyse;
}
namespace GpgFrontend::UI {
@@ -39,66 +43,172 @@ class InfoBoardWidget;
class TextEdit;
#ifdef SMTP_SUPPORT
+/**
+ * @brief
+ *
+ * @param parent
+ * @param info_board
+ * @param text
+ * @param attach_signature
+ */
void send_an_email(QWidget* parent, InfoBoardWidget* info_board,
const QString& text, bool attach_signature = true);
#endif
-
+/**
+ * @brief
+ *
+ * @param parent
+ * @param info_board
+ * @param error
+ * @param verify_result
+ */
void show_verify_details(QWidget* parent, InfoBoardWidget* info_board,
GpgError error, const GpgVerifyResult& verify_result);
+/**
+ * @brief
+ *
+ * @param parent
+ * @param verify_res
+ */
void import_unknown_key_from_keyserver(QWidget* parent,
- const VerifyResultAnalyse& verify_res);
+ const GpgVerifyResultAnalyse& verify_res);
+/**
+ * @brief
+ *
+ * @param info_board
+ * @param status
+ * @param report_text
+ */
void refresh_info_board(InfoBoardWidget* info_board, int status,
const std::string& report_text);
+/**
+ * @brief
+ *
+ * @param edit
+ * @param info_board
+ * @param result_analyse
+ */
void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board,
- const ResultAnalyse& result_analyse);
+ const GpgResultAnalyse& result_analyse);
+/**
+ * @brief
+ *
+ * @param edit
+ * @param info_board
+ * @param result_analyse_a
+ * @param result_analyse_b
+ */
void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board,
- const ResultAnalyse& result_analyse_a,
- const ResultAnalyse& result_analyse_b);
+ const GpgResultAnalyse& result_analyse_a,
+ const GpgResultAnalyse& result_analyse_b);
+/**
+ * @brief
+ *
+ * @param parent
+ * @param waiting_title
+ * @param func
+ */
void process_operation(QWidget* parent, const std::string& waiting_title,
const std::function<void()>& func);
+/**
+ * @brief
+ *
+ */
class CommonUtils : public QWidget {
Q_OBJECT
public:
- static CommonUtils* GetInstance();
+ /**
+ * @brief
+ *
+ */
+ using ImportCallbackFunctiopn = std::function<void(
+ const std::string&, const std::string&, size_t, size_t)>;
+ /**
+ * @brief Construct a new Common Utils object
+ *
+ */
CommonUtils();
- using ImportCallbackFunctiopn = std::function<void(
- const std::string&, const std::string&, size_t, size_t)>;
+ /**
+ * @brief Get the Instance object
+ *
+ * @return CommonUtils*
+ */
+ static CommonUtils* GetInstance();
signals:
- void signalKeyStatusUpdated();
-
- void signalGnupgNotInstall();
+ /**
+ * @brief
+ *
+ */
+ void SignalKeyStatusUpdated();
+
+ /**
+ * @brief
+ *
+ */
+ void SignalGnupgNotInstall();
public slots:
-
- void slotImportKeys(QWidget* parent, const std::string& in_buffer);
-
- void slotImportKeyFromFile(QWidget* parent);
-
- void slotImportKeyFromKeyServer(QWidget* parent);
-
- void slotImportKeyFromClipboard(QWidget* parent);
-
- static void slotImportKeyFromKeyServer(
+ /**
+ * @brief
+ *
+ * @param parent
+ * @param in_buffer
+ */
+ void SlotImportKeys(QWidget* parent, const std::string& in_buffer);
+
+ /**
+ * @brief
+ *
+ * @param parent
+ */
+ void SlotImportKeyFromFile(QWidget* parent);
+
+ /**
+ * @brief
+ *
+ * @param parent
+ */
+ void SlotImportKeyFromKeyServer(QWidget* parent);
+
+ /**
+ * @brief
+ *
+ * @param parent
+ */
+ void SlotImportKeyFromClipboard(QWidget* parent);
+
+ /**
+ * @brief
+ *
+ * @param ctx_channel
+ * @param key_ids
+ * @param callback
+ */
+ static void SlotImportKeyFromKeyServer(
int ctx_channel, const GpgFrontend::KeyIdArgsList& key_ids,
const GpgFrontend::UI::CommonUtils::ImportCallbackFunctiopn& callback);
- void slotExecuteGpgCommand(
+ /**
+ * @brief
+ *
+ * @param arguments
+ * @param interact_func
+ */
+ void SlotExecuteGpgCommand(
const QStringList& arguments,
const std::function<void(QProcess*)>& interact_func);
- private slots:
-
private:
- static std::unique_ptr<CommonUtils> _instance;
+ static std::unique_ptr<CommonUtils> instance_; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/data_struct/SettingsObject.cpp b/src/ui/data_struct/SettingsObject.cpp
deleted file mode 100644
index d8d1b76c..00000000
--- a/src/ui/data_struct/SettingsObject.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#include "SettingsObject.h"
-
-nlohmann::json& GpgFrontend::UI::SettingsObject::Check(
- const std::string& key, nlohmann::json default_value) {
- if (!nlohmann::json::contains(key))
- nlohmann::json::operator[](key) = std::move(default_value);
- return nlohmann::json::operator[](key);
-}
-
-GpgFrontend::UI::SettingsObject GpgFrontend::UI::SettingsObject::Check(
- const std::string& key) {
- if (!nlohmann::json::contains(key)) nlohmann::json::operator[](key) = {};
- return SettingsObject{nlohmann::json::operator[](key), false};
-}
-
-GpgFrontend::UI::SettingsObject::SettingsObject(std::string settings_name)
- : settings_name_(std::move(settings_name)) {
- try {
- auto _json_optional =
- GlobalSettingStation::GetInstance().GetDataObject(settings_name_);
-
- if (_json_optional.has_value()) {
- nlohmann::json::operator=(_json_optional.value());
- }
-
- } catch (...) {
- }
-}
-
-GpgFrontend::UI::SettingsObject::SettingsObject(nlohmann::json _sub_json, bool)
- : nlohmann::json(std::move(_sub_json)), settings_name_({}) {}
-
-GpgFrontend::UI::SettingsObject::~SettingsObject() {
- if (!settings_name_.empty())
- GpgFrontend::UI::GlobalSettingStation::GetInstance().SaveDataObj(
- settings_name_, *this);
-}
diff --git a/src/ui/details/SignatureDetailsDialog.cpp b/src/ui/details/SignatureDetailsDialog.cpp
index b9ab6b78..a3ad03b3 100644
--- a/src/ui/details/SignatureDetailsDialog.cpp
+++ b/src/ui/details/SignatureDetailsDialog.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/src/ui/details/SignatureDetailsDialog.h b/src/ui/details/SignatureDetailsDialog.h
index ea69d1f2..847b320b 100644
--- a/src/ui/details/SignatureDetailsDialog.h
+++ b/src/ui/details/SignatureDetailsDialog.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -29,7 +33,6 @@
class SignatureDetailsDialog : public QDialog {
Q_OBJECT
public:
-
};
#endif // GPGFRONTEND_SIGNATUREDETAILSDIALOG_H
diff --git a/src/ui/details/VerifyDetailsDialog.cpp b/src/ui/details/VerifyDetailsDialog.cpp
index baa573f1..14407396 100644
--- a/src/ui/details/VerifyDetailsDialog.cpp
+++ b/src/ui/details/VerifyDetailsDialog.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -48,7 +52,7 @@ void VerifyDetailsDialog::slot_refresh() {
// Button Box for close button
button_box_ = new QDialogButtonBox(QDialogButtonBox::Close);
- connect(button_box_, SIGNAL(rejected()), this, SLOT(close()));
+ connect(button_box_, &QDialogButtonBox::rejected, this, &VerifyDetailsDialog::close);
mVboxLayout->addWidget(new QLabel(QString::fromStdString(
std::string(_("Status")) + ": " + gpgme_strerror(error_))));
diff --git a/src/ui/details/VerifyDetailsDialog.h b/src/ui/details/VerifyDetailsDialog.h
index c252eac6..97e2cc2d 100644
--- a/src/ui/details/VerifyDetailsDialog.h
+++ b/src/ui/details/VerifyDetailsDialog.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/src/ui/QuitDialog.cpp b/src/ui/dialog/QuitDialog.cpp
index a5ed7c3f..da0be488 100755
--- a/src/ui/QuitDialog.cpp
+++ b/src/ui/dialog/QuitDialog.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,23 +8,25 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "ui/QuitDialog.h"
+#include "QuitDialog.h"
#include <boost/format.hpp>
@@ -32,42 +36,42 @@ QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs)
: QDialog(parent) {
setWindowTitle(_("Unsaved Files"));
setModal(true);
- discarded = false;
+ discarded_ = false;
/*
* Table of unsaved documents
*/
QHashIterator<int, QString> i(unsavedDocs);
int row = 0;
- mFileList = new QTableWidget(this);
- mFileList->horizontalHeader()->hide();
- mFileList->setColumnCount(3);
- mFileList->setColumnWidth(0, 20);
- mFileList->setColumnHidden(2, true);
- mFileList->verticalHeader()->hide();
- mFileList->setShowGrid(false);
- mFileList->setEditTriggers(QAbstractItemView::NoEditTriggers);
- mFileList->setFocusPolicy(Qt::NoFocus);
- mFileList->horizontalHeader()->setStretchLastSection(true);
+ m_fileList_ = new QTableWidget(this);
+ m_fileList_->horizontalHeader()->hide();
+ m_fileList_->setColumnCount(3);
+ m_fileList_->setColumnWidth(0, 20);
+ m_fileList_->setColumnHidden(2, true);
+ m_fileList_->verticalHeader()->hide();
+ m_fileList_->setShowGrid(false);
+ m_fileList_->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ m_fileList_->setFocusPolicy(Qt::NoFocus);
+ m_fileList_->horizontalHeader()->setStretchLastSection(true);
// fill the table
i.toFront(); // jump to the end of list to fill the table backwards
while (i.hasNext()) {
i.next();
- mFileList->setRowCount(mFileList->rowCount() + 1);
+ m_fileList_->setRowCount(m_fileList_->rowCount() + 1);
// checkbox in front of filename
auto* tmp0 = new QTableWidgetItem();
tmp0->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
tmp0->setCheckState(Qt::Checked);
- mFileList->setItem(row, 0, tmp0);
+ m_fileList_->setItem(row, 0, tmp0);
// filename
auto* tmp1 = new QTableWidgetItem(i.value());
- mFileList->setItem(row, 1, tmp1);
+ m_fileList_->setItem(row, 1, tmp1);
// tab-index in hidden column
auto* tmp2 = new QTableWidgetItem(QString::number(i.key()));
- mFileList->setItem(row, 2, tmp2);
+ m_fileList_->setItem(row, 2, tmp2);
++row;
}
/*
@@ -104,10 +108,10 @@ QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs)
auto* buttonBox =
new QDialogButtonBox(QDialogButtonBox::Discard | QDialogButtonBox::Save |
QDialogButtonBox::Cancel);
- connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
- connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+ connect(buttonBox, &QDialogButtonBox::accepted, this, &QuitDialog::accept);
+ connect(buttonBox, &QDialogButtonBox::rejected, this, &QuitDialog::reject);
QPushButton* btnNoKey = buttonBox->button(QDialogButtonBox::Discard);
- connect(btnNoKey, SIGNAL(clicked()), SLOT(slotMyDiscard()));
+ connect(btnNoKey, &QPushButton::clicked, this,&QuitDialog::slot_my_discard);
/*
* Set the layout
@@ -115,24 +119,24 @@ QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs)
auto* vbox = new QVBoxLayout();
vbox->addWidget(warnBox);
vbox->addWidget(checkLabel);
- vbox->addWidget(mFileList);
+ vbox->addWidget(m_fileList_);
vbox->addWidget(note_label);
vbox->addWidget(buttonBox);
this->setLayout(vbox);
}
-void QuitDialog::slotMyDiscard() {
- discarded = true;
+void QuitDialog::slot_my_discard() {
+ discarded_ = true;
reject();
}
-bool QuitDialog::isDiscarded() const { return discarded; }
+bool QuitDialog::IsDiscarded() const { return discarded_; }
-QList<int> QuitDialog::getTabIdsToSave() {
+QList<int> QuitDialog::GetTabIdsToSave() {
QList<int> tabIdsToSave;
- for (int i = 0; i < mFileList->rowCount(); i++) {
- if (mFileList->item(i, 0)->checkState() == Qt::Checked) {
- tabIdsToSave << mFileList->item(i, 2)->text().toInt();
+ for (int i = 0; i < m_fileList_->rowCount(); i++) {
+ if (m_fileList_->item(i, 0)->checkState() == Qt::Checked) {
+ tabIdsToSave << m_fileList_->item(i, 2)->text().toInt();
}
}
return tabIdsToSave;
diff --git a/src/ui/dialog/QuitDialog.h b/src/ui/dialog/QuitDialog.h
new file mode 100755
index 00000000..2d09790b
--- /dev/null
+++ b/src/ui/dialog/QuitDialog.h
@@ -0,0 +1,82 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#ifndef __QUITDIALOG_H__
+#define __QUITDIALOG_H__
+
+#include "ui/GpgFrontendUI.h"
+
+namespace GpgFrontend::UI {
+
+/**
+ * @brief
+ *
+ */
+class QuitDialog : public QDialog {
+ Q_OBJECT
+
+ public:
+ /**
+ * @brief Construct a new Quit Dialog object
+ *
+ * @param parent
+ * @param unsavedDocs
+ */
+ QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs);
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsDiscarded() const;
+
+ /**
+ * @brief Get the Tab Ids To Save object
+ *
+ * @return QList<int>
+ */
+ QList<int> GetTabIdsToSave();
+
+ private slots:
+
+ /**
+ * @brief
+ *
+ */
+ void slot_my_discard();
+
+ private:
+ bool discarded_; ///<
+ QTableWidget* m_fileList_; ///<
+};
+
+} // namespace GpgFrontend::UI
+
+#endif // __QUITDIALOG_H__
diff --git a/src/ui/WaitingDialog.cpp b/src/ui/dialog/WaitingDialog.cpp
index a83845ab..a4412e57 100644
--- a/src/ui/WaitingDialog.cpp
+++ b/src/ui/dialog/WaitingDialog.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,23 +8,25 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "ui/WaitingDialog.h"
+#include "WaitingDialog.h"
namespace GpgFrontend::UI {
diff --git a/src/ui/WaitingDialog.h b/src/ui/dialog/WaitingDialog.h
index 798c2a3c..1bb6a22b 100644
--- a/src/ui/WaitingDialog.h
+++ b/src/ui/dialog/WaitingDialog.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -29,16 +33,20 @@
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class WaitingDialog : public QDialog {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Waiting Dialog object
+ *
+ * @param title
+ * @param parent
+ */
WaitingDialog(const QString& title, QWidget* parent);
-
- public slots:
-
- private slots:
-
- private:
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/Wizard.cpp b/src/ui/dialog/Wizard.cpp
index 78cea649..0f051874 100644
--- a/src/ui/Wizard.cpp
+++ b/src/ui/dialog/Wizard.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,25 +8,27 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "ui/Wizard.h"
+#include "Wizard.h"
-#include "ui/settings/GlobalSettingStation.h"
+#include "core/function/GlobalSettingStation.h"
namespace GpgFrontend::UI {
@@ -52,10 +56,10 @@ Wizard::Wizard(QWidget* parent) : QWizard(parent) {
}
setStartId(next_page_id);
- connect(this, SIGNAL(accepted()), this, SLOT(slotWizardAccepted()));
+ connect(this, &Wizard::accepted, this, &Wizard::slot_wizard_accepted);
}
-void Wizard::slotWizardAccepted() {
+void Wizard::slot_wizard_accepted() {
LOG(INFO) << _("Called");
// Don't show is mapped to show -> negation
try {
@@ -74,7 +78,7 @@ void Wizard::slotWizardAccepted() {
LOG(ERROR) << _("Setting Operation Error");
}
if (field("openHelp").toBool()) {
- emit signalOpenHelp("docu.html#content");
+ emit SignalOpenHelp("docu.html#content");
}
}
@@ -169,17 +173,17 @@ ChoosePage::ChoosePage(QWidget* parent) : QWizardPage(parent) {
layout->addWidget(encrDecyTextLabel);
layout->addWidget(signVerifyTextLabel);
setLayout(layout);
- nextPage = Wizard::Page_Conclusion;
+ next_page_ = Wizard::Page_Conclusion;
}
-int ChoosePage::nextId() const { return nextPage; }
+int ChoosePage::nextId() const { return next_page_; }
-void ChoosePage::slotJumpPage(const QString& page) {
+void ChoosePage::slot_jump_page(const QString& page) {
QMetaObject qmo = Wizard::staticMetaObject;
int index = qmo.indexOfEnumerator("WizardPages");
QMetaEnum m = qmo.enumerator(index);
- nextPage = m.keyToValue(page.toUtf8().data());
+ next_page_ = m.keyToValue(page.toUtf8().data());
wizard()->next();
}
@@ -200,10 +204,6 @@ KeyGenPage::KeyGenPage(QWidget* parent) : QWizardPage(parent) {
"docu_keygen.html#content"
">" +
QString(_("Offline tutorial")) + "</a>");
- // linkLabel->setOpenExternalLinks(true);
-
- // connect(linkLabel, SIGNAL(linkActivated(QString)),
- // parentWidget()->parentWidget(), SLOT(openHelp(QString)));
auto* createKeyButtonBox = new QWidget(this);
auto* createKeyButtonBoxLayout = new QHBoxLayout(createKeyButtonBox);
@@ -214,15 +214,15 @@ KeyGenPage::KeyGenPage(QWidget* parent) : QWizardPage(parent) {
layout->addWidget(topLabel);
layout->addWidget(linkLabel);
layout->addWidget(createKeyButtonBox);
- connect(createKeyButton, SIGNAL(clicked(bool)), this,
- SLOT(slotGenerateKeyDialog()));
+ connect(createKeyButton, &QPushButton::clicked, this,
+ &KeyGenPage::slot_generate_key_dialog);
setLayout(layout);
}
int KeyGenPage::nextId() const { return Wizard::Page_Conclusion; }
-void KeyGenPage::slotGenerateKeyDialog() {
+void KeyGenPage::slot_generate_key_dialog() {
LOG(INFO) << "Try Opening KeyGenDialog";
(new KeyGenDialog(this))->show();
wizard()->next();
@@ -247,19 +247,19 @@ ConclusionPage::ConclusionPage(QWidget* parent) : QWizardPage(parent) {
bottomLabel->setOpenExternalLinks(true);
bottomLabel->setWordWrap(true);
- openHelpCheckBox = new QCheckBox(_("Open offline help."));
- openHelpCheckBox->setChecked(true);
+ open_help_check_box_ = new QCheckBox(_("Open offline help."));
+ open_help_check_box_->setChecked(true);
- dontShowWizardCheckBox = new QCheckBox(_("Dont show the wizard again."));
- dontShowWizardCheckBox->setChecked(true);
+ dont_show_wizard_checkbox_ = new QCheckBox(_("Dont show the wizard again."));
+ dont_show_wizard_checkbox_->setChecked(true);
- registerField("showWizard", dontShowWizardCheckBox);
+ registerField("showWizard", dont_show_wizard_checkbox_);
// registerField("openHelp", openHelpCheckBox);
auto* layout = new QVBoxLayout;
layout->addWidget(bottomLabel);
// layout->addWidget(openHelpCheckBox);
- layout->addWidget(dontShowWizardCheckBox);
+ layout->addWidget(dont_show_wizard_checkbox_);
setLayout(layout);
setVisible(true);
}
diff --git a/src/ui/Wizard.h b/src/ui/dialog/Wizard.h
index 7145d310..eb093550 100644
--- a/src/ui/Wizard.h
+++ b/src/ui/dialog/Wizard.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,33 +8,39 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef WIZARD_H
#define WIZARD_H
-#include "gpg/GpgConstants.h"
+#include "core/GpgConstants.h"
#include "ui/GpgFrontendUI.h"
#include "ui/KeyMgmt.h"
-#include "ui/keygen/KeygenDialog.h"
+#include "ui/key_generate/KeygenDialog.h"
#include "ui/settings/SettingsDialog.h"
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class Wizard : public QWizard {
Q_OBJECT
Q_ENUMS(WizardPages)
@@ -40,21 +48,50 @@ class Wizard : public QWizard {
public:
enum WizardPages { Page_Intro, Page_Choose, Page_GenKey, Page_Conclusion };
+ /**
+ * @brief Construct a new Wizard object
+ *
+ * @param parent
+ */
explicit Wizard(QWidget* parent = nullptr);
private slots:
- void slotWizardAccepted();
+ /**
+ * @brief
+ *
+ */
+ void slot_wizard_accepted();
signals:
- void signalOpenHelp(QString page);
+ /**
+ * @brief
+ *
+ * @param page
+ */
+ void SignalOpenHelp(QString page);
};
+/**
+ * @brief
+ *
+ */
class IntroPage : public QWizardPage {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Intro Page object
+ *
+ * @param parent
+ */
explicit IntroPage(QWidget* parent = nullptr);
+ protected:
+ /**
+ * @brief
+ *
+ * @return int
+ */
[[nodiscard]] int nextId() const override;
};
@@ -62,42 +99,89 @@ class ChoosePage : public QWizardPage {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Choose Page object
+ *
+ * @param parent
+ */
explicit ChoosePage(QWidget* parent = nullptr);
private slots:
- void slotJumpPage(const QString& page);
-
- private:
+ /**
+ * @brief
+ *
+ * @param page
+ */
+ void slot_jump_page(const QString& page);
+
+ protected:
+ /**
+ * @brief
+ *
+ * @return int
+ */
[[nodiscard]] int nextId() const override;
- int nextPage;
+ int next_page_; ///<
};
+/**
+ * @brief
+ *
+ */
class KeyGenPage : public QWizardPage {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Key Gen Page object
+ *
+ * @param parent
+ */
explicit KeyGenPage(QWidget* parent = nullptr);
+ /**
+ * @brief
+ *
+ * @return int
+ */
[[nodiscard]] int nextId() const override;
private slots:
- void slotGenerateKeyDialog();
+ /**
+ * @brief
+ *
+ */
+ void slot_generate_key_dialog();
};
+/**
+ * @brief
+ *
+ */
class ConclusionPage : public QWizardPage {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Conclusion Page object
+ *
+ * @param parent
+ */
explicit ConclusionPage(QWidget* parent = nullptr);
+ /**
+ * @brief
+ *
+ * @return int
+ */
[[nodiscard]] int nextId() const override;
private:
- QCheckBox* dontShowWizardCheckBox;
- QCheckBox* openHelpCheckBox;
+ QCheckBox* dont_show_wizard_checkbox_; ///<
+ QCheckBox* open_help_check_box_; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/help/AboutDialog.cpp b/src/ui/help/AboutDialog.cpp
index a7df83cc..4a23c314 100644
--- a/src/ui/help/AboutDialog.cpp
+++ b/src/ui/help/AboutDialog.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,26 +8,28 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include "ui/help/AboutDialog.h"
#include "GpgFrontendBuildInfo.h"
-#include "ui/settings/GlobalSettingStation.h"
+#include "core/function/GlobalSettingStation.h"
#include "ui/thread/VersionCheckThread.h"
namespace GpgFrontend::UI {
@@ -50,7 +54,7 @@ AboutDialog::AboutDialog(int defaultIndex, QWidget* parent) : QDialog(parent) {
}
auto* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
- connect(buttonBox, SIGNAL(accepted()), this, SLOT(close()));
+ connect(buttonBox, &QDialogButtonBox::accepted, this, &AboutDialog::close);
auto* mainLayout = new QVBoxLayout;
mainLayout->addWidget(tabWidget);
@@ -190,9 +194,9 @@ void UpdateTab::getLatestVersion() {
auto version_thread = new VersionCheckThread();
- connect(version_thread, SIGNAL(finished()), version_thread,
- SLOT(deleteLater()));
- connect(version_thread, &VersionCheckThread::upgradeVersion, this,
+ connect(version_thread, &VersionCheckThread::finished, version_thread,
+ &VersionCheckThread::deleteLater);
+ connect(version_thread, &VersionCheckThread::SignalUpgradeVersion, this,
&UpdateTab::slot_show_version_status);
version_thread->start();
diff --git a/src/ui/help/AboutDialog.h b/src/ui/help/AboutDialog.h
index ee24701f..40d93f3e 100644
--- a/src/ui/help/AboutDialog.h
+++ b/src/ui/help/AboutDialog.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,28 +8,30 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef __ABOUTDIALOG_H__
#define __ABOUTDIALOG_H__
-#include "gpg/GpgContext.h"
+#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
-#include "ui/data_struct/SoftwareVersion.h"
+#include "ui/struct/SoftwareVersion.h"
namespace GpgFrontend::UI {
diff --git a/src/ui/import_export/ExportKeyPackageDialog.cpp b/src/ui/import_export/ExportKeyPackageDialog.cpp
new file mode 100644
index 00000000..d6f303f6
--- /dev/null
+++ b/src/ui/import_export/ExportKeyPackageDialog.cpp
@@ -0,0 +1,145 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#include "ExportKeyPackageDialog.h"
+
+#include <boost/format.hpp>
+
+#include "core/function/gpg/GpgKeyGetter.h"
+#include "core/function/KeyPackageOperator.h"
+#include "ui_ExportKeyPackageDialog.h"
+
+GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog(
+ KeyIdArgsListPtr key_ids, QWidget* parent)
+ : QDialog(parent),
+ ui_(std::make_shared<Ui_exportKeyPackageDialog>()),
+ key_ids_(std::move(key_ids)) {
+ ui_->setupUi(this);
+
+ ui_->nameValueLabel->setText(
+ KeyPackageOperator::GenerateKeyPackageName().c_str());
+
+ connect(ui_->gnerateNameButton, &QPushButton::clicked, this, [=]() {
+ ui_->nameValueLabel->setText(
+ KeyPackageOperator::GenerateKeyPackageName().c_str());
+ });
+
+ connect(ui_->setOutputPathButton, &QPushButton::clicked, this, [=]() {
+ auto file_name = QFileDialog::getSaveFileName(
+ this, _("Export Key Package"), ui_->nameValueLabel->text() + ".gfepack",
+ QString(_("Key Package")) + " (*.gfepack);;All Files (*)");
+ ui_->outputPathLabel->setText(file_name);
+ });
+
+ connect(ui_->generatePassphraseButton, &QPushButton::clicked, this, [=]() {
+ auto file_name = QFileDialog::getSaveFileName(
+ this, _("Export Key Package Passphrase"),
+ ui_->nameValueLabel->text() + ".key",
+ QString(_("Key File")) + " (*.key);;All Files (*)");
+
+ if (!KeyPackageOperator::GeneratePassphrase(file_name.toStdString(),
+ passphrase_)) {
+ QMessageBox::critical(
+ this, _("Error"),
+ _("An error occurred while generating the passphrase file."));
+ return;
+ }
+ ui_->passphraseValueLabel->setText(file_name);
+ });
+
+ connect(ui_->button_box_, &QDialogButtonBox::accepted, this, [=]() {
+ if (ui_->outputPathLabel->text().isEmpty()) {
+ QMessageBox::critical(
+ this, _("Forbidden"),
+ _("Please select an output path before exporting."));
+ return;
+ }
+
+ if (ui_->passphraseValueLabel->text().isEmpty()) {
+ QMessageBox::critical(
+ this, _("Forbidden"),
+ _("Please generate a password to protect your key before exporting, "
+ "it is very important. Don't forget to back up your password in a "
+ "safe place."));
+ return;
+ }
+
+ // get suitable key ids
+ auto key_id_exported = std::make_unique<KeyIdArgsList>();
+ auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids_);
+ for (const auto& key : *keys) {
+ if (ui_->noPublicKeyCheckBox->isChecked() && !key.IsPrivateKey())
+ continue;
+ key_id_exported->push_back(key.GetId());
+ }
+
+ if (KeyPackageOperator::GenerateKeyPackage(
+ ui_->outputPathLabel->text().toStdString(),
+ ui_->nameValueLabel->text().toStdString(), key_id_exported,
+ passphrase_, ui_->includeSecretKeyCheckBox->isChecked())) {
+ QMessageBox::information(
+ this, _("Success"),
+ QString(
+ _("The Key Package has been successfully generated and has been "
+ "protected by encryption algorithms(AES-256-ECB). You can "
+ "safely transfer your Key Package.")) +
+ "<br /><br />" + "<b>" +
+ _("But the key file cannot be leaked under any "
+ "circumstances. Please delete the Key Package and key file as "
+ "soon "
+ "as possible after completing the transfer operation.") +
+ "</b>");
+ accept();
+ } else {
+ QMessageBox::critical(
+ this, _("Error"),
+ _("An error occurred while exporting the key package."));
+ }
+ });
+
+ connect(ui_->button_box_, &QDialogButtonBox::rejected, this,
+ [=]() { this->close(); });
+
+ ui_->nameLabel->setText(_("Key Package Name"));
+ ui_->selectOutputPathLabel->setText(_("Output Path"));
+ ui_->passphraseLabel->setText(_("Passphrase"));
+ ui_->tipsLabel->setText(
+ _("Tips: You can use Key Package to safely and conveniently transfer "
+ "your public and private keys between devices."));
+ ui_->generatePassphraseButton->setText(_("Generate and Save Passphrase"));
+ ui_->gnerateNameButton->setText(_("Generate Key Package Name"));
+ ui_->setOutputPathButton->setText(_("Select Output Path"));
+
+ ui_->includeSecretKeyCheckBox->setText(
+ _("Include secret key (Think twice before acting)"));
+ ui_->noPublicKeyCheckBox->setText(
+ _("Exclude keys that do not have a private key"));
+
+ setAttribute(Qt::WA_DeleteOnClose);
+ setWindowTitle(_("exportKeyPackageDialog"));
+}
diff --git a/src/ui/widgets/ExportKeyPackageDialog.h b/src/ui/import_export/ExportKeyPackageDialog.h
index a07cda69..ecf13b1d 100644
--- a/src/ui/widgets/ExportKeyPackageDialog.h
+++ b/src/ui/import_export/ExportKeyPackageDialog.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -31,24 +35,26 @@ class Ui_exportKeyPackageDialog;
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class ExportKeyPackageDialog : public QDialog {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Export Key Package Dialog object
+ *
+ * @param key_ids
+ * @param parent
+ */
explicit ExportKeyPackageDialog(KeyIdArgsListPtr key_ids, QWidget* parent);
- std::string generate_passphrase(int len);
-
private:
- std::shared_ptr<Ui_exportKeyPackageDialog> ui;
- KeyIdArgsListPtr key_ids_;
-
- std::random_device rd;
- std::mt19937 mt;
-
- std::string passphrase_;
-
- void generate_key_package_name();
+ std::shared_ptr<Ui_exportKeyPackageDialog> ui_; ///<
+ KeyIdArgsListPtr key_ids_; ///<
+ std::string passphrase_; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/KeyImportDetailDialog.cpp b/src/ui/import_export/KeyImportDetailDialog.cpp
index 1a50c64c..766d2d81 100644
--- a/src/ui/KeyImportDetailDialog.cpp
+++ b/src/ui/import_export/KeyImportDetailDialog.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,32 +8,34 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "ui/KeyImportDetailDialog.h"
+#include "KeyImportDetailDialog.h"
-#include "gpg/function/GpgKeyGetter.h"
+#include "core/function/gpg/GpgKeyGetter.h"
namespace GpgFrontend::UI {
KeyImportDetailDialog::KeyImportDetailDialog(GpgImportInformation result,
bool automatic, QWidget* parent)
- : QDialog(parent), mResult(std::move(result)) {
+ : QDialog(parent), m_result_(std::move(result)) {
// If no key for import found, just show a message
- if (mResult.considered == 0) {
+ if (m_result_.considered == 0) {
if (automatic)
QMessageBox::information(parent, _("Key Update Details"),
_("No keys found"));
@@ -44,12 +48,12 @@ KeyImportDetailDialog::KeyImportDetailDialog(GpgImportInformation result,
} else {
auto* mv_box = new QVBoxLayout();
- this->createGeneralInfoBox();
- mv_box->addWidget(generalInfoBox);
- this->createKeysTable();
- mv_box->addWidget(keysTable);
- this->createButtonBox();
- mv_box->addWidget(buttonBox);
+ this->create_general_info_box();
+ mv_box->addWidget(general_info_box_);
+ this->create_keys_table();
+ mv_box->addWidget(keys_table_);
+ this->create_button_box();
+ mv_box->addWidget(button_box_);
this->setLayout(mv_box);
if (automatic)
@@ -69,97 +73,97 @@ KeyImportDetailDialog::KeyImportDetailDialog(GpgImportInformation result,
}
}
-void KeyImportDetailDialog::createGeneralInfoBox() {
+void KeyImportDetailDialog::create_general_info_box() {
// GridBox for general import information
- generalInfoBox = new QGroupBox(_("General key info"));
- auto* generalInfoBoxLayout = new QGridLayout(generalInfoBox);
+ general_info_box_ = new QGroupBox(_("General key info"));
+ auto* generalInfoBoxLayout = new QGridLayout(general_info_box_);
generalInfoBoxLayout->addWidget(new QLabel(QString(_("Considered")) + ": "),
1, 0);
generalInfoBoxLayout->addWidget(
- new QLabel(QString::number(mResult.considered)), 1, 1);
+ new QLabel(QString::number(m_result_.considered)), 1, 1);
int row = 2;
- if (mResult.unchanged != 0) {
+ if (m_result_.unchanged != 0) {
generalInfoBoxLayout->addWidget(
new QLabel(QString(_("Public unchanged")) + ": "), row, 0);
generalInfoBoxLayout->addWidget(
- new QLabel(QString::number(mResult.unchanged)), row, 1);
+ new QLabel(QString::number(m_result_.unchanged)), row, 1);
row++;
}
- if (mResult.imported != 0) {
+ if (m_result_.imported != 0) {
generalInfoBoxLayout->addWidget(new QLabel(QString(_("Imported")) + ": "),
row, 0);
generalInfoBoxLayout->addWidget(
- new QLabel(QString::number(mResult.imported)), row, 1);
+ new QLabel(QString::number(m_result_.imported)), row, 1);
row++;
}
- if (mResult.not_imported != 0) {
+ if (m_result_.not_imported != 0) {
generalInfoBoxLayout->addWidget(
new QLabel(QString(_("Not Imported")) + ": "), row, 0);
generalInfoBoxLayout->addWidget(
- new QLabel(QString::number(mResult.not_imported)), row, 1);
+ new QLabel(QString::number(m_result_.not_imported)), row, 1);
row++;
}
- if (mResult.secret_read != 0) {
+ if (m_result_.secret_read != 0) {
generalInfoBoxLayout->addWidget(
new QLabel(QString(_("Private Read")) + ": "), row, 0);
generalInfoBoxLayout->addWidget(
- new QLabel(QString::number(mResult.secret_read)), row, 1);
+ new QLabel(QString::number(m_result_.secret_read)), row, 1);
row++;
}
- if (mResult.secret_imported != 0) {
+ if (m_result_.secret_imported != 0) {
generalInfoBoxLayout->addWidget(
new QLabel(QString(_("Private Imported")) + ": "), row, 0);
generalInfoBoxLayout->addWidget(
- new QLabel(QString::number(mResult.secret_imported)), row, 1);
+ new QLabel(QString::number(m_result_.secret_imported)), row, 1);
row++;
}
- if (mResult.secret_unchanged != 0) {
+ if (m_result_.secret_unchanged != 0) {
generalInfoBoxLayout->addWidget(
new QLabel(QString(_("Private Unchanged")) + ": "), row, 0);
generalInfoBoxLayout->addWidget(
- new QLabel(QString::number(mResult.secret_unchanged)), row, 1);
+ new QLabel(QString::number(m_result_.secret_unchanged)), row, 1);
row++;
}
}
-void KeyImportDetailDialog::createKeysTable() {
- LOG(INFO) << "KeyImportDetailDialog::createKeysTable() Called";
+void KeyImportDetailDialog::create_keys_table() {
+ LOG(INFO) << "KeyImportDetailDialog::create_keys_table() Called";
- keysTable = new QTableWidget(this);
- keysTable->setRowCount(0);
- keysTable->setColumnCount(4);
- keysTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ keys_table_ = new QTableWidget(this);
+ keys_table_->setRowCount(0);
+ keys_table_->setColumnCount(4);
+ keys_table_->setEditTriggers(QAbstractItemView::NoEditTriggers);
// Nothing is selectable
- keysTable->setSelectionMode(QAbstractItemView::NoSelection);
+ keys_table_->setSelectionMode(QAbstractItemView::NoSelection);
QStringList headerLabels;
headerLabels << _("Name") << _("Email") << _("Status") << _("Fingerprint");
- keysTable->verticalHeader()->hide();
+ keys_table_->verticalHeader()->hide();
- keysTable->setHorizontalHeaderLabels(headerLabels);
+ keys_table_->setHorizontalHeaderLabels(headerLabels);
int row = 0;
- for (const auto& imp_key : mResult.importedKeys) {
- keysTable->setRowCount(row + 1);
+ for (const auto& imp_key : m_result_.importedKeys) {
+ keys_table_->setRowCount(row + 1);
GpgKey key = GpgKeyGetter::GetInstance().GetKey(imp_key.fpr);
if (!key.IsGood()) continue;
- keysTable->setItem(
+ keys_table_->setItem(
row, 0, new QTableWidgetItem(QString::fromStdString(key.GetName())));
- keysTable->setItem(
+ keys_table_->setItem(
row, 1, new QTableWidgetItem(QString::fromStdString(key.GetEmail())));
- keysTable->setItem(
- row, 2, new QTableWidgetItem(getStatusString(imp_key.import_status)));
- keysTable->setItem(
+ keys_table_->setItem(
+ row, 2, new QTableWidgetItem(get_status_string(imp_key.import_status)));
+ keys_table_->setItem(
row, 3, new QTableWidgetItem(QString::fromStdString(imp_key.fpr)));
row++;
}
- keysTable->horizontalHeader()->setSectionResizeMode(
+ keys_table_->horizontalHeader()->setSectionResizeMode(
0, QHeaderView::ResizeToContents);
- keysTable->horizontalHeader()->setStretchLastSection(true);
- keysTable->resizeColumnsToContents();
+ keys_table_->horizontalHeader()->setStretchLastSection(true);
+ keys_table_->resizeColumnsToContents();
}
-QString KeyImportDetailDialog::getStatusString(int keyStatus) {
+QString KeyImportDetailDialog::get_status_string(int keyStatus) {
QString statusString;
// keystatus is greater than 15, if key is private
if (keyStatus > 15) {
@@ -191,8 +195,8 @@ QString KeyImportDetailDialog::getStatusString(int keyStatus) {
return statusString;
}
-void KeyImportDetailDialog::createButtonBox() {
- buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
- connect(buttonBox, SIGNAL(accepted()), this, SLOT(close()));
+void KeyImportDetailDialog::create_button_box() {
+ button_box_ = new QDialogButtonBox(QDialogButtonBox::Ok);
+ connect(button_box_, &QDialogButtonBox::accepted, this, &KeyImportDetailDialog::close);
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/import_export/KeyImportDetailDialog.h b/src/ui/import_export/KeyImportDetailDialog.h
new file mode 100644
index 00000000..a648f205
--- /dev/null
+++ b/src/ui/import_export/KeyImportDetailDialog.h
@@ -0,0 +1,91 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#ifndef __KEYIMPORTDETAILSDIALOG_H__
+#define __KEYIMPORTDETAILSDIALOG_H__
+
+#include "core/GpgContext.h"
+#include "core/function/gpg/GpgKeyImportExporter.h"
+#include "ui/GpgFrontendUI.h"
+
+namespace GpgFrontend::UI {
+
+/**
+ * @brief
+ *
+ */
+class KeyImportDetailDialog : public QDialog {
+ Q_OBJECT
+
+ public:
+ /**
+ * @brief Construct a new Key Import Detail Dialog object
+ *
+ * @param result
+ * @param automatic
+ * @param parent
+ */
+ KeyImportDetailDialog(GpgImportInformation result, bool automatic,
+ QWidget* parent = nullptr);
+
+ private:
+ /**
+ * @brief Create a general info box object
+ *
+ */
+ void create_general_info_box();
+
+ /**
+ * @brief Create a keys table object
+ *
+ */
+ void create_keys_table();
+
+ /**
+ * @brief Create a button box object
+ *
+ */
+ void create_button_box();
+
+ /**
+ * @brief Get the status string object
+ *
+ * @param keyStatus
+ * @return QString
+ */
+ static QString get_status_string(int keyStatus);
+
+ QTableWidget* keys_table_{}; ///<
+ QGroupBox* general_info_box_{}; ///<
+ QGroupBox* key_info_box_{}; ///<
+ QDialogButtonBox* button_box_{}; ///<
+ GpgImportInformation m_result_; ///<
+};
+} // namespace GpgFrontend::UI
+
+#endif // __KEYIMPORTDETAILSDIALOG_H__
diff --git a/src/ui/KeyServerImportDialog.cpp b/src/ui/import_export/KeyServerImportDialog.cpp
index 7c59de6f..c35e3db7 100644
--- a/src/ui/KeyServerImportDialog.cpp
+++ b/src/ui/import_export/KeyServerImportDialog.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,34 +8,36 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "ui/KeyServerImportDialog.h"
+#include "KeyServerImportDialog.h"
#include <utility>
-#include "gpg/function/GpgKeyImportExporter.h"
+#include "core/function/gpg/GpgKeyImportExporter.h"
#include "ui/SignalStation.h"
-#include "ui/settings/GlobalSettingStation.h"
+#include "core/function/GlobalSettingStation.h"
namespace GpgFrontend::UI {
KeyServerImportDialog::KeyServerImportDialog(bool automatic, QWidget* parent)
- : QDialog(parent), mAutomatic(automatic) {
+ : QDialog(parent), m_automatic_(automatic) {
// Layout for messagebox
auto* messageLayout = new QHBoxLayout;
@@ -41,37 +45,41 @@ KeyServerImportDialog::KeyServerImportDialog(bool automatic, QWidget* parent)
setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
} else {
// Buttons
- closeButton = createButton(_("Close"), SLOT(close()));
- importButton = createButton(_("Import ALL"), SLOT(slotImport()));
- importButton->setDisabled(true);
- searchButton = createButton(_("Search"), SLOT(slotSearch()));
- // Line edit for search string
- searchLabel = new QLabel(QString(_("Search String")) + _(": "));
- searchLineEdit = new QLineEdit();
+ close_button_ = new QPushButton(_("Close"));
+ connect(close_button_, &QPushButton::clicked, this, &KeyServerImportDialog::close);
+ import_button_ = new QPushButton(_("Import ALL"));
+ connect(import_button_, &QPushButton::clicked, this, &KeyServerImportDialog::slot_import);
+ import_button_->setDisabled(true);
+ search_button_ = new QPushButton(_("Search"));
+ connect(search_button_, &QPushButton::clicked, this, &KeyServerImportDialog::slot_search);
+
+ // Line edits for search string
+ search_label_ = new QLabel(QString(_("Search String")) + _(": "));
+ search_line_edit_ = new QLineEdit();
- // combobox for keyserverlist
- keyServerLabel = new QLabel(QString(_("Key Server")) + _(": "));
- keyServerComboBox = createComboBox();
+ // combobox for keyserver list
+ key_server_label_ = new QLabel(QString(_("Key Server")) + _(": "));
+ key_server_combo_box_ = create_comboBox();
// table containing the keys found
- createKeysTable();
- message = new QLabel;
- message->setFixedHeight(24);
- icon = new QLabel;
- icon->setFixedHeight(24);
-
- messageLayout->addWidget(icon);
- messageLayout->addWidget(message);
+ create_keys_table();
+ message_ = new QLabel;
+ message_->setFixedHeight(24);
+ icon_ = new QLabel;
+ icon_->setFixedHeight(24);
+
+ messageLayout->addWidget(icon_);
+ messageLayout->addWidget(message_);
messageLayout->addStretch();
}
// Network Waiting
- waitingBar = new QProgressBar();
- waitingBar->setVisible(false);
- waitingBar->setRange(0, 0);
- waitingBar->setFixedWidth(200);
- messageLayout->addWidget(waitingBar);
+ waiting_bar_ = new QProgressBar();
+ waiting_bar_->setVisible(false);
+ waiting_bar_->setRange(0, 0);
+ waiting_bar_->setFixedWidth(200);
+ messageLayout->addWidget(waiting_bar_);
auto* mainLayout = new QGridLayout;
@@ -79,19 +87,19 @@ KeyServerImportDialog::KeyServerImportDialog(bool automatic, QWidget* parent)
if (automatic) {
mainLayout->addLayout(messageLayout, 0, 0, 1, 3);
} else {
- mainLayout->addWidget(searchLabel, 1, 0);
- mainLayout->addWidget(searchLineEdit, 1, 1);
- mainLayout->addWidget(searchButton, 1, 2);
- mainLayout->addWidget(keyServerLabel, 2, 0);
- mainLayout->addWidget(keyServerComboBox, 2, 1);
- mainLayout->addWidget(keysTable, 3, 0, 1, 3);
+ mainLayout->addWidget(search_label_, 1, 0);
+ mainLayout->addWidget(search_line_edit_, 1, 1);
+ mainLayout->addWidget(search_button_, 1, 2);
+ mainLayout->addWidget(key_server_label_, 2, 0);
+ mainLayout->addWidget(key_server_combo_box_, 2, 1);
+ mainLayout->addWidget(keys_table_, 3, 0, 1, 3);
mainLayout->addLayout(messageLayout, 4, 0, 1, 3);
// Layout for import and close button
auto* buttonsLayout = new QHBoxLayout;
buttonsLayout->addStretch();
- buttonsLayout->addWidget(importButton);
- buttonsLayout->addWidget(closeButton);
+ buttonsLayout->addWidget(import_button_);
+ buttonsLayout->addWidget(close_button_);
mainLayout->addLayout(buttonsLayout, 6, 0, 1, 3);
}
@@ -131,21 +139,14 @@ KeyServerImportDialog::KeyServerImportDialog(bool automatic, QWidget* parent)
this->setModal(true);
- connect(this, SIGNAL(signalKeyImported()), SignalStation::GetInstance(),
- SIGNAL(KeyDatabaseRefresh()));
+ connect(this, &KeyServerImportDialog::SignalKeyImported, SignalStation::GetInstance(),
+ &SignalStation::SignalKeyDatabaseRefresh);
// save window pos and size to configure file
- connect(this, SIGNAL(finished(int)), this, SLOT(slotSaveWindowState()));
+ connect(this, &KeyServerImportDialog::finished, this, &KeyServerImportDialog::slot_save_window_state);
}
-QPushButton* KeyServerImportDialog::createButton(const QString& text,
- const char* member) {
- auto* button = new QPushButton(text);
- connect(button, SIGNAL(clicked()), this, member);
- return button;
-}
-
-QComboBox* KeyServerImportDialog::createComboBox() {
+QComboBox* KeyServerImportDialog::create_comboBox() {
auto* comboBox = new QComboBox;
comboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
@@ -173,95 +174,98 @@ QComboBox* KeyServerImportDialog::createComboBox() {
return comboBox;
}
-void KeyServerImportDialog::createKeysTable() {
- keysTable = new QTableWidget();
- keysTable->setColumnCount(4);
+void KeyServerImportDialog::create_keys_table() {
+ keys_table_ = new QTableWidget();
+ keys_table_->setColumnCount(4);
// always a whole row is marked
- keysTable->setSelectionBehavior(QAbstractItemView::SelectRows);
- keysTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ keys_table_->setSelectionBehavior(QAbstractItemView::SelectRows);
+ keys_table_->setEditTriggers(QAbstractItemView::NoEditTriggers);
// Make just one row selectable
- keysTable->setSelectionMode(QAbstractItemView::SingleSelection);
+ keys_table_->setSelectionMode(QAbstractItemView::SingleSelection);
QStringList labels;
labels << _("UID") << _("Creation date") << _("KeyID") << _("Tag");
- keysTable->horizontalHeader()->setSectionResizeMode(
+ keys_table_->horizontalHeader()->setSectionResizeMode(
0, QHeaderView::ResizeToContents);
- keysTable->setHorizontalHeaderLabels(labels);
- keysTable->verticalHeader()->hide();
+ keys_table_->setHorizontalHeaderLabels(labels);
+ keys_table_->verticalHeader()->hide();
- connect(keysTable, SIGNAL(cellActivated(int, int)), this, SLOT(slotImport()));
+ connect(keys_table_, &QTableWidget::cellActivated, this,
+ &KeyServerImportDialog::slot_import);
}
-void KeyServerImportDialog::setMessage(const QString& text, bool error) {
- if (mAutomatic) return;
+void KeyServerImportDialog::set_message(const QString& text, bool error) {
+ if (m_automatic_) return;
- message->setText(text);
+ message_->setText(text);
if (error) {
- icon->setPixmap(
+ icon_->setPixmap(
QPixmap(":error.png").scaled(QSize(24, 24), Qt::KeepAspectRatio));
} else {
- icon->setPixmap(
+ icon_->setPixmap(
QPixmap(":info.png").scaled(QSize(24, 24), Qt::KeepAspectRatio));
}
}
-void KeyServerImportDialog::slotSearch() {
- if (searchLineEdit->text().isEmpty()) {
- setMessage("<h4>" + QString(_("Text is empty.")) + "</h4>", false);
+void KeyServerImportDialog::slot_search() {
+ if (search_line_edit_->text().isEmpty()) {
+ set_message("<h4>" + QString(_("Text is empty.")) + "</h4>", false);
return;
}
- QUrl url_from_remote = keyServerComboBox->currentText() +
- "/pks/lookup?search=" + searchLineEdit->text() +
+ QUrl url_from_remote = key_server_combo_box_->currentText() +
+ "/pks/lookup?search=" + search_line_edit_->text() +
"&op=index&options=mr";
- qnam = new QNetworkAccessManager(this);
- QNetworkReply* reply = qnam->get(QNetworkRequest(url_from_remote));
+ network_access_manager_ = new QNetworkAccessManager(this);
+ QNetworkReply* reply =
+ network_access_manager_->get(QNetworkRequest(url_from_remote));
- connect(reply, SIGNAL(finished()), this, SLOT(slotSearchFinished()));
+ connect(reply, &QNetworkReply::finished, this, &KeyServerImportDialog::slot_search_finished);
- setLoading(true);
- this->searchButton->setDisabled(true);
- this->keyServerComboBox->setDisabled(true);
- this->searchLineEdit->setReadOnly(true);
- this->importButton->setDisabled(true);
+ set_loading(true);
+ this->search_button_->setDisabled(true);
+ this->key_server_combo_box_->setDisabled(true);
+ this->search_line_edit_->setReadOnly(true);
+ this->import_button_->setDisabled(true);
while (reply->isRunning()) {
QApplication::processEvents();
}
- this->searchButton->setDisabled(false);
- this->keyServerComboBox->setDisabled(false);
- this->searchLineEdit->setReadOnly(false);
- this->importButton->setDisabled(false);
- setLoading(false);
+ this->search_button_->setDisabled(false);
+ this->key_server_combo_box_->setDisabled(false);
+ this->search_line_edit_->setReadOnly(false);
+ this->import_button_->setDisabled(false);
+ set_loading(false);
}
-void KeyServerImportDialog::slotSearchFinished() {
- LOG(INFO) << "KeyServerImportDialog::slotSearchFinished Called";
+void KeyServerImportDialog::slot_search_finished() {
+ LOG(INFO) << "Called";
auto* reply = qobject_cast<QNetworkReply*>(sender());
- keysTable->clearContents();
- keysTable->setRowCount(0);
+ keys_table_->clearContents();
+ keys_table_->setRowCount(0);
QString first_line = QString(reply->readLine(1024));
auto error = reply->error();
if (error != QNetworkReply::NoError) {
- qDebug() << "Error From Reply" << reply->errorString();
+ LOG(INFO) << "Error From Reply" << reply->errorString().toStdString();
+
switch (error) {
case QNetworkReply::ContentNotFoundError:
- setMessage(_("Not Key Found"), true);
+ set_message(_("Not Key Found"), true);
break;
case QNetworkReply::TimeoutError:
- setMessage(_("Timeout"), true);
+ set_message(_("Timeout"), true);
break;
case QNetworkReply::HostNotFoundError:
- setMessage(_("Key Server Not Found"), true);
+ set_message(_("Key Server Not Found"), true);
break;
default:
- setMessage(_("Connection Error"), true);
+ set_message(_("Connection Error"), true);
}
return;
}
@@ -269,38 +273,39 @@ void KeyServerImportDialog::slotSearchFinished() {
if (first_line.contains("Error")) {
QString text = QString(reply->readLine(1024));
if (text.contains("Too many responses")) {
- setMessage(
+ set_message(
"<h4>" + QString(_("Too many responses from keyserver!")) + "</h4>",
true);
return;
} else if (text.contains("No keys found")) {
// if string looks like hex string, search again with 0x prepended
QRegExp rx("[0-9A-Fa-f]*");
- QString query = searchLineEdit->text();
+ QString query = search_line_edit_->text();
if (rx.exactMatch(query)) {
- setMessage(
+ set_message(
"<h4>" +
QString(_("No keys found, input may be kexId, retrying search "
"with 0x.")) +
"</h4>",
true);
- searchLineEdit->setText(query.prepend("0x"));
- this->slotSearch();
+ search_line_edit_->setText(query.prepend("0x"));
+ this->slot_search();
return;
} else {
- setMessage(
+ set_message(
"<h4>" + QString(_("No keys found containing the search string!")) +
"</h4>",
true);
return;
}
} else if (text.contains("Insufficiently specific words")) {
- setMessage("<h4>" + QString(_("Insufficiently specific search string!")) +
- "</h4>",
- true);
+ set_message("<h4>" +
+ QString(_("Insufficiently specific search string!")) +
+ "</h4>",
+ true);
return;
} else {
- setMessage(text, true);
+ set_message(text, true);
return;
}
} else {
@@ -316,23 +321,23 @@ void KeyServerImportDialog::slotSearchFinished() {
strikeout = false;
QString flags = line[line.size() - 1];
- keysTable->setRowCount(row + 1);
+ keys_table_->setRowCount(row + 1);
// flags can be "d" for disabled, "r" for revoked
// or "e" for expired
if (flags.contains("r") or flags.contains("d") or flags.contains("e")) {
strikeout = true;
if (flags.contains("e")) {
- keysTable->setItem(row, 3,
- new QTableWidgetItem(QString("expired")));
+ keys_table_->setItem(row, 3,
+ new QTableWidgetItem(QString("expired")));
}
if (flags.contains("r")) {
- keysTable->setItem(row, 3,
- new QTableWidgetItem(QString(_("revoked"))));
+ keys_table_->setItem(row, 3,
+ new QTableWidgetItem(QString(_("revoked"))));
}
if (flags.contains("d")) {
- keysTable->setItem(row, 3,
- new QTableWidgetItem(QString(_("disabled"))));
+ keys_table_->setItem(row, 3,
+ new QTableWidgetItem(QString(_("disabled"))));
}
}
@@ -341,13 +346,13 @@ void KeyServerImportDialog::slotSearchFinished() {
auto* uid = new QTableWidgetItem();
if (line2.size() > 1) {
uid->setText(line2[1]);
- keysTable->setItem(row, 0, uid);
+ keys_table_->setItem(row, 0, uid);
}
auto* creation_date = new QTableWidgetItem(
QDateTime::fromTime_t(line[4].toInt()).toString("dd. MMM. yyyy"));
- keysTable->setItem(row, 1, creation_date);
+ keys_table_->setItem(row, 1, creation_date);
auto* keyid = new QTableWidgetItem(line[1]);
- keysTable->setItem(row, 2, keyid);
+ keys_table_->setItem(row, 2, keyid);
if (strikeout) {
QFont strike = uid->font();
strike.setStrikeOut(true);
@@ -359,12 +364,12 @@ void KeyServerImportDialog::slotSearchFinished() {
} else {
if (line[0] == "uid") {
QStringList l;
- int height = keysTable->rowHeight(row - 1);
- keysTable->setRowHeight(row - 1, height + 16);
- QString tmp = keysTable->item(row - 1, 0)->text();
+ int height = keys_table_->rowHeight(row - 1);
+ keys_table_->setRowHeight(row - 1, height + 16);
+ QString tmp = keys_table_->item(row - 1, 0)->text();
tmp.append(QString("\n") + line[1]);
auto* tmp1 = new QTableWidgetItem(tmp);
- keysTable->setItem(row - 1, 0, tmp1);
+ keys_table_->setItem(row - 1, 0, tmp1);
if (strikeout) {
QFont strike = tmp1->font();
strike.setStrikeOut(true);
@@ -372,31 +377,31 @@ void KeyServerImportDialog::slotSearchFinished() {
}
}
}
- setMessage(
+ set_message(
QString("<h4>") +
QString(_("%1 keys found. Double click a key to import it."))
.arg(row) +
"</h4>",
false);
}
- keysTable->resizeColumnsToContents();
- importButton->setDisabled(keysTable->size().isEmpty());
+ keys_table_->resizeColumnsToContents();
+ import_button_->setDisabled(keys_table_->size().isEmpty());
}
reply->deleteLater();
}
-void KeyServerImportDialog::slotImport() {
- LOG(INFO) << _("Current Row") << keysTable->currentRow();
- if (keysTable->currentRow() > -1) {
- QString keyid = keysTable->item(keysTable->currentRow(), 2)->text();
- slotImport(QStringList(keyid), keyServerComboBox->currentText());
+void KeyServerImportDialog::slot_import() {
+ LOG(INFO) << _("Current Row") << keys_table_->currentRow();
+ if (keys_table_->currentRow() > -1) {
+ QString keyid = keys_table_->item(keys_table_->currentRow(), 2)->text();
+ SlotImport(QStringList(keyid), key_server_combo_box_->currentText());
}
}
-void KeyServerImportDialog::slotImport(const KeyIdArgsListPtr& keys) {
+void KeyServerImportDialog::SlotImport(const KeyIdArgsListPtr& keys) {
std::string target_keyserver;
- if (keyServerComboBox != nullptr) {
- target_keyserver = keyServerComboBox->currentText().toStdString();
+ if (key_server_combo_box_ != nullptr) {
+ target_keyserver = key_server_combo_box_->currentText().toStdString();
}
if (target_keyserver.empty()) {
try {
@@ -418,13 +423,13 @@ void KeyServerImportDialog::slotImport(const KeyIdArgsListPtr& keys) {
auto key_ids = QStringList();
for (const auto& key_id : *keys)
key_ids.append(QString::fromStdString(key_id));
- slotImport(key_ids, QUrl(target_keyserver.c_str()));
+ SlotImport(key_ids, QUrl(target_keyserver.c_str()));
}
-void KeyServerImportDialog::slotImport(const QStringList& keyIds,
- const QUrl& keyServerUrl) {
+void KeyServerImportDialog::SlotImport(const QStringList& keyIds,
+ const QUrl& keyserverUrl) {
for (const auto& keyId : keyIds) {
- QUrl req_url(keyServerUrl.scheme() + "://" + keyServerUrl.host() +
+ QUrl req_url(keyserverUrl.scheme() + "://" + keyserverUrl.host() +
"/pks/lookup?op=get&search=0x" + keyId + "&options=mr");
LOG(INFO) << "request url" << req_url.toString().toStdString();
@@ -432,16 +437,16 @@ void KeyServerImportDialog::slotImport(const QStringList& keyIds,
QNetworkReply* reply = manager->get(QNetworkRequest(req_url));
connect(reply, &QNetworkReply::finished, this,
- [&, keyId]() { this->slotImportFinished(keyId); });
+ [&, keyId]() { this->slot_import_finished(keyId); });
LOG(INFO) << "loading start";
- setLoading(true);
+ set_loading(true);
while (reply->isRunning()) QApplication::processEvents();
- setLoading(false);
+ set_loading(false);
LOG(INFO) << "loading done";
}
}
-void KeyServerImportDialog::slotImportFinished(const QString& keyid) {
+void KeyServerImportDialog::slot_import_finished(const QString& keyid) {
LOG(INFO) << _("Called");
auto* reply = qobject_cast<QNetworkReply*>(sender());
@@ -451,19 +456,19 @@ void KeyServerImportDialog::slotImportFinished(const QString& keyid) {
auto error = reply->error();
if (error != QNetworkReply::NoError) {
LOG(ERROR) << "Error From Reply" << reply->errorString().toStdString();
- if (!mAutomatic) {
+ if (!m_automatic_) {
switch (error) {
case QNetworkReply::ContentNotFoundError:
- setMessage(_("Key Not Found"), true);
+ set_message(_("Key Not Found"), true);
break;
case QNetworkReply::TimeoutError:
- setMessage(_("Timeout"), true);
+ set_message(_("Timeout"), true);
break;
case QNetworkReply::HostNotFoundError:
- setMessage(_("Key Server Not Found"), true);
+ set_message(_("Key Server Not Found"), true);
break;
default:
- setMessage(_("Connection Error"), true);
+ set_message(_("Connection Error"), true);
}
} else {
switch (error) {
@@ -485,7 +490,7 @@ void KeyServerImportDialog::slotImportFinished(const QString& keyid) {
_("General Connection Error"));
}
}
- if (mAutomatic) {
+ if (m_automatic_) {
setWindowFlags(Qt::Window | Qt::WindowTitleHint |
Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
}
@@ -494,19 +499,19 @@ void KeyServerImportDialog::slotImportFinished(const QString& keyid) {
reply->deleteLater();
- this->importKeys(std::make_unique<ByteArray>(key.constData(), key.length()));
+ this->import_keys(std::make_unique<ByteArray>(key.constData(), key.length()));
- if (!mAutomatic) {
- setMessage(QString("<h4>") + _("Key Imported") + "</h4>", false);
+ if (!m_automatic_) {
+ set_message(QString("<h4>") + _("Key Imported") + "</h4>", false);
}
}
-void KeyServerImportDialog::importKeys(ByteArrayPtr in_data) {
+void KeyServerImportDialog::import_keys(ByteArrayPtr in_data) {
GpgImportInformation result =
GpgKeyImportExporter::GetInstance().ImportKey(std::move(in_data));
- emit signalKeyImported();
+ emit SignalKeyImported();
QWidget* _parent = qobject_cast<QWidget*>(parent());
- if (mAutomatic) {
+ if (m_automatic_) {
auto dialog = new KeyImportDetailDialog(result, true, _parent);
dialog->show();
this->accept();
@@ -516,32 +521,32 @@ void KeyServerImportDialog::importKeys(ByteArrayPtr in_data) {
}
}
-void KeyServerImportDialog::setLoading(bool status) {
- waitingBar->setVisible(status);
- if (!mAutomatic) {
- icon->setVisible(!status);
- message->setVisible(!status);
+void KeyServerImportDialog::set_loading(bool status) {
+ waiting_bar_->setVisible(status);
+ if (!m_automatic_) {
+ icon_->setVisible(!status);
+ message_->setVisible(!status);
}
}
KeyServerImportDialog::KeyServerImportDialog(QWidget* parent)
- : QDialog(parent), mAutomatic(true) {
+ : QDialog(parent), m_automatic_(true) {
setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
// Network Waiting
- waitingBar = new QProgressBar();
- waitingBar->setVisible(false);
- waitingBar->setRange(0, 0);
- waitingBar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
- waitingBar->setTextVisible(false);
+ waiting_bar_ = new QProgressBar();
+ waiting_bar_->setVisible(false);
+ waiting_bar_->setRange(0, 0);
+ waiting_bar_->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ waiting_bar_->setTextVisible(false);
// Layout for messagebox
auto* layout = new QHBoxLayout();
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
- layout->addWidget(waitingBar);
+ layout->addWidget(waiting_bar_);
- keyServerComboBox = createComboBox();
+ key_server_combo_box_ = create_comboBox();
this->setLayout(layout);
this->setWindowTitle(_("Update Keys from Keyserver"));
@@ -549,13 +554,13 @@ KeyServerImportDialog::KeyServerImportDialog(QWidget* parent)
this->setModal(true);
}
-void KeyServerImportDialog::slotSaveWindowState() {
+void KeyServerImportDialog::slot_save_window_state() {
LOG(INFO) << _("Called");
- if (mAutomatic) return;
+ if (m_automatic_) return;
auto& settings =
- GpgFrontend::UI::GlobalSettingStation::GetInstance().GetUISettings();
+ GpgFrontend::GlobalSettingStation::GetInstance().GetUISettings();
if (!settings.exists("window") ||
settings.lookup("window").getType() != libconfig::Setting::TypeGroup)
diff --git a/src/ui/import_export/KeyServerImportDialog.h b/src/ui/import_export/KeyServerImportDialog.h
new file mode 100644
index 00000000..37362859
--- /dev/null
+++ b/src/ui/import_export/KeyServerImportDialog.h
@@ -0,0 +1,183 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#ifndef __KEY_SERVER_IMPORT_DIALOG_H__
+#define __KEY_SERVER_IMPORT_DIALOG_H__
+
+#include "KeyImportDetailDialog.h"
+#include "core/GpgContext.h"
+#include "ui/GpgFrontendUI.h"
+#include "ui/widgets/KeyList.h"
+
+namespace GpgFrontend::UI {
+
+/**
+ * @brief
+ *
+ */
+class KeyServerImportDialog : public QDialog {
+ Q_OBJECT
+
+ public:
+ /**
+ * @brief Construct a new Key Server Import Dialog object
+ *
+ * @param automatic
+ * @param parent
+ */
+ KeyServerImportDialog(bool automatic, QWidget* parent);
+
+ /**
+ * @brief Construct a new Key Server Import Dialog object
+ *
+ * @param parent
+ */
+ explicit KeyServerImportDialog(QWidget* parent);
+
+ public slots:
+
+ /**
+ * @brief
+ *
+ * @param keys
+ */
+ void SlotImport(const KeyIdArgsListPtr& keys);
+
+ /**
+ * @brief
+ *
+ * @param keyIds
+ * @param keyserverUrl
+ */
+ void SlotImport(const QStringList& keyIds, const QUrl& keyserverUrl);
+
+ signals:
+
+ /**
+ * @brief
+ *
+ */
+ void SignalKeyImported();
+
+ private slots:
+
+ /**
+ * @brief
+ *
+ */
+ void slot_import();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_search_finished();
+
+ /**
+ * @brief
+ *
+ * @param keyid
+ */
+ void slot_import_finished(const QString& keyid);
+
+ /**
+ * @brief
+ *
+ */
+ void slot_search();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_save_window_state();
+
+ private:
+ /**
+ * @brief Create a keys table object
+ *
+ */
+ void create_keys_table();
+
+ /**
+ * @brief Set the message object
+ *
+ * @param text
+ * @param error
+ */
+ void set_message(const QString& text, bool error);
+
+ /**
+ * @brief
+ *
+ * @param in_data
+ */
+ void import_keys(ByteArrayPtr in_data);
+
+ /**
+ * @brief Set the loading object
+ *
+ * @param status
+ */
+ void set_loading(bool status);
+
+ /**
+ * @brief Create a button object
+ *
+ * @param text
+ * @param member
+ * @return QPushButton*
+ */
+ QPushButton* create_button(const QString& text, const char* member);
+
+ /**
+ * @brief Create a comboBox object
+ *
+ * @return QComboBox*
+ */
+ QComboBox* create_comboBox();
+
+ bool m_automatic_ = false; ///<
+
+ QLineEdit* search_line_edit_{}; ///<
+ QComboBox* key_server_combo_box_{}; ///<
+ QProgressBar* waiting_bar_; ///<
+ QLabel* search_label_{}; ///<
+ QLabel* key_server_label_{}; ///<
+ QLabel* message_{}; ///<
+ QLabel* icon_{}; ///<
+ QPushButton* close_button_{}; ///<
+ QPushButton* import_button_{}; ///<
+ QPushButton* search_button_{}; ///<
+ QTableWidget* keys_table_{}; ///<
+ QNetworkAccessManager* network_access_manager_{}; ///<
+};
+
+} // namespace GpgFrontend::UI
+
+#endif // __KEY_SERVER_IMPORT_DIALOG_H__
diff --git a/src/ui/KeyUploadDialog.cpp b/src/ui/import_export/KeyUploadDialog.cpp
index d2b8c0bf..a0436a8e 100644
--- a/src/ui/KeyUploadDialog.cpp
+++ b/src/ui/import_export/KeyUploadDialog.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,35 +8,37 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "ui/KeyUploadDialog.h"
+#include "KeyUploadDialog.h"
#include <algorithm>
-#include "gpg/function/GpgKeyGetter.h"
-#include "gpg/function/GpgKeyImportExporter.h"
-#include "ui/settings/GlobalSettingStation.h"
+#include "core/function/gpg/GpgKeyGetter.h"
+#include "core/function/gpg/GpgKeyImportExporter.h"
+#include "core/function/GlobalSettingStation.h"
namespace GpgFrontend::UI {
KeyUploadDialog::KeyUploadDialog(const KeyIdArgsListPtr& keys_ids,
QWidget* parent)
- : QDialog(parent), mKeys(GpgKeyGetter::GetInstance().GetKeys(keys_ids)) {
+ : QDialog(parent), m_keys_(GpgKeyGetter::GetInstance().GetKeys(keys_ids)) {
auto* pb = new QProgressBar();
pb->setRange(0, 0);
pb->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
@@ -51,13 +55,13 @@ KeyUploadDialog::KeyUploadDialog(const KeyIdArgsListPtr& keys_ids,
this->setFixedSize(240, 42);
}
-void KeyUploadDialog::slotUpload() {
+void KeyUploadDialog::SlotUpload() {
auto out_data = std::make_unique<ByteArray>();
- GpgKeyImportExporter::GetInstance().ExportKeys(*mKeys, out_data);
- uploadKeyToServer(*out_data);
+ GpgKeyImportExporter::GetInstance().ExportKeys(*m_keys_, out_data);
+ slot_upload_key_to_server(*out_data);
}
-void KeyUploadDialog::uploadKeyToServer(
+void KeyUploadDialog::slot_upload_key_to_server(
const GpgFrontend::ByteArray& keys_data) {
std::string target_keyserver;
if (target_keyserver.empty()) {
@@ -105,7 +109,7 @@ void KeyUploadDialog::uploadKeyToServer(
// Send Post Data
QNetworkReply* reply = qnam->post(request, postData);
- connect(reply, SIGNAL(finished()), this, SLOT(slotUploadFinished()));
+ connect(reply, &QNetworkReply::finished, this, &KeyUploadDialog::slot_upload_finished);
// Keep Waiting
while (reply->isRunning()) {
@@ -117,7 +121,7 @@ void KeyUploadDialog::uploadKeyToServer(
this->close();
}
-void KeyUploadDialog::slotUploadFinished() {
+void KeyUploadDialog::slot_upload_finished() {
auto* reply = qobject_cast<QNetworkReply*>(sender());
QByteArray response = reply->readAll();
diff --git a/src/ui/KeyUploadDialog.h b/src/ui/import_export/KeyUploadDialog.h
index 6f292d2b..05cba083 100644
--- a/src/ui/KeyUploadDialog.h
+++ b/src/ui/import_export/KeyUploadDialog.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,48 +8,73 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef GPGFRONTEND_KEYUPLOADWIDGET_H
#define GPGFRONTEND_KEYUPLOADWIDGET_H
-#include "gpg/GpgContext.h"
+#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class KeyUploadDialog : public QDialog {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Key Upload Dialog object
+ *
+ * @param keys_ids
+ * @param parent
+ */
explicit KeyUploadDialog(const KeyIdArgsListPtr& keys_ids, QWidget* parent);
public slots:
- void slotUpload();
+ /**
+ * @brief
+ *
+ */
+ void SlotUpload();
private slots:
- void uploadKeyToServer(const GpgFrontend::ByteArray& keys_data);
+ /**
+ * @brief
+ *
+ * @param keys_data
+ */
+ void slot_upload_key_to_server(const GpgFrontend::ByteArray& keys_data);
- void slotUploadFinished();
+ /**
+ * @brief
+ *
+ */
+ void slot_upload_finished();
private:
- KeyListPtr mKeys;
- QByteArray mKeyData;
+ KeyListPtr m_keys_; ///<
+ QByteArray m_key_data_; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/keygen/KeygenDialog.cpp b/src/ui/key_generate/KeygenDialog.cpp
index a3ffc671..6df0bcf0 100644
--- a/src/ui/keygen/KeygenDialog.cpp
+++ b/src/ui/key_generate/KeygenDialog.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,28 +8,30 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "ui/keygen/KeygenDialog.h"
+#include "ui/key_generate/KeygenDialog.h"
-#include "gpg/function/GpgKeyOpera.h"
+#include "dialog/WaitingDialog.h"
+#include "core/function/gpg/GpgKeyOpera.h"
#include "ui/SignalStation.h"
-#include "ui/WaitingDialog.h"
-#include "ui/settings/GlobalSettingStation.h"
+#include "core/function/GlobalSettingStation.h"
namespace GpgFrontend::UI {
@@ -54,8 +58,8 @@ KeyGenDialog::KeyGenDialog(QWidget* parent) : QDialog(parent) {
this->setWindowTitle(_("Generate Key"));
this->setModal(true);
- connect(this, SIGNAL(SignalKeyGenerated()), SignalStation::GetInstance(),
- SIGNAL(KeyDatabaseRefresh()));
+ connect(this, &KeyGenDialog::SignalKeyGenerated, SignalStation::GetInstance(),
+ &SignalStation::SignalKeyDatabaseRefresh);
generate_key_dialog();
}
@@ -305,23 +309,25 @@ void KeyGenDialog::refresh_widgets_state() {
}
void KeyGenDialog::set_signal_slot() {
- connect(button_box_, SIGNAL(accepted()), this, SLOT(slot_key_gen_accept()));
- connect(button_box_, SIGNAL(rejected()), this, SLOT(reject()));
-
- connect(expire_check_box_, SIGNAL(stateChanged(int)), this,
- SLOT(slot_expire_box_changed()));
-
- connect(key_usage_check_boxes_[0], SIGNAL(stateChanged(int)), this,
- SLOT(slot_encryption_box_changed(int)));
- connect(key_usage_check_boxes_[1], SIGNAL(stateChanged(int)), this,
- SLOT(slot_signing_box_changed(int)));
- connect(key_usage_check_boxes_[2], SIGNAL(stateChanged(int)), this,
- SLOT(slot_certification_box_changed(int)));
- connect(key_usage_check_boxes_[3], SIGNAL(stateChanged(int)), this,
- SLOT(slot_authentication_box_changed(int)));
-
- connect(key_type_combo_box_, SIGNAL(currentIndexChanged(int)), this,
- SLOT(slot_activated_key_type(int)));
+ connect(button_box_, &QDialogButtonBox::accepted, this,
+ &KeyGenDialog::slot_key_gen_accept);
+ connect(button_box_, &QDialogButtonBox::rejected, this,
+ &KeyGenDialog::reject);
+
+ connect(expire_check_box_, &QCheckBox::stateChanged, this,
+ &KeyGenDialog::slot_expire_box_changed);
+
+ connect(key_usage_check_boxes_[0], &QCheckBox::stateChanged, this,
+ &KeyGenDialog::slot_encryption_box_changed);
+ connect(key_usage_check_boxes_[1], &QCheckBox::stateChanged, this,
+ &KeyGenDialog::slot_signing_box_changed);
+ connect(key_usage_check_boxes_[2], &QCheckBox::stateChanged, this,
+ &KeyGenDialog::slot_certification_box_changed);
+ connect(key_usage_check_boxes_[3], &QCheckBox::stateChanged, this,
+ &KeyGenDialog::slot_authentication_box_changed);
+
+ connect(key_type_combo_box_, qOverload<int>(&QComboBox::currentIndexChanged),
+ this, &KeyGenDialog::slot_activated_key_type);
connect(no_pass_phrase_check_box_, &QCheckBox::stateChanged, this,
[this](int state) -> void {
diff --git a/src/ui/keygen/KeygenDialog.h b/src/ui/key_generate/KeygenDialog.h
index 482ab3b0..751ebdd8 100644
--- a/src/ui/keygen/KeygenDialog.h
+++ b/src/ui/key_generate/KeygenDialog.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -25,8 +27,8 @@
#ifndef __KEYGENDIALOG_H__
#define __KEYGENDIALOG_H__
-#include "gpg/GpgContext.h"
-#include "gpg/GpgGenKeyInfo.h"
+#include "core/GpgContext.h"
+#include "core/GpgGenKeyInfo.h"
#include "ui/GpgFrontendUI.h"
namespace GpgFrontend::UI {
diff --git a/src/ui/keygen/SubkeyGenerateDialog.cpp b/src/ui/key_generate/SubkeyGenerateDialog.cpp
index 983d26b7..4eb041aa 100644
--- a/src/ui/keygen/SubkeyGenerateDialog.cpp
+++ b/src/ui/key_generate/SubkeyGenerateDialog.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,29 +8,29 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
*
*/
-#include "ui/keygen/SubkeyGenerateDialog.h"
+#include "ui/key_generate/SubkeyGenerateDialog.h"
-#include "gpg/function/GpgKeyGetter.h"
-#include "gpg/function/GpgKeyOpera.h"
+#include "dialog/WaitingDialog.h"
+#include "core/function/gpg/GpgKeyGetter.h"
+#include "core/function/gpg/GpgKeyOpera.h"
#include "ui/SignalStation.h"
-#include "ui/WaitingDialog.h"
-#include "ui/settings/GlobalSettingStation.h"
+#include "core/function/GlobalSettingStation.h"
namespace GpgFrontend::UI {
@@ -71,8 +73,8 @@ SubkeyGenerateDialog::SubkeyGenerateDialog(const KeyId& key_id, QWidget* parent)
this->setLayout(vbox2);
this->setModal(true);
- connect(this, SIGNAL(SignalSubKeyGenerated()), SignalStation::GetInstance(),
- SIGNAL(KeyDatabaseRefresh()));
+ connect(this, &SubkeyGenerateDialog::SignalSubKeyGenerated, SignalStation::GetInstance(),
+ &SignalStation::SignalKeyDatabaseRefresh);
set_signal_slot();
refresh_widgets_state();
@@ -154,23 +156,23 @@ QGroupBox* SubkeyGenerateDialog::create_basic_info_group_box() {
}
void SubkeyGenerateDialog::set_signal_slot() {
- connect(button_box_, SIGNAL(accepted()), this, SLOT(slot_key_gen_accept()));
- connect(button_box_, SIGNAL(rejected()), this, SLOT(reject()));
-
- connect(expire_check_box_, SIGNAL(stateChanged(int)), this,
- SLOT(slot_expire_box_changed()));
-
- connect(key_usage_check_boxes_[0], SIGNAL(stateChanged(int)), this,
- SLOT(slot_encryption_box_changed(int)));
- connect(key_usage_check_boxes_[1], SIGNAL(stateChanged(int)), this,
- SLOT(slot_signing_box_changed(int)));
- connect(key_usage_check_boxes_[2], SIGNAL(stateChanged(int)), this,
- SLOT(slot_certification_box_changed(int)));
- connect(key_usage_check_boxes_[3], SIGNAL(stateChanged(int)), this,
- SLOT(slot_authentication_box_changed(int)));
-
- connect(key_type_combo_box_, SIGNAL(currentIndexChanged(int)), this,
- SLOT(slot_activated_key_type(int)));
+ connect(button_box_, &QDialogButtonBox::accepted, this, &SubkeyGenerateDialog::slot_key_gen_accept);
+ connect(button_box_, &QDialogButtonBox::rejected, this, &SubkeyGenerateDialog::reject);
+
+ connect(expire_check_box_, &QCheckBox::stateChanged, this,
+ &SubkeyGenerateDialog::slot_expire_box_changed);
+
+ connect(key_usage_check_boxes_[0], &QCheckBox::stateChanged, this,
+ &SubkeyGenerateDialog::slot_encryption_box_changed);
+ connect(key_usage_check_boxes_[1], &QCheckBox::stateChanged, this,
+ &SubkeyGenerateDialog::slot_signing_box_changed);
+ connect(key_usage_check_boxes_[2], &QCheckBox::stateChanged, this,
+ &SubkeyGenerateDialog::slot_certification_box_changed);
+ connect(key_usage_check_boxes_[3], &QCheckBox::stateChanged, this,
+ &SubkeyGenerateDialog::slot_authentication_box_changed);
+
+ connect(key_type_combo_box_, qOverload<int>(&QComboBox::currentIndexChanged), this,
+ &SubkeyGenerateDialog::slot_activated_key_type);
}
void SubkeyGenerateDialog::slot_expire_box_changed() {
diff --git a/src/ui/keygen/SubkeyGenerateDialog.h b/src/ui/key_generate/SubkeyGenerateDialog.h
index df65b87a..4ab90ad4 100644
--- a/src/ui/keygen/SubkeyGenerateDialog.h
+++ b/src/ui/key_generate/SubkeyGenerateDialog.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -25,8 +27,8 @@
#ifndef GPGFRONTEND_SUBKEYGENERATEDIALOG_H
#define GPGFRONTEND_SUBKEYGENERATEDIALOG_H
-#include "gpg/GpgContext.h"
-#include "gpg/GpgGenKeyInfo.h"
+#include "core/GpgContext.h"
+#include "core/GpgGenKeyInfo.h"
#include "ui/GpgFrontendUI.h"
namespace GpgFrontend::UI {
diff --git a/src/ui/keypair_details/EditSubKeyDialog.cpp b/src/ui/keypair_details/EditSubKeyDialog.cpp
deleted file mode 100644
index 6c2e0ce1..00000000
--- a/src/ui/keypair_details/EditSubKeyDialog.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#include "ui/keypair_details/EditSubKeyDialog.h"
diff --git a/src/ui/keypair_details/EditSubKeyDialog.h b/src/ui/keypair_details/EditSubKeyDialog.h
deleted file mode 100644
index 51842405..00000000
--- a/src/ui/keypair_details/EditSubKeyDialog.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#ifndef GPGFRONTEND_EDITSUBKEY_H
-#define GPGFRONTEND_EDITSUBKEY_H
-
-class EditSubKeyDialog {};
-
-#endif // GPGFRONTEND_EDITSUBKEY_H
diff --git a/src/ui/keypair_details/KeyDetailsDialog.cpp b/src/ui/keypair_details/KeyDetailsDialog.cpp
index 4b4c0dba..3b3e8818 100644
--- a/src/ui/keypair_details/KeyDetailsDialog.cpp
+++ b/src/ui/keypair_details/KeyDetailsDialog.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -32,15 +36,17 @@
namespace GpgFrontend::UI {
KeyDetailsDialog::KeyDetailsDialog(const GpgKey& key, QWidget* parent)
: QDialog(parent) {
- tabWidget = new QTabWidget();
- tabWidget->addTab(new KeyPairDetailTab(key.GetId(), tabWidget), _("KeyPair"));
- tabWidget->addTab(new KeyPairUIDTab(key.GetId(), tabWidget), _("UIDs"));
- tabWidget->addTab(new KeyPairSubkeyTab(key.GetId(), tabWidget), _("Subkeys"));
- tabWidget->addTab(new KeyPairOperaTab(key.GetId(), tabWidget),
- _("Operations"));
+ tab_widget_ = new QTabWidget();
+ tab_widget_->addTab(new KeyPairDetailTab(key.GetId(), tab_widget_),
+ _("KeyPair"));
+ tab_widget_->addTab(new KeyPairUIDTab(key.GetId(), tab_widget_), _("UIDs"));
+ tab_widget_->addTab(new KeyPairSubkeyTab(key.GetId(), tab_widget_),
+ _("Subkeys"));
+ tab_widget_->addTab(new KeyPairOperaTab(key.GetId(), tab_widget_),
+ _("Operations"));
auto* mainLayout = new QVBoxLayout;
- mainLayout->addWidget(tabWidget);
+ mainLayout->addWidget(tab_widget_);
#ifdef MACOS
setAttribute(Qt::WA_LayoutUsesWidgetRect);
diff --git a/src/ui/keypair_details/KeyDetailsDialog.h b/src/ui/keypair_details/KeyDetailsDialog.h
index 72ae3f57..e6f4472c 100644
--- a/src/ui/keypair_details/KeyDetailsDialog.h
+++ b/src/ui/keypair_details/KeyDetailsDialog.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,26 +8,28 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef __KEYDETAILSDIALOG_H__
#define __KEYDETAILSDIALOG_H__
-#include "gpg/GpgContext.h"
+#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
namespace GpgFrontend::UI {
@@ -37,7 +41,7 @@ class KeyDetailsDialog : public QDialog {
explicit KeyDetailsDialog(const GpgKey& key, QWidget* parent = nullptr);
private:
- QTabWidget* tabWidget{};
+ QTabWidget* tab_widget_{};
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/keypair_details/KeyNewUIDDialog.cpp b/src/ui/keypair_details/KeyNewUIDDialog.cpp
index a4f2bd74..9ff73f9e 100644
--- a/src/ui/keypair_details/KeyNewUIDDialog.cpp
+++ b/src/ui/keypair_details/KeyNewUIDDialog.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -24,68 +26,69 @@
#include "ui/keypair_details/KeyNewUIDDialog.h"
-#include "gpg/function/GpgKeyGetter.h"
-#include "gpg/function/UIDOperator.h"
+#include "core/function/gpg/GpgKeyGetter.h"
+#include "core/function/gpg/GpgUIDOperator.h"
#include "ui/SignalStation.h"
namespace GpgFrontend::UI {
KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent)
- : QDialog(parent), mKey(GpgKeyGetter::GetInstance().GetKey(key_id)) {
- name = new QLineEdit();
- name->setMinimumWidth(240);
- email = new QLineEdit();
- email->setMinimumWidth(240);
- comment = new QLineEdit();
- comment->setMinimumWidth(240);
- createButton = new QPushButton("Create");
- errorLabel = new QLabel();
+ : QDialog(parent), m_key_(GpgKeyGetter::GetInstance().GetKey(key_id)) {
+ name_ = new QLineEdit();
+ name_->setMinimumWidth(240);
+ email_ = new QLineEdit();
+ email_->setMinimumWidth(240);
+ comment_ = new QLineEdit();
+ comment_->setMinimumWidth(240);
+ create_button_ = new QPushButton("Create");
+ error_label_ = new QLabel();
auto gridLayout = new QGridLayout();
gridLayout->addWidget(new QLabel(_("Name")), 0, 0);
gridLayout->addWidget(new QLabel(_("Email")), 1, 0);
gridLayout->addWidget(new QLabel(_("Comment")), 2, 0);
- gridLayout->addWidget(name, 0, 1);
- gridLayout->addWidget(email, 1, 1);
- gridLayout->addWidget(comment, 2, 1);
+ gridLayout->addWidget(name_, 0, 1);
+ gridLayout->addWidget(email_, 1, 1);
+ gridLayout->addWidget(comment_, 2, 1);
- gridLayout->addWidget(createButton, 3, 0, 1, 2);
+ gridLayout->addWidget(create_button_, 3, 0, 1, 2);
gridLayout->addWidget(
new QLabel(_("Notice: The New UID Created will be set as Primary.")), 4,
0, 1, 2);
- gridLayout->addWidget(errorLabel, 5, 0, 1, 2);
+ gridLayout->addWidget(error_label_, 5, 0, 1, 2);
- connect(createButton, SIGNAL(clicked(bool)), this, SLOT(slotCreateNewUID()));
+ connect(create_button_, &QPushButton::clicked, this,
+ &KeyNewUIDDialog::slot_create_new_uid);
this->setLayout(gridLayout);
this->setWindowTitle(_("Create New UID"));
this->setAttribute(Qt::WA_DeleteOnClose, true);
this->setModal(true);
- connect(this, SIGNAL(signalUIDCreated()), SignalStation::GetInstance(),
- SIGNAL(KeyDatabaseRefresh()));
+ connect(this, &KeyNewUIDDialog::SignalUIDCreated, SignalStation::GetInstance(),
+ &SignalStation::SignalKeyDatabaseRefresh);
}
-void KeyNewUIDDialog::slotCreateNewUID() {
+void KeyNewUIDDialog::slot_create_new_uid() {
std::stringstream error_stream;
/**
* check for errors in keygen dialog input
*/
- if ((name->text()).size() < 5) {
+ if ((name_->text()).size() < 5) {
error_stream << " " << _("Name must contain at least five characters.")
<< std::endl;
}
- if (email->text().isEmpty() || !check_email_address(email->text())) {
+ if (email_->text().isEmpty() || !check_email_address(email_->text())) {
error_stream << " " << _("Please give a email address.") << std::endl;
}
auto error_string = error_stream.str();
if (error_string.empty()) {
- if (UIDOperator::GetInstance().AddUID(mKey, name->text().toStdString(),
- comment->text().toStdString(),
- email->text().toStdString())) {
+ if (GpgUIDOperator::GetInstance().AddUID(m_key_, name_->text().toStdString(),
+ comment_->text().toStdString(),
+ email_->text().toStdString())) {
emit finished(1);
- emit signalUIDCreated();
+ emit SignalUIDCreated();
} else
emit finished(-1);
@@ -93,17 +96,17 @@ void KeyNewUIDDialog::slotCreateNewUID() {
/**
* create error message
*/
- errorLabel->setAutoFillBackground(true);
- QPalette error = errorLabel->palette();
+ error_label_->setAutoFillBackground(true);
+ QPalette error = error_label_->palette();
error.setColor(QPalette::Window, "#ff8080");
- errorLabel->setPalette(error);
- errorLabel->setText(error_string.c_str());
+ error_label_->setPalette(error);
+ error_label_->setText(error_string.c_str());
this->show();
}
}
bool KeyNewUIDDialog::check_email_address(const QString& str) {
- return re_email.match(str).hasMatch();
+ return re_email_.match(str).hasMatch();
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/keypair_details/KeyNewUIDDialog.h b/src/ui/keypair_details/KeyNewUIDDialog.h
index 2e38a7f4..24f2c6b1 100644
--- a/src/ui/keypair_details/KeyNewUIDDialog.h
+++ b/src/ui/keypair_details/KeyNewUIDDialog.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -25,7 +27,7 @@
#ifndef GPGFRONTEND_KEYNEWUIDDIALOG_H
#define GPGFRONTEND_KEYNEWUIDDIALOG_H
-#include "gpg/GpgContext.h"
+#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
namespace GpgFrontend::UI {
@@ -33,30 +35,51 @@ class KeyNewUIDDialog : public QDialog {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Key New U I D Dialog object
+ *
+ * @param key
+ * @param parent
+ */
KeyNewUIDDialog(const KeyId& key, QWidget* parent = nullptr);
signals:
- void signalUIDCreated();
+ /**
+ * @brief
+ *
+ */
+ void SignalUIDCreated();
private slots:
- void slotCreateNewUID();
+ /**
+ * @brief
+ *
+ */
+ void slot_create_new_uid();
private:
- GpgKey mKey;
+ GpgKey m_key_; ///<
- QLineEdit* name{};
- QLineEdit* email{};
- QLineEdit* comment{};
+ QLineEdit* name_{}; ///<
+ QLineEdit* email_{}; ///<
+ QLineEdit* comment_{}; ///<
- QPushButton* createButton{};
+ QPushButton* create_button_{}; ///<
- QStringList errorMessages;
- QLabel* errorLabel{};
+ QStringList error_messages_; ///<
+ QLabel* error_label_{}; ///<
- QRegularExpression re_email{
+ QRegularExpression re_email_{
R"((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))"};
+ /**
+ * @brief
+ *
+ * @param str
+ * @return true
+ * @return false
+ */
bool check_email_address(const QString& str);
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/keypair_details/KeyPairDetailTab.cpp b/src/ui/keypair_details/KeyPairDetailTab.cpp
index ed71be0f..6174e67b 100644
--- a/src/ui/keypair_details/KeyPairDetailTab.cpp
+++ b/src/ui/keypair_details/KeyPairDetailTab.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -24,10 +26,10 @@
#include "ui/keypair_details/KeyPairDetailTab.h"
-#include "gpg/function/GpgKeyGetter.h"
-#include "gpg/function/GpgKeyImportExporter.h"
+#include "dialog/WaitingDialog.h"
+#include "core/function/gpg/GpgKeyGetter.h"
+#include "core/function/gpg/GpgKeyImportExporter.h"
#include "ui/SignalStation.h"
-#include "ui/WaitingDialog.h"
namespace GpgFrontend::UI {
KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent)
@@ -35,30 +37,30 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent)
LOG(INFO) << key_.GetEmail() << key_.IsPrivateKey() << key_.IsHasMasterKey()
<< key_.GetSubKeys()->front().IsPrivateKey();
- ownerBox = new QGroupBox(_("Owner"));
- keyBox = new QGroupBox(_("Primary Key"));
- fingerprintBox = new QGroupBox(_("Fingerprint"));
- additionalUidBox = new QGroupBox(_("Additional UIDs"));
+ owner_box_ = new QGroupBox(_("Owner"));
+ key_box_ = new QGroupBox(_("Primary Key"));
+ fingerprint_box_ = new QGroupBox(_("Fingerprint"));
+ additional_uid_box_ = new QGroupBox(_("Additional UIDs"));
- nameVarLabel = new QLabel();
- nameVarLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
- emailVarLabel = new QLabel();
- emailVarLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
+ name_var_label_ = new QLabel();
+ name_var_label_->setTextInteractionFlags(Qt::TextSelectableByMouse);
+ email_var_label_ = new QLabel();
+ email_var_label_->setTextInteractionFlags(Qt::TextSelectableByMouse);
- commentVarLabel = new QLabel();
- commentVarLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
- keyidVarLabel = new QLabel();
- keyidVarLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
+ comment_var_label_ = new QLabel();
+ comment_var_label_->setTextInteractionFlags(Qt::TextSelectableByMouse);
+ key_id_var_label = new QLabel();
+ key_id_var_label->setTextInteractionFlags(Qt::TextSelectableByMouse);
- usageVarLabel = new QLabel();
- actualUsageVarLabel = new QLabel();
+ usage_var_label_ = new QLabel();
+ actual_usage_var_label_ = new QLabel();
- keySizeVarLabel = new QLabel();
- expireVarLabel = new QLabel();
- createdVarLabel = new QLabel();
- lastUpdateVarLabel = new QLabel();
- algorithmVarLabel = new QLabel();
- masterKeyExistVarLabel = new QLabel();
+ key_size_var_label_ = new QLabel();
+ expire_var_label_ = new QLabel();
+ created_var_label_ = new QLabel();
+ last_update_var_label_ = new QLabel();
+ algorithm_var_label_ = new QLabel();
+ primary_key_exist_var_label_ = new QLabel();
auto* mvbox = new QVBoxLayout();
auto* vboxKD = new QGridLayout();
@@ -67,9 +69,9 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent)
vboxOD->addWidget(new QLabel(QString(_("Name")) + ": "), 0, 0);
vboxOD->addWidget(new QLabel(QString(_("Email Address")) + ": "), 1, 0);
vboxOD->addWidget(new QLabel(QString(_("Comment")) + ": "), 2, 0);
- vboxOD->addWidget(nameVarLabel, 0, 1);
- vboxOD->addWidget(emailVarLabel, 1, 1);
- vboxOD->addWidget(commentVarLabel, 2, 1);
+ vboxOD->addWidget(name_var_label_, 0, 1);
+ vboxOD->addWidget(email_var_label_, 1, 1);
+ vboxOD->addWidget(comment_var_label_, 2, 1);
vboxKD->addWidget(new QLabel(QString(_("Key ID")) + ": "), 0, 0);
vboxKD->addWidget(new QLabel(QString(_("Algorithm")) + ": "), 1, 0);
@@ -85,115 +87,116 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent)
vboxKD->addWidget(new QLabel(QString(_("Primary Key Existence")) + ": "), 8,
0);
- keyidVarLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- vboxKD->addWidget(keyidVarLabel, 0, 1, 1, 1);
- vboxKD->addWidget(algorithmVarLabel, 1, 1, 1, 2);
- vboxKD->addWidget(keySizeVarLabel, 2, 1, 1, 2);
- vboxKD->addWidget(usageVarLabel, 3, 1, 1, 2);
- vboxKD->addWidget(actualUsageVarLabel, 4, 1, 1, 2);
- vboxKD->addWidget(createdVarLabel, 5, 1, 1, 2);
- vboxKD->addWidget(expireVarLabel, 6, 1, 1, 2);
- vboxKD->addWidget(lastUpdateVarLabel, 7, 1, 1, 2);
- vboxKD->addWidget(masterKeyExistVarLabel, 8, 1, 1, 2);
+ key_id_var_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ vboxKD->addWidget(key_id_var_label, 0, 1, 1, 1);
+ vboxKD->addWidget(algorithm_var_label_, 1, 1, 1, 2);
+ vboxKD->addWidget(key_size_var_label_, 2, 1, 1, 2);
+ vboxKD->addWidget(usage_var_label_, 3, 1, 1, 2);
+ vboxKD->addWidget(actual_usage_var_label_, 4, 1, 1, 2);
+ vboxKD->addWidget(created_var_label_, 5, 1, 1, 2);
+ vboxKD->addWidget(expire_var_label_, 6, 1, 1, 2);
+ vboxKD->addWidget(last_update_var_label_, 7, 1, 1, 2);
+ vboxKD->addWidget(primary_key_exist_var_label_, 8, 1, 1, 2);
auto* copyKeyIdButton = new QPushButton(_("Copy"));
copyKeyIdButton->setFlat(true);
copyKeyIdButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
vboxKD->addWidget(copyKeyIdButton, 0, 2);
connect(copyKeyIdButton, &QPushButton::clicked, this, [=]() {
- QString fpr = keyidVarLabel->text().trimmed();
+ QString fpr = key_id_var_label->text().trimmed();
QClipboard* cb = QApplication::clipboard();
cb->setText(fpr);
});
- ownerBox->setLayout(vboxOD);
- mvbox->addWidget(ownerBox);
- keyBox->setLayout(vboxKD);
- mvbox->addWidget(keyBox);
+ owner_box_->setLayout(vboxOD);
+ mvbox->addWidget(owner_box_);
+ key_box_->setLayout(vboxKD);
+ mvbox->addWidget(key_box_);
- fingerPrintVarLabel = new QLabel();
- fingerPrintVarLabel->setWordWrap(false);
- fingerPrintVarLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
- fingerPrintVarLabel->setStyleSheet("margin-left: 0; margin-right: 5;");
- fingerPrintVarLabel->setAlignment(Qt::AlignCenter);
+ fingerprint_var_label_ = new QLabel();
+ fingerprint_var_label_->setWordWrap(false);
+ fingerprint_var_label_->setTextInteractionFlags(Qt::TextSelectableByMouse);
+ fingerprint_var_label_->setStyleSheet("margin-left: 0; margin-right: 5;");
+ fingerprint_var_label_->setAlignment(Qt::AlignCenter);
auto* hboxFP = new QHBoxLayout();
hboxFP->addStretch();
- hboxFP->addWidget(fingerPrintVarLabel);
+ hboxFP->addWidget(fingerprint_var_label_);
auto* copyFingerprintButton = new QPushButton(_("Copy"));
copyFingerprintButton->setFlat(true);
copyFingerprintButton->setToolTip(_("copy fingerprint to clipboard"));
- connect(copyFingerprintButton, SIGNAL(clicked()), this,
- SLOT(slotCopyFingerprint()));
+ connect(copyFingerprintButton, &QPushButton::clicked, this,
+ &KeyPairDetailTab::slot_copy_fingerprint);
hboxFP->addWidget(copyFingerprintButton);
hboxFP->addStretch();
- fingerprintBox->setLayout(hboxFP);
- mvbox->addWidget(fingerprintBox);
+ fingerprint_box_->setLayout(hboxFP);
+ mvbox->addWidget(fingerprint_box_);
mvbox->addStretch();
auto* expBox = new QHBoxLayout();
QPixmap pixmap(":warning.png");
- expLabel = new QLabel();
- iconLabel = new QLabel();
+ exp_label_ = new QLabel();
+ icon_label_ = new QLabel();
- iconLabel->setPixmap(pixmap.scaled(24, 24, Qt::KeepAspectRatio));
- expLabel->setAlignment(Qt::AlignCenter);
+ icon_label_->setPixmap(pixmap.scaled(24, 24, Qt::KeepAspectRatio));
+ exp_label_->setAlignment(Qt::AlignCenter);
expBox->addStretch();
- expBox->addWidget(iconLabel);
- expBox->addWidget(expLabel);
+ expBox->addWidget(icon_label_);
+ expBox->addWidget(exp_label_);
expBox->addStretch();
mvbox->addLayout(expBox);
mvbox->setContentsMargins(0, 0, 0, 0);
// when key database updated
- connect(SignalStation::GetInstance(), SIGNAL(KeyDatabaseRefresh()), this,
- SLOT(slotRefreshKey()));
+ connect(SignalStation::GetInstance(), &SignalStation::SignalKeyDatabaseRefresh, this,
+ &KeyPairDetailTab::slot_refresh_key);
- slotRefreshKeyInfo();
+ slot_refresh_key_info();
setAttribute(Qt::WA_DeleteOnClose, true);
setLayout(mvbox);
}
-void KeyPairDetailTab::slotCopyFingerprint() {
- QString fpr = fingerPrintVarLabel->text().trimmed().replace(" ", QString());
+void KeyPairDetailTab::slot_copy_fingerprint() {
+ QString fpr =
+ fingerprint_var_label_->text().trimmed().replace(" ", QString());
QClipboard* cb = QApplication::clipboard();
cb->setText(fpr);
}
-void KeyPairDetailTab::slotRefreshKeyInfo() {
+void KeyPairDetailTab::slot_refresh_key_info() {
// Show the situation that primary key not exists.
- masterKeyExistVarLabel->setText(key_.IsHasMasterKey() ? _("Exists")
+ primary_key_exist_var_label_->setText(key_.IsHasMasterKey() ? _("Exists")
: _("Not Exists"));
if (!key_.IsHasMasterKey()) {
- auto palette_expired = masterKeyExistVarLabel->palette();
- palette_expired.setColor(masterKeyExistVarLabel->foregroundRole(), Qt::red);
- masterKeyExistVarLabel->setPalette(palette_expired);
+ auto palette_expired = primary_key_exist_var_label_->palette();
+ palette_expired.setColor(primary_key_exist_var_label_->foregroundRole(), Qt::red);
+ primary_key_exist_var_label_->setPalette(palette_expired);
} else {
- auto palette_valid = masterKeyExistVarLabel->palette();
- palette_valid.setColor(masterKeyExistVarLabel->foregroundRole(),
+ auto palette_valid = primary_key_exist_var_label_->palette();
+ palette_valid.setColor(primary_key_exist_var_label_->foregroundRole(),
Qt::darkGreen);
- masterKeyExistVarLabel->setPalette(palette_valid);
+ primary_key_exist_var_label_->setPalette(palette_valid);
}
if (key_.IsExpired()) {
- auto paletteExpired = expireVarLabel->palette();
- paletteExpired.setColor(expireVarLabel->foregroundRole(), Qt::red);
- expireVarLabel->setPalette(paletteExpired);
+ auto paletteExpired = expire_var_label_->palette();
+ paletteExpired.setColor(expire_var_label_->foregroundRole(), Qt::red);
+ expire_var_label_->setPalette(paletteExpired);
} else {
- auto paletteValid = expireVarLabel->palette();
- paletteValid.setColor(expireVarLabel->foregroundRole(), Qt::darkGreen);
- expireVarLabel->setPalette(paletteValid);
+ auto paletteValid = expire_var_label_->palette();
+ paletteValid.setColor(expire_var_label_->foregroundRole(), Qt::darkGreen);
+ expire_var_label_->setPalette(paletteValid);
}
- nameVarLabel->setText(QString::fromStdString(key_.GetName()));
- emailVarLabel->setText(QString::fromStdString(key_.GetEmail()));
+ name_var_label_->setText(QString::fromStdString(key_.GetName()));
+ email_var_label_->setText(QString::fromStdString(key_.GetEmail()));
- commentVarLabel->setText(QString::fromStdString(key_.GetComment()));
- keyidVarLabel->setText(QString::fromStdString(key_.GetId()));
+ comment_var_label_->setText(QString::fromStdString(key_.GetComment()));
+ key_id_var_label->setText(QString::fromStdString(key_.GetId()));
std::stringstream usage_steam;
@@ -203,7 +206,7 @@ void KeyPairDetailTab::slotRefreshKeyInfo() {
if (key_.IsHasSigningCapability()) usage_steam << _("Sign") << " ";
if (key_.IsHasAuthenticationCapability()) usage_steam << _("Auth") << " ";
- usageVarLabel->setText(usage_steam.str().c_str());
+ usage_var_label_->setText(usage_steam.str().c_str());
std::stringstream actual_usage_steam;
@@ -216,7 +219,7 @@ void KeyPairDetailTab::slotRefreshKeyInfo() {
if (key_.IsHasActualAuthenticationCapability())
actual_usage_steam << _("Auth") << " ";
- actualUsageVarLabel->setText(actual_usage_steam.str().c_str());
+ actual_usage_var_label_->setText(actual_usage_steam.str().c_str());
std::string key_size_val, key_expire_val, key_create_time_val, key_algo_val,
key_last_update_val;
@@ -224,48 +227,48 @@ void KeyPairDetailTab::slotRefreshKeyInfo() {
key_size_val = std::to_string(key_.GetPrimaryKeyLength());
if (to_time_t(boost::posix_time::ptime(key_.GetExpireTime())) == 0) {
- expireVarLabel->setText(_("Never Expire"));
+ expire_var_label_->setText(_("Never Expire"));
} else {
- expireVarLabel->setText(QLocale::system().toString(
+ expire_var_label_->setText(QLocale::system().toString(
QDateTime::fromTime_t(to_time_t(key_.GetExpireTime()))));
}
key_algo_val = key_.GetPublicKeyAlgo();
- createdVarLabel->setText(QLocale::system().toString(
+ created_var_label_->setText(QLocale::system().toString(
QDateTime::fromTime_t(to_time_t(key_.GetCreateTime()))));
if (to_time_t(boost::posix_time::ptime(key_.GetLastUpdateTime())) == 0) {
- lastUpdateVarLabel->setText(_("No Data"));
+ last_update_var_label_->setText(_("No Data"));
} else {
- lastUpdateVarLabel->setText(QLocale::system().toString(
+ last_update_var_label_->setText(QLocale::system().toString(
QDateTime::fromTime_t(to_time_t(key_.GetLastUpdateTime()))));
}
- keySizeVarLabel->setText(key_size_val.c_str());
- algorithmVarLabel->setText(key_algo_val.c_str());
- fingerPrintVarLabel->setText(
+ key_size_var_label_->setText(key_size_val.c_str());
+ algorithm_var_label_->setText(key_algo_val.c_str());
+ fingerprint_var_label_->setText(
beautify_fingerprint(key_.GetFingerprint()).c_str());
- iconLabel->hide();
- expLabel->hide();
+ icon_label_->hide();
+ exp_label_->hide();
if (key_.IsExpired()) {
- iconLabel->show();
- expLabel->show();
- expLabel->setText(_("Warning: The primary key has expired."));
+ icon_label_->show();
+ exp_label_->show();
+ exp_label_->setText(_("Warning: The primary key has expired."));
}
if (key_.IsRevoked()) {
- iconLabel->show();
- expLabel->show();
- expLabel->setText(_("Warning: The primary key has been revoked."));
+ icon_label_->show();
+ exp_label_->show();
+ exp_label_->setText(_("Warning: The primary key has been revoked."));
}
}
-void KeyPairDetailTab::slotRefreshKey() {
+void KeyPairDetailTab::slot_refresh_key() {
LOG(INFO) << _("Called");
this->key_ = GpgKeyGetter::GetInstance().GetKey(key_.GetId());
- this->slotRefreshKeyInfo();
+ this->slot_refresh_key_info();
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/keypair_details/KeyPairDetailTab.h b/src/ui/keypair_details/KeyPairDetailTab.h
index 151d8fc7..9d0d6560 100644
--- a/src/ui/keypair_details/KeyPairDetailTab.h
+++ b/src/ui/keypair_details/KeyPairDetailTab.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -26,10 +28,10 @@
#define GPGFRONTEND_KEYPAIRDETAILTAB_H
#include "KeySetExpireDateDialog.h"
-#include "gpg/GpgContext.h"
+#include "core/GpgContext.h"
+#include "import_export/KeyServerImportDialog.h"
+#include "import_export/KeyUploadDialog.h"
#include "ui/GpgFrontendUI.h"
-#include "ui/KeyServerImportDialog.h"
-#include "ui/KeyUploadDialog.h"
namespace GpgFrontend::UI {
@@ -41,42 +43,53 @@ class KeyPairDetailTab : public QWidget {
/**
* @details Copy the fingerprint to clipboard
*/
- void slotCopyFingerprint();
+ void slot_copy_fingerprint();
- void slotRefreshKeyInfo();
+ /**
+ * @brief
+ *
+ */
+ void slot_refresh_key_info();
- void slotRefreshKey();
+ /**
+ * @brief
+ *
+ */
+ void slot_refresh_key();
private:
- GpgKey key_;
-
- QGroupBox* ownerBox; /** Groupbox containing owner information */
- QGroupBox* keyBox; /** Groupbox containing key information */
- QGroupBox* fingerprintBox; /** Groupbox containing fingerprint information */
- QGroupBox* additionalUidBox; /** Groupbox containing information about
- additional uids */
-
- QLabel* nameVarLabel; /** Label containng the keys name */
- QLabel* emailVarLabel; /** Label containng the keys email */
- QLabel* commentVarLabel; /** Label containng the keys commment */
- QLabel* keySizeVarLabel; /** Label containng the keys keysize */
- QLabel* expireVarLabel; /** Label containng the keys expiration date */
- QLabel* createdVarLabel; /** Label containng the keys creation date */
- QLabel* lastUpdateVarLabel;
- QLabel* algorithmVarLabel; /** Label containng the keys algorithm */
- QLabel* keyidVarLabel; /** Label containng the keys keyid */
- QLabel* fingerPrintVarLabel; /** Label containng the keys fingerprint */
- QLabel* usageVarLabel;
- QLabel* actualUsageVarLabel;
- QLabel* masterKeyExistVarLabel;
-
- QLabel* iconLabel;
- QLabel* expLabel;
-
- QMenu* keyServerOperaMenu{};
- QMenu* secretKeyExportOperaMenu{};
+ GpgKey key_; ///<
+
+ QGroupBox* owner_box_; ///< Groupbox containing owner information
+ QGroupBox* key_box_; ///< Groupbox containing key information
+ QGroupBox* fingerprint_box_; ///< Groupbox containing fingerprint information
+ QGroupBox* additional_uid_box_; ///< Groupbox containing information about
+ ///< additional uids
+
+ QLabel* name_var_label_; ///< Label containing the keys name
+ QLabel* email_var_label_; ///< Label containing the keys email
+ QLabel* comment_var_label_; ///< Label containing the keys comment
+ QLabel* key_size_var_label_; ///< Label containing the keys key size
+ QLabel* expire_var_label_; ///< Label containing the keys expiration date
+ QLabel* created_var_label_; ///< Label containing the keys creation date
+ QLabel* last_update_var_label_; ///<
+ QLabel* algorithm_var_label_; ///< Label containing the keys algorithm
+ QLabel* key_id_var_label; ///< Label containing the keys keyid
+ QLabel* fingerprint_var_label_; ///< Label containing the keys fingerprint
+ QLabel* usage_var_label_;
+ QLabel* actual_usage_var_label_;
+ QLabel* primary_key_exist_var_label_;
+
+ QLabel* icon_label_; ///<
+ QLabel* exp_label_; ///<
public:
+ /**
+ * @brief Construct a new Key Pair Detail Tab object
+ *
+ * @param key_id
+ * @param parent
+ */
explicit KeyPairDetailTab(const std::string& key_id,
QWidget* parent = nullptr);
};
diff --git a/src/ui/keypair_details/KeyPairOperaTab.cpp b/src/ui/keypair_details/KeyPairOperaTab.cpp
index d5fdec0e..988ce527 100644
--- a/src/ui/keypair_details/KeyPairOperaTab.cpp
+++ b/src/ui/keypair_details/KeyPairOperaTab.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -24,9 +26,9 @@
#include "KeyPairOperaTab.h"
-#include "gpg/function/GpgKeyImportExporter.h"
-#include "gpg/function/GpgKeyOpera.h"
-#include "ui/KeyUploadDialog.h"
+#include "core/function/gpg/GpgKeyImportExporter.h"
+#include "core/function/gpg/GpgKeyOpera.h"
+#include "import_export/KeyUploadDialog.h"
#include "ui/SignalStation.h"
#include "ui/UserInterfaceUtils.h"
#include "ui/keypair_details/KeySetExpireDateDialog.h"
@@ -36,7 +38,7 @@ namespace GpgFrontend::UI {
KeyPairOperaTab::KeyPairOperaTab(const std::string& key_id, QWidget* parent)
: QWidget(parent), m_key_(GpgKeyGetter::GetInstance().GetKey(key_id)) {
// Set Menu
- createOperaMenu();
+ CreateOperaMenu();
auto m_vbox = new QVBoxLayout(this);
auto* opera_key_box = new QGroupBox(_("General Operations"));
@@ -47,23 +49,23 @@ KeyPairOperaTab::KeyPairOperaTab(const std::string& key_id, QWidget* parent)
auto* export_public_button = new QPushButton(_("Export Public Key"));
export_h_box_layout->addWidget(export_public_button);
- connect(export_public_button, SIGNAL(clicked()), this,
- SLOT(slotExportPublicKey()));
+ connect(export_public_button, &QPushButton::clicked, this,
+ &KeyPairOperaTab::slot_export_public_key);
if (m_key_.IsPrivateKey()) {
auto* export_private_button = new QPushButton(_("Export Private Key"));
export_private_button->setStyleSheet("text-align:center;");
- export_private_button->setMenu(secretKeyExportOperaMenu);
+ export_private_button->setMenu(secret_key_export_opera_menu_);
export_h_box_layout->addWidget(export_private_button);
if (m_key_.IsHasMasterKey()) {
auto* edit_expires_button =
new QPushButton(_("Modify Expiration Datetime (Primary Key)"));
- connect(edit_expires_button, SIGNAL(clicked()), this,
- SLOT(slotModifyEditDatetime()));
+ connect(edit_expires_button, &QPushButton::clicked, this,
+ &KeyPairOperaTab::slot_modify_edit_datetime);
auto* edit_password_button = new QPushButton(_("Modify Password"));
- connect(edit_password_button, SIGNAL(clicked()), this,
- SLOT(slotModifyPassword()));
+ connect(edit_password_button, &QPushButton::clicked, this,
+ &KeyPairOperaTab::slot_modify_password);
vbox_p_k->addWidget(edit_expires_button);
vbox_p_k->addWidget(edit_password_button);
@@ -74,20 +76,20 @@ KeyPairOperaTab::KeyPairOperaTab(const std::string& key_id, QWidget* parent)
auto* key_server_opera_button =
new QPushButton(_("Key Server Operation (Pubkey)"));
key_server_opera_button->setStyleSheet("text-align:center;");
- key_server_opera_button->setMenu(keyServerOperaMenu);
+ key_server_opera_button->setMenu(key_server_opera_menu_);
advance_h_box_layout->addWidget(key_server_opera_button);
if (m_key_.IsPrivateKey() && m_key_.IsHasMasterKey()) {
auto* revoke_cert_gen_button =
new QPushButton(_("Generate Revoke Certificate"));
- connect(revoke_cert_gen_button, SIGNAL(clicked()), this,
- SLOT(slotGenRevokeCert()));
+ connect(revoke_cert_gen_button, &QPushButton::clicked, this,
+ &KeyPairOperaTab::slot_gen_revoke_cert);
advance_h_box_layout->addWidget(revoke_cert_gen_button);
}
auto* modify_tofu_button = new QPushButton(_("Modify TOFU Policy"));
- connect(modify_tofu_button, SIGNAL(clicked()), this,
- SLOT(slotModifyTOFUPolicy()));
+ connect(modify_tofu_button, &QPushButton::clicked, this,
+ &KeyPairOperaTab::slot_modify_tofu_policy);
vbox_p_k->addLayout(advance_h_box_layout);
opera_key_box->setLayout(vbox_p_k);
@@ -98,44 +100,44 @@ KeyPairOperaTab::KeyPairOperaTab(const std::string& key_id, QWidget* parent)
setLayout(m_vbox);
}
-void KeyPairOperaTab::createOperaMenu() {
- keyServerOperaMenu = new QMenu(this);
+void KeyPairOperaTab::CreateOperaMenu() {
+ key_server_opera_menu_ = new QMenu(this);
auto* uploadKeyPair = new QAction(_("Upload Key Pair to Key Server"), this);
- connect(uploadKeyPair, SIGNAL(triggered()), this,
- SLOT(slotUploadKeyToServer()));
+ connect(uploadKeyPair, &QAction::triggered, this,
+ &KeyPairOperaTab::slot_upload_key_to_server);
if (!(m_key_.IsPrivateKey() && m_key_.IsHasMasterKey()))
uploadKeyPair->setDisabled(true);
auto* updateKeyPair = new QAction(_("Sync Key Pair From Key Server"), this);
- connect(updateKeyPair, SIGNAL(triggered()), this,
- SLOT(slotUpdateKeyFromServer()));
+ connect(updateKeyPair, &QAction::triggered, this,
+ &KeyPairOperaTab::slot_update_key_from_server);
// when a key has primary key, it should always upload to keyserver.
if (m_key_.IsHasMasterKey()) {
updateKeyPair->setDisabled(true);
}
- keyServerOperaMenu->addAction(uploadKeyPair);
- keyServerOperaMenu->addAction(updateKeyPair);
+ key_server_opera_menu_->addAction(uploadKeyPair);
+ key_server_opera_menu_->addAction(updateKeyPair);
- secretKeyExportOperaMenu = new QMenu(this);
+ secret_key_export_opera_menu_ = new QMenu(this);
auto* exportFullSecretKey = new QAction(_("Export Full Secret Key"), this);
- connect(exportFullSecretKey, SIGNAL(triggered()), this,
- SLOT(slotExportPrivateKey()));
+ connect(exportFullSecretKey, &QAction::triggered, this,
+ &KeyPairOperaTab::slot_export_private_key);
if (!m_key_.IsPrivateKey()) exportFullSecretKey->setDisabled(true);
auto* exportShortestSecretKey =
new QAction(_("Export Shortest Secret Key"), this);
- connect(exportShortestSecretKey, SIGNAL(triggered()), this,
- SLOT(slotExportShortPrivateKey()));
+ connect(exportShortestSecretKey, &QAction::triggered, this,
+ &KeyPairOperaTab::slot_export_short_private_key);
- secretKeyExportOperaMenu->addAction(exportFullSecretKey);
- secretKeyExportOperaMenu->addAction(exportShortestSecretKey);
+ secret_key_export_opera_menu_->addAction(exportFullSecretKey);
+ secret_key_export_opera_menu_->addAction(exportShortestSecretKey);
}
-void KeyPairOperaTab::slotExportPublicKey() {
+void KeyPairOperaTab::slot_export_public_key() {
ByteArrayPtr keyArray = nullptr;
if (!GpgKeyImportExporter::GetInstance().ExportKey(m_key_, keyArray)) {
@@ -161,7 +163,7 @@ void KeyPairOperaTab::slotExportPublicKey() {
}
}
-void KeyPairOperaTab::slotExportShortPrivateKey() {
+void KeyPairOperaTab::slot_export_short_private_key() {
// Show a information box with explanation about private key
int ret = QMessageBox::information(
this, _("Exporting short private Key"),
@@ -205,7 +207,7 @@ void KeyPairOperaTab::slotExportShortPrivateKey() {
}
}
-void KeyPairOperaTab::slotExportPrivateKey() {
+void KeyPairOperaTab::slot_export_private_key() {
// Show a information box with explanation about private key
int ret = QMessageBox::information(
this, _("Exporting private Key"),
@@ -245,28 +247,28 @@ void KeyPairOperaTab::slotExportPrivateKey() {
}
}
-void KeyPairOperaTab::slotModifyEditDatetime() {
+void KeyPairOperaTab::slot_modify_edit_datetime() {
auto dialog = new KeySetExpireDateDialog(m_key_.GetId(), this);
dialog->show();
}
-void KeyPairOperaTab::slotUploadKeyToServer() {
+void KeyPairOperaTab::slot_upload_key_to_server() {
auto keys = std::make_unique<KeyIdArgsList>();
keys->push_back(m_key_.GetId());
auto* dialog = new KeyUploadDialog(keys, this);
dialog->show();
- dialog->slotUpload();
+ dialog->SlotUpload();
}
-void KeyPairOperaTab::slotUpdateKeyFromServer() {
+void KeyPairOperaTab::slot_update_key_from_server() {
auto keys = std::make_unique<KeyIdArgsList>();
keys->push_back(m_key_.GetId());
auto* dialog = new KeyServerImportDialog(this);
dialog->show();
- dialog->slotImport(keys);
+ dialog->SlotImport(keys);
}
-void KeyPairOperaTab::slotGenRevokeCert() {
+void KeyPairOperaTab::slot_gen_revoke_cert() {
auto literal = QString("%1 (*.rev)").arg(_("Revocation Certificates"));
QString m_output_file_name;
@@ -278,7 +280,7 @@ void KeyPairOperaTab::slotGenRevokeCert() {
if (dialog.exec()) m_output_file_name = dialog.selectedFiles().front();
if (!m_output_file_name.isEmpty())
- CommonUtils::GetInstance()->slotExecuteGpgCommand(
+ CommonUtils::GetInstance()->SlotExecuteGpgCommand(
{"--command-fd", "0", "--status-fd", "1", "--no-tty", "-o",
m_output_file_name, "--gen-revoke", m_key_.GetFingerprint().c_str()},
[](QProcess* proc) -> void {
@@ -307,7 +309,7 @@ void KeyPairOperaTab::slotGenRevokeCert() {
});
}
-void KeyPairOperaTab::slotModifyPassword() {
+void KeyPairOperaTab::slot_modify_password() {
auto err = GpgKeyOpera::GetInstance().ModifyPassword(m_key_);
if (check_gpg_error_2_err_code(err) != GPG_ERR_NO_ERROR) {
QMessageBox::critical(this, _("Not Successful"),
@@ -315,7 +317,7 @@ void KeyPairOperaTab::slotModifyPassword() {
}
}
-void KeyPairOperaTab::slotModifyTOFUPolicy() {
+void KeyPairOperaTab::slot_modify_tofu_policy() {
QStringList items;
items << _("Policy Auto") << _("Policy Good") << _("Policy Bad")
<< _("Policy Ask") << _("Policy Unknown");
diff --git a/src/ui/keypair_details/KeyPairOperaTab.h b/src/ui/keypair_details/KeyPairOperaTab.h
index f8a5ded9..af6b1eee 100644
--- a/src/ui/keypair_details/KeyPairOperaTab.h
+++ b/src/ui/keypair_details/KeyPairOperaTab.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -25,44 +27,86 @@
#ifndef GPGFRONTEND_KEYPAIROPERATAB_H
#define GPGFRONTEND_KEYPAIROPERATAB_H
-#include "gpg/function/GpgKeyGetter.h"
+#include "core/function/gpg/GpgKeyGetter.h"
#include "ui/GpgFrontendUI.h"
namespace GpgFrontend::UI {
class KeyPairOperaTab : public QWidget {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Key Pair Opera Tab object
+ *
+ * @param key_id
+ * @param parent
+ */
KeyPairOperaTab(const std::string& key_id, QWidget* parent);
- void createOperaMenu();
+ /**
+ * @brief Create a Opera Menu object
+ *
+ */
+ void CreateOperaMenu();
private slots:
/**
* @details Export the key to a file, which is chosen in a file dialog
*/
- void slotExportPrivateKey();
+ void slot_export_private_key();
- void slotExportShortPrivateKey();
+ /**
+ * @brief
+ *
+ */
+ void slot_export_short_private_key();
- void slotExportPublicKey();
+ /**
+ * @brief
+ *
+ */
+ void slot_export_public_key();
- void slotModifyEditDatetime();
+ /**
+ * @brief
+ *
+ */
+ void slot_modify_edit_datetime();
- void slotModifyPassword();
+ /**
+ * @brief
+ *
+ */
+ void slot_modify_password();
- void slotUploadKeyToServer();
+ /**
+ * @brief
+ *
+ */
+ void slot_upload_key_to_server();
- void slotUpdateKeyFromServer();
+ /**
+ * @brief
+ *
+ */
+ void slot_update_key_from_server();
- void slotGenRevokeCert();
+ /**
+ * @brief
+ *
+ */
+ void slot_gen_revoke_cert();
- void slotModifyTOFUPolicy();
+ /**
+ * @brief
+ *
+ */
+ void slot_modify_tofu_policy();
private:
- GpgKey m_key_;
- QMenu* keyServerOperaMenu{};
- QMenu* secretKeyExportOperaMenu{};
+ GpgKey m_key_; ///<
+ QMenu* key_server_opera_menu_{}; ///<
+ QMenu* secret_key_export_opera_menu_{}; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/keypair_details/KeyPairSubkeyTab.cpp b/src/ui/keypair_details/KeyPairSubkeyTab.cpp
index 4cbe9b1a..067ce110 100644
--- a/src/ui/keypair_details/KeyPairSubkeyTab.cpp
+++ b/src/ui/keypair_details/KeyPairSubkeyTab.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,25 +8,27 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include "ui/keypair_details/KeyPairSubkeyTab.h"
-#include "gpg/function/GpgKeyGetter.h"
+#include "core/function/gpg/GpgKeyGetter.h"
#include "ui/SignalStation.h"
namespace GpgFrontend::UI {
@@ -34,11 +38,11 @@ KeyPairSubkeyTab::KeyPairSubkeyTab(const std::string& key_id, QWidget* parent)
LOG(INFO) << key_.GetEmail() << key_.IsPrivateKey() << key_.IsHasMasterKey()
<< key_.GetSubKeys()->front().IsPrivateKey();
- createSubkeyList();
- createSubkeyOperaMenu();
+ create_subkey_list();
+ create_subkey_opera_menu();
- listBox = new QGroupBox(_("Subkey List"));
- detailBox = new QGroupBox(_("Detail of Selected Subkey"));
+ list_box_ = new QGroupBox(_("Subkey List"));
+ detail_box_ = new QGroupBox(_("Detail of Selected Subkey"));
auto uidButtonsLayout = new QGridLayout();
@@ -53,7 +57,7 @@ KeyPairSubkeyTab::KeyPairSubkeyTab(const std::string& key_id, QWidget* parent)
auto* baseLayout = new QVBoxLayout();
auto subkeyListLayout = new QGridLayout();
- subkeyListLayout->addWidget(subkeyList, 0, 0);
+ subkeyListLayout->addWidget(subkey_list_, 0, 0);
subkeyListLayout->addLayout(uidButtonsLayout, 1, 0);
subkeyListLayout->setContentsMargins(0, 10, 0, 0);
@@ -76,120 +80,123 @@ KeyPairSubkeyTab::KeyPairSubkeyTab(const std::string& key_id, QWidget* parent)
subkeyDetailLayout->addWidget(new QLabel(QString(_("Fingerprint")) + ": "), 8,
0);
- keyidVarLabel = new QLabel(this);
- keySizeVarLabel = new QLabel(this);
- expireVarLabel = new QLabel(this);
- algorithmVarLabel = new QLabel(this);
- createdVarLabel = new QLabel(this);
- usageVarLabel = new QLabel(this);
- masterKeyExistVarLabel = new QLabel(this);
- fingerPrintVarLabel = new QLabel(this);
- cardKeyLabel = new QLabel(this);
-
- subkeyDetailLayout->addWidget(keyidVarLabel, 0, 1, 1, 1);
- subkeyDetailLayout->addWidget(keySizeVarLabel, 2, 1, 1, 2);
- subkeyDetailLayout->addWidget(expireVarLabel, 4, 1, 1, 2);
- subkeyDetailLayout->addWidget(algorithmVarLabel, 1, 1, 1, 2);
- subkeyDetailLayout->addWidget(createdVarLabel, 5, 1, 1, 2);
- subkeyDetailLayout->addWidget(usageVarLabel, 3, 1, 1, 2);
- subkeyDetailLayout->addWidget(masterKeyExistVarLabel, 6, 1, 1, 2);
- subkeyDetailLayout->addWidget(cardKeyLabel, 7, 1, 1, 2);
- subkeyDetailLayout->addWidget(fingerPrintVarLabel, 8, 1, 1, 2);
+ key_id_var_label_ = new QLabel(this);
+ key_size_var_label_ = new QLabel(this);
+ expire_var_label_ = new QLabel(this);
+ algorithm_var_label_ = new QLabel(this);
+ created_var_label_ = new QLabel(this);
+ usage_var_label_ = new QLabel(this);
+ master_key_exist_var_label_ = new QLabel(this);
+ fingerprint_var_label_ = new QLabel(this);
+ card_key_label_ = new QLabel(this);
+
+ subkeyDetailLayout->addWidget(key_id_var_label_, 0, 1, 1, 1);
+ subkeyDetailLayout->addWidget(key_size_var_label_, 2, 1, 1, 2);
+ subkeyDetailLayout->addWidget(expire_var_label_, 4, 1, 1, 2);
+ subkeyDetailLayout->addWidget(algorithm_var_label_, 1, 1, 1, 2);
+ subkeyDetailLayout->addWidget(created_var_label_, 5, 1, 1, 2);
+ subkeyDetailLayout->addWidget(usage_var_label_, 3, 1, 1, 2);
+ subkeyDetailLayout->addWidget(master_key_exist_var_label_, 6, 1, 1, 2);
+ subkeyDetailLayout->addWidget(card_key_label_, 7, 1, 1, 2);
+ subkeyDetailLayout->addWidget(fingerprint_var_label_, 8, 1, 1, 2);
auto* copyKeyIdButton = new QPushButton(_("Copy"));
copyKeyIdButton->setFlat(true);
subkeyDetailLayout->addWidget(copyKeyIdButton, 0, 2);
connect(copyKeyIdButton, &QPushButton::clicked, this, [=]() {
- QString fpr = keyidVarLabel->text().trimmed();
+ QString fpr = key_id_var_label_->text().trimmed();
QClipboard* cb = QApplication::clipboard();
cb->setText(fpr);
});
- listBox->setLayout(subkeyListLayout);
- listBox->setContentsMargins(0, 12, 0, 0);
- detailBox->setLayout(subkeyDetailLayout);
+ list_box_->setLayout(subkeyListLayout);
+ list_box_->setContentsMargins(0, 12, 0, 0);
+ detail_box_->setLayout(subkeyDetailLayout);
- baseLayout->addWidget(listBox);
- baseLayout->addWidget(detailBox);
+ baseLayout->addWidget(list_box_);
+ baseLayout->addWidget(detail_box_);
baseLayout->addStretch();
- connect(addSubkeyButton, SIGNAL(clicked(bool)), this, SLOT(slotAddSubkey()));
- connect(subkeyList, SIGNAL(itemSelectionChanged()), this,
- SLOT(slotRefreshSubkeyDetail()));
+ connect(addSubkeyButton, &QPushButton::clicked, this,
+ &KeyPairSubkeyTab::slot_add_subkey);
+ connect(subkey_list_, &QTableWidget::itemSelectionChanged, this,
+ &KeyPairSubkeyTab::slot_refresh_subkey_detail);
// key database refresh signal
- connect(SignalStation::GetInstance(), SIGNAL(KeyDatabaseRefresh()), this,
- SLOT(slotRefreshKeyInfo()));
- connect(SignalStation::GetInstance(), SIGNAL(KeyDatabaseRefresh()), this,
- SLOT(slotRefreshSubkeyList()));
+ connect(SignalStation::GetInstance(),
+ &SignalStation::SignalKeyDatabaseRefresh, this,
+ &KeyPairSubkeyTab::slot_refresh_key_info);
+ connect(SignalStation::GetInstance(),
+ &SignalStation::SignalKeyDatabaseRefresh, this,
+ &KeyPairSubkeyTab::slot_refresh_subkey_list);
baseLayout->setContentsMargins(0, 0, 0, 0);
setLayout(baseLayout);
setAttribute(Qt::WA_DeleteOnClose, true);
- slotRefreshSubkeyList();
+ slot_refresh_subkey_list();
}
-void KeyPairSubkeyTab::createSubkeyList() {
- subkeyList = new QTableWidget(this);
+void KeyPairSubkeyTab::create_subkey_list() {
+ subkey_list_ = new QTableWidget(this);
- subkeyList->setColumnCount(5);
- subkeyList->horizontalHeader()->setSectionResizeMode(
+ subkey_list_->setColumnCount(5);
+ subkey_list_->horizontalHeader()->setSectionResizeMode(
QHeaderView::ResizeToContents);
- subkeyList->verticalHeader()->hide();
- subkeyList->setShowGrid(false);
- subkeyList->setSelectionBehavior(QAbstractItemView::SelectRows);
+ subkey_list_->verticalHeader()->hide();
+ subkey_list_->setShowGrid(false);
+ subkey_list_->setSelectionBehavior(QAbstractItemView::SelectRows);
// tableitems not editable
- subkeyList->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ subkey_list_->setEditTriggers(QAbstractItemView::NoEditTriggers);
// no focus (rectangle around tableitems)
// may be it should focus on whole row
- subkeyList->setFocusPolicy(Qt::NoFocus);
- subkeyList->setAlternatingRowColors(true);
+ subkey_list_->setFocusPolicy(Qt::NoFocus);
+ subkey_list_->setAlternatingRowColors(true);
QStringList labels;
labels << _("Subkey ID") << _("Key Size") << _("Algo")
<< _("Create Date (UTC)") << _("Expire Date (UTC)");
- subkeyList->setHorizontalHeaderLabels(labels);
- subkeyList->horizontalHeader()->setStretchLastSection(false);
+ subkey_list_->setHorizontalHeaderLabels(labels);
+ subkey_list_->horizontalHeader()->setStretchLastSection(false);
}
-void KeyPairSubkeyTab::slotRefreshSubkeyList() {
+void KeyPairSubkeyTab::slot_refresh_subkey_list() {
LOG(INFO) << "Called";
int row = 0;
- subkeyList->setSelectionMode(QAbstractItemView::SingleSelection);
+ subkey_list_->setSelectionMode(QAbstractItemView::SingleSelection);
- this->buffered_subkeys.clear();
+ this->buffered_subkeys_.clear();
auto sub_keys = key_.GetSubKeys();
for (auto& sub_key : *sub_keys) {
if (sub_key.IsDisabled() || sub_key.IsRevoked()) continue;
- this->buffered_subkeys.push_back(std::move(sub_key));
+ this->buffered_subkeys_.push_back(std::move(sub_key));
}
- subkeyList->setRowCount(buffered_subkeys.size());
+ subkey_list_->setRowCount(buffered_subkeys_.size());
- for (const auto& subkeys : buffered_subkeys) {
+ for (const auto& subkeys : buffered_subkeys_) {
auto* tmp0 = new QTableWidgetItem(QString::fromStdString(subkeys.GetID()));
tmp0->setTextAlignment(Qt::AlignCenter);
- subkeyList->setItem(row, 0, tmp0);
+ subkey_list_->setItem(row, 0, tmp0);
auto* tmp1 = new QTableWidgetItem(QString::number(subkeys.GetKeyLength()));
tmp1->setTextAlignment(Qt::AlignCenter);
- subkeyList->setItem(row, 1, tmp1);
+ subkey_list_->setItem(row, 1, tmp1);
auto* tmp2 =
new QTableWidgetItem(QString::fromStdString(subkeys.GetPubkeyAlgo()));
tmp2->setTextAlignment(Qt::AlignCenter);
- subkeyList->setItem(row, 2, tmp2);
+ subkey_list_->setItem(row, 2, tmp2);
auto* tmp3 = new QTableWidgetItem(
QString::fromStdString(to_iso_string(subkeys.GetCreateTime())));
tmp3->setTextAlignment(Qt::AlignCenter);
- subkeyList->setItem(row, 3, tmp3);
+ subkey_list_->setItem(row, 3, tmp3);
auto* tmp4 = new QTableWidgetItem(
boost::posix_time::to_time_t(
@@ -197,53 +204,53 @@ void KeyPairSubkeyTab::slotRefreshSubkeyList() {
? _("Never Expire")
: QString::fromStdString(to_iso_string(subkeys.GetExpireTime())));
tmp4->setTextAlignment(Qt::AlignCenter);
- subkeyList->setItem(row, 4, tmp4);
+ subkey_list_->setItem(row, 4, tmp4);
if (!row) {
- for (auto i = 0; i < subkeyList->columnCount(); i++) {
- subkeyList->item(row, i)->setForeground(QColor(65, 105, 255));
+ for (auto i = 0; i < subkey_list_->columnCount(); i++) {
+ subkey_list_->item(row, i)->setForeground(QColor(65, 105, 255));
}
}
row++;
}
- if (subkeyList->rowCount() > 0) {
- subkeyList->selectRow(0);
+ if (subkey_list_->rowCount() > 0) {
+ subkey_list_->selectRow(0);
}
}
-void KeyPairSubkeyTab::slotAddSubkey() {
+void KeyPairSubkeyTab::slot_add_subkey() {
auto dialog = new SubkeyGenerateDialog(key_.GetId(), this);
dialog->show();
}
-void KeyPairSubkeyTab::slotRefreshSubkeyDetail() {
- auto& subkey = getSelectedSubkey();
+void KeyPairSubkeyTab::slot_refresh_subkey_detail() {
+ auto& subkey = get_selected_subkey();
- keyidVarLabel->setText(QString::fromStdString(subkey.GetID()));
- keySizeVarLabel->setText(QString::number(subkey.GetKeyLength()));
+ key_id_var_label_->setText(QString::fromStdString(subkey.GetID()));
+ key_size_var_label_->setText(QString::number(subkey.GetKeyLength()));
time_t subkey_time_t = boost::posix_time::to_time_t(
boost::posix_time::ptime(subkey.GetExpireTime()));
- expireVarLabel->setText(
+ expire_var_label_->setText(
subkey_time_t == 0 ? _("Never Expires")
: QLocale::system().toString(QDateTime::fromTime_t(
to_time_t(subkey.GetExpireTime()))));
if (subkey_time_t != 0 &&
subkey.GetExpireTime() < boost::posix_time::second_clock::local_time()) {
- auto paletteExpired = expireVarLabel->palette();
- paletteExpired.setColor(expireVarLabel->foregroundRole(), Qt::red);
- expireVarLabel->setPalette(paletteExpired);
+ auto paletteExpired = expire_var_label_->palette();
+ paletteExpired.setColor(expire_var_label_->foregroundRole(), Qt::red);
+ expire_var_label_->setPalette(paletteExpired);
} else {
- auto paletteValid = expireVarLabel->palette();
- paletteValid.setColor(expireVarLabel->foregroundRole(), Qt::darkGreen);
- expireVarLabel->setPalette(paletteValid);
+ auto paletteValid = expire_var_label_->palette();
+ paletteValid.setColor(expire_var_label_->foregroundRole(), Qt::darkGreen);
+ expire_var_label_->setPalette(paletteValid);
}
- algorithmVarLabel->setText(QString::fromStdString(subkey.GetPubkeyAlgo()));
- createdVarLabel->setText(QLocale::system().toString(
+ algorithm_var_label_->setText(QString::fromStdString(subkey.GetPubkeyAlgo()));
+ created_var_label_->setText(QLocale::system().toString(
QDateTime::fromTime_t(to_time_t(subkey.GetCreateTime()))));
std::stringstream usage_steam;
@@ -254,76 +261,77 @@ void KeyPairSubkeyTab::slotRefreshSubkeyDetail() {
if (subkey.IsHasSigningCapability()) usage_steam << _("Sign") << " ";
if (subkey.IsHasAuthenticationCapability()) usage_steam << _("Auth") << " ";
- usageVarLabel->setText(usage_steam.str().c_str());
+ usage_var_label_->setText(usage_steam.str().c_str());
// Show the situation that secret key not exists.
- masterKeyExistVarLabel->setText(subkey.IsSecretKey() ? _("Exists")
- : _("Not Exists"));
+ master_key_exist_var_label_->setText(subkey.IsSecretKey() ? _("Exists")
+ : _("Not Exists"));
// Show the situation if key in a smart card.
- cardKeyLabel->setText(subkey.IsCardKey() ? _("Yes") : _("No"));
+ card_key_label_->setText(subkey.IsCardKey() ? _("Yes") : _("No"));
if (!subkey.IsSecretKey()) {
- auto palette_expired = masterKeyExistVarLabel->palette();
- palette_expired.setColor(masterKeyExistVarLabel->foregroundRole(), Qt::red);
- masterKeyExistVarLabel->setPalette(palette_expired);
+ auto palette_expired = master_key_exist_var_label_->palette();
+ palette_expired.setColor(master_key_exist_var_label_->foregroundRole(),
+ Qt::red);
+ master_key_exist_var_label_->setPalette(palette_expired);
} else {
- auto palette_valid = masterKeyExistVarLabel->palette();
- palette_valid.setColor(masterKeyExistVarLabel->foregroundRole(),
+ auto palette_valid = master_key_exist_var_label_->palette();
+ palette_valid.setColor(master_key_exist_var_label_->foregroundRole(),
Qt::darkGreen);
- masterKeyExistVarLabel->setPalette(palette_valid);
+ master_key_exist_var_label_->setPalette(palette_valid);
}
if (!subkey.IsCardKey()) {
- auto palette_expired = cardKeyLabel->palette();
- palette_expired.setColor(cardKeyLabel->foregroundRole(), Qt::red);
- cardKeyLabel->setPalette(palette_expired);
+ auto palette_expired = card_key_label_->palette();
+ palette_expired.setColor(card_key_label_->foregroundRole(), Qt::red);
+ card_key_label_->setPalette(palette_expired);
} else {
- auto palette_valid = cardKeyLabel->palette();
- palette_valid.setColor(cardKeyLabel->foregroundRole(), Qt::darkGreen);
- cardKeyLabel->setPalette(palette_valid);
+ auto palette_valid = card_key_label_->palette();
+ palette_valid.setColor(card_key_label_->foregroundRole(), Qt::darkGreen);
+ card_key_label_->setPalette(palette_valid);
}
- fingerPrintVarLabel->setText(QString::fromStdString(subkey.GetFingerprint()));
+ fingerprint_var_label_->setText(
+ QString::fromStdString(subkey.GetFingerprint()));
}
-void KeyPairSubkeyTab::createSubkeyOperaMenu() {
- subkeyOperaMenu = new QMenu(this);
- // auto *revokeSubkeyAct = new QAction(_("Revoke Subkey"));
+void KeyPairSubkeyTab::create_subkey_opera_menu() {
+ subkey_opera_menu_ = new QMenu(this);
auto* editSubkeyAct = new QAction(_("Edit Expire Date"));
- connect(editSubkeyAct, SIGNAL(triggered(bool)), this, SLOT(slotEditSubkey()));
+ connect(editSubkeyAct, &QAction::triggered, this,
+ &KeyPairSubkeyTab::slot_edit_subkey);
- // subkeyOperaMenu->addAction(revokeSubkeyAct);
- subkeyOperaMenu->addAction(editSubkeyAct);
+ subkey_opera_menu_->addAction(editSubkeyAct);
}
-void KeyPairSubkeyTab::slotEditSubkey() {
- LOG(INFO) << "Fpr" << getSelectedSubkey().GetFingerprint();
+void KeyPairSubkeyTab::slot_edit_subkey() {
+ LOG(INFO) << "Fpr" << get_selected_subkey().GetFingerprint();
auto dialog = new KeySetExpireDateDialog(
- key_.GetId(), getSelectedSubkey().GetFingerprint(), this);
+ key_.GetId(), get_selected_subkey().GetFingerprint(), this);
dialog->show();
}
-void KeyPairSubkeyTab::slotRevokeSubkey() {}
+void KeyPairSubkeyTab::slot_revoke_subkey() {}
void KeyPairSubkeyTab::contextMenuEvent(QContextMenuEvent* event) {
- if (!subkeyList->selectedItems().isEmpty()) {
- subkeyOperaMenu->exec(event->globalPos());
+ if (!subkey_list_->selectedItems().isEmpty()) {
+ subkey_opera_menu_->exec(event->globalPos());
}
}
-const GpgSubKey& KeyPairSubkeyTab::getSelectedSubkey() {
+const GpgSubKey& KeyPairSubkeyTab::get_selected_subkey() {
int row = 0;
- for (int i = 0; i < subkeyList->rowCount(); i++) {
- if (subkeyList->item(row, 0)->isSelected()) break;
+ for (int i = 0; i < subkey_list_->rowCount(); i++) {
+ if (subkey_list_->item(row, 0)->isSelected()) break;
row++;
}
- return buffered_subkeys[row];
+ return buffered_subkeys_[row];
}
-void KeyPairSubkeyTab::slotRefreshKeyInfo() {
+void KeyPairSubkeyTab::slot_refresh_key_info() {
key_ = GpgKeyGetter::GetInstance().GetKey(key_.GetId());
}
diff --git a/src/ui/keypair_details/KeyPairSubkeyTab.h b/src/ui/keypair_details/KeyPairSubkeyTab.h
index f254fed0..a64d143c 100644
--- a/src/ui/keypair_details/KeyPairSubkeyTab.h
+++ b/src/ui/keypair_details/KeyPairSubkeyTab.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -26,9 +30,9 @@
#define GPGFRONTEND_KEYPAIRSUBKEYTAB_H
#include "KeySetExpireDateDialog.h"
-#include "gpg/GpgContext.h"
+#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
-#include "ui/keygen/SubkeyGenerateDialog.h"
+#include "ui/key_generate/SubkeyGenerateDialog.h"
namespace GpgFrontend::UI {
@@ -36,49 +40,97 @@ class KeyPairSubkeyTab : public QWidget {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Key Pair Subkey Tab object
+ *
+ * @param key
+ * @param parent
+ */
KeyPairSubkeyTab(const std::string& key, QWidget* parent);
private:
- void createSubkeyList();
-
- void createSubkeyOperaMenu();
-
- const GpgSubKey& getSelectedSubkey();
-
- GpgKey key_;
- QTableWidget* subkeyList{};
- std::vector<GpgSubKey> buffered_subkeys;
-
- QGroupBox* listBox;
- QGroupBox* detailBox;
-
- QMenu* subkeyOperaMenu{};
-
- QLabel* keySizeVarLabel; /** Label containing the keys key size */
- QLabel* expireVarLabel; /** Label containing the keys expiration date */
- QLabel* createdVarLabel; /** Label containing the keys creation date */
- QLabel* algorithmVarLabel; /** Label containing the keys algorithm */
- QLabel* keyidVarLabel; /** Label containing the keys keyid */
- QLabel* fingerPrintVarLabel; /** Label containing the keys fingerprint */
- QLabel* usageVarLabel;
- QLabel* masterKeyExistVarLabel;
- QLabel* cardKeyLabel;
+ /**
+ * @brief Create a subkey list object
+ *
+ */
+ void create_subkey_list();
+
+ /**
+ * @brief Create a subkey opera menu object
+ *
+ */
+ void create_subkey_opera_menu();
+
+ /**
+ * @brief Get the selected subkey object
+ *
+ * @return const GpgSubKey&
+ */
+ const GpgSubKey& get_selected_subkey();
+
+ GpgKey key_; ///<
+ QTableWidget* subkey_list_{}; ///<
+ std::vector<GpgSubKey> buffered_subkeys_; ///<
+
+ QGroupBox* list_box_; ///<
+ QGroupBox* detail_box_; ///<
+
+ QMenu* subkey_opera_menu_{}; ///<
+
+ QLabel* key_size_var_label_; ///< Label containing the keys key size
+ QLabel* expire_var_label_; ///< Label containing the keys expiration date
+ QLabel* created_var_label_; ///< Label containing the keys creation date
+ QLabel* algorithm_var_label_; ///< Label containing the keys algorithm
+ QLabel* key_id_var_label_; ///< Label containing the keys keyid
+ QLabel* fingerprint_var_label_; ///< Label containing the keys fingerprint
+ QLabel* usage_var_label_; ///<
+ QLabel* master_key_exist_var_label_; ///<
+ QLabel* card_key_label_; ///<
private slots:
- void slotAddSubkey();
-
- void slotRefreshSubkeyList();
-
- void slotRefreshSubkeyDetail();
-
- void slotEditSubkey();
-
- void slotRevokeSubkey();
-
- void slotRefreshKeyInfo();
+ /**
+ * @brief
+ *
+ */
+ void slot_add_subkey();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_refresh_subkey_list();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_refresh_subkey_detail();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_edit_subkey();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_revoke_subkey();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_refresh_key_info();
protected:
+ /**
+ * @brief
+ *
+ * @param event
+ */
void contextMenuEvent(QContextMenuEvent* event) override;
};
diff --git a/src/ui/keypair_details/KeyPairUIDTab.cpp b/src/ui/keypair_details/KeyPairUIDTab.cpp
index 903b93f8..81d34684 100644
--- a/src/ui/keypair_details/KeyPairUIDTab.cpp
+++ b/src/ui/keypair_details/KeyPairUIDTab.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -24,29 +26,29 @@
#include "ui/keypair_details/KeyPairUIDTab.h"
-#include "gpg/function/GpgKeyGetter.h"
-#include "gpg/function/GpgKeyManager.h"
-#include "gpg/function/UIDOperator.h"
+#include "core/function/gpg/GpgKeyGetter.h"
+#include "core/function/gpg/GpgKeyManager.h"
+#include "core/function/gpg/GpgUIDOperator.h"
#include "ui/SignalStation.h"
#include "ui/widgets/TOFUInfoPage.h"
namespace GpgFrontend::UI {
KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent)
- : QWidget(parent), mKey(GpgKeyGetter::GetInstance().GetKey(key_id)) {
- createUIDList();
- createSignList();
- createManageUIDMenu();
- createUIDPopupMenu();
- createSignPopupMenu();
+ : QWidget(parent), m_key_(GpgKeyGetter::GetInstance().GetKey(key_id)) {
+ create_uid_list();
+ create_sign_list();
+ create_manage_uid_menu();
+ create_uid_popup_menu();
+ create_sign_popup_menu();
auto uidButtonsLayout = new QGridLayout();
auto addUIDButton = new QPushButton(_("New UID"));
auto manageUIDButton = new QPushButton(_("UID Management"));
- if (mKey.IsHasMasterKey()) {
- manageUIDButton->setMenu(manageSelectedUIDMenu);
+ if (m_key_.IsHasMasterKey()) {
+ manageUIDButton->setMenu(manage_selected_uid_menu_);
} else {
manageUIDButton->setDisabled(true);
}
@@ -56,7 +58,7 @@ KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent)
auto grid_layout = new QGridLayout();
- grid_layout->addWidget(uidList, 0, 0);
+ grid_layout->addWidget(uid_list_, 0, 0);
grid_layout->addLayout(uidButtonsLayout, 1, 0);
grid_layout->setContentsMargins(0, 10, 0, 0);
@@ -69,12 +71,12 @@ KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent)
tofu_group_box->setLayout(tofu_vbox_layout);
tofu_group_box->setTitle(_("TOFU"));
#if !defined(RELEASE)
- tofuTabs = new QTabWidget(this);
- tofu_vbox_layout->addWidget(tofuTabs);
+ tofu_tabs_ = new QTabWidget(this);
+ tofu_vbox_layout->addWidget(tofu_tabs_);
#endif
auto sign_grid_layout = new QGridLayout();
- sign_grid_layout->addWidget(sigList, 0, 0);
+ sign_grid_layout->addWidget(sig_list_, 0, 0);
sign_grid_layout->setContentsMargins(0, 10, 0, 0);
auto sign_group_box = new QGroupBox();
@@ -91,191 +93,194 @@ KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent)
vboxLayout->setContentsMargins(0, 0, 0, 0);
- connect(addUIDButton, SIGNAL(clicked(bool)), this, SLOT(slotAddUID()));
- connect(uidList, SIGNAL(itemSelectionChanged()), this,
- SLOT(slotRefreshTOFUInfo()));
- connect(uidList, SIGNAL(itemSelectionChanged()), this,
- SLOT(slotRefreshSigList()));
+ connect(addUIDButton, &QPushButton::clicked, this,
+ &KeyPairUIDTab::slot_add_uid);
+ connect(uid_list_, &QTableWidget::itemSelectionChanged, this,
+ &KeyPairUIDTab::slot_refresh_tofu_info);
+ connect(uid_list_, &QTableWidget::itemSelectionChanged, this,
+ &KeyPairUIDTab::slot_refresh_sig_list);
// Key Database Refresh
- connect(SignalStation::GetInstance(), SIGNAL(KeyDatabaseRefresh()), this,
- SLOT(slotRefreshKey()));
+ connect(SignalStation::GetInstance(),
+ &SignalStation::SignalKeyDatabaseRefresh, this,
+ &KeyPairUIDTab::slot_refresh_key);
- connect(this, SIGNAL(signalUpdateUIDInfo()), SignalStation::GetInstance(),
- SIGNAL(KeyDatabaseRefresh()));
+ connect(this, &KeyPairUIDTab::SignalUpdateUIDInfo,
+ SignalStation::GetInstance(),
+ &SignalStation::SignalKeyDatabaseRefresh);
setLayout(vboxLayout);
setAttribute(Qt::WA_DeleteOnClose, true);
- slotRefreshUIDList();
+ slot_refresh_uid_list();
}
-void KeyPairUIDTab::createUIDList() {
- uidList = new QTableWidget(this);
- uidList->setColumnCount(4);
- uidList->horizontalHeader()->setSectionResizeMode(
+void KeyPairUIDTab::create_uid_list() {
+ uid_list_ = new QTableWidget(this);
+ uid_list_->setColumnCount(4);
+ uid_list_->horizontalHeader()->setSectionResizeMode(
QHeaderView::ResizeToContents);
- uidList->verticalHeader()->hide();
- uidList->setShowGrid(false);
- uidList->setSelectionBehavior(QAbstractItemView::SelectRows);
- uidList->setSelectionMode(QAbstractItemView::SingleSelection);
+ uid_list_->verticalHeader()->hide();
+ uid_list_->setShowGrid(false);
+ uid_list_->setSelectionBehavior(QAbstractItemView::SelectRows);
+ uid_list_->setSelectionMode(QAbstractItemView::SingleSelection);
// tableitems not editable
- uidList->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ uid_list_->setEditTriggers(QAbstractItemView::NoEditTriggers);
// no focus (rectangle around tableitems)
// may be it should focus on whole row
- uidList->setFocusPolicy(Qt::NoFocus);
- uidList->setAlternatingRowColors(true);
+ uid_list_->setFocusPolicy(Qt::NoFocus);
+ uid_list_->setAlternatingRowColors(true);
QStringList labels;
labels << _("Select") << _("Name") << _("Email") << _("Comment");
- uidList->setHorizontalHeaderLabels(labels);
- uidList->horizontalHeader()->setStretchLastSection(true);
+ uid_list_->setHorizontalHeaderLabels(labels);
+ uid_list_->horizontalHeader()->setStretchLastSection(true);
}
-void KeyPairUIDTab::createSignList() {
- sigList = new QTableWidget(this);
- sigList->setColumnCount(5);
- sigList->horizontalHeader()->setSectionResizeMode(
+void KeyPairUIDTab::create_sign_list() {
+ sig_list_ = new QTableWidget(this);
+ sig_list_->setColumnCount(5);
+ sig_list_->horizontalHeader()->setSectionResizeMode(
QHeaderView::ResizeToContents);
- sigList->verticalHeader()->hide();
- sigList->setShowGrid(false);
- sigList->setSelectionBehavior(QAbstractItemView::SelectRows);
+ sig_list_->verticalHeader()->hide();
+ sig_list_->setShowGrid(false);
+ sig_list_->setSelectionBehavior(QAbstractItemView::SelectRows);
// table items not editable
- sigList->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ sig_list_->setEditTriggers(QAbstractItemView::NoEditTriggers);
// no focus (rectangle around table items)
// may be it should focus on whole row
- sigList->setFocusPolicy(Qt::NoFocus);
- sigList->setAlternatingRowColors(true);
+ sig_list_->setFocusPolicy(Qt::NoFocus);
+ sig_list_->setAlternatingRowColors(true);
QStringList labels;
labels << _("Key ID") << _("Name") << _("Email") << _("Create Date (UTC)")
<< _("Expired Date (UTC)");
- sigList->setHorizontalHeaderLabels(labels);
- sigList->horizontalHeader()->setStretchLastSection(false);
+ sig_list_->setHorizontalHeaderLabels(labels);
+ sig_list_->horizontalHeader()->setStretchLastSection(false);
}
-void KeyPairUIDTab::slotRefreshUIDList() {
+void KeyPairUIDTab::slot_refresh_uid_list() {
int row = 0;
- uidList->setSelectionMode(QAbstractItemView::SingleSelection);
+ uid_list_->setSelectionMode(QAbstractItemView::SingleSelection);
- this->buffered_uids.clear();
+ this->buffered_uids_.clear();
- auto uids = mKey.GetUIDs();
+ auto uids = m_key_.GetUIDs();
for (auto& uid : *uids) {
if (uid.GetInvalid() || uid.GetRevoked()) {
continue;
}
- this->buffered_uids.push_back(std::move(uid));
+ this->buffered_uids_.push_back(std::move(uid));
}
- uidList->setRowCount(buffered_uids.size());
+ uid_list_->setRowCount(buffered_uids_.size());
- for (const auto& uid : buffered_uids) {
+ for (const auto& uid : buffered_uids_) {
auto* tmp0 = new QTableWidgetItem(QString::fromStdString(uid.GetUID()));
- uidList->setItem(row, 1, tmp0);
+ uid_list_->setItem(row, 1, tmp0);
auto* tmp1 = new QTableWidgetItem(QString::fromStdString(uid.GetUID()));
- uidList->setItem(row, 2, tmp1);
+ uid_list_->setItem(row, 2, tmp1);
auto* tmp2 = new QTableWidgetItem(QString::fromStdString(uid.GetUID()));
- uidList->setItem(row, 3, tmp2);
+ uid_list_->setItem(row, 3, tmp2);
auto* tmp3 = new QTableWidgetItem(QString::number(row));
tmp3->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled |
Qt::ItemIsSelectable);
tmp3->setTextAlignment(Qt::AlignCenter);
tmp3->setCheckState(Qt::Unchecked);
- uidList->setItem(row, 0, tmp3);
+ uid_list_->setItem(row, 0, tmp3);
if (!row) {
- for (auto i = 0; i < uidList->columnCount(); i++) {
- uidList->item(row, i)->setForeground(QColor(65, 105, 255));
+ for (auto i = 0; i < uid_list_->columnCount(); i++) {
+ uid_list_->item(row, i)->setForeground(QColor(65, 105, 255));
}
}
row++;
}
- if (uidList->rowCount() > 0) {
- uidList->selectRow(0);
+ if (uid_list_->rowCount() > 0) {
+ uid_list_->selectRow(0);
}
- slotRefreshSigList();
- slotRefreshTOFUInfo();
+ slot_refresh_sig_list();
+ slot_refresh_tofu_info();
}
-void KeyPairUIDTab::slotRefreshTOFUInfo() {
- if (this->tofuTabs == nullptr) return;
+void KeyPairUIDTab::slot_refresh_tofu_info() {
+ if (this->tofu_tabs_ == nullptr) return;
int uidRow = 0;
- tofuTabs->clear();
- for (const auto& uid : buffered_uids) {
+ tofu_tabs_->clear();
+ for (const auto& uid : buffered_uids_) {
// Only Show Selected UID Signatures
- if (!uidList->item(uidRow++, 0)->isSelected()) {
+ if (!uid_list_->item(uidRow++, 0)->isSelected()) {
continue;
}
auto tofu_infos = uid.GetTofuInfos();
LOG(INFO) << "tofu info size" << tofu_infos->size();
if (tofu_infos->empty()) {
- tofuTabs->hide();
+ tofu_tabs_->hide();
} else {
- tofuTabs->show();
+ tofu_tabs_->show();
}
int index = 1;
for (const auto& tofu_info : *tofu_infos) {
- tofuTabs->addTab(new TOFUInfoPage(tofu_info, this),
- QString(_("TOFU %1")).arg(index++));
+ tofu_tabs_->addTab(new TOFUInfoPage(tofu_info, this),
+ QString(_("TOFU %1")).arg(index++));
}
}
}
-void KeyPairUIDTab::slotRefreshSigList() {
+void KeyPairUIDTab::slot_refresh_sig_list() {
int uidRow = 0, sigRow = 0;
- for (const auto& uid : buffered_uids) {
+ for (const auto& uid : buffered_uids_) {
// Only Show Selected UID Signatures
- if (!uidList->item(uidRow++, 0)->isSelected()) {
+ if (!uid_list_->item(uidRow++, 0)->isSelected()) {
continue;
}
- buffered_signatures.clear();
+ buffered_signatures_.clear();
auto signatures = uid.GetSignatures();
for (auto& sig : *signatures) {
if (sig.IsInvalid() || sig.IsRevoked()) {
continue;
}
- buffered_signatures.push_back(std::move(sig));
+ buffered_signatures_.push_back(std::move(sig));
}
- sigList->setRowCount(buffered_signatures.size());
+ sig_list_->setRowCount(buffered_signatures_.size());
- for (const auto& sig : buffered_signatures) {
+ for (const auto& sig : buffered_signatures_) {
auto* tmp0 = new QTableWidgetItem(QString::fromStdString(sig.GetKeyID()));
- sigList->setItem(sigRow, 0, tmp0);
+ sig_list_->setItem(sigRow, 0, tmp0);
if (gpgme_err_code(sig.GetStatus()) == GPG_ERR_NO_PUBKEY) {
auto* tmp2 = new QTableWidgetItem("<Unknown>");
- sigList->setItem(sigRow, 1, tmp2);
+ sig_list_->setItem(sigRow, 1, tmp2);
auto* tmp3 = new QTableWidgetItem("<Unknown>");
- sigList->setItem(sigRow, 2, tmp3);
+ sig_list_->setItem(sigRow, 2, tmp3);
} else {
auto* tmp2 =
new QTableWidgetItem(QString::fromStdString(sig.GetName()));
- sigList->setItem(sigRow, 1, tmp2);
+ sig_list_->setItem(sigRow, 1, tmp2);
auto* tmp3 =
new QTableWidgetItem(QString::fromStdString(sig.GetEmail()));
- sigList->setItem(sigRow, 2, tmp3);
+ sig_list_->setItem(sigRow, 2, tmp3);
}
auto* tmp4 = new QTableWidgetItem(QLocale::system().toString(
QDateTime::fromTime_t(to_time_t(sig.GetCreateTime()))));
- sigList->setItem(sigRow, 3, tmp4);
+ sig_list_->setItem(sigRow, 3, tmp4);
auto* tmp5 = new QTableWidgetItem(
boost::posix_time::to_time_t(
@@ -284,7 +289,7 @@ void KeyPairUIDTab::slotRefreshSigList() {
: QLocale::system().toString(
QDateTime::fromTime_t(to_time_t(sig.GetExpireTime()))));
tmp5->setTextAlignment(Qt::AlignCenter);
- sigList->setItem(sigRow, 4, tmp5);
+ sig_list_->setItem(sigRow, 4, tmp5);
sigRow++;
}
@@ -293,8 +298,8 @@ void KeyPairUIDTab::slotRefreshSigList() {
}
}
-void KeyPairUIDTab::slotAddSign() {
- auto selected_uids = getUIDChecked();
+void KeyPairUIDTab::slot_add_sign() {
+ auto selected_uids = get_uid_checked();
if (selected_uids->empty()) {
QMessageBox::information(
@@ -304,43 +309,43 @@ void KeyPairUIDTab::slotAddSign() {
}
auto keySignDialog =
- new KeyUIDSignDialog(mKey, std::move(selected_uids), this);
+ new KeyUIDSignDialog(m_key_, std::move(selected_uids), this);
keySignDialog->show();
}
-UIDArgsListPtr KeyPairUIDTab::getUIDChecked() {
+UIDArgsListPtr KeyPairUIDTab::get_uid_checked() {
auto selected_uids = std::make_unique<UIDArgsList>();
- for (int i = 0; i < uidList->rowCount(); i++) {
- if (uidList->item(i, 0)->checkState() == Qt::Checked)
- selected_uids->push_back(buffered_uids[i].GetUID());
+ for (int i = 0; i < uid_list_->rowCount(); i++) {
+ if (uid_list_->item(i, 0)->checkState() == Qt::Checked)
+ selected_uids->push_back(buffered_uids_[i].GetUID());
}
return selected_uids;
}
-void KeyPairUIDTab::createManageUIDMenu() {
- manageSelectedUIDMenu = new QMenu(this);
+void KeyPairUIDTab::create_manage_uid_menu() {
+ manage_selected_uid_menu_ = new QMenu(this);
auto* signUIDAct = new QAction(_("Sign Selected UID(s)"), this);
- connect(signUIDAct, SIGNAL(triggered()), this, SLOT(slotAddSign()));
+ connect(signUIDAct, &QAction::triggered, this, &KeyPairUIDTab::slot_add_sign);
auto* delUIDAct = new QAction(_("Delete Selected UID(s)"), this);
- connect(delUIDAct, SIGNAL(triggered()), this, SLOT(slotDelUID()));
+ connect(delUIDAct, &QAction::triggered, this, &KeyPairUIDTab::slot_del_uid);
- if (mKey.IsHasMasterKey()) {
- manageSelectedUIDMenu->addAction(signUIDAct);
- manageSelectedUIDMenu->addAction(delUIDAct);
+ if (m_key_.IsHasMasterKey()) {
+ manage_selected_uid_menu_->addAction(signUIDAct);
+ manage_selected_uid_menu_->addAction(delUIDAct);
}
}
-void KeyPairUIDTab::slotAddUID() {
- auto keyNewUIDDialog = new KeyNewUIDDialog(mKey.GetId(), this);
- connect(keyNewUIDDialog, SIGNAL(finished(int)), this,
- SLOT(slotAddUIDResult(int)));
- connect(keyNewUIDDialog, SIGNAL(finished(int)), keyNewUIDDialog,
- SLOT(deleteLater()));
+void KeyPairUIDTab::slot_add_uid() {
+ auto keyNewUIDDialog = new KeyNewUIDDialog(m_key_.GetId(), this);
+ connect(keyNewUIDDialog, &KeyNewUIDDialog::finished, this,
+ &KeyPairUIDTab::slot_add_uid_result);
+ connect(keyNewUIDDialog, &KeyNewUIDDialog::finished, keyNewUIDDialog,
+ &KeyPairUIDTab::deleteLater);
keyNewUIDDialog->show();
}
-void KeyPairUIDTab::slotAddUIDResult(int result) {
+void KeyPairUIDTab::slot_add_uid_result(int result) {
if (result == 1) {
QMessageBox::information(nullptr, _("Successful Operation"),
_("Successfully added a new UID."));
@@ -350,8 +355,8 @@ void KeyPairUIDTab::slotAddUIDResult(int result) {
}
}
-void KeyPairUIDTab::slotDelUID() {
- auto selected_uids = getUIDChecked();
+void KeyPairUIDTab::slot_del_uid() {
+ auto selected_uids = get_uid_checked();
if (selected_uids->empty()) {
QMessageBox::information(
@@ -377,20 +382,20 @@ void KeyPairUIDTab::slotDelUID() {
if (ret == QMessageBox::Yes) {
for (const auto& uid : *selected_uids) {
- LOG(INFO) << "KeyPairUIDTab::slotDelUID UID" << uid;
- if (!UIDOperator::GetInstance().RevUID(mKey, uid)) {
+ LOG(INFO) << "KeyPairUIDTab::slot_del_uid UID" << uid;
+ if (!GpgUIDOperator::GetInstance().RevUID(m_key_, uid)) {
QMessageBox::critical(
nullptr, _("Operation Failed"),
QString(_("An error occurred during the delete %1 operation."))
.arg(uid.c_str()));
}
}
- emit signalUpdateUIDInfo();
+ emit SignalUpdateUIDInfo();
}
}
-void KeyPairUIDTab::slotSetPrimaryUID() {
- auto selected_uids = getUIDSelected();
+void KeyPairUIDTab::slot_set_primary_uid() {
+ auto selected_uids = get_uid_selected();
if (selected_uids->empty()) {
auto emptyUIDMsg = new QMessageBox();
@@ -413,68 +418,66 @@ void KeyPairUIDTab::slotSetPrimaryUID() {
QMessageBox::No | QMessageBox::Yes);
if (ret == QMessageBox::Yes) {
- if (!UIDOperator::GetInstance().SetPrimaryUID(mKey,
+ if (!GpgUIDOperator::GetInstance().SetPrimaryUID(m_key_,
selected_uids->front())) {
QMessageBox::critical(nullptr, _("Operation Failed"),
_("An error occurred during the operation."));
} else {
- emit signalUpdateUIDInfo();
+ emit SignalUpdateUIDInfo();
}
}
}
-UIDArgsListPtr KeyPairUIDTab::getUIDSelected() {
+UIDArgsListPtr KeyPairUIDTab::get_uid_selected() {
auto uids = std::make_unique<UIDArgsList>();
- for (int i = 0; i < uidList->rowCount(); i++) {
- if (uidList->item(i, 0)->isSelected()) {
- uids->push_back(buffered_uids[i].GetUID());
+ for (int i = 0; i < uid_list_->rowCount(); i++) {
+ if (uid_list_->item(i, 0)->isSelected()) {
+ uids->push_back(buffered_uids_[i].GetUID());
}
}
return uids;
}
-SignIdArgsListPtr KeyPairUIDTab::getSignSelected() {
+SignIdArgsListPtr KeyPairUIDTab::get_sign_selected() {
auto signatures = std::make_unique<SignIdArgsList>();
- for (int i = 0; i < sigList->rowCount(); i++) {
- if (sigList->item(i, 0)->isSelected()) {
- auto& sign = buffered_signatures[i];
+ for (int i = 0; i < sig_list_->rowCount(); i++) {
+ if (sig_list_->item(i, 0)->isSelected()) {
+ auto& sign = buffered_signatures_[i];
signatures->push_back({sign.GetKeyID(), sign.GetUID()});
}
}
return signatures;
}
-void KeyPairUIDTab::createUIDPopupMenu() {
- uidPopupMenu = new QMenu(this);
+void KeyPairUIDTab::create_uid_popup_menu() {
+ uid_popup_menu_ = new QMenu(this);
auto* serPrimaryUIDAct = new QAction(_("Set As Primary"), this);
- connect(serPrimaryUIDAct, SIGNAL(triggered()), this,
- SLOT(slotSetPrimaryUID()));
+ connect(serPrimaryUIDAct, &QAction::triggered, this,
+ &KeyPairUIDTab::slot_set_primary_uid);
auto* signUIDAct = new QAction(_("Sign UID"), this);
- connect(signUIDAct, SIGNAL(triggered()), this, SLOT(slotAddSignSingle()));
+ connect(signUIDAct, &QAction::triggered, this,
+ &KeyPairUIDTab::slot_add_sign_single);
auto* delUIDAct = new QAction(_("Delete UID"), this);
- connect(delUIDAct, SIGNAL(triggered()), this, SLOT(slotDelUIDSingle()));
+ connect(delUIDAct, &QAction::triggered, this,
+ &KeyPairUIDTab::slot_del_uid_single);
- if (mKey.IsHasMasterKey()) {
- uidPopupMenu->addAction(serPrimaryUIDAct);
- uidPopupMenu->addAction(signUIDAct);
- uidPopupMenu->addAction(delUIDAct);
+ if (m_key_.IsHasMasterKey()) {
+ uid_popup_menu_->addAction(serPrimaryUIDAct);
+ uid_popup_menu_->addAction(signUIDAct);
+ uid_popup_menu_->addAction(delUIDAct);
}
}
void KeyPairUIDTab::contextMenuEvent(QContextMenuEvent* event) {
- if (uidList->selectedItems().length() > 0 &&
- sigList->selectedItems().isEmpty()) {
- uidPopupMenu->exec(event->globalPos());
+ if (uid_list_->selectedItems().length() > 0 &&
+ sig_list_->selectedItems().isEmpty()) {
+ uid_popup_menu_->exec(event->globalPos());
}
-
- // if (!sigList->selectedItems().isEmpty()) {
- // signPopupMenu->exec(event->globalPos());
- // }
}
-void KeyPairUIDTab::slotAddSignSingle() {
- auto selected_uids = getUIDSelected();
+void KeyPairUIDTab::slot_add_sign_single() {
+ auto selected_uids = get_uid_selected();
if (selected_uids->empty()) {
QMessageBox::information(
@@ -484,12 +487,12 @@ void KeyPairUIDTab::slotAddSignSingle() {
}
auto keySignDialog =
- new KeyUIDSignDialog(mKey, std::move(selected_uids), this);
+ new KeyUIDSignDialog(m_key_, std::move(selected_uids), this);
keySignDialog->show();
}
-void KeyPairUIDTab::slotDelUIDSingle() {
- auto selected_uids = getUIDSelected();
+void KeyPairUIDTab::slot_del_uid_single() {
+ auto selected_uids = get_uid_selected();
if (selected_uids->empty()) {
QMessageBox::information(
nullptr, _("Invalid Operation"),
@@ -512,26 +515,26 @@ void KeyPairUIDTab::slotDelUIDSingle() {
QMessageBox::No | QMessageBox::Yes);
if (ret == QMessageBox::Yes) {
- if (!UIDOperator::GetInstance().RevUID(mKey, selected_uids->front())) {
+ if (!GpgUIDOperator::GetInstance().RevUID(m_key_, selected_uids->front())) {
QMessageBox::critical(nullptr, _("Operation Failed"),
_("An error occurred during the operation."));
} else {
- emit signalUpdateUIDInfo();
+ emit SignalUpdateUIDInfo();
}
}
}
-void KeyPairUIDTab::createSignPopupMenu() {
- signPopupMenu = new QMenu(this);
+void KeyPairUIDTab::create_sign_popup_menu() {
+ sign_popup_menu_ = new QMenu(this);
auto* delSignAct = new QAction(_("Delete(Revoke) Key Signature"), this);
- connect(delSignAct, SIGNAL(triggered()), this, SLOT(slotDelSign()));
+ connect(delSignAct, &QAction::triggered, this, &KeyPairUIDTab::slot_del_sign);
- signPopupMenu->addAction(delSignAct);
+ sign_popup_menu_->addAction(delSignAct);
}
-void KeyPairUIDTab::slotDelSign() {
- auto selected_signs = getSignSelected();
+void KeyPairUIDTab::slot_del_sign() {
+ auto selected_signs = get_sign_selected();
if (selected_signs->empty()) {
QMessageBox::information(
nullptr, _("Invalid Operation"),
@@ -564,17 +567,17 @@ void KeyPairUIDTab::slotDelSign() {
QMessageBox::No | QMessageBox::Yes);
if (ret == QMessageBox::Yes) {
- if (!GpgKeyManager::GetInstance().RevSign(mKey, selected_signs)) {
+ if (!GpgKeyManager::GetInstance().RevSign(m_key_, selected_signs)) {
QMessageBox::critical(nullptr, _("Operation Failed"),
_("An error occurred during the operation."));
}
}
}
-void KeyPairUIDTab::slotRefreshKey() {
- this->mKey = GpgKeyGetter::GetInstance().GetKey(this->mKey.GetId());
- this->slotRefreshUIDList();
- this->slotRefreshTOFUInfo();
- this->slotRefreshSigList();
+void KeyPairUIDTab::slot_refresh_key() {
+ this->m_key_ = GpgKeyGetter::GetInstance().GetKey(this->m_key_.GetId());
+ this->slot_refresh_uid_list();
+ this->slot_refresh_tofu_info();
+ this->slot_refresh_sig_list();
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/keypair_details/KeyPairUIDTab.h b/src/ui/keypair_details/KeyPairUIDTab.h
index 823935d4..fae8f9f2 100644
--- a/src/ui/keypair_details/KeyPairUIDTab.h
+++ b/src/ui/keypair_details/KeyPairUIDTab.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -27,7 +31,7 @@
#include "KeyNewUIDDialog.h"
#include "KeyUIDSignDialog.h"
-#include "gpg/GpgContext.h"
+#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
namespace GpgFrontend::UI {
@@ -36,65 +40,165 @@ class KeyPairUIDTab : public QWidget {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Key Pair U I D Tab object
+ *
+ * @param key_id
+ * @param parent
+ */
KeyPairUIDTab(const std::string& key_id, QWidget* parent);
signals:
- void signalUpdateUIDInfo();
-
- private:
- GpgKey mKey;
- QTableWidget* uidList{};
- QTableWidget* sigList{};
- QTabWidget* tofuTabs{};
- QMenu* manageSelectedUIDMenu{};
- QMenu* uidPopupMenu{};
- QMenu* signPopupMenu{};
- std::vector<GpgUID> buffered_uids;
- std::vector<GpgKeySignature> buffered_signatures;
-
- void createUIDList();
-
- void createSignList();
- void createManageUIDMenu();
+ /**
+ * @brief
+ *
+ */
+ void SignalUpdateUIDInfo();
- void createUIDPopupMenu();
-
- void createSignPopupMenu();
-
- UIDArgsListPtr getUIDChecked();
-
- UIDArgsListPtr getUIDSelected();
-
- SignIdArgsListPtr getSignSelected();
+ private:
+ GpgKey m_key_;
+ QTableWidget* uid_list_{}; ///<
+ QTableWidget* sig_list_{}; ///<
+ QTabWidget* tofu_tabs_{}; ///<
+ QMenu* manage_selected_uid_menu_{}; ///<
+ QMenu* uid_popup_menu_{}; ///<
+ QMenu* sign_popup_menu_{}; ///<
+ std::vector<GpgUID> buffered_uids_; ///<
+ std::vector<GpgKeySignature> buffered_signatures_; ///<
+
+ /**
+ * @brief Create a uid list object
+ *
+ */
+ void create_uid_list();
+
+ /**
+ * @brief Create a sign list object
+ *
+ */
+ void create_sign_list();
+
+ /**
+ * @brief Create a manage uid menu object
+ *
+ */
+ void create_manage_uid_menu();
+
+ /**
+ * @brief Create a uid popup menu object
+ *
+ */
+ void create_uid_popup_menu();
+
+ /**
+ * @brief Create a sign popup menu object
+ *
+ */
+ void create_sign_popup_menu();
+
+ /**
+ * @brief Get the uid checked object
+ *
+ * @return UIDArgsListPtr
+ */
+ UIDArgsListPtr get_uid_checked();
+
+ /**
+ * @brief Get the uid selected object
+ *
+ * @return UIDArgsListPtr
+ */
+ UIDArgsListPtr get_uid_selected();
+
+ /**
+ * @brief Get the sign selected object
+ *
+ * @return SignIdArgsListPtr
+ */
+ SignIdArgsListPtr get_sign_selected();
private slots:
- void slotRefreshUIDList();
-
- void slotRefreshTOFUInfo();
-
- void slotRefreshSigList();
-
- void slotAddSign();
-
- void slotAddSignSingle();
-
- void slotAddUID();
-
- void slotDelUID();
-
- void slotDelUIDSingle();
-
- void slotSetPrimaryUID();
-
- void slotDelSign();
-
- void slotRefreshKey();
-
- static void slotAddUIDResult(int result);
+ /**
+ * @brief
+ *
+ */
+ void slot_refresh_uid_list();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_refresh_tofu_info();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_refresh_sig_list();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_add_sign();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_add_sign_single();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_add_uid();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_del_uid();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_del_uid_single();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_set_primary_uid();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_del_sign();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_refresh_key();
+
+ /**
+ * @brief
+ *
+ * @param result
+ */
+ static void slot_add_uid_result(int result);
protected:
+ /**
+ * @brief
+ *
+ * @param event
+ */
void contextMenuEvent(QContextMenuEvent* event) override;
};
diff --git a/src/ui/keypair_details/KeySetExpireDateDialog.cpp b/src/ui/keypair_details/KeySetExpireDateDialog.cpp
index 756916bb..79325e8b 100644
--- a/src/ui/keypair_details/KeySetExpireDateDialog.cpp
+++ b/src/ui/keypair_details/KeySetExpireDateDialog.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -26,10 +30,10 @@
#include <utility>
-#include "gpg/function/GpgKeyGetter.h"
-#include "gpg/function/GpgKeyOpera.h"
+#include "core/function/gpg/GpgKeyGetter.h"
+#include "core/function/gpg/GpgKeyOpera.h"
#include "ui/SignalStation.h"
-#include "ui/settings/GlobalSettingStation.h"
+#include "core/function/GlobalSettingStation.h"
#include "ui_ModifiedExpirationDateTime.h"
namespace GpgFrontend::UI {
@@ -37,8 +41,8 @@ namespace GpgFrontend::UI {
KeySetExpireDateDialog::KeySetExpireDateDialog(const KeyId& key_id,
QWidget* parent)
: QDialog(parent),
- ui(std::make_shared<Ui_ModifiedExpirationDateTime>()),
- mKey(GpgKeyGetter::GetInstance().GetKey(key_id)) {
+ ui_(std::make_shared<Ui_ModifiedExpirationDateTime>()),
+ m_key_(GpgKeyGetter::GetInstance().GetKey(key_id)) {
init();
}
@@ -46,26 +50,26 @@ KeySetExpireDateDialog::KeySetExpireDateDialog(const KeyId& key_id,
std::string subkey_fpr,
QWidget* parent)
: QDialog(parent),
- ui(std::make_shared<Ui_ModifiedExpirationDateTime>()),
- mKey(GpgKeyGetter::GetInstance().GetKey(key_id)),
- mSubkey(std::move(subkey_fpr)) {
+ ui_(std::make_shared<Ui_ModifiedExpirationDateTime>()),
+ m_key_(GpgKeyGetter::GetInstance().GetKey(key_id)),
+ m_subkey_(std::move(subkey_fpr)) {
init();
}
-void KeySetExpireDateDialog::slotConfirm() {
- LOG(INFO) << "Called" << ui->dateEdit->date().toString().toStdString()
- << ui->timeEdit->time().toString().toStdString();
- auto datetime = QDateTime(ui->dateEdit->date(), ui->timeEdit->time());
+void KeySetExpireDateDialog::slot_confirm() {
+ LOG(INFO) << "Called" << ui_->dateEdit->date().toString().toStdString()
+ << ui_->timeEdit->time().toString().toStdString();
+ auto datetime = QDateTime(ui_->dateEdit->date(), ui_->timeEdit->time());
std::unique_ptr<boost::posix_time::ptime> expires = nullptr;
- if (ui->noExpirationCheckBox->checkState() == Qt::Unchecked) {
+ if (ui_->noExpirationCheckBox->checkState() == Qt::Unchecked) {
expires = std::make_unique<boost::posix_time::ptime>(
boost::posix_time::from_time_t(datetime.toLocalTime().toTime_t()));
- LOG(INFO) << "keyid" << mKey.GetId() << mSubkey << *expires;
+ LOG(INFO) << "keyid" << m_key_.GetId() << m_subkey_ << *expires;
} else {
- LOG(INFO) << "keyid" << mKey.GetId() << mSubkey << "Non Expired";
+ LOG(INFO) << "keyid" << m_key_.GetId() << m_subkey_ << "Non Expired";
}
- auto err = GpgKeyOpera::GetInstance().SetExpire(mKey, mSubkey, expires);
+ auto err = GpgKeyOpera::GetInstance().SetExpire(m_key_, m_subkey_, expires);
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR) {
auto* msg_box = new QMessageBox(nullptr);
@@ -76,7 +80,7 @@ void KeySetExpireDateDialog::slotConfirm() {
msg_box->setModal(false);
msg_box->open();
- emit signalKeyExpireDateUpdated();
+ emit SignalKeyExpireDateUpdated();
} else {
QMessageBox::critical(this, _("Failure"), _(gpgme_strerror(err)));
@@ -86,7 +90,7 @@ void KeySetExpireDateDialog::slotConfirm() {
}
void KeySetExpireDateDialog::init() {
- ui->setupUi(this);
+ ui_->setupUi(this);
auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
@@ -106,31 +110,32 @@ void KeySetExpireDateDialog::init() {
auto min_date_time = QDateTime::currentDateTime().addDays(7);
- ui->dateEdit->setMaximumDateTime(max_date_time);
- ui->dateEdit->setMinimumDateTime(min_date_time);
+ ui_->dateEdit->setMaximumDateTime(max_date_time);
+ ui_->dateEdit->setMinimumDateTime(min_date_time);
- ui->dateEdit->setDateTime(max_date_time);
- ui->timeEdit->setDateTime(max_date_time);
+ ui_->dateEdit->setDateTime(max_date_time);
+ ui_->timeEdit->setDateTime(max_date_time);
- connect(ui->noExpirationCheckBox, SIGNAL(stateChanged(int)), this,
- SLOT(slotNonExpiredChecked(int)));
- connect(ui->button_box_, &QDialogButtonBox::accepted, this,
- &KeySetExpireDateDialog::slotConfirm);
- connect(this, SIGNAL(signalKeyExpireDateUpdated()),
- SignalStation::GetInstance(), SIGNAL(KeyDatabaseRefresh()));
+ connect(ui_->noExpirationCheckBox, &QCheckBox::stateChanged, this,
+ &KeySetExpireDateDialog::slot_non_expired_checked);
+ connect(ui_->button_box_, &QDialogButtonBox::accepted, this,
+ &KeySetExpireDateDialog::slot_confirm);
+ connect(this, &KeySetExpireDateDialog::SignalKeyExpireDateUpdated,
+ SignalStation::GetInstance(),
+ &SignalStation::SignalKeyDatabaseRefresh);
- ui->titleLabel->setText(_("Modified Expiration Date (Local Time)"));
- ui->label->setText(
+ ui_->titleLabel->setText(_("Modified Expiration Date (Local Time)"));
+ ui_->label->setText(
_("Tips: For the sake of security, the key is valid for up to two years. "
"If you are an expert user, please unlock it for a longer time in the "
"settings."));
- ui->noExpirationCheckBox->setText(_("No Expiration"));
+ ui_->noExpirationCheckBox->setText(_("No Expiration"));
this->setWindowTitle(_("Modified Expiration Date"));
}
-void KeySetExpireDateDialog::slotNonExpiredChecked(int state) {
- ui->dateEdit->setDisabled(state == Qt::Checked);
- ui->timeEdit->setDisabled(state == Qt::Checked);
+void KeySetExpireDateDialog::slot_non_expired_checked(int state) {
+ ui_->dateEdit->setDisabled(state == Qt::Checked);
+ ui_->timeEdit->setDisabled(state == Qt::Checked);
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/keypair_details/KeySetExpireDateDialog.h b/src/ui/keypair_details/KeySetExpireDateDialog.h
index d4386e43..3c0b62f7 100644
--- a/src/ui/keypair_details/KeySetExpireDateDialog.h
+++ b/src/ui/keypair_details/KeySetExpireDateDialog.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,28 +8,30 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef GPGFRONTEND_KEYSETEXPIREDATEDIALOG_H
#define GPGFRONTEND_KEYSETEXPIREDATEDIALOG_H
-#include "gpg/GpgContext.h"
-#include "gpg/model/GpgKey.h"
-#include "gpg/model/GpgSubKey.h"
+#include "core/GpgContext.h"
+#include "core/model/GpgKey.h"
+#include "core/model/GpgSubKey.h"
#include "ui/GpgFrontendUI.h"
class Ui_ModifiedExpirationDateTime;
@@ -37,25 +41,56 @@ namespace GpgFrontend::UI {
class KeySetExpireDateDialog : public QDialog {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Key Set Expire Date Dialog object
+ *
+ * @param key_id
+ * @param parent
+ */
explicit KeySetExpireDateDialog(const KeyId& key_id,
QWidget* parent = nullptr);
+ /**
+ * @brief Construct a new Key Set Expire Date Dialog object
+ *
+ * @param key_id
+ * @param subkey_fpr
+ * @param parent
+ */
explicit KeySetExpireDateDialog(const KeyId& key_id, std::string subkey_fpr,
QWidget* parent = nullptr);
signals:
- void signalKeyExpireDateUpdated();
+ /**
+ * @brief
+ *
+ */
+ void SignalKeyExpireDateUpdated();
private:
+ /**
+ * @brief
+ *
+ */
void init();
- std::shared_ptr<Ui_ModifiedExpirationDateTime> ui;
- const GpgKey mKey;
- const SubkeyId mSubkey;
+ std::shared_ptr<Ui_ModifiedExpirationDateTime> ui_; ///<
+ const GpgKey m_key_; ///<
+ const SubkeyId m_subkey_; ///<
private slots:
- void slotConfirm();
- void slotNonExpiredChecked(int state);
+ /**
+ * @brief
+ *
+ */
+ void slot_confirm();
+
+ /**
+ * @brief
+ *
+ * @param state
+ */
+ void slot_non_expired_checked(int state);
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/keypair_details/KeyUIDSignDialog.cpp b/src/ui/keypair_details/KeyUIDSignDialog.cpp
index fff38383..2ed45512 100644
--- a/src/ui/keypair_details/KeyUIDSignDialog.cpp
+++ b/src/ui/keypair_details/KeyUIDSignDialog.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -24,67 +26,68 @@
#include "ui/keypair_details/KeyUIDSignDialog.h"
-#include "gpg/function/GpgKeyGetter.h"
-#include "gpg/function/GpgKeyManager.h"
+#include "core/function/gpg/GpgKeyGetter.h"
+#include "core/function/gpg/GpgKeyManager.h"
#include "ui/SignalStation.h"
namespace GpgFrontend::UI {
KeyUIDSignDialog::KeyUIDSignDialog(const GpgKey& key, UIDArgsListPtr uid,
QWidget* parent)
- : QDialog(parent), mUids(std::move(uid)), mKey(key) {
- const auto key_id = mKey.GetId();
- mKeyList = new KeyList(KeyMenuAbility::NONE, this);
- mKeyList->addListGroupTab(_("Signers"), KeyListRow::ONLY_SECRET_KEY,
- KeyListColumn::NAME | KeyListColumn::EmailAddress,
- [key_id](const GpgKey& key) -> bool {
- if (key.IsDisabled() ||
- !key.IsHasCertificationCapability() ||
- !key.IsHasMasterKey() || key.IsExpired() ||
- key.IsRevoked() || key_id == key.GetId())
- return false;
- else
- return true;
- });
- mKeyList->slotRefresh();
-
- signKeyButton = new QPushButton("Sign");
+ : QDialog(parent), m_uids_(std::move(uid)), m_key_(key) {
+ const auto key_id = m_key_.GetId();
+ m_key_list_ = new KeyList(KeyMenuAbility::NONE, this);
+ m_key_list_->AddListGroupTab(
+ _("Signers"), KeyListRow::ONLY_SECRET_KEY,
+ KeyListColumn::NAME | KeyListColumn::EmailAddress,
+ [key_id](const GpgKey& key) -> bool {
+ if (key.IsDisabled() || !key.IsHasCertificationCapability() ||
+ !key.IsHasMasterKey() || key.IsExpired() || key.IsRevoked() ||
+ key_id == key.GetId())
+ return false;
+ else
+ return true;
+ });
+ m_key_list_->SlotRefresh();
+
+ sign_key_button_ = new QPushButton("Sign");
/**
* A DateTime after 5 Years is recommend.
*/
- expiresEdit = new QDateTimeEdit(QDateTime::currentDateTime().addYears(5));
- expiresEdit->setMinimumDateTime(QDateTime::currentDateTime());
+ expires_edit_ = new QDateTimeEdit(QDateTime::currentDateTime().addYears(5));
+ expires_edit_->setMinimumDateTime(QDateTime::currentDateTime());
/**
* Note further that the OpenPGP protocol uses 32 bit values for timestamps
* and thus can only encode dates up to the year 2106.
*/
- expiresEdit->setMaximumDate(QDate(2106, 1, 1));
+ expires_edit_->setMaximumDate(QDate(2106, 1, 1));
- nonExpireCheck = new QCheckBox("Non Expired");
- nonExpireCheck->setTristate(false);
+ non_expire_check_ = new QCheckBox("Non Expired");
+ non_expire_check_->setTristate(false);
- connect(nonExpireCheck, &QCheckBox::stateChanged, this,
+ connect(non_expire_check_, &QCheckBox::stateChanged, this,
[this](int state) -> void {
if (state == 0)
- expiresEdit->setDisabled(false);
+ expires_edit_->setDisabled(false);
else
- expiresEdit->setDisabled(true);
+ expires_edit_->setDisabled(true);
});
auto layout = new QGridLayout();
auto timeLayout = new QGridLayout();
- layout->addWidget(mKeyList, 0, 0);
- layout->addWidget(signKeyButton, 2, 0, Qt::AlignRight);
+ layout->addWidget(m_key_list_, 0, 0);
+ layout->addWidget(sign_key_button_, 2, 0, Qt::AlignRight);
timeLayout->addWidget(new QLabel(_("Expire Date")), 0, 0);
- timeLayout->addWidget(expiresEdit, 0, 1);
- timeLayout->addWidget(nonExpireCheck, 0, 2);
+ timeLayout->addWidget(expires_edit_, 0, 1);
+ timeLayout->addWidget(non_expire_check_, 0, 2);
layout->addLayout(timeLayout, 1, 0);
- connect(signKeyButton, SIGNAL(clicked(bool)), this, SLOT(slotSignKey(bool)));
+ connect(sign_key_button_, &QPushButton::clicked, this,
+ &KeyUIDSignDialog::slot_sign_key);
this->setLayout(layout);
this->setModal(true);
@@ -93,26 +96,27 @@ KeyUIDSignDialog::KeyUIDSignDialog(const GpgKey& key, UIDArgsListPtr uid,
setAttribute(Qt::WA_DeleteOnClose, true);
- connect(this, SIGNAL(signalKeyUIDSignUpdate()), SignalStation::GetInstance(),
- SIGNAL(KeyDatabaseRefresh()));
+ connect(this, &KeyUIDSignDialog::SignalKeyUIDSignUpdate,
+ SignalStation::GetInstance(),
+ &SignalStation::SignalKeyDatabaseRefresh);
}
-void KeyUIDSignDialog::slotSignKey(bool clicked) {
+void KeyUIDSignDialog::slot_sign_key(bool clicked) {
LOG(INFO) << "Called";
// Set Signers
- auto key_ids = mKeyList->getChecked();
+ auto key_ids = m_key_list_->GetChecked();
auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids);
LOG(INFO) << "Key Info Got";
auto expires = std::make_unique<boost::posix_time::ptime>(
- boost::posix_time::from_time_t(expiresEdit->dateTime().toTime_t()));
+ boost::posix_time::from_time_t(expires_edit_->dateTime().toTime_t()));
LOG(INFO) << "Sign Start";
- for (const auto& uid : *mUids) {
+ for (const auto& uid : *m_uids_) {
LOG(INFO) << "Sign UID" << uid;
// Sign For mKey
- if (!GpgKeyManager::GetInstance().SignKey(mKey, *keys, uid, expires)) {
+ if (!GpgKeyManager::GetInstance().SignKey(m_key_, *keys, uid, expires)) {
QMessageBox::critical(
nullptr, _("Unsuccessful Operation"),
QString(_("Signature operation failed for UID %1")).arg(uid.c_str()));
@@ -122,7 +126,7 @@ void KeyUIDSignDialog::slotSignKey(bool clicked) {
QMessageBox::information(nullptr, _("Operation Complete"),
_("The signature operation of the UID is complete"));
this->close();
- emit signalKeyUIDSignUpdate();
+ emit SignalKeyUIDSignUpdate();
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/keypair_details/KeyUIDSignDialog.h b/src/ui/keypair_details/KeyUIDSignDialog.h
index 8a83977a..7c1cb58c 100644
--- a/src/ui/keypair_details/KeyUIDSignDialog.h
+++ b/src/ui/keypair_details/KeyUIDSignDialog.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -25,7 +27,7 @@
#ifndef GPGFRONTEND_KEYUIDSIGNDIALOG_H
#define GPGFRONTEND_KEYUIDSIGNDIALOG_H
-#include "gpg/GpgContext.h"
+#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
#include "ui/widgets/KeyList.h"
@@ -35,28 +37,39 @@ class KeyUIDSignDialog : public QDialog {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Key U I D Sign Dialog object
+ *
+ * @param key
+ * @param uid
+ * @param parent
+ */
explicit KeyUIDSignDialog(const GpgKey& key, UIDArgsListPtr uid,
QWidget* parent = nullptr);
signals:
- void signalKeyUIDSignUpdate();
+ /**
+ * @brief
+ *
+ */
+ void SignalKeyUIDSignUpdate();
private:
- KeyList* mKeyList;
-
- QPushButton* signKeyButton;
-
- QDateTimeEdit* expiresEdit;
+ KeyList* m_key_list_; ///<
+ QPushButton* sign_key_button_; ///<
+ QDateTimeEdit* expires_edit_; ///<
+ QCheckBox* non_expire_check_; ///<
+ UIDArgsListPtr m_uids_; ///<
- QCheckBox* nonExpireCheck;
-
- UIDArgsListPtr mUids;
-
- const GpgKey& mKey;
+ const GpgKey& m_key_; ///<
private slots:
-
- void slotSignKey(bool clicked);
+ /**
+ * @brief
+ *
+ * @param clicked
+ */
+ void slot_sign_key(bool clicked);
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/smtp/EmailListEditor.cpp b/src/ui/mail/EmailListEditor.cpp
index 49399f11..b5147115 100644
--- a/src/ui/smtp/EmailListEditor.cpp
+++ b/src/ui/mail/EmailListEditor.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -28,8 +32,8 @@
GpgFrontend::UI::EmailListEditor::EmailListEditor(const QString& email_list,
QWidget* parent)
- : QDialog(parent), ui(std::make_shared<Ui_EmailListEditorDialog>()) {
- ui->setupUi(this);
+ : QDialog(parent), ui_(std::make_shared<Ui_EmailListEditorDialog>()) {
+ ui_->setupUi(this);
QStringList email_string_list = email_list.split(';');
@@ -38,53 +42,53 @@ GpgFrontend::UI::EmailListEditor::EmailListEditor(const QString& email_list,
auto _recipient = recipient.trimmed();
if (check_email_address(_recipient)) {
auto item = new QListWidgetItem(_recipient);
- ui->emaillistWidget->addItem(item);
+ ui_->emaillistWidget->addItem(item);
item->setFlags(item->flags() | Qt::ItemIsEditable);
}
}
}
- connect(ui->addEmailAddressButton, &QPushButton::clicked, this, [=]() {
+ connect(ui_->addEmailAddressButton, &QPushButton::clicked, this, [=]() {
auto item = new QListWidgetItem("new email address");
- ui->emaillistWidget->addItem(item);
+ ui_->emaillistWidget->addItem(item);
item->setFlags(item->flags() | Qt::ItemIsEditable);
});
- connect(
- ui->actionDelete_Selected_Email_Address, &QAction::triggered, this,
- [=]() {
- const auto row_size = ui->emaillistWidget->count();
- for (int i = 0; i < row_size; i++) {
- auto item = ui->emaillistWidget->item(i);
- if (!item->isSelected()) continue;
- delete ui->emaillistWidget->takeItem(ui->emaillistWidget->row(item));
- break;
- }
- });
+ connect(ui_->actionDelete_Selected_Email_Address, &QAction::triggered, this,
+ [=]() {
+ const auto row_size = ui_->emaillistWidget->count();
+ for (int i = 0; i < row_size; i++) {
+ auto item = ui_->emaillistWidget->item(i);
+ if (!item->isSelected()) continue;
+ delete ui_->emaillistWidget->takeItem(
+ ui_->emaillistWidget->row(item));
+ break;
+ }
+ });
- ui->titleLabel->setText(_("Email List:"));
- ui->tipsLabel->setText(
+ ui_->titleLabel->setText(_("Email List:"));
+ ui_->tipsLabel->setText(
_("Tips: You can double-click the email address in the edit list, or "
"click the email to pop up the option menu."));
- ui->addEmailAddressButton->setText(_("Add An Email Address"));
+ ui_->addEmailAddressButton->setText(_("Add An Email Address"));
this->setWindowTitle(_("Email List Editor"));
- ui->actionDelete_Selected_Email_Address->setText(_("Delete"));
+ ui_->actionDelete_Selected_Email_Address->setText(_("Delete"));
- popupMenu = new QMenu(this);
- popupMenu->addAction(ui->actionDelete_Selected_Email_Address);
+ popup_menu_ = new QMenu(this);
+ popup_menu_->addAction(ui_->actionDelete_Selected_Email_Address);
this->exec();
}
bool GpgFrontend::UI::EmailListEditor::check_email_address(
const QString& email_address) {
- return re_email.match(email_address).hasMatch();
+ return re_email_.match(email_address).hasMatch();
}
-QString GpgFrontend::UI::EmailListEditor::getEmailList() {
+QString GpgFrontend::UI::EmailListEditor::GetEmailList() {
QString email_list;
- for (int i = 0; i < ui->emaillistWidget->count(); ++i) {
- QListWidgetItem* item = ui->emaillistWidget->item(i);
+ for (int i = 0; i < ui_->emaillistWidget->count(); ++i) {
+ QListWidgetItem* item = ui_->emaillistWidget->item(i);
if (check_email_address(item->text())) {
email_list.append(item->text());
email_list.append("; ");
@@ -96,7 +100,7 @@ QString GpgFrontend::UI::EmailListEditor::getEmailList() {
void GpgFrontend::UI::EmailListEditor::contextMenuEvent(
QContextMenuEvent* event) {
QWidget::contextMenuEvent(event);
- if (ui->emaillistWidget->selectedItems().length() > 0) {
- popupMenu->exec(event->globalPos());
+ if (ui_->emaillistWidget->selectedItems().length() > 0) {
+ popup_menu_->exec(event->globalPos());
}
}
diff --git a/src/ui/smtp/EmailListEditor.h b/src/ui/mail/EmailListEditor.h
index d4e476a4..b716ff66 100644
--- a/src/ui/smtp/EmailListEditor.h
+++ b/src/ui/mail/EmailListEditor.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -30,23 +34,50 @@
class Ui_EmailListEditorDialog;
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class EmailListEditor : public QDialog {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Email List Editor object
+ *
+ * @param email_list
+ * @param parent
+ */
explicit EmailListEditor(const QString& email_list, QWidget* parent);
- QString getEmailList();
- private:
- std::shared_ptr<Ui_EmailListEditorDialog> ui;
- QMenu* popupMenu{};
+ /**
+ * @brief Get the Email List object
+ *
+ * @return QString
+ */
+ QString GetEmailList();
- QRegularExpression re_email{
+ private:
+ std::shared_ptr<Ui_EmailListEditorDialog> ui_; ///<
+ QMenu* popup_menu_{}; ///<
+ QRegularExpression re_email_{
R"((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))"};
+ /**
+ * @brief
+ *
+ * @param email_address
+ * @return true
+ * @return false
+ */
bool check_email_address(const QString& email_address);
protected:
+ /**
+ * @brief
+ *
+ * @param event
+ */
void contextMenuEvent(QContextMenuEvent* event) override;
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/smtp/IMAPFolder.cpp b/src/ui/mail/IMAPFolder.cpp
index 446b1bea..68a894f7 100644
--- a/src/ui/smtp/IMAPFolder.cpp
+++ b/src/ui/mail/IMAPFolder.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -76,7 +80,6 @@ GpgFrontend::UI::IMAPFolder::IMAPFolder(
tree_node_->setText(0, folder_name.c_str());
else
tree_node_->setIcon(0, QIcon(":server.png"));
-
}
void GpgFrontend::UI::IMAPFolder::SetParentFolder(IMAPFolder *parent_folder) {
diff --git a/src/ui/smtp/IMAPFolder.h b/src/ui/mail/IMAPFolder.h
index 255f3d71..8d09eb94 100644
--- a/src/ui/smtp/IMAPFolder.h
+++ b/src/ui/mail/IMAPFolder.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef GPGFRONTEND_IMAPFOLDER_H
@@ -31,19 +35,43 @@ class folder;
};
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class IMAPFolder {
public:
+ /**
+ * @brief Construct a new IMAPFolder object
+ *
+ * @param folder
+ */
explicit IMAPFolder(std::shared_ptr<vmime::net::folder> folder);
+ /**
+ * @brief Set the Parent Folder object
+ *
+ * @param parent_node
+ */
void SetParentFolder(IMAPFolder* parent_node);
+ /**
+ * @brief Get the Tree Widget Item object
+ *
+ * @return QTreeWidgetItem*
+ */
QTreeWidgetItem* GetTreeWidgetItem();
+ /**
+ * @brief Get the Vmime Folder object
+ *
+ * @return vmime::net::folder*
+ */
vmime::net::folder* GetVmimeFolder();
private:
- std::shared_ptr<vmime::net::folder> folder_;
- QTreeWidgetItem* tree_node_;
+ std::shared_ptr<vmime::net::folder> folder_; ///<
+ QTreeWidgetItem* tree_node_; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/smtp/ReceiveMailDialog.cpp b/src/ui/mail/ReceiveMailDialog.cpp
index 81d8ccd8..765e8baa 100644
--- a/src/ui/smtp/ReceiveMailDialog.cpp
+++ b/src/ui/mail/ReceiveMailDialog.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -27,11 +31,11 @@
#include "ui_ReceiveMailDialog.h"
GpgFrontend::UI::ReceiveMailDialog::ReceiveMailDialog(QWidget *parent)
- : QDialog(parent), ui(std::make_shared<Ui_ReceiveMailDialog>()) {
- ui->setupUi(this);
+ : QDialog(parent), ui_(std::make_shared<Ui_ReceiveMailDialog>()) {
+ ui_->setupUi(this);
}
-void GpgFrontend::UI::ReceiveMailDialog::slotRefreshData() {}
+void GpgFrontend::UI::ReceiveMailDialog::slot_refresh_data() {}
void GpgFrontend::UI::ReceiveMailDialog::list_sub_folders(
GpgFrontend::UI::IMAPFolder *parent_folder,
diff --git a/src/ui/smtp/ReceiveMailDialog.h b/src/ui/mail/ReceiveMailDialog.h
index 9dc6088c..2ccb2664 100644
--- a/src/ui/smtp/ReceiveMailDialog.h
+++ b/src/ui/mail/ReceiveMailDialog.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -37,21 +41,38 @@ namespace GpgFrontend::UI {
class IMAPFolder;
+/**
+ * @brief
+ *
+ */
class ReceiveMailDialog : public QDialog {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Receive Mail Dialog object
+ *
+ * @param parent
+ */
explicit ReceiveMailDialog(QWidget* parent);
private slots:
- void slotRefreshData();
+ /**
+ * @brief
+ *
+ */
+ void slot_refresh_data();
private:
- std::shared_ptr<Ui_ReceiveMailDialog> ui;
+ std::shared_ptr<Ui_ReceiveMailDialog> ui_; ///<
+ std::vector<std::shared_ptr<IMAPFolder>> folders_; ///<
+ /**
+ * @brief
+ *
+ * @param parent_folder
+ */
void list_sub_folders(IMAPFolder* parent_folder,
const std::shared_ptr<vmime::net::folder>&);
-
- std::vector<std::shared_ptr<IMAPFolder>> folders;
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/smtp/RecipientsPicker.cpp b/src/ui/mail/RecipientsPicker.cpp
index 47c9808b..d6b8bcc5 100644
--- a/src/ui/smtp/RecipientsPicker.cpp
+++ b/src/ui/mail/RecipientsPicker.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -30,23 +34,23 @@ GpgFrontend::UI::RecipientsPicker::RecipientsPicker(
const GpgFrontend::KeyIdArgsListPtr& current_key_ids, QWidget* parent)
: QDialog(parent) {
auto confirm_button = new QPushButton(_("Confirm"));
- connect(confirm_button, SIGNAL(clicked(bool)), this, SLOT(accept()));
+ connect(confirm_button,&QPushButton::clicked, this, &RecipientsPicker::accept);
// Setup KeyList
key_list_ = new KeyList(KeyMenuAbility::NONE, this);
- key_list_->addListGroupTab(
+ key_list_->AddListGroupTab(
_("Recipient(s)"), KeyListRow::SECRET_OR_PUBLIC_KEY,
KeyListColumn::NAME | KeyListColumn::EmailAddress,
[](const GpgKey& key) -> bool {
return !key.IsPrivateKey() && key.IsHasActualEncryptionCapability();
});
- key_list_->slotRefresh();
+ key_list_->SlotRefresh();
auto key_ids = std::make_unique<GpgFrontend::KeyIdArgsList>();
for (const auto& key_id : *current_key_ids) {
key_ids->push_back(key_id);
}
- key_list_->setChecked(std::move(key_ids));
+ key_list_->SetChecked(std::move(key_ids));
auto* vbox2 = new QVBoxLayout();
vbox2->addWidget(new QLabel(QString(_("Select Recipient(s)")) + ": "));
@@ -71,6 +75,6 @@ GpgFrontend::UI::RecipientsPicker::RecipientsPicker(
}
GpgFrontend::KeyIdArgsListPtr
-GpgFrontend::UI::RecipientsPicker::getCheckedRecipients() {
- return key_list_->getChecked();
+GpgFrontend::UI::RecipientsPicker::GetCheckedRecipients() {
+ return key_list_->GetChecked();
}
diff --git a/src/ui/smtp/RecipientsPicker.h b/src/ui/mail/RecipientsPicker.h
index bf128149..252bbd58 100644
--- a/src/ui/smtp/RecipientsPicker.h
+++ b/src/ui/mail/RecipientsPicker.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -31,18 +35,33 @@ namespace GpgFrontend::UI {
class KeyList;
+/**
+ * @brief
+ *
+ */
class RecipientsPicker : public QDialog {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Recipients Picker object
+ *
+ * @param current_key_ids
+ * @param parent
+ */
explicit RecipientsPicker(
const GpgFrontend::KeyIdArgsListPtr& current_key_ids,
QWidget* parent = nullptr);
- GpgFrontend::KeyIdArgsListPtr getCheckedRecipients();
+ /**
+ * @brief Get the Checked Recipients object
+ *
+ * @return GpgFrontend::KeyIdArgsListPtr
+ */
+ GpgFrontend::KeyIdArgsListPtr GetCheckedRecipients();
private:
- KeyList* key_list_;
+ KeyList* key_list_; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/smtp/SendMailDialog.cpp b/src/ui/mail/SendMailDialog.cpp
index 18c8beb1..137c941f 100644
--- a/src/ui/smtp/SendMailDialog.cpp
+++ b/src/ui/mail/SendMailDialog.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,41 +8,43 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include "SendMailDialog.h"
-#include "gpg/function/GpgKeyGetter.h"
-#include "ui/smtp/EmailListEditor.h"
-#include "ui/smtp/RecipientsPicker.h"
-#include "ui/smtp/SenderPicker.h"
+#include "core/function/gpg/GpgKeyGetter.h"
+#include "ui/mail/EmailListEditor.h"
+#include "ui/mail/RecipientsPicker.h"
+#include "ui/mail/SenderPicker.h"
#include "ui_SendMailDialog.h"
#ifdef SMTP_SUPPORT
-#include "ui/settings/GlobalSettingStation.h"
+#include "core/function/GlobalSettingStation.h"
#include "ui/thread/SMTPSendMailThread.h"
#endif
namespace GpgFrontend::UI {
SendMailDialog::SendMailDialog(const QString& text, QWidget* parent)
- : QDialog(parent), ui(std::make_shared<Ui_SendMailDialog>()) {
+ : QDialog(parent), ui_(std::make_shared<Ui_SendMailDialog>()) {
// read from settings
- initSettings();
+ init_settings();
if (smtp_address_.isEmpty()) {
QMessageBox::critical(
@@ -52,18 +56,18 @@ SendMailDialog::SendMailDialog(const QString& text, QWidget* parent)
return;
}
- ui->setupUi(this);
+ ui_->setupUi(this);
- ui->ccInputWidget->setHidden(true);
- ui->bccInputWidget->setHidden(true);
- ui->textEdit->setText(text);
- ui->errorLabel->setHidden(true);
+ ui_->ccInputWidget->setHidden(true);
+ ui_->bccInputWidget->setHidden(true);
+ ui_->textEdit->setText(text);
+ ui_->errorLabel->setHidden(true);
- ui->senderEdit->setText(default_sender_);
+ ui_->senderEdit->setText(default_sender_);
- if (!default_sender_gpg_key_id.isEmpty()) {
+ if (!default_sender_gpg_key_id_.isEmpty()) {
auto key = GpgKeyGetter::GetInstance().GetKey(
- default_sender_gpg_key_id.toStdString());
+ default_sender_gpg_key_id_.toStdString());
if (key.IsGood() && key.IsPrivateKey() &&
key.IsHasActualSigningCapability()) {
sender_key_id_ = key.GetId();
@@ -71,69 +75,69 @@ SendMailDialog::SendMailDialog(const QString& text, QWidget* parent)
}
}
- connect(ui->ccButton, &QPushButton::clicked, [=]() {
- ui->ccInputWidget->setHidden(!ui->ccInputWidget->isHidden());
- ui->ccEdit->clear();
+ connect(ui_->ccButton, &QPushButton::clicked, [=]() {
+ ui_->ccInputWidget->setHidden(!ui_->ccInputWidget->isHidden());
+ ui_->ccEdit->clear();
});
- connect(ui->bccButton, &QPushButton::clicked, [=]() {
- ui->bccInputWidget->setHidden(!ui->bccInputWidget->isHidden());
- ui->bccEdit->clear();
+ connect(ui_->bccButton, &QPushButton::clicked, [=]() {
+ ui_->bccInputWidget->setHidden(!ui_->bccInputWidget->isHidden());
+ ui_->bccEdit->clear();
});
#ifdef SMTP_SUPPORT
- connect(ui->sendMailButton, &QPushButton::clicked, this,
- &SendMailDialog::slotConfirm);
+ connect(ui_->sendMailButton, &QPushButton::clicked, this,
+ &SendMailDialog::slot_confirm);
#endif
- connect(ui->senderKeySelectButton, &QPushButton::clicked, this, [=]() {
+ connect(ui_->senderKeySelectButton, &QPushButton::clicked, this, [=]() {
auto picker = new SenderPicker(sender_key_id_, this);
- sender_key_id_ = picker->getCheckedSender();
+ sender_key_id_ = picker->GetCheckedSender();
set_sender_value_label();
});
- connect(ui->recipientKeySelectButton, &QPushButton::clicked, this, [=]() {
+ connect(ui_->recipientKeySelectButton, &QPushButton::clicked, this, [=]() {
auto picker = new RecipientsPicker(recipients_key_ids_, this);
- recipients_key_ids_ = picker->getCheckedRecipients();
+ recipients_key_ids_ = picker->GetCheckedRecipients();
set_recipients_value_label();
});
- connect(ui->recipientsEditButton, &QPushButton::clicked, this, [=]() {
- auto editor = new EmailListEditor(ui->recipientEdit->text(), this);
- ui->recipientEdit->setText(editor->getEmailList());
+ connect(ui_->recipientsEditButton, &QPushButton::clicked, this, [=]() {
+ auto editor = new EmailListEditor(ui_->recipientEdit->text(), this);
+ ui_->recipientEdit->setText(editor->GetEmailList());
});
- connect(ui->ccEditButton, &QPushButton::clicked, this, [=]() {
- auto editor = new EmailListEditor(ui->ccEdit->text(), this);
- ui->ccEdit->setText(editor->getEmailList());
+ connect(ui_->ccEditButton, &QPushButton::clicked, this, [=]() {
+ auto editor = new EmailListEditor(ui_->ccEdit->text(), this);
+ ui_->ccEdit->setText(editor->GetEmailList());
});
- connect(ui->bccEditButton, &QPushButton::clicked, this, [=]() {
- auto editor = new EmailListEditor(ui->bccEdit->text(), this);
- ui->bccEdit->setText(editor->getEmailList());
+ connect(ui_->bccEditButton, &QPushButton::clicked, this, [=]() {
+ auto editor = new EmailListEditor(ui_->bccEdit->text(), this);
+ ui_->bccEdit->setText(editor->GetEmailList());
});
- ui->ccButton->setText(_("CC"));
- ui->bccButton->setText(_("BCC"));
- ui->senderLabel->setText(_("Sender"));
- ui->recipientLabel->setText(_("Recipient"));
- ui->subjectLabel->setText(_("Mail Subject"));
- ui->bccLabel->setText(_("BCC"));
- ui->ccLabel->setText(_("CC"));
- ui->tipsLabel->setText(
+ ui_->ccButton->setText(_("CC"));
+ ui_->bccButton->setText(_("BCC"));
+ ui_->senderLabel->setText(_("Sender"));
+ ui_->recipientLabel->setText(_("Recipient"));
+ ui_->subjectLabel->setText(_("Mail Subject"));
+ ui_->bccLabel->setText(_("BCC"));
+ ui_->ccLabel->setText(_("CC"));
+ ui_->tipsLabel->setText(
_("Tips: You can fill in multiple email addresses, please separate them "
"with \";\"."));
- ui->sendMailButton->setText(_("Send Message"));
- ui->senderKeySelectButton->setText(_("Select Sender GPG Key"));
- ui->recipientKeySelectButton->setText(_("Select Recipient(s) GPG Key"));
- ui->gpgOperaLabel->setText(_("GPG Operations"));
- ui->attacSignatureCheckBox->setText(_("Attach signature"));
- ui->attachSenderPublickeyCheckBox->setText(_("Attach sender's public key"));
- ui->contentEncryptCheckBox->setText(_("Encrypt content"));
- ui->recipientsEditButton->setText(_("Edit Recipients(s)"));
- ui->ccEditButton->setText(_("Edit CC(s)"));
- ui->bccEditButton->setText(_("Edit BCC(s)"));
- ui->senderKeyLabel->setText(_("Sender GPG Key: "));
- ui->recipientKeysLabel->setText(_("Recipient(s) GPG Key: "));
+ ui_->sendMailButton->setText(_("Send Message"));
+ ui_->senderKeySelectButton->setText(_("Select Sender GPG Key"));
+ ui_->recipientKeySelectButton->setText(_("Select Recipient(s) GPG Key"));
+ ui_->gpgOperaLabel->setText(_("GPG Operations"));
+ ui_->attacSignatureCheckBox->setText(_("Attach signature"));
+ ui_->attachSenderPublickeyCheckBox->setText(_("Attach sender's public key"));
+ ui_->contentEncryptCheckBox->setText(_("Encrypt content"));
+ ui_->recipientsEditButton->setText(_("Edit Recipients(s)"));
+ ui_->ccEditButton->setText(_("Edit CC(s)"));
+ ui_->bccEditButton->setText(_("Edit BCC(s)"));
+ ui_->senderKeyLabel->setText(_("Sender GPG Key: "));
+ ui_->recipientKeysLabel->setText(_("Recipient(s) GPG Key: "));
auto pos = QPoint(100, 100);
LOG(INFO) << "parent" << parent;
@@ -147,18 +151,18 @@ SendMailDialog::SendMailDialog(const QString& text, QWidget* parent)
}
bool SendMailDialog::check_email_address(const QString& str) {
- return re_email.match(str).hasMatch();
+ return re_email_.match(str).hasMatch();
}
#ifdef SMTP_SUPPORT
-void SendMailDialog::slotConfirm() {
+void SendMailDialog::slot_confirm() {
QString errString;
- ui->errorLabel->clear();
- ui->errorLabel->setHidden(true);
- QStringList rcpt_string_list = ui->recipientEdit->text().split(';');
- QStringList cc_string_list = ui->ccEdit->text().split(';');
- QStringList bcc_string_list = ui->bccEdit->text().split(';');
+ ui_->errorLabel->clear();
+ ui_->errorLabel->setHidden(true);
+ QStringList rcpt_string_list = ui_->recipientEdit->text().split(';');
+ QStringList cc_string_list = ui_->ccEdit->text().split(';');
+ QStringList bcc_string_list = ui_->bccEdit->text().split(';');
if (rcpt_string_list.isEmpty()) {
errString.append(QString(" ") + _("Recipient cannot be empty") + " \n");
@@ -173,17 +177,17 @@ void SendMailDialog::slotConfirm() {
}
}
}
- if (ui->senderEdit->text().isEmpty()) {
+ if (ui_->senderEdit->text().isEmpty()) {
errString.append(QString(" ") + _("Sender cannot be empty") + " \n");
- } else if (!check_email_address(ui->senderEdit->text())) {
+ } else if (!check_email_address(ui_->senderEdit->text())) {
errString.append(QString(" ") + _("Sender's email is invalid") + " \n");
}
- if (ui->subjectEdit->text().isEmpty()) {
+ if (ui_->subjectEdit->text().isEmpty()) {
errString.append(QString(" ") + _("Subject cannot be empty") + " \n");
}
- if (!ui->ccEdit->text().isEmpty())
+ if (!ui_->ccEdit->text().isEmpty())
for (const auto& cc : cc_string_list) {
LOG(INFO) << "cc" << cc.trimmed().toStdString();
if (!check_email_address(cc.trimmed())) {
@@ -193,7 +197,7 @@ void SendMailDialog::slotConfirm() {
}
}
- if (!ui->bccEdit->text().isEmpty())
+ if (!ui_->bccEdit->text().isEmpty())
for (const auto& bcc : bcc_string_list) {
LOG(INFO) << "bcc" << bcc.trimmed().toStdString();
if (!check_email_address(bcc.trimmed())) {
@@ -204,12 +208,12 @@ void SendMailDialog::slotConfirm() {
}
if (!errString.isEmpty()) {
- ui->errorLabel->setAutoFillBackground(true);
- QPalette error = ui->errorLabel->palette();
+ ui_->errorLabel->setAutoFillBackground(true);
+ QPalette error = ui_->errorLabel->palette();
error.setColor(QPalette::Window, "#ff8080");
- ui->errorLabel->setPalette(error);
- ui->errorLabel->setText(errString);
- ui->errorLabel->setHidden(false);
+ ui_->errorLabel->setPalette(error);
+ ui_->errorLabel->setText(errString);
+ ui_->errorLabel->setHidden(false);
return;
}
@@ -232,19 +236,19 @@ void SendMailDialog::slotConfirm() {
bool identity_needed = identity_enable_;
auto username = username_.toStdString();
auto password = password_.toStdString();
- auto sender_address = ui->senderEdit->text().toStdString();
+ auto sender_address = ui_->senderEdit->text().toStdString();
auto thread = new SMTPSendMailThread(
host, port, connection_type, identity_needed, username, password, this);
- thread->setSender(ui->senderEdit->text());
- thread->setRecipient(ui->recipientEdit->text());
- thread->setCC(ui->ccEdit->text());
- thread->setBCC(ui->bccEdit->text());
- thread->setSubject(ui->subjectEdit->text());
- thread->addTextContent(ui->textEdit->toPlainText());
+ thread->SetSender(ui_->senderEdit->text());
+ thread->SetRecipient(ui_->recipientEdit->text());
+ thread->SetCC(ui_->ccEdit->text());
+ thread->SetBCC(ui_->bccEdit->text());
+ thread->SetSubject(ui_->subjectEdit->text());
+ thread->AddTextContent(ui_->textEdit->toPlainText());
- if (ui->contentEncryptCheckBox->checkState() == Qt::Checked) {
+ if (ui_->contentEncryptCheckBox->checkState() == Qt::Checked) {
if (recipients_key_ids_ == nullptr || recipients_key_ids_->empty()) {
QMessageBox::critical(
this, _("Forbidden"),
@@ -256,11 +260,11 @@ void SendMailDialog::slotConfirm() {
auto key_ids = std::make_unique<KeyIdArgsList>();
for (const auto& key_id : *recipients_key_ids_)
key_ids->push_back(key_id);
- thread->setEncryptContent(true, std::move(key_ids));
+ thread->SetEncryptContent(true, std::move(key_ids));
}
}
- if (ui->attacSignatureCheckBox->checkState() == Qt::Checked) {
+ if (ui_->attacSignatureCheckBox->checkState() == Qt::Checked) {
if (sender_key_id_.empty()) {
QMessageBox::critical(
this, _("Forbidden"),
@@ -270,11 +274,11 @@ void SendMailDialog::slotConfirm() {
"operation is prohibited."));
return;
} else {
- thread->setAttachSignatureFile(true, sender_key_id_);
+ thread->SetAttachSignatureFile(true, sender_key_id_);
}
}
- if (ui->attachSenderPublickeyCheckBox->checkState() == Qt::Checked) {
+ if (ui_->attachSenderPublickeyCheckBox->checkState() == Qt::Checked) {
if (sender_key_id_.empty()) {
QMessageBox::critical(
this, _("Forbidden"),
@@ -285,7 +289,7 @@ void SendMailDialog::slotConfirm() {
"with your expectations, so the operation is prohibited."));
return;
} else {
- thread->setAttachPublicKey(true, sender_key_id_);
+ thread->SetAttachPublicKey(true, sender_key_id_);
}
}
@@ -300,8 +304,8 @@ void SendMailDialog::slotConfirm() {
waiting_dialog_label->setWordWrap(true);
waiting_dialog->setLabel(waiting_dialog_label);
waiting_dialog->resize(420, 120);
- connect(thread, &SMTPSendMailThread::signalSMTPResult, this,
- &SendMailDialog::slotTestSMTPConnectionResult);
+ connect(thread, &SMTPSendMailThread::SignalSMTPResult, this,
+ &SendMailDialog::slot_test_smtp_connection_result);
connect(thread, &QThread::finished, [=]() {
waiting_dialog->finished(0);
waiting_dialog->deleteLater();
@@ -321,7 +325,7 @@ void SendMailDialog::slotConfirm() {
loop.exec();
}
-void SendMailDialog::initSettings() {
+void SendMailDialog::init_settings() {
auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
try {
@@ -373,7 +377,7 @@ void SendMailDialog::initSettings() {
}
try {
- default_sender_gpg_key_id =
+ default_sender_gpg_key_id_ =
settings.lookup("smtp.default_sender_gpg_key_id").c_str();
} catch (...) {
LOG(ERROR) << _("Setting Operation Error")
@@ -385,7 +389,7 @@ void SendMailDialog::initSettings() {
void SendMailDialog::set_sender_value_label() {
auto key = GpgKeyGetter::GetInstance().GetKey(sender_key_id_);
if (key.IsGood()) {
- ui->senderKeyValueLabel->setText(key.GetUIDs()->front().GetUID().c_str());
+ ui_->senderKeyValueLabel->setText(key.GetUIDs()->front().GetUID().c_str());
}
}
@@ -397,10 +401,10 @@ void SendMailDialog::set_recipients_value_label() {
ss << key.GetUIDs()->front().GetUID().c_str() << ";";
}
}
- ui->recipientsKeyValueLabel->setText(ss.str().c_str());
+ ui_->recipientsKeyValueLabel->setText(ss.str().c_str());
}
-void SendMailDialog::slotTestSMTPConnectionResult(const QString& result) {
+void SendMailDialog::slot_test_smtp_connection_result(const QString& result) {
if (result == "Fail to connect SMTP server") {
QMessageBox::critical(this, _("Fail"), _("Fail to Connect SMTP Server."));
} else if (result == "Fail to login") {
@@ -424,12 +428,12 @@ void SendMailDialog::slotTestSMTPConnectionResult(const QString& result) {
QMessageBox::critical(this, _("Fail"), _("Unknown error."));
}
}
-void SendMailDialog::setContentEncryption(bool on) {
- ui->contentEncryptCheckBox->setCheckState(on ? Qt::Checked : Qt::Unchecked);
+void SendMailDialog::SetContentEncryption(bool on) {
+ ui_->contentEncryptCheckBox->setCheckState(on ? Qt::Checked : Qt::Unchecked);
}
-void SendMailDialog::setAttachSignature(bool on) {
- ui->attacSignatureCheckBox->setCheckState(on ? Qt::Checked : Qt::Unchecked);
+void SendMailDialog::SetAttachSignature(bool on) {
+ ui_->attacSignatureCheckBox->setCheckState(on ? Qt::Checked : Qt::Unchecked);
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/mail/SendMailDialog.h b/src/ui/mail/SendMailDialog.h
new file mode 100644
index 00000000..3d745e11
--- /dev/null
+++ b/src/ui/mail/SendMailDialog.h
@@ -0,0 +1,132 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#ifndef GPGFRONTEND_SENDMAILDIALOG_H
+#define GPGFRONTEND_SENDMAILDIALOG_H
+
+#include "ui/GpgFrontendUI.h"
+
+class Ui_SendMailDialog;
+
+namespace GpgFrontend::UI {
+
+/**
+ * @brief
+ *
+ */
+class SendMailDialog : public QDialog {
+ Q_OBJECT
+ public:
+ /**
+ * @brief Construct a new Send Mail Dialog object
+ *
+ * @param text
+ * @param parent
+ */
+ explicit SendMailDialog(const QString& text, QWidget* parent = nullptr);
+
+ /**
+ * @brief Set the Content Encryption object
+ *
+ * @param on
+ */
+ void SetContentEncryption(bool on);
+
+ /**
+ * @brief Set the Attach Signature object
+ *
+ * @param on
+ */
+ void SetAttachSignature(bool on);
+
+ private slots:
+
+ /**
+ * @brief
+ *
+ */
+ void slot_confirm();
+
+ /**
+ * @brief
+ *
+ * @param result
+ */
+ void slot_test_smtp_connection_result(const QString& result);
+
+ private:
+ /**
+ * @brief
+ *
+ */
+ void init_settings();
+
+ std::shared_ptr<Ui_SendMailDialog> ui_; ///<
+
+ bool ability_enable_ = false; ///<
+ bool identity_enable_ = false; ///<
+ QString smtp_address_; ///<
+ QString username_; ///<
+ QString password_; ///<
+ QString default_sender_; ///<
+ QString connection_type_settings_ = "None"; ///<
+ QString default_sender_gpg_key_id_ = {}; ///<
+ int port_ = 25; ///<
+
+ GpgFrontend::KeyId sender_key_id_; ///<
+ GpgFrontend::KeyIdArgsListPtr recipients_key_ids_ =
+ std::make_unique<GpgFrontend::KeyIdArgsList>(); ///<
+
+ QRegularExpression re_email_{
+ R"((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))"};
+
+ /**
+ * @brief
+ *
+ * @param str
+ * @return true
+ * @return false
+ */
+ bool check_email_address(const QString& str);
+
+ /**
+ * @brief Set the sender value label object
+ *
+ */
+ void set_sender_value_label();
+
+ /**
+ * @brief Set the recipients value label object
+ *
+ */
+ void set_recipients_value_label();
+};
+
+} // namespace GpgFrontend::UI
+
+#endif // GPGFRONTEND_SENDMAILDIALOG_H
diff --git a/src/ui/smtp/SenderPicker.cpp b/src/ui/mail/SenderPicker.cpp
index b2ad7f9f..e3563480 100644
--- a/src/ui/smtp/SenderPicker.cpp
+++ b/src/ui/mail/SenderPicker.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -30,20 +34,20 @@ GpgFrontend::UI::SenderPicker::SenderPicker(const KeyId& current_key_id,
QWidget* parent)
: QDialog(parent) {
auto confirm_button = new QPushButton(_("Confirm"));
- connect(confirm_button, SIGNAL(clicked(bool)), this, SLOT(accept()));
+ connect(confirm_button, &QPushButton::clicked, this, &SenderPicker::accept);
// Setup KeyList
key_list_ = new KeyList(KeyMenuAbility::NONE, this);
- key_list_->addListGroupTab(_("Sender"), KeyListRow::ONLY_SECRET_KEY,
+ key_list_->AddListGroupTab(_("Sender"), KeyListRow::ONLY_SECRET_KEY,
KeyListColumn::NAME | KeyListColumn::EmailAddress,
[](const GpgKey& key) -> bool {
return key.IsHasActualSigningCapability();
});
- key_list_->slotRefresh();
+ key_list_->SlotRefresh();
auto key_ids = std::make_unique<GpgFrontend::KeyIdArgsList>();
key_ids->push_back(current_key_id);
- key_list_->setChecked(std::move(key_ids));
+ key_list_->SetChecked(std::move(key_ids));
auto* vbox2 = new QVBoxLayout();
vbox2->addWidget(new QLabel(QString(_("Select Sender")) + ": "));
@@ -67,10 +71,10 @@ GpgFrontend::UI::SenderPicker::SenderPicker(const KeyId& current_key_id,
this->exec();
}
-GpgFrontend::KeyId GpgFrontend::UI::SenderPicker::getCheckedSender() {
- auto checked_keys = key_list_->getChecked();
+GpgFrontend::KeyId GpgFrontend::UI::SenderPicker::GetCheckedSender() {
+ auto checked_keys = key_list_->GetChecked();
if (!checked_keys->empty()) {
- return key_list_->getChecked()->front();
+ return key_list_->GetChecked()->front();
} else {
return {};
}
diff --git a/src/ui/smtp/SenderPicker.h b/src/ui/mail/SenderPicker.h
index 3745bb34..ce8cd8e6 100644
--- a/src/ui/smtp/SenderPicker.h
+++ b/src/ui/mail/SenderPicker.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -31,16 +35,31 @@ namespace GpgFrontend::UI {
class KeyList;
+/**
+ * @brief
+ *
+ */
class SenderPicker : public QDialog {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Sender Picker object
+ *
+ * @param current_key_id
+ * @param parent
+ */
explicit SenderPicker(const KeyId& current_key_id, QWidget* parent = nullptr);
- GpgFrontend::KeyId getCheckedSender();
+ /**
+ * @brief Get the Checked Sender object
+ *
+ * @return GpgFrontend::KeyId
+ */
+ GpgFrontend::KeyId GetCheckedSender();
private:
- KeyList* key_list_;
+ KeyList* key_list_; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/MainWindow.cpp b/src/ui/main_window/MainWindow.cpp
index 2cab0f38..368c5630 100644
--- a/src/ui/MainWindow.cpp
+++ b/src/ui/main_window/MainWindow.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -28,9 +32,9 @@
#ifdef RELEASE
#include "ui/thread/VersionCheckThread.h"
#endif
+#include "core/function/GlobalSettingStation.h"
#include "ui/SignalStation.h"
-#include "ui/data_struct/SettingsObject.h"
-#include "ui/settings/GlobalSettingStation.h"
+#include "ui/struct/SettingsObject.h"
namespace GpgFrontend::UI {
@@ -39,66 +43,65 @@ MainWindow::MainWindow() {
this->setWindowTitle(qApp->applicationName());
}
-void MainWindow::init() noexcept {
+void MainWindow::Init() noexcept {
try {
- networkAccessManager = new QNetworkAccessManager(this);
-
/* get path where app was started */
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
- edit = new TextEdit(this);
- setCentralWidget(edit);
+ edit_ = new TextEdit(this);
+ setCentralWidget(edit_);
/* the list of Keys available*/
- mKeyList = new KeyList(
+ m_key_list_ = new KeyList(
KeyMenuAbility::REFRESH | KeyMenuAbility::UNCHECK_ALL, this);
- infoBoard = new InfoBoardWidget(this);
+ info_board_ = new InfoBoardWidget(this);
/* List of binary Attachments */
- attachmentDockCreated = false;
+ attachment_dock_created_ = false;
/* Variable containing if restart is needed */
- this->slotSetRestartNeeded(false);
+ this->SlotSetRestartNeeded(false);
- createActions();
- createMenus();
- createToolBars();
- createStatusBar();
- createDockWindows();
+ create_actions();
+ create_menus();
+ create_tool_bars();
+ create_status_bar();
+ create_dock_windows();
- connect(edit->tabWidget, SIGNAL(currentChanged(int)), this,
- SLOT(slotDisableTabActions(int)));
+ connect(edit_->tab_widget_, &QTabWidget::currentChanged, this,
+ &MainWindow::slot_disable_tab_actions);
connect(SignalStation::GetInstance(),
- &SignalStation::signalRefreshStatusBar, this,
- [=](const QString& message, int timeout) {
+ &SignalStation::SignalRefreshStatusBar, this,
+ [=](const QString &message, int timeout) {
statusBar()->showMessage(message, timeout);
});
- mKeyList->addMenuAction(appendSelectedKeysAct);
- mKeyList->addMenuAction(copyMailAddressToClipboardAct);
- mKeyList->addSeparator();
- mKeyList->addMenuAction(showKeyDetailsAct);
+ m_key_list_->AddMenuAction(append_selected_keys_act_);
+ m_key_list_->AddMenuAction(copy_mail_address_to_clipboard_act_);
+ m_key_list_->AddSeparator();
+ m_key_list_->AddMenuAction(show_key_details_act_);
- restoreSettings();
+ restore_settings();
// open filename if provided as first command line parameter
QStringList args = qApp->arguments();
if (args.size() > 1) {
if (!args[1].startsWith("-")) {
- if (QFile::exists(args[1])) edit->loadFile(args[1]);
+ if (QFile::exists(args[1]))
+ edit_->LoadFile(args[1]);
}
}
- edit->curTextPage()->setFocus();
+ edit_->CurTextPage()->setFocus();
- auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ auto &settings = GlobalSettingStation::GetInstance().GetUISettings();
if (!settings.exists("wizard") ||
settings.lookup("wizard").getType() != libconfig::Setting::TypeGroup)
settings.add("wizard", libconfig::Setting::TypeGroup);
- auto& wizard = settings["wizard"];
+ auto &wizard = settings["wizard"];
// Show wizard, if the don't show wizard message box wasn't checked
// and keylist doesn't contain a private key
@@ -112,20 +115,20 @@ void MainWindow::init() noexcept {
LOG(INFO) << "wizard show_wizard" << show_wizard;
if (show_wizard) {
- slotStartWizard();
+ slot_start_wizard();
}
- emit loaded();
+ emit SignalLoaded();
// if not prohibit update checking
if (!prohibit_update_checking_) {
#ifdef RELEASE
auto version_thread = new VersionCheckThread();
- connect(version_thread, SIGNAL(finished()), version_thread,
- SLOT(deleteLater()));
- connect(version_thread, &VersionCheckThread::upgradeVersion, this,
- &MainWindow::slotVersionUpgrade);
+ connect(version_thread, &VersionCheckThread::finished, version_thread,
+ &VersionCheckThread::deleteLater);
+ connect(version_thread, &VersionCheckThread::SignalUpgradeVersion, this,
+ &MainWindow::slot_version_upgrade);
version_thread->start();
#endif
@@ -140,10 +143,13 @@ void MainWindow::init() noexcept {
}
}
-void MainWindow::restoreSettings() {
+void MainWindow::restore_settings() {
LOG(INFO) << _("Called");
try {
+
+ LOG(INFO) << "restore settings main_windows_state";
+
SettingsObject main_windows_state("main_windows_state");
std::string window_state = main_windows_state.Check(
@@ -183,11 +189,13 @@ void MainWindow::restoreSettings() {
main_windows_state.Check("icon_style", Qt::ToolButtonTextUnderIcon);
auto icon_style = static_cast<Qt::ToolButtonStyle>(s_icon_style);
this->setToolButtonStyle(icon_style);
- importButton->setToolButtonStyle(icon_style);
+ import_button_->setToolButtonStyle(icon_style);
// icons ize
this->setIconSize(QSize(width, height));
- importButton->setIconSize(QSize(width, height));
+ import_button_->setIconSize(QSize(width, height));
+
+ LOG(INFO) << "restore settings key_server";
SettingsObject key_server_json("key_server");
@@ -201,13 +209,13 @@ void MainWindow::restoreSettings() {
key_server_json["default_server"] = 0;
}
- auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ auto &settings = GlobalSettingStation::GetInstance().GetUISettings();
if (!settings.exists("general") ||
settings.lookup("general").getType() != libconfig::Setting::TypeGroup)
settings.add("general", libconfig::Setting::TypeGroup);
- auto& general = settings["general"];
+ auto &general = settings["general"];
if (!general.exists("save_key_checked")) {
general.add("save_key_checked", libconfig::Setting::TypeBoolean) = true;
@@ -222,21 +230,26 @@ void MainWindow::restoreSettings() {
general.lookupValue("save_key_checked", save_key_checked);
try {
+
+ LOG(INFO) << "restore settings default_key_checked";
+
// Checked Keys
SettingsObject default_key_checked("default_key_checked");
if (save_key_checked) {
auto key_ids_ptr = std::make_unique<KeyIdArgsList>();
- for (auto& it : default_key_checked) {
+ for (auto &it : default_key_checked) {
std::string key_id = it;
LOG(INFO) << "get checked key id" << key_id;
key_ids_ptr->push_back(key_id);
}
- mKeyList->setChecked(std::move(key_ids_ptr));
+ m_key_list_->SetChecked(std::move(key_ids_ptr));
}
} catch (...) {
LOG(ERROR) << "restore default_key_checked failed";
}
+ LOG(INFO) << "restore settings smtp_passport";
+
SettingsObject smtp_passport("smtp_passport");
smtp_passport.Check("enable", false);
@@ -256,8 +269,8 @@ void MainWindow::restoreSettings() {
GlobalSettingStation::GetInstance().SyncSettings();
}
-void MainWindow::saveSettings() {
- auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+void MainWindow::save_settings() {
+ auto &settings = GlobalSettingStation::GetInstance().GetUISettings();
try {
SettingsObject main_windows_state("main_windows_state");
@@ -274,12 +287,12 @@ void MainWindow::saveSettings() {
// keyid-list of private checked keys
if (save_key_checked) {
- auto key_ids_need_to_store = mKeyList->getChecked();
+ auto key_ids_need_to_store = m_key_list_->GetChecked();
SettingsObject default_key_checked("default_key_checked");
default_key_checked.clear();
- for (const auto& key_id : *key_ids_need_to_store)
+ for (const auto &key_id : *key_ids_need_to_store)
default_key_checked.push_back(key_id);
} else {
settings["general"].remove("save_key_checked");
@@ -291,22 +304,22 @@ void MainWindow::saveSettings() {
GlobalSettingStation::GetInstance().SyncSettings();
}
-void MainWindow::closeAttachmentDock() {
- if (!attachmentDockCreated) {
+void MainWindow::close_attachment_dock() {
+ if (!attachment_dock_created_) {
return;
}
- attachmentDock->close();
- attachmentDock->deleteLater();
- attachmentDockCreated = false;
+ attachment_dock_->close();
+ attachment_dock_->deleteLater();
+ attachment_dock_created_ = false;
}
-void MainWindow::closeEvent(QCloseEvent* event) {
+void MainWindow::closeEvent(QCloseEvent *event) {
/*
* ask to save changes, if there are
* modified documents in any tab
*/
- if (edit->maybeSaveAnyTab()) {
- saveSettings();
+ if (edit_->MaybeSaveAnyTab()) {
+ save_settings();
event->accept();
} else {
event->ignore();
@@ -316,4 +329,4 @@ void MainWindow::closeEvent(QCloseEvent* event) {
// GpgContext::GetInstance().clearPasswordCache();
}
-} // namespace GpgFrontend::UI
+} // namespace GpgFrontend::UI
diff --git a/src/ui/main_window/MainWindow.h b/src/ui/main_window/MainWindow.h
new file mode 100644
index 00000000..5cc9a15a
--- /dev/null
+++ b/src/ui/main_window/MainWindow.h
@@ -0,0 +1,416 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#ifndef __GPGWIN_H__
+#define __GPGWIN_H__
+
+#include "core/GpgConstants.h"
+#include "core/function/result_analyse/GpgDecryptResultAnalyse.h"
+#include "core/function/result_analyse/GpgEncryptResultAnalyse.h"
+#include "core/function/result_analyse/GpgSignResultAnalyse.h"
+#include "ui/GpgFrontendUI.h"
+#include "ui/KeyMgmt.h"
+#include "ui/dialog/WaitingDialog.h"
+#include "ui/dialog/Wizard.h"
+#include "ui/help/AboutDialog.h"
+#include "ui/import_export/KeyUploadDialog.h"
+#include "ui/settings/SettingsDialog.h"
+#include "ui/widgets/FindWidget.h"
+#include "ui/widgets/InfoBoardWidget.h"
+#include "ui/widgets/TextEdit.h"
+
+namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
+class MainWindow : public QMainWindow {
+ Q_OBJECT
+
+ public:
+
+ struct CryptoMenu{
+ using OperationType = unsigned int;
+
+ static constexpr OperationType None = 0;
+ static constexpr OperationType Encrypt = 1 << 0;
+ static constexpr OperationType Sign = 1 << 1;
+ static constexpr OperationType Decrypt = 1 << 2;
+ static constexpr OperationType Verify = 1 << 3;
+ static constexpr OperationType EncryptAndSign = 1 << 4;
+ static constexpr OperationType DecryptAndVerify = 1 << 5;
+ };
+
+ /**
+ * @brief
+ *
+ */
+ MainWindow();
+
+ /**
+ * @details ONLY Called from main()
+ */
+ void Init() noexcept;
+
+ /**
+ * @details refresh and enable specify crypto-menu actions.
+ */
+ void SetCryptoMenuStatus(CryptoMenu::OperationType type);
+
+ signals:
+
+ /**
+ * @brief
+ */
+ void SignalLoaded();
+
+
+ public slots:
+
+ /**
+ * @brief
+ */
+ void SlotSetStatusBarText(const QString& text);
+
+ protected:
+ /**
+ * @details Close event shows a save dialog, if there are unsaved documents on
+ * exit.
+ * @param event
+ */
+ void closeEvent(QCloseEvent* event) override;
+
+ public slots:
+
+ /**
+ * @details Open a new tab for path
+ */
+ void SlotOpenFile(QString& path);
+
+ /**
+ * @details Open dialog for encrypting file.
+ */
+ void SlotFileEncrypt();
+
+ /**
+ * @details Open dialog for decrypting file.
+ */
+ void SlotFileDecrypt();
+
+ /**
+ * @details Open dialog for signing file.
+ */
+ void SlotFileSign();
+
+ /**
+ * @details Open dialog for verifying file.
+ */
+ void SlotFileVerify();
+
+ /**
+ * @details Open dialog for signing file.
+ */
+ void SlotFileEncryptSign();
+
+ /**
+ * @details Open dialog for verifying file.
+ */
+ void SlotFileDecryptVerify();
+
+ /**
+ * @details get value of member restartNeeded to needed.
+ * @param needed true, if application has to be restarted
+ */
+ void SlotSetRestartNeeded(bool needed);
+
+ private slots:
+
+ /**
+ * @details encrypt the text of currently active textedit-page
+ * with the currently checked keys
+ */
+ void slot_encrypt();
+
+ /**
+ * @details encrypt and sign the text of currently active textedit-page
+ * with the currently checked keys
+ */
+ void slot_encrypt_sign();
+
+ /**
+ * @details Show a passphrase dialog and decrypt the text of currently active
+ * tab.
+ */
+ void slot_decrypt();
+
+ /**
+ * @details Sign the text of currently active tab with the checked private
+ * keys
+ */
+ void slot_sign();
+
+ /**
+ * @details Verify the text of currently active tab and show verify
+ * information. If document is signed with a key, which is not in keylist,
+ * show import missing key from keyserver in Menu of verifynotification.
+ */
+ void slot_verify();
+
+ /**
+ * @details decrypt and verify the text of currently active textedit-page
+ * with the currently checked keys
+ */
+ void slot_decrypt_verify();
+
+ /**
+ * @details Show the details of the first of the first of selected keys
+ */
+ void slot_show_key_details();
+
+ /**
+ * @details Refresh key information of selected keys from default keyserver
+ */
+ void refresh_keys_from_key_server();
+
+ /**
+ * @details upload the selected key to the keyserver
+ */
+ void upload_key_to_server();
+
+ /**
+ * @details Open find widget.
+ */
+ void slot_find();
+
+ /**
+ * @details start the wizard
+ */
+ void slot_start_wizard();
+
+ /**
+ * @details Import keys from currently active tab to keylist if possible.
+ */
+ void slot_import_key_from_edit();
+
+ /**
+ * @details Append the selected keys to currently active textedit.
+ */
+ void slot_append_selected_keys();
+
+ /**
+ * @details Copy the mailaddress of selected key to clipboard.
+ * Method for keylists contextmenu.
+ */
+ void slot_copy_mail_address_to_clipboard();
+
+ /**
+ * @details Open key management dialog.
+ */
+ void slot_open_key_management();
+
+ /**
+ * @details Open File Opera Tab
+ */
+ void slot_open_file_tab();
+
+ /**
+ * @details Open settings-dialog.
+ */
+ void slot_open_settings_dialog();
+
+ /**
+ * @details Replace double linebreaks by single linebreaks in currently active
+ * tab.
+ */
+ void slot_clean_double_line_breaks();
+
+ /**
+ * @details Cut the existing PGP header and footer from current tab.
+ */
+ void slot_cut_pgp_header();
+
+ /**
+ * @details Add PGP header and footer to current tab.
+ */
+ void slot_add_pgp_header();
+
+ /**
+ * @details Disable tab related actions, if number of tabs is 0.
+ * @param number number of the opened tabs and -1, if no tab is opened
+ */
+ void slot_disable_tab_actions(int number);
+
+ /**
+ * @details called when need to upgrade.
+ */
+ void slot_version_upgrade(const SoftwareVersion& version);
+
+ private:
+ /**
+ * @details Create actions for the main-menu and the context-menu of the
+ * keylist.
+ */
+ void create_actions();
+
+ /**
+ * @details create the menu of the main-window.
+ */
+ void create_menus();
+
+ /**
+ * @details Create edit-, crypt- and key-toolbars.
+ */
+ void create_tool_bars();
+
+ /**
+ * @details Create statusbar of mainwindow.
+ */
+ void create_status_bar();
+
+ /**
+ * @details Create keylist- and attachment-dockwindows.
+ */
+ void create_dock_windows();
+
+ /**
+ * @details Create attachment dock window.
+ */
+ void create_attachment_dock();
+
+ /**
+ * @details close attachment-dockwindow.
+ */
+ void close_attachment_dock();
+
+ /**
+ * @details Load settings from ini-file.
+ */
+ void restore_settings();
+
+ /**
+ * @details Save settings to ini-file.
+ */
+ void save_settings();
+
+ /**
+ * @brief return true, if restart is needed
+ */
+ [[nodiscard]] bool get_restart_needed() const;
+
+ TextEdit* edit_{}; ///< Tabwidget holding the edit-windows
+ QMenu* file_menu_{}; ///< Submenu for file-operations
+ QMenu* edit_menu_{}; ///< Submenu for text-operations
+ QMenu* crypt_menu_{}; ///< Submenu for crypt-operations
+ QMenu* help_menu_{}; ///< Submenu for help-operations
+ QMenu* key_menu_{}; ///< Submenu for key-operations
+ QMenu* view_menu_{}; ///< Submenu for view operations
+ QMenu* import_key_menu_{}; ///< Submenu for import operations
+#ifdef SMTP_SUPPORT
+ QMenu* email_menu_{}; ///< Submenu for email operations
+#endif
+
+ QMenu* steganography_menu_{}; ///< Submenu for steganography operations
+ QToolBar* crypt_tool_bar_{}; ///< Toolbar holding crypt actions
+ QToolBar* file_tool_bar_{}; ///< Toolbar holding file actions
+ QToolBar* edit_tool_bar_{}; ///< Toolbar holding edit actions
+ QToolBar*
+ special_edit_tool_bar_{}; ///< Toolbar holding special edit actions
+ QToolBar* key_tool_bar_{}; ///< Toolbar holding key operations
+ QToolBar* email_tool_bar_{}; ///< Toolbar holding key operations
+ QToolButton*
+ import_button_{}; ///< Tool button for import dropdown menu in toolbar
+ QDockWidget* key_list_dock_{}; ///< Encrypt Dock
+ QDockWidget* attachment_dock_{}; ///< Attachment Dock
+ QDockWidget* info_board_dock_{};
+
+ QAction* new_tab_act_{}; ///< Action to create new tab
+ QAction* switch_tab_up_act_{}; ///< Action to switch tab up
+ QAction* switch_tab_down_act_{}; ///< Action to switch tab down
+ QAction* open_act_{}; ///< Action to open file
+ QAction* browser_act_{}; ///< Action to open file browser
+ QAction* save_act_{}; ///< Action to save file
+ QAction* save_as_act_{}; ///< Action to save file as
+ QAction* print_act_{}; ///< Action to print
+ QAction* close_tab_act_{}; ///< Action to print
+ QAction* quit_act_{}; ///< Action to quit application
+ QAction* encrypt_act_{}; ///< Action to encrypt text
+ QAction* encrypt_sign_act_{}; ///< Action to encrypt and sign text
+ QAction* decrypt_verify_act_{}; ///< Action to encrypt and sign text
+ QAction* decrypt_act_{}; ///< Action to decrypt text
+ QAction* sign_act_{}; ///< Action to sign text
+ QAction* verify_act_{}; ///< Action to verify text
+ QAction* import_key_from_edit_act_{}; ///< Action to import key from edit
+ QAction* clean_double_line_breaks_act_{}; ///< Action to remove double line
+ ///< breaks
+
+ QAction*
+ append_selected_keys_act_{}; ///< Action to append selected keys to edit
+ QAction* copy_mail_address_to_clipboard_act_{}; ///< Action to copy mail to
+ ///< clipboard
+ QAction* open_key_management_act_{}; ///< Action to open key management
+ QAction* copy_act_{}; ///< Action to copy text
+ QAction* quote_act_{}; ///< Action to quote text
+ QAction* cut_act_{}; ///< Action to cut text
+ QAction* paste_act_{}; ///< Action to paste text
+ QAction* select_all_act_{}; ///< Action to select whole text
+ QAction* find_act_{}; ///< Action to find text
+ QAction* undo_act_{}; ///< Action to undo last action
+ QAction* redo_act_{}; ///< Action to redo last action
+ QAction* zoom_in_act_{}; ///< Action to zoom in
+ QAction* zoom_out_act_{}; ///< Action to zoom out
+ QAction* about_act_{}; ///< Action to open about dialog
+ QAction* check_update_act_{}; ///< Action to open about dialog
+ QAction* translate_act_{}; ///< Action to open about dialog
+ QAction* open_settings_act_{}; ///< Action to open settings dialog
+ QAction* show_key_details_act_{}; ///< Action to open key-details dialog
+ QAction* start_wizard_act_{}; ///< Action to open the wizard
+ QAction* cut_pgp_header_act_{}; ///< Action for cutting the PGP header
+ QAction* add_pgp_header_act_{}; ///< Action for adding the PGP header
+
+#ifdef SMTP_SUPPORT
+ QAction* send_mail_act_{}; ///< Action for sending a email
+ QAction* receive_mail_act_{}; ///< Action for receive emails
+#endif
+
+ QAction* import_key_from_file_act_{}; ///<
+ QAction* import_key_from_clipboard_act_{}; ///<
+ QAction* import_key_from_key_server_act_{}; ///<
+
+ QLabel* status_bar_icon_{}; ///<
+
+ KeyList* m_key_list_{}; ///<
+ InfoBoardWidget* info_board_{}; ///<
+
+ bool attachment_dock_created_{}; ///<
+ bool restart_needed_{}; ///<
+ bool prohibit_update_checking_ = false; ///<
+};
+
+} // namespace GpgFrontend::UI
+
+#endif // __GPGWIN_H__
diff --git a/src/ui/main_window/MainWindowFileSlotFunction.cpp b/src/ui/main_window/MainWindowFileSlotFunction.cpp
index adf762d8..97cb6a8d 100644
--- a/src/ui/main_window/MainWindowFileSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowFileSlotFunction.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,37 +8,40 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include "MainWindow.h"
-#include "gpg/function/GpgFileOpera.h"
-#include "gpg/function/GpgKeyGetter.h"
+#include "core/function/ArchiveFileOperator.h"
+#include "core/function/GlobalSettingStation.h"
+#include "core/function/gpg/GpgFileOpera.h"
+#include "core/function/gpg/GpgKeyGetter.h"
#include "ui/UserInterfaceUtils.h"
-#include "ui/settings/GlobalSettingStation.h"
#include "ui/widgets/SignersPicker.h"
namespace GpgFrontend::UI {
-bool file_pre_check(QWidget* parent, const QString& path) {
+bool path_pre_check(QWidget* parent, const QString& path) {
QFileInfo file_info(path);
QFileInfo path_info(file_info.absolutePath());
- if (!file_info.isFile()) {
+ if (!path_info.exists()) {
QMessageBox::critical(parent, _("Error"),
- _("Select a file before doing it."));
+ QString(_("The path %1 does not exist.")).arg(path));
return false;
}
if (!file_info.isReadable()) {
@@ -52,14 +57,97 @@ bool file_pre_check(QWidget* parent, const QString& path) {
return true;
}
-void MainWindow::slotFileEncrypt() {
- auto fileTreeView = edit->slotCurPageFileTreeView();
- auto path = fileTreeView->getSelected();
+/**
+ * @brief convert directory into tarball
+ *
+ * @param parent parent widget
+ * @param path the directory to be converted
+ * @return
+ */
+bool process_tarball_into_directory(QWidget* parent,
+ std::filesystem::path& path) {
+ auto selected_dir_path = std::filesystem::path(path);
+
+ if (selected_dir_path.extension() != ".tar") {
+ QMessageBox::critical(parent, _("Error"), _("The file is not a tarball."));
+ return false;
+ }
+
+ try {
+ auto base_path = selected_dir_path.parent_path();
+
+ auto target_path = selected_dir_path;
+ target_path.replace_extension(".tar");
+
+ LOG(INFO) << "base path" << base_path << "target archive path"
+ << target_path;
+
+ bool if_error = false;
+ process_operation(parent, _("Extracting Tarball"), [&]() {
+ try {
+ GpgFrontend::ArchiveFileOperator::ExtractArchive(target_path,
+ base_path);
+ } catch (const std::runtime_error& e) {
+ if_error = true;
+ }
+ });
+
+ if (if_error || !exists(target_path)) {
+ throw std::runtime_error("Decompress Failed");
+ }
+ path = target_path.string().c_str();
+ } catch (...) {
+ LOG(ERROR) << "decompress error";
+ return false;
+ }
+ return true;
+}
+
+/**
+ * @brief convert tarball into directory
+ *
+ * @param parent parent widget
+ * @param path the tarball to be converted
+ */
+bool process_directory_into_tarball(QWidget* parent, QString& path) {
+ auto selected_dir_path = std::filesystem::path(path.toStdString());
+ try {
+ auto base_path = selected_dir_path.parent_path();
+ auto target_path = selected_dir_path;
+ selected_dir_path.replace_extension("");
+
+ LOG(INFO) << "base path" << base_path << "target archive path"
+ << target_path << "selected_dir_path" << selected_dir_path;
+
+ bool if_error = false;
+ process_operation(parent, _("Making Tarball"), [&]() {
+ try {
+ GpgFrontend::ArchiveFileOperator::CreateArchive(base_path, target_path,
+ 0, {selected_dir_path});
+ } catch (const std::runtime_error& e) {
+ if_error = true;
+ }
+ });
+
+ if (if_error || !exists(target_path)) {
+ throw std::runtime_error("Compress Failed");
+ }
+ path = target_path.string().c_str();
+ } catch (...) {
+ LOG(ERROR) << "compress error";
+ return false;
+ }
+ return true;
+}
+
+void MainWindow::SlotFileEncrypt() {
+ auto fileTreeView = edit_->SlotCurPageFileTreeView();
+ auto path = fileTreeView->GetSelected();
- if (!file_pre_check(this, path)) return;
+ if (!path_pre_check(this, path)) return;
// check selected keys
- auto key_ids = mKeyList->getChecked();
+ auto key_ids = m_key_list_->GetChecked();
GpgEncrResult result = nullptr;
GpgError error;
bool if_error = false;
@@ -73,9 +161,16 @@ void MainWindow::slotFileEncrypt() {
LOG(ERROR) << _("Setting Operation Error") << _("non_ascii_when_export");
}
+ // get file info
+ QFileInfo file_info(path);
+
+ if (file_info.isDir()) {
+ path = path + (file_info.isDir() ? ".tar" : "");
+ }
+
auto _channel = GPGFRONTEND_DEFAULT_CHANNEL;
auto _extension = ".asc";
- if (non_ascii_when_export) {
+ if (non_ascii_when_export || file_info.isDir()) {
_channel = GPGFRONTEND_NON_ASCII_CHANNEL;
_extension = ".gpg";
}
@@ -83,7 +178,7 @@ void MainWindow::slotFileEncrypt() {
auto out_path = path + _extension;
if (QFile::exists(out_path)) {
- boost::filesystem::path _out_path = out_path.toStdString();
+ std::filesystem::path _out_path = out_path.toStdString();
auto out_file_name = boost::format(_("The target file %1% already exists, "
"do you need to overwrite it?")) %
_out_path.filename();
@@ -94,6 +189,15 @@ void MainWindow::slotFileEncrypt() {
if (ret == QMessageBox::Cancel) return;
}
+ if (file_info.isDir()) {
+ // stop if the process making tarball failed
+ if (!process_directory_into_tarball(this, path)) {
+ QMessageBox::critical(this, _("Error"),
+ _("Unable to convert the folder into tarball."));
+ return;
+ }
+ }
+
if (key_ids->empty()) {
// Symmetric Encrypt
auto ret = QMessageBox::information(
@@ -140,10 +244,19 @@ void MainWindow::slotFileEncrypt() {
});
}
+ // remove xxx.tar and only left xxx.tar.gpg
+ if (file_info.isDir()) {
+ auto selected_dir_path = std::filesystem::path(path.toStdString());
+ auto target_path = selected_dir_path.replace_extension(".tar");
+ if (exists(target_path)) {
+ std::filesystem::remove(target_path);
+ }
+ }
+
if (!if_error) {
- auto resultAnalyse = EncryptResultAnalyse(error, std::move(result));
+ auto resultAnalyse = GpgEncryptResultAnalyse(error, std::move(result));
resultAnalyse.Analyse();
- process_result_analyse(edit, infoBoard, resultAnalyse);
+ process_result_analyse(edit_, info_board_, resultAnalyse);
fileTreeView->update();
} else {
QMessageBox::critical(this, _("Error"),
@@ -152,13 +265,13 @@ void MainWindow::slotFileEncrypt() {
}
}
-void MainWindow::slotFileDecrypt() {
- auto fileTreeView = edit->slotCurPageFileTreeView();
- auto path = fileTreeView->getSelected();
+void MainWindow::SlotFileDecrypt() {
+ auto fileTreeView = edit_->SlotCurPageFileTreeView();
+ auto path = fileTreeView->GetSelected();
- if (!file_pre_check(this, path)) return;
+ if (!path_pre_check(this, path)) return;
- boost::filesystem::path out_path = path.toStdString();
+ std::filesystem::path out_path = path.toStdString();
if (out_path.extension() == ".asc" || out_path.extension() == ".gpg") {
out_path = out_path.parent_path() / out_path.stem();
@@ -188,9 +301,9 @@ void MainWindow::slotFileDecrypt() {
});
if (!if_error) {
- auto resultAnalyse = DecryptResultAnalyse(error, std::move(result));
+ auto resultAnalyse = GpgDecryptResultAnalyse(error, std::move(result));
resultAnalyse.Analyse();
- process_result_analyse(edit, infoBoard, resultAnalyse);
+ process_result_analyse(edit_, info_board_, resultAnalyse);
fileTreeView->update();
} else {
@@ -198,15 +311,35 @@ void MainWindow::slotFileDecrypt() {
_("An error occurred during operation."));
return;
}
+
+ // extract the tarball
+ if (out_path.extension() == ".tar" && exists(out_path)) {
+ bool ret = QMessageBox::information(
+ this, _("Decrypting"),
+ _("Do you want to extract and delete the decrypted tarball?"),
+ QMessageBox::Ok | QMessageBox::Cancel);
+ if (ret) {
+ if (process_tarball_into_directory(this, out_path)) {
+ QMessageBox::information(this, _("Decrypting"),
+ _("Extracting tarball succeeded."));
+ // remove tarball
+ std::filesystem::remove(out_path);
+ } else {
+ QMessageBox::critical(this, _("Decrypting"),
+ _("Extracting tarball failed."));
+ }
+ }
+ }
+
}
-void MainWindow::slotFileSign() {
- auto fileTreeView = edit->slotCurPageFileTreeView();
- auto path = fileTreeView->getSelected();
+void MainWindow::SlotFileSign() {
+ auto fileTreeView = edit_->SlotCurPageFileTreeView();
+ auto path = fileTreeView->GetSelected();
- if (!file_pre_check(this, path)) return;
+ if (!path_pre_check(this, path)) return;
- auto key_ids = mKeyList->getChecked();
+ auto key_ids = m_key_list_->GetChecked();
auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids);
if (keys->empty()) {
@@ -244,7 +377,7 @@ void MainWindow::slotFileSign() {
_extension = ".sig";
}
- boost::filesystem::path in_path = path.toStdString();
+ std::filesystem::path in_path = path.toStdString();
auto sig_file_path = in_path;
sig_file_path += _extension;
if (exists(sig_file_path)) {
@@ -272,9 +405,9 @@ void MainWindow::slotFileSign() {
});
if (!if_error) {
- auto resultAnalyse = SignResultAnalyse(error, std::move(result));
+ auto resultAnalyse = GpgSignResultAnalyse(error, std::move(result));
resultAnalyse.Analyse();
- process_result_analyse(edit, infoBoard, resultAnalyse);
+ process_result_analyse(edit_, info_board_, resultAnalyse);
fileTreeView->update();
@@ -287,12 +420,12 @@ void MainWindow::slotFileSign() {
fileTreeView->update();
}
-void MainWindow::slotFileVerify() {
- auto fileTreeView = edit->slotCurPageFileTreeView();
- auto path = fileTreeView->getSelected();
+void MainWindow::SlotFileVerify() {
+ auto fileTreeView = edit_->SlotCurPageFileTreeView();
+ auto path = fileTreeView->GetSelected();
- boost::filesystem::path in_path = path.toStdString();
- boost::filesystem::path sign_file_path = in_path, data_file_path;
+ std::filesystem::path in_path = path.toStdString();
+ std::filesystem::path sign_file_path = in_path, data_file_path;
// Detect ascii mode
auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
@@ -353,15 +486,15 @@ void MainWindow::slotFileVerify() {
});
if (!if_error) {
- auto result_analyse = VerifyResultAnalyse(error, result);
+ auto result_analyse = GpgVerifyResultAnalyse(error, result);
result_analyse.Analyse();
- process_result_analyse(edit, infoBoard, result_analyse);
+ process_result_analyse(edit_, info_board_, result_analyse);
if (result_analyse.GetStatus() == -2)
import_unknown_key_from_keyserver(this, result_analyse);
if (result_analyse.GetStatus() >= 0)
- show_verify_details(this, infoBoard, error, result);
+ show_verify_details(this, info_board_, error, result);
fileTreeView->update();
} else {
@@ -371,14 +504,14 @@ void MainWindow::slotFileVerify() {
}
}
-void MainWindow::slotFileEncryptSign() {
- auto fileTreeView = edit->slotCurPageFileTreeView();
- auto path = fileTreeView->getSelected();
+void MainWindow::SlotFileEncryptSign() {
+ auto fileTreeView = edit_->SlotCurPageFileTreeView();
+ auto path = fileTreeView->GetSelected();
- if (!file_pre_check(this, path)) return;
+ if (!path_pre_check(this, path)) return;
// check selected keys
- auto key_ids = mKeyList->getChecked();
+ auto key_ids = m_key_list_->GetChecked();
auto p_keys = GpgKeyGetter::GetInstance().GetKeys(key_ids);
if (p_keys->empty()) {
@@ -402,7 +535,7 @@ void MainWindow::slotFileEncryptSign() {
}
}
- // Detect ascii mode
+ // detect ascii mode
auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
bool non_ascii_when_export = true;
try {
@@ -411,16 +544,23 @@ void MainWindow::slotFileEncryptSign() {
LOG(ERROR) << _("Setting Operation Error") << _("non_ascii_when_export");
}
+ // get file info
+ QFileInfo file_info(path);
+
+ if (file_info.isDir()) {
+ path = path + (file_info.isDir() ? ".tar" : "");
+ }
+
auto _channel = GPGFRONTEND_DEFAULT_CHANNEL;
auto _extension = ".asc";
- if (non_ascii_when_export) {
+ if (non_ascii_when_export || file_info.isDir()) {
_channel = GPGFRONTEND_NON_ASCII_CHANNEL;
_extension = ".gpg";
}
- boost::filesystem::path out_path = path.toStdString() + _extension;
+ auto out_path = path + _extension;
- if (exists(out_path)) {
+ if (QFile::exists(out_path)) {
auto ret = QMessageBox::warning(
this, _("Warning"),
_("The target file already exists, do you need to overwrite it?"),
@@ -431,12 +571,22 @@ void MainWindow::slotFileEncryptSign() {
auto signersPicker = new SignersPicker(this);
QEventLoop loop;
- connect(signersPicker, SIGNAL(finished(int)), &loop, SLOT(quit()));
+ connect(signersPicker, &SignersPicker::finished, &loop, &QEventLoop::quit);
loop.exec();
- auto signer_key_ids = signersPicker->getCheckedSigners();
+ auto signer_key_ids = signersPicker->GetCheckedSigners();
auto p_signer_keys = GpgKeyGetter::GetInstance().GetKeys(signer_key_ids);
+ // convert directory into tarball
+ if (file_info.isDir()) {
+ // stop if the process making tarball failed
+ if (!process_directory_into_tarball(this, path)) {
+ QMessageBox::critical(this, _("Error"),
+ _("Unable to convert the folder into tarball."));
+ return;
+ }
+ }
+
GpgEncrResult encr_result = nullptr;
GpgSignResult sign_result = nullptr;
@@ -447,18 +597,19 @@ void MainWindow::slotFileEncryptSign() {
try {
error = GpgFileOpera::EncryptSignFile(
std::move(p_keys), std::move(p_signer_keys), path.toStdString(),
- out_path.string(), encr_result, sign_result, _channel);
+ out_path.toStdString(), encr_result, sign_result, _channel);
} catch (const std::runtime_error& e) {
if_error = true;
}
});
if (!if_error) {
- auto encrypt_result = EncryptResultAnalyse(error, std::move(encr_result));
- auto sign_res = SignResultAnalyse(error, std::move(sign_result));
+ auto encrypt_result =
+ GpgEncryptResultAnalyse(error, std::move(encr_result));
+ auto sign_res = GpgSignResultAnalyse(error, std::move(sign_result));
encrypt_result.Analyse();
sign_res.Analyse();
- process_result_analyse(edit, infoBoard, encrypt_result, sign_res);
+ process_result_analyse(edit_, info_board_, encrypt_result, sign_res);
fileTreeView->update();
@@ -467,16 +618,26 @@ void MainWindow::slotFileEncryptSign() {
_("An error occurred during operation."));
return;
}
+
+ // remove xxx.tar and only left xxx.tar.gpg
+ if (file_info.isDir()) {
+ auto selected_dir_path = std::filesystem::path(path.toStdString());
+ auto target_path = selected_dir_path.replace_extension(".tar");
+ if (exists(target_path)) {
+ std::filesystem::remove(target_path);
+ }
+ }
+
}
-void MainWindow::slotFileDecryptVerify() {
- auto fileTreeView = edit->slotCurPageFileTreeView();
- auto path = fileTreeView->getSelected();
+void MainWindow::SlotFileDecryptVerify() {
+ auto fileTreeView = edit_->SlotCurPageFileTreeView();
+ auto path = fileTreeView->GetSelected();
- if (!file_pre_check(this, path)) return;
+ if (!path_pre_check(this, path)) return;
- boost::filesystem::path in_path(path.toStdString());
- boost::filesystem::path out_path = in_path;
+ std::filesystem::path in_path(path.toStdString());
+ std::filesystem::path out_path = in_path;
if (in_path.extension() == ".asc" || in_path.extension() == ".gpg") {
out_path = in_path.parent_path() / out_path.stem();
} else {
@@ -509,17 +670,17 @@ void MainWindow::slotFileDecryptVerify() {
});
if (!if_error) {
- auto decrypt_res = DecryptResultAnalyse(error, std::move(d_result));
- auto verify_res = VerifyResultAnalyse(error, v_result);
+ auto decrypt_res = GpgDecryptResultAnalyse(error, std::move(d_result));
+ auto verify_res = GpgVerifyResultAnalyse(error, v_result);
decrypt_res.Analyse();
verify_res.Analyse();
- process_result_analyse(edit, infoBoard, decrypt_res, verify_res);
+ process_result_analyse(edit_, info_board_, decrypt_res, verify_res);
if (verify_res.GetStatus() == -2)
import_unknown_key_from_keyserver(this, verify_res);
if (verify_res.GetStatus() >= 0)
- show_verify_details(this, infoBoard, error, v_result);
+ show_verify_details(this, info_board_, error, v_result);
fileTreeView->update();
} else {
@@ -527,6 +688,26 @@ void MainWindow::slotFileDecryptVerify() {
_("An error occurred during operation."));
return;
}
+
+ // extract the tarball
+ if (out_path.extension() == ".tar" && exists(out_path)) {
+ bool ret = QMessageBox::information(
+ this, _("Decrypting"),
+ _("Do you want to extract and delete the decrypted tarball?"),
+ QMessageBox::Ok | QMessageBox::Cancel);
+ if (ret) {
+ if (process_tarball_into_directory(this, out_path)) {
+ QMessageBox::information(this, _("Decrypting"),
+ _("Extracting tarball succeeded."));
+ // remove tarball
+ std::filesystem::remove(out_path);
+ } else {
+ QMessageBox::critical(this, _("Decrypting"),
+ _("Extracting tarball failed."));
+ }
+ }
+ }
+
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/main_window/MainWindowServerSlotFunction.cpp b/src/ui/main_window/MainWindowServerSlotFunction.cpp
deleted file mode 100644
index 17491db7..00000000
--- a/src/ui/main_window/MainWindowServerSlotFunction.cpp
+++ /dev/null
@@ -1,262 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#include "MainWindow.h"
-
-#ifdef SERVER_SUPPORT
-#include "rapidjson/document.h"
-#include "rapidjson/prettywriter.h"
-#include "server/ComUtils.h"
-#endif
-#include "ui/ShowCopyDialog.h"
-
-namespace GpgFrontend::UI {
-
-#ifdef SERVER_SUPPORT
-
-/**
- * get full size crypt text from server using short crypto text
- * @param shortenCryptoText short crypto text([GpgFrontend_ShortCrypto]://)
- * @return
- */
-QString MainWindow::getCryptText(const QString& shortenCryptoText) {
- QString ownKeyId = settings.value("general/ownKeyId").toString();
-
- GpgKey key = mCtx->getKeyRefById(ownKeyId);
- if (!key.good) {
- QMessageBox::critical(this, _("Invalid Own Key"),
- _("Own Key can not be use to do any operation. "
- "Please go to the setting interface to select an "
- "OwnKey and get a ServiceToken."));
- return {};
- }
-
- auto utils = new ComUtils(this);
-
- QString serviceToken = settings.value("general/serviceToken").toString();
- if (serviceToken.isEmpty() || !utils->checkServiceTokenFormat(serviceToken)) {
- QMessageBox::critical(
- this, _("Error"),
- _("Please obtain a Service Token from the server in the settings."));
- return {};
- }
-
- QUrl reqUrl(utils->getUrl(ComUtils::GetFullCryptText));
- QNetworkRequest request(reqUrl);
- request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
-
- // Sign Shorten Text
- auto outSignTextBase64 =
- ComUtils::getSignStringBase64(mCtx, shortenCryptoText, key);
-
- rapidjson::Document doc;
- doc.SetObject();
-
- rapidjson::Value s, t;
-
- // Signature
- s.SetString(outSignTextBase64.constData(), outSignTextBase64.count());
- // Service Token
- const auto t_byte_array = serviceToken.toUtf8();
- t.SetString(t_byte_array.constData(), t_byte_array.count());
-
- rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();
-
- doc.AddMember("signature", s, allocator);
- doc.AddMember("serviceToken", t, allocator);
-
- rapidjson::StringBuffer sb;
- rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(sb);
- doc.Accept(writer);
-
- QByteArray postData(sb.GetString());
- qDebug() << "postData" << QString::fromUtf8(postData);
-
- QNetworkReply* reply = utils->getNetworkManager().post(request, postData);
-
- auto dialog = new WaitingDialog(_("Getting Cpt From Server"), this);
- dialog->show();
-
- while (reply->isRunning()) QApplication::processEvents();
-
- dialog->close();
-
- QByteArray replyData = reply->readAll().constData();
- if (utils->checkServerReply(replyData)) {
- /**
- * {
- * "cryptoText" : ...
- * "sha": ...
- * "serviceToken": ...
- * "date": ...
- * }
- */
-
- if (!utils->checkDataValueStr("cryptoText") ||
- !utils->checkDataValueStr("sha") ||
- !utils->checkDataValueStr("serviceToken")) {
- QMessageBox::critical(this, _("Error"),
- _("The communication content with the server does "
- "not meet the requirements"));
- return {};
- }
-
- auto cryptoText = utils->getDataValueStr("cryptoText");
- auto sha = utils->getDataValueStr("sha");
- auto serviceTokenFromServer = utils->getDataValueStr("serviceToken");
-
- QCryptographicHash sha_generator(QCryptographicHash::Sha256);
- sha_generator.addData(cryptoText.toUtf8());
-
- if (sha_generator.result().toHex() == sha &&
- serviceToken == serviceTokenFromServer) {
- return cryptoText;
- } else
- QMessageBox::critical(this, _("Error"), _("Invalid short ciphertext"));
-
- return {};
- }
-
- return {};
-}
-
-#endif
-
-#ifdef SERVER_SUPPORT
-
-void MainWindow::shortenCryptText() {
- // gather information
- QString serviceToken = settings.value("general/serviceToken").toString();
- QString ownKeyId = settings.value("general/ownKeyId").toString();
- QByteArray cryptoText = edit->curTextPage()->toPlainText().toUtf8();
-
- auto utils = new ComUtils(this);
-
- if (serviceToken.isEmpty() || !utils->checkServiceTokenFormat(serviceToken)) {
- QMessageBox::critical(
- this, _("Invalid Service Token"),
- _("Please go to the setting interface to get a ServiceToken."));
- return;
- }
-
- QUrl reqUrl(utils->getUrl(ComUtils::ShortenCryptText));
- QNetworkRequest request(reqUrl);
- request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
-
- GpgKey key = mCtx->getKeyRefById(ownKeyId);
- if (!key.good) {
- QMessageBox::critical(this, _("Invalid Own Key"),
- _("Own Key can not be use to do any operation."));
- return;
- }
-
- QCryptographicHash ch(QCryptographicHash::Md5);
- ch.addData(cryptoText);
- QString md5 = ch.result().toHex();
-
- qDebug() << "md5" << md5;
-
- QByteArray signText = QString("[%1][%2]").arg(serviceToken, md5).toUtf8();
-
- QCryptographicHash sha(QCryptographicHash::Sha256);
- sha.addData(signText);
- QString shaText = sha.result().toHex();
-
- qDebug() << "shaText" << shaText;
-
- QByteArray outSignTextBase64 =
- ComUtils::getSignStringBase64(mCtx, signText, key);
-
- rapidjson::Value c, s, m, t;
-
- rapidjson::Document doc;
- doc.SetObject();
-
- c.SetString(cryptoText.constData(), cryptoText.count());
- auto m_byte_array = shaText.toUtf8();
- m.SetString(m_byte_array.constData(), m_byte_array.count());
- s.SetString(outSignTextBase64.constData(), outSignTextBase64.count());
- auto t_byte_array = serviceToken.toUtf8();
- t.SetString(t_byte_array.constData(), t_byte_array.count());
-
- rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();
-
- doc.AddMember("cryptoText", c, allocator);
- doc.AddMember("sha", m, allocator);
- doc.AddMember("sign", s, allocator);
- doc.AddMember("serviceToken", t, allocator);
-
- rapidjson::StringBuffer sb;
- rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(sb);
- doc.Accept(writer);
-
- QByteArray postData(sb.GetString());
- qDebug() << "postData" << QString::fromUtf8(postData);
-
- QNetworkReply* reply = networkAccessManager->post(request, postData);
-
- auto* dialog = new WaitingDialog(_("Getting Scpt From Server"), this);
- dialog->show();
- while (reply->isRunning()) QApplication::processEvents();
- dialog->close();
-
- if (utils->checkServerReply(reply->readAll().constData())) {
- /**
- * {
- * "shortenText" : ...
- * "md5": ...
- * }
- */
-
- if (!utils->checkDataValueStr("shortenText") ||
- !utils->checkDataValueStr("md5")) {
- QMessageBox::critical(this, _("Error"),
- _("The communication content with the server does "
- "not meet the requirements"));
- return;
- }
-
- QString shortenText = utils->getDataValueStr("shortenText");
-
- QCryptographicHash md5_generator(QCryptographicHash::Md5);
- md5_generator.addData(shortenText.toUtf8());
- if (md5_generator.result().toHex() == utils->getDataValueStr("md5")) {
- auto* dialog =
- new ShowCopyDialog(shortenText,
- _("Notice: Use Decrypt & Verify operation to "
- "decrypt this short crypto text."),
- this);
- dialog->show();
- } else {
- QMessageBox::critical(
- this, _("Error"),
- _("There is a problem with the communication with the server"));
- return;
- }
- }
-}
-
-#endif
-
-} // namespace GpgFrontend::UI
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp
index fe0408e0..9a05cdc6 100644
--- a/src/ui/main_window/MainWindowSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowSlotFunction.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -32,25 +36,28 @@
#endif
#ifdef SMTP_SUPPORT
-#include "ui/smtp/SendMailDialog.h"
+#include "ui/mail/SendMailDialog.h"
#endif
-#include "gpg/function/BasicOperator.h"
-#include "gpg/function/GpgKeyGetter.h"
-#include "gpg/function/GpgKeyImportExporter.h"
+#include "core/function/GlobalSettingStation.h"
+#include "core/function/gpg/GpgBasicOperator.h"
+#include "core/function/gpg/GpgKeyGetter.h"
+#include "core/function/gpg/GpgKeyImportExporter.h"
#include "ui/UserInterfaceUtils.h"
#include "ui/help/AboutDialog.h"
-#include "ui/settings/GlobalSettingStation.h"
#include "ui/widgets/SignersPicker.h"
namespace GpgFrontend::UI {
/**
* Encrypt Entry(Text & File)
*/
-void MainWindow::slotEncrypt() {
- if (edit->tabCount() == 0 || edit->slotCurPageTextEdit() == nullptr) return;
+void MainWindow::slot_encrypt() {
+ if (edit_->TabCount() == 0 || edit_->SlotCurPageTextEdit() == nullptr) {
+ if (edit_->SlotCurPageFileTreeView() != nullptr) this->SlotFileEncrypt();
+ return;
+ }
- auto key_ids = mKeyList->getChecked();
+ auto key_ids = m_key_list_->GetChecked();
GpgEncrResult result = nullptr;
GpgError error;
@@ -70,8 +77,8 @@ void MainWindow::slotEncrypt() {
process_operation(this, _("Symmetrically Encrypting"), [&]() {
try {
auto buffer =
- edit->curTextPage()->getTextPage()->toPlainText().toStdString();
- error = GpgFrontend::BasicOperator::GetInstance().EncryptSymmetric(
+ edit_->CurTextPage()->GetTextPage()->toPlainText().toStdString();
+ error = GpgFrontend::GpgBasicOperator::GetInstance().EncryptSymmetric(
buffer, tmp, result);
} catch (const std::runtime_error& e) {
if_error = true;
@@ -96,8 +103,8 @@ void MainWindow::slotEncrypt() {
process_operation(this, _("Encrypting"), [&]() {
try {
auto buffer =
- edit->curTextPage()->getTextPage()->toPlainText().toStdString();
- error = GpgFrontend::BasicOperator::GetInstance().Encrypt(
+ edit_->CurTextPage()->GetTextPage()->toPlainText().toStdString();
+ error = GpgFrontend::GpgBasicOperator::GetInstance().Encrypt(
std::move(keys), buffer, tmp, result);
} catch (const std::runtime_error& e) {
if_error = true;
@@ -107,17 +114,17 @@ void MainWindow::slotEncrypt() {
if (!if_error) {
LOG(INFO) << "result" << result.get();
- auto resultAnalyse = EncryptResultAnalyse(error, std::move(result));
+ auto resultAnalyse = GpgEncryptResultAnalyse(error, std::move(result));
resultAnalyse.Analyse();
- process_result_analyse(edit, infoBoard, resultAnalyse);
+ process_result_analyse(edit_, info_board_, resultAnalyse);
if (check_gpg_error_2_err_code(error) == GPG_ERR_NO_ERROR)
- edit->slotFillTextEditWithText(QString::fromStdString(*tmp));
- infoBoard->resetOptionActionsMenu();
+ edit_->SlotFillTextEditWithText(QString::fromStdString(*tmp));
+ info_board_->ResetOptionActionsMenu();
#ifdef SMTP_SUPPORT
if (check_gpg_error_2_err_code(error) == GPG_ERR_NO_ERROR)
- send_an_email(this, infoBoard,
- edit->curTextPage()->getTextPage()->toPlainText());
+ send_an_email(this, info_board_,
+ edit_->CurTextPage()->GetTextPage()->toPlainText());
#endif
} else {
QMessageBox::critical(this, _("Error"),
@@ -126,10 +133,10 @@ void MainWindow::slotEncrypt() {
}
}
-void MainWindow::slotSign() {
- if (edit->tabCount() == 0 || edit->slotCurPageTextEdit() == nullptr) return;
+void MainWindow::slot_sign() {
+ if (edit_->TabCount() == 0 || edit_->SlotCurPageTextEdit() == nullptr) return;
- auto key_ids = mKeyList->getPrivateChecked();
+ auto key_ids = m_key_list_->GetPrivateChecked();
if (key_ids->empty()) {
QMessageBox::critical(
@@ -160,12 +167,12 @@ void MainWindow::slotSign() {
process_operation(this, _("Signing"), [&]() {
try {
- auto buffer = edit->curTextPage()
- ->getTextPage()
+ auto buffer = edit_->CurTextPage()
+ ->GetTextPage()
->toPlainText()
.toUtf8()
.toStdString();
- error = GpgFrontend::BasicOperator::GetInstance().Sign(
+ error = GpgFrontend::GpgBasicOperator::GetInstance().Sign(
std::move(keys), buffer, tmp, GPGME_SIG_MODE_CLEAR, result);
} catch (const std::runtime_error& e) {
if_error = true;
@@ -173,12 +180,12 @@ void MainWindow::slotSign() {
});
if (!if_error) {
- auto resultAnalyse = SignResultAnalyse(error, std::move(result));
+ auto resultAnalyse = GpgSignResultAnalyse(error, std::move(result));
resultAnalyse.Analyse();
- process_result_analyse(edit, infoBoard, resultAnalyse);
+ process_result_analyse(edit_, info_board_, resultAnalyse);
if (check_gpg_error_2_err_code(error) == GPG_ERR_NO_ERROR)
- edit->slotFillTextEditWithText(QString::fromStdString(*tmp));
+ edit_->SlotFillTextEditWithText(QString::fromStdString(*tmp));
} else {
QMessageBox::critical(this, _("Error"),
_("An error occurred during operation."));
@@ -186,11 +193,14 @@ void MainWindow::slotSign() {
}
}
-void MainWindow::slotDecrypt() {
- if (edit->tabCount() == 0 || edit->slotCurPageTextEdit() == nullptr) return;
+void MainWindow::slot_decrypt() {
+ if (edit_->TabCount() == 0 || edit_->SlotCurPageTextEdit() == nullptr) {
+ if (edit_->SlotCurPageFileTreeView() != nullptr) this->SlotFileDecrypt();
+ return;
+ }
auto decrypted = std::make_unique<ByteArray>();
- QByteArray text = edit->curTextPage()->getTextPage()->toPlainText().toUtf8();
+ QByteArray text = edit_->CurTextPage()->GetTextPage()->toPlainText().toUtf8();
if (text.trimmed().startsWith(GpgConstants::GPG_FRONTEND_SHORT_CRYPTO_HEAD)) {
QMessageBox::critical(
@@ -205,7 +215,7 @@ void MainWindow::slotDecrypt() {
process_operation(this, _("Decrypting"), [&]() {
try {
auto buffer = text.toStdString();
- error = GpgFrontend::BasicOperator::GetInstance().Decrypt(
+ error = GpgFrontend::GpgBasicOperator::GetInstance().Decrypt(
buffer, decrypted, result);
} catch (const std::runtime_error& e) {
if_error = true;
@@ -213,12 +223,12 @@ void MainWindow::slotDecrypt() {
});
if (!if_error) {
- auto resultAnalyse = DecryptResultAnalyse(error, std::move(result));
+ auto resultAnalyse = GpgDecryptResultAnalyse(error, std::move(result));
resultAnalyse.Analyse();
- process_result_analyse(edit, infoBoard, resultAnalyse);
+ process_result_analyse(edit_, info_board_, resultAnalyse);
if (check_gpg_error_2_err_code(error) == GPG_ERR_NO_ERROR)
- edit->slotFillTextEditWithText(QString::fromStdString(*decrypted));
+ edit_->SlotFillTextEditWithText(QString::fromStdString(*decrypted));
} else {
QMessageBox::critical(this, _("Error"),
_("An error occurred during operation."));
@@ -226,22 +236,25 @@ void MainWindow::slotDecrypt() {
}
}
-void MainWindow::slotFind() {
- if (edit->tabCount() == 0 || edit->curTextPage() == nullptr) {
+void MainWindow::slot_find() {
+ if (edit_->TabCount() == 0 || edit_->CurTextPage() == nullptr) {
return;
}
// At first close verifynotification, if existing
- edit->slotCurPageTextEdit()->closeNoteByClass("findwidget");
+ edit_->SlotCurPageTextEdit()->CloseNoteByClass("findwidget");
- auto* fw = new FindWidget(this, edit->curTextPage());
- edit->slotCurPageTextEdit()->showNotificationWidget(fw, "findWidget");
+ auto* fw = new FindWidget(this, edit_->CurTextPage());
+ edit_->SlotCurPageTextEdit()->ShowNotificationWidget(fw, "findWidget");
}
-void MainWindow::slotVerify() {
- if (edit->tabCount() == 0 || edit->slotCurPageTextEdit() == nullptr) return;
+void MainWindow::slot_verify() {
+ if (edit_->TabCount() == 0 || edit_->SlotCurPageTextEdit() == nullptr) {
+ if (edit_->SlotCurPageFileTreeView() != nullptr) this->SlotFileVerify();
+ return;
+ }
- auto text = edit->curTextPage()->getTextPage()->toPlainText().toUtf8();
+ auto text = edit_->CurTextPage()->GetTextPage()->toPlainText().toUtf8();
// TODO(Saturneric) PreventNoDataErr
auto sig_buffer = std::make_unique<ByteArray>();
@@ -253,7 +266,7 @@ void MainWindow::slotVerify() {
process_operation(this, _("Verifying"), [&]() {
try {
auto buffer = text.toStdString();
- error = GpgFrontend::BasicOperator::GetInstance().Verify(
+ error = GpgFrontend::GpgBasicOperator::GetInstance().Verify(
buffer, sig_buffer, result);
} catch (const std::runtime_error& e) {
if_error = true;
@@ -261,22 +274,26 @@ void MainWindow::slotVerify() {
});
if (!if_error) {
- auto result_analyse = VerifyResultAnalyse(error, result);
+ auto result_analyse = GpgVerifyResultAnalyse(error, result);
result_analyse.Analyse();
- process_result_analyse(edit, infoBoard, result_analyse);
+ process_result_analyse(edit_, info_board_, result_analyse);
if (result_analyse.GetStatus() == -2)
import_unknown_key_from_keyserver(this, result_analyse);
if (result_analyse.GetStatus() >= 0)
- show_verify_details(this, infoBoard, error, result);
+ show_verify_details(this, info_board_, error, result);
}
}
-void MainWindow::slotEncryptSign() {
- if (edit->tabCount() == 0 || edit->slotCurPageTextEdit() == nullptr) return;
+void MainWindow::slot_encrypt_sign() {
+ if (edit_->TabCount() == 0 || edit_->SlotCurPageTextEdit() == nullptr) {
+ if (edit_->SlotCurPageFileTreeView() != nullptr)
+ this->SlotFileEncryptSign();
+ return;
+ }
- auto key_ids = mKeyList->getChecked();
+ auto key_ids = m_key_list_->GetChecked();
if (key_ids->empty()) {
QMessageBox::critical(
@@ -302,10 +319,10 @@ void MainWindow::slotEncryptSign() {
auto signersPicker = new SignersPicker(this);
QEventLoop loop;
- connect(signersPicker, SIGNAL(finished(int)), &loop, SLOT(quit()));
+ connect(signersPicker, &SignersPicker::finished, &loop, &QEventLoop::quit);
loop.exec();
- auto signer_key_ids = signersPicker->getCheckedSigners();
+ auto signer_key_ids = signersPicker->GetCheckedSigners();
auto signer_keys = GpgKeyGetter::GetInstance().GetKeys(signer_key_ids);
for (const auto& key : *keys) {
@@ -324,12 +341,12 @@ void MainWindow::slotEncryptSign() {
auto tmp = std::make_unique<ByteArray>();
process_operation(this, _("Encrypting and Signing"), [&]() {
try {
- auto buffer = edit->curTextPage()
- ->getTextPage()
+ auto buffer = edit_->CurTextPage()
+ ->GetTextPage()
->toPlainText()
.toUtf8()
.toStdString();
- error = GpgFrontend::BasicOperator::GetInstance().EncryptSign(
+ error = GpgFrontend::GpgBasicOperator::GetInstance().EncryptSign(
std::move(keys), std::move(signer_keys), buffer, tmp, encr_result,
sign_result);
} catch (const std::runtime_error& e) {
@@ -351,20 +368,20 @@ void MainWindow::slotEncryptSign() {
}
}
#endif
- LOG(INFO) << "ResultAnalyse Started";
- auto encrypt_res = EncryptResultAnalyse(error, std::move(encr_result));
- auto sign_res = SignResultAnalyse(error, std::move(sign_result));
+ LOG(INFO) << "GpgResultAnalyse Started";
+ auto encrypt_res = GpgEncryptResultAnalyse(error, std::move(encr_result));
+ auto sign_res = GpgSignResultAnalyse(error, std::move(sign_result));
encrypt_res.Analyse();
sign_res.Analyse();
- process_result_analyse(edit, infoBoard, encrypt_res, sign_res);
+ process_result_analyse(edit_, info_board_, encrypt_res, sign_res);
if (check_gpg_error_2_err_code(error) == GPG_ERR_NO_ERROR)
- edit->slotFillTextEditWithText(QString::fromStdString(*tmp));
+ edit_->SlotFillTextEditWithText(QString::fromStdString(*tmp));
- infoBoard->resetOptionActionsMenu();
+ info_board_->ResetOptionActionsMenu();
#ifdef SMTP_SUPPORT
if (check_gpg_error_2_err_code(error) == GPG_ERR_NO_ERROR)
- send_an_email(this, infoBoard,
- edit->curTextPage()->getTextPage()->toPlainText(), false);
+ send_an_email(this, info_board_,
+ edit_->CurTextPage()->GetTextPage()->toPlainText(), false);
#endif
#ifdef ADVANCE_SUPPORT
@@ -385,10 +402,14 @@ void MainWindow::slotEncryptSign() {
}
}
-void MainWindow::slotDecryptVerify() {
- if (edit->tabCount() == 0 || edit->slotCurPageTextEdit() == nullptr) return;
+void MainWindow::slot_decrypt_verify() {
+ if (edit_->TabCount() == 0 || edit_->SlotCurPageTextEdit() == nullptr) {
+ if (edit_->SlotCurPageFileTreeView() != nullptr)
+ this->SlotFileDecryptVerify();
+ return;
+ }
- QString plainText = edit->curTextPage()->getTextPage()->toPlainText();
+ QString plainText = edit_->CurTextPage()->GetTextPage()->toPlainText();
#ifdef ADVANCE_SUPPORT
if (plainText.trimmed().startsWith(
@@ -424,27 +445,27 @@ void MainWindow::slotDecryptVerify() {
process_operation(this, _("Decrypting and Verifying"), [&]() {
try {
auto buffer = text.toStdString();
- error = BasicOperator::GetInstance().DecryptVerify(buffer, decrypted,
- d_result, v_result);
+ error = GpgBasicOperator::GetInstance().DecryptVerify(buffer, decrypted,
+ d_result, v_result);
} catch (const std::runtime_error& e) {
if_error = true;
}
});
if (!if_error) {
- auto decrypt_res = DecryptResultAnalyse(error, std::move(d_result));
- auto verify_res = VerifyResultAnalyse(error, v_result);
+ auto decrypt_res = GpgDecryptResultAnalyse(error, std::move(d_result));
+ auto verify_res = GpgVerifyResultAnalyse(error, v_result);
decrypt_res.Analyse();
verify_res.Analyse();
- process_result_analyse(edit, infoBoard, decrypt_res, verify_res);
+ process_result_analyse(edit_, info_board_, decrypt_res, verify_res);
if (check_gpg_error_2_err_code(error) == GPG_ERR_NO_ERROR)
- edit->slotFillTextEditWithText(QString::fromStdString(*decrypted));
+ edit_->SlotFillTextEditWithText(QString::fromStdString(*decrypted));
if (verify_res.GetStatus() == -2)
import_unknown_key_from_keyserver(this, verify_res);
if (verify_res.GetStatus() >= 0)
- show_verify_details(this, infoBoard, error, v_result);
+ show_verify_details(this, info_board_, error, v_result);
} else {
QMessageBox::critical(this, _("Error"),
@@ -456,21 +477,21 @@ void MainWindow::slotDecryptVerify() {
/*
* Append the selected (not checked!) Key(s) To Textedit
*/
-void MainWindow::slotAppendSelectedKeys() {
- if (edit->tabCount() == 0 || edit->slotCurPageTextEdit() == nullptr) {
+void MainWindow::slot_append_selected_keys() {
+ if (edit_->TabCount() == 0 || edit_->SlotCurPageTextEdit() == nullptr) {
return;
}
auto exported = std::make_unique<ByteArray>();
- auto key_ids = mKeyList->getSelected();
+ auto key_ids = m_key_list_->GetSelected();
GpgKeyImportExporter::GetInstance().ExportKeys(key_ids, exported);
- edit->curTextPage()->getTextPage()->appendPlainText(
+ edit_->CurTextPage()->GetTextPage()->appendPlainText(
QString::fromStdString(*exported));
}
-void MainWindow::slotCopyMailAddressToClipboard() {
- auto key_ids = mKeyList->getSelected();
+void MainWindow::slot_copy_mail_address_to_clipboard() {
+ auto key_ids = m_key_list_->GetSelected();
if (key_ids->empty()) return;
auto key = GpgKeyGetter::GetInstance().GetKey(key_ids->front());
@@ -482,8 +503,8 @@ void MainWindow::slotCopyMailAddressToClipboard() {
cb->setText(QString::fromStdString(key.GetEmail()));
}
-void MainWindow::slotShowKeyDetails() {
- auto key_ids = mKeyList->getSelected();
+void MainWindow::slot_show_key_details() {
+ auto key_ids = m_key_list_->GetSelected();
if (key_ids->empty()) return;
auto key = GpgKeyGetter::GetInstance().GetKey(key_ids->front());
@@ -494,25 +515,25 @@ void MainWindow::slotShowKeyDetails() {
}
}
-void MainWindow::refreshKeysFromKeyserver() {
- auto key_ids = mKeyList->getSelected();
+void MainWindow::refresh_keys_from_key_server() {
+ auto key_ids = m_key_list_->GetSelected();
if (key_ids->empty()) return;
auto* dialog = new KeyServerImportDialog(this);
dialog->show();
- dialog->slotImport(key_ids);
+ dialog->SlotImport(key_ids);
}
-void MainWindow::uploadKeyToServer() {
- auto key_ids = mKeyList->getSelected();
+void MainWindow::upload_key_to_server() {
+ auto key_ids = m_key_list_->GetSelected();
auto* dialog = new KeyUploadDialog(key_ids, this);
dialog->show();
- dialog->slotUpload();
+ dialog->SlotUpload();
}
-void MainWindow::slotOpenFile(QString& path) { edit->slotOpenFile(path); }
+void MainWindow::SlotOpenFile(QString& path) { edit_->SlotOpenFile(path); }
-void MainWindow::slotVersionUpgrade(const SoftwareVersion& version) {
+void MainWindow::slot_version_upgrade(const SoftwareVersion& version) {
LOG(INFO) << _("called");
if (version.NeedUpgrade()) {
statusBar()->showMessage(
diff --git a/src/ui/main_window/MainWindowSlotUI.cpp b/src/ui/main_window/MainWindowSlotUI.cpp
index 9f40ec9d..9d81b11c 100644
--- a/src/ui/main_window/MainWindowSlotUI.cpp
+++ b/src/ui/main_window/MainWindowSlotUI.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,53 +8,56 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include "MainWindow.h"
+#include "core/function/GlobalSettingStation.h"
#include "ui/UserInterfaceUtils.h"
-#include "ui/settings/GlobalSettingStation.h"
+#include "ui/struct/SettingsObject.h"
namespace GpgFrontend::UI {
-void MainWindow::slotSetStatusBarText(const QString& text) {
+void MainWindow::SlotSetStatusBarText(const QString& text) {
statusBar()->showMessage(text, 20000);
}
-void MainWindow::slotStartWizard() {
+void MainWindow::slot_start_wizard() {
auto* wizard = new Wizard(this);
wizard->show();
wizard->setModal(true);
}
-void MainWindow::slotImportKeyFromEdit() {
- if (edit->tabCount() == 0 || edit->slotCurPageTextEdit() == nullptr) return;
- CommonUtils::GetInstance()->slotImportKeys(
- this, edit->curTextPage()->getTextPage()->toPlainText().toStdString());
+void MainWindow::slot_import_key_from_edit() {
+ if (edit_->TabCount() == 0 || edit_->SlotCurPageTextEdit() == nullptr) return;
+ CommonUtils::GetInstance()->SlotImportKeys(
+ this, edit_->CurTextPage()->GetTextPage()->toPlainText().toStdString());
}
-void MainWindow::slotOpenKeyManagement() {
+void MainWindow::slot_open_key_management() {
auto* dialog = new KeyMgmt(this);
dialog->show();
dialog->raise();
}
-void MainWindow::slotOpenFileTab() { edit->slotNewFileTab(); }
+void MainWindow::slot_open_file_tab() { edit_->SlotNewFileTab(); }
-void MainWindow::slotDisableTabActions(int number) {
+void MainWindow::slot_disable_tab_actions(int number) {
bool disable;
if (number == -1)
@@ -60,109 +65,105 @@ void MainWindow::slotDisableTabActions(int number) {
else
disable = false;
- if (edit->curFilePage() != nullptr) {
+ if (edit_->CurFilePage() != nullptr) {
disable = true;
}
- printAct->setDisabled(disable);
- saveAct->setDisabled(disable);
- saveAsAct->setDisabled(disable);
- quoteAct->setDisabled(disable);
- cutAct->setDisabled(disable);
- copyAct->setDisabled(disable);
- pasteAct->setDisabled(disable);
- closeTabAct->setDisabled(disable);
- selectAllAct->setDisabled(disable);
- findAct->setDisabled(disable);
- verifyAct->setDisabled(disable);
- signAct->setDisabled(disable);
- encryptAct->setDisabled(disable);
- encryptSignAct->setDisabled(disable);
- decryptAct->setDisabled(disable);
- decryptVerifyAct->setDisabled(disable);
-
- redoAct->setDisabled(disable);
- undoAct->setDisabled(disable);
- zoomOutAct->setDisabled(disable);
- zoomInAct->setDisabled(disable);
- cleanDoubleLinebreaksAct->setDisabled(disable);
- quoteAct->setDisabled(disable);
- appendSelectedKeysAct->setDisabled(disable);
- importKeyFromEditAct->setDisabled(disable);
-
- cutPgpHeaderAct->setDisabled(disable);
- addPgpHeaderAct->setDisabled(disable);
+ print_act_->setDisabled(disable);
+ save_act_->setDisabled(disable);
+ save_as_act_->setDisabled(disable);
+ quote_act_->setDisabled(disable);
+ cut_act_->setDisabled(disable);
+ copy_act_->setDisabled(disable);
+ paste_act_->setDisabled(disable);
+ close_tab_act_->setDisabled(disable);
+ select_all_act_->setDisabled(disable);
+ find_act_->setDisabled(disable);
+ verify_act_->setDisabled(disable);
+ sign_act_->setDisabled(disable);
+ encrypt_act_->setDisabled(disable);
+ encrypt_sign_act_->setDisabled(disable);
+ decrypt_act_->setDisabled(disable);
+ decrypt_verify_act_->setDisabled(disable);
+
+ redo_act_->setDisabled(disable);
+ undo_act_->setDisabled(disable);
+ zoom_out_act_->setDisabled(disable);
+ zoom_in_act_->setDisabled(disable);
+ clean_double_line_breaks_act_->setDisabled(disable);
+ quote_act_->setDisabled(disable);
+ append_selected_keys_act_->setDisabled(disable);
+ import_key_from_edit_act_->setDisabled(disable);
+
+ cut_pgp_header_act_->setDisabled(disable);
+ add_pgp_header_act_->setDisabled(disable);
}
-void MainWindow::slotOpenSettingsDialog() {
+void MainWindow::slot_open_settings_dialog() {
auto dialog = new SettingsDialog(this);
connect(dialog, &SettingsDialog::finished, this, [&]() -> void {
LOG(INFO) << "Setting Dialog Finished";
- auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ SettingsObject main_windows_state("main_windows_state");
- int icon_width = settings["window"]["icon_size"]["width"];
- int icon_height = settings["window"]["icon_size"]["height"];
+ int width = main_windows_state.Check("icon_size").Check("width", 24),
+ height = main_windows_state.Check("icon_size").Check("height", 24);
+ LOG(INFO) << "icon_size" << width << height;
- this->setIconSize(QSize(icon_width, icon_height));
- importButton->setIconSize(QSize(icon_width, icon_height));
+ main_windows_state.Check("info_font_size", 10);
- // Iconstyle
+ // icon_style
+ int s_icon_style =
+ main_windows_state.Check("icon_style", Qt::ToolButtonTextUnderIcon);
+ auto icon_style = static_cast<Qt::ToolButtonStyle>(s_icon_style);
+ this->setToolButtonStyle(icon_style);
+ import_button_->setToolButtonStyle(icon_style);
- int icon_style = settings["window"]["icon_style"];
- auto button_style = static_cast<Qt::ToolButtonStyle>(icon_style);
- this->setToolButtonStyle(button_style);
- importButton->setToolButtonStyle(button_style);
+ // icons ize
+ this->setIconSize(QSize(width, height));
+ import_button_->setIconSize(QSize(width, height));
// restart mainwindow if necessary
- if (getRestartNeeded()) {
- if (edit->maybeSaveAnyTab()) {
- saveSettings();
+ if (get_restart_needed()) {
+ if (edit_->MaybeSaveAnyTab()) {
+ save_settings();
qApp->exit(RESTART_CODE);
}
}
-#ifdef ADVANCED_SUPPORT
- // steganography hide/show
- if (!settings.value("advanced/steganography").toBool()) {
- this->menuBar()->removeAction(steganoMenu->menuAction());
- } else {
- this->menuBar()->insertAction(viewMenu->menuAction(),
- steganoMenu->menuAction());
- }
-#endif
});
}
-void MainWindow::slotCleanDoubleLinebreaks() {
- if (edit->tabCount() == 0 || edit->slotCurPageTextEdit() == nullptr) {
+void MainWindow::slot_clean_double_line_breaks() {
+ if (edit_->TabCount() == 0 || edit_->SlotCurPageTextEdit() == nullptr) {
return;
}
- QString content = edit->curTextPage()->getTextPage()->toPlainText();
+ QString content = edit_->CurTextPage()->GetTextPage()->toPlainText();
content.replace("\n\n", "\n");
- edit->slotFillTextEditWithText(content);
+ edit_->SlotFillTextEditWithText(content);
}
-void MainWindow::slotAddPgpHeader() {
- if (edit->tabCount() == 0 || edit->slotCurPageTextEdit() == nullptr) {
+void MainWindow::slot_add_pgp_header() {
+ if (edit_->TabCount() == 0 || edit_->SlotCurPageTextEdit() == nullptr) {
return;
}
- QString content = edit->curTextPage()->getTextPage()->toPlainText().trimmed();
+ QString content =
+ edit_->CurTextPage()->GetTextPage()->toPlainText().trimmed();
content.prepend("\n\n").prepend(GpgConstants::PGP_CRYPT_BEGIN);
content.append("\n").append(GpgConstants::PGP_CRYPT_END);
- edit->slotFillTextEditWithText(content);
+ edit_->SlotFillTextEditWithText(content);
}
-void MainWindow::slotCutPgpHeader() {
- if (edit->tabCount() == 0 || edit->slotCurPageTextEdit() == nullptr) {
+void MainWindow::slot_cut_pgp_header() {
+ if (edit_->TabCount() == 0 || edit_->SlotCurPageTextEdit() == nullptr) {
return;
}
- QString content = edit->curTextPage()->getTextPage()->toPlainText();
+ QString content = edit_->CurTextPage()->GetTextPage()->toPlainText();
int start = content.indexOf(GpgConstants::PGP_CRYPT_BEGIN);
int end = content.indexOf(GpgConstants::PGP_CRYPT_END);
@@ -178,13 +179,46 @@ void MainWindow::slotCutPgpHeader() {
end = content.indexOf(GpgConstants::PGP_CRYPT_END);
content.remove(end, QString(GpgConstants::PGP_CRYPT_END).size());
- edit->slotFillTextEditWithText(content.trimmed());
+ edit_->SlotFillTextEditWithText(content.trimmed());
}
-void MainWindow::slotSetRestartNeeded(bool needed) {
- this->restartNeeded = needed;
+void MainWindow::SlotSetRestartNeeded(bool needed) {
+ this->restart_needed_ = needed;
}
-bool MainWindow::getRestartNeeded() const { return this->restartNeeded; }
+bool MainWindow::get_restart_needed() const { return this->restart_needed_; }
+
+void MainWindow::SetCryptoMenuStatus(
+ MainWindow::CryptoMenu::OperationType type) {
+ LOG(INFO) << "SetCryptoMenuStatus" << type;
+
+ // refresh status to disable all
+ verify_act_->setDisabled(true);
+ sign_act_->setDisabled(true);
+ encrypt_act_->setDisabled(true);
+ encrypt_sign_act_->setDisabled(true);
+ decrypt_act_->setDisabled(true);
+ decrypt_verify_act_->setDisabled(true);
+
+ // enable according to type
+ if (type & MainWindow::CryptoMenu::Verify) {
+ verify_act_->setDisabled(false);
+ }
+ if (type & MainWindow::CryptoMenu::Sign) {
+ sign_act_->setDisabled(false);
+ }
+ if (type & MainWindow::CryptoMenu::Encrypt) {
+ encrypt_act_->setDisabled(false);
+ }
+ if (type & MainWindow::CryptoMenu::EncryptAndSign) {
+ encrypt_sign_act_->setDisabled(false);
+ }
+ if (type & MainWindow::CryptoMenu::Decrypt) {
+ decrypt_act_->setDisabled(false);
+ }
+ if (type & MainWindow::CryptoMenu::DecryptAndVerify) {
+ decrypt_verify_act_->setDisabled(false);
+ }
+}
} // namespace GpgFrontend::UI
diff --git a/src/ui/main_window/MainWindowUI.cpp b/src/ui/main_window/MainWindowUI.cpp
index 3d1e45b8..01c4bbc9 100644
--- a/src/ui/main_window/MainWindowUI.cpp
+++ b/src/ui/main_window/MainWindowUI.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,449 +8,457 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include "MainWindow.h"
#include "ui/UserInterfaceUtils.h"
#ifdef SMTP_SUPPORT
-#include "ui/smtp/ReceiveMailDialog.h"
-#include "ui/smtp/SendMailDialog.h"
+#include "ui/mail/ReceiveMailDialog.h"
+#include "ui/mail/SendMailDialog.h"
#endif
namespace GpgFrontend::UI {
-void MainWindow::createActions() {
+void MainWindow::create_actions() {
/* Main Menu
*/
- newTabAct = new QAction(_("New"), this);
- newTabAct->setIcon(QIcon(":misc_doc.png"));
+ new_tab_act_ = new QAction(_("New"), this);
+ new_tab_act_->setIcon(QIcon(":misc_doc.png"));
QList<QKeySequence> newTabActShortcutList;
newTabActShortcutList.append(QKeySequence(Qt::CTRL + Qt::Key_N));
newTabActShortcutList.append(QKeySequence(Qt::CTRL + Qt::Key_T));
- newTabAct->setShortcuts(newTabActShortcutList);
- newTabAct->setToolTip(_("Open a new file"));
- connect(newTabAct, SIGNAL(triggered()), edit, SLOT(slotNewTab()));
-
- openAct = new QAction(_("Open..."), this);
- openAct->setIcon(QIcon(":fileopen.png"));
- openAct->setShortcut(QKeySequence::Open);
- openAct->setToolTip(_("Open an existing file"));
- connect(openAct, SIGNAL(triggered()), edit, SLOT(slotOpen()));
-
- browserAct = new QAction(_("File Browser"), this);
- browserAct->setIcon(QIcon(":file-browser.png"));
- browserAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B));
- browserAct->setToolTip(_("Open a file browser"));
- connect(browserAct, SIGNAL(triggered()), this, SLOT(slotOpenFileTab()));
-
- saveAct = new QAction(_("Save File"), this);
- saveAct->setIcon(QIcon(":filesave.png"));
- saveAct->setShortcut(QKeySequence::Save);
- saveAct->setToolTip(_("Save the current File"));
- connect(saveAct, SIGNAL(triggered()), edit, SLOT(slotSave()));
-
- saveAsAct = new QAction(QString(_("Save As")) + "...", this);
- saveAsAct->setIcon(QIcon(":filesaveas.png"));
- saveAsAct->setShortcut(QKeySequence::SaveAs);
- saveAsAct->setToolTip(_("Save the current File as..."));
- connect(saveAsAct, SIGNAL(triggered()), edit, SLOT(slotSaveAs()));
-
- printAct = new QAction(_("Print"), this);
- printAct->setIcon(QIcon(":fileprint.png"));
- printAct->setShortcut(QKeySequence::Print);
- printAct->setToolTip(_("Print Document"));
- connect(printAct, SIGNAL(triggered()), edit, SLOT(slotPrint()));
-
- closeTabAct = new QAction(_("Close"), this);
- closeTabAct->setShortcut(QKeySequence::Close);
- closeTabAct->setToolTip(_("Close file"));
- connect(closeTabAct, SIGNAL(triggered()), edit, SLOT(slotCloseTab()));
-
- quitAct = new QAction(_("Quit"), this);
- quitAct->setShortcut(QKeySequence::Quit);
- quitAct->setIcon(QIcon(":exit.png"));
- quitAct->setToolTip(_("Quit Program"));
- connect(quitAct, SIGNAL(triggered()), this, SLOT(close()));
+ new_tab_act_->setShortcuts(newTabActShortcutList);
+ new_tab_act_->setToolTip(_("Open a new file"));
+ connect(new_tab_act_, &QAction::triggered, edit_, &TextEdit::SlotNewTab);
+
+ open_act_ = new QAction(_("Open..."), this);
+ open_act_->setIcon(QIcon(":fileopen.png"));
+ open_act_->setShortcut(QKeySequence::Open);
+ open_act_->setToolTip(_("Open an existing file"));
+ connect(open_act_, &QAction::triggered, edit_, &TextEdit::SlotOpen);
+
+ browser_act_ = new QAction(_("File Browser"), this);
+ browser_act_->setIcon(QIcon(":file-browser.png"));
+ browser_act_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B));
+ browser_act_->setToolTip(_("Open a file browser"));
+ connect(browser_act_, &QAction::triggered, this, &MainWindow::slot_open_file_tab);
+
+ save_act_ = new QAction(_("Save File"), this);
+ save_act_->setIcon(QIcon(":filesave.png"));
+ save_act_->setShortcut(QKeySequence::Save);
+ save_act_->setToolTip(_("Save the current File"));
+ connect(save_act_, &QAction::triggered, edit_, &TextEdit::SlotSave);
+
+ save_as_act_ = new QAction(QString(_("Save As")) + "...", this);
+ save_as_act_->setIcon(QIcon(":filesaveas.png"));
+ save_as_act_->setShortcut(QKeySequence::SaveAs);
+ save_as_act_->setToolTip(_("Save the current File as..."));
+ connect(save_as_act_, &QAction::triggered, edit_, &TextEdit::SlotSaveAs);
+
+ print_act_ = new QAction(_("Print"), this);
+ print_act_->setIcon(QIcon(":fileprint.png"));
+ print_act_->setShortcut(QKeySequence::Print);
+ print_act_->setToolTip(_("Print Document"));
+ connect(print_act_, &QAction::triggered, edit_, &TextEdit::SlotPrint);
+
+ close_tab_act_ = new QAction(_("Close"), this);
+ close_tab_act_->setShortcut(QKeySequence::Close);
+ close_tab_act_->setToolTip(_("Close file"));
+ connect(close_tab_act_, &QAction::triggered, edit_, &TextEdit::SlotCloseTab);
+
+ quit_act_ = new QAction(_("Quit"), this);
+ quit_act_->setShortcut(QKeySequence::Quit);
+ quit_act_->setIcon(QIcon(":exit.png"));
+ quit_act_->setToolTip(_("Quit Program"));
+ connect(quit_act_, &QAction::triggered, this, &MainWindow::close);
/* Edit Menu
*/
- undoAct = new QAction(_("Undo"), this);
- undoAct->setShortcut(QKeySequence::Undo);
- undoAct->setToolTip(_("Undo Last Edit Action"));
- connect(undoAct, SIGNAL(triggered()), edit, SLOT(slotUndo()));
-
- redoAct = new QAction(_("Redo"), this);
- redoAct->setShortcut(QKeySequence::Redo);
- redoAct->setToolTip(_("Redo Last Edit Action"));
- connect(redoAct, SIGNAL(triggered()), edit, SLOT(slotRedo()));
-
- zoomInAct = new QAction(_("Zoom In"), this);
- zoomInAct->setShortcut(QKeySequence::ZoomIn);
- connect(zoomInAct, SIGNAL(triggered()), edit, SLOT(slotZoomIn()));
-
- zoomOutAct = new QAction(_("Zoom Out"), this);
- zoomOutAct->setShortcut(QKeySequence::ZoomOut);
- connect(zoomOutAct, SIGNAL(triggered()), edit, SLOT(slotZoomOut()));
-
- pasteAct = new QAction(_("Paste"), this);
- pasteAct->setIcon(QIcon(":button_paste.png"));
- pasteAct->setShortcut(QKeySequence::Paste);
- pasteAct->setToolTip(_("Paste Text From Clipboard"));
- connect(pasteAct, SIGNAL(triggered()), edit, SLOT(slotPaste()));
-
- cutAct = new QAction(_("Cut"), this);
- cutAct->setIcon(QIcon(":button_cut.png"));
- cutAct->setShortcut(QKeySequence::Cut);
- cutAct->setToolTip(
+ undo_act_ = new QAction(_("Undo"), this);
+ undo_act_->setShortcut(QKeySequence::Undo);
+ undo_act_->setToolTip(_("Undo Last Edit Action"));
+ connect(undo_act_, &QAction::triggered, edit_, &TextEdit::SlotUndo);
+
+ redo_act_ = new QAction(_("Redo"), this);
+ redo_act_->setShortcut(QKeySequence::Redo);
+ redo_act_->setToolTip(_("Redo Last Edit Action"));
+ connect(redo_act_, &QAction::triggered, edit_, &TextEdit::SlotRedo);
+
+ zoom_in_act_ = new QAction(_("Zoom In"), this);
+ zoom_in_act_->setShortcut(QKeySequence::ZoomIn);
+ connect(zoom_in_act_, &QAction::triggered, edit_, &TextEdit::SlotZoomIn);
+
+ zoom_out_act_ = new QAction(_("Zoom Out"), this);
+ zoom_out_act_->setShortcut(QKeySequence::ZoomOut);
+ connect(zoom_out_act_, &QAction::triggered, edit_, &TextEdit::SlotZoomOut);
+
+ paste_act_ = new QAction(_("Paste"), this);
+ paste_act_->setIcon(QIcon(":button_paste.png"));
+ paste_act_->setShortcut(QKeySequence::Paste);
+ paste_act_->setToolTip(_("Paste Text From Clipboard"));
+ connect(paste_act_, &QAction::triggered, edit_, &TextEdit::SlotPaste);
+
+ cut_act_ = new QAction(_("Cut"), this);
+ cut_act_->setIcon(QIcon(":button_cut.png"));
+ cut_act_->setShortcut(QKeySequence::Cut);
+ cut_act_->setToolTip(
_("Cut the current selection's contents to the "
"clipboard"));
- connect(cutAct, SIGNAL(triggered()), edit, SLOT(slotCut()));
+ connect(cut_act_, &QAction::triggered, edit_, &TextEdit::SlotCut);
- copyAct = new QAction(_("Copy"), this);
- copyAct->setIcon(QIcon(":button_copy.png"));
- copyAct->setShortcut(QKeySequence::Copy);
- copyAct->setToolTip(
+ copy_act_ = new QAction(_("Copy"), this);
+ copy_act_->setIcon(QIcon(":button_copy.png"));
+ copy_act_->setShortcut(QKeySequence::Copy);
+ copy_act_->setToolTip(
_("Copy the current selection's contents to the "
"clipboard"));
- connect(copyAct, SIGNAL(triggered()), edit, SLOT(slotCopy()));
-
- quoteAct = new QAction(_("Quote"), this);
- quoteAct->setIcon(QIcon(":quote.png"));
- quoteAct->setToolTip(_("Quote whole text"));
- connect(quoteAct, SIGNAL(triggered()), edit, SLOT(slotQuote()));
-
- selectAllAct = new QAction(_("Select All"), this);
- selectAllAct->setIcon(QIcon(":edit.png"));
- selectAllAct->setShortcut(QKeySequence::SelectAll);
- selectAllAct->setToolTip(_("Select the whole text"));
- connect(selectAllAct, SIGNAL(triggered()), edit, SLOT(slotSelectAll()));
-
- findAct = new QAction(_("Find"), this);
- findAct->setShortcut(QKeySequence::Find);
- findAct->setToolTip(_("Find a word"));
- connect(findAct, SIGNAL(triggered()), this, SLOT(slotFind()));
-
- cleanDoubleLinebreaksAct = new QAction(_("Remove spacing"), this);
- cleanDoubleLinebreaksAct->setIcon(QIcon(":format-line-spacing-triple.png"));
+ connect(copy_act_, &QAction::triggered, edit_, &TextEdit::SlotCopy);
+
+ quote_act_ = new QAction(_("Quote"), this);
+ quote_act_->setIcon(QIcon(":quote.png"));
+ quote_act_->setToolTip(_("Quote whole text"));
+ connect(quote_act_, &QAction::triggered, edit_, &TextEdit::SlotQuote);
+
+ select_all_act_ = new QAction(_("Select All"), this);
+ select_all_act_->setIcon(QIcon(":edit.png"));
+ select_all_act_->setShortcut(QKeySequence::SelectAll);
+ select_all_act_->setToolTip(_("Select the whole text"));
+ connect(select_all_act_, &QAction::triggered, edit_, &TextEdit::SlotSelectAll);
+
+ find_act_ = new QAction(_("Find"), this);
+ find_act_->setShortcut(QKeySequence::Find);
+ find_act_->setToolTip(_("Find a word"));
+ connect(find_act_, &QAction::triggered, this, &MainWindow::slot_find);
+
+ clean_double_line_breaks_act_ = new QAction(_("Remove spacing"), this);
+ clean_double_line_breaks_act_->setIcon(
+ QIcon(":format-line-spacing-triple.png"));
// cleanDoubleLineBreaksAct->setShortcut(QKeySequence::SelectAll);
- cleanDoubleLinebreaksAct->setToolTip(
+ clean_double_line_breaks_act_->setToolTip(
_("Remove double linebreaks, e.g. in pasted text from Web Mailer"));
- connect(cleanDoubleLinebreaksAct, SIGNAL(triggered()), this,
- SLOT(slotCleanDoubleLinebreaks()));
+ connect(clean_double_line_breaks_act_, &QAction::triggered, this,
+ &MainWindow::slot_clean_double_line_breaks);
- openSettingsAct = new QAction(_("Settings"), this);
- openSettingsAct->setToolTip(_("Open settings dialog"));
- openSettingsAct->setShortcut(QKeySequence::Preferences);
- connect(openSettingsAct, SIGNAL(triggered()), this,
- SLOT(slotOpenSettingsDialog()));
+ open_settings_act_ = new QAction(_("Settings"), this);
+ open_settings_act_->setToolTip(_("Open settings dialog"));
+ open_settings_act_->setShortcut(QKeySequence::Preferences);
+ connect(open_settings_act_, &QAction::triggered, this,
+ &MainWindow::slot_open_settings_dialog);
/* Crypt Menu
*/
- encryptAct = new QAction(_("Encrypt"), this);
- encryptAct->setIcon(QIcon(":encrypted.png"));
- encryptAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_E));
- encryptAct->setToolTip(_("Encrypt Message"));
- connect(encryptAct, SIGNAL(triggered()), this, SLOT(slotEncrypt()));
-
- encryptSignAct = new QAction(_("Encrypt Sign"), this);
- encryptSignAct->setIcon(QIcon(":encrypted_signed.png"));
- encryptSignAct->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_E));
- encryptSignAct->setToolTip(_("Encrypt and Sign Message"));
- connect(encryptSignAct, SIGNAL(triggered()), this, SLOT(slotEncryptSign()));
-
- decryptAct = new QAction(_("Decrypt"), this);
- decryptAct->setIcon(QIcon(":decrypted.png"));
- decryptAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
- decryptAct->setToolTip(_("Decrypt Message"));
- connect(decryptAct, SIGNAL(triggered()), this, SLOT(slotDecrypt()));
-
- decryptVerifyAct = new QAction(_("Decrypt Verify"), this);
- decryptVerifyAct->setIcon(QIcon(":decrypted_verified.png"));
- decryptVerifyAct->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D));
- decryptVerifyAct->setToolTip(_("Decrypt and Verify Message"));
- connect(decryptVerifyAct, SIGNAL(triggered()), this,
- SLOT(slotDecryptVerify()));
-
- signAct = new QAction(_("Sign"), this);
- signAct->setIcon(QIcon(":signature.png"));
- signAct->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I));
- signAct->setToolTip(_("Sign Message"));
- connect(signAct, SIGNAL(triggered()), this, SLOT(slotSign()));
-
- verifyAct = new QAction(_("Verify"), this);
- verifyAct->setIcon(QIcon(":verify.png"));
- verifyAct->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_V));
- verifyAct->setToolTip(_("Verify Message"));
- connect(verifyAct, SIGNAL(triggered()), this, SLOT(slotVerify()));
+ encrypt_act_ = new QAction(_("Encrypt"), this);
+ encrypt_act_->setIcon(QIcon(":encrypted.png"));
+ encrypt_act_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_E));
+ encrypt_act_->setToolTip(_("Encrypt Message"));
+ connect(encrypt_act_, &QAction::triggered, this, &MainWindow::slot_encrypt);
+
+ encrypt_sign_act_ = new QAction(_("Encrypt Sign"), this);
+ encrypt_sign_act_->setIcon(QIcon(":encrypted_signed.png"));
+ encrypt_sign_act_->setShortcut(
+ QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_E));
+ encrypt_sign_act_->setToolTip(_("Encrypt and Sign Message"));
+ connect(encrypt_sign_act_, &QAction::triggered, this,
+ &MainWindow::slot_encrypt_sign);
+
+ decrypt_act_ = new QAction(_("Decrypt"), this);
+ decrypt_act_->setIcon(QIcon(":decrypted.png"));
+ decrypt_act_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
+ decrypt_act_->setToolTip(_("Decrypt Message"));
+ connect(decrypt_act_, &QAction::triggered, this, &MainWindow::slot_decrypt);
+
+ decrypt_verify_act_ = new QAction(_("Decrypt Verify"), this);
+ decrypt_verify_act_->setIcon(QIcon(":decrypted_verified.png"));
+ decrypt_verify_act_->setShortcut(
+ QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D));
+ decrypt_verify_act_->setToolTip(_("Decrypt and Verify Message"));
+ connect(decrypt_verify_act_, &QAction::triggered, this,
+ &MainWindow::slot_decrypt_verify);
+
+ sign_act_ = new QAction(_("Sign"), this);
+ sign_act_->setIcon(QIcon(":signature.png"));
+ sign_act_->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I));
+ sign_act_->setToolTip(_("Sign Message"));
+ connect(sign_act_, &QAction::triggered, this, &MainWindow::slot_sign);
+
+ verify_act_ = new QAction(_("Verify"), this);
+ verify_act_->setIcon(QIcon(":verify.png"));
+ verify_act_->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_V));
+ verify_act_->setToolTip(_("Verify Message"));
+ connect(verify_act_, &QAction::triggered, this, &MainWindow::slot_verify);
/* Key Menu
*/
- importKeyFromFileAct = new QAction(_("File"), this);
- importKeyFromFileAct->setIcon(QIcon(":import_key_from_file.png"));
- importKeyFromFileAct->setToolTip(_("Import New Key From File"));
- connect(importKeyFromFileAct, &QAction::triggered, this,
- [&]() { CommonUtils::GetInstance()->slotImportKeyFromFile(this); });
-
- importKeyFromClipboardAct = new QAction(_("Clipboard"), this);
- importKeyFromClipboardAct->setIcon(QIcon(":import_key_from_clipboard.png"));
- importKeyFromClipboardAct->setToolTip(_("Import New Key From Clipboard"));
- connect(importKeyFromClipboardAct, &QAction::triggered, this, [&]() {
- CommonUtils::GetInstance()->slotImportKeyFromClipboard(this);
+ import_key_from_file_act_ = new QAction(_("File"), this);
+ import_key_from_file_act_->setIcon(QIcon(":import_key_from_file.png"));
+ import_key_from_file_act_->setToolTip(_("Import New Key From File"));
+ connect(import_key_from_file_act_, &QAction::triggered, this,
+ [&]() { CommonUtils::GetInstance()->SlotImportKeyFromFile(this); });
+
+ import_key_from_clipboard_act_ = new QAction(_("Clipboard"), this);
+ import_key_from_clipboard_act_->setIcon(
+ QIcon(":import_key_from_clipboard.png"));
+ import_key_from_clipboard_act_->setToolTip(
+ _("Import New Key From Clipboard"));
+ connect(import_key_from_clipboard_act_, &QAction::triggered, this, [&]() {
+ CommonUtils::GetInstance()->SlotImportKeyFromClipboard(this);
});
- importKeyFromKeyServerAct = new QAction(_("Keyserver"), this);
- importKeyFromKeyServerAct->setIcon(QIcon(":import_key_from_server.png"));
- importKeyFromKeyServerAct->setToolTip(_("Import New Key From Keyserver"));
- connect(importKeyFromKeyServerAct, &QAction::triggered, this, [&]() {
- CommonUtils::GetInstance()->slotImportKeyFromKeyServer(this);
+ import_key_from_key_server_act_ = new QAction(_("Keyserver"), this);
+ import_key_from_key_server_act_->setIcon(
+ QIcon(":import_key_from_server.png"));
+ import_key_from_key_server_act_->setToolTip(
+ _("Import New Key From Keyserver"));
+ connect(import_key_from_key_server_act_, &QAction::triggered, this, [&]() {
+ CommonUtils::GetInstance()->SlotImportKeyFromKeyServer(this);
});
- importKeyFromEditAct = new QAction(_("Editor"), this);
- importKeyFromEditAct->setIcon(QIcon(":txt.png"));
- importKeyFromEditAct->setToolTip(_("Import New Key From Editor"));
- connect(importKeyFromEditAct, SIGNAL(triggered()), this,
- SLOT(slotImportKeyFromEdit()));
+ import_key_from_edit_act_ = new QAction(_("Editor"), this);
+ import_key_from_edit_act_->setIcon(QIcon(":txt.png"));
+ import_key_from_edit_act_->setToolTip(_("Import New Key From Editor"));
+ connect(import_key_from_edit_act_, &QAction::triggered, this,
+ &MainWindow::slot_import_key_from_edit);
- openKeyManagementAct = new QAction(_("Manage Keys"), this);
- openKeyManagementAct->setIcon(QIcon(":keymgmt.png"));
- openKeyManagementAct->setToolTip(_("Open Key Management"));
- connect(openKeyManagementAct, SIGNAL(triggered()), this,
- SLOT(slotOpenKeyManagement()));
+ open_key_management_act_ = new QAction(_("Manage Keys"), this);
+ open_key_management_act_->setIcon(QIcon(":keymgmt.png"));
+ open_key_management_act_->setToolTip(_("Open Key Management"));
+ connect(open_key_management_act_, &QAction::triggered, this,
+ &MainWindow::slot_open_key_management);
/*
* About Menu
*/
- aboutAct = new QAction(_("About"), this);
- aboutAct->setIcon(QIcon(":help.png"));
- aboutAct->setToolTip(_("Show the application's About box"));
- connect(aboutAct, &QAction::triggered, this,
+ about_act_ = new QAction(_("About"), this);
+ about_act_->setIcon(QIcon(":help.png"));
+ about_act_->setToolTip(_("Show the application's About box"));
+ connect(about_act_, &QAction::triggered, this,
[=]() { new AboutDialog(0, this); });
- translateAct = new QAction(_("Translate"), this);
- translateAct->setIcon(QIcon(":help.png"));
- translateAct->setToolTip(_("Information about translation"));
- connect(translateAct, &QAction::triggered, this,
+ translate_act_ = new QAction(_("Translate"), this);
+ translate_act_->setIcon(QIcon(":help.png"));
+ translate_act_->setToolTip(_("Information about translation"));
+ connect(translate_act_, &QAction::triggered, this,
[=]() { new AboutDialog(1, this); });
/*
* Check Update Menu
*/
- checkUpdateAct = new QAction(_("Check for Updates"), this);
- checkUpdateAct->setIcon(QIcon(":help.png"));
- checkUpdateAct->setToolTip(_("Check for updates"));
- connect(checkUpdateAct, &QAction::triggered, this,
+ check_update_act_ = new QAction(_("Check for Updates"), this);
+ check_update_act_->setIcon(QIcon(":help.png"));
+ check_update_act_->setToolTip(_("Check for updates"));
+ connect(check_update_act_, &QAction::triggered, this,
[=]() { new AboutDialog(2, this); });
- startWizardAct = new QAction(_("Open Wizard"), this);
- startWizardAct->setToolTip(_("Open the wizard"));
- connect(startWizardAct, SIGNAL(triggered()), this, SLOT(slotStartWizard()));
+ start_wizard_act_ = new QAction(_("Open Wizard"), this);
+ start_wizard_act_->setToolTip(_("Open the wizard"));
+ connect(start_wizard_act_, &QAction::triggered, this,
+ &MainWindow::slot_start_wizard);
/* Popup-Menu-Action for KeyList
*/
- appendSelectedKeysAct =
- new QAction(_("Append Public Key To Text Editor"), this);
- appendSelectedKeysAct->setToolTip(
- _("Append The Selected Keys To Text in Editor"));
- connect(appendSelectedKeysAct, SIGNAL(triggered()), this,
- SLOT(slotAppendSelectedKeys()));
-
- copyMailAddressToClipboardAct = new QAction(_("Copy Email"), this);
- copyMailAddressToClipboardAct->setToolTip(
+ append_selected_keys_act_ =
+ new QAction(_("Append To Text Editor"), this);
+ append_selected_keys_act_->setToolTip(
+ _("Append The Selected Public Key To Text in Editor"));
+ connect(append_selected_keys_act_, &QAction::triggered, this,
+ &MainWindow::slot_append_selected_keys);
+
+ copy_mail_address_to_clipboard_act_ = new QAction(_("Copy Email"), this);
+ copy_mail_address_to_clipboard_act_->setToolTip(
_("Copy selected Email to clipboard"));
- connect(copyMailAddressToClipboardAct, SIGNAL(triggered()), this,
- SLOT(slotCopyMailAddressToClipboard()));
+ connect(copy_mail_address_to_clipboard_act_, &QAction::triggered, this,
+ &MainWindow::slot_copy_mail_address_to_clipboard);
// TODO: find central place for shared actions, to avoid code-duplication with
// keymgmt.cpp
- showKeyDetailsAct = new QAction(_("Show Key Details"), this);
- showKeyDetailsAct->setToolTip(_("Show Details for this Key"));
- connect(showKeyDetailsAct, SIGNAL(triggered()), this,
- SLOT(slotShowKeyDetails()));
+ show_key_details_act_ = new QAction(_("Show Key Details"), this);
+ show_key_details_act_->setToolTip(_("Show Details for this Key"));
+ connect(show_key_details_act_, &QAction::triggered, this,
+ &MainWindow::slot_show_key_details);
/* Key-Shortcuts for Tab-Switchung-Action
*/
- switchTabUpAct = new QAction(this);
- switchTabUpAct->setShortcut(QKeySequence::NextChild);
- connect(switchTabUpAct, SIGNAL(triggered()), edit, SLOT(slotSwitchTabUp()));
- this->addAction(switchTabUpAct);
-
- switchTabDownAct = new QAction(this);
- switchTabDownAct->setShortcut(QKeySequence::PreviousChild);
- connect(switchTabDownAct, SIGNAL(triggered()), edit,
- SLOT(slotSwitchTabDown()));
- this->addAction(switchTabDownAct);
-
- cutPgpHeaderAct = new QAction(_("Remove PGP Header"), this);
- connect(cutPgpHeaderAct, SIGNAL(triggered()), this, SLOT(slotCutPgpHeader()));
-
- addPgpHeaderAct = new QAction(_("Add PGP Header"), this);
- connect(addPgpHeaderAct, SIGNAL(triggered()), this, SLOT(slotAddPgpHeader()));
+ switch_tab_up_act_ = new QAction(this);
+ switch_tab_up_act_->setShortcut(QKeySequence::NextChild);
+ connect(switch_tab_up_act_, &QAction::triggered, edit_,
+ &TextEdit::SlotSwitchTabUp);
+ this->addAction(switch_tab_up_act_);
+
+ switch_tab_down_act_ = new QAction(this);
+ switch_tab_down_act_->setShortcut(QKeySequence::PreviousChild);
+ connect(switch_tab_down_act_, &QAction::triggered, edit_,
+ &TextEdit::SlotSwitchTabDown);
+ this->addAction(switch_tab_down_act_);
+
+ cut_pgp_header_act_ = new QAction(_("Remove PGP Header"), this);
+ connect(cut_pgp_header_act_, &QAction::triggered, this,
+ &MainWindow::slot_cut_pgp_header);
+
+ add_pgp_header_act_ = new QAction(_("Add PGP Header"), this);
+ connect(add_pgp_header_act_, &QAction::triggered, this,
+ &MainWindow::slot_add_pgp_header);
#ifdef SMTP_SUPPORT
- sendMailAct = new QAction(_("New Message"), this);
- sendMailAct->setIcon(QIcon(":email.png"));
- connect(sendMailAct, &QAction::triggered, this, [=]() {
+ send_mail_act_ = new QAction(_("New Message"), this);
+ send_mail_act_->setIcon(QIcon(":email.png"));
+ connect(send_mail_act_, &QAction::triggered, this, [=]() {
auto* dialog = new SendMailDialog({}, this);
dialog->show();
});
- receiveMailAct = new QAction(_("Message Inbox"), this);
- receiveMailAct->setIcon(QIcon(":receive_email.png"));
- connect(receiveMailAct, &QAction::triggered, this, [=]() {
+ receive_mail_act_ = new QAction(_("Message Inbox"), this);
+ receive_mail_act_->setVisible(false);
+ receive_mail_act_->setIcon(QIcon(":receive_email.png"));
+ connect(receive_mail_act_, &QAction::triggered, this, [=]() {
auto* dialog = new ReceiveMailDialog(this);
dialog->show();
});
#endif
}
-void MainWindow::createMenus() {
- fileMenu = menuBar()->addMenu(_("File"));
- fileMenu->addAction(newTabAct);
- fileMenu->addAction(browserAct);
- fileMenu->addAction(openAct);
- fileMenu->addSeparator();
- fileMenu->addAction(saveAct);
- fileMenu->addAction(saveAsAct);
- fileMenu->addSeparator();
- fileMenu->addAction(printAct);
- fileMenu->addSeparator();
- fileMenu->addAction(closeTabAct);
- fileMenu->addAction(quitAct);
-
- editMenu = menuBar()->addMenu(_("Edit"));
- editMenu->addAction(undoAct);
- editMenu->addAction(redoAct);
- editMenu->addSeparator();
- editMenu->addAction(zoomInAct);
- editMenu->addAction(zoomOutAct);
- editMenu->addSeparator();
- editMenu->addAction(copyAct);
- editMenu->addAction(cutAct);
- editMenu->addAction(pasteAct);
- editMenu->addAction(selectAllAct);
- editMenu->addAction(findAct);
- editMenu->addSeparator();
- editMenu->addAction(quoteAct);
- editMenu->addAction(cleanDoubleLinebreaksAct);
- editMenu->addSeparator();
- editMenu->addAction(openSettingsAct);
-
- cryptMenu = menuBar()->addMenu(_("Crypt"));
- cryptMenu->addAction(encryptAct);
- cryptMenu->addAction(encryptSignAct);
- cryptMenu->addAction(decryptAct);
- cryptMenu->addAction(decryptVerifyAct);
- cryptMenu->addSeparator();
- cryptMenu->addAction(signAct);
- cryptMenu->addAction(verifyAct);
- cryptMenu->addSeparator();
-
- keyMenu = menuBar()->addMenu(_("Keys"));
- importKeyMenu = keyMenu->addMenu(_("Import Key"));
- importKeyMenu->setIcon(QIcon(":key_import.png"));
- importKeyMenu->addAction(importKeyFromFileAct);
- importKeyMenu->addAction(importKeyFromEditAct);
- importKeyMenu->addAction(importKeyFromClipboardAct);
- importKeyMenu->addAction(importKeyFromKeyServerAct);
- keyMenu->addAction(openKeyManagementAct);
-
- steganoMenu = menuBar()->addMenu(_("Steganography"));
- steganoMenu->addAction(cutPgpHeaderAct);
- steganoMenu->addAction(addPgpHeaderAct);
+void MainWindow::create_menus() {
+ file_menu_ = menuBar()->addMenu(_("File"));
+ file_menu_->addAction(new_tab_act_);
+ file_menu_->addAction(browser_act_);
+ file_menu_->addAction(open_act_);
+ file_menu_->addSeparator();
+ file_menu_->addAction(save_act_);
+ file_menu_->addAction(save_as_act_);
+ file_menu_->addSeparator();
+ file_menu_->addAction(print_act_);
+ file_menu_->addSeparator();
+ file_menu_->addAction(close_tab_act_);
+ file_menu_->addAction(quit_act_);
+
+ edit_menu_ = menuBar()->addMenu(_("Edit"));
+ edit_menu_->addAction(undo_act_);
+ edit_menu_->addAction(redo_act_);
+ edit_menu_->addSeparator();
+ edit_menu_->addAction(zoom_in_act_);
+ edit_menu_->addAction(zoom_out_act_);
+ edit_menu_->addSeparator();
+ edit_menu_->addAction(copy_act_);
+ edit_menu_->addAction(cut_act_);
+ edit_menu_->addAction(paste_act_);
+ edit_menu_->addAction(select_all_act_);
+ edit_menu_->addAction(find_act_);
+ edit_menu_->addSeparator();
+ edit_menu_->addAction(quote_act_);
+ edit_menu_->addAction(clean_double_line_breaks_act_);
+ edit_menu_->addSeparator();
+ edit_menu_->addAction(open_settings_act_);
+
+ crypt_menu_ = menuBar()->addMenu(_("Crypt"));
+ crypt_menu_->addAction(encrypt_act_);
+ crypt_menu_->addAction(encrypt_sign_act_);
+ crypt_menu_->addAction(decrypt_act_);
+ crypt_menu_->addAction(decrypt_verify_act_);
+ crypt_menu_->addSeparator();
+ crypt_menu_->addAction(sign_act_);
+ crypt_menu_->addAction(verify_act_);
+ crypt_menu_->addSeparator();
+
+ key_menu_ = menuBar()->addMenu(_("Keys"));
+ import_key_menu_ = key_menu_->addMenu(_("Import Key"));
+ import_key_menu_->setIcon(QIcon(":key_import.png"));
+ import_key_menu_->addAction(import_key_from_file_act_);
+ import_key_menu_->addAction(import_key_from_edit_act_);
+ import_key_menu_->addAction(import_key_from_clipboard_act_);
+ import_key_menu_->addAction(import_key_from_key_server_act_);
+ key_menu_->addAction(open_key_management_act_);
+
+ steganography_menu_ = menuBar()->addMenu(_("Steganography"));
+ steganography_menu_->addAction(cut_pgp_header_act_);
+ steganography_menu_->addAction(add_pgp_header_act_);
#ifdef SMTP_SUPPORT
- emailMenu = menuBar()->addMenu(_("Email"));
- emailMenu->addAction(sendMailAct);
- emailMenu->addAction(receiveMailAct);
-#endif
-
-#ifdef ADVANCED_SUPPORT
- // Hide menu, when steganography menu is disabled in settings
- if (!settings.value("advanced/steganography").toBool()) {
- this->menuBar()->removeAction(steganoMenu->menuAction());
- }
+ email_menu_ = menuBar()->addMenu(_("Email"));
+ email_menu_->addAction(send_mail_act_);
+ email_menu_->addAction(receive_mail_act_);
#endif
- viewMenu = menuBar()->addMenu(_("View"));
+ view_menu_ = menuBar()->addMenu(_("View"));
- helpMenu = menuBar()->addMenu(_("Help"));
- helpMenu->addAction(startWizardAct);
- helpMenu->addSeparator();
- helpMenu->addAction(checkUpdateAct);
- helpMenu->addAction(translateAct);
- helpMenu->addAction(aboutAct);
+ help_menu_ = menuBar()->addMenu(_("Help"));
+ help_menu_->addAction(start_wizard_act_);
+ help_menu_->addSeparator();
+ help_menu_->addAction(check_update_act_);
+ help_menu_->addAction(translate_act_);
+ help_menu_->addAction(about_act_);
}
-void MainWindow::createToolBars() {
- fileToolBar = addToolBar(_("File"));
- fileToolBar->setObjectName("fileToolBar");
- fileToolBar->addAction(newTabAct);
- fileToolBar->addAction(openAct);
- fileToolBar->addAction(saveAct);
- fileToolBar->addAction(browserAct);
- viewMenu->addAction(fileToolBar->toggleViewAction());
-
- cryptToolBar = addToolBar(_("Operations"));
- cryptToolBar->setObjectName("cryptToolBar");
- cryptToolBar->addAction(encryptAct);
- cryptToolBar->addAction(encryptSignAct);
- cryptToolBar->addAction(decryptAct);
- cryptToolBar->addAction(decryptVerifyAct);
- cryptToolBar->addAction(signAct);
- cryptToolBar->addAction(verifyAct);
- viewMenu->addAction(cryptToolBar->toggleViewAction());
-
- keyToolBar = addToolBar(_("Key"));
- keyToolBar->setObjectName("keyToolBar");
- keyToolBar->addAction(openKeyManagementAct);
- viewMenu->addAction(keyToolBar->toggleViewAction());
-
- editToolBar = addToolBar(_("Edit"));
- editToolBar->setObjectName("editToolBar");
- editToolBar->addAction(copyAct);
- editToolBar->addAction(pasteAct);
- editToolBar->addAction(selectAllAct);
- editToolBar->hide();
- viewMenu->addAction(editToolBar->toggleViewAction());
-
- specialEditToolBar = addToolBar(_("Special Edit"));
- specialEditToolBar->setObjectName("specialEditToolBar");
- specialEditToolBar->addAction(quoteAct);
- specialEditToolBar->addAction(cleanDoubleLinebreaksAct);
- specialEditToolBar->hide();
- viewMenu->addAction(specialEditToolBar->toggleViewAction());
-
- emailToolBar = addToolBar(_("Email"));
- emailToolBar->setObjectName("emailToolBar");
- emailToolBar->addAction(sendMailAct);
- emailToolBar->addAction(receiveMailAct);
- viewMenu->addAction(emailToolBar->toggleViewAction());
+void MainWindow::create_tool_bars() {
+ file_tool_bar_ = addToolBar(_("File"));
+ file_tool_bar_->setObjectName("fileToolBar");
+ file_tool_bar_->addAction(new_tab_act_);
+ file_tool_bar_->addAction(open_act_);
+ file_tool_bar_->addAction(save_act_);
+ file_tool_bar_->addAction(browser_act_);
+ view_menu_->addAction(file_tool_bar_->toggleViewAction());
+
+ crypt_tool_bar_ = addToolBar(_("Operations"));
+ crypt_tool_bar_->setObjectName("cryptToolBar");
+ crypt_tool_bar_->addAction(encrypt_act_);
+ crypt_tool_bar_->addAction(encrypt_sign_act_);
+ crypt_tool_bar_->addAction(decrypt_act_);
+ crypt_tool_bar_->addAction(decrypt_verify_act_);
+ crypt_tool_bar_->addAction(sign_act_);
+ crypt_tool_bar_->addAction(verify_act_);
+ view_menu_->addAction(crypt_tool_bar_->toggleViewAction());
+
+ key_tool_bar_ = addToolBar(_("Key"));
+ key_tool_bar_->setObjectName("keyToolBar");
+ key_tool_bar_->addAction(open_key_management_act_);
+ view_menu_->addAction(key_tool_bar_->toggleViewAction());
+
+ edit_tool_bar_ = addToolBar(_("Edit"));
+ edit_tool_bar_->setObjectName("editToolBar");
+ edit_tool_bar_->addAction(copy_act_);
+ edit_tool_bar_->addAction(paste_act_);
+ edit_tool_bar_->addAction(select_all_act_);
+ edit_tool_bar_->hide();
+ view_menu_->addAction(edit_tool_bar_->toggleViewAction());
+
+ special_edit_tool_bar_ = addToolBar(_("Special Edit"));
+ special_edit_tool_bar_->setObjectName("specialEditToolBar");
+ special_edit_tool_bar_->addAction(quote_act_);
+ special_edit_tool_bar_->addAction(clean_double_line_breaks_act_);
+ special_edit_tool_bar_->hide();
+ view_menu_->addAction(special_edit_tool_bar_->toggleViewAction());
+
+ email_tool_bar_ = addToolBar(_("Email"));
+ email_tool_bar_->setObjectName("emailToolBar");
+ email_tool_bar_->addAction(send_mail_act_);
+ email_tool_bar_->addAction(receive_mail_act_);
+ view_menu_->addAction(email_tool_bar_->toggleViewAction());
// Add dropdown menu for key import to keytoolbar
- importButton = new QToolButton();
- importButton->setMenu(importKeyMenu);
- importButton->setPopupMode(QToolButton::InstantPopup);
- importButton->setIcon(QIcon(":key_import.png"));
- importButton->setToolTip(_("Import key from..."));
- importButton->setText(_("Import key"));
- keyToolBar->addWidget(importButton);
+ import_button_ = new QToolButton();
+ import_button_->setMenu(import_key_menu_);
+ import_button_->setPopupMode(QToolButton::InstantPopup);
+ import_button_->setIcon(QIcon(":key_import.png"));
+ import_button_->setToolTip(_("Import key from..."));
+ import_button_->setText(_("Import key"));
+ key_tool_bar_->addWidget(import_button_);
}
-void MainWindow::createStatusBar() {
+void MainWindow::create_status_bar() {
auto* statusBarBox = new QWidget();
auto* statusBarBoxLayout = new QHBoxLayout();
// QPixmap* pixmap;
@@ -464,17 +474,17 @@ void MainWindow::createStatusBar() {
statusBarBox->setLayout(statusBarBoxLayout);
}
-void MainWindow::createDockWindows() {
+void MainWindow::create_dock_windows() {
/* KeyList-Dock window
*/
- keyListDock = new QDockWidget(_("Key ToolBox"), this);
- keyListDock->setObjectName("EncryptDock");
- keyListDock->setAllowedAreas(Qt::LeftDockWidgetArea |
- Qt::RightDockWidgetArea);
- keyListDock->setMinimumWidth(460);
- addDockWidget(Qt::RightDockWidgetArea, keyListDock);
-
- mKeyList->addListGroupTab(
+ key_list_dock_ = new QDockWidget(_("Key ToolBox"), this);
+ key_list_dock_->setObjectName("EncryptDock");
+ key_list_dock_->setAllowedAreas(Qt::LeftDockWidgetArea |
+ Qt::RightDockWidgetArea);
+ key_list_dock_->setMinimumWidth(460);
+ addDockWidget(Qt::RightDockWidgetArea, key_list_dock_);
+
+ m_key_list_->AddListGroupTab(
_("Default"), KeyListRow::SECRET_OR_PUBLIC_KEY,
KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress |
KeyListColumn::Usage | KeyListColumn::Validity,
@@ -482,7 +492,7 @@ void MainWindow::createDockWindows() {
return !(key.IsRevoked() || key.IsDisabled() || key.IsExpired());
});
- mKeyList->addListGroupTab(
+ m_key_list_->AddListGroupTab(
_("Only Public Key"), KeyListRow::SECRET_OR_PUBLIC_KEY,
KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress |
KeyListColumn::Usage | KeyListColumn::Validity,
@@ -491,7 +501,7 @@ void MainWindow::createDockWindows() {
!(key.IsRevoked() || key.IsDisabled() || key.IsExpired());
});
- mKeyList->addListGroupTab(
+ m_key_list_->AddListGroupTab(
_("Has Private Key"), KeyListRow::SECRET_OR_PUBLIC_KEY,
KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress |
KeyListColumn::Usage | KeyListColumn::Validity,
@@ -500,18 +510,18 @@ void MainWindow::createDockWindows() {
!(key.IsRevoked() || key.IsDisabled() || key.IsExpired());
});
- mKeyList->slotRefresh();
+ m_key_list_->SlotRefresh();
- keyListDock->setWidget(mKeyList);
- viewMenu->addAction(keyListDock->toggleViewAction());
+ key_list_dock_->setWidget(m_key_list_);
+ view_menu_->addAction(key_list_dock_->toggleViewAction());
- infoBoardDock = new QDockWidget(_("Information Board"), this);
- infoBoardDock->setObjectName("Information Board");
- infoBoardDock->setAllowedAreas(Qt::BottomDockWidgetArea);
- addDockWidget(Qt::BottomDockWidgetArea, infoBoardDock);
- infoBoardDock->setWidget(infoBoard);
- infoBoardDock->widget()->layout()->setContentsMargins(0, 0, 0, 0);
- viewMenu->addAction(infoBoardDock->toggleViewAction());
+ info_board_dock_ = new QDockWidget(_("Information Board"), this);
+ info_board_dock_->setObjectName("Information Board");
+ info_board_dock_->setAllowedAreas(Qt::BottomDockWidgetArea);
+ addDockWidget(Qt::BottomDockWidgetArea, info_board_dock_);
+ info_board_dock_->setWidget(info_board_);
+ info_board_dock_->widget()->layout()->setContentsMargins(0, 0, 0, 0);
+ view_menu_->addAction(info_board_dock_->toggleViewAction());
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/settings/GlobalSettingStation.cpp b/src/ui/settings/GlobalSettingStation.cpp
deleted file mode 100644
index e1e5f6f4..00000000
--- a/src/ui/settings/GlobalSettingStation.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#include "GlobalSettingStation.h"
-
-#include <openssl/bio.h>
-#include <openssl/pem.h>
-
-#include <vmime/security/cert/openssl/X509Certificate_OpenSSL.hpp>
-#include <vmime/vmime.hpp>
-
-std::unique_ptr<GpgFrontend::UI::GlobalSettingStation>
- GpgFrontend::UI::GlobalSettingStation::_instance = nullptr;
-
-GpgFrontend::UI::GlobalSettingStation&
-GpgFrontend::UI::GlobalSettingStation::GetInstance() {
- if (_instance == nullptr) {
- _instance = std::make_unique<GlobalSettingStation>();
- }
- return *_instance;
-}
-
-void GpgFrontend::UI::GlobalSettingStation::SyncSettings() noexcept {
- using namespace libconfig;
- try {
- ui_cfg.writeFile(ui_config_path.string().c_str());
- LOG(INFO) << _("Updated ui configuration successfully written to")
- << ui_config_path;
-
- } catch (const FileIOException& fioex) {
- LOG(ERROR) << _("I/O error while writing ui configuration file")
- << ui_config_path;
- }
-}
-
-GpgFrontend::UI::GlobalSettingStation::GlobalSettingStation() noexcept {
- using namespace boost::filesystem;
- using namespace libconfig;
-
- el::Loggers::addFlag(el::LoggingFlag::AutoSpacing);
-
- LOG(INFO) << _("App Path") << app_path;
- LOG(INFO) << _("App Configure Path") << app_configure_path;
- LOG(INFO) << _("App Data Path") << app_data_path;
- LOG(INFO) << _("App Log Path") << app_log_path;
- LOG(INFO) << _("App Locale Path") << app_locale_path;
-
- if (!is_directory(app_configure_path)) create_directory(app_configure_path);
-
- if (!is_directory(app_data_path)) create_directory(app_data_path);
-
- if (!is_directory(app_log_path)) create_directory(app_log_path);
-
- if (!is_directory(ui_config_dir_path)) create_directory(ui_config_dir_path);
-
- if (!is_directory(app_secure_path)) create_directory(app_secure_path);
-
- if (!exists(app_secure_key_path)) {
- init_app_secure_key();
- }
-
- const auto key =
- GpgFrontend::read_all_data_in_file(app_secure_key_path.string());
- hash_key_ = QCryptographicHash::hash(QByteArray::fromStdString(key),
- QCryptographicHash::Sha256);
-
- if (!exists(app_data_objs_path)) create_directory(app_data_objs_path);
-
- if (!exists(ui_config_path)) {
- try {
- this->ui_cfg.writeFile(ui_config_path.string().c_str());
- LOG(INFO) << _("UserInterface configuration successfully written to")
- << ui_config_path;
-
- } catch (const FileIOException& fioex) {
- LOG(ERROR)
- << _("I/O error while writing UserInterface configuration file")
- << ui_config_path;
- }
- } else {
- try {
- this->ui_cfg.readFile(ui_config_path.string().c_str());
- LOG(INFO) << _("UserInterface configuration successfully read from")
- << ui_config_path;
- } catch (const FileIOException& fioex) {
- LOG(ERROR) << _("I/O error while reading UserInterface configure file");
- } catch (const ParseException& pex) {
- LOG(ERROR) << _("Parse error at ") << pex.getFile() << ":"
- << pex.getLine() << " - " << pex.getError();
- }
- }
-}
-
-void GpgFrontend::UI::GlobalSettingStation::AddRootCert(
- const boost::filesystem::path& path) {
- auto out_buffer = GpgFrontend::read_all_data_in_file(path.string());
-
- auto mem_bio = std::shared_ptr<BIO>(
- BIO_new_mem_buf(out_buffer.data(), static_cast<int>(out_buffer.size())),
- [](BIO* _p) { BIO_free(_p); });
-
- auto x509 = std::shared_ptr<X509>(
- PEM_read_bio_X509(mem_bio.get(), nullptr, nullptr, nullptr),
- [](X509* _p) { X509_free(_p); });
-
- if (!x509) return;
-
- root_certs_.push_back(x509);
-}
-
-vmime::shared_ptr<vmime::security::cert::defaultCertificateVerifier>
-GpgFrontend::UI::GlobalSettingStation::GetCertVerifier() const {
- auto p_cv =
- vmime::make_shared<vmime::security::cert::defaultCertificateVerifier>();
-
- std::vector<vmime::shared_ptr<vmime::security::cert::X509Certificate>>
- _root_certs;
- for (const auto& cert : root_certs_) {
- _root_certs.push_back(
- std::make_shared<vmime::security::cert::X509Certificate_OpenSSL>(
- cert.get()));
- }
- return p_cv;
-}
-
-const std::vector<std::shared_ptr<X509>>&
-GpgFrontend::UI::GlobalSettingStation::GetRootCerts() {
- return root_certs_;
-}
-
-std::string GpgFrontend::UI::GlobalSettingStation::generate_passphrase(
- int len) {
- std::uniform_int_distribution<int> dist(999, 99999);
- static const char alphanum[] =
- "0123456789"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz";
- std::string tmp_str;
- tmp_str.reserve(len);
-
- for (int i = 0; i < len; ++i) {
- tmp_str += alphanum[dist(mt) % (sizeof(alphanum) - 1)];
- }
-
- return tmp_str;
-}
-
-void GpgFrontend::UI::GlobalSettingStation::init_app_secure_key() {
- GpgFrontend::write_buffer_to_file(app_secure_key_path.string(),
- generate_passphrase(256));
- boost::filesystem::permissions(
- app_secure_key_path,
- boost::filesystem::owner_read | boost::filesystem::owner_write);
-}
-
-std::string GpgFrontend::UI::GlobalSettingStation::SaveDataObj(
- const std::string& _key, const nlohmann::json& value) {
- std::string _hash_obj_key = {};
- if (_key.empty()) {
- _hash_obj_key =
- QCryptographicHash::hash(
- hash_key_ + QByteArray::fromStdString(
- generate_passphrase(32) +
- to_iso_extended_string(
- boost::posix_time::second_clock::local_time())),
- QCryptographicHash::Sha256)
- .toHex()
- .toStdString();
- } else {
- _hash_obj_key =
- QCryptographicHash::hash(hash_key_ + QByteArray::fromStdString(_key),
- QCryptographicHash::Sha256)
- .toHex()
- .toStdString();
- }
-
- const auto obj_path = app_data_objs_path / _hash_obj_key;
-
- QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::ECB,
- QAESEncryption::Padding::ISO);
- auto encoded =
- encryption.encode(QByteArray::fromStdString(to_string(value)), hash_key_);
-
- GpgFrontend::write_buffer_to_file(obj_path.string(), encoded.toStdString());
-
- return _key.empty() ? _hash_obj_key : std::string();
-}
-
-std::optional<nlohmann::json>
-GpgFrontend::UI::GlobalSettingStation::GetDataObject(const std::string& _key) {
- try {
- auto _hash_obj_key =
- QCryptographicHash::hash(hash_key_ + QByteArray::fromStdString(_key),
- QCryptographicHash::Sha256)
- .toHex()
- .toStdString();
-
- const auto obj_path = app_data_objs_path / _hash_obj_key;
-
- if (!boost::filesystem::exists(obj_path)) {
- return {};
- }
-
- auto buffer = GpgFrontend::read_all_data_in_file(obj_path.string());
- auto encoded = QByteArray::fromStdString(buffer);
-
- QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::ECB,
- QAESEncryption::Padding::ISO);
-
- auto decoded =
- encryption.removePadding(encryption.decode(encoded, hash_key_));
-
- return nlohmann::json::parse(decoded.toStdString());
- } catch (...) {
- return {};
- }
-}
-std::optional<nlohmann::json>
-GpgFrontend::UI::GlobalSettingStation::GetDataObjectByRef(
- const std::string& _ref) {
- if (_ref.size() != 64) return {};
-
- try {
- auto _hash_obj_key = _ref;
- const auto obj_path = app_data_objs_path / _hash_obj_key;
-
- if (!boost::filesystem::exists(obj_path)) return {};
-
- auto buffer = GpgFrontend::read_all_data_in_file(obj_path.string());
- auto encoded = QByteArray::fromStdString(buffer);
-
- QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::ECB,
- QAESEncryption::Padding::ISO);
-
- auto decoded =
- encryption.removePadding(encryption.decode(encoded, hash_key_));
-
- return nlohmann::json::parse(decoded.toStdString());
- } catch (...) {
- return {};
- }
-}
-
-GpgFrontend::UI::GlobalSettingStation::~GlobalSettingStation() noexcept =
- default;
diff --git a/src/ui/settings/GlobalSettingStation.h b/src/ui/settings/GlobalSettingStation.h
deleted file mode 100644
index 457a5a2f..00000000
--- a/src/ui/settings/GlobalSettingStation.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#ifndef GPGFRONTEND_GLOBALSETTINGSTATION_H
-#define GPGFRONTEND_GLOBALSETTINGSTATION_H
-
-#include <openssl/x509.h>
-
-#include <nlohmann/json.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-
-#include "GpgFrontendBuildInstallInfo.h"
-#include "ui/GpgFrontendUI.h"
-
-namespace vmime::security::cert {
-class defaultCertificateVerifier;
-class X509Certificate;
-} // namespace vmime::security::cert
-
-namespace GpgFrontend::UI {
-
-class GlobalSettingStation : public QObject {
- Q_OBJECT
- public:
- static GlobalSettingStation& GetInstance();
-
- GlobalSettingStation() noexcept;
-
- ~GlobalSettingStation() noexcept override;
-
- libconfig::Setting& GetUISettings() noexcept { return ui_cfg.getRoot(); }
-
- [[nodiscard]] boost::filesystem::path GetAppDir() const { return app_path; }
-
- [[nodiscard]] boost::filesystem::path GetLogDir() const {
- return app_log_path;
- }
-
- [[nodiscard]] boost::filesystem::path GetStandaloneDatabaseDir() const {
- auto db_path = app_configure_path / "db";
- if (!boost::filesystem::exists(db_path)) {
- boost::filesystem::create_directory(db_path);
- }
- return db_path;
- }
-
- [[nodiscard]] boost::filesystem::path GetStandaloneGpgBinDir() const {
- return app_resource_path / "gpg1.4" / "gpg";
- }
-
- [[nodiscard]] boost::filesystem::path GetLocaleDir() const {
- return app_locale_path;
- }
-
- [[nodiscard]] boost::filesystem::path GetResourceDir() const {
- return app_resource_path;
- }
-
- [[nodiscard]] boost::filesystem::path GetCertsDir() const {
- return app_resource_path / "certs";
- }
-
- [[nodiscard]] std::shared_ptr<
- vmime::security::cert::defaultCertificateVerifier>
- GetCertVerifier() const;
-
- void AddRootCert(const boost::filesystem::path& path);
-
- const std::vector<std::shared_ptr<X509>>& GetRootCerts();
-
- void ResetRootCerts() { root_certs_.clear(); }
-
- void SyncSettings() noexcept;
-
- std::string SaveDataObj(const std::string& _key, const nlohmann::json& value);
-
- std::optional<nlohmann::json> GetDataObject(const std::string& _key);
-
- std::optional<nlohmann::json> GetDataObjectByRef(const std::string& _ref);
-
- private:
- // Program Location
- boost::filesystem::path app_path = qApp->applicationDirPath().toStdString();
-
- // Program Data Location
- boost::filesystem::path app_data_path =
- QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
- .toStdString();
-
- // Program Data Location
- boost::filesystem::path app_log_path = app_data_path / "logs";
-
- // object storage path
- boost::filesystem::path app_data_objs_path = app_data_path / "objs";
-
-#ifdef LINUX_INSTALL_BUILD
- // Program Data Location
- boost::filesystem::path app_resource_path =
- boost::filesystem::path(APP_LOCALSTATE_PATH) / "gpgfrontend";
-#else
- // Program Data Location
- boost::filesystem::path app_resource_path = RESOURCE_DIR_BOOST_PATH(app_path);
-#endif
-
-#ifdef LINUX_INSTALL_BUILD
- // Program Data Location
- boost::filesystem::path app_locale_path = std::string(APP_LOCALE_PATH);
-#else
- // Program Data Location
- boost::filesystem::path app_locale_path = app_resource_path / "locales";
-#endif
-
- // Program Configure Location
- boost::filesystem::path app_configure_path =
- QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)
- .toStdString();
-
- boost::filesystem::path app_secure_path = app_configure_path / "secure";
-
- boost::filesystem::path app_secure_key_path = app_secure_path / "app.key";
-
- // Configure File Directory Location
- boost::filesystem::path ui_config_dir_path =
- app_configure_path / "UserInterface";
-
- // UI Configure File Location
- boost::filesystem::path ui_config_path = ui_config_dir_path / "ui.cfg";
-
- libconfig::Config ui_cfg;
-
- std::vector<std::shared_ptr<X509>> root_certs_;
-
- std::random_device rd;
-
- std::mt19937 mt;
-
- QByteArray hash_key_;
-
- static std::unique_ptr<GlobalSettingStation> _instance;
-
- void init_app_secure_key();
-
- std::string generate_passphrase(int len);
-};
-} // namespace GpgFrontend::UI
-
-#endif // GPGFRONTEND_GLOBALSETTINGSTATION_H
diff --git a/src/ui/settings/SettingsAdvanced.cpp b/src/ui/settings/SettingsAdvanced.cpp
index b64ec8e9..516d4d02 100644
--- a/src/ui/settings/SettingsAdvanced.cpp
+++ b/src/ui/settings/SettingsAdvanced.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,67 +8,97 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include "SettingsAdvanced.h"
+#include "core/function/GlobalSettingStation.h"
+
namespace GpgFrontend::UI {
-AdvancedTab::AdvancedTab(QWidget* parent)
- : QWidget(parent),
- appPath(qApp->applicationDirPath()),
- settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini",
- QSettings::IniFormat) {
- /*****************************************
- * Steganography Box
- *****************************************/
- auto* steganoBox = new QGroupBox(_("Show Steganography Options"));
- auto* steganoBoxLayout = new QHBoxLayout();
- steganoCheckBox = new QCheckBox(_("Show Steganographic Options."), this);
- steganoBoxLayout->addWidget(steganoCheckBox);
- steganoBox->setLayout(steganoBoxLayout);
+AdvancedTab::AdvancedTab(QWidget* parent) : QWidget(parent) {
+ auto* stegano_box = new QGroupBox(_("Show Steganography Options"));
+ auto* stegano_box_layout = new QHBoxLayout();
+ stegano_check_box_ = new QCheckBox(_("Show Steganography Options."), this);
+ stegano_box_layout->addWidget(stegano_check_box_);
+ stegano_box->setLayout(stegano_box_layout);
- auto* pubkeyExchangeBox = new QGroupBox(_("Pubkey Exchange"));
- auto* pubkeyExchangeBoxLayout = new QHBoxLayout();
- autoPubkeyExchangeCheckBox = new QCheckBox(_("Auto Pubkey Exchange"), this);
- pubkeyExchangeBoxLayout->addWidget(autoPubkeyExchangeCheckBox);
- pubkeyExchangeBox->setLayout(pubkeyExchangeBoxLayout);
+ auto* pubkey_exchange_box = new QGroupBox(_("Pubkey Exchange"));
+ auto* pubkey_exchange_box_layout = new QHBoxLayout();
+ auto_pubkey_exchange_check_box_ =
+ new QCheckBox(_("Auto Pubkey Exchange"), this);
+ pubkey_exchange_box_layout->addWidget(auto_pubkey_exchange_check_box_);
+ pubkey_exchange_box->setLayout(pubkey_exchange_box_layout);
- auto* mainLayout = new QVBoxLayout;
- mainLayout->addWidget(steganoBox);
- mainLayout->addWidget(pubkeyExchangeBox);
- setSettings();
- mainLayout->addStretch(1);
- setLayout(mainLayout);
+ auto* main_layout = new QVBoxLayout;
+ main_layout->addWidget(stegano_box);
+ main_layout->addWidget(pubkey_exchange_box);
+ SetSettings();
+ main_layout->addStretch(1);
+ setLayout(main_layout);
}
-void AdvancedTab::setSettings() {
- if (settings.value("advanced/steganography").toBool()) {
- steganoCheckBox->setCheckState(Qt::Checked);
+void AdvancedTab::SetSettings() {
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ try {
+ bool stegano_checked = settings.lookup("advanced.stegano_checked");
+ if (stegano_checked) stegano_check_box_->setCheckState(Qt::Checked);
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error") << _("stegano_checked");
}
- if (settings.value("advanced/autoPubkeyExchange").toBool()) {
- autoPubkeyExchangeCheckBox->setCheckState(Qt::Checked);
+
+ try {
+ bool auto_pubkey_exchange_checked =
+ settings.lookup("advanced.auto_pubkey_exchange_checked");
+ if (auto_pubkey_exchange_checked)
+ auto_pubkey_exchange_check_box_->setCheckState(Qt::Checked);
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error")
+ << _("auto_pubkey_exchange_checked");
}
}
-void AdvancedTab::applySettings() {
- settings.setValue("advanced/steganography", steganoCheckBox->isChecked());
- settings.setValue("advanced/autoPubkeyExchange",
- autoPubkeyExchangeCheckBox->isChecked());
+void AdvancedTab::ApplySettings() {
+ auto& settings =
+ GpgFrontend::GlobalSettingStation::GetInstance().GetUISettings();
+
+ if (!settings.exists("advanced") ||
+ settings.lookup("advanced").getType() != libconfig::Setting::TypeGroup)
+ settings.add("advanced", libconfig::Setting::TypeGroup);
+
+ auto& advanced = settings["advanced"];
+
+ if (!advanced.exists("stegano_checked"))
+ advanced.add("stegano_checked", libconfig::Setting::TypeBoolean) =
+ stegano_check_box_->isChecked();
+ else {
+ advanced["stegano_checked"] = stegano_check_box_->isChecked();
+ }
+
+ if (!advanced.exists("auto_pubkey_exchange_checked"))
+ advanced.add("auto_pubkey_exchange_checked",
+ libconfig::Setting::TypeBoolean) =
+ auto_pubkey_exchange_check_box_->isChecked();
+ else {
+ advanced["auto_pubkey_exchange_checked"] =
+ auto_pubkey_exchange_check_box_->isChecked();
+ }
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/settings/SettingsAdvanced.h b/src/ui/settings/SettingsAdvanced.h
index d8ec8089..c1a3d5a6 100644
--- a/src/ui/settings/SettingsAdvanced.h
+++ b/src/ui/settings/SettingsAdvanced.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -34,20 +38,17 @@ class AdvancedTab : public QWidget {
public:
explicit AdvancedTab(QWidget* parent = nullptr);
- void setSettings();
+ void SetSettings();
- void applySettings();
+ void ApplySettings();
private:
- QString appPath;
- QSettings settings;
-
- QCheckBox* steganoCheckBox;
- QCheckBox* autoPubkeyExchangeCheckBox;
+ QCheckBox* stegano_check_box_;
+ QCheckBox* auto_pubkey_exchange_check_box_;
signals:
- void signalRestartNeeded(bool needed);
+ void SignalRestartNeeded(bool needed);
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/settings/SettingsAppearance.cpp b/src/ui/settings/SettingsAppearance.cpp
index 49dc349c..7e54c9f8 100644
--- a/src/ui/settings/SettingsAppearance.cpp
+++ b/src/ui/settings/SettingsAppearance.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,25 +8,28 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include "SettingsAppearance.h"
-#include "GlobalSettingStation.h"
+#include "core/function/GlobalSettingStation.h"
+#include "ui/struct/SettingsObject.h"
namespace GpgFrontend::UI {
@@ -33,19 +38,19 @@ AppearanceTab::AppearanceTab(QWidget* parent) : QWidget(parent) {
* Icon-Size-Box
*****************************************/
auto* iconSizeBox = new QGroupBox(_("Icon Size"));
- iconSizeGroup = new QButtonGroup();
- iconSizeSmall = new QRadioButton(_("small"));
- iconSizeMedium = new QRadioButton(_("medium"));
- iconSizeLarge = new QRadioButton(_("large"));
+ icon_size_group_ = new QButtonGroup();
+ icon_size_small_ = new QRadioButton(_("small"));
+ icon_size_medium_ = new QRadioButton(_("medium"));
+ icon_size_large_ = new QRadioButton(_("large"));
- iconSizeGroup->addButton(iconSizeSmall, 1);
- iconSizeGroup->addButton(iconSizeMedium, 2);
- iconSizeGroup->addButton(iconSizeLarge, 3);
+ icon_size_group_->addButton(icon_size_small_, 1);
+ icon_size_group_->addButton(icon_size_medium_, 2);
+ icon_size_group_->addButton(icon_size_large_, 3);
auto* iconSizeBoxLayout = new QHBoxLayout();
- iconSizeBoxLayout->addWidget(iconSizeSmall);
- iconSizeBoxLayout->addWidget(iconSizeMedium);
- iconSizeBoxLayout->addWidget(iconSizeLarge);
+ iconSizeBoxLayout->addWidget(icon_size_small_);
+ iconSizeBoxLayout->addWidget(icon_size_medium_);
+ iconSizeBoxLayout->addWidget(icon_size_large_);
iconSizeBox->setLayout(iconSizeBoxLayout);
@@ -53,19 +58,19 @@ AppearanceTab::AppearanceTab(QWidget* parent) : QWidget(parent) {
* Icon-Style-Box
*****************************************/
auto* iconStyleBox = new QGroupBox(_("Icon Style"));
- iconStyleGroup = new QButtonGroup();
- iconTextButton = new QRadioButton(_("just text"));
- iconIconsButton = new QRadioButton(_("just icons"));
- iconAllButton = new QRadioButton(_("text and icons"));
+ icon_style_group_ = new QButtonGroup();
+ icon_text_button_ = new QRadioButton(_("just text"));
+ icon_icons_button_ = new QRadioButton(_("just icons"));
+ icon_all_button_ = new QRadioButton(_("text and icons"));
- iconStyleGroup->addButton(iconTextButton, 1);
- iconStyleGroup->addButton(iconIconsButton, 2);
- iconStyleGroup->addButton(iconAllButton, 3);
+ icon_style_group_->addButton(icon_text_button_, 1);
+ icon_style_group_->addButton(icon_icons_button_, 2);
+ icon_style_group_->addButton(icon_all_button_, 3);
auto* iconStyleBoxLayout = new QHBoxLayout();
- iconStyleBoxLayout->addWidget(iconTextButton);
- iconStyleBoxLayout->addWidget(iconIconsButton);
- iconStyleBoxLayout->addWidget(iconAllButton);
+ iconStyleBoxLayout->addWidget(icon_text_button_);
+ iconStyleBoxLayout->addWidget(icon_icons_button_);
+ iconStyleBoxLayout->addWidget(icon_all_button_);
iconStyleBox->setLayout(iconStyleBoxLayout);
@@ -74,9 +79,9 @@ AppearanceTab::AppearanceTab(QWidget* parent) : QWidget(parent) {
*****************************************/
auto* windowSizeBox = new QGroupBox(_("Window State"));
auto* windowSizeBoxLayout = new QHBoxLayout();
- windowSizeCheckBox =
+ window_size_check_box_ =
new QCheckBox(_("Save window size and position on exit."), this);
- windowSizeBoxLayout->addWidget(windowSizeCheckBox);
+ windowSizeBoxLayout->addWidget(window_size_check_box_);
windowSizeBox->setLayout(windowSizeBoxLayout);
/*****************************************
@@ -85,12 +90,12 @@ AppearanceTab::AppearanceTab(QWidget* parent) : QWidget(parent) {
auto* infoBoardBox = new QGroupBox(_("Information Board"));
auto* infoBoardLayout = new QHBoxLayout();
- infoBoardFontSizeSpin = new QSpinBox();
- infoBoardFontSizeSpin->setRange(9, 18);
- infoBoardFontSizeSpin->setValue(10);
- infoBoardFontSizeSpin->setSingleStep(1);
+ info_board_font_size_spin_ = new QSpinBox();
+ info_board_font_size_spin_->setRange(9, 18);
+ info_board_font_size_spin_->setValue(10);
+ info_board_font_size_spin_->setSingleStep(1);
infoBoardLayout->addWidget(new QLabel(_("Font Size in Information Board")));
- infoBoardLayout->addWidget(infoBoardFontSizeSpin);
+ infoBoardLayout->addWidget(info_board_font_size_spin_);
infoBoardBox->setLayout(infoBoardLayout);
auto* mainLayout = new QVBoxLayout;
@@ -99,7 +104,7 @@ AppearanceTab::AppearanceTab(QWidget* parent) : QWidget(parent) {
mainLayout->addWidget(windowSizeBox);
mainLayout->addWidget(infoBoardBox);
mainLayout->addStretch(1);
- setSettings();
+ SetSettings();
setLayout(mainLayout);
}
@@ -108,89 +113,64 @@ AppearanceTab::AppearanceTab(QWidget* parent) : QWidget(parent) {
* and set the buttons and checkboxes
* appropriately
**********************************/
-void AppearanceTab::setSettings() {
- auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
-
- try {
- int width = settings.lookup("window.icon_size.width");
- int height = settings.lookup("window.icon_size.height");
-
- auto icon_size = QSize(width, height);
-
- switch (icon_size.height()) {
- case 12:
- iconSizeSmall->setChecked(true);
- break;
- case 24:
- iconSizeMedium->setChecked(true);
- break;
- case 32:
- iconSizeLarge->setChecked(true);
- break;
- }
-
- } catch (...) {
- LOG(ERROR) << _("Setting Operation Error") << _("icon_size");
- }
+void AppearanceTab::SetSettings() {
- // icon_style
- try {
- int s_icon_style = settings.lookup("window.icon_style");
- auto icon_style = static_cast<Qt::ToolButtonStyle>(s_icon_style);
-
- switch (icon_style) {
- case Qt::ToolButtonTextOnly:
- iconTextButton->setChecked(true);
- break;
- case Qt::ToolButtonIconOnly:
- iconIconsButton->setChecked(true);
- break;
- case Qt::ToolButtonTextUnderIcon:
- iconAllButton->setChecked(true);
- break;
- default:
- break;
- }
-
- } catch (...) {
- LOG(ERROR) << _("Setting Operation Error") << _("icon_style");
- }
+ SettingsObject main_windows_state("main_windows_state");
+
+ int width = main_windows_state.Check("icon_size").Check("width", 24),
+ height = main_windows_state.Check("icon_size").Check("height", 24);
- // Window Save and Position
- try {
- bool window_save = settings.lookup("window.window_save");
- if (window_save) windowSizeCheckBox->setCheckState(Qt::Checked);
+ auto icon_size = QSize(width, height);
- } catch (...) {
- LOG(ERROR) << _("Setting Operation Error") << _("window_save");
+ switch (icon_size.width()) {
+ case 12:
+ icon_size_small_->setChecked(true);
+ break;
+ case 24:
+ icon_size_medium_->setChecked(true);
+ break;
+ case 32:
+ icon_size_large_->setChecked(true);
+ break;
}
- // info board font size
- try {
- int info_font_size = settings.lookup("window.info_font_size");
- if (info_font_size < 9 || info_font_size > 18) info_font_size = 10;
- infoBoardFontSizeSpin->setValue(info_font_size);
- } catch (...) {
- LOG(ERROR) << _("Setting Operation Error") << _("info_font_size");
+ // icon_style
+ int s_icon_style =
+ main_windows_state.Check("icon_style", Qt::ToolButtonTextUnderIcon);
+ auto icon_style = static_cast<Qt::ToolButtonStyle>(s_icon_style);
+
+ switch (icon_style) {
+ case Qt::ToolButtonTextOnly:
+ icon_text_button_->setChecked(true);
+ break;
+ case Qt::ToolButtonIconOnly:
+ icon_icons_button_->setChecked(true);
+ break;
+ case Qt::ToolButtonTextUnderIcon:
+ icon_all_button_->setChecked(true);
+ break;
+ default:
+ break;
}
+
+ bool window_save = main_windows_state.Check("window_save", true);
+ if (window_save) window_size_check_box_->setCheckState(Qt::Checked);
+
+ auto info_font_size = main_windows_state.Check("info_font_size", 10);
+ if (info_font_size < 9 || info_font_size > 18) info_font_size = 10;
+ info_board_font_size_spin_->setValue(info_font_size);
}
/***********************************
* get the values of the buttons and
* write them to settings-file
*************************************/
-void AppearanceTab::applySettings() {
- auto& settings =
- GpgFrontend::UI::GlobalSettingStation::GetInstance().GetUISettings();
-
- if (!settings.exists("window") ||
- settings.lookup("window").getType() != libconfig::Setting::TypeGroup)
- settings.add("window", libconfig::Setting::TypeGroup);
+void AppearanceTab::ApplySettings() {
- auto& window = settings["window"];
+ SettingsObject main_windows_state("main_windows_state");
int icon_size = 24;
- switch (iconSizeGroup->checkedId()) {
+ switch (icon_size_group_->checkedId()) {
case 1:
icon_size = 12;
break;
@@ -202,18 +182,11 @@ void AppearanceTab::applySettings() {
break;
}
- if (!window.exists("icon_size")) {
- auto& icon_size_settings =
- window.add("icon_size", libconfig::Setting::TypeGroup);
- icon_size_settings.add("width", libconfig::Setting::TypeInt) = icon_size;
- icon_size_settings.add("height", libconfig::Setting::TypeInt) = icon_size;
- } else {
- window["icon_size"]["width"] = icon_size;
- window["icon_size"]["height"] = icon_size;
- }
+ main_windows_state["icon_size"]["width"] = icon_size;
+ main_windows_state["icon_size"]["height"] = icon_size;
auto icon_style = Qt::ToolButtonTextUnderIcon;
- switch (iconStyleGroup->checkedId()) {
+ switch (icon_style_group_->checkedId()) {
case 1:
icon_style = Qt::ToolButtonTextOnly;
break;
@@ -225,25 +198,12 @@ void AppearanceTab::applySettings() {
break;
}
- if (!window.exists("icon_style")) {
- window.add("icon_style", libconfig::Setting::TypeInt) = icon_style;
- } else {
- window["icon_style"] = icon_style;
- }
+ main_windows_state["icon_style"] = icon_style;
- if (!window.exists("window_save")) {
- window.add("window_save", libconfig::Setting::TypeBoolean) =
- windowSizeCheckBox->isChecked();
- } else {
- window["window_save"] = windowSizeCheckBox->isChecked();
- }
+ main_windows_state["window_save"] = window_size_check_box_->isChecked();
+
+ main_windows_state["info_font_size"] = info_board_font_size_spin_->value();
- if (!window.exists("info_font_size")) {
- window.add("info_font_size", libconfig::Setting::TypeBoolean) =
- infoBoardFontSizeSpin->value();
- } else {
- window["info_font_size"] = infoBoardFontSizeSpin->value();
- }
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/settings/SettingsAppearance.h b/src/ui/settings/SettingsAppearance.h
index c0a0247b..7110d992 100644
--- a/src/ui/settings/SettingsAppearance.h
+++ b/src/ui/settings/SettingsAppearance.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -33,26 +37,44 @@ class AppearanceTab : public QWidget {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Appearance Tab object
+ *
+ * @param parent
+ */
explicit AppearanceTab(QWidget* parent = nullptr);
- void setSettings();
+ /**
+ * @brief Set the Settings object
+ *
+ */
+ void SetSettings();
- void applySettings();
+ /**
+ * @brief
+ *
+ */
+ void ApplySettings();
private:
- QButtonGroup* iconStyleGroup;
- QRadioButton* iconSizeSmall;
- QRadioButton* iconSizeMedium;
- QRadioButton* iconSizeLarge;
- QButtonGroup* iconSizeGroup;
- QRadioButton* iconTextButton;
- QRadioButton* iconIconsButton;
- QRadioButton* iconAllButton;
- QSpinBox* infoBoardFontSizeSpin;
- QCheckBox* windowSizeCheckBox;
+ QButtonGroup* icon_style_group_; ///<
+ QRadioButton* icon_size_small_; ///<
+ QRadioButton* icon_size_medium_; ///<
+ QRadioButton* icon_size_large_; ///<
+ QButtonGroup* icon_size_group_; ///<
+ QRadioButton* icon_text_button_; ///<
+ QRadioButton* icon_icons_button_; ///<
+ QRadioButton* icon_all_button_; ///<
+ QSpinBox* info_board_font_size_spin_; ///<
+ QCheckBox* window_size_check_box_; ///<
signals:
+ /**
+ * @brief
+ *
+ * @param needed
+ */
void signalRestartNeeded(bool needed);
};
diff --git a/src/ui/settings/SettingsDialog.cpp b/src/ui/settings/SettingsDialog.cpp
index dc84e8ac..2c23858f 100644
--- a/src/ui/settings/SettingsDialog.cpp
+++ b/src/ui/settings/SettingsDialog.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,118 +8,109 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include "SettingsDialog.h"
-#include "GlobalSettingStation.h"
-#include "SettingsAdvanced.h"
-#include "SettingsAppearance.h"
-#include "SettingsGeneral.h"
-#include "SettingsKeyServer.h"
-#include "SettingsNetwork.h"
+#include "core/function/GlobalSettingStation.h"
+#include "ui/settings/SettingsAdvanced.h"
+#include "ui/settings/SettingsAppearance.h"
+#include "ui/settings/SettingsGeneral.h"
+#include "ui/settings/SettingsKeyServer.h"
+#include "ui/settings/SettingsNetwork.h"
+#include "ui/main_window/MainWindow.h"
#ifdef SMTP_SUPPORT
-#include "SettingsSendMail.h"
+#include "ui/settings/SettingsSendMail.h"
#endif
namespace GpgFrontend::UI {
SettingsDialog::SettingsDialog(QWidget* parent) : QDialog(parent) {
- tabWidget = new QTabWidget();
- generalTab = new GeneralTab();
- appearanceTab = new AppearanceTab();
+ tab_widget_ = new QTabWidget();
+ general_tab_ = new GeneralTab();
+ appearance_tab_ = new AppearanceTab();
#ifdef SMTP_SUPPORT
- sendMailTab = new SendMailTab();
+ send_mail_tab_ = new SendMailTab();
#endif
- keyserverTab = new KeyserverTab();
- networkTab = new NetworkTab();
+ key_server_tab_ = new KeyserverTab();
+ network_tab_ = new NetworkTab();
#ifdef ADVANCED_SUPPORT
advancedTab = new AdvancedTab;
#endif
- tabWidget->addTab(generalTab, _("General"));
- tabWidget->addTab(appearanceTab, _("Appearance"));
+ tab_widget_->addTab(general_tab_, _("General"));
+ tab_widget_->addTab(appearance_tab_, _("Appearance"));
#ifdef SMTP_SUPPORT
- tabWidget->addTab(sendMailTab, _("Send Mail"));
+ tab_widget_->addTab(send_mail_tab_, _("Send Mail"));
#endif
- tabWidget->addTab(keyserverTab, _("Key Server"));
+ tab_widget_->addTab(key_server_tab_, _("Key Server"));
// tabWidget->addTab(gpgPathsTab, _("Gpg paths"));
- tabWidget->addTab(networkTab, _("Network"));
+ tab_widget_->addTab(network_tab_, _("Network"));
#ifdef ADVANCED_SUPPORT
tabWidget->addTab(advancedTab, _("Advanced"));
#endif
- buttonBox =
+ button_box_ =
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotAccept()));
- connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+ connect(button_box_, &QDialogButtonBox::accepted, this, &SettingsDialog::SlotAccept);
+ connect(button_box_, &QDialogButtonBox::rejected, this, &SettingsDialog::reject);
auto* mainLayout = new QVBoxLayout;
- mainLayout->addWidget(tabWidget);
+ mainLayout->addWidget(tab_widget_);
mainLayout->stretch(0);
- mainLayout->addWidget(buttonBox);
+ mainLayout->addWidget(button_box_);
mainLayout->stretch(0);
setLayout(mainLayout);
setWindowTitle(_("Settings"));
- // slots for handling the restartneeded member
- this->slotSetRestartNeeded(false);
- connect(generalTab, SIGNAL(signalRestartNeeded(bool)), this,
- SLOT(slotSetRestartNeeded(bool)));
- connect(appearanceTab, SIGNAL(signalRestartNeeded(bool)), this,
- SLOT(slotSetRestartNeeded(bool)));
-#ifdef SMTP_SUPPORT
- connect(sendMailTab, SIGNAL(signalRestartNeeded(bool)), this,
- SLOT(slotSetRestartNeeded(bool)));
-#endif
- connect(keyserverTab, SIGNAL(signalRestartNeeded(bool)), this,
- SLOT(slotSetRestartNeeded(bool)));
-#ifdef ADVANCED_SUPPORT
- connect(advancedTab, SIGNAL(signalRestartNeeded(bool)), this,
- SLOT(slotSetRestartNeeded(bool)));
-#endif
-
- connect(this, SIGNAL(signalRestartNeeded(bool)), parent,
- SLOT(slotSetRestartNeeded(bool)));
+ // slots for handling the restart needed member
+ this->slot_set_restart_needed(false);
+ connect(general_tab_, &GeneralTab::SignalRestartNeeded, this,
+ &SettingsDialog::slot_set_restart_needed);
+ connect(this, &SettingsDialog::SignalRestartNeeded, qobject_cast<MainWindow *>(parent), &MainWindow::SlotSetRestartNeeded);
this->setMinimumSize(480, 680);
this->adjustSize();
this->show();
}
-bool SettingsDialog::getRestartNeeded() const { return this->restartNeeded; }
+bool SettingsDialog::get_restart_needed() const {
+ return this->restart_needed_;
+}
-void SettingsDialog::slotSetRestartNeeded(bool needed) {
- this->restartNeeded = needed;
+void SettingsDialog::slot_set_restart_needed(bool needed) {
+ this->restart_needed_ = needed;
}
-void SettingsDialog::slotAccept() {
+void SettingsDialog::SlotAccept() {
LOG(INFO) << "Called";
- generalTab->applySettings();
+ general_tab_->ApplySettings();
#ifdef SMTP_SUPPORT
- sendMailTab->applySettings();
+ send_mail_tab_->ApplySettings();
#endif
- appearanceTab->applySettings();
- keyserverTab->applySettings();
- networkTab->applySettings();
+ appearance_tab_->ApplySettings();
+ key_server_tab_->ApplySettings();
+ network_tab_->ApplySettings();
#ifdef ADVANCED_SUPPORT
advancedTab->applySettings();
#endif
@@ -127,14 +120,14 @@ void SettingsDialog::slotAccept() {
// write settings to filesystem
GlobalSettingStation::GetInstance().SyncSettings();
- LOG(INFO) << "restart needed" << getRestartNeeded();
- if (getRestartNeeded()) {
- emit signalRestartNeeded(true);
+ LOG(INFO) << "restart needed" << get_restart_needed();
+ if (get_restart_needed()) {
+ emit SignalRestartNeeded(true);
}
close();
}
-QHash<QString, QString> SettingsDialog::listLanguages() {
+QHash<QString, QString> SettingsDialog::ListLanguages() {
QHash<QString, QString> languages;
languages.insert(QString(), _("System Default"));
diff --git a/src/ui/settings/SettingsDialog.h b/src/ui/settings/SettingsDialog.h
index da3bdba3..000e6599 100755
--- a/src/ui/settings/SettingsDialog.h
+++ b/src/ui/settings/SettingsDialog.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -44,43 +48,77 @@ class NetworkTab;
class AdvancedTab;
#endif
+/**
+ * @brief
+ *
+ */
class SettingsDialog : public QDialog {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Settings Dialog object
+ *
+ * @param parent
+ */
explicit SettingsDialog(QWidget* parent = nullptr);
- GeneralTab* generalTab;
+ GeneralTab* general_tab_; ///<
#ifdef SMTP_SUPPORT
- SendMailTab* sendMailTab;
+ SendMailTab* send_mail_tab_; ///<
#endif
- AppearanceTab* appearanceTab;
- KeyserverTab* keyserverTab;
- NetworkTab* networkTab;
+ AppearanceTab* appearance_tab_; ///<
+ KeyserverTab* key_server_tab_; ///<
+ NetworkTab* network_tab_; ///<
#ifdef ADVANCED_SUPPORT
- AdvancedTab* advancedTab;
+ AdvancedTab* advanced_tab_; ///<
#endif
- static QHash<QString, QString> listLanguages();
+ /**
+ * @brief
+ *
+ * @return QHash<QString, QString>
+ */
+ static QHash<QString, QString> ListLanguages();
public slots:
- void slotAccept();
+ /**
+ * @brief
+ *
+ */
+ void SlotAccept();
signals:
- void signalRestartNeeded(bool needed);
+ /**
+ * @brief
+ *
+ * @param needed
+ */
+ void SignalRestartNeeded(bool needed);
private:
- QTabWidget* tabWidget;
- QDialogButtonBox* buttonBox;
- bool restartNeeded{};
-
- bool getRestartNeeded() const;
+ QTabWidget* tab_widget_; ///<
+ QDialogButtonBox* button_box_; ///<
+ bool restart_needed_{}; ///<
+
+ /**
+ * @brief Get the Restart Needed object
+ *
+ * @return true
+ * @return false
+ */
+ bool get_restart_needed() const;
private slots:
- void slotSetRestartNeeded(bool needed);
+ /**
+ * @brief
+ *
+ * @param needed
+ */
+ void slot_set_restart_needed(bool needed);
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/settings/SettingsGeneral.cpp b/src/ui/settings/SettingsGeneral.cpp
index 4f8ef544..3c7bca32 100644
--- a/src/ui/settings/SettingsGeneral.cpp
+++ b/src/ui/settings/SettingsGeneral.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -28,45 +32,45 @@
#include "SettingsDialog.h"
#endif
-#include "GlobalSettingStation.h"
+#include "core/function/GlobalSettingStation.h"
#include "ui_GeneralSettings.h"
namespace GpgFrontend::UI {
GeneralTab::GeneralTab(QWidget* parent)
- : QWidget(parent), ui(std::make_shared<Ui_GeneralSettings>()) {
- ui->setupUi(this);
+ : QWidget(parent), ui_(std::make_shared<Ui_GeneralSettings>()) {
+ ui_->setupUi(this);
- ui->saveCheckedKeysBox->setTitle(_("Save Checked Keys"));
- ui->saveCheckedKeysCheckBox->setText(
+ ui_->saveCheckedKeysBox->setTitle(_("Save Checked Keys"));
+ ui_->saveCheckedKeysCheckBox->setText(
_("Save checked private keys on exit and restore them on next start."));
- ui->longerKeyExpirationDateBox->setTitle(_("Longer Key Expiration Date"));
- ui->longerKeyExpirationDateCheckBox->setText(
+ ui_->longerKeyExpirationDateBox->setTitle(_("Longer Key Expiration Date"));
+ ui_->longerKeyExpirationDateCheckBox->setText(
_("Unlock key expiration date setting up to 30 years."));
- ui->importConfirmationBox->setTitle(_("Confirm drag'n'drop key import"));
- ui->importConfirmationCheckBox->setText(
+ ui_->importConfirmationBox->setTitle(_("Confirm drag'n'drop key import"));
+ ui_->importConfirmationCheckBox->setText(
_("Import files dropped on the Key List without confirmation."));
- ui->asciiModeBox->setTitle(_("ASCII Mode"));
- ui->asciiModeCheckBox->setText(
+ ui_->asciiModeBox->setTitle(_("ASCII Mode"));
+ ui_->asciiModeCheckBox->setText(
_("ASCII encoding is not used when file encrypting and "
"signing."));
- ui->langBox->setTitle(_("Language"));
- ui->langNoteLabel->setText(
+ ui_->langBox->setTitle(_("Language"));
+ ui_->langNoteLabel->setText(
"<b>" + QString(_("NOTE")) + _(": ") + "</b>" +
_("GpgFrontend will restart automatically if you change the language!"));
#ifdef MULTI_LANG_SUPPORT
- lang = SettingsDialog::listLanguages();
- for (const auto& l : lang) {
- ui->langSelectBox->addItem(l);
+ lang_ = SettingsDialog::ListLanguages();
+ for (const auto& l : lang_) {
+ ui_->langSelectBox->addItem(l);
}
- connect(ui->langSelectBox, SIGNAL(currentIndexChanged(int)), this,
- SLOT(slotLanguageChanged()));
+ connect(ui_->langSelectBox, qOverload<int>(&QComboBox::currentIndexChanged),
+ this, &GeneralTab::slot_language_changed);
#endif
- setSettings();
+ SetSettings();
}
/**********************************
@@ -74,12 +78,12 @@ GeneralTab::GeneralTab(QWidget* parent)
* and set the buttons and checkboxes
* appropriately
**********************************/
-void GeneralTab::setSettings() {
+void GeneralTab::SetSettings() {
auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
try {
bool save_key_checked = settings.lookup("general.save_key_checked");
if (save_key_checked)
- ui->saveCheckedKeysCheckBox->setCheckState(Qt::Checked);
+ ui_->saveCheckedKeysCheckBox->setCheckState(Qt::Checked);
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("save_key_checked");
}
@@ -89,7 +93,7 @@ void GeneralTab::setSettings() {
settings.lookup("general.longer_expiration_date");
LOG(INFO) << "longer_expiration_date" << longer_expiration_date;
if (longer_expiration_date)
- ui->longerKeyExpirationDateCheckBox->setCheckState(Qt::Checked);
+ ui_->longerKeyExpirationDateCheckBox->setCheckState(Qt::Checked);
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("longer_expiration_date");
}
@@ -97,13 +101,13 @@ void GeneralTab::setSettings() {
#ifdef MULTI_LANG_SUPPORT
try {
std::string lang_key = settings.lookup("general.lang");
- QString lang_value = lang.value(lang_key.c_str());
+ QString lang_value = lang_.value(lang_key.c_str());
LOG(INFO) << "lang settings current" << lang_value.toStdString();
- if (!lang.empty()) {
- ui->langSelectBox->setCurrentIndex(
- ui->langSelectBox->findText(lang_value));
+ if (!lang_.empty()) {
+ ui_->langSelectBox->setCurrentIndex(
+ ui_->langSelectBox->findText(lang_value));
} else {
- ui->langSelectBox->setCurrentIndex(0);
+ ui_->langSelectBox->setCurrentIndex(0);
}
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("lang");
@@ -114,7 +118,7 @@ void GeneralTab::setSettings() {
bool confirm_import_keys = settings.lookup("general.confirm_import_keys");
LOG(INFO) << "confirm_import_keys" << confirm_import_keys;
if (confirm_import_keys)
- ui->importConfirmationCheckBox->setCheckState(Qt::Checked);
+ ui_->importConfirmationCheckBox->setCheckState(Qt::Checked);
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("confirm_import_keys");
}
@@ -124,7 +128,7 @@ void GeneralTab::setSettings() {
settings.lookup("general.non_ascii_when_export");
LOG(INFO) << "non_ascii_when_export" << non_ascii_when_export;
if (non_ascii_when_export)
- ui->asciiModeCheckBox->setCheckState(Qt::Checked);
+ ui_->asciiModeCheckBox->setCheckState(Qt::Checked);
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("non_ascii_when_export");
}
@@ -134,9 +138,9 @@ void GeneralTab::setSettings() {
* get the values of the buttons and
* write them to settings-file
*************************************/
-void GeneralTab::applySettings() {
+void GeneralTab::ApplySettings() {
auto& settings =
- GpgFrontend::UI::GlobalSettingStation::GetInstance().GetUISettings();
+ GpgFrontend::GlobalSettingStation::GetInstance().GetUISettings();
if (!settings.exists("general") ||
settings.lookup("general").getType() != libconfig::Setting::TypeGroup)
@@ -146,46 +150,47 @@ void GeneralTab::applySettings() {
if (!general.exists("longer_expiration_date"))
general.add("longer_expiration_date", libconfig::Setting::TypeBoolean) =
- ui->longerKeyExpirationDateCheckBox->isChecked();
+ ui_->longerKeyExpirationDateCheckBox->isChecked();
else {
general["longer_expiration_date"] =
- ui->longerKeyExpirationDateCheckBox->isChecked();
+ ui_->longerKeyExpirationDateCheckBox->isChecked();
}
if (!general.exists("save_key_checked"))
general.add("save_key_checked", libconfig::Setting::TypeBoolean) =
- ui->saveCheckedKeysCheckBox->isChecked();
+ ui_->saveCheckedKeysCheckBox->isChecked();
else {
- general["save_key_checked"] = ui->saveCheckedKeysCheckBox->isChecked();
+ general["save_key_checked"] = ui_->saveCheckedKeysCheckBox->isChecked();
}
if (!general.exists("non_ascii_when_export"))
general.add("non_ascii_when_export", libconfig::Setting::TypeBoolean) =
- ui->asciiModeCheckBox->isChecked();
+ ui_->asciiModeCheckBox->isChecked();
else {
- general["non_ascii_when_export"] = ui->asciiModeCheckBox->isChecked();
+ general["non_ascii_when_export"] = ui_->asciiModeCheckBox->isChecked();
}
#ifdef MULTI_LANG_SUPPORT
if (!general.exists("lang"))
general.add("lang", libconfig::Setting::TypeBoolean) =
- lang.key(ui->langSelectBox->currentText()).toStdString();
+ lang_.key(ui_->langSelectBox->currentText()).toStdString();
else {
- general["lang"] = lang.key(ui->langSelectBox->currentText()).toStdString();
+ general["lang"] =
+ lang_.key(ui_->langSelectBox->currentText()).toStdString();
}
#endif
if (!general.exists("confirm_import_keys"))
general.add("confirm_import_keys", libconfig::Setting::TypeBoolean) =
- ui->importConfirmationCheckBox->isChecked();
+ ui_->importConfirmationCheckBox->isChecked();
else {
general["confirm_import_keys"] =
- ui->importConfirmationCheckBox->isChecked();
+ ui_->importConfirmationCheckBox->isChecked();
}
}
#ifdef MULTI_LANG_SUPPORT
-void GeneralTab::slotLanguageChanged() { emit signalRestartNeeded(true); }
+void GeneralTab::slot_language_changed() { emit SignalRestartNeeded(true); }
#endif
} // namespace GpgFrontend::UI
diff --git a/src/ui/settings/SettingsGeneral.h b/src/ui/settings/SettingsGeneral.h
index a5e2b8d0..b3e7d904 100644
--- a/src/ui/settings/SettingsGeneral.h
+++ b/src/ui/settings/SettingsGeneral.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -32,37 +36,63 @@ class Ui_GeneralSettings;
namespace GpgFrontend::UI {
class KeyList;
+/**
+ * @brief
+ *
+ */
class GeneralTab : public QWidget {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new General Tab object
+ *
+ * @param parent
+ */
explicit GeneralTab(QWidget* parent = nullptr);
- void setSettings();
+ /**
+ * @brief Set the Settings object
+ *
+ */
+ void SetSettings();
- void applySettings();
+ /**
+ * @brief
+ *
+ */
+ void ApplySettings();
+
+ signals:
+
+ /**
+ * @brief
+ *
+ * @param needed
+ */
+ void SignalRestartNeeded(bool needed);
private:
- std::shared_ptr<Ui_GeneralSettings> ui;
+ std::shared_ptr<Ui_GeneralSettings> ui_; ///<
#ifdef MULTI_LANG_SUPPORT
- QHash<QString, QString> lang;
+ QHash<QString, QString> lang_; ///<
#endif
- std::vector<std::string> keyIdsList;
+ std::vector<std::string> key_ids_list_; ///<
- KeyList* mKeyList{};
+ KeyList* m_key_list_{}; ///<
private slots:
#ifdef MULTI_LANG_SUPPORT
-
- void slotLanguageChanged();
+ /**
+ * @brief
+ *
+ */
+ void slot_language_changed();
#endif
- signals:
-
- void signalRestartNeeded(bool needed);
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/settings/SettingsKeyServer.cpp b/src/ui/settings/SettingsKeyServer.cpp
index 533c8316..f2eaf9a9 100644
--- a/src/ui/settings/SettingsKeyServer.cpp
+++ b/src/ui/settings/SettingsKeyServer.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,104 +8,108 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include "SettingsKeyServer.h"
-#include "GlobalSettingStation.h"
-#include "ui/thread/TestListedKeyServerThread.h"
+#include "core/function/GlobalSettingStation.h"
+#include "ui/struct/SettingsObject.h"
+#include "ui/thread/ListedKeyServerTestThread.h"
#include "ui_KeyServerSettings.h"
namespace GpgFrontend::UI {
KeyserverTab::KeyserverTab(QWidget* parent)
- : QWidget(parent), ui(std::make_shared<Ui_KeyServerSettings>()) {
- ui->setupUi(this);
- ui->keyServerListTable->setSizeAdjustPolicy(
+ : QWidget(parent), ui_(std::make_shared<Ui_KeyServerSettings>()) {
+ ui_->setupUi(this);
+ ui_->keyServerListTable->setSizeAdjustPolicy(
QAbstractScrollArea::AdjustToContents);
- connect(ui->addKeyServerPushButton, &QPushButton::clicked, this,
- &KeyserverTab::addKeyServer);
- connect(ui->testKeyServerButton, &QPushButton::clicked, this,
- &KeyserverTab::slotTestListedKeyServer);
+ connect(ui_->addKeyServerPushButton, &QPushButton::clicked, this,
+ &KeyserverTab::slot_add_key_server);
+ connect(ui_->testKeyServerButton, &QPushButton::clicked, this,
+ &KeyserverTab::slot_test_listed_key_server);
- ui->keyServerListGroupBox->setTitle(_("Keyserver List"));
- ui->operationsGroupBox->setTitle(_("Operations"));
+ ui_->keyServerListGroupBox->setTitle(_("Keyserver List"));
+ ui_->operationsGroupBox->setTitle(_("Operations"));
- ui->keyServerListTable->horizontalHeaderItem(0)->setText(_("Default"));
- ui->keyServerListTable->horizontalHeaderItem(1)->setText(
+ ui_->keyServerListTable->horizontalHeaderItem(0)->setText(_("Default"));
+ ui_->keyServerListTable->horizontalHeaderItem(1)->setText(
_("Keyserver Address"));
- ui->keyServerListTable->horizontalHeaderItem(2)->setText(_("Security"));
- ui->keyServerListTable->horizontalHeaderItem(3)->setText(_("Available"));
+ ui_->keyServerListTable->horizontalHeaderItem(2)->setText(_("Security"));
+ ui_->keyServerListTable->horizontalHeaderItem(3)->setText(_("Available"));
- ui->addKeyServerPushButton->setText(_("Add"));
- ui->testKeyServerButton->setText(_("Test Listed Keyserver"));
+ ui_->addKeyServerPushButton->setText(_("Add"));
+ ui_->testKeyServerButton->setText(_("Test Listed Keyserver"));
- ui->tipsLabel->setText(_("Tips: Please Double-click table item to edit it."));
- ui->actionDelete_Selected_Key_Server->setText(_("Delete Selected"));
- ui->actionDelete_Selected_Key_Server->setToolTip(
+ ui_->tipsLabel->setText(
+ _("Tips: Please Double-click table item to edit it."));
+ ui_->actionDelete_Selected_Key_Server->setText(_("Delete Selected"));
+ ui_->actionDelete_Selected_Key_Server->setToolTip(
_("Delete Selected Key Server"));
- ui->actionSet_As_Default->setText(_("Set As Default"));
- ui->actionSet_As_Default->setToolTip(_("Set As Default"));
+ ui_->actionSet_As_Default->setText(_("Set As Default"));
+ ui_->actionSet_As_Default->setToolTip(_("Set As Default"));
- popupMenu = new QMenu(this);
- popupMenu->addAction(ui->actionSet_As_Default);
- popupMenu->addAction(ui->actionDelete_Selected_Key_Server);
+ popup_menu_ = new QMenu(this);
+ popup_menu_->addAction(ui_->actionSet_As_Default);
+ popup_menu_->addAction(ui_->actionDelete_Selected_Key_Server);
- connect(ui->keyServerListTable, &QTableWidget::itemChanged,
+ connect(ui_->keyServerListTable, &QTableWidget::itemChanged,
[=](QTableWidgetItem* item) {
LOG(INFO) << "item edited" << item->column();
if (item->column() != 1) return;
- const auto row_size = ui->keyServerListTable->rowCount();
+ const auto row_size = ui_->keyServerListTable->rowCount();
// Update Actions
if (row_size > 0) {
- keyServerStrList.clear();
+ key_server_str_list_.clear();
for (int i = 0; i < row_size; i++) {
const auto key_server =
- ui->keyServerListTable->item(i, 1)->text();
- keyServerStrList.append(key_server);
+ ui_->keyServerListTable->item(i, 1)->text();
+ key_server_str_list_.append(key_server);
}
}
});
- connect(ui->actionSet_As_Default, &QAction::triggered, [=]() {
- const auto row_size = ui->keyServerListTable->rowCount();
+ connect(ui_->actionSet_As_Default, &QAction::triggered, [=]() {
+ const auto row_size = ui_->keyServerListTable->rowCount();
for (int i = 0; i < row_size; i++) {
- const auto item = ui->keyServerListTable->item(i, 1);
+ const auto item = ui_->keyServerListTable->item(i, 1);
if (!item->isSelected()) continue;
- this->defaultKeyServer = item->text();
+ this->default_key_server_ = item->text();
}
- this->refreshTable();
+ this->slot_refresh_table();
});
- connect(ui->actionDelete_Selected_Key_Server, &QAction::triggered, [=]() {
- const auto row_size = ui->keyServerListTable->rowCount();
+ connect(ui_->actionDelete_Selected_Key_Server, &QAction::triggered, [=]() {
+ const auto row_size = ui_->keyServerListTable->rowCount();
for (int i = 0; i < row_size; i++) {
- const auto item = ui->keyServerListTable->item(i, 1);
+ const auto item = ui_->keyServerListTable->item(i, 1);
if (!item->isSelected()) continue;
- this->keyServerStrList.removeAt(i);
+ this->key_server_str_list_.removeAt(i);
break;
}
- this->refreshTable();
+ this->slot_refresh_table();
});
// Read key-list from ini-file and fill it into combobox
- setSettings();
- refreshTable();
+ SetSettings();
+ slot_refresh_table();
}
/**********************************
@@ -111,33 +117,31 @@ KeyserverTab::KeyserverTab(QWidget* parent)
* and set the buttons and checkboxes
* appropriately
**********************************/
-void KeyserverTab::setSettings() {
- auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+void KeyserverTab::SetSettings() {
+ SettingsObject key_server_json("key_server");
- try {
- auto& server_list = settings.lookup("keyserver.server_list");
- const auto server_list_size = server_list.getLength();
- for (int i = 0; i < server_list_size; i++) {
- std::string server_url = server_list[i];
- keyServerStrList.append(server_url.c_str());
- }
- } catch (...) {
- LOG(ERROR) << _("Setting Operation Error") << _("server_list");
- }
+ const auto key_server_list =
+ key_server_json.Check("server_list", nlohmann::json::array());
- try {
- std::string default_server = settings.lookup("keyserver.default_server");
- if (!keyServerStrList.contains(default_server.c_str()))
- keyServerStrList.append(default_server.c_str());
- defaultKeyServer = QString::fromStdString(default_server);
- } catch (...) {
- LOG(ERROR) << _("Setting Operation Error") << _("default_server");
+ for (const auto& key_server : key_server_list) {
+ const auto key_server_str = key_server.get<std::string>();
+ this->key_server_str_list_.append(key_server_str.c_str());
}
+
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+
+ int default_key_server_index = key_server_json.Check("default_server", 0);
+ std::string default_key_server =
+ key_server_list[default_key_server_index].get<std::string>();
+
+ if (!key_server_str_list_.contains(default_key_server.c_str()))
+ key_server_str_list_.append(default_key_server.c_str());
+ default_key_server_ = QString::fromStdString(default_key_server);
}
-void KeyserverTab::addKeyServer() {
- auto target_url = ui->addKeyServerEdit->text();
- if (url_reg.match(target_url).hasMatch()) {
+void KeyserverTab::slot_add_key_server() {
+ auto target_url = ui_->addKeyServerEdit->text();
+ if (url_reg_.match(target_url).hasMatch()) {
if (target_url.startsWith("https://")) {
;
} else if (target_url.startsWith("http://")) {
@@ -148,7 +152,7 @@ void KeyserverTab::addKeyServer() {
"the key server is not recommended. It is recommended to use "
"HTTPS."));
}
- keyServerStrList.append(ui->addKeyServerEdit->text());
+ key_server_str_list_.append(ui_->addKeyServerEdit->text());
} else {
auto ret = QMessageBox::warning(
this, _("Warning"),
@@ -162,99 +166,85 @@ void KeyserverTab::addKeyServer() {
if (ret == QMessageBox::Cancel)
return;
else
- keyServerStrList.append(ui->addKeyServerEdit->text());
+ key_server_str_list_.append(ui_->addKeyServerEdit->text());
}
- refreshTable();
+ slot_refresh_table();
}
-void KeyserverTab::applySettings() {
- auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
-
- if (!settings.exists("keyserver") ||
- settings.lookup("keyserver").getType() != libconfig::Setting::TypeGroup)
- settings.add("keyserver", libconfig::Setting::TypeGroup);
-
- auto& keyserver = settings["keyserver"];
-
- if (keyserver.exists("server_list")) keyserver.remove("server_list");
-
- keyserver.add("server_list", libconfig::Setting::TypeList);
-
- const auto row_size = ui->keyServerListTable->rowCount();
- auto& server_list = keyserver["server_list"];
- for (int i = 0; i < row_size; i++) {
- const auto key_server = ui->keyServerListTable->item(i, 1)->text();
- server_list.add(libconfig::Setting::TypeString) = key_server.toStdString();
- }
-
- if (!keyserver.exists("default_server")) {
- keyserver.add("default_server", libconfig::Setting::TypeString) =
- defaultKeyServer.toStdString();
- } else {
- keyserver["default_server"] = defaultKeyServer.toStdString();
+void KeyserverTab::ApplySettings() {
+ SettingsObject key_server_json("key_server");
+ key_server_json["server_list"] = nlohmann::json::array();
+ auto& key_server_list = key_server_json["server_list"];
+
+ const auto list_size = key_server_str_list_.size();
+ for (int i = 0; i < list_size; i++) {
+ const auto key_server = key_server_str_list_[i];
+ if (default_key_server_ == key_server)
+ key_server_json["default_server"] = i;
+ key_server_list.insert(key_server_list.end(), key_server.toStdString());
}
}
-void KeyserverTab::refreshTable() {
+void KeyserverTab::slot_refresh_table() {
LOG(INFO) << "Start Refreshing Key Server Table";
- ui->keyServerListTable->blockSignals(true);
- ui->keyServerListTable->setRowCount(keyServerStrList.size());
+ ui_->keyServerListTable->blockSignals(true);
+ ui_->keyServerListTable->setRowCount(key_server_str_list_.size());
int index = 0;
- for (const auto& server : keyServerStrList) {
+ for (const auto& server : key_server_str_list_) {
auto* tmp1 =
- new QTableWidgetItem(server == defaultKeyServer ? "*" : QString{});
+ new QTableWidgetItem(server == default_key_server_ ? "*" : QString{});
tmp1->setTextAlignment(Qt::AlignCenter);
- ui->keyServerListTable->setItem(index, 0, tmp1);
+ ui_->keyServerListTable->setItem(index, 0, tmp1);
tmp1->setFlags(tmp1->flags() ^ Qt::ItemIsEditable);
auto* tmp2 = new QTableWidgetItem(server);
tmp2->setTextAlignment(Qt::AlignCenter);
- ui->keyServerListTable->setItem(index, 1, tmp2);
+ ui_->keyServerListTable->setItem(index, 1, tmp2);
auto* tmp3 = new QTableWidgetItem(server.startsWith("https") ? _("true")
: _("false"));
tmp3->setTextAlignment(Qt::AlignCenter);
- ui->keyServerListTable->setItem(index, 2, tmp3);
+ ui_->keyServerListTable->setItem(index, 2, tmp3);
tmp3->setFlags(tmp3->flags() ^ Qt::ItemIsEditable);
auto* tmp4 = new QTableWidgetItem(_("unknown"));
tmp4->setTextAlignment(Qt::AlignCenter);
- ui->keyServerListTable->setItem(index, 3, tmp4);
+ ui_->keyServerListTable->setItem(index, 3, tmp4);
tmp4->setFlags(tmp3->flags() ^ Qt::ItemIsEditable);
index++;
}
- const auto column_count = ui->keyServerListTable->columnCount();
+ const auto column_count = ui_->keyServerListTable->columnCount();
for (int i = 0; i < column_count; i++) {
- ui->keyServerListTable->resizeColumnToContents(i);
+ ui_->keyServerListTable->resizeColumnToContents(i);
}
- ui->keyServerListTable->blockSignals(false);
+ ui_->keyServerListTable->blockSignals(false);
}
-void KeyserverTab::slotTestListedKeyServer() {
+void KeyserverTab::slot_test_listed_key_server() {
auto timeout =
QInputDialog::getInt(this, _("Set TCP Timeout"), tr("timeout(ms): "),
QLineEdit::Normal, 500, 2000);
QStringList urls;
- const auto row_size = ui->keyServerListTable->rowCount();
+ const auto row_size = ui_->keyServerListTable->rowCount();
for (int i = 0; i < row_size; i++) {
- const auto keyserver_url = ui->keyServerListTable->item(i, 1)->text();
+ const auto keyserver_url = ui_->keyServerListTable->item(i, 1)->text();
urls.push_back(keyserver_url);
}
- auto thread = new TestListedKeyServerThread(urls, timeout, this);
+ auto thread = new ListedKeyServerTestThread(urls, timeout, this);
connect(thread,
- &GpgFrontend::UI::TestListedKeyServerThread::
- signalKeyServerListTestResult,
+ &GpgFrontend::UI::ListedKeyServerTestThread::
+ SignalKeyServerListTestResult,
this, [=](const QStringList& result) {
- const auto row_size = ui->keyServerListTable->rowCount();
+ const auto row_size = ui_->keyServerListTable->rowCount();
if (result.size() != row_size) return;
- ui->keyServerListTable->blockSignals(true);
+ ui_->keyServerListTable->blockSignals(true);
for (int i = 0; i < row_size; i++) {
const auto status = result[i];
- auto status_iem = ui->keyServerListTable->item(i, 3);
+ auto status_iem = ui_->keyServerListTable->item(i, 3);
if (status == "Reachable") {
status_iem->setText(_("Reachable"));
status_iem->setForeground(QBrush(QColor::fromRgb(0, 255, 0)));
@@ -263,7 +253,7 @@ void KeyserverTab::slotTestListedKeyServer() {
status_iem->setForeground(QBrush(QColor::fromRgb(255, 0, 0)));
}
}
- ui->keyServerListTable->blockSignals(false);
+ ui_->keyServerListTable->blockSignals(false);
});
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
@@ -300,8 +290,8 @@ void KeyserverTab::slotTestListedKeyServer() {
void KeyserverTab::contextMenuEvent(QContextMenuEvent* event) {
QWidget::contextMenuEvent(event);
- if (ui->keyServerListTable->selectedItems().length() > 0) {
- popupMenu->exec(event->globalPos());
+ if (ui_->keyServerListTable->selectedItems().length() > 0) {
+ popup_menu_->exec(event->globalPos());
}
}
diff --git a/src/ui/settings/SettingsKeyServer.h b/src/ui/settings/SettingsKeyServer.h
index 735ace98..f983e69b 100644
--- a/src/ui/settings/SettingsKeyServer.h
+++ b/src/ui/settings/SettingsKeyServer.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -30,38 +34,76 @@
class Ui_KeyServerSettings;
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class KeyserverTab : public QWidget {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Keyserver Tab object
+ *
+ * @param parent
+ */
explicit KeyserverTab(QWidget* parent = nullptr);
- void setSettings();
+ /**
+ * @brief Set the Settings object
+ *
+ */
+ void SetSettings();
- void applySettings();
+ /**
+ * @brief
+ *
+ */
+ void ApplySettings();
private:
- std::shared_ptr<Ui_KeyServerSettings> ui;
- QString defaultKeyServer;
- QStringList keyServerStrList;
- QMenu* popupMenu{};
+ std::shared_ptr<Ui_KeyServerSettings> ui_;
+ QString default_key_server_;
+ QStringList key_server_str_list_;
+ QMenu* popup_menu_{};
- QRegularExpression url_reg{
+ QRegularExpression url_reg_{
R"(^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$)"};
private slots:
- void addKeyServer();
+ /**
+ * @brief
+ *
+ */
+ void slot_add_key_server();
- void refreshTable();
+ /**
+ * @brief
+ *
+ */
+ void slot_refresh_table();
- void slotTestListedKeyServer();
+ /**
+ * @brief
+ *
+ */
+ void slot_test_listed_key_server();
signals:
-
- void signalRestartNeeded(bool needed);
+ /**
+ * @brief
+ *
+ * @param needed
+ */
+ void SignalRestartNeeded(bool needed);
protected:
+ /**
+ * @brief
+ *
+ * @param event
+ */
void contextMenuEvent(QContextMenuEvent* event) override;
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/settings/SettingsNetwork.cpp b/src/ui/settings/SettingsNetwork.cpp
index 0aec38c4..d4edae42 100644
--- a/src/ui/settings/SettingsNetwork.cpp
+++ b/src/ui/settings/SettingsNetwork.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,151 +8,153 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include "SettingsNetwork.h"
+#include "core/function/GlobalSettingStation.h"
#include "ui/thread/ProxyConnectionTestThread.h"
-#include "ui/settings//GlobalSettingStation.h"
#include "ui_NetworkSettings.h"
GpgFrontend::UI::NetworkTab::NetworkTab(QWidget *parent)
- : QWidget(parent), ui(std::make_shared<Ui_NetworkSettings>()) {
- ui->setupUi(this);
+ : QWidget(parent), ui_(std::make_shared<Ui_NetworkSettings>()) {
+ ui_->setupUi(this);
- connect(ui->enableProxyCheckBox, &QCheckBox::stateChanged, this,
+ connect(ui_->enableProxyCheckBox, &QCheckBox::stateChanged, this,
[=](int state) { switch_ui_enabled(state == Qt::Checked); });
connect(
- ui->proxyTypeComboBox, &QComboBox::currentTextChanged, this,
+ ui_->proxyTypeComboBox, &QComboBox::currentTextChanged, this,
[=](const QString &current_text) { switch_ui_proxy_type(current_text); });
- connect(ui->checkProxyConnectionButton, &QPushButton::clicked, this,
- &NetworkTab::slotTestProxyConnectionResult);
+ connect(ui_->checkProxyConnectionButton, &QPushButton::clicked, this,
+ &NetworkTab::slot_test_proxy_connection_result);
- ui->proxyGroupBox->setTitle(_("Proxy"));
- ui->capabilityGroupBox->setTitle(_("Network Capability"));
- ui->operationsGroupBox->setTitle(_("Operations"));
+ ui_->proxyGroupBox->setTitle(_("Proxy"));
+ ui_->capabilityGroupBox->setTitle(_("Network Capability"));
+ ui_->operationsGroupBox->setTitle(_("Operations"));
- ui->enableProxyCheckBox->setText(_("Enable Proxy"));
- ui->proxyServerPortLabel->setText(_("Port"));
+ ui_->enableProxyCheckBox->setText(_("Enable Proxy"));
+ ui_->proxyServerPortLabel->setText(_("Port"));
- ui->proxyServerAddressLabel->setText(_("Host Address"));
- ui->proxyServerPortLabel->setText(_("Port"));
- ui->proxyTypeLabel->setText(_("Proxy Type"));
- ui->usernameLabel->setText(_("Username"));
- ui->passwordLabel->setText(_("Password"));
+ ui_->proxyServerAddressLabel->setText(_("Host Address"));
+ ui_->proxyServerPortLabel->setText(_("Port"));
+ ui_->proxyTypeLabel->setText(_("Proxy Type"));
+ ui_->usernameLabel->setText(_("Username"));
+ ui_->passwordLabel->setText(_("Password"));
- ui->forbidALLCheckBox->setText(_("Forbid all network connection."));
- ui->forbidALLCheckBox->setDisabled(true);
+ ui_->forbidALLCheckBox->setText(_("Forbid all network connection."));
+ ui_->forbidALLCheckBox->setDisabled(true);
- ui->prohibitUpdateCheck->setText(
+ ui_->prohibitUpdateCheck->setText(
_("Prohibit checking for version updates when the program starts."));
- ui->checkProxyConnectionButton->setText(_("Check Proxy Connection"));
+ ui_->checkProxyConnectionButton->setText(_("Check Proxy Connection"));
- setSettings();
+ SetSettings();
}
-void GpgFrontend::UI::NetworkTab::setSettings() {
+void GpgFrontend::UI::NetworkTab::SetSettings() {
auto &settings = GlobalSettingStation::GetInstance().GetUISettings();
try {
std::string proxy_host = settings.lookup("proxy.proxy_host");
- ui->proxyServerAddressEdit->setText(proxy_host.c_str());
+ ui_->proxyServerAddressEdit->setText(proxy_host.c_str());
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("proxy_host");
}
try {
std::string std_username = settings.lookup("proxy.username");
- ui->usernameEdit->setText(std_username.c_str());
+ ui_->usernameEdit->setText(std_username.c_str());
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("username");
}
try {
std::string std_password = settings.lookup("proxy.password");
- ui->passwordEdit->setText(std_password.c_str());
+ ui_->passwordEdit->setText(std_password.c_str());
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("password");
}
try {
int port = settings.lookup("proxy.port");
- ui->portSpin->setValue(port);
+ ui_->portSpin->setValue(port);
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("port");
}
- ui->proxyTypeComboBox->setCurrentText("HTTP");
+ ui_->proxyTypeComboBox->setCurrentText("HTTP");
try {
std::string proxy_type = settings.lookup("proxy.proxy_type");
- ui->proxyTypeComboBox->setCurrentText(proxy_type.c_str());
+ ui_->proxyTypeComboBox->setCurrentText(proxy_type.c_str());
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("proxy_type");
}
- switch_ui_proxy_type(ui->proxyTypeComboBox->currentText());
+ switch_ui_proxy_type(ui_->proxyTypeComboBox->currentText());
- ui->enableProxyCheckBox->setCheckState(Qt::Unchecked);
+ ui_->enableProxyCheckBox->setCheckState(Qt::Unchecked);
try {
bool proxy_enable = settings.lookup("proxy.enable");
if (proxy_enable)
- ui->enableProxyCheckBox->setCheckState(Qt::Checked);
+ ui_->enableProxyCheckBox->setCheckState(Qt::Checked);
else
- ui->enableProxyCheckBox->setCheckState(Qt::Unchecked);
+ ui_->enableProxyCheckBox->setCheckState(Qt::Unchecked);
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("proxy_enable");
}
{
- auto state = ui->enableProxyCheckBox->checkState();
+ auto state = ui_->enableProxyCheckBox->checkState();
switch_ui_enabled(state == Qt::Checked);
}
- ui->forbidALLCheckBox->setCheckState(Qt::Unchecked);
+ ui_->forbidALLCheckBox->setCheckState(Qt::Unchecked);
try {
bool forbid_all_connection =
settings.lookup("network.forbid_all_connection");
if (forbid_all_connection)
- ui->forbidALLCheckBox->setCheckState(Qt::Checked);
+ ui_->forbidALLCheckBox->setCheckState(Qt::Checked);
else
- ui->forbidALLCheckBox->setCheckState(Qt::Unchecked);
+ ui_->forbidALLCheckBox->setCheckState(Qt::Unchecked);
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("forbid_all_connection");
}
- ui->prohibitUpdateCheck->setCheckState(Qt::Unchecked);
+ ui_->prohibitUpdateCheck->setCheckState(Qt::Unchecked);
try {
bool prohibit_update_checking =
settings.lookup("network.prohibit_update_checking");
if (prohibit_update_checking)
- ui->prohibitUpdateCheck->setCheckState(Qt::Checked);
+ ui_->prohibitUpdateCheck->setCheckState(Qt::Checked);
else
- ui->prohibitUpdateCheck->setCheckState(Qt::Unchecked);
+ ui_->prohibitUpdateCheck->setCheckState(Qt::Unchecked);
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("prohibit_update_checking");
}
}
-void GpgFrontend::UI::NetworkTab::applySettings() {
+void GpgFrontend::UI::NetworkTab::ApplySettings() {
LOG(INFO) << "called";
auto &settings =
- GpgFrontend::UI::GlobalSettingStation::GetInstance().GetUISettings();
+ GpgFrontend::GlobalSettingStation::GetInstance().GetUISettings();
if (!settings.exists("proxy") ||
settings.lookup("proxy").getType() != libconfig::Setting::TypeGroup)
@@ -160,43 +164,43 @@ void GpgFrontend::UI::NetworkTab::applySettings() {
if (!proxy.exists("proxy_host"))
proxy.add("proxy_host", libconfig::Setting::TypeString) =
- ui->proxyServerAddressEdit->text().toStdString();
+ ui_->proxyServerAddressEdit->text().toStdString();
else {
- proxy["proxy_host"] = ui->proxyServerAddressEdit->text().toStdString();
+ proxy["proxy_host"] = ui_->proxyServerAddressEdit->text().toStdString();
}
if (!proxy.exists("username"))
proxy.add("username", libconfig::Setting::TypeString) =
- ui->usernameEdit->text().toStdString();
+ ui_->usernameEdit->text().toStdString();
else {
- proxy["username"] = ui->usernameEdit->text().toStdString();
+ proxy["username"] = ui_->usernameEdit->text().toStdString();
}
if (!proxy.exists("password"))
proxy.add("password", libconfig::Setting::TypeString) =
- ui->passwordEdit->text().toStdString();
+ ui_->passwordEdit->text().toStdString();
else {
- proxy["password"] = ui->passwordEdit->text().toStdString();
+ proxy["password"] = ui_->passwordEdit->text().toStdString();
}
if (!proxy.exists("port"))
- proxy.add("port", libconfig::Setting::TypeInt) = ui->portSpin->value();
+ proxy.add("port", libconfig::Setting::TypeInt) = ui_->portSpin->value();
else {
- proxy["port"] = ui->portSpin->value();
+ proxy["port"] = ui_->portSpin->value();
}
if (!proxy.exists("proxy_type"))
proxy.add("proxy_type", libconfig::Setting::TypeString) =
- ui->proxyTypeComboBox->currentText().toStdString();
+ ui_->proxyTypeComboBox->currentText().toStdString();
else {
- proxy["proxy_type"] = ui->proxyTypeComboBox->currentText().toStdString();
+ proxy["proxy_type"] = ui_->proxyTypeComboBox->currentText().toStdString();
}
if (!proxy.exists("enable"))
proxy.add("enable", libconfig::Setting::TypeBoolean) =
- ui->enableProxyCheckBox->isChecked();
+ ui_->enableProxyCheckBox->isChecked();
else {
- proxy["enable"] = ui->enableProxyCheckBox->isChecked();
+ proxy["enable"] = ui_->enableProxyCheckBox->isChecked();
}
if (!settings.exists("network") ||
@@ -207,16 +211,16 @@ void GpgFrontend::UI::NetworkTab::applySettings() {
if (!network.exists("forbid_all_connection"))
network.add("forbid_all_connection", libconfig::Setting::TypeBoolean) =
- ui->forbidALLCheckBox->isChecked();
+ ui_->forbidALLCheckBox->isChecked();
else {
- network["forbid_all_connection"] = ui->forbidALLCheckBox->isChecked();
+ network["forbid_all_connection"] = ui_->forbidALLCheckBox->isChecked();
}
if (!network.exists("prohibit_update_checking"))
network.add("prohibit_update_checking", libconfig::Setting::TypeBoolean) =
- ui->prohibitUpdateCheck->isChecked();
+ ui_->prohibitUpdateCheck->isChecked();
else {
- network["prohibit_update_checking"] = ui->prohibitUpdateCheck->isChecked();
+ network["prohibit_update_checking"] = ui_->prohibitUpdateCheck->isChecked();
}
apply_proxy_settings();
@@ -224,7 +228,7 @@ void GpgFrontend::UI::NetworkTab::applySettings() {
LOG(INFO) << "done";
}
-void GpgFrontend::UI::NetworkTab::slotTestProxyConnectionResult() {
+void GpgFrontend::UI::NetworkTab::slot_test_proxy_connection_result() {
apply_proxy_settings();
bool ok;
@@ -235,7 +239,7 @@ void GpgFrontend::UI::NetworkTab::slotTestProxyConnectionResult() {
auto thread = new ProxyConnectionTestThread(url, 800, this);
connect(thread,
&GpgFrontend::UI::ProxyConnectionTestThread::
- signalProxyConnectionTestResult,
+ SignalProxyConnectionTestResult,
this, [=](const QString &result) {
if (result == "Reachable") {
QMessageBox::information(this, _("Success"),
@@ -284,14 +288,14 @@ void GpgFrontend::UI::NetworkTab::slotTestProxyConnectionResult() {
void GpgFrontend::UI::NetworkTab::apply_proxy_settings() {
// apply settings
QNetworkProxy _proxy;
- if (ui->enableProxyCheckBox->isChecked() &&
+ if (ui_->enableProxyCheckBox->isChecked() &&
proxy_type_ != QNetworkProxy::DefaultProxy) {
_proxy.setType(proxy_type_);
- _proxy.setHostName(ui->proxyServerAddressEdit->text());
- _proxy.setPort(ui->portSpin->value());
- if (!ui->usernameEdit->text().isEmpty()) {
- _proxy.setUser(ui->usernameEdit->text());
- _proxy.setPassword(ui->passwordEdit->text());
+ _proxy.setHostName(ui_->proxyServerAddressEdit->text());
+ _proxy.setPort(ui_->portSpin->value());
+ if (!ui_->usernameEdit->text().isEmpty()) {
+ _proxy.setUser(ui_->usernameEdit->text());
+ _proxy.setPassword(ui_->passwordEdit->text());
}
} else {
_proxy.setType(proxy_type_);
@@ -301,34 +305,34 @@ void GpgFrontend::UI::NetworkTab::apply_proxy_settings() {
}
void GpgFrontend::UI::NetworkTab::switch_ui_enabled(bool enabled) {
- ui->proxyServerAddressEdit->setDisabled(!enabled);
- ui->portSpin->setDisabled(!enabled);
- ui->proxyTypeComboBox->setDisabled(!enabled);
- ui->usernameEdit->setDisabled(!enabled);
- ui->passwordEdit->setDisabled(!enabled);
- ui->checkProxyConnectionButton->setDisabled(!enabled);
+ ui_->proxyServerAddressEdit->setDisabled(!enabled);
+ ui_->portSpin->setDisabled(!enabled);
+ ui_->proxyTypeComboBox->setDisabled(!enabled);
+ ui_->usernameEdit->setDisabled(!enabled);
+ ui_->passwordEdit->setDisabled(!enabled);
+ ui_->checkProxyConnectionButton->setDisabled(!enabled);
if (!enabled) proxy_type_ = QNetworkProxy::NoProxy;
}
void GpgFrontend::UI::NetworkTab::switch_ui_proxy_type(
const QString &type_text) {
if (type_text == "HTTP") {
- ui->proxyServerAddressEdit->setDisabled(false);
- ui->portSpin->setDisabled(false);
- ui->usernameEdit->setDisabled(false);
- ui->passwordEdit->setDisabled(false);
+ ui_->proxyServerAddressEdit->setDisabled(false);
+ ui_->portSpin->setDisabled(false);
+ ui_->usernameEdit->setDisabled(false);
+ ui_->passwordEdit->setDisabled(false);
proxy_type_ = QNetworkProxy::HttpProxy;
} else if (type_text == "Socks5") {
- ui->proxyServerAddressEdit->setDisabled(false);
- ui->portSpin->setDisabled(false);
- ui->usernameEdit->setDisabled(false);
- ui->passwordEdit->setDisabled(false);
+ ui_->proxyServerAddressEdit->setDisabled(false);
+ ui_->portSpin->setDisabled(false);
+ ui_->usernameEdit->setDisabled(false);
+ ui_->passwordEdit->setDisabled(false);
proxy_type_ = QNetworkProxy::Socks5Proxy;
} else {
- ui->proxyServerAddressEdit->setDisabled(true);
- ui->portSpin->setDisabled(true);
- ui->usernameEdit->setDisabled(true);
- ui->passwordEdit->setDisabled(true);
+ ui_->proxyServerAddressEdit->setDisabled(true);
+ ui_->portSpin->setDisabled(true);
+ ui_->usernameEdit->setDisabled(true);
+ ui_->passwordEdit->setDisabled(true);
proxy_type_ = QNetworkProxy::DefaultProxy;
}
}
diff --git a/src/ui/settings/SettingsNetwork.h b/src/ui/settings/SettingsNetwork.h
index cf136604..d4c0d00d 100644
--- a/src/ui/settings/SettingsNetwork.h
+++ b/src/ui/settings/SettingsNetwork.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -34,22 +38,55 @@ class NetworkTab : public QWidget {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Network Tab object
+ *
+ * @param parent
+ */
explicit NetworkTab(QWidget* parent = nullptr);
- void setSettings();
+ /**
+ * @brief Set the Settings object
+ *
+ */
+ void SetSettings();
- void applySettings();
+ /**
+ * @brief
+ *
+ */
+ void ApplySettings();
private slots:
- void slotTestProxyConnectionResult();
+ /**
+ * @brief
+ *
+ */
+ void slot_test_proxy_connection_result();
private:
- std::shared_ptr<Ui_NetworkSettings> ui;
- QNetworkProxy::ProxyType proxy_type_ = QNetworkProxy::HttpProxy;
+ std::shared_ptr<Ui_NetworkSettings> ui_; ///<
+ QNetworkProxy::ProxyType proxy_type_ = QNetworkProxy::HttpProxy; ///<
+ /**
+ * @brief
+ *
+ */
void apply_proxy_settings();
+
+ /**
+ * @brief
+ *
+ * @param enabled
+ */
void switch_ui_enabled(bool enabled);
+
+ /**
+ * @brief
+ *
+ * @param type_text
+ */
void switch_ui_proxy_type(const QString& type_text);
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/settings/SettingsSendMail.cpp b/src/ui/settings/SettingsSendMail.cpp
index 728cfc66..bb948d9a 100644
--- a/src/ui/settings/SettingsSendMail.cpp
+++ b/src/ui/settings/SettingsSendMail.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,49 +8,51 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include "SettingsSendMail.h"
-#include "ui/data_struct/SettingsObject.h"
+#include "ui/struct/SettingsObject.h"
+#include "ui/thread/SMTPConnectionTestThread.h"
#include "ui/thread/SMTPSendMailThread.h"
-#include "ui/thread/SMTPTestThread.h"
#include "ui_SendMailSettings.h"
namespace GpgFrontend::UI {
SendMailTab::SendMailTab(QWidget* parent)
- : QWidget(parent), ui(std::make_shared<Ui_SendMailSettings>()) {
- ui->setupUi(this);
+ : QWidget(parent), ui_(std::make_shared<Ui_SendMailSettings>()) {
+ ui_->setupUi(this);
- connect(ui->enableCheckBox, &QCheckBox::stateChanged, this,
+ connect(ui_->enableCheckBox, &QCheckBox::stateChanged, this,
[=](int state) { switch_ui_enabled(state == Qt::Checked); });
#ifdef SMTP_SUPPORT
- connect(ui->checkConnectionButton, &QPushButton::clicked, this,
- &SendMailTab::slotCheckConnection);
- connect(ui->senTestMailButton, &QPushButton::clicked, this,
- &SendMailTab::slotSendTestMail);
+ connect(ui_->checkConnectionButton, &QPushButton::clicked, this,
+ &SendMailTab::slot_check_connection);
+ connect(ui_->senTestMailButton, &QPushButton::clicked, this,
+ &SendMailTab::slot_send_test_mail);
#endif
- connect(ui->identityCheckBox, &QCheckBox::stateChanged, this,
+ connect(ui_->identityCheckBox, &QCheckBox::stateChanged, this,
[=](int state) { switch_ui_identity_enabled(state == Qt::Checked); });
- connect(ui->connextionSecurityComboBox, &QComboBox::currentTextChanged, this,
+ connect(ui_->connextionSecurityComboBox, &QComboBox::currentTextChanged, this,
[=](const QString& current_text) {
if (current_text == "SSL") {
connection_type_ = SmtpClient::ConnectionType::SslConnection;
@@ -59,104 +63,104 @@ SendMailTab::SendMailTab(QWidget* parent)
}
});
- ui->generalGroupBox->setTitle(_("General"));
- ui->identityGroupBox->setTitle(_("Identity Information"));
- ui->preferenceGroupBox->setTitle(_("Preference"));
- ui->operationsGroupBox->setTitle(_("Operations"));
+ ui_->generalGroupBox->setTitle(_("General"));
+ ui_->identityGroupBox->setTitle(_("Identity Information"));
+ ui_->preferenceGroupBox->setTitle(_("Preference"));
+ ui_->operationsGroupBox->setTitle(_("Operations"));
- ui->enableCheckBox->setText(_("Enable Send Mail Ability"));
- ui->identityCheckBox->setText(_("Need Auth"));
+ ui_->enableCheckBox->setText(_("Enable Send Mail Ability"));
+ ui_->identityCheckBox->setText(_("Need Auth"));
- ui->smtpServerAddressLabel->setText(_("SMTP Server Address"));
- ui->smtpServerPortLabel->setText(_("SMTP Server Port"));
- ui->connectionSecurityLabel->setText(_("SMTP Connection Security"));
- ui->usernameLabel->setText(_("Username"));
- ui->passwordLabel->setText(_("Password"));
+ ui_->smtpServerAddressLabel->setText(_("SMTP Server Address"));
+ ui_->smtpServerPortLabel->setText(_("SMTP Server Port"));
+ ui_->connectionSecurityLabel->setText(_("SMTP Connection Security"));
+ ui_->usernameLabel->setText(_("Username"));
+ ui_->passwordLabel->setText(_("Password"));
- ui->senderLabel->setText(_("Default Sender Email"));
- ui->checkConnectionButton->setText(_("Check Connection"));
- ui->senTestMailButton->setText(_("Send Test Email"));
- ui->gpgkeyIdLabel->setText(_("Default Sender GPG Key ID"));
+ ui_->senderLabel->setText(_("Default Sender Email"));
+ ui_->checkConnectionButton->setText(_("Check Connection"));
+ ui_->senTestMailButton->setText(_("Send Test Email"));
+ ui_->gpgkeyIdLabel->setText(_("Default Sender GPG Key ID"));
- ui->tipsLabel->setText(
+ ui_->tipsLabel->setText(
_("Tips: It is recommended that you build your own mail server or use "
"a trusted mail server. If you don't know the detailed configuration "
"information, you can get it from the mail service provider."));
- ui->senTestMailButton->setDisabled(true);
+ ui_->senTestMailButton->setDisabled(true);
auto* email_validator =
- new QRegularExpressionValidator(re_email, ui->defaultSenderEmailEdit);
- ui->defaultSenderEmailEdit->setValidator(email_validator);
+ new QRegularExpressionValidator(re_email_, ui_->defaultSenderEmailEdit);
+ ui_->defaultSenderEmailEdit->setValidator(email_validator);
- setSettings();
+ SetSettings();
}
-void SendMailTab::setSettings() {
+void SendMailTab::SetSettings() {
auto smtp_passport = SettingsObject("smtp_passport");
- ui->smtpServerAddressEdit->setText(
- std::string{smtp_passport.Check("smtp_address", {})}.c_str());
+ ui_->smtpServerAddressEdit->setText(
+ std::string{smtp_passport.Check("smtp_address", "")}.c_str());
- ui->usernameEdit->setText(
- std::string{smtp_passport.Check("username", {})}.c_str());
+ ui_->usernameEdit->setText(
+ std::string{smtp_passport.Check("username", "")}.c_str());
- ui->passwordEdit->setText(
- std::string{smtp_passport.Check("password", {})}.c_str());
+ ui_->passwordEdit->setText(
+ std::string{smtp_passport.Check("password", "")}.c_str());
- ui->portSpin->setValue(int{smtp_passport.Check("port", 25)});
+ ui_->portSpin->setValue(int{smtp_passport.Check("port", 25)});
- ui->connextionSecurityComboBox->setCurrentText(
+ ui_->connextionSecurityComboBox->setCurrentText(
std::string{smtp_passport.Check("connection_type", "None")}.c_str());
- ui->defaultSenderEmailEdit->setText(
- std::string{smtp_passport.Check("default_sender", {})}.c_str());
+ ui_->defaultSenderEmailEdit->setText(
+ std::string{smtp_passport.Check("default_sender", "")}.c_str());
- ui->gpgKeyIDEdit->setText(
- std::string{smtp_passport.Check("default_sender_gpg_key_id", {})}
+ ui_->gpgKeyIDEdit->setText(
+ std::string{smtp_passport.Check("default_sender_gpg_key_id", "")}
.c_str());
- ui->identityCheckBox->setChecked(
+ ui_->identityCheckBox->setChecked(
bool{smtp_passport.Check("identity_enable", false)});
- ui->enableCheckBox->setChecked(bool{smtp_passport.Check("enable", false)});
+ ui_->enableCheckBox->setChecked(bool{smtp_passport.Check("enable", false)});
{
- auto state = ui->identityCheckBox->checkState();
+ auto state = ui_->identityCheckBox->checkState();
switch_ui_identity_enabled(state == Qt::Checked);
}
{
- auto state = ui->enableCheckBox->checkState();
+ auto state = ui_->enableCheckBox->checkState();
switch_ui_enabled(state == Qt::Checked);
}
}
-void SendMailTab::applySettings() {
+void SendMailTab::ApplySettings() {
try {
auto smtp_passport = SettingsObject("smtp_passport");
smtp_passport["smtp_address"] =
- ui->smtpServerAddressEdit->text().toStdString();
+ ui_->smtpServerAddressEdit->text().toStdString();
- smtp_passport["username"] = ui->usernameEdit->text().toStdString();
+ smtp_passport["username"] = ui_->usernameEdit->text().toStdString();
- smtp_passport["password"] = ui->passwordEdit->text().toStdString();
+ smtp_passport["password"] = ui_->passwordEdit->text().toStdString();
- smtp_passport["port"] = ui->portSpin->value();
+ smtp_passport["port"] = ui_->portSpin->value();
smtp_passport["connection_type"] =
- ui->connextionSecurityComboBox->currentText().toStdString();
+ ui_->connextionSecurityComboBox->currentText().toStdString();
smtp_passport["default_sender"] =
- ui->defaultSenderEmailEdit->text().toStdString();
+ ui_->defaultSenderEmailEdit->text().toStdString();
smtp_passport["default_sender_gpg_key_id"] =
- ui->gpgKeyIDEdit->text().toStdString();
+ ui_->gpgKeyIDEdit->text().toStdString();
- smtp_passport["identity_enable"] = ui->identityCheckBox->isChecked();
+ smtp_passport["identity_enable"] = ui_->identityCheckBox->isChecked();
- smtp_passport["enable"] = ui->enableCheckBox->isChecked();
+ smtp_passport["enable"] = ui_->enableCheckBox->isChecked();
} catch (...) {
LOG(ERROR) << _("apply settings failed");
@@ -164,16 +168,16 @@ void SendMailTab::applySettings() {
}
#ifdef SMTP_SUPPORT
-void SendMailTab::slotCheckConnection() {
- auto host = ui->smtpServerAddressEdit->text().toStdString();
- auto port = ui->portSpin->value();
+void SendMailTab::slot_check_connection() {
+ auto host = ui_->smtpServerAddressEdit->text().toStdString();
+ auto port = ui_->portSpin->value();
auto connection_type = connection_type_;
- bool identity_needed = ui->identityCheckBox->isChecked();
- auto username = ui->usernameEdit->text().toStdString();
- auto password = ui->passwordEdit->text().toStdString();
+ bool identity_needed = ui_->identityCheckBox->isChecked();
+ auto username = ui_->usernameEdit->text().toStdString();
+ auto password = ui_->passwordEdit->text().toStdString();
- auto thread = new SMTPTestThread(host, port, connection_type, identity_needed,
- username, password);
+ auto thread = new SMTPConnectionTestThread(
+ host, port, connection_type, identity_needed, username, password);
// Waiting Dialog
auto* waiting_dialog = new QProgressDialog(this);
@@ -186,8 +190,8 @@ void SendMailTab::slotCheckConnection() {
waiting_dialog_label->setWordWrap(true);
waiting_dialog->setLabel(waiting_dialog_label);
waiting_dialog->resize(420, 120);
- connect(thread, &SMTPTestThread::signalSMTPTestResult, this,
- &SendMailTab::slotTestSMTPConnectionResult);
+ connect(thread, &SMTPConnectionTestThread::SignalSMTPConnectionTestResult,
+ this, &SendMailTab::slot_test_smtp_connection_result);
connect(thread, &QThread::finished, [=]() {
waiting_dialog->finished(0);
waiting_dialog->deleteLater();
@@ -209,14 +213,14 @@ void SendMailTab::slotCheckConnection() {
#endif
#ifdef SMTP_SUPPORT
-void SendMailTab::slotSendTestMail() {
- auto host = ui->smtpServerAddressEdit->text().toStdString();
- auto port = ui->portSpin->value();
+void SendMailTab::slot_send_test_mail() {
+ auto host = ui_->smtpServerAddressEdit->text().toStdString();
+ auto port = ui_->portSpin->value();
auto connection_type = connection_type_;
- bool identity_needed = ui->identityCheckBox->isChecked();
- auto username = ui->usernameEdit->text().toStdString();
- auto password = ui->passwordEdit->text().toStdString();
- auto sender_address = ui->defaultSenderEmailEdit->text();
+ bool identity_needed = ui_->identityCheckBox->isChecked();
+ auto username = ui_->usernameEdit->text().toStdString();
+ auto password = ui_->passwordEdit->text().toStdString();
+ auto sender_address = ui_->defaultSenderEmailEdit->text();
auto thread = new SMTPSendMailThread(host, port, connection_type,
identity_needed, username, password);
@@ -232,8 +236,8 @@ void SendMailTab::slotSendTestMail() {
waiting_dialog_label->setWordWrap(true);
waiting_dialog->setLabel(waiting_dialog_label);
waiting_dialog->resize(420, 120);
- connect(thread, &SMTPSendMailThread::signalSMTPResult, this,
- &SendMailTab::slotTestSMTPConnectionResult);
+ connect(thread, &SMTPSendMailThread::SignalSMTPResult, this,
+ &SendMailTab::slot_test_smtp_connection_result);
connect(thread, &QThread::finished, [=]() {
waiting_dialog->finished(0);
waiting_dialog->deleteLater();
@@ -243,10 +247,10 @@ void SendMailTab::slotSendTestMail() {
if (thread->isRunning()) thread->terminate();
});
- thread->setSender(sender_address);
- thread->setRecipient(sender_address);
- thread->setSubject(_("Test Email from GpgFrontend"));
- thread->addTextContent(
+ thread->SetSender(sender_address);
+ thread->SetRecipient(sender_address);
+ thread->SetSubject(_("Test Email from GpgFrontend"));
+ thread->AddTextContent(
_("Hello, this is a test email from GpgFrontend. If you receive this "
"email, it means that you have configured the correct SMTP server "
"parameters."));
@@ -261,48 +265,48 @@ void SendMailTab::slotSendTestMail() {
loop.exec();
}
-void SendMailTab::slotTestSMTPConnectionResult(const QString& result) {
+void SendMailTab::slot_test_smtp_connection_result(const QString& result) {
if (result == "Fail to connect SMTP server") {
QMessageBox::critical(this, _("Fail"), _("Fail to Connect SMTP Server."));
- ui->senTestMailButton->setDisabled(true);
+ ui_->senTestMailButton->setDisabled(true);
} else if (result == "Fail to login") {
QMessageBox::critical(this, _("Fail"), _("Fail to Login."));
- ui->senTestMailButton->setDisabled(true);
+ ui_->senTestMailButton->setDisabled(true);
} else if (result == "Fail to send mail") {
QMessageBox::critical(this, _("Fail"), _("Fail to Login."));
- ui->senTestMailButton->setDisabled(true);
+ ui_->senTestMailButton->setDisabled(true);
} else if (result == "Succeed in testing connection") {
QMessageBox::information(this, _("Success"),
_("Succeed in connecting and login"));
- ui->senTestMailButton->setDisabled(false);
+ ui_->senTestMailButton->setDisabled(false);
} else if (result == "Succeed in sending a test email") {
QMessageBox::information(
this, _("Success"),
_("Succeed in sending a test email to the SMTP Server"));
- ui->senTestMailButton->setDisabled(false);
+ ui_->senTestMailButton->setDisabled(false);
} else {
QMessageBox::critical(this, _("Fail"), _("Unknown error."));
- ui->senTestMailButton->setDisabled(true);
+ ui_->senTestMailButton->setDisabled(true);
}
}
void SendMailTab::switch_ui_enabled(bool enabled) {
- ui->smtpServerAddressEdit->setDisabled(!enabled);
- ui->portSpin->setDisabled(!enabled);
- ui->connextionSecurityComboBox->setDisabled(!enabled);
+ ui_->smtpServerAddressEdit->setDisabled(!enabled);
+ ui_->portSpin->setDisabled(!enabled);
+ ui_->connextionSecurityComboBox->setDisabled(!enabled);
- ui->identityCheckBox->setDisabled(!enabled);
- ui->usernameEdit->setDisabled(!enabled);
- ui->passwordEdit->setDisabled(!enabled);
+ ui_->identityCheckBox->setDisabled(!enabled);
+ ui_->usernameEdit->setDisabled(!enabled);
+ ui_->passwordEdit->setDisabled(!enabled);
- ui->defaultSenderEmailEdit->setDisabled(!enabled);
- ui->gpgKeyIDEdit->setDisabled(!enabled);
- ui->checkConnectionButton->setDisabled(!enabled);
+ ui_->defaultSenderEmailEdit->setDisabled(!enabled);
+ ui_->gpgKeyIDEdit->setDisabled(!enabled);
+ ui_->checkConnectionButton->setDisabled(!enabled);
}
void SendMailTab::switch_ui_identity_enabled(bool enabled) {
- ui->usernameEdit->setDisabled(!enabled);
- ui->passwordEdit->setDisabled(!enabled);
+ ui_->usernameEdit->setDisabled(!enabled);
+ ui_->passwordEdit->setDisabled(!enabled);
}
#endif
diff --git a/src/ui/settings/SettingsSendMail.h b/src/ui/settings/SettingsSendMail.h
index 75b03c77..84259844 100644
--- a/src/ui/settings/SettingsSendMail.h
+++ b/src/ui/settings/SettingsSendMail.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -30,40 +34,85 @@
class Ui_SendMailSettings;
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class SendMailTab : public QWidget {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Send Mail Tab object
+ *
+ * @param parent
+ */
explicit SendMailTab(QWidget* parent = nullptr);
- void setSettings();
+ /**
+ * @brief Set the Settings object
+ *
+ */
+ void SetSettings();
+
+ /**
+ * @brief
+ *
+ */
+ void ApplySettings();
- void applySettings();
+ signals:
+
+ /**
+ * @brief
+ *
+ * @param needed
+ */
+ void SignalRestartNeeded(bool needed);
private slots:
- void slotTestSMTPConnectionResult(const QString& result);
+ /**
+ * @brief
+ *
+ * @param result
+ */
+ void slot_test_smtp_connection_result(const QString& result);
#ifdef SMTP_SUPPORT
- void slotCheckConnection();
-
- void slotSendTestMail();
+ /**
+ * @brief
+ *
+ */
+ void slot_check_connection();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_send_test_mail();
#endif
private:
- std::shared_ptr<Ui_SendMailSettings> ui;
- QRegularExpression re_email{
+ std::shared_ptr<Ui_SendMailSettings> ui_; ///<
+ QRegularExpression re_email_{
R"((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))"};
SmtpClient::ConnectionType connection_type_ =
- SmtpClient::ConnectionType::TcpConnection;
+ SmtpClient::ConnectionType::TcpConnection; ///<
+ /**
+ * @brief
+ *
+ * @param enabled
+ */
void switch_ui_enabled(bool enabled);
+ /**
+ * @brief
+ *
+ * @param enabled
+ */
void switch_ui_identity_enabled(bool enabled);
-
- signals:
-
- void signalRestartNeeded(bool needed);
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/smtp/SendMailDialog.h b/src/ui/smtp/SendMailDialog.h
deleted file mode 100644
index 04224f18..00000000
--- a/src/ui/smtp/SendMailDialog.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#ifndef GPGFRONTEND_SENDMAILDIALOG_H
-#define GPGFRONTEND_SENDMAILDIALOG_H
-
-#include "ui/GpgFrontendUI.h"
-
-class Ui_SendMailDialog;
-
-namespace GpgFrontend::UI {
-
-class SendMailDialog : public QDialog {
- Q_OBJECT
- public:
- explicit SendMailDialog(const QString& text, QWidget* parent = nullptr);
-
- void setContentEncryption(bool on);
-
- void setAttachSignature(bool on);
-
- private slots:
-
- void slotConfirm();
-
- void slotTestSMTPConnectionResult(const QString& result);
-
- private:
- void initSettings();
-
- std::shared_ptr<Ui_SendMailDialog> ui;
-
- bool ability_enable_ = false;
- bool identity_enable_ = false;
- QString smtp_address_;
- QString username_;
- QString password_;
- QString default_sender_;
- QString connection_type_settings_ = "None";
- QString default_sender_gpg_key_id = {};
- int port_ = 25;
-
- GpgFrontend::KeyId sender_key_id_;
- GpgFrontend::KeyIdArgsListPtr recipients_key_ids_ =
- std::make_unique<GpgFrontend::KeyIdArgsList>();
-
- QRegularExpression re_email{
- R"((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))"};
-
- bool check_email_address(const QString& str);
-
- void set_sender_value_label();
-
- void set_recipients_value_label();
-};
-
-} // namespace GpgFrontend::UI
-
-#endif // GPGFRONTEND_SENDMAILDIALOG_H
diff --git a/src/ui/struct/SettingsObject.cpp b/src/ui/struct/SettingsObject.cpp
new file mode 100644
index 00000000..4a9aa7d6
--- /dev/null
+++ b/src/ui/struct/SettingsObject.cpp
@@ -0,0 +1,104 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#include "SettingsObject.h"
+
+nlohmann::json& GpgFrontend::UI::SettingsObject::Check(
+ const std::string& key, const nlohmann::json& default_value) {
+ // check if the self null
+ if (this->nlohmann::json::is_null()) {
+ LOG(INFO) << "SettingsObject is null, creating new one";
+ this->nlohmann::json::operator=(nlohmann::json::object());
+ }
+
+ try {
+ if (!this->nlohmann::json::contains(key) ||
+ this->nlohmann::json::at(key).is_null() ||
+ this->nlohmann::json::at(key).type_name() !=
+ default_value.type_name()) {
+ LOG(INFO) << "Added missing key: " << key;
+ if (default_value.is_null()) {
+ LOG(WARNING) << "Default value is null, using empty object";
+ this->nlohmann::json::operator[](key) = nlohmann::json::object();
+ } else {
+ this->nlohmann::json::operator[](key) = default_value;
+ }
+ }
+ return this->nlohmann::json::at(key);
+ } catch (nlohmann::json::exception& e) {
+ LOG(ERROR) << e.what();
+ throw e;
+ }
+}
+
+GpgFrontend::UI::SettingsObject GpgFrontend::UI::SettingsObject::Check(
+ const std::string& key) {
+ // check if the self null
+ if (this->nlohmann::json::is_null()) {
+ LOG(INFO) << "SettingsObject is null, creating new one";
+ this->nlohmann::json::operator=(nlohmann::json::object());
+ }
+
+ if (!nlohmann::json::contains(key) ||
+ this->nlohmann::json::at(key).is_null() ||
+ this->nlohmann::json::at(key).type() != nlohmann::json::value_t::object) {
+ LOG(INFO) << "Added missing key: " << key;
+ this->nlohmann::json::operator[](key) = nlohmann::json::object();
+ }
+ return SettingsObject{nlohmann::json::operator[](key), false};
+}
+
+GpgFrontend::UI::SettingsObject::SettingsObject(std::string settings_name)
+ : settings_name_(std::move(settings_name)) {
+ try {
+ LOG(INFO) << "Loading settings from: " << this->settings_name_;
+ auto _json_optional =
+ GpgFrontend::DataObjectOperator::GetInstance().GetDataObject(
+ settings_name_);
+
+ if (_json_optional.has_value()) {
+ LOG(INFO) << "SettingsObject: " << settings_name_ << " loaded.";
+ nlohmann::json::operator=(_json_optional.value());
+ } else {
+ LOG(INFO) << "SettingsObject: " << settings_name_ << " not found.";
+ nlohmann::json::operator=({});
+ }
+
+ } catch (std::exception& e) {
+ LOG(ERROR) << e.what();
+ }
+}
+
+GpgFrontend::UI::SettingsObject::SettingsObject(nlohmann::json _sub_json, bool)
+ : nlohmann::json(std::move(_sub_json)), settings_name_({}) {}
+
+GpgFrontend::UI::SettingsObject::~SettingsObject() {
+ if (!settings_name_.empty())
+ GpgFrontend::DataObjectOperator::GetInstance().SaveDataObj(settings_name_,
+ *this);
+}
diff --git a/src/ui/data_struct/SettingsObject.h b/src/ui/struct/SettingsObject.h
index 3d26ae4b..653a543f 100644
--- a/src/ui/data_struct/SettingsObject.h
+++ b/src/ui/struct/SettingsObject.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -27,12 +31,13 @@
#include <utility>
-#include "ui/settings/GlobalSettingStation.h"
+#include "core/function/DataObjectOperator.h"
namespace GpgFrontend::UI {
/**
- * @brief
+ * @brief The SettingsObject class
+ * This class is used to store settings for the application securely.
*
*/
class SettingsObject : public nlohmann::json {
@@ -40,7 +45,7 @@ class SettingsObject : public nlohmann::json {
/**
* @brief Construct a new Settings Object object
*
- * @param settings_name
+ * @param settings_name The name of the settings object
*/
explicit SettingsObject(std::string settings_name);
@@ -64,7 +69,7 @@ class SettingsObject : public nlohmann::json {
* @param default_value
* @return nlohmann::json&
*/
- nlohmann::json& Check(const std::string& key, nlohmann::json default_value);
+ nlohmann::json& Check(const std::string& key, const nlohmann::json& default_value);
/**
* @brief
diff --git a/src/ui/data_struct/SoftwareVersion.cpp b/src/ui/struct/SoftwareVersion.cpp
index 2e814cb9..ecccf7c0 100644
--- a/src/ui/data_struct/SoftwareVersion.cpp
+++ b/src/ui/struct/SoftwareVersion.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/src/ui/data_struct/SoftwareVersion.h b/src/ui/struct/SoftwareVersion.h
index 433eb99a..04300053 100644
--- a/src/ui/data_struct/SoftwareVersion.h
+++ b/src/ui/struct/SoftwareVersion.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/src/ui/thread/CtxCheckThread.cpp b/src/ui/thread/CtxCheckThread.cpp
index b51954e1..b1e50b94 100644
--- a/src/ui/thread/CtxCheckThread.cpp
+++ b/src/ui/thread/CtxCheckThread.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -24,14 +26,14 @@
#include "CtxCheckThread.h"
-#include "gpg/GpgContext.h"
-#include "gpg/GpgCoreInit.h"
-#include "gpg/function/GpgKeyGetter.h"
+#include "core/GpgContext.h"
+#include "core/GpgCoreInit.h"
+#include "core/function/gpg/GpgKeyGetter.h"
#include "ui/UserInterfaceUtils.h"
GpgFrontend::UI::CtxCheckThread::CtxCheckThread() : QThread(nullptr) {
- connect(this, &CtxCheckThread::signalGnupgNotInstall,
- CommonUtils::GetInstance(), &CommonUtils::signalGnupgNotInstall);
+ connect(this, &CtxCheckThread::SignalGnupgNotInstall,
+ CommonUtils::GetInstance(), &CommonUtils::SignalGnupgNotInstall);
}
void GpgFrontend::UI::CtxCheckThread::run() {
@@ -40,7 +42,7 @@ void GpgFrontend::UI::CtxCheckThread::run() {
// Create & Check Gnupg Context Status
if (!GpgContext::GetInstance().good()) {
- emit signalGnupgNotInstall();
+ emit SignalGnupgNotInstall();
}
// Try fetching key
else
diff --git a/src/ui/thread/CtxCheckThread.h b/src/ui/thread/CtxCheckThread.h
index 74bdb491..36281525 100644
--- a/src/ui/thread/CtxCheckThread.h
+++ b/src/ui/thread/CtxCheckThread.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -26,15 +28,31 @@
#define GPGFRONTEND_CTXCHECKTRHEAD_H
#include "ui/GpgFrontendUI.h"
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class CtxCheckThread : public QThread {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Ctx Check Thread object
+ *
+ */
CtxCheckThread();
signals:
- void signalGnupgNotInstall();
+ /**
+ * @brief
+ *
+ */
+ void SignalGnupgNotInstall();
protected:
+ /**
+ * @brief
+ *
+ */
void run() override;
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/thread/FileReadThread.cpp b/src/ui/thread/FileReadThread.cpp
index 04f713bd..b0eae355 100644
--- a/src/ui/thread/FileReadThread.cpp
+++ b/src/ui/thread/FileReadThread.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -24,18 +26,18 @@
#include "FileReadThread.h"
-#include <boost/filesystem.hpp>
+
#include <utility>
namespace GpgFrontend::UI {
-FileReadThread::FileReadThread(std::string path) : path(std::move(path)) {
+FileReadThread::FileReadThread(std::string path) : path_(std::move(path)) {
qRegisterMetaType<std::string>("std::string");
}
void FileReadThread::run() {
LOG(INFO) << "started";
- boost::filesystem::path read_file_path(this->path);
+ std::filesystem::path read_file_path(this->path_);
if (is_regular_file(read_file_path)) {
LOG(INFO) << "read open";
@@ -54,7 +56,7 @@ void FileReadThread::run() {
LOG(INFO) << "block size " << read_size;
std::string buffer_str(buffer, read_size);
- emit sendReadBlock(buffer_str);
+ emit SignalSendReadBlock(buffer_str);
#ifdef RELEASE
QThread::msleep(32);
#else
@@ -62,7 +64,7 @@ void FileReadThread::run() {
#endif
}
fclose(fp);
- emit readDone();
+ emit SignalReadDone();
LOG(INFO) << "thread end reading";
}
}
diff --git a/src/ui/thread/FileReadThread.h b/src/ui/thread/FileReadThread.h
index 65982848..e7573af8 100644
--- a/src/ui/thread/FileReadThread.h
+++ b/src/ui/thread/FileReadThread.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -29,23 +31,45 @@
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class FileReadThread : public QThread {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new File Read Thread object
+ *
+ * @param path
+ */
explicit FileReadThread(std::string path);
signals:
- void sendReadBlock(const std::string& block);
+ /**
+ * @brief
+ *
+ * @param block
+ */
+ void SignalSendReadBlock(const std::string& block);
- void readDone();
+ /**
+ * @brief
+ *
+ */
+ void SignalReadDone();
protected:
+ /**
+ * @brief
+ *
+ */
void run() override;
private:
- std::string path;
+ std::string path_; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/thread/TestListedKeyServerThread.cpp b/src/ui/thread/ListedKeyServerTestThread.cpp
index 4f816860..8c86f0be 100644
--- a/src/ui/thread/TestListedKeyServerThread.cpp
+++ b/src/ui/thread/ListedKeyServerTestThread.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,25 +8,25 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
*
*/
-#include "TestListedKeyServerThread.h"
+#include "ListedKeyServerTestThread.h"
-void GpgFrontend::UI::TestListedKeyServerThread::run() {
+void GpgFrontend::UI::ListedKeyServerTestThread::run() {
for (const auto& url : urls_) {
const auto keyserver_url = url;
@@ -43,5 +45,5 @@ void GpgFrontend::UI::TestListedKeyServerThread::run() {
socket.close();
}
- emit signalKeyServerListTestResult(result_);
+ emit SignalKeyServerListTestResult(result_);
}
diff --git a/src/ui/thread/TestListedKeyServerThread.h b/src/ui/thread/ListedKeyServerTestThread.h
index 99fd6c6d..dd7c2fa8 100644
--- a/src/ui/thread/TestListedKeyServerThread.h
+++ b/src/ui/thread/ListedKeyServerTestThread.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,50 +8,63 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
*
*/
-#ifndef GPGFRONTEND_TESTLISTEDKEYSERVERTHREAD_H
-#define GPGFRONTEND_TESTLISTEDKEYSERVERTHREAD_H
+#ifndef GPGFRONTEND_LISTEDKEYSERVERTESTTHREAD_H
+#define GPGFRONTEND_LISTEDKEYSERVERTESTTHREAD_H
#include "GpgFrontendUI.h"
namespace GpgFrontend::UI {
-class TestListedKeyServerThread : public QThread {
+/**
+ * @brief
+ *
+ */
+class ListedKeyServerTestThread : public QThread {
Q_OBJECT
public:
- explicit TestListedKeyServerThread(const QStringList& urls, int timeout,
+ explicit ListedKeyServerTestThread(const QStringList& urls, int timeout,
QWidget* parent = nullptr)
: QThread(parent), urls_(urls), timeout_(timeout) {}
signals:
- void signalKeyServerListTestResult(const QStringList& result);
+ /**
+ * @brief
+ *
+ * @param result
+ */
+ void SignalKeyServerListTestResult(const QStringList& result);
protected:
+ /**
+ * @brief
+ *
+ */
void run() override;
private:
- QStringList urls_;
- QStringList result_;
- int timeout_ = 500;
+ QStringList urls_; ///<
+ QStringList result_; ///<
+ int timeout_ = 500; ///<
};
} // namespace GpgFrontend::UI
class TestListedKeyServerThread {};
-#endif // GPGFRONTEND_TESTLISTEDKEYSERVERTHREAD_H
+#endif // GPGFRONTEND_LISTEDKEYSERVERTESTTHREAD_H
diff --git a/src/ui/thread/ProxyConnectionTestThread.cpp b/src/ui/thread/ProxyConnectionTestThread.cpp
index 76cf525e..062f4774 100644
--- a/src/ui/thread/ProxyConnectionTestThread.cpp
+++ b/src/ui/thread/ProxyConnectionTestThread.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -52,5 +54,5 @@ void GpgFrontend::UI::ProxyConnectionTestThread::run() {
_reply->deleteLater();
- emit signalProxyConnectionTestResult(result_);
+ emit SignalProxyConnectionTestResult(result_);
}
diff --git a/src/ui/thread/ProxyConnectionTestThread.h b/src/ui/thread/ProxyConnectionTestThread.h
index 4ef75050..70757e03 100644
--- a/src/ui/thread/ProxyConnectionTestThread.h
+++ b/src/ui/thread/ProxyConnectionTestThread.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -33,23 +35,43 @@ class ProxyConnectionTestThread {};
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class ProxyConnectionTestThread : public QThread {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Proxy Connection Test Thread object
+ *
+ * @param url
+ * @param timeout
+ * @param parent
+ */
explicit ProxyConnectionTestThread(QString url, int timeout,
QWidget* parent = nullptr)
: QThread(parent), url_(std::move(url)), timeout_(timeout) {}
signals:
- void signalProxyConnectionTestResult(const QString& result);
+ /**
+ * @brief
+ *
+ * @param result
+ */
+ void SignalProxyConnectionTestResult(const QString& result);
protected:
+ /**
+ * @brief
+ *
+ */
void run() override;
private:
- QString url_;
- QString result_;
- int timeout_ = 500;
+ QString url_; ///<
+ QString result_; ///<
+ int timeout_ = 500; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/thread/SMTPTestThread.cpp b/src/ui/thread/SMTPConnectionTestThread.cpp
index 0eb267f2..95cc8f72 100644
--- a/src/ui/thread/SMTPTestThread.cpp
+++ b/src/ui/thread/SMTPConnectionTestThread.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,41 +8,41 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
*
*/
-#include "SMTPTestThread.h"
+#include "SMTPConnectionTestThread.h"
namespace GpgFrontend::UI {
-void SMTPTestThread::run() {
+void SMTPConnectionTestThread::run() {
SmtpClient smtp(host_.c_str(), port_, connection_type_);
if (identify_) {
smtp.setUser(username_.c_str());
smtp.setPassword(password_.c_str());
}
if (!smtp.connectToHost()) {
- emit signalSMTPTestResult("Fail to connect SMTP server");
+ emit SignalSMTPConnectionTestResult("Fail to connect SMTP server");
return;
}
if (!smtp.login()) {
- emit signalSMTPTestResult("Fail to login");
+ emit SignalSMTPConnectionTestResult("Fail to login");
return;
}
smtp.quit();
- emit signalSMTPTestResult("Succeed in testing connection");
+ emit SignalSMTPConnectionTestResult("Succeed in testing connection");
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/thread/SMTPConnectionTestThread.h b/src/ui/thread/SMTPConnectionTestThread.h
new file mode 100644
index 00000000..b37cc09c
--- /dev/null
+++ b/src/ui/thread/SMTPConnectionTestThread.h
@@ -0,0 +1,93 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#ifndef GPGFRONTEND_SMTPCONNECTIONTESTTHREAD_H
+#define GPGFRONTEND_SMTPCONNECTIONTESTTHREAD_H
+
+#include <utility>
+
+#include "ui/GpgFrontendUI.h"
+
+namespace GpgFrontend::UI {
+
+/**
+ * @brief
+ *
+ */
+class SMTPConnectionTestThread : public QThread {
+ Q_OBJECT
+ public:
+ /**
+ * @brief Construct a new SMTPConnectionTestThread object
+ *
+ * @param host
+ * @param port
+ * @param connection_type
+ * @param identify
+ * @param username
+ * @param password
+ * @param parent
+ */
+ explicit SMTPConnectionTestThread(std::string host, int port,
+ SmtpClient::ConnectionType connection_type,
+ bool identify, std::string username,
+ std::string password,
+ QWidget* parent = nullptr)
+ : QThread(parent),
+ host_(std::move(host)),
+ port_(port),
+ connection_type_(connection_type),
+ identify_(identify),
+ username_(std::move(username)),
+ password_(std::move(password)) {}
+
+ signals:
+ /**
+ * @brief
+ *
+ * @param result
+ */
+ void SignalSMTPConnectionTestResult(const QString& result);
+
+ protected:
+ /**
+ * @brief
+ *
+ */
+ void run() override;
+
+ private:
+ std::string host_; ///<
+ int port_; ///<
+ SmtpClient::ConnectionType connection_type_; ///<
+ bool identify_; ///<
+ std::string username_; ///<
+ std::string password_; ///<
+};
+
+} // namespace GpgFrontend::UI
+
+#endif // GPGFRONTEND_SMTPCONNECTIONTESTTHREAD_H
diff --git a/src/ui/thread/SMTPSendMailThread.cpp b/src/ui/thread/SMTPSendMailThread.cpp
index edfd3156..f1cb1626 100644
--- a/src/ui/thread/SMTPSendMailThread.cpp
+++ b/src/ui/thread/SMTPSendMailThread.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -26,9 +28,9 @@
#include <boost/format.hpp>
-#include "gpg/function/BasicOperator.h"
-#include "gpg/function/GpgKeyGetter.h"
-#include "gpg/function/GpgKeyImportExporter.h"
+#include "core/function/gpg/GpgBasicOperator.h"
+#include "core/function/gpg/GpgKeyGetter.h"
+#include "core/function/gpg/GpgKeyImportExporter.h"
namespace GpgFrontend::UI {
@@ -64,11 +66,11 @@ void SMTPSendMailThread::run() {
GpgEncrResult result;
auto in_buffer = std::make_unique<ByteArray>(plain_text);
auto keys = GpgKeyGetter::GetInstance().GetKeys(public_key_ids_);
- auto err = BasicOperator::GetInstance().Encrypt(
+ auto err = GpgBasicOperator::GetInstance().Encrypt(
std::move(keys), *in_buffer, out_buffer, result);
if (check_gpg_error_2_err_code(err) != GPG_ERR_NO_ERROR) {
- emit signalSMTPResult("Fail to encrypt with gpg keys");
+ emit SignalSMTPResult("Fail to encrypt with gpg keys");
return;
}
text->setText(out_buffer->c_str());
@@ -126,12 +128,12 @@ void SMTPSendMailThread::run() {
// The signature MUST be generated detached from the signed data
// so that the process does not alter the signed data in any way.
- auto err = BasicOperator::GetInstance().Sign(
+ auto err = GpgBasicOperator::GetInstance().Sign(
std::move(keys), *in_buffer, out_buffer, GPGME_SIG_MODE_DETACH,
result);
if (check_gpg_error_2_err_code(err) != GPG_ERR_NO_ERROR) {
- emit signalSMTPResult("Fail to sign with gpg keys");
+ emit SignalSMTPResult("Fail to sign with gpg keys");
return;
}
@@ -174,7 +176,7 @@ void SMTPSendMailThread::run() {
auto public_key_file_name =
boost::format("%1%_pubkey.asc") % attached_public_key_ids_;
- addFileContent(public_key_file_name.str().c_str(), out_buffer->c_str());
+ AddFileContent(public_key_file_name.str().c_str(), out_buffer->c_str());
auto& key_file = files_.back();
key_file->setEncoding(MimePart::_7Bit);
key_file->setContentType("application/pgp-keys");
@@ -190,70 +192,70 @@ void SMTPSendMailThread::run() {
// Now we can send the mail
if (!smtp.connectToHost()) {
- emit signalSMTPResult("Fail to connect SMTP server");
+ emit SignalSMTPResult("Fail to connect SMTP server");
return;
}
if (!smtp.login()) {
- emit signalSMTPResult("Fail to login");
+ emit SignalSMTPResult("Fail to login");
return;
}
if (!smtp.sendMail(message)) {
- emit signalSMTPResult("Fail to send mail");
+ emit SignalSMTPResult("Fail to send mail");
return;
}
smtp.quit();
- emit signalSMTPResult("Succeed in sending a test email");
+ emit SignalSMTPResult("Succeed in sending a test email");
}
-void SMTPSendMailThread::setBCC(const QString& bccs) {
+void SMTPSendMailThread::SetBCC(const QString& bccs) {
QStringList bcc_string_list = bccs.split(';');
for (const auto& bcc : bcc_string_list) {
if (!bcc.isEmpty()) message.addBcc(new EmailAddress(bcc.trimmed()));
}
}
-void SMTPSendMailThread::setCC(const QString& ccs) {
+void SMTPSendMailThread::SetCC(const QString& ccs) {
QStringList cc_string_list = ccs.split(';');
for (const auto& cc : cc_string_list) {
if (!cc.isEmpty()) message.addCc(new EmailAddress(cc.trimmed()));
}
}
-void SMTPSendMailThread::setRecipient(const QString& recipients) {
+void SMTPSendMailThread::SetRecipient(const QString& recipients) {
QStringList rcpt_string_list = recipients.split(';');
for (const auto& rcpt : rcpt_string_list) {
if (!rcpt.isEmpty()) message.addRecipient(new EmailAddress(rcpt.trimmed()));
}
}
-void SMTPSendMailThread::setSender(const QString& sender) {
+void SMTPSendMailThread::SetSender(const QString& sender) {
message.setSender(new EmailAddress(sender));
}
-void SMTPSendMailThread::addTextContent(const QString& content) {
+void SMTPSendMailThread::AddTextContent(const QString& content) {
auto text = std::make_unique<MimeText>(content.trimmed());
texts_.push_back(std::move(text));
}
-void SMTPSendMailThread::addFileContent(const QString& file_name,
+void SMTPSendMailThread::AddFileContent(const QString& file_name,
const QByteArray& content) {
auto file = std::make_unique<MimeFile>(content, file_name);
files_.push_back(std::move(file));
}
-void SMTPSendMailThread::setEncryptContent(
+void SMTPSendMailThread::SetEncryptContent(
bool encrypt_content, GpgFrontend::KeyIdArgsListPtr public_key_ids) {
this->encrypt_content_ = encrypt_content;
this->public_key_ids_ = std::move(public_key_ids);
}
-void SMTPSendMailThread::setAttachSignatureFile(
+void SMTPSendMailThread::SetAttachSignatureFile(
bool attach_signature_file, GpgFrontend::KeyId private_key_id) {
this->attach_signature_file_ = attach_signature_file;
this->private_key_id_ = std::move(private_key_id);
}
-void SMTPSendMailThread::setAttachPublicKey(
+void SMTPSendMailThread::SetAttachPublicKey(
bool attach_public_key_file, GpgFrontend::KeyId attached_public_key_ids) {
this->attach_public_key_file_ = attach_public_key_file;
this->attached_public_key_ids_ = std::move(attached_public_key_ids);
diff --git a/src/ui/thread/SMTPSendMailThread.h b/src/ui/thread/SMTPSendMailThread.h
index 3d723670..58420bf3 100644
--- a/src/ui/thread/SMTPSendMailThread.h
+++ b/src/ui/thread/SMTPSendMailThread.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -30,9 +32,24 @@
#include "ui/GpgFrontendUI.h"
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class SMTPSendMailThread : public QThread {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new SMTPSendMailThread object
+ *
+ * @param host
+ * @param port
+ * @param connection_type
+ * @param identify
+ * @param username
+ * @param password
+ * @param parent
+ */
explicit SMTPSendMailThread(std::string host, int port,
SmtpClient::ConnectionType connection_type,
bool identify, std::string username,
@@ -45,57 +62,117 @@ class SMTPSendMailThread : public QThread {
username_(std::move(username)),
password_(std::move(password)) {}
- void setSender(const QString& sender);
-
- void setRecipient(const QString& recipients);
-
- void setCC(const QString& ccs);
-
- void setBCC(const QString& bccs);
-
- void setSubject(const QString& subject) { message.setSubject(subject); }
-
- void addTextContent(const QString& content);
-
- void addFileContent(const QString& file_name, const QByteArray& content);
-
- void setEncryptContent(bool encrypt_content,
+ void SetSender(const QString& sender);
+
+ /**
+ * @brief Set the Recipient object
+ *
+ * @param recipients
+ */
+ void SetRecipient(const QString& recipients);
+
+ /**
+ * @brief
+ *
+ * @param ccs
+ */
+ void SetCC(const QString& ccs);
+
+ /**
+ * @brief
+ *
+ * @param bccs
+ */
+ void SetBCC(const QString& bccs);
+
+ /**
+ * @brief Set the Subject object
+ *
+ * @param subject
+ */
+ void SetSubject(const QString& subject) { message.setSubject(subject); }
+
+ /**
+ * @brief
+ *
+ * @param content
+ */
+ void AddTextContent(const QString& content);
+
+ /**
+ * @brief
+ *
+ * @param file_name
+ * @param content
+ */
+ void AddFileContent(const QString& file_name, const QByteArray& content);
+
+ /**
+ * @brief Set the Encrypt Content object
+ *
+ * @param encrypt_content
+ * @param public_key_ids
+ */
+ void SetEncryptContent(bool encrypt_content,
GpgFrontend::KeyIdArgsListPtr public_key_ids);
- void setAttachSignatureFile(bool attach_signature_file,
+ /**
+ * @brief Set the Attach Signature File object
+ *
+ * @param attach_signature_file
+ * @param private_key_id
+ */
+ void SetAttachSignatureFile(bool attach_signature_file,
GpgFrontend::KeyId private_key_id);
- void setAttachPublicKey(bool attach_public_key_file,
+ /**
+ * @brief Set the Attach Public Key object
+ *
+ * @param attach_public_key_file
+ * @param attached_public_key_ids
+ */
+ void SetAttachPublicKey(bool attach_public_key_file,
GpgFrontend::KeyId attached_public_key_ids);
signals:
- void signalSMTPResult(const QString& result);
+ /**
+ * @brief
+ *
+ * @param result
+ */
+ void SignalSMTPResult(const QString& result);
protected:
+ /**
+ * @brief
+ *
+ */
void run() override;
private:
// SMTP Options
- std::string host_;
- int port_;
- SmtpClient::ConnectionType connection_type_;
- bool identify_;
- std::string username_;
- std::string password_;
+ std::string host_; ///<
+ int port_; ///<
+ SmtpClient::ConnectionType connection_type_; ///<
+
+ bool identify_; ///<
+ std::string username_; ///<
+ std::string password_; ///<
- MimeMessage message;
- std::vector<std::unique_ptr<MimeText>> texts_;
- std::vector<std::unique_ptr<MimeText>> send_texts_;
- std::vector<std::unique_ptr<MimeFile>> files_;
+ MimeMessage message; ///<
+ std::vector<std::unique_ptr<MimeText>> texts_; ///<
+ std::vector<std::unique_ptr<MimeText>> send_texts_; ///<
+ std::vector<std::unique_ptr<MimeFile>> files_; ///<
// GPG Options
- bool encrypt_content_ = false;
- GpgFrontend::KeyIdArgsListPtr public_key_ids_;
- bool attach_signature_file_ = false;
- GpgFrontend::KeyId private_key_id_;
- bool attach_public_key_file_ = false;
- GpgFrontend::KeyId attached_public_key_ids_;
+
+ bool encrypt_content_ = false; ///<
+ GpgFrontend::KeyIdArgsListPtr public_key_ids_; ///<
+ bool attach_signature_file_ = false; ///<
+ GpgFrontend::KeyId private_key_id_; ///<
+ bool attach_public_key_file_ = false; ///<
+ GpgFrontend::KeyId attached_public_key_ids_; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/thread/SMTPTestThread.h b/src/ui/thread/SMTPTestThread.h
deleted file mode 100644
index c51ac3fd..00000000
--- a/src/ui/thread/SMTPTestThread.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
- *
- */
-
-#ifndef GPGFRONTEND_SMTPTESTTHREAD_H
-#define GPGFRONTEND_SMTPTESTTHREAD_H
-
-#include <utility>
-
-#include "ui/GpgFrontendUI.h"
-
-namespace GpgFrontend::UI {
-
-class SMTPTestThread : public QThread {
- Q_OBJECT
- public:
- explicit SMTPTestThread(std::string host, int port,
- SmtpClient::ConnectionType connection_type,
- bool identify, std::string username,
- std::string password, QWidget* parent = nullptr)
- : QThread(parent),
- host_(std::move(host)),
- port_(port),
- connection_type_(connection_type),
- identify_(identify),
- username_(std::move(username)),
- password_(std::move(password)) {}
-
- signals:
- void signalSMTPTestResult(const QString& result);
-
- protected:
- void run() override;
-
- private:
- std::string host_;
- int port_;
- SmtpClient::ConnectionType connection_type_;
-
- bool identify_;
- std::string username_;
- std::string password_;
-};
-
-} // namespace GpgFrontend::UI
-
-#endif // GPGFRONTEND_SMTPTESTTHREAD_H
diff --git a/src/ui/thread/VersionCheckThread.cpp b/src/ui/thread/VersionCheckThread.cpp
index 8b2487d8..6d73417d 100644
--- a/src/ui/thread/VersionCheckThread.cpp
+++ b/src/ui/thread/VersionCheckThread.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -115,7 +119,7 @@ void VersionCheckThread::run() {
LOG(INFO) << "error occurred";
version.load_info_done = false;
}
- emit upgradeVersion(version);
+ emit SignalUpgradeVersion(version);
}
VersionCheckThread::VersionCheckThread() : QThread(nullptr) {
diff --git a/src/ui/thread/VersionCheckThread.h b/src/ui/thread/VersionCheckThread.h
index 0db9770c..6ad35afe 100644
--- a/src/ui/thread/VersionCheckThread.h
+++ b/src/ui/thread/VersionCheckThread.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -26,25 +30,44 @@
#define GPGFRONTEND_VERSIONCHECKTHREAD_H
#include "ui/GpgFrontendUI.h"
-#include "ui/data_struct/SoftwareVersion.h"
+#include "ui/struct/SoftwareVersion.h"
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class VersionCheckThread : public QThread {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Version Check Thread object
+ *
+ */
explicit VersionCheckThread();
signals:
- void upgradeVersion(SoftwareVersion version);
+ /**
+ * @brief
+ *
+ * @param version
+ */
+ void SignalUpgradeVersion(SoftwareVersion version);
protected:
+ /**
+ * @brief
+
+ *
+ */
void run() override;
private:
- QByteArray latest_reply_bytes_, current_reply_bytes_;
+ QByteArray latest_reply_bytes_; ///<
+ QByteArray current_reply_bytes_; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/ExportKeyPackageDialog.cpp b/src/ui/widgets/ExportKeyPackageDialog.cpp
deleted file mode 100644
index 77e490f4..00000000
--- a/src/ui/widgets/ExportKeyPackageDialog.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#include "ExportKeyPackageDialog.h"
-
-#include <boost/format.hpp>
-
-#include "gpg/function/GpgKeyGetter.h"
-#include "gpg/function/GpgKeyImportExporter.h"
-#include "ui_ExportKeyPackageDialog.h"
-
-GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog(
- KeyIdArgsListPtr key_ids, QWidget* parent)
- : QDialog(parent),
- ui(std::make_shared<Ui_exportKeyPackageDialog>()),
- key_ids_(std::move(key_ids)),
- mt(rd()) {
- ui->setupUi(this);
-
- generate_key_package_name();
-
- connect(ui->gnerateNameButton, &QPushButton::clicked, this,
- [=]() { generate_key_package_name(); });
-
- connect(ui->setOutputPathButton, &QPushButton::clicked, this, [=]() {
- auto file_name = QFileDialog::getSaveFileName(
- this, _("Export Key Package"), ui->nameValueLabel->text() + ".gfepack",
- QString(_("Key Package")) + " (*.gfepack);;All Files (*)");
- ui->outputPathLabel->setText(file_name);
- });
-
- connect(ui->generatePassphraseButton, &QPushButton::clicked, this, [=]() {
- passphrase_ = generate_passphrase(256);
- auto file_name = QFileDialog::getSaveFileName(
- this, _("Export Key Package Passphrase"),
- ui->nameValueLabel->text() + ".key",
- QString(_("Key File")) + " (*.key);;All Files (*)");
- ui->passphraseValueLabel->setText(file_name);
- write_buffer_to_file(file_name.toStdString(), passphrase_);
- });
-
- connect(ui->button_box_, &QDialogButtonBox::accepted, this, [=]() {
- if (ui->outputPathLabel->text().isEmpty()) {
- QMessageBox::critical(
- this, _("Forbidden"),
- _("Please select an output path before exporting."));
- return;
- }
-
- if (ui->passphraseValueLabel->text().isEmpty()) {
- QMessageBox::critical(
- this, _("Forbidden"),
- _("Please generate a password to protect your key before exporting, "
- "it is very important. Don't forget to back up your password in a "
- "safe place."));
- return;
- }
-
- auto key_id_exported = std::make_unique<KeyIdArgsList>();
- auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids_);
- for (const auto& key : *keys) {
- if (ui->noPublicKeyCheckBox->isChecked() && !key.IsPrivateKey()) {
- continue;
- }
- key_id_exported->push_back(key.GetId());
- }
-
- ByteArrayPtr key_export_data = nullptr;
- if (!GpgKeyImportExporter::GetInstance().ExportKeys(
- key_ids_, key_export_data,
- ui->includeSecretKeyCheckBox->isChecked())) {
- QMessageBox::critical(this, _("Error"), _("Export Key(s) Failed."));
- this->close();
- return;
- }
-
- auto key = QByteArray::fromStdString(passphrase_),
- data =
- QString::fromStdString(*key_export_data).toLocal8Bit().toBase64();
-
- auto hash_key = QCryptographicHash::hash(key, QCryptographicHash::Sha256);
- QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::ECB,
- QAESEncryption::Padding::ISO);
- auto encoded = encryption.encode(data, hash_key);
-
- write_buffer_to_file(ui->outputPathLabel->text().toStdString(),
- encoded.toStdString());
-
- QMessageBox::information(
- this, _("Success"),
- QString(_(
- "The Key Package has been successfully generated and has been "
- "protected by encryption algorithms. You can safely transfer your "
- "Key Package.")) +
- "<br />" + "<b>" +
- _("But the key file cannot be leaked under any "
- "circumstances. Please delete the Key Package and key file as "
- "soon "
- "as possible after completing the transfer operation.") +
- "</b>");
- });
-
- connect(ui->button_box_, &QDialogButtonBox::rejected, this,
- [=]() { this->close(); });
-
- ui->nameLabel->setText(_("Key Package Name"));
- ui->selectOutputPathLabel->setText(_("Output Path"));
- ui->passphraseLabel->setText(_("Passphrase"));
- ui->tipsLabel->setText(
- _("Tips: You can use Key Package to safely and conveniently transfer "
- "your public and private keys between devices."));
- ui->generatePassphraseButton->setText(_("Generate and Save Passphrase"));
- ui->gnerateNameButton->setText(_("Generate Key Package Name"));
- ui->setOutputPathButton->setText(_("Select Output Path"));
-
- ui->includeSecretKeyCheckBox->setText(
- _("Include secret key (Think twice before acting)"));
- ui->noPublicKeyCheckBox->setText(
- _("Exclude keys that do not have a private key"));
-
- setAttribute(Qt::WA_DeleteOnClose);
- setWindowTitle(_("exportKeyPackageDialog"));
-}
-
-std::string GpgFrontend::UI::ExportKeyPackageDialog::generate_passphrase(
- const int len) {
- std::uniform_int_distribution<int> dist(999, 99999);
- static const char alphanum[] =
- "0123456789"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz";
- std::string tmp_str;
- tmp_str.reserve(len);
-
- for (int i = 0; i < len; ++i) {
- tmp_str += alphanum[dist(mt) % (sizeof(alphanum) - 1)];
- }
-
- return tmp_str;
-}
-
-void GpgFrontend::UI::ExportKeyPackageDialog::generate_key_package_name() {
- std::uniform_int_distribution<int> dist(999, 99999);
- auto file_string = boost::format("KeyPackage_%1%") % dist(mt);
- ui->nameValueLabel->setText(file_string.str().c_str());
- ui->outputPathLabel->clear();
- ui->passphraseValueLabel->clear();
-}
diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp
index 3e140bd4..7682448d 100644
--- a/src/ui/widgets/FilePage.cpp
+++ b/src/ui/widgets/FilePage.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,74 +8,78 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include "ui/widgets/FilePage.h"
-#include <boost/filesystem.hpp>
#include <string>
-#include "ui/MainWindow.h"
+#include "core/function/ArchiveFileOperator.h"
+#include "core/function/gpg/GpgFileOpera.h"
#include "ui/SignalStation.h"
+#include "ui/main_window/MainWindow.h"
#include "ui_FilePage.h"
namespace GpgFrontend::UI {
FilePage::FilePage(QWidget* parent)
- : QWidget(parent), ui(std::make_shared<Ui_FilePage>()) {
- ui->setupUi(this);
-
- firstParent = parent;
-
- dirModel = new QFileSystemModel();
- dirModel->setRootPath(QDir::currentPath());
- dirModel->setFilter(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
-
- ui->fileTreeView->setModel(dirModel);
- ui->fileTreeView->setColumnWidth(0, 320);
- ui->fileTreeView->sortByColumn(0, Qt::AscendingOrder);
- mPath = boost::filesystem::path(dirModel->rootPath().toStdString());
-
- createPopupMenu();
-
- connect(ui->upPathButton, &QPushButton::clicked, this,
- &FilePage::slotUpLevel);
- connect(ui->refreshButton, &QPushButton::clicked, this,
- &FilePage::slotGoPath);
- ui->optionsButton->setMenu(optionPopUpMenu);
-
- ui->pathEdit->setText(dirModel->rootPath());
-
- pathEditCompleter = new QCompleter(this);
- pathCompleteModel = new QStringListModel();
- pathEditCompleter->setModel(pathCompleteModel);
- pathEditCompleter->setCaseSensitivity(Qt::CaseInsensitive);
- pathEditCompleter->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
- ui->pathEdit->setCompleter(pathEditCompleter);
-
- connect(ui->fileTreeView, &QTreeView::clicked, this,
- &FilePage::fileTreeViewItemClicked);
- connect(ui->fileTreeView, &QTreeView::doubleClicked, this,
- &FilePage::fileTreeViewItemDoubleClicked);
- connect(ui->fileTreeView, &QTreeView::customContextMenuRequested, this,
+ : QWidget(parent), ui_(std::make_shared<Ui_FilePage>()) {
+ ui_->setupUi(this);
+
+ first_parent_ = parent;
+
+ dir_model_ = new QFileSystemModel();
+ dir_model_->setRootPath(QDir::currentPath());
+ dir_model_->setFilter(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
+
+ ui_->fileTreeView->setModel(dir_model_);
+ ui_->fileTreeView->setColumnWidth(0, 320);
+ ui_->fileTreeView->sortByColumn(0, Qt::AscendingOrder);
+ m_path_ = std::filesystem::path(dir_model_->rootPath().toStdString());
+
+ create_popup_menu();
+
+ connect(ui_->upPathButton, &QPushButton::clicked, this,
+ &FilePage::slot_up_level);
+ connect(ui_->refreshButton, &QPushButton::clicked, this,
+ &FilePage::SlotGoPath);
+ ui_->optionsButton->setMenu(option_popup_menu_);
+
+ ui_->pathEdit->setText(dir_model_->rootPath());
+
+ path_edit_completer_ = new QCompleter(this);
+ path_complete_model_ = new QStringListModel();
+ path_edit_completer_->setModel(path_complete_model_);
+ path_edit_completer_->setCaseSensitivity(Qt::CaseInsensitive);
+ path_edit_completer_->setCompletionMode(
+ QCompleter::UnfilteredPopupCompletion);
+ ui_->pathEdit->setCompleter(path_edit_completer_);
+
+ connect(ui_->fileTreeView, &QTreeView::clicked, this,
+ &FilePage::slot_file_tree_view_item_clicked);
+ connect(ui_->fileTreeView, &QTreeView::doubleClicked, this,
+ &FilePage::slot_file_tree_view_item_double_clicked);
+ connect(ui_->fileTreeView, &QTreeView::customContextMenuRequested, this,
&FilePage::onCustomContextMenu);
- connect(ui->pathEdit, &QLineEdit::textChanged, [=]() {
- auto path = ui->pathEdit->text();
+ connect(ui_->pathEdit, &QLineEdit::textChanged, [=]() {
+ auto path = ui_->pathEdit->text();
auto dir = QDir(path);
if (path.endsWith("/") && dir.isReadable()) {
auto dir_list = dir.entryInfoList(QDir::AllEntries);
@@ -84,216 +90,230 @@ FilePage::FilePage(QWidget* parent)
if (file_name == "." || file_name == "..") continue;
paths.append(file_path);
}
- pathCompleteModel->setStringList(paths);
+ path_complete_model_->setStringList(paths);
}
});
- connect(this, &FilePage::signalRefreshInfoBoard, SignalStation::GetInstance(),
- &SignalStation::signalRefreshInfoBoard);
+ connect(this, &FilePage::SignalRefreshInfoBoard, SignalStation::GetInstance(),
+ &SignalStation::SignalRefreshInfoBoard);
}
-void FilePage::fileTreeViewItemClicked(const QModelIndex& index) {
- selectedPath = boost::filesystem::path(
- dirModel->fileInfo(index).absoluteFilePath().toStdString());
- mPath = selectedPath;
- LOG(INFO) << "selected path" << selectedPath;
+void FilePage::slot_file_tree_view_item_clicked(const QModelIndex& index) {
+ selected_path_ = std::filesystem::path(
+ dir_model_->fileInfo(index).absoluteFilePath().toStdString());
+ m_path_ = selected_path_;
+ LOG(INFO) << "selected path" << selected_path_;
+
+ selected_path_ = std::filesystem::path(selected_path_);
+ MainWindow::CryptoMenu::OperationType operation_type =
+ MainWindow::CryptoMenu::None;
+
+ if (index.isValid()) {
+ QFileInfo info(QString::fromStdString(selected_path_.string()));
+
+ if ((info.isDir() || info.isFile()) &&
+ (info.suffix() != "gpg" && info.suffix() != "sig" &&
+ info.suffix() != "asc")) {
+ operation_type |= MainWindow::CryptoMenu::Encrypt;
+ }
+
+ if ((info.isDir() || info.isFile()) &&
+ (info.suffix() != "gpg" && info.suffix() != "sig" &&
+ info.suffix() != "asc")) {
+ operation_type |= MainWindow::CryptoMenu::EncryptAndSign;
+ }
+
+ if (info.isFile() && (info.suffix() == "gpg" || info.suffix() == "asc")) {
+ operation_type |= MainWindow::CryptoMenu::Decrypt;
+ operation_type |= MainWindow::CryptoMenu::DecryptAndVerify;
+ }
+
+ if (info.isFile() && (info.suffix() != "gpg" && info.suffix() != "sig" &&
+ info.suffix() != "asc")) {
+ operation_type |= MainWindow::CryptoMenu::Sign;
+ }
+
+ if (info.isFile() && (info.suffix() == "sig" || info.suffix() == "gpg" ||
+ info.suffix() == "asc")) {
+ operation_type |= MainWindow::CryptoMenu::Verify;
+ }
+ }
+
+ auto main_window = qobject_cast<MainWindow*>(first_parent_);
+ if (main_window != nullptr) main_window->SetCryptoMenuStatus(operation_type);
}
-void FilePage::slotUpLevel() {
- QModelIndex currentRoot = ui->fileTreeView->rootIndex();
+void FilePage::slot_up_level() {
+ QModelIndex currentRoot = ui_->fileTreeView->rootIndex();
auto utf8_path =
- dirModel->fileInfo(currentRoot).absoluteFilePath().toStdString();
- boost::filesystem::path path_obj(utf8_path);
-
- mPath = path_obj;
- LOG(INFO) << "get path" << mPath;
- if (mPath.has_parent_path() && !mPath.parent_path().empty()) {
- mPath = mPath.parent_path();
- LOG(INFO) << "parent path" << mPath;
- ui->pathEdit->setText(mPath.string().c_str());
- this->slotGoPath();
+ dir_model_->fileInfo(currentRoot).absoluteFilePath().toStdString();
+ std::filesystem::path path_obj(utf8_path);
+
+ m_path_ = path_obj;
+ LOG(INFO) << "get path" << m_path_;
+ if (m_path_.has_parent_path() && !m_path_.parent_path().empty()) {
+ m_path_ = m_path_.parent_path();
+ LOG(INFO) << "parent path" << m_path_;
+ ui_->pathEdit->setText(m_path_.string().c_str());
+ this->SlotGoPath();
}
}
-void FilePage::fileTreeViewItemDoubleClicked(const QModelIndex& index) {
- QFileInfo file_info(dirModel->fileInfo(index).absoluteFilePath());
+void FilePage::slot_file_tree_view_item_double_clicked(
+ const QModelIndex& index) {
+ QFileInfo file_info(dir_model_->fileInfo(index).absoluteFilePath());
if (file_info.isFile()) {
- slotOpenItem();
+ slot_open_item();
} else {
- ui->pathEdit->setText(file_info.filePath());
- slotGoPath();
+ ui_->pathEdit->setText(file_info.filePath());
+ SlotGoPath();
}
}
-QString FilePage::getSelected() const {
- return QString::fromStdString(selectedPath.string());
+QString FilePage::GetSelected() const {
+ return QString::fromStdString(selected_path_.string());
}
-void FilePage::slotGoPath() {
- const auto path_edit = ui->pathEdit->text().toStdString();
- boost::filesystem::path path_obj(path_edit);
+void FilePage::SlotGoPath() {
+ const auto path_edit = ui_->pathEdit->text().toStdString();
+ std::filesystem::path path_obj(path_edit);
- if (mPath.string() != path_edit) mPath = path_obj;
- auto fileInfo = QFileInfo(mPath.string().c_str());
+ if (m_path_.string() != path_edit) m_path_ = path_obj;
+ auto fileInfo = QFileInfo(m_path_.string().c_str());
if (fileInfo.isDir() && fileInfo.isReadable() && fileInfo.isExecutable()) {
- mPath = boost::filesystem::path(fileInfo.filePath().toStdString());
- LOG(INFO) << "set path" << mPath;
- ui->fileTreeView->setRootIndex(dirModel->index(fileInfo.filePath()));
- dirModel->setRootPath(fileInfo.filePath());
- for (int i = 1; i < dirModel->columnCount(); ++i) {
- ui->fileTreeView->resizeColumnToContents(i);
+ m_path_ = std::filesystem::path(fileInfo.filePath().toStdString());
+ LOG(INFO) << "set path" << m_path_;
+ ui_->fileTreeView->setRootIndex(dir_model_->index(fileInfo.filePath()));
+ dir_model_->setRootPath(fileInfo.filePath());
+ for (int i = 1; i < dir_model_->columnCount(); ++i) {
+ ui_->fileTreeView->resizeColumnToContents(i);
}
- ui->pathEdit->setText(mPath.generic_path().string().c_str());
+ ui_->pathEdit->setText(m_path_.generic_string().c_str());
} else {
QMessageBox::critical(
this, _("Error"),
_("The path is not exists, unprivileged or unreachable."));
}
- emit pathChanged(mPath.string().c_str());
+ emit SignalPathChanged(m_path_.string().c_str());
}
-void FilePage::createPopupMenu() {
- popUpMenu = new QMenu();
-
- ui->actionOpenFile->setText(_("Open"));
- connect(ui->actionOpenFile, &QAction::triggered, this,
- &FilePage::slotOpenItem);
- ui->actionRenameFile->setText(_("Rename"));
- connect(ui->actionRenameFile, &QAction::triggered, this,
- &FilePage::slotRenameItem);
- ui->actionDeleteFile->setText(_("Delete"));
- connect(ui->actionDeleteFile, &QAction::triggered, this,
- &FilePage::slotDeleteItem);
-
- ui->actionEncrypt->setText(_("Encrypt"));
- connect(ui->actionEncrypt, &QAction::triggered, this,
- &FilePage::slotEncryptItem);
- ui->actionEncryptSign->setText(_("Encrypt Sign"));
- connect(ui->actionEncryptSign, &QAction::triggered, this,
- &FilePage::slotEncryptSignItem);
- ui->actionDecrypt->setText(QString(_("Decrypt Verify")) + " " +
- _("(.gpg .asc)"));
- connect(ui->actionDecrypt, &QAction::triggered, this,
- &FilePage::slotDecryptItem);
- ui->actionSign->setText(_("Sign"));
- connect(ui->actionSign, &QAction::triggered, this, &FilePage::slotSignItem);
- ui->actionVerify->setText(QString(_("Verify")) + " " + _("(.sig .gpg .asc)"));
- connect(ui->actionVerify, &QAction::triggered, this,
- &FilePage::slotVerifyItem);
-
- ui->actionCalculateHash->setText(_("Calculate Hash"));
- connect(ui->actionCalculateHash, &QAction::triggered, this,
- &FilePage::slotCalculateHash);
-
- ui->actionMakeDirectory->setText(_("Make New Directory"));
- connect(ui->actionMakeDirectory, &QAction::triggered, this,
- &FilePage::slotMkdir);
-
- ui->actionCreateEmptyFile->setText(_("Create Empty File"));
- connect(ui->actionCreateEmptyFile, &QAction::triggered, this,
- &FilePage::slotCreateEmptyFile);
-
- popUpMenu->addAction(ui->actionOpenFile);
- popUpMenu->addAction(ui->actionRenameFile);
- popUpMenu->addAction(ui->actionDeleteFile);
- popUpMenu->addSeparator();
- popUpMenu->addAction(ui->actionEncrypt);
- popUpMenu->addAction(ui->actionEncryptSign);
- popUpMenu->addAction(ui->actionDecrypt);
- popUpMenu->addAction(ui->actionSign);
- popUpMenu->addAction(ui->actionVerify);
- popUpMenu->addSeparator();
- popUpMenu->addAction(ui->actionMakeDirectory);
- popUpMenu->addAction(ui->actionCreateEmptyFile);
- popUpMenu->addAction(ui->actionCalculateHash);
-
- optionPopUpMenu = new QMenu();
+void FilePage::create_popup_menu() {
+ popup_menu_ = new QMenu();
+
+ ui_->actionOpenFile->setText(_("Open"));
+ connect(ui_->actionOpenFile, &QAction::triggered, this,
+ &FilePage::slot_open_item);
+ ui_->actionRenameFile->setText(_("Rename"));
+ connect(ui_->actionRenameFile, &QAction::triggered, this,
+ &FilePage::slot_rename_item);
+ ui_->actionDeleteFile->setText(_("Delete"));
+ connect(ui_->actionDeleteFile, &QAction::triggered, this,
+ &FilePage::slot_delete_item);
+
+ ui_->actionCalculateHash->setText(_("Calculate Hash"));
+ connect(ui_->actionCalculateHash, &QAction::triggered, this,
+ &FilePage::slot_calculate_hash);
+
+ ui_->actionMakeDirectory->setText(_("Directory"));
+ connect(ui_->actionMakeDirectory, &QAction::triggered, this,
+ &FilePage::slot_mkdir);
+
+ ui_->actionCreateEmptyFile->setText(_("File"));
+ connect(ui_->actionCreateEmptyFile, &QAction::triggered, this,
+ &FilePage::slot_create_empty_file);
+
+ ui_->actionCompressFiles->setText(_("Compress..."));
+ ui_->actionCompressFiles->setVisible(false);
+ connect(ui_->actionCompressFiles, &QAction::triggered, this,
+ &FilePage::slot_compress_files);
+
+ auto new_item_action_menu = new QMenu(this);
+ new_item_action_menu->setTitle(_("New"));
+ new_item_action_menu->addAction(ui_->actionCreateEmptyFile);
+ new_item_action_menu->addAction(ui_->actionMakeDirectory);
+
+ popup_menu_->addAction(ui_->actionOpenFile);
+ popup_menu_->addAction(ui_->actionRenameFile);
+ popup_menu_->addAction(ui_->actionDeleteFile);
+ popup_menu_->addSeparator();
+ popup_menu_->addMenu(new_item_action_menu);
+ popup_menu_->addAction(ui_->actionCompressFiles);
+ popup_menu_->addAction(ui_->actionCalculateHash);
+
+ option_popup_menu_ = new QMenu();
auto showHiddenAct = new QAction(_("Show Hidden File"), this);
showHiddenAct->setCheckable(true);
connect(showHiddenAct, &QAction::triggered, this, [&](bool checked) {
LOG(INFO) << "Set Hidden" << checked;
if (checked)
- dirModel->setFilter(dirModel->filter() | QDir::Hidden);
+ dir_model_->setFilter(dir_model_->filter() | QDir::Hidden);
else
- dirModel->setFilter(dirModel->filter() & ~QDir::Hidden);
- dirModel->setRootPath(mPath.string().c_str());
+ dir_model_->setFilter(dir_model_->filter() & ~QDir::Hidden);
+ dir_model_->setRootPath(m_path_.string().c_str());
});
- optionPopUpMenu->addAction(showHiddenAct);
+ option_popup_menu_->addAction(showHiddenAct);
auto showSystemAct = new QAction(_("Show System File"), this);
showSystemAct->setCheckable(true);
connect(showSystemAct, &QAction::triggered, this, [&](bool checked) {
LOG(INFO) << "Set Hidden" << checked;
if (checked)
- dirModel->setFilter(dirModel->filter() | QDir::System);
+ dir_model_->setFilter(dir_model_->filter() | QDir::System);
else
- dirModel->setFilter(dirModel->filter() & ~QDir::System);
- dirModel->setRootPath(mPath.string().c_str());
+ dir_model_->setFilter(dir_model_->filter() & ~QDir::System);
+ dir_model_->setRootPath(m_path_.string().c_str());
});
- optionPopUpMenu->addAction(showSystemAct);
+ option_popup_menu_->addAction(showSystemAct);
}
void FilePage::onCustomContextMenu(const QPoint& point) {
- QModelIndex index = ui->fileTreeView->indexAt(point);
- selectedPath = boost::filesystem::path(
- dirModel->fileInfo(index).absoluteFilePath().toStdString());
- LOG(INFO) << "right click" << selectedPath;
+ QModelIndex index = ui_->fileTreeView->indexAt(point);
+ LOG(INFO) << "right click" << selected_path_;
+
+ selected_path_ = std::filesystem::path(
+ dir_model_->fileInfo(index).absoluteFilePath().toStdString());
+
+ // update crypt menu
+ slot_file_tree_view_item_clicked(index);
+
if (index.isValid()) {
- ui->actionOpenFile->setEnabled(true);
- ui->actionRenameFile->setEnabled(true);
- ui->actionDeleteFile->setEnabled(true);
-
- QFileInfo info(QString::fromStdString(selectedPath.string()));
- ui->actionEncrypt->setEnabled(info.isFile() && (info.suffix() != "gpg" &&
- info.suffix() != "sig" &&
- info.suffix() != "asc"));
- ui->actionEncryptSign->setEnabled(
- info.isFile() && (info.suffix() != "gpg" && info.suffix() != "sig" &&
- info.suffix() != "asc"));
- ui->actionDecrypt->setEnabled(
- info.isFile() && (info.suffix() == "gpg" || info.suffix() == "asc"));
- ui->actionSign->setEnabled(info.isFile() && (info.suffix() != "gpg" &&
- info.suffix() != "sig" &&
- info.suffix() != "asc"));
- ui->actionVerify->setEnabled(info.isFile() && (info.suffix() == "sig" ||
- info.suffix() == "gpg" ||
- info.suffix() == "asc"));
- ui->actionCalculateHash->setEnabled(info.isFile() && info.isReadable());
+ ui_->actionOpenFile->setEnabled(true);
+ ui_->actionRenameFile->setEnabled(true);
+ ui_->actionDeleteFile->setEnabled(true);
+
+ QFileInfo info(QString::fromStdString(selected_path_.string()));
+ ui_->actionCalculateHash->setEnabled(info.isFile() && info.isReadable());
} else {
- ui->actionOpenFile->setEnabled(false);
- ui->actionRenameFile->setEnabled(false);
- ui->actionDeleteFile->setEnabled(false);
-
- ui->actionEncrypt->setEnabled(false);
- ui->actionEncryptSign->setEnabled(false);
- ui->actionDecrypt->setEnabled(false);
- ui->actionSign->setEnabled(false);
- ui->actionVerify->setEnabled(false);
- ui->actionCalculateHash->setEnabled(false);
+ ui_->actionOpenFile->setEnabled(false);
+ ui_->actionRenameFile->setEnabled(false);
+ ui_->actionDeleteFile->setEnabled(false);
+
+ ui_->actionCalculateHash->setEnabled(false);
}
- popUpMenu->exec(ui->fileTreeView->viewport()->mapToGlobal(point));
+ popup_menu_->exec(ui_->fileTreeView->viewport()->mapToGlobal(point));
}
-void FilePage::slotOpenItem() {
- QFileInfo info(QString::fromStdString(selectedPath.string()));
+void FilePage::slot_open_item() {
+ QFileInfo info(QString::fromStdString(selected_path_.string()));
if (info.isDir()) {
if (info.isReadable() && info.isExecutable()) {
const auto file_path = info.filePath().toStdString();
LOG(INFO) << "set path" << file_path;
- ui->pathEdit->setText(info.filePath());
- slotGoPath();
+ ui_->pathEdit->setText(info.filePath());
+ SlotGoPath();
} else {
QMessageBox::critical(this, _("Error"),
_("The directory is unprivileged or unreachable."));
}
} else {
if (info.isReadable()) {
- auto mainWindow = qobject_cast<MainWindow*>(firstParent);
- LOG(INFO) << "open item" << selectedPath;
- auto qt_path = QString::fromStdString(selectedPath.string());
- if (mainWindow != nullptr) mainWindow->slotOpenFile(qt_path);
+ // handle normal text or binary file
+ auto main_window = qobject_cast<MainWindow*>(first_parent_);
+ LOG(INFO) << "open item" << selected_path_;
+ auto qt_path = QString::fromStdString(selected_path_.string());
+ if (main_window != nullptr) main_window->SlotOpenFile(qt_path);
} else {
QMessageBox::critical(this, _("Error"),
_("The file is unprivileged or unreachable."));
@@ -301,8 +321,8 @@ void FilePage::slotOpenItem() {
}
}
-void FilePage::slotRenameItem() {
- auto new_name_path = selectedPath, old_name_path = selectedPath;
+void FilePage::slot_rename_item() {
+ auto new_name_path = selected_path_, old_name_path = selected_path_;
auto old_name = old_name_path.filename();
new_name_path = new_name_path.remove_filename();
@@ -314,9 +334,9 @@ void FilePage::slotRenameItem() {
try {
new_name_path /= text.toStdString();
LOG(INFO) << "new name path" << new_name_path;
- boost::filesystem::rename(old_name_path, new_name_path);
+ std::filesystem::rename(old_name_path, new_name_path);
// refresh
- this->slotGoPath();
+ this->SlotGoPath();
} catch (...) {
LOG(ERROR) << "rename error" << new_name_path;
QMessageBox::critical(this, _("Error"),
@@ -325,9 +345,9 @@ void FilePage::slotRenameItem() {
}
}
-void FilePage::slotDeleteItem() {
- QModelIndex index = ui->fileTreeView->currentIndex();
- QVariant data = ui->fileTreeView->model()->data(index);
+void FilePage::slot_delete_item() {
+ QModelIndex index = ui_->fileTreeView->currentIndex();
+ QVariant data = ui_->fileTreeView->model()->data(index);
auto ret = QMessageBox::warning(this, _("Warning"),
_("Are you sure you want to delete it?"),
@@ -337,88 +357,19 @@ void FilePage::slotDeleteItem() {
LOG(INFO) << "Delete Item" << data.toString().toStdString();
- if (!dirModel->remove(index)) {
+ if (!dir_model_->remove(index)) {
QMessageBox::critical(this, _("Error"),
_("Unable to delete the file or folder."));
}
}
-void FilePage::slotEncryptItem() {
- auto mainWindow = qobject_cast<MainWindow*>(firstParent);
- if (mainWindow != nullptr) mainWindow->slotFileEncrypt();
+void FilePage::slot_calculate_hash() {
+ auto info_str = FileOperator::CalculateHash(selected_path_);
+ emit SignalRefreshInfoBoard(info_str.c_str(), InfoBoardStatus::INFO_ERROR_OK);
}
-void FilePage::slotEncryptSignItem() {
- auto mainWindow = qobject_cast<MainWindow*>(firstParent);
- if (mainWindow != nullptr) mainWindow->slotFileEncryptSign();
-}
-
-void FilePage::slotDecryptItem() {
- auto mainWindow = qobject_cast<MainWindow*>(firstParent);
- if (mainWindow != nullptr) mainWindow->slotFileDecryptVerify();
-}
-
-void FilePage::slotSignItem() {
- auto mainWindow = qobject_cast<MainWindow*>(firstParent);
- if (mainWindow != nullptr) mainWindow->slotFileSign();
-}
-
-void FilePage::slotVerifyItem() {
- auto mainWindow = qobject_cast<MainWindow*>(firstParent);
- if (mainWindow != nullptr) mainWindow->slotFileVerify();
-}
-
-void FilePage::slotCalculateHash() {
- // Returns empty QByteArray() on failure.
- QFileInfo info(QString::fromStdString(selectedPath.string()));
-
- if (info.isFile() && info.isReadable()) {
- std::stringstream ss;
-
- ss << "[#] " << _("File Hash Information") << std::endl;
- ss << " " << _("filename") << _(": ")
- << selectedPath.filename().string().c_str() << std::endl;
-
- QFile f(info.filePath());
- f.open(QFile::ReadOnly);
- auto buffer = f.readAll();
- LOG(INFO) << "buffer size" << buffer.size();
- f.close();
- if (f.open(QFile::ReadOnly)) {
- auto hash_md5 = QCryptographicHash(QCryptographicHash::Md5);
- // md5
- hash_md5.addData(buffer);
- auto md5 = hash_md5.result().toHex().toStdString();
- LOG(INFO) << "md5" << md5;
- ss << " "
- << "md5" << _(": ") << md5 << std::endl;
-
- auto hash_sha1 = QCryptographicHash(QCryptographicHash::Sha1);
- // sha1
- hash_sha1.addData(buffer);
- auto sha1 = hash_sha1.result().toHex().toStdString();
- LOG(INFO) << "sha1" << sha1;
- ss << " "
- << "sha1" << _(": ") << sha1 << std::endl;
-
- auto hash_sha256 = QCryptographicHash(QCryptographicHash::Sha256);
- // sha1
- hash_sha256.addData(buffer);
- auto sha256 = hash_sha256.result().toHex().toStdString();
- LOG(INFO) << "sha256" << sha256;
- ss << " "
- << "sha256" << _(": ") << sha256 << std::endl;
-
- ss << std::endl;
-
- emit signalRefreshInfoBoard(ss.str().c_str(),
- InfoBoardStatus::INFO_ERROR_OK);
- }
- }
-}
-
-void FilePage::slotMkdir() {
- auto index = ui->fileTreeView->rootIndex();
+void FilePage::slot_mkdir() {
+ auto index = ui_->fileTreeView->rootIndex();
QString new_dir_name;
bool ok;
@@ -426,13 +377,13 @@ void FilePage::slotMkdir() {
QInputDialog::getText(this, _("Make New Directory"), _("Directory Name"),
QLineEdit::Normal, new_dir_name, &ok);
if (ok && !new_dir_name.isEmpty()) {
- dirModel->mkdir(index, new_dir_name);
+ dir_model_->mkdir(index, new_dir_name);
}
}
-void FilePage::slotCreateEmptyFile() {
- auto root_path_str = dirModel->rootPath().toStdString();
- boost::filesystem::path root_path(root_path_str);
+void FilePage::slot_create_empty_file() {
+ auto root_path_str = dir_model_->rootPath().toStdString();
+ std::filesystem::path root_path(root_path_str);
QString new_file_name;
bool ok;
@@ -451,16 +402,18 @@ void FilePage::slotCreateEmptyFile() {
void FilePage::keyPressEvent(QKeyEvent* event) {
LOG(INFO) << "Key Press" << event->key();
- if (ui->pathEdit->hasFocus() &&
+ if (ui_->pathEdit->hasFocus() &&
(event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)) {
- slotGoPath();
- } else if (ui->fileTreeView->currentIndex().isValid()) {
+ SlotGoPath();
+ } else if (ui_->fileTreeView->currentIndex().isValid()) {
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)
- slotOpenItem();
+ slot_open_item();
else if (event->key() == Qt::Key_Delete ||
event->key() == Qt::Key_Backspace)
- slotDeleteItem();
+ slot_delete_item();
}
}
+void FilePage::slot_compress_files() {}
+
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/FilePage.h b/src/ui/widgets/FilePage.h
index 1f2b51f8..cff395a8 100644
--- a/src/ui/widgets/FilePage.h
+++ b/src/ui/widgets/FilePage.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,26 +8,28 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef GPGFRONTEND_FILEPAGE_H
#define GPGFRONTEND_FILEPAGE_H
-#include <boost/filesystem.hpp>
+
#include "ui/GpgFrontendUI.h"
#include "ui/widgets/InfoBoardWidget.h"
@@ -34,62 +38,150 @@ class Ui_FilePage;
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class FilePage : public QWidget {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new File Page object
+ *
+ * @param parent
+ */
explicit FilePage(QWidget* parent = nullptr);
- [[nodiscard]] QString getSelected() const;
+ /**
+ * @brief Get the Selected object
+ *
+ * @return QString
+ */
+ [[nodiscard]] QString GetSelected() const;
public slots:
- void slotGoPath();
+ /**
+ * @brief
+ *
+ */
+ void SlotGoPath();
signals:
- void pathChanged(const QString& path);
- void signalRefreshInfoBoard(const QString& text,
+ /**
+ * @brief
+ *
+ * @param path
+ */
+ void SignalPathChanged(const QString& path);
+
+ /**
+ * @brief
+ *
+ * @param text
+ * @param verify_label_status
+ */
+ void SignalRefreshInfoBoard(const QString& text,
InfoBoardStatus verify_label_status);
private slots:
- void fileTreeViewItemClicked(const QModelIndex& index);
- void fileTreeViewItemDoubleClicked(const QModelIndex& index);
-
- void slotUpLevel();
-
- void slotOpenItem();
- void slotRenameItem();
- void slotDeleteItem();
- void slotEncryptItem();
- void slotEncryptSignItem();
- void slotDecryptItem();
- void slotSignItem();
- void slotVerifyItem();
- void slotCalculateHash();
- void slotMkdir();
- void slotCreateEmptyFile();
-
- void onCustomContextMenu(const QPoint& point);
+ /**
+ * @brief
+ *
+ * @param index
+ */
+ void slot_file_tree_view_item_clicked(const QModelIndex& index);
+
+ /**
+ * @brief
+ *
+ * @param index
+ */
+ void slot_file_tree_view_item_double_clicked(const QModelIndex& index);
+
+ /**
+ * @brief
+ *
+ */
+ void slot_up_level();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_open_item();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_rename_item();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_delete_item();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_calculate_hash();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_mkdir();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_create_empty_file();
+
+ /**
+ * @brief compress directory into gpg-zip
+ *
+ */
+ void slot_compress_files();
protected:
+ /**
+ * @brief
+ *
+ * @param event
+ */
void keyPressEvent(QKeyEvent* event) override;
+ /**
+ * @brief
+ *
+ * @param point
+ */
+ void onCustomContextMenu(const QPoint& point);
+
private:
- void createPopupMenu();
+ /**
+ * @brief Create a popup menu object
+ *
+ */
+ void create_popup_menu();
- std::shared_ptr<Ui_FilePage> ui;
+ std::shared_ptr<Ui_FilePage> ui_; ///<
- QFileSystemModel* dirModel;
- QCompleter* pathEditCompleter;
- QStringListModel* pathCompleteModel;
+ QFileSystemModel* dir_model_; ///<
+ QCompleter* path_edit_completer_; ///<
+ QStringListModel* path_complete_model_; ///<
- // using boost path
- boost::filesystem::path mPath;
- boost::filesystem::path selectedPath;
+ std::filesystem::path m_path_; ///<
+ std::filesystem::path selected_path_; ///<
- QMenu* popUpMenu{};
- QMenu* optionPopUpMenu{};
- QWidget* firstParent;
+ QMenu* popup_menu_{}; ///<
+ QMenu* option_popup_menu_{}; ///<
+ QWidget* first_parent_{}; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/FindWidget.cpp b/src/ui/widgets/FindWidget.cpp
new file mode 100644
index 00000000..58ceda7c
--- /dev/null
+++ b/src/ui/widgets/FindWidget.cpp
@@ -0,0 +1,171 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#include "FindWidget.h"
+
+namespace GpgFrontend::UI {
+
+FindWidget::FindWidget(QWidget* parent, PlainTextEditorPage* edit)
+ : QWidget(parent), m_text_page_(edit) {
+ find_edit_ = new QLineEdit(this);
+ auto* closeButton = new QPushButton(
+ this->style()->standardIcon(QStyle::SP_TitleBarCloseButton), QString(),
+ this);
+ auto* nextButton = new QPushButton(QIcon(":button_next.png"), QString());
+ auto* previousButton = new QPushButton(QIcon(":button_previous.png"), "");
+
+ auto* notificationWidgetLayout = new QHBoxLayout(this);
+ notificationWidgetLayout->setContentsMargins(10, 0, 0, 0);
+ notificationWidgetLayout->addWidget(new QLabel(QString(_("Find")) + ": "));
+ notificationWidgetLayout->addWidget(find_edit_, 2);
+ notificationWidgetLayout->addWidget(nextButton);
+ notificationWidgetLayout->addWidget(previousButton);
+ notificationWidgetLayout->addWidget(closeButton);
+
+ this->setLayout(notificationWidgetLayout);
+ connect(find_edit_, &QLineEdit::textEdited, this, &FindWidget::slot_find);
+ connect(find_edit_, &QLineEdit::returnPressed, this, &FindWidget::slot_find_next);
+ connect(nextButton, &QPushButton::clicked, this, &FindWidget::slot_find_next);
+ connect(previousButton, &QPushButton::clicked, this, &FindWidget::slot_find_previous);
+ connect(closeButton, &QPushButton::clicked, this, &FindWidget::slot_close);
+
+ // The timer is necessary for setting the focus
+ QTimer::singleShot(0, find_edit_, SLOT(setFocus()));
+}
+
+void FindWidget::set_background() {
+ auto cursor = m_text_page_->GetTextPage()->textCursor();
+ // if match is found set background of QLineEdit to white, otherwise to red
+ QPalette bgPalette(find_edit_->palette());
+
+ if (!find_edit_->text().isEmpty() && m_text_page_->GetTextPage()
+ ->document()
+ ->find(find_edit_->text())
+ .position() < 0) {
+ bgPalette.setColor(QPalette::Base, "#ececba");
+ } else {
+ bgPalette.setColor(QPalette::Base, Qt::white);
+ }
+ find_edit_->setPalette(bgPalette);
+}
+
+void FindWidget::slot_find_next() {
+ QTextCursor cursor = m_text_page_->GetTextPage()->textCursor();
+ cursor = m_text_page_->GetTextPage()->document()->find(
+ find_edit_->text(), cursor, QTextDocument::FindCaseSensitively);
+
+ // if end of document is reached, restart search from beginning
+ if (cursor.position() == -1) {
+ cursor = m_text_page_->GetTextPage()->document()->find(
+ find_edit_->text(), cursor, QTextDocument::FindCaseSensitively);
+ }
+
+ // cursor should not stay at -1, otherwise text is not editable
+ // todo: check how gedit handles this
+ if (cursor.position() != -1) {
+ m_text_page_->GetTextPage()->setTextCursor(cursor);
+ }
+ this->set_background();
+}
+
+void FindWidget::slot_find() {
+ QTextCursor cursor = m_text_page_->GetTextPage()->textCursor();
+
+ if (cursor.anchor() == -1) {
+ cursor = m_text_page_->GetTextPage()->document()->find(
+ find_edit_->text(), cursor, QTextDocument::FindCaseSensitively);
+ } else {
+ cursor = m_text_page_->GetTextPage()->document()->find(
+ find_edit_->text(), cursor.anchor(),
+ QTextDocument::FindCaseSensitively);
+ }
+
+ // if end of document is reached, restart search from beginning
+ if (cursor.position() == -1) {
+ cursor = m_text_page_->GetTextPage()->document()->find(
+ find_edit_->text(), cursor, QTextDocument::FindCaseSensitively);
+ }
+
+ // cursor should not stay at -1, otherwise text is not editable
+ // todo: check how gedit handles this
+ if (cursor.position() != -1) {
+ m_text_page_->GetTextPage()->setTextCursor(cursor);
+ }
+ this->set_background();
+}
+
+void FindWidget::slot_find_previous() {
+ QTextDocument::FindFlags flags;
+ flags |= QTextDocument::FindBackward;
+ flags |= QTextDocument::FindCaseSensitively;
+
+ QTextCursor cursor = m_text_page_->GetTextPage()->textCursor();
+ cursor = m_text_page_->GetTextPage()->document()->find(find_edit_->text(),
+ cursor, flags);
+
+ // if begin of document is reached, restart search from end
+ if (cursor.position() == -1) {
+ cursor = m_text_page_->GetTextPage()->document()->find(
+ find_edit_->text(), QTextCursor::End, flags);
+ }
+
+ // cursor should not stay at -1, otherwise text is not editable
+ // todo: check how gedit handles this
+ if (cursor.position() != -1) {
+ m_text_page_->GetTextPage()->setTextCursor(cursor);
+ }
+ this->set_background();
+}
+
+void FindWidget::keyPressEvent(QKeyEvent* e) {
+ switch (e->key()) {
+ case Qt::Key_Escape:
+ this->slot_close();
+ break;
+ case Qt::Key_F3:
+ if (e->modifiers() & Qt::ShiftModifier) {
+ this->slot_find_previous();
+ } else {
+ this->slot_find_next();
+ }
+ break;
+ }
+}
+
+void FindWidget::slot_close() {
+ QTextCursor cursor = m_text_page_->GetTextPage()->textCursor();
+
+ if (cursor.position() == -1) {
+ cursor.setPosition(0);
+ m_text_page_->GetTextPage()->setTextCursor(cursor);
+ }
+ m_text_page_->setFocus();
+ close();
+}
+
+} // namespace GpgFrontend::UI
diff --git a/src/ui/FindWidget.h b/src/ui/widgets/FindWidget.h
index bc412012..dfe50f9c 100644
--- a/src/ui/FindWidget.h
+++ b/src/ui/widgets/FindWidget.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -44,27 +48,50 @@ class FindWidget : public QWidget {
*/
explicit FindWidget(QWidget* parent, PlainTextEditorPage* edit);
- private:
+ protected:
+ /**
+ * @brief
+ *
+ * @param e
+ */
void keyPressEvent(QKeyEvent* e) override;
+ private:
/**
* @details Set background of findEdit to red, if no match is found (Documents
* textcursor position equals -1), otherwise set it to white.
*/
- void setBackground();
+ void set_background();
- PlainTextEditorPage* mTextpage; /** Textedit associated to the notification */
- QLineEdit* findEdit; /** Label holding the text shown in infoBoard */
+ PlainTextEditorPage*
+ m_text_page_; ///< Textedit associated to the notification
+ QLineEdit* find_edit_; ///< Label holding the text shown in infoBoard
private slots:
- void slotFindNext();
+ /**
+ * @brief
+ *
+ */
+ void slot_find_next();
- void slotFindPrevious();
+ /**
+ * @brief
+ *
+ */
+ void slot_find_previous();
- void slotFind();
+ /**
+ * @brief
+ *
+ */
+ void slot_find();
- void slotClose();
+ /**
+ * @brief
+ *
+ */
+ void slot_close();
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/GroupKeyList.cpp b/src/ui/widgets/GroupKeyList.cpp
deleted file mode 100644
index efba4428..00000000
--- a/src/ui/widgets/GroupKeyList.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#include "GroupKeyList.h"
diff --git a/src/ui/widgets/GroupKeyList.h b/src/ui/widgets/GroupKeyList.h
deleted file mode 100644
index 163c7126..00000000
--- a/src/ui/widgets/GroupKeyList.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Foobar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
- *
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
- *
- */
-
-#ifndef GPGFRONTEND_GROUPKEYLIST_H
-#define GPGFRONTEND_GROUPKEYLIST_H
-
-#include "ui/GpgFrontendUI.h"
-
-class GroupKeyList : public QWidget {
- Q_OBJECT
-};
-
-#endif // GPGFRONTEND_GROUPKEYLIST_H
diff --git a/src/ui/widgets/HelpPage.cpp b/src/ui/widgets/HelpPage.cpp
index 7b1e86c0..b116df30 100644
--- a/src/ui/widgets/HelpPage.cpp
+++ b/src/ui/widgets/HelpPage.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -29,32 +33,33 @@
namespace GpgFrontend::UI {
HelpPage::HelpPage(const QString& path, QWidget* parent) : QWidget(parent) {
- browser = new QTextBrowser();
+ browser_ = new QTextBrowser();
auto* mainLayout = new QVBoxLayout();
mainLayout->setSpacing(0);
- mainLayout->addWidget(browser);
+ mainLayout->addWidget(browser_);
mainLayout->setContentsMargins(0, 0, 0, 0);
setLayout(mainLayout);
- connect(browser, SIGNAL(anchorClicked(QUrl)), this, SLOT(slotOpenUrl(QUrl)));
- browser->setOpenLinks(false);
- browser->setSource(localizedHelp(QUrl(path)));
- browser->setFocus();
+ connect(browser_, &QTextBrowser::anchorClicked, this,
+ &HelpPage::slot_open_url);
+ browser_->setOpenLinks(false);
+ browser_->setSource(localized_help(QUrl(path)));
+ browser_->setFocus();
}
-void HelpPage::slotOpenUrl(const QUrl& url) {
- browser->setSource(localizedHelp(url));
+void HelpPage::slot_open_url(const QUrl& url) {
+ browser_->setSource(localized_help(url));
};
/**
- * @brief HelpPage::localizedHelp
+ * @brief HelpPage::localized_help
* check if the requested file is also available with the locale,
* e.g. return index.de.html if index.html was requested but the
* locale is de and index.de.html is available
* @param url
* @return
*/
-QUrl HelpPage::localizedHelp(const QUrl& url) {
+QUrl HelpPage::localized_help(const QUrl& url) {
QString path = url.toLocalFile();
QString filename = path.mid(path.lastIndexOf("/") + 1);
QString filepath = path.left(path.lastIndexOf("/") + 1);
@@ -77,6 +82,6 @@ QUrl HelpPage::localizedHelp(const QUrl& url) {
}
}
-QTextBrowser* HelpPage::getBrowser() { return browser; }
+QTextBrowser* HelpPage::GetBrowser() { return browser_; }
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/HelpPage.h b/src/ui/widgets/HelpPage.h
index 25490557..0b0db5ea 100644
--- a/src/ui/widgets/HelpPage.h
+++ b/src/ui/widgets/HelpPage.h
@@ -1,22 +1,29 @@
-/*
- * helppage.h
+/**
+ * Copyright (C) 2021 Saturneric
*
- * Copyright 2008 gpg4usb-team <[email protected]>
+ * This file is part of GpgFrontend.
*
- * This file is part of gpg4usb.
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
- * Gpg4usb is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * Gpg4usb is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
- * You should have received a copy of the GNU General Public License
- * along with gpg4usb. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef HELPPAGE_H
@@ -26,22 +33,40 @@
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
class HelpPage : public QWidget {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Help Page object
+ *
+ * @param path
+ * @param parent
+ */
explicit HelpPage(const QString& path, QWidget* parent = nullptr);
- QTextBrowser* getBrowser();
-
- signals:
+ /**
+ * @brief Get the Browser object
+ *
+ * @return QTextBrowser*
+ */
+ QTextBrowser* GetBrowser();
public slots:
- void slotOpenUrl(const QUrl& url);
+ /**
+ * @brief
+ *
+ * @param url
+ */
+ void slot_open_url(const QUrl& url);
private:
- QTextBrowser* browser; /** The textbrowser of the tab */
- QUrl localizedHelp(const QUrl& path);
+ QTextBrowser* browser_; ///< The textbrowser of the tab
+ QUrl localized_help(const QUrl& path);
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/InfoBoardWidget.cpp b/src/ui/widgets/InfoBoardWidget.cpp
index 7718cba3..ec2971cc 100644
--- a/src/ui/widgets/InfoBoardWidget.cpp
+++ b/src/ui/widgets/InfoBoardWidget.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,55 +8,58 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include "ui/widgets/InfoBoardWidget.h"
#include "ui/SignalStation.h"
-#include "ui/settings/GlobalSettingStation.h"
+#include "core/function/GlobalSettingStation.h"
#include "ui_InfoBoard.h"
+#include "ui/struct/SettingsObject.h"
namespace GpgFrontend::UI {
InfoBoardWidget::InfoBoardWidget(QWidget* parent)
- : QWidget(parent), ui(std::make_shared<Ui_InfoBoard>()) {
- ui->setupUi(this);
-
- ui->actionButtonLayout->addStretch();
- ui->copyButton->setText(_("Copy"));
- ui->saveButton->setText(_("Save File"));
- ui->clearButton->setText(_("Clear"));
-
- connect(ui->copyButton, &QPushButton::clicked, this,
- &InfoBoardWidget::slotCopy);
- connect(ui->saveButton, &QPushButton::clicked, this,
- &InfoBoardWidget::slotSave);
- connect(ui->clearButton, &QPushButton::clicked, this,
- &InfoBoardWidget::slotReset);
-
- connect(SignalStation::GetInstance(), &SignalStation::signalRefreshInfoBoard,
- this, &InfoBoardWidget::slotRefresh);
+ : QWidget(parent), ui_(std::make_shared<Ui_InfoBoard>()) {
+ ui_->setupUi(this);
+
+ ui_->actionButtonLayout->addStretch();
+ ui_->copyButton->setText(_("Copy"));
+ ui_->saveButton->setText(_("Save File"));
+ ui_->clearButton->setText(_("Clear"));
+
+ connect(ui_->copyButton, &QPushButton::clicked, this,
+ &InfoBoardWidget::slot_copy);
+ connect(ui_->saveButton, &QPushButton::clicked, this,
+ &InfoBoardWidget::slot_save);
+ connect(ui_->clearButton, &QPushButton::clicked, this,
+ &InfoBoardWidget::SlotReset);
+
+ connect(SignalStation::GetInstance(), &SignalStation::SignalRefreshInfoBoard,
+ this, &InfoBoardWidget::SlotRefresh);
}
-void InfoBoardWidget::setInfoBoard(const QString& text,
- InfoBoardStatus verifyLabelStatus) {
+void InfoBoardWidget::SetInfoBoard(const QString& text,
+ InfoBoardStatus verify_label_status) {
QString color;
- ui->infoBoard->clear();
- switch (verifyLabelStatus) {
+ ui_->infoBoard->clear();
+ switch (verify_label_status) {
case INFO_ERROR_OK:
color = "#008000";
break;
@@ -67,98 +72,95 @@ void InfoBoardWidget::setInfoBoard(const QString& text,
default:
break;
}
- ui->infoBoard->append(text);
+ ui_->infoBoard->append(text);
- ui->infoBoard->setAutoFillBackground(true);
- QPalette status = ui->infoBoard->palette();
+ ui_->infoBoard->setAutoFillBackground(true);
+ QPalette status = ui_->infoBoard->palette();
status.setColor(QPalette::Text, color);
- ui->infoBoard->setPalette(status);
+ ui_->infoBoard->setPalette(status);
- auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ SettingsObject main_windows_state("main_windows_state");
// info board font size
- auto info_font_size = 10;
- try {
- info_font_size = settings.lookup("window.info_font_size");
- if (info_font_size < 9 || info_font_size > 18) info_font_size = 10;
- } catch (...) {
- LOG(ERROR) << _("Setting Operation Error") << _("info_font_size");
- }
- ui->infoBoard->setFont(QFont("Times", info_font_size));
+ auto info_font_size = main_windows_state.Check("info_font_size", 10);
+ ui_->infoBoard->setFont(QFont("Times", info_font_size));
}
-void InfoBoardWidget::slotRefresh(const QString& text, InfoBoardStatus status) {
- ui->infoBoard->clear();
- setInfoBoard(text, status);
- ui->infoBoard->verticalScrollBar()->setValue(0);
+void InfoBoardWidget::SlotRefresh(const QString& text, InfoBoardStatus status) {
+ ui_->infoBoard->clear();
+ SetInfoBoard(text, status);
+ ui_->infoBoard->verticalScrollBar()->setValue(0);
}
-void InfoBoardWidget::associateTextEdit(QTextEdit* edit) {
- if (mTextPage != nullptr)
- disconnect(mTextPage, SIGNAL(textChanged()), this, SLOT(slotReset()));
- this->mTextPage = edit;
- connect(edit, SIGNAL(textChanged()), this, SLOT(slotReset()));
+void InfoBoardWidget::AssociateTextEdit(QTextEdit* edit) {
+ if (m_text_page_ != nullptr)
+ disconnect(m_text_page_, &QTextEdit::textChanged, this,
+ &InfoBoardWidget::SlotReset);
+ this->m_text_page_ = edit;
+ connect(edit, &QTextEdit::textChanged, this, &InfoBoardWidget::SlotReset);
}
-void InfoBoardWidget::associateTabWidget(QTabWidget* tab) {
- mTextPage = nullptr;
- mTabWidget = tab;
- connect(tab, SIGNAL(tabBarClicked(int)), this, SLOT(slotReset()));
- connect(tab, SIGNAL(tabCloseRequested(int)), this, SLOT(slotReset()));
+void InfoBoardWidget::AssociateTabWidget(QTabWidget* tab) {
+ m_text_page_ = nullptr;
+ m_tab_widget_ = tab;
+ connect(tab, &QTabWidget::tabBarClicked, this, &InfoBoardWidget::SlotReset);
+ connect(tab, &QTabWidget::tabCloseRequested, this,
+ &InfoBoardWidget::SlotReset);
// reset
- this->slotReset();
+ this->SlotReset();
}
-void InfoBoardWidget::addOptionalAction(const QString& name,
+void InfoBoardWidget::AddOptionalAction(const QString& name,
const std::function<void()>& action) {
LOG(INFO) << "add option" << name.toStdString();
auto actionButton = new QPushButton(name);
auto layout = new QHBoxLayout();
layout->setContentsMargins(5, 0, 5, 0);
- ui->infoBoard->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
+ ui_->infoBoard->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
// set margin from surroundings
layout->addWidget(actionButton);
- ui->actionButtonLayout->addLayout(layout);
+ ui_->actionButtonLayout->addLayout(layout);
connect(actionButton, &QPushButton::clicked, this, [=]() { action(); });
}
/**
* Delete All item in actionButtonLayout
*/
-void InfoBoardWidget::resetOptionActionsMenu() {
+void InfoBoardWidget::ResetOptionActionsMenu() {
// skip stretch
- deleteWidgetsInLayout(ui->actionButtonLayout, 1);
+ delete_widgets_in_layout(ui_->actionButtonLayout, 1);
}
-void InfoBoardWidget::slotReset() {
- ui->infoBoard->clear();
- resetOptionActionsMenu();
+void InfoBoardWidget::SlotReset() {
+ ui_->infoBoard->clear();
+ ResetOptionActionsMenu();
}
/**
* Try Delete all widget from target layout
* @param layout target layout
*/
-void InfoBoardWidget::deleteWidgetsInLayout(QLayout* layout, int start_index) {
+void InfoBoardWidget::delete_widgets_in_layout(QLayout* layout,
+ int start_index) {
LOG(INFO) << "Called";
QLayoutItem* item;
while ((item = layout->layout()->takeAt(start_index)) != nullptr) {
layout->removeItem(item);
if (item->layout() != nullptr)
- deleteWidgetsInLayout(item->layout());
+ delete_widgets_in_layout(item->layout());
else if (item->widget() != nullptr)
delete item->widget();
delete item;
}
}
-void InfoBoardWidget::slotCopy() {
+void InfoBoardWidget::slot_copy() {
auto* clipboard = QGuiApplication::clipboard();
- clipboard->setText(ui->infoBoard->toPlainText());
+ clipboard->setText(ui_->infoBoard->toPlainText());
}
-void InfoBoardWidget::slotSave() {
+void InfoBoardWidget::slot_save() {
auto file_path = QFileDialog::getSaveFileName(
this, _("Save Information Board's Content"), {}, tr("Text (*.txt)"));
LOG(INFO) << "file path" << file_path.toStdString();
@@ -166,7 +168,7 @@ void InfoBoardWidget::slotSave() {
QFile file(file_path);
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
- file.write(ui->infoBoard->toPlainText().toUtf8());
+ file.write(ui_->infoBoard->toPlainText().toUtf8());
} else {
QMessageBox::critical(
this, _("Error"),
diff --git a/src/ui/widgets/InfoBoardWidget.h b/src/ui/widgets/InfoBoardWidget.h
index 816da849..7f456777 100644
--- a/src/ui/widgets/InfoBoardWidget.h
+++ b/src/ui/widgets/InfoBoardWidget.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -26,7 +30,7 @@
#define __VERIFYNOTIFICATION_H__
#include "PlainTextEditorPage.h"
-#include "gpg/result_analyse/VerifyResultAnalyse.h"
+#include "core/function/result_analyse/GpgVerifyResultAnalyse.h"
#include "ui/details/VerifyDetailsDialog.h"
class Ui_InfoBoard;
@@ -34,7 +38,7 @@ class Ui_InfoBoard;
namespace GpgFrontend::UI {
/**
- * @details Enumeration for the status of Verifylabel
+ * @details Enumeration for the status of Verify label
*/
typedef enum {
INFO_ERROR_OK = 0,
@@ -44,7 +48,7 @@ typedef enum {
} InfoBoardStatus;
/**
- * @brief Class for handling the verifylabel shown at buttom of a textedit-page
+ * @brief Class for handling the verify label shown at bottom of a textedit-page
*/
class InfoBoardWidget : public QWidget {
Q_OBJECT
@@ -57,45 +61,86 @@ class InfoBoardWidget : public QWidget {
*/
explicit InfoBoardWidget(QWidget* parent);
- void associateTextEdit(QTextEdit* edit);
+ /**
+ * @brief
+ *
+ * @param edit
+ */
+ void AssociateTextEdit(QTextEdit* edit);
- void associateTabWidget(QTabWidget* tab);
+ /**
+ * @brief
+ *
+ * @param tab
+ */
+ void AssociateTabWidget(QTabWidget* tab);
- void addOptionalAction(const QString& name,
+ /**
+ * @brief
+ *
+ * @param name
+ * @param action
+ */
+ void AddOptionalAction(const QString& name,
const std::function<void()>& action);
- void resetOptionActionsMenu();
+ /**
+ * @brief
+ *
+ */
+ void ResetOptionActionsMenu();
/**
* @details Set the text and background-color of verify notification.
*
* @param text The text to be set.
- * @param verifyLabelStatus The status of label to set the specified color.
+ * @param verify_label_status The status of label to set the specified color.
*/
- void setInfoBoard(const QString& text, InfoBoardStatus verifyLabelStatus);
+ void SetInfoBoard(const QString& text,
+ GpgFrontend::UI::InfoBoardStatus verify_label_status);
public slots:
- void slotReset();
+ /**
+ * @brief
+ *
+ */
+ void SlotReset();
/**
* @details Refresh the contents of dialog.
*/
- void slotRefresh(const QString& text, InfoBoardStatus status);
+ void SlotRefresh(const QString& text,
+ GpgFrontend::UI::InfoBoardStatus status);
private slots:
- void slotCopy();
+ /**
+ * @brief
+ *
+ */
+ void slot_copy();
- void slotSave();
+ /**
+ * @brief
+ *
+ */
+ void slot_save();
private:
- std::shared_ptr<Ui_InfoBoard> ui;
+ std::shared_ptr<Ui_InfoBoard> ui_; ///<
- QTextEdit* mTextPage{nullptr}; /** TextEdit associated to the notification */
- QTabWidget* mTabWidget{nullptr};
+ QTextEdit* m_text_page_{
+ nullptr}; ///< TextEdit associated to the notification
+ QTabWidget* m_tab_widget_{nullptr}; ///<
- void deleteWidgetsInLayout(QLayout* layout, int start_index = 0);
+ /**
+ * @brief
+ *
+ * @param layout
+ * @param start_index
+ */
+ void delete_widgets_in_layout(QLayout* layout, int start_index = 0);
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp
index 921195db..75558edc 100644
--- a/src/ui/widgets/KeyList.cpp
+++ b/src/ui/widgets/KeyList.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -27,21 +31,21 @@
#include <boost/format.hpp>
#include <utility>
-#include "gpg/GpgCoreInit.h"
-#include "gpg/function/GpgKeyGetter.h"
+#include "core/GpgCoreInit.h"
+#include "core/function/gpg/GpgKeyGetter.h"
#include "ui/SignalStation.h"
#include "ui/UserInterfaceUtils.h"
-#include "ui/settings/GlobalSettingStation.h"
+#include "core/function/GlobalSettingStation.h"
#include "ui_KeyList.h"
namespace GpgFrontend::UI {
-int KeyList::key_list_id = 2048;
+int KeyList::key_list_id_ = 2048;
KeyList::KeyList(KeyMenuAbility::AbilityType menu_ability, QWidget* parent)
: QWidget(parent),
- _m_key_list_id(key_list_id++),
- ui(std::make_shared<Ui_KeyList>()),
+ m_key_list_id_(key_list_id_++),
+ ui_(std::make_shared<Ui_KeyList>()),
menu_ability_(menu_ability) {
init();
}
@@ -49,70 +53,73 @@ KeyList::KeyList(KeyMenuAbility::AbilityType menu_ability, QWidget* parent)
void KeyList::init() {
#ifdef GPG_STANDALONE_MODE
LOG(INFO) << "GPG_STANDALONE_MODE Enabled";
- auto gpg_path = GpgFrontend::UI::GlobalSettingStation::GetInstance()
+ auto gpg_path = GpgFrontend::GlobalSettingStation::GetInstance()
.GetStandaloneGpgBinDir();
- auto db_path = GpgFrontend::UI::GlobalSettingStation::GetInstance()
+ auto db_path = GpgFrontend::GlobalSettingStation::GetInstance()
.GetStandaloneDatabaseDir();
GpgContext::CreateInstance(
_m_key_list_id, std::make_unique<GpgContext>(true, db_path.string(), true,
gpg_path.string()));
#else
- new_default_settings_channel(_m_key_list_id);
+ new_default_settings_channel(m_key_list_id_);
#endif
- ui->setupUi(this);
+ ui_->setupUi(this);
- ui->menuWidget->setHidden(!menu_ability_);
- ui->refreshKeyListButton->setHidden(~menu_ability_ & KeyMenuAbility::REFRESH);
- ui->syncButton->setHidden(~menu_ability_ & KeyMenuAbility::SYNC_PUBLIC_KEY);
- ui->uncheckButton->setHidden(~menu_ability_ & KeyMenuAbility::UNCHECK_ALL);
+ ui_->menuWidget->setHidden(!menu_ability_);
+ ui_->refreshKeyListButton->setHidden(~menu_ability_ &
+ KeyMenuAbility::REFRESH);
+ ui_->syncButton->setHidden(~menu_ability_ & KeyMenuAbility::SYNC_PUBLIC_KEY);
+ ui_->uncheckButton->setHidden(~menu_ability_ & KeyMenuAbility::UNCHECK_ALL);
- ui->keyGroupTab->clear();
- popupMenu = new QMenu(this);
+ ui_->keyGroupTab->clear();
+ popup_menu_ = new QMenu(this);
// register key database refresh signal
- connect(this, &KeyList::signalRefreshDatabase, SignalStation::GetInstance(),
- &SignalStation::KeyDatabaseRefresh);
- connect(SignalStation::GetInstance(), SIGNAL(KeyDatabaseRefresh()), this,
- SLOT(slotRefresh()));
- connect(ui->refreshKeyListButton, &QPushButton::clicked, this,
- &KeyList::slotRefresh);
- connect(ui->uncheckButton, &QPushButton::clicked, this,
- &KeyList::slotUncheckALL);
- connect(ui->checkALLButton, &QPushButton::clicked, this,
- &KeyList::slotCheckALL);
- connect(ui->syncButton, &QPushButton::clicked, this,
- &KeyList::slotSyncWithKeyServer);
- connect(this, &KeyList::signalRefreshStatusBar, SignalStation::GetInstance(),
- &SignalStation::signalRefreshStatusBar);
+ connect(this, &KeyList::SignalRefreshDatabase, SignalStation::GetInstance(),
+ &SignalStation::SignalKeyDatabaseRefresh);
+ connect(SignalStation::GetInstance(),
+ &SignalStation::SignalKeyDatabaseRefresh, this,
+ &KeyList::SlotRefresh);
+ connect(ui_->refreshKeyListButton, &QPushButton::clicked, this,
+ &KeyList::SlotRefresh);
+ connect(ui_->uncheckButton, &QPushButton::clicked, this,
+ &KeyList::uncheck_all);
+ connect(ui_->checkALLButton, &QPushButton::clicked, this,
+ &KeyList::check_all);
+ connect(ui_->syncButton, &QPushButton::clicked, this,
+ &KeyList::slot_sync_with_key_server);
+ connect(this, &KeyList::SignalRefreshStatusBar, SignalStation::GetInstance(),
+ &SignalStation::SignalRefreshStatusBar);
setAcceptDrops(true);
- ui->refreshKeyListButton->setText(_("Refresh"));
- ui->refreshKeyListButton->setToolTip(
+ ui_->refreshKeyListButton->setText(_("Refresh"));
+ ui_->refreshKeyListButton->setToolTip(
_("Refresh the key list to synchronize changes."));
- ui->syncButton->setText(_("Sync Public Key"));
- ui->syncButton->setToolTip(_("Sync public key with your default keyserver."));
- ui->uncheckButton->setText(_("Uncheck ALL"));
- ui->uncheckButton->setToolTip(
+ ui_->syncButton->setText(_("Sync Public Key"));
+ ui_->syncButton->setToolTip(
+ _("Sync public key with your default keyserver."));
+ ui_->uncheckButton->setText(_("Uncheck ALL"));
+ ui_->uncheckButton->setToolTip(
_("Cancel all checked items in the current tab at once."));
- ui->checkALLButton->setText(_("Check ALL"));
- ui->checkALLButton->setToolTip(
+ ui_->checkALLButton->setText(_("Check ALL"));
+ ui_->checkALLButton->setToolTip(
_("Check all items in the current tab at once"));
}
-void KeyList::addListGroupTab(
+void KeyList::AddListGroupTab(
const QString& name, KeyListRow::KeyType selectType,
KeyListColumn::InfoType infoType,
const std::function<bool(const GpgKey&)>& filter) {
LOG(INFO) << _("Called") << name.toStdString();
auto key_list = new QTableWidget(this);
- if (mKeyList == nullptr) {
- mKeyList = key_list;
+ if (m_key_list_ == nullptr) {
+ m_key_list_ = key_list;
}
- ui->keyGroupTab->addTab(key_list, name);
- mKeyTables.emplace_back(key_list, selectType, infoType, filter);
+ ui_->keyGroupTab->addTab(key_list, name);
+ m_key_tables_.emplace_back(key_list, selectType, infoType, filter);
key_list->setColumnCount(7);
key_list->horizontalHeader()->setSectionResizeMode(
@@ -159,39 +166,40 @@ void KeyList::addListGroupTab(
key_list->horizontalHeader()->setStretchLastSection(false);
connect(key_list, &QTableWidget::doubleClicked, this,
- &KeyList::slotDoubleClicked);
+ &KeyList::slot_double_clicked);
}
-void KeyList::slotRefresh() {
- LOG(INFO) << _("Called") << "_m_key_list_id" << _m_key_list_id;
- emit signalRefreshStatusBar(_("Refreshing Key List..."), 3000);
- auto thread = QThread::create([this, _id = _m_key_list_id]() {
- std::lock_guard<std::mutex> guard(buffered_key_list_mutex);
- _buffered_keys_list = nullptr;
+void KeyList::SlotRefresh() {
+ LOG(INFO) << _("Called") << "_m_key_list_id" << m_key_list_id_;
+ emit SignalRefreshStatusBar(_("Refreshing Key List..."), 3000);
+ auto thread = QThread::create([this, _id = m_key_list_id_]() {
+ std::lock_guard<std::mutex> guard(buffered_key_list_mutex_);
+ buffered_keys_list_ = nullptr;
// buffered keys list
- _buffered_keys_list = GpgKeyGetter::GetInstance(_id).FetchKey();
+ buffered_keys_list_ = GpgKeyGetter::GetInstance(_id).FetchKey();
});
- connect(thread, &QThread::finished, this, &KeyList::slotRefreshUI);
+ connect(thread, &QThread::finished, this, &KeyList::slot_refresh_ui);
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
- ui->refreshKeyListButton->setDisabled(true);
- ui->syncButton->setDisabled(true);
+ ui_->refreshKeyListButton->setDisabled(true);
+ ui_->syncButton->setDisabled(true);
thread->start();
}
-KeyIdArgsListPtr KeyList::getChecked(const KeyTable& key_table) {
+KeyIdArgsListPtr KeyList::GetChecked(const KeyTable& key_table) {
auto ret = std::make_unique<KeyIdArgsList>();
- for (int i = 0; i < key_table.key_list->rowCount(); i++) {
- if (key_table.key_list->item(i, 0)->checkState() == Qt::Checked) {
- ret->push_back(key_table.buffered_keys[i].GetId());
+ for (int i = 0; i < key_table.key_list_->rowCount(); i++) {
+ if (key_table.key_list_->item(i, 0)->checkState() == Qt::Checked) {
+ ret->push_back(key_table.buffered_keys_[i].GetId());
}
}
return ret;
}
-KeyIdArgsListPtr KeyList::getChecked() {
- auto key_list = qobject_cast<QTableWidget*>(ui->keyGroupTab->currentWidget());
+KeyIdArgsListPtr KeyList::GetChecked() {
+ auto key_list =
+ qobject_cast<QTableWidget*>(ui_->keyGroupTab->currentWidget());
const auto& buffered_keys =
- mKeyTables[ui->keyGroupTab->currentIndex()].buffered_keys;
+ m_key_tables_[ui_->keyGroupTab->currentIndex()].buffered_keys_;
auto ret = std::make_unique<KeyIdArgsList>();
for (int i = 0; i < key_list->rowCount(); i++) {
if (key_list->item(i, 0)->checkState() == Qt::Checked) {
@@ -201,10 +209,11 @@ KeyIdArgsListPtr KeyList::getChecked() {
return ret;
}
-KeyIdArgsListPtr KeyList::getAllPrivateKeys() {
- auto key_list = qobject_cast<QTableWidget*>(ui->keyGroupTab->currentWidget());
+KeyIdArgsListPtr KeyList::GetAllPrivateKeys() {
+ auto key_list =
+ qobject_cast<QTableWidget*>(ui_->keyGroupTab->currentWidget());
const auto& buffered_keys =
- mKeyTables[ui->keyGroupTab->currentIndex()].buffered_keys;
+ m_key_tables_[ui_->keyGroupTab->currentIndex()].buffered_keys_;
auto ret = std::make_unique<KeyIdArgsList>();
for (int i = 0; i < key_list->rowCount(); i++) {
if (key_list->item(i, 1) && buffered_keys[i].IsPrivateKey()) {
@@ -214,13 +223,14 @@ KeyIdArgsListPtr KeyList::getAllPrivateKeys() {
return ret;
}
-KeyIdArgsListPtr KeyList::getPrivateChecked() {
+KeyIdArgsListPtr KeyList::GetPrivateChecked() {
auto ret = std::make_unique<KeyIdArgsList>();
- if (ui->keyGroupTab->size().isEmpty()) return ret;
+ if (ui_->keyGroupTab->size().isEmpty()) return ret;
- auto key_list = qobject_cast<QTableWidget*>(ui->keyGroupTab->currentWidget());
+ auto key_list =
+ qobject_cast<QTableWidget*>(ui_->keyGroupTab->currentWidget());
const auto& buffered_keys =
- mKeyTables[ui->keyGroupTab->currentIndex()].buffered_keys;
+ m_key_tables_[ui_->keyGroupTab->currentIndex()].buffered_keys_;
for (int i = 0; i < key_list->rowCount(); i++) {
if ((key_list->item(i, 0)->checkState() == Qt::Checked) &&
@@ -231,24 +241,25 @@ KeyIdArgsListPtr KeyList::getPrivateChecked() {
return ret;
}
-void KeyList::setChecked(const KeyIdArgsListPtr& keyIds,
+void KeyList::SetChecked(const KeyIdArgsListPtr& keyIds,
const KeyTable& key_table) {
if (!keyIds->empty()) {
- for (int i = 0; i < key_table.key_list->rowCount(); i++) {
+ for (int i = 0; i < key_table.key_list_->rowCount(); i++) {
if (std::find(keyIds->begin(), keyIds->end(),
- key_table.buffered_keys[i].GetId()) != keyIds->end()) {
- key_table.key_list->item(i, 0)->setCheckState(Qt::Checked);
+ key_table.buffered_keys_[i].GetId()) != keyIds->end()) {
+ key_table.key_list_->item(i, 0)->setCheckState(Qt::Checked);
}
}
}
}
-void KeyList::setChecked(KeyIdArgsListPtr key_ids) {
- auto key_list = qobject_cast<QTableWidget*>(ui->keyGroupTab->currentWidget());
+void KeyList::SetChecked(KeyIdArgsListPtr key_ids) {
+ auto key_list =
+ qobject_cast<QTableWidget*>(ui_->keyGroupTab->currentWidget());
if (key_list == nullptr) return;
- if (!mKeyTables.empty()) {
- for (auto& key_table : mKeyTables) {
- if (key_table.key_list == key_list) {
+ if (!m_key_tables_.empty()) {
+ for (auto& key_table : m_key_tables_) {
+ if (key_table.key_list_ == key_list) {
key_table.SetChecked(std::move(key_ids));
break;
}
@@ -256,13 +267,14 @@ void KeyList::setChecked(KeyIdArgsListPtr key_ids) {
}
}
-KeyIdArgsListPtr KeyList::getSelected() {
+KeyIdArgsListPtr KeyList::GetSelected() {
auto ret = std::make_unique<KeyIdArgsList>();
- if (ui->keyGroupTab->size().isEmpty()) return ret;
+ if (ui_->keyGroupTab->size().isEmpty()) return ret;
- auto key_list = qobject_cast<QTableWidget*>(ui->keyGroupTab->currentWidget());
+ auto key_list =
+ qobject_cast<QTableWidget*>(ui_->keyGroupTab->currentWidget());
const auto& buffered_keys =
- mKeyTables[ui->keyGroupTab->currentIndex()].buffered_keys;
+ m_key_tables_[ui_->keyGroupTab->currentIndex()].buffered_keys_;
for (int i = 0; i < key_list->rowCount(); i++) {
if (key_list->item(i, 0)->isSelected() == 1) {
@@ -272,37 +284,37 @@ KeyIdArgsListPtr KeyList::getSelected() {
return ret;
}
-[[maybe_unused]] bool KeyList::containsPrivateKeys() {
- if (ui->keyGroupTab->size().isEmpty()) return false;
- mKeyList = qobject_cast<QTableWidget*>(ui->keyGroupTab->currentWidget());
+[[maybe_unused]] bool KeyList::ContainsPrivateKeys() {
+ if (ui_->keyGroupTab->size().isEmpty()) return false;
+ m_key_list_ = qobject_cast<QTableWidget*>(ui_->keyGroupTab->currentWidget());
- for (int i = 0; i < mKeyList->rowCount(); i++) {
- if (mKeyList->item(i, 1)) {
+ for (int i = 0; i < m_key_list_->rowCount(); i++) {
+ if (m_key_list_->item(i, 1)) {
return true;
}
}
return false;
}
-void KeyList::setColumnWidth(int row, int size) {
- if (ui->keyGroupTab->size().isEmpty()) return;
- mKeyList = qobject_cast<QTableWidget*>(ui->keyGroupTab->currentWidget());
+void KeyList::SetColumnWidth(int row, int size) {
+ if (ui_->keyGroupTab->size().isEmpty()) return;
+ m_key_list_ = qobject_cast<QTableWidget*>(ui_->keyGroupTab->currentWidget());
- mKeyList->setColumnWidth(row, size);
+ m_key_list_->setColumnWidth(row, size);
}
void KeyList::contextMenuEvent(QContextMenuEvent* event) {
- if (ui->keyGroupTab->size().isEmpty()) return;
- mKeyList = qobject_cast<QTableWidget*>(ui->keyGroupTab->currentWidget());
+ if (ui_->keyGroupTab->size().isEmpty()) return;
+ m_key_list_ = qobject_cast<QTableWidget*>(ui_->keyGroupTab->currentWidget());
- if (mKeyList->selectedItems().length() > 0) {
- popupMenu->exec(event->globalPos());
+ if (m_key_list_->selectedItems().length() > 0) {
+ popup_menu_->exec(event->globalPos());
}
}
-void KeyList::addSeparator() { popupMenu->addSeparator(); }
+void KeyList::AddSeparator() { popup_menu_->addSeparator(); }
-void KeyList::addMenuAction(QAction* act) { popupMenu->addAction(act); }
+void KeyList::AddMenuAction(QAction* act) { popup_menu_->addAction(act); }
void KeyList::dropEvent(QDropEvent* event) {
auto* dialog = new QDialog();
@@ -331,8 +343,8 @@ void KeyList::dropEvent(QDropEvent* event) {
// Buttons for ok and cancel
auto* buttonBox =
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
- connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
+ connect(buttonBox, &QDialogButtonBox::accepted, dialog, &QDialog::accept);
+ connect(buttonBox, &QDialogButtonBox::rejected, dialog, &QDialog::reject);
auto* vbox = new QVBoxLayout();
vbox->addWidget(label);
@@ -367,12 +379,12 @@ void KeyList::dropEvent(QDropEvent* event) {
<< tmp.toString().toStdString();
}
QByteArray inBuffer = file.readAll();
- this->importKeys(inBuffer);
+ this->import_keys(inBuffer);
file.close();
}
} else {
QByteArray inBuffer(event->mimeData()->text().toUtf8());
- this->importKeys(inBuffer);
+ this->import_keys(inBuffer);
}
}
@@ -383,102 +395,103 @@ void KeyList::dragEnterEvent(QDragEnterEvent* event) {
/** set background color for Keys and put them to top
*
*/
-[[maybe_unused]] void KeyList::markKeys(QStringList* keyIds) {
+[[maybe_unused]] void KeyList::MarkKeys(QStringList* keyIds) {
foreach (QString id, *keyIds) { qDebug() << "marked: " << id; }
}
-void KeyList::importKeys(const QByteArray& inBuffer) {
+void KeyList::import_keys(const QByteArray& inBuffer) {
auto std_buffer = std::make_unique<ByteArray>(inBuffer.toStdString());
GpgImportInformation result =
- GpgKeyImportExporter::GetInstance(_m_key_list_id)
+ GpgKeyImportExporter::GetInstance(m_key_list_id_)
.ImportKey(std::move(std_buffer));
new KeyImportDetailDialog(result, false, this);
}
-void KeyList::slotDoubleClicked(const QModelIndex& index) {
- if (ui->keyGroupTab->size().isEmpty()) return;
+void KeyList::slot_double_clicked(const QModelIndex& index) {
+ if (ui_->keyGroupTab->size().isEmpty()) return;
const auto& buffered_keys =
- mKeyTables[ui->keyGroupTab->currentIndex()].buffered_keys;
- if (mAction != nullptr) {
- const auto key = GpgKeyGetter::GetInstance(_m_key_list_id)
+ m_key_tables_[ui_->keyGroupTab->currentIndex()].buffered_keys_;
+ if (m_action_ != nullptr) {
+ const auto key = GpgKeyGetter::GetInstance(m_key_list_id_)
.GetKey(buffered_keys[index.row()].GetId());
- mAction(key, this);
+ m_action_(key, this);
}
}
-void KeyList::setDoubleClickedAction(
+void KeyList::SetDoubleClickedAction(
std::function<void(const GpgKey&, QWidget*)> action) {
- this->mAction = std::move(action);
+ this->m_action_ = std::move(action);
}
-std::string KeyList::getSelectedKey() {
- if (ui->keyGroupTab->size().isEmpty()) return {};
+std::string KeyList::GetSelectedKey() {
+ if (ui_->keyGroupTab->size().isEmpty()) return {};
const auto& buffered_keys =
- mKeyTables[ui->keyGroupTab->currentIndex()].buffered_keys;
+ m_key_tables_[ui_->keyGroupTab->currentIndex()].buffered_keys_;
- for (int i = 0; i < mKeyList->rowCount(); i++) {
- if (mKeyList->item(i, 0)->isSelected() == 1) {
+ for (int i = 0; i < m_key_list_->rowCount(); i++) {
+ if (m_key_list_->item(i, 0)->isSelected() == 1) {
return buffered_keys[i].GetId();
}
}
return {};
}
-void KeyList::slotRefreshUI() {
- LOG(INFO) << _("Called") << _buffered_keys_list.get();
- if (_buffered_keys_list != nullptr) {
- std::lock_guard<std::mutex> guard(buffered_key_list_mutex);
- for (auto& key_table : mKeyTables) {
- key_table.Refresh(GpgKeyGetter::GetKeysCopy(_buffered_keys_list));
+void KeyList::slot_refresh_ui() {
+ LOG(INFO) << _("Called") << buffered_keys_list_.get();
+ if (buffered_keys_list_ != nullptr) {
+ std::lock_guard<std::mutex> guard(buffered_key_list_mutex_);
+ for (auto& key_table : m_key_tables_) {
+ key_table.Refresh(GpgKeyGetter::GetKeysCopy(buffered_keys_list_));
}
}
- emit signalRefreshStatusBar(_("Key List Refreshed."), 1000);
- ui->refreshKeyListButton->setDisabled(false);
- ui->syncButton->setDisabled(false);
+ emit SignalRefreshStatusBar(_("Key List Refreshed."), 1000);
+ ui_->refreshKeyListButton->setDisabled(false);
+ ui_->syncButton->setDisabled(false);
}
-void KeyList::slotSyncWithKeyServer() {
+void KeyList::slot_sync_with_key_server() {
KeyIdArgsList key_ids;
{
- std::lock_guard<std::mutex> guard(buffered_key_list_mutex);
- for (const auto& key : *_buffered_keys_list) {
+ std::lock_guard<std::mutex> guard(buffered_key_list_mutex_);
+ for (const auto& key : *buffered_keys_list_) {
if (!(key.IsPrivateKey() && key.IsHasMasterKey()))
key_ids.push_back(key.GetId());
}
}
- ui->refreshKeyListButton->setDisabled(true);
- ui->syncButton->setDisabled(true);
+ ui_->refreshKeyListButton->setDisabled(true);
+ ui_->syncButton->setDisabled(true);
- emit signalRefreshStatusBar(_("Syncing Key List..."), 3000);
- CommonUtils::slotImportKeyFromKeyServer(
- _m_key_list_id, key_ids,
+ emit SignalRefreshStatusBar(_("Syncing Key List..."), 3000);
+ CommonUtils::SlotImportKeyFromKeyServer(
+ m_key_list_id_, key_ids,
[=](const std::string& key_id, const std::string& status,
size_t current_index, size_t all_index) {
LOG(INFO) << _("Called") << key_id << status << current_index
<< all_index;
- auto key = GpgKeyGetter::GetInstance(_m_key_list_id).GetKey(key_id);
+ auto key = GpgKeyGetter::GetInstance(m_key_list_id_).GetKey(key_id);
boost::format status_str = boost::format(_("Sync [%1%/%2%] %3% %4%")) %
current_index % all_index %
key.GetUIDs()->front().GetUID() % status;
- emit signalRefreshStatusBar(status_str.str().c_str(), 1500);
+ emit SignalRefreshStatusBar(status_str.str().c_str(), 1500);
if (current_index == all_index) {
- ui->syncButton->setDisabled(false);
- ui->refreshKeyListButton->setDisabled(false);
- emit signalRefreshStatusBar(_("Key List Sync Done."), 3000);
- emit signalRefreshDatabase();
+ ui_->syncButton->setDisabled(false);
+ ui_->refreshKeyListButton->setDisabled(false);
+ emit SignalRefreshStatusBar(_("Key List Sync Done."), 3000);
+ emit SignalRefreshDatabase();
}
});
}
-void KeyList::slotUncheckALL() {
- auto key_list = qobject_cast<QTableWidget*>(ui->keyGroupTab->currentWidget());
+void KeyList::uncheck_all() {
+ auto key_list =
+ qobject_cast<QTableWidget*>(ui_->keyGroupTab->currentWidget());
if (key_list == nullptr) return;
- if (!mKeyTables.empty()) {
- for (auto& key_table : mKeyTables) {
- if (key_table.key_list == key_list) {
+ if (!m_key_tables_.empty()) {
+ for (auto& key_table : m_key_tables_) {
+ if (key_table.key_list_ == key_list) {
key_table.UncheckALL();
break;
}
@@ -486,12 +499,13 @@ void KeyList::slotUncheckALL() {
}
}
-void KeyList::slotCheckALL() {
- auto key_list = qobject_cast<QTableWidget*>(ui->keyGroupTab->currentWidget());
+void KeyList::check_all() {
+ auto key_list =
+ qobject_cast<QTableWidget*>(ui_->keyGroupTab->currentWidget());
if (key_list == nullptr) return;
- if (!mKeyTables.empty()) {
- for (auto& key_table : mKeyTables) {
- if (key_table.key_list == key_list) {
+ if (!m_key_tables_.empty()) {
+ for (auto& key_table : m_key_tables_) {
+ if (key_table.key_list_ == key_list) {
key_table.CheckALL();
break;
}
@@ -504,9 +518,9 @@ KeyIdArgsListPtr& KeyTable::GetChecked() {
if (checked_key_ids_ == nullptr)
checked_key_ids_ = std::make_unique<KeyIdArgsList>();
auto& ret = checked_key_ids_;
- for (int i = 0; i < key_list->rowCount(); i++) {
- auto key_id = buffered_keys[i].GetId();
- if (key_list->item(i, 0)->checkState() == Qt::Checked &&
+ for (int i = 0; i < key_list_->rowCount(); i++) {
+ auto key_id = buffered_keys_[i].GetId();
+ if (key_list_->item(i, 0)->checkState() == Qt::Checked &&
std::find(ret->begin(), ret->end(), key_id) == ret->end()) {
ret->push_back(key_id);
}
@@ -525,8 +539,8 @@ void KeyTable::Refresh(KeyLinkListPtr m_keys) {
auto& checked_key_list = GetChecked();
// while filling the table, sort enabled causes errors
- key_list->setSortingEnabled(false);
- key_list->clearContents();
+ key_list_->setSortingEnabled(false);
+ key_list_->clearContents();
// Optimization for copy
KeyLinkListPtr keys = nullptr;
@@ -539,13 +553,13 @@ void KeyTable::Refresh(KeyLinkListPtr m_keys) {
int row_count = 0;
while (it != keys->end()) {
- if (filter != nullptr) {
- if (!filter(*it)) {
+ if (filter_ != nullptr) {
+ if (!filter_(*it)) {
it = keys->erase(it);
continue;
}
}
- if (select_type == KeyListRow::ONLY_SECRET_KEY && !it->IsPrivateKey()) {
+ if (select_type_ == KeyListRow::ONLY_SECRET_KEY && !it->IsPrivateKey()) {
it = keys->erase(it);
continue;
}
@@ -553,12 +567,12 @@ void KeyTable::Refresh(KeyLinkListPtr m_keys) {
it++;
}
- key_list->setRowCount(row_count);
+ key_list_->setRowCount(row_count);
int row_index = 0;
it = keys->begin();
- auto& table_buffered_keys = buffered_keys;
+ auto& table_buffered_keys = buffered_keys_;
table_buffered_keys.clear();
@@ -570,7 +584,7 @@ void KeyTable::Refresh(KeyLinkListPtr m_keys) {
Qt::ItemIsSelectable);
tmp0->setTextAlignment(Qt::AlignCenter);
tmp0->setCheckState(Qt::Unchecked);
- key_list->setItem(row_index, 0, tmp0);
+ key_list_->setItem(row_index, 0, tmp0);
QString type_str;
QTextStream type_steam(&type_str);
@@ -589,12 +603,12 @@ void KeyTable::Refresh(KeyLinkListPtr m_keys) {
}
auto* tmp1 = new QTableWidgetItem(type_str);
- key_list->setItem(row_index, 1, tmp1);
+ key_list_->setItem(row_index, 1, tmp1);
auto* tmp2 = new QTableWidgetItem(QString::fromStdString(it->GetName()));
- key_list->setItem(row_index, 2, tmp2);
+ key_list_->setItem(row_index, 2, tmp2);
auto* tmp3 = new QTableWidgetItem(QString::fromStdString(it->GetEmail()));
- key_list->setItem(row_index, 3, tmp3);
+ key_list_->setItem(row_index, 3, tmp3);
QString usage;
QTextStream usage_steam(&usage);
@@ -606,17 +620,17 @@ void KeyTable::Refresh(KeyLinkListPtr m_keys) {
auto* temp_usage = new QTableWidgetItem(usage);
temp_usage->setTextAlignment(Qt::AlignCenter);
- key_list->setItem(row_index, 4, temp_usage);
+ key_list_->setItem(row_index, 4, temp_usage);
auto* temp_validity =
new QTableWidgetItem(QString::fromStdString(it->GetOwnerTrust()));
temp_validity->setTextAlignment(Qt::AlignCenter);
- key_list->setItem(row_index, 5, temp_validity);
+ key_list_->setItem(row_index, 5, temp_validity);
auto* temp_fpr =
new QTableWidgetItem(QString::fromStdString(it->GetFingerprint()));
temp_fpr->setTextAlignment(Qt::AlignCenter);
- key_list->setItem(row_index, 6, temp_fpr);
+ key_list_->setItem(row_index, 6, temp_fpr);
// strike out expired keys
if (it->IsExpired() || it->IsRevoked()) {
@@ -635,10 +649,10 @@ void KeyTable::Refresh(KeyLinkListPtr m_keys) {
}
if (!checked_key_list->empty()) {
- for (int i = 0; i < key_list->rowCount(); i++) {
+ for (int i = 0; i < key_list_->rowCount(); i++) {
if (std::find(checked_key_list->begin(), checked_key_list->end(),
- buffered_keys[i].GetId()) != checked_key_list->end()) {
- key_list->item(i, 0)->setCheckState(Qt::Checked);
+ buffered_keys_[i].GetId()) != checked_key_list->end()) {
+ key_list_->item(i, 0)->setCheckState(Qt::Checked);
}
}
}
@@ -647,14 +661,14 @@ void KeyTable::Refresh(KeyLinkListPtr m_keys) {
}
void KeyTable::UncheckALL() const {
- for (int i = 0; i < key_list->rowCount(); i++) {
- key_list->item(i, 0)->setCheckState(Qt::Unchecked);
+ for (int i = 0; i < key_list_->rowCount(); i++) {
+ key_list_->item(i, 0)->setCheckState(Qt::Unchecked);
}
}
void KeyTable::CheckALL() const {
- for (int i = 0; i < key_list->rowCount(); i++) {
- key_list->item(i, 0)->setCheckState(Qt::Checked);
+ for (int i = 0; i < key_list_->rowCount(); i++) {
+ key_list_->item(i, 0)->setCheckState(Qt::Checked);
}
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/KeyList.h b/src/ui/widgets/KeyList.h
index 4b41decd..d79f9331 100644
--- a/src/ui/widgets/KeyList.h
+++ b/src/ui/widgets/KeyList.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -27,147 +31,357 @@
#include <utility>
-#include "gpg/GpgContext.h"
-#include "ui/KeyImportDetailDialog.h"
+#include "core/GpgContext.h"
+#include "ui/import_export/KeyImportDetailDialog.h"
class Ui_KeyList;
namespace GpgFrontend::UI {
+/**
+ * @brief
+ *
+ */
struct KeyListRow {
using KeyType = unsigned int;
- static const KeyType SECRET_OR_PUBLIC_KEY = 0;
- static const KeyType ONLY_SECRET_KEY = 1;
+ static const KeyType SECRET_OR_PUBLIC_KEY = 0; ///<
+ static const KeyType ONLY_SECRET_KEY = 1; ///<
};
+/**
+ * @brief
+ *
+ */
struct KeyListColumn {
using InfoType = unsigned int;
- static constexpr InfoType ALL = ~0;
- static constexpr InfoType TYPE = 1 << 0;
- static constexpr InfoType NAME = 1 << 1;
- static constexpr InfoType EmailAddress = 1 << 2;
- static constexpr InfoType Usage = 1 << 3;
- static constexpr InfoType Validity = 1 << 4;
- static constexpr InfoType FingerPrint = 1 << 5;
+ static constexpr InfoType ALL = ~0; ///<
+ static constexpr InfoType TYPE = 1 << 0; ///<
+ static constexpr InfoType NAME = 1 << 1; ///<
+ static constexpr InfoType EmailAddress = 1 << 2; ///<
+ static constexpr InfoType Usage = 1 << 3; ///<
+ static constexpr InfoType Validity = 1 << 4; ///<
+ static constexpr InfoType FingerPrint = 1 << 5; ///<
};
+/**
+ * @brief
+ *
+ */
struct KeyMenuAbility {
using AbilityType = unsigned int;
- static constexpr AbilityType ALL = ~0;
- static constexpr AbilityType NONE = 0;
- static constexpr AbilityType REFRESH = 1 << 0;
- static constexpr AbilityType SYNC_PUBLIC_KEY = 1 << 1;
- static constexpr AbilityType UNCHECK_ALL = 1 << 3;
- static constexpr AbilityType CHECK_ALL = 1 << 5;
+ static constexpr AbilityType ALL = ~0; ///<
+ static constexpr AbilityType NONE = 0; ///<
+ static constexpr AbilityType REFRESH = 1 << 0; ///<
+ static constexpr AbilityType SYNC_PUBLIC_KEY = 1 << 1; ///<
+ static constexpr AbilityType UNCHECK_ALL = 1 << 3; ///<
+ static constexpr AbilityType CHECK_ALL = 1 << 5; ///<
};
+/**
+ * @brief
+ *
+ */
struct KeyTable {
- QTableWidget* key_list;
- KeyListRow::KeyType select_type;
- KeyListColumn::InfoType info_type;
- std::vector<GpgKey> buffered_keys;
- std::function<bool(const GpgKey&)> filter;
- KeyIdArgsListPtr checked_key_ids_;
-
+ QTableWidget* key_list_; ///<
+ KeyListRow::KeyType select_type_; ///<
+ KeyListColumn::InfoType info_type_; ///<
+ std::vector<GpgKey> buffered_keys_; ///<
+ std::function<bool(const GpgKey&)> filter_; ///<
+ KeyIdArgsListPtr checked_key_ids_; ///<
+
+ /**
+ * @brief Construct a new Key Table object
+ *
+ * @param _key_list
+ * @param _select_type
+ * @param _info_type
+ * @param _filter
+ */
KeyTable(
QTableWidget* _key_list, KeyListRow::KeyType _select_type,
KeyListColumn::InfoType _info_type,
std::function<bool(const GpgKey&)> _filter = [](const GpgKey&) -> bool {
return true;
})
- : key_list(_key_list),
- select_type(_select_type),
- info_type(_info_type),
- filter(std::move(_filter)) {}
-
+ : key_list_(_key_list),
+ select_type_(_select_type),
+ info_type_(_info_type),
+ filter_(std::move(_filter)) {}
+
+ /**
+ * @brief
+ *
+ * @param m_keys
+ */
void Refresh(KeyLinkListPtr m_keys = nullptr);
+ /**
+ * @brief Get the Checked object
+ *
+ * @return KeyIdArgsListPtr&
+ */
KeyIdArgsListPtr& GetChecked();
+ /**
+ * @brief
+ *
+ */
void UncheckALL() const;
+ /**
+ * @brief
+ *
+ */
void CheckALL() const;
+ /**
+ * @brief Set the Checked object
+ *
+ * @param key_ids
+ */
void SetChecked(KeyIdArgsListPtr key_ids);
};
+/**
+ * @brief
+ *
+ */
class KeyList : public QWidget {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Key List object
+ *
+ * @param menu_ability
+ * @param parent
+ */
explicit KeyList(KeyMenuAbility::AbilityType menu_ability,
QWidget* parent = nullptr);
- void addListGroupTab(
+ /**
+ * @brief
+ *
+ * @param name
+ * @param selectType
+ * @param infoType
+ * @param filter
+ */
+ void AddListGroupTab(
const QString& name,
KeyListRow::KeyType selectType = KeyListRow::SECRET_OR_PUBLIC_KEY,
KeyListColumn::InfoType infoType = KeyListColumn::ALL,
const std::function<bool(const GpgKey&)>& filter =
[](const GpgKey&) -> bool { return true; });
- void setDoubleClickedAction(
+ /**
+ * @brief Set the Double Clicked Action object
+ *
+ * @param action
+ */
+ void SetDoubleClickedAction(
std::function<void(const GpgKey&, QWidget*)> action);
- void setColumnWidth(int row, int size);
- void addMenuAction(QAction* act);
- void addSeparator();
+ /**
+ * @brief Set the Column Width object
+ *
+ * @param row
+ * @param size
+ */
+ void SetColumnWidth(int row, int size);
+
+ /**
+ * @brief
+ *
+ * @param act
+ */
+ void AddMenuAction(QAction* act);
+
+ /**
+ * @brief
+ *
+ */
+ void AddSeparator();
+
+ /**
+ * @brief Get the Checked object
+ *
+ * @return KeyIdArgsListPtr
+ */
+ KeyIdArgsListPtr GetChecked();
+
+ /**
+ * @brief Get the Checked object
+ *
+ * @param key_table
+ * @return KeyIdArgsListPtr
+ */
+ static KeyIdArgsListPtr GetChecked(const KeyTable& key_table);
+
+ /**
+ * @brief Get the Private Checked object
+ *
+ * @return KeyIdArgsListPtr
+ */
+ KeyIdArgsListPtr GetPrivateChecked();
+
+ /**
+ * @brief Get the All Private Keys object
+ *
+ * @return KeyIdArgsListPtr
+ */
+ KeyIdArgsListPtr GetAllPrivateKeys();
+
+ /**
+ * @brief Set the Checked object
+ *
+ * @param key_ids
+ */
+ void SetChecked(KeyIdArgsListPtr key_ids);
- KeyIdArgsListPtr getChecked();
- static KeyIdArgsListPtr getChecked(const KeyTable& key_table);
- KeyIdArgsListPtr getPrivateChecked();
- KeyIdArgsListPtr getAllPrivateKeys();
- void setChecked(KeyIdArgsListPtr key_ids);
- static void setChecked(const KeyIdArgsListPtr& keyIds,
+ /**
+ * @brief Set the Checked object
+ *
+ * @param keyIds
+ * @param key_table
+ */
+ static void SetChecked(const KeyIdArgsListPtr& keyIds,
const KeyTable& key_table);
- KeyIdArgsListPtr getSelected();
- std::string getSelectedKey();
-
- [[maybe_unused]] static void markKeys(QStringList* keyIds);
- [[maybe_unused]] bool containsPrivateKeys();
+ /**
+ * @brief Get the Selected object
+ *
+ * @return KeyIdArgsListPtr
+ */
+ KeyIdArgsListPtr GetSelected();
+
+ /**
+ * @brief Get the Selected Key object
+ *
+ * @return std::string
+ */
+ std::string GetSelectedKey();
+
+ /**
+ * @brief
+ *
+ * @param keyIds
+ */
+ [[maybe_unused]] static void MarkKeys(QStringList* keyIds);
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[maybe_unused]] bool ContainsPrivateKeys();
signals:
- void signalRefreshStatusBar(const QString& message, int timeout);
- void signalRefreshDatabase();
+ /**
+ * @brief
+ *
+ * @param message
+ * @param timeout
+ */
+ void SignalRefreshStatusBar(const QString& message, int timeout);
+
+ /**
+ * @brief
+ *
+ */
+ void SignalRefreshDatabase();
public slots:
- void slotRefresh();
+ /**
+ * @brief
+ *
+ */
+ void SlotRefresh();
private:
+ /**
+ * @brief
+ *
+ */
void init();
- void importKeys(const QByteArray& inBuffer);
- void slotUncheckALL();
- void slotCheckALL();
-
- static int key_list_id;
- int _m_key_list_id;
- std::mutex buffered_key_list_mutex;
-
- std::shared_ptr<Ui_KeyList> ui;
- QTableWidget* mKeyList{};
- std::vector<KeyTable> mKeyTables;
- QMenu* popupMenu{};
- GpgFrontend::KeyLinkListPtr _buffered_keys_list;
- std::function<void(const GpgKey&, QWidget*)> mAction = nullptr;
- KeyMenuAbility::AbilityType menu_ability_ = KeyMenuAbility::ALL;
- private slots:
-
- void slotDoubleClicked(const QModelIndex& index);
+ /**
+ * @brief
+ *
+ * @param inBuffer
+ */
+ void import_keys(const QByteArray& inBuffer);
+
+ /**
+ * @brief
+ *
+ */
+ void uncheck_all();
+
+ /**
+ * @brief
+ *
+ */
+ void check_all();
+
+ static int key_list_id_; ///<
+ int m_key_list_id_; ///<
+ std::mutex buffered_key_list_mutex_; ///<
+
+ std::shared_ptr<Ui_KeyList> ui_; ///<
+ QTableWidget* m_key_list_{}; ///<
+ std::vector<KeyTable> m_key_tables_; ///<
+ QMenu* popup_menu_{}; ///<
+ GpgFrontend::KeyLinkListPtr buffered_keys_list_; ///<
+ std::function<void(const GpgKey&, QWidget*)> m_action_ = nullptr; ///<
+ KeyMenuAbility::AbilityType menu_ability_ = KeyMenuAbility::ALL; ///<
- void slotRefreshUI();
+ private slots:
- void slotSyncWithKeyServer();
+ /**
+ * @brief
+ *
+ * @param index
+ */
+ void slot_double_clicked(const QModelIndex& index);
+
+ /**
+ * @brief
+ *
+ */
+ void slot_refresh_ui();
+
+ /**
+ * @brief
+ *
+ */
+ void slot_sync_with_key_server();
protected:
+ /**
+ * @brief
+ *
+ * @param event
+ */
void contextMenuEvent(QContextMenuEvent* event) override;
+ /**
+ * @brief
+ *
+ * @param event
+ */
void dragEnterEvent(QDragEnterEvent* event) override;
+ /**
+ * @brief
+ *
+ * @param event
+ */
void dropEvent(QDropEvent* event) override;
};
diff --git a/src/ui/widgets/PlainTextEditorPage.cpp b/src/ui/widgets/PlainTextEditorPage.cpp
index 6fe8977e..0161bf91 100644
--- a/src/ui/widgets/PlainTextEditorPage.cpp
+++ b/src/ui/widgets/PlainTextEditorPage.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -24,76 +26,76 @@
#include "ui/widgets/PlainTextEditorPage.h"
-#include <boost/filesystem.hpp>
+#include <encoding-detect/TextEncodingDetect.h>
+
#include <boost/format.hpp>
#include <utility>
-#include "ui/encoding/TextEncodingDetect.h"
#include "ui/thread/FileReadThread.h"
#include "ui_PlainTextEditor.h"
namespace GpgFrontend::UI {
-PlainTextEditorPage::PlainTextEditorPage(QString filePath, QWidget* parent)
+PlainTextEditorPage::PlainTextEditorPage(QString filePath, QWidget *parent)
: QWidget(parent),
- ui(std::make_shared<Ui_PlainTextEditor>()),
+ ui_(std::make_shared<Ui_PlainTextEditor>()),
full_file_path_(std::move(filePath)) {
- ui->setupUi(this);
+ ui_->setupUi(this);
if (full_file_path_.isEmpty()) read_done_ = true;
- ui->textPage->setFocus();
- ui->loadingLabel->setHidden(true);
+ ui_->textPage->setFocus();
+ ui_->loadingLabel->setHidden(true);
// Front in same width
this->setFont({"Courier"});
this->setAttribute(Qt::WA_DeleteOnClose);
- this->ui->characterLabel->setText(_("0 character"));
- this->ui->lfLabel->setText(_("None"));
- this->ui->encodingLabel->setText(_("Binary"));
+ this->ui_->characterLabel->setText(_("0 character"));
+ this->ui_->lfLabel->setText(_("None"));
+ this->ui_->encodingLabel->setText(_("Binary"));
- connect(ui->textPage, &QPlainTextEdit::textChanged, this, [=]() {
+ connect(ui_->textPage, &QPlainTextEdit::textChanged, this, [=]() {
if (!read_done_) return;
- auto text = ui->textPage->document()->toPlainText();
+ auto text = ui_->textPage->document()->toPlainText();
auto str = boost::format(_("%1% character(s)")) % text.size();
- this->ui->characterLabel->setText(str.str().c_str());
-
+ this->ui_->characterLabel->setText(str.str().c_str());
+
detect_cr_lf(text);
detect_encoding(text.toStdString());
});
- ui->loadingLabel->setText(_("Loading..."));
+ ui_->loadingLabel->setText(_("Loading..."));
}
-const QString& PlainTextEditorPage::getFilePath() const {
+const QString &PlainTextEditorPage::GetFilePath() const {
return full_file_path_;
}
-QPlainTextEdit* PlainTextEditorPage::getTextPage() { return ui->textPage; }
+QPlainTextEdit *PlainTextEditorPage::GetTextPage() { return ui_->textPage; }
-void PlainTextEditorPage::setFilePath(const QString& filePath) {
+void PlainTextEditorPage::SetFilePath(const QString &filePath) {
full_file_path_ = filePath;
}
-void PlainTextEditorPage::showNotificationWidget(QWidget* widget,
- const char* className) {
+void PlainTextEditorPage::ShowNotificationWidget(QWidget *widget,
+ const char *className) {
widget->setProperty(className, true);
- ui->verticalLayout->addWidget(widget);
+ ui_->verticalLayout->addWidget(widget);
}
-void PlainTextEditorPage::closeNoteByClass(const char* className) {
- QList<QWidget*> widgets = findChildren<QWidget*>();
- for (QWidget* widget : widgets) {
+void PlainTextEditorPage::CloseNoteByClass(const char *className) {
+ QList<QWidget *> widgets = findChildren<QWidget *>();
+ for (QWidget *widget : widgets) {
if (widget->property(className) == true) {
widget->close();
}
}
}
-void PlainTextEditorPage::slotFormatGpgHeader() {
- QString content = ui->textPage->toPlainText();
+void PlainTextEditorPage::slot_format_gpg_header() {
+ QString content = ui_->textPage->toPlainText();
// Get positions of the gpg-headers, if they exist
int start = content.indexOf(GpgFrontend::GpgConstants::PGP_SIGNED_BEGIN);
@@ -101,11 +103,11 @@ void PlainTextEditorPage::slotFormatGpgHeader() {
content.indexOf(GpgFrontend::GpgConstants::PGP_SIGNATURE_BEGIN);
int endSig = content.indexOf(GpgFrontend::GpgConstants::PGP_SIGNATURE_END);
- if (start < 0 || startSig < 0 || endSig < 0 || signMarked) {
+ if (start < 0 || startSig < 0 || endSig < 0 || sign_marked_) {
return;
}
- signMarked = true;
+ sign_marked_ = true;
// Set the fontstyle for the header
QTextCharFormat signFormat;
@@ -113,7 +115,7 @@ void PlainTextEditorPage::slotFormatGpgHeader() {
signFormat.setFontPointSize(9);
// set font style for the signature
- QTextCursor cursor(ui->textPage->document());
+ QTextCursor cursor(ui_->textPage->document());
cursor.setPosition(startSig, QTextCursor::MoveAnchor);
cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, endSig);
cursor.setCharFormat(signFormat);
@@ -130,20 +132,20 @@ void PlainTextEditorPage::ReadFile() {
read_done_ = false;
read_bytes_ = 0;
- ui->textPage->setEnabled(false);
- ui->textPage->setReadOnly(true);
- ui->textPage->blockSignals(true);
- ui->loadingLabel->setHidden(false);
- ui->textPage->document()->blockSignals(true);
+ ui_->textPage->setEnabled(false);
+ ui_->textPage->setReadOnly(true);
+ ui_->textPage->blockSignals(true);
+ ui_->loadingLabel->setHidden(false);
+ ui_->textPage->document()->blockSignals(true);
- auto text_page = this->getTextPage();
+ auto text_page = this->GetTextPage();
text_page->setReadOnly(true);
auto thread = new FileReadThread(this->full_file_path_.toStdString());
- connect(thread, &FileReadThread::sendReadBlock, this,
- &PlainTextEditorPage::slotInsertText);
+ connect(thread, &FileReadThread::SignalSendReadBlock, this,
+ &PlainTextEditorPage::slot_insert_text);
- connect(thread, &FileReadThread::readDone, this, [=]() {
+ connect(thread, &FileReadThread::SignalReadDone, this, [=]() {
LOG(INFO) << "thread read done";
if (!binary_mode_) {
text_page->setReadOnly(false);
@@ -155,23 +157,23 @@ void PlainTextEditorPage::ReadFile() {
thread->deleteLater();
read_done_ = true;
read_thread_ = nullptr;
- ui->textPage->setEnabled(true);
+ ui_->textPage->setEnabled(true);
text_page->document()->setModified(false);
- ui->textPage->blockSignals(false);
- ui->textPage->document()->blockSignals(false);
- ui->loadingLabel->setHidden(true);
+ ui_->textPage->blockSignals(false);
+ ui_->textPage->document()->blockSignals(false);
+ ui_->loadingLabel->setHidden(true);
});
connect(this, &PlainTextEditorPage::destroyed, [=]() {
LOG(INFO) << "request interruption for read thread";
- thread->requestInterruption();
+ if (read_thread_ && thread->isRunning()) thread->requestInterruption();
read_thread_ = nullptr;
});
this->read_thread_ = thread;
thread->start();
}
-std::string binary_to_string(const std::string& source) {
+std::string binary_to_string(const std::string &source) {
static char syms[] = "0123456789ABCDEF";
std::stringstream ss;
for (unsigned char c : source)
@@ -179,7 +181,7 @@ std::string binary_to_string(const std::string& source) {
return ss.str();
}
-void PlainTextEditorPage::slotInsertText(const std::string& data) {
+void PlainTextEditorPage::slot_insert_text(const std::string &data) {
LOG(INFO) << "data size" << data.size();
read_bytes_ += data.size();
// If binary format is detected, the entire file is converted to binary format
@@ -192,22 +194,22 @@ void PlainTextEditorPage::slotInsertText(const std::string& data) {
if (binary_mode_) {
if (if_last_binary_mode != binary_mode_) {
auto text_buffer =
- ui->textPage->document()->toRawText().toLocal8Bit().toStdString();
- ui->textPage->clear();
- this->getTextPage()->insertPlainText(
+ ui_->textPage->document()->toRawText().toLocal8Bit().toStdString();
+ ui_->textPage->clear();
+ this->GetTextPage()->insertPlainText(
binary_to_string(text_buffer).c_str());
- this->ui->lfLabel->setText("None");
+ this->ui_->lfLabel->setText("None");
}
- this->getTextPage()->insertPlainText(binary_to_string(data).c_str());
+ this->GetTextPage()->insertPlainText(binary_to_string(data).c_str());
auto str = boost::format(_("%1% byte(s)")) % read_bytes_;
- this->ui->characterLabel->setText(str.str().c_str());
+ this->ui_->characterLabel->setText(str.str().c_str());
} else {
- this->getTextPage()->insertPlainText(data.c_str());
+ this->GetTextPage()->insertPlainText(data.c_str());
- auto text = this->getTextPage()->toPlainText();
+ auto text = this->GetTextPage()->toPlainText();
auto str = boost::format(_("%1% character(s)")) % text.size();
- this->ui->characterLabel->setText(str.str().c_str());
+ this->ui_->characterLabel->setText(str.str().c_str());
detect_cr_lf(text);
}
}
@@ -219,39 +221,39 @@ void PlainTextEditorPage::PrepareToDestroy() {
}
}
-void PlainTextEditorPage::detect_encoding(const std::string& data) {
+void PlainTextEditorPage::detect_encoding(const std::string &data) {
AutoIt::Common::TextEncodingDetect text_detect;
AutoIt::Common::TextEncodingDetect::Encoding encoding =
- text_detect.DetectEncoding((unsigned char*)(data.data()), data.size());
+ text_detect.DetectEncoding((unsigned char *)(data.data()), data.size());
if (encoding == AutoIt::Common::TextEncodingDetect::None) {
binary_mode_ = true;
- ui->encodingLabel->setText(_("Binary"));
+ ui_->encodingLabel->setText(_("Binary"));
} else if (encoding == AutoIt::Common::TextEncodingDetect::ASCII) {
- ui->encodingLabel->setText(_("ASCII(7 bits)"));
+ ui_->encodingLabel->setText(_("ASCII(7 bits)"));
} else if (encoding == AutoIt::Common::TextEncodingDetect::ANSI) {
- ui->encodingLabel->setText(_("ASCII(8 bits)"));
+ ui_->encodingLabel->setText(_("ASCII(8 bits)"));
} else if (encoding == AutoIt::Common::TextEncodingDetect::UTF8_BOM ||
encoding == AutoIt::Common::TextEncodingDetect::UTF8_NOBOM) {
- ui->encodingLabel->setText(_("UTF-8"));
+ ui_->encodingLabel->setText(_("UTF-8"));
} else if (encoding == AutoIt::Common::TextEncodingDetect::UTF16_LE_BOM ||
encoding == AutoIt::Common::TextEncodingDetect::UTF16_LE_NOBOM) {
- ui->encodingLabel->setText(_("UTF-16"));
+ ui_->encodingLabel->setText(_("UTF-16"));
} else if (encoding == AutoIt::Common::TextEncodingDetect::UTF16_BE_BOM ||
encoding == AutoIt::Common::TextEncodingDetect::UTF16_BE_NOBOM) {
- ui->encodingLabel->setText(_("UTF-16(BE)"));
+ ui_->encodingLabel->setText(_("UTF-16(BE)"));
}
}
-void PlainTextEditorPage::detect_cr_lf(const QString& data) {
+void PlainTextEditorPage::detect_cr_lf(const QString &data) {
if (binary_mode_) {
- this->ui->lfLabel->setText("None");
+ this->ui_->lfLabel->setText("None");
return;
}
if (data.contains("\r\n")) {
- this->ui->lfLabel->setText("CRLF");
+ this->ui_->lfLabel->setText("CRLF");
} else {
- this->ui->lfLabel->setText("LF");
+ this->ui_->lfLabel->setText("LF");
}
}
diff --git a/src/ui/widgets/PlainTextEditorPage.h b/src/ui/widgets/PlainTextEditorPage.h
index 24823c06..f73e2282 100644
--- a/src/ui/widgets/PlainTextEditorPage.h
+++ b/src/ui/widgets/PlainTextEditorPage.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,26 +8,28 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef __EDITORPAGE_H__
#define __EDITORPAGE_H__
-#include "gpg/GpgConstants.h"
+#include "core/GpgConstants.h"
#include "ui/GpgFrontendUI.h"
class Ui_PlainTextEditor;
@@ -51,19 +55,19 @@ class PlainTextEditorPage : public QWidget {
/**
* @details Get the filepath of the currently activated tab.
*/
- [[nodiscard]] const QString& getFilePath() const;
+ [[nodiscard]] const QString& GetFilePath() const;
/**
* @details Set filepath of currently activated tab.
*
* @param filePath The path to be set
*/
- void setFilePath(const QString& filePath);
+ void SetFilePath(const QString& filePath);
/**
* @details Return pointer tp the textedit of the currently activated tab.
*/
- QPlainTextEdit* getTextPage();
+ QPlainTextEdit* GetTextPage();
/**
* @details Show additional widget at buttom of currently active tab
@@ -71,32 +75,56 @@ class PlainTextEditorPage : public QWidget {
* @param widget The widget to be added
* @param className The name to handle the added widget
*/
- void showNotificationWidget(QWidget* widget, const char* className);
+ void ShowNotificationWidget(QWidget* widget, const char* className);
/**
* @details Hide all widgets with the given className
*
* @param className The classname of the widgets to hide
*/
- void closeNoteByClass(const char* className);
+ void CloseNoteByClass(const char* className);
+ /**
+ * @brief
+ *
+ */
void ReadFile();
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
[[nodiscard]] bool ReadDone() const { return this->read_done_; }
+ /**
+ * @brief
+ *
+ */
void PrepareToDestroy();
private:
- std::shared_ptr<Ui_PlainTextEditor> ui;
- QString full_file_path_; /** The path to the file handled in the tab */
- bool signMarked{}; /** true, if the signed header is marked, false if not */
- bool read_done_ = false;
- QThread* read_thread_ = nullptr;
- bool binary_mode_ = false;
- size_t read_bytes_ = 0;
+ std::shared_ptr<Ui_PlainTextEditor> ui_; ///<
+ QString full_file_path_; ///< The path to the file handled in the tab
+ bool sign_marked_{}; ///< true, if the signed header is marked, false if not
+ bool read_done_ = false; ///<
+ QThread* read_thread_ = nullptr; ///<
+ bool binary_mode_ = false; ///<
+ size_t read_bytes_ = 0; ///<
+ /**
+ * @brief
+ *
+ * @param data
+ */
void detect_encoding(const std::string& data);
+ /**
+ * @brief
+ *
+ * @param data
+ */
void detect_cr_lf(const QString& data);
private slots:
@@ -104,9 +132,14 @@ class PlainTextEditorPage : public QWidget {
/**
* @details Format the gpg header in another font-style
*/
- void slotFormatGpgHeader();
+ void slot_format_gpg_header();
- void slotInsertText(const std::string& data);
+ /**
+ * @brief
+ *
+ * @param data
+ */
+ void slot_insert_text(const std::string& data);
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/SignersPicker.cpp b/src/ui/widgets/SignersPicker.cpp
index d46bd4ad..75f6b2ba 100644
--- a/src/ui/widgets/SignersPicker.cpp
+++ b/src/ui/widgets/SignersPicker.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -30,17 +34,17 @@ namespace GpgFrontend::UI {
SignersPicker::SignersPicker(QWidget* parent) : QDialog(parent) {
auto confirm_button = new QPushButton(_("Confirm"));
- connect(confirm_button, SIGNAL(clicked(bool)), this, SLOT(accept()));
+ connect(confirm_button, &QPushButton::clicked, this, &SignersPicker::accept);
/*Setup KeyList*/
key_list_ = new KeyList(false, this);
- key_list_->addListGroupTab(
+ key_list_->AddListGroupTab(
_("Signers"), KeyListRow::ONLY_SECRET_KEY,
KeyListColumn::NAME | KeyListColumn::EmailAddress | KeyListColumn::Usage,
[](const GpgKey& key) -> bool {
return key.IsHasActualSigningCapability();
});
- key_list_->slotRefresh();
+ key_list_->SlotRefresh();
auto* vbox2 = new QVBoxLayout();
vbox2->addWidget(new QLabel(QString(_("Select Signer(s)")) + ": "));
@@ -63,8 +67,8 @@ SignersPicker::SignersPicker(QWidget* parent) : QDialog(parent) {
this->show();
}
-GpgFrontend::KeyIdArgsListPtr SignersPicker::getCheckedSigners() {
- return key_list_->getPrivateChecked();
+GpgFrontend::KeyIdArgsListPtr SignersPicker::GetCheckedSigners() {
+ return key_list_->GetPrivateChecked();
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/SignersPicker.h b/src/ui/widgets/SignersPicker.h
index 08972a76..30f872f8 100644
--- a/src/ui/widgets/SignersPicker.h
+++ b/src/ui/widgets/SignersPicker.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -31,16 +35,30 @@ namespace GpgFrontend::UI {
class KeyList;
+/**
+ * @brief
+ *
+ */
class SignersPicker : public QDialog {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Signers Picker object
+ *
+ * @param parent
+ */
explicit SignersPicker(QWidget* parent = nullptr);
- GpgFrontend::KeyIdArgsListPtr getCheckedSigners();
+ /**
+ * @brief Get the Checked Signers object
+ *
+ * @return GpgFrontend::KeyIdArgsListPtr
+ */
+ GpgFrontend::KeyIdArgsListPtr GetCheckedSigners();
private:
- KeyList* key_list_;
+ KeyList* key_list_; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/TOFUInfoPage.cpp b/src/ui/widgets/TOFUInfoPage.cpp
index a1f76d7a..709a66e1 100644
--- a/src/ui/widgets/TOFUInfoPage.cpp
+++ b/src/ui/widgets/TOFUInfoPage.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
diff --git a/src/ui/widgets/TOFUInfoPage.h b/src/ui/widgets/TOFUInfoPage.h
index 29f004d1..445b1567 100644
--- a/src/ui/widgets/TOFUInfoPage.h
+++ b/src/ui/widgets/TOFUInfoPage.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -25,17 +27,26 @@
#ifndef GPGFRONTEND_TOFUINFOPAGE_H
#define GPGFRONTEND_TOFUINFOPAGE_H
-#include "gpg/GpgModel.h"
+#include "core/GpgModel.h"
#include "ui/GpgFrontendUI.h"
namespace GpgFrontend::UI {
+
+/**
+ * @brief
+ *
+ */
class TOFUInfoPage : public QWidget {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new TOFUInfoPage object
+ *
+ * @param tofu_info
+ * @param parent
+ */
explicit TOFUInfoPage(const GpgTOFUInfo &tofu_info,
QWidget *parent = nullptr);
-
- private:
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/TextEdit.cpp b/src/ui/widgets/TextEdit.cpp
index a8ff8d73..5556397e 100644
--- a/src/ui/widgets/TextEdit.cpp
+++ b/src/ui/widgets/TextEdit.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -29,68 +33,68 @@
namespace GpgFrontend::UI {
TextEdit::TextEdit(QWidget* parent) : QWidget(parent) {
- countPage = 0;
- tabWidget = new QTabWidget(this);
- tabWidget->setMovable(true);
- tabWidget->setTabsClosable(true);
- tabWidget->setDocumentMode(true);
+ count_page_ = 0;
+ tab_widget_ = new QTabWidget(this);
+ tab_widget_->setMovable(true);
+ tab_widget_->setTabsClosable(true);
+ tab_widget_->setDocumentMode(true);
auto* layout = new QVBoxLayout;
- layout->addWidget(tabWidget);
+ layout->addWidget(tab_widget_);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
setLayout(layout);
- connect(tabWidget, SIGNAL(tabCloseRequested(int)), this,
- SLOT(removeTab(int)));
- slotNewTab();
+ connect(tab_widget_, &QTabWidget::tabCloseRequested, this,
+ &TextEdit::slot_remove_tab);
+ SlotNewTab();
setAcceptDrops(false);
}
-void TextEdit::slotNewTab() {
- QString header = _("untitled") + QString::number(++countPage) + ".txt";
+void TextEdit::SlotNewTab() {
+ QString header = _("untitled") + QString::number(++count_page_) + ".txt";
auto* page = new PlainTextEditorPage();
- auto index = tabWidget->addTab(page, header);
- tabWidget->setTabIcon(index, QIcon(":file.png"));
- tabWidget->setCurrentIndex(tabWidget->count() - 1);
- page->getTextPage()->setFocus();
- connect(page->getTextPage()->document(), &QTextDocument::modificationChanged,
- this, &TextEdit::slotShowModified);
+ auto index = tab_widget_->addTab(page, header);
+ tab_widget_->setTabIcon(index, QIcon(":file.png"));
+ tab_widget_->setCurrentIndex(tab_widget_->count() - 1);
+ page->GetTextPage()->setFocus();
+ connect(page->GetTextPage()->document(), &QTextDocument::modificationChanged,
+ this, &TextEdit::SlotShowModified);
}
void TextEdit::slotNewHelpTab(const QString& title, const QString& path) const {
auto* page = new HelpPage(path);
- tabWidget->addTab(page, title);
- tabWidget->setCurrentIndex(tabWidget->count() - 1);
+ tab_widget_->addTab(page, title);
+ tab_widget_->setCurrentIndex(tab_widget_->count() - 1);
}
-void TextEdit::slotNewFileTab() const {
+void TextEdit::SlotNewFileTab() const {
auto* page = new FilePage(qobject_cast<QWidget*>(parent()));
- auto index = tabWidget->addTab(page, QString());
- tabWidget->setTabIcon(index, QIcon(":file-browser.png"));
- tabWidget->setCurrentIndex(tabWidget->count() - 1);
- connect(page, &FilePage::pathChanged, this,
- &TextEdit::slotFilePagePathChanged);
- page->slotGoPath();
+ auto index = tab_widget_->addTab(page, QString());
+ tab_widget_->setTabIcon(index, QIcon(":file-browser.png"));
+ tab_widget_->setCurrentIndex(tab_widget_->count() - 1);
+ connect(page, &FilePage::SignalPathChanged, this,
+ &TextEdit::slot_file_page_path_changed);
+ page->SlotGoPath();
}
-void TextEdit::slotOpenFile(QString& path) {
+void TextEdit::SlotOpenFile(QString& path) {
QFile file(path);
LOG(INFO) << "path" << path.toStdString();
auto result = file.open(QIODevice::ReadOnly | QIODevice::Text);
if (result) {
auto* page = new PlainTextEditorPage(path);
- connect(page->getTextPage()->document(),
+ connect(page->GetTextPage()->document(),
&QTextDocument::modificationChanged, this,
- &TextEdit::slotShowModified);
+ &TextEdit::SlotShowModified);
QApplication::setOverrideCursor(Qt::WaitCursor);
- auto index = tabWidget->addTab(page, strippedName(path));
- tabWidget->setTabIcon(index, QIcon(":file.png"));
- tabWidget->setCurrentIndex(tabWidget->count() - 1);
+ auto index = tab_widget_->addTab(page, stripped_name(path));
+ tab_widget_->setTabIcon(index, QIcon(":file.png"));
+ tab_widget_->setCurrentIndex(tab_widget_->count() - 1);
QApplication::restoreOverrideCursor();
- page->getTextPage()->setFocus();
+ page->GetTextPage()->setFocus();
page->ReadFile();
} else {
QMessageBox::warning(this, _("Warning"),
@@ -103,7 +107,7 @@ void TextEdit::slotOpenFile(QString& path) {
file.close();
}
-void TextEdit::slotOpen() {
+void TextEdit::SlotOpen() {
QStringList fileNames =
QFileDialog::getOpenFileNames(this, _("Open file"), QDir::currentPath());
for (const auto& fileName : fileNames) {
@@ -115,18 +119,18 @@ void TextEdit::slotOpen() {
QTextStream in(&file);
QApplication::setOverrideCursor(Qt::WaitCursor);
- page->getTextPage()->setPlainText(in.readAll());
- page->setFilePath(fileName);
- QTextDocument* document = page->getTextPage()->document();
+ page->GetTextPage()->setPlainText(in.readAll());
+ page->SetFilePath(fileName);
+ QTextDocument* document = page->GetTextPage()->document();
document->setModified(false);
- tabWidget->addTab(page, strippedName(fileName));
- tabWidget->setCurrentIndex(tabWidget->count() - 1);
+ tab_widget_->addTab(page, stripped_name(fileName));
+ tab_widget_->setCurrentIndex(tab_widget_->count() - 1);
QApplication::restoreOverrideCursor();
- page->getTextPage()->setFocus();
- connect(page->getTextPage()->document(),
- SIGNAL(modificationChanged(bool)), this,
- SLOT(slotShowModified()));
+ page->GetTextPage()->setFocus();
+ connect(page->GetTextPage()->document(),
+ &QTextDocument::modificationChanged, this,
+ &TextEdit::SlotShowModified);
// enableAction(true)
file.close();
} else {
@@ -141,23 +145,23 @@ void TextEdit::slotOpen() {
}
}
-void TextEdit::slotSave() {
- if (tabWidget->count() == 0 || slotCurPageTextEdit() == 0) {
+void TextEdit::SlotSave() {
+ if (tab_widget_->count() == 0 || SlotCurPageTextEdit() == 0) {
return;
}
- QString fileName = slotCurPageTextEdit()->getFilePath();
+ QString fileName = SlotCurPageTextEdit()->GetFilePath();
if (fileName.isEmpty()) {
// QString docname = tabWidget->tabText(tabWidget->currentIndex());
// docname.remove(0,2);
- slotSaveAs();
+ SlotSaveAs();
} else {
- saveFile(fileName);
+ save_file(fileName);
}
}
-bool TextEdit::saveFile(const QString& fileName) {
+bool TextEdit::save_file(const QString& fileName) {
if (fileName.isEmpty()) {
return false;
}
@@ -165,19 +169,19 @@ bool TextEdit::saveFile(const QString& fileName) {
QFile file(fileName);
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
- PlainTextEditorPage* page = slotCurPageTextEdit();
+ PlainTextEditorPage* page = SlotCurPageTextEdit();
QTextStream outputStream(&file);
QApplication::setOverrideCursor(Qt::WaitCursor);
- outputStream << page->getTextPage()->toPlainText();
+ outputStream << page->GetTextPage()->toPlainText();
QApplication::restoreOverrideCursor();
- QTextDocument* document = page->getTextPage()->document();
+ QTextDocument* document = page->GetTextPage()->document();
document->setModified(false);
- int curIndex = tabWidget->currentIndex();
- tabWidget->setTabText(curIndex, strippedName(fileName));
- page->setFilePath(fileName);
+ int curIndex = tab_widget_->currentIndex();
+ tab_widget_->setTabText(curIndex, stripped_name(fileName));
+ page->SetFilePath(fileName);
// statusBar()->showMessage(_("File saved"), 2000);
file.close();
return true;
@@ -192,53 +196,53 @@ bool TextEdit::saveFile(const QString& fileName) {
}
}
-bool TextEdit::slotSaveAs() {
- if (tabWidget->count() == 0 || slotCurPageTextEdit() == nullptr) {
+bool TextEdit::SlotSaveAs() {
+ if (tab_widget_->count() == 0 || SlotCurPageTextEdit() == nullptr) {
return true;
}
- PlainTextEditorPage* page = slotCurPageTextEdit();
+ PlainTextEditorPage* page = SlotCurPageTextEdit();
QString path;
- if (!page->getFilePath().isEmpty()) {
- path = page->getFilePath();
+ if (!page->GetFilePath().isEmpty()) {
+ path = page->GetFilePath();
} else {
- path = tabWidget->tabText(tabWidget->currentIndex()).remove(0, 2);
+ path = tab_widget_->tabText(tab_widget_->currentIndex()).remove(0, 2);
}
QString fileName = QFileDialog::getSaveFileName(this, _("Save file"), path);
- return saveFile(fileName);
+ return save_file(fileName);
}
-void TextEdit::slotCloseTab() {
- removeTab(tabWidget->currentIndex());
- if (tabWidget->count() != 0) {
- slotCurPageTextEdit()->getTextPage()->setFocus();
+void TextEdit::SlotCloseTab() {
+ slot_remove_tab(tab_widget_->currentIndex());
+ if (tab_widget_->count() != 0) {
+ SlotCurPageTextEdit()->GetTextPage()->setFocus();
}
}
-void TextEdit::removeTab(int index) {
+void TextEdit::slot_remove_tab(int index) {
// Do nothing, if no tab is opened
- if (tabWidget->count() == 0) {
+ if (tab_widget_->count() == 0) {
return;
}
// get the index of the actual current tab
- int lastIndex = tabWidget->currentIndex();
+ int last_index = tab_widget_->currentIndex();
// set the focus to argument index
- tabWidget->setCurrentIndex(index);
+ tab_widget_->setCurrentIndex(index);
- if (maybeSaveCurrentTab(true)) {
- tabWidget->removeTab(index);
+ if (maybe_save_current_tab(true)) {
+ tab_widget_->removeTab(index);
- if (index >= lastIndex) {
- tabWidget->setCurrentIndex(lastIndex);
+ if (index >= last_index) {
+ tab_widget_->setCurrentIndex(last_index);
} else {
- tabWidget->setCurrentIndex(lastIndex - 1);
+ tab_widget_->setCurrentIndex(last_index - 1);
}
}
- if (tabWidget->count() == 0) {
+ if (tab_widget_->count() == 0) {
// enableAction(false);
}
}
@@ -249,28 +253,28 @@ void TextEdit::removeTab(int index) {
*
* If it returns false, the close event should be aborted.
*/
-bool TextEdit::maybeSaveCurrentTab(bool askToSave) {
- PlainTextEditorPage* page = slotCurPageTextEdit();
+bool TextEdit::maybe_save_current_tab(bool askToSave) {
+ PlainTextEditorPage* page = SlotCurPageTextEdit();
// if this page is no textedit, there should be nothing to save
if (page == nullptr) {
return true;
}
- QTextDocument* document = page->getTextPage()->document();
+ QTextDocument* document = page->GetTextPage()->document();
if (page->ReadDone() && document->isModified()) {
QMessageBox::StandardButton result = QMessageBox::Cancel;
// write title of tab to docname and remove the leading *
- QString docname = tabWidget->tabText(tabWidget->currentIndex());
- docname.remove(0, 2);
+ QString doc_name = tab_widget_->tabText(tab_widget_->currentIndex());
+ doc_name.remove(0, 2);
- const QString& filePath = page->getFilePath();
+ const QString& file_path = page->GetFilePath();
if (askToSave) {
result = QMessageBox::warning(
this, _("Unsaved document"),
QString(_("The document \"%1\" has been modified. Do you want to "
"save your changes?"))
- .arg(docname) +
+ .arg(doc_name) +
"<br/><b>" + _("Note:") + "</b>" +
_("If you don't save these files, all changes are "
"lost.") +
@@ -278,12 +282,12 @@ bool TextEdit::maybeSaveCurrentTab(bool askToSave) {
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
}
if ((result == QMessageBox::Save) || (!askToSave)) {
- if (filePath.isEmpty()) {
+ if (file_path.isEmpty()) {
// QString docname = tabWidget->tabText(tabWidget->currentIndex());
// docname.remove(0,2);
- return slotSaveAs();
+ return SlotSaveAs();
} else {
- return saveFile(filePath);
+ return save_file(file_path);
}
} else if (result == QMessageBox::Discard) {
return true;
@@ -297,9 +301,9 @@ bool TextEdit::maybeSaveCurrentTab(bool askToSave) {
return true;
}
-bool TextEdit::maybeSaveAnyTab() {
+bool TextEdit::MaybeSaveAnyTab() {
// get a list of all unsaved documents and their tabids
- QHash<int, QString> unsaved_docs = this->unsavedDocuments();
+ QHash<int, QString> unsaved_docs = this->UnsavedDocuments();
/*
* no unsaved documents, so app can be closed
@@ -313,8 +317,8 @@ bool TextEdit::maybeSaveAnyTab() {
*/
if (unsaved_docs.size() == 1) {
int modifiedTab = unsaved_docs.keys().at(0);
- tabWidget->setCurrentIndex(modifiedTab);
- return maybeSaveCurrentTab(true);
+ tab_widget_->setCurrentIndex(modifiedTab);
+ return maybe_save_current_tab(true);
}
/*
@@ -330,18 +334,18 @@ bool TextEdit::maybeSaveAnyTab() {
// if result is QDialog::Rejected, discard or cancel was clicked
if (result == QDialog::Rejected) {
// return true, if discard is clicked, so app can be closed
- if (dialog->isDiscarded()) {
+ if (dialog->IsDiscarded()) {
return true;
} else {
return false;
}
} else {
bool all_saved = true;
- QList<int> tabIdsToSave = dialog->getTabIdsToSave();
+ QList<int> tabIdsToSave = dialog->GetTabIdsToSave();
for (const auto& tabId : tabIdsToSave) {
- tabWidget->setCurrentIndex(tabId);
- if (!maybeSaveCurrentTab(false)) {
+ tab_widget_->setCurrentIndex(tabId);
+ if (!maybe_save_current_tab(false)) {
all_saved = false;
}
}
@@ -352,12 +356,12 @@ bool TextEdit::maybeSaveAnyTab() {
return false;
}
-PlainTextEditorPage* TextEdit::curTextPage() const {
- return qobject_cast<PlainTextEditorPage*>(tabWidget->currentWidget());
+PlainTextEditorPage* TextEdit::CurTextPage() const {
+ return qobject_cast<PlainTextEditorPage*>(tab_widget_->currentWidget());
}
-FilePage* TextEdit::curFilePage() const {
- auto* curFilePage = qobject_cast<FilePage*>(tabWidget->currentWidget());
+FilePage* TextEdit::CurFilePage() const {
+ auto* curFilePage = qobject_cast<FilePage*>(tab_widget_->currentWidget());
if (curFilePage != nullptr) {
return curFilePage;
} else {
@@ -365,25 +369,25 @@ FilePage* TextEdit::curFilePage() const {
}
}
-int TextEdit::tabCount() const { return tabWidget->count(); }
+int TextEdit::TabCount() const { return tab_widget_->count(); }
-PlainTextEditorPage* TextEdit::slotCurPageTextEdit() const {
+PlainTextEditorPage* TextEdit::SlotCurPageTextEdit() const {
auto* curPage =
- qobject_cast<PlainTextEditorPage*>(tabWidget->currentWidget());
+ qobject_cast<PlainTextEditorPage*>(tab_widget_->currentWidget());
return curPage;
}
-FilePage* TextEdit::slotCurPageFileTreeView() const {
- auto* curPage = qobject_cast<FilePage*>(tabWidget->currentWidget());
+FilePage* TextEdit::SlotCurPageFileTreeView() const {
+ auto* curPage = qobject_cast<FilePage*>(tab_widget_->currentWidget());
return curPage;
}
-void TextEdit::slotQuote() const {
- if (tabWidget->count() == 0 || curTextPage() == nullptr) {
+void TextEdit::SlotQuote() const {
+ if (tab_widget_->count() == 0 || CurTextPage() == nullptr) {
return;
}
- QTextCursor cursor(curTextPage()->getTextPage()->document());
+ QTextCursor cursor(CurTextPage()->GetTextPage()->document());
// beginEditBlock and endEditBlock() let operation look like single undo/redo
// operation
@@ -400,15 +404,15 @@ void TextEdit::slotQuote() const {
cursor.endEditBlock();
}
-void TextEdit::slotFillTextEditWithText(const QString& text) const {
- QTextCursor cursor(curTextPage()->getTextPage()->document());
+void TextEdit::SlotFillTextEditWithText(const QString& text) const {
+ QTextCursor cursor(CurTextPage()->GetTextPage()->document());
cursor.beginEditBlock();
- this->curTextPage()->getTextPage()->selectAll();
- this->curTextPage()->getTextPage()->insertPlainText(text);
+ this->CurTextPage()->GetTextPage()->selectAll();
+ this->CurTextPage()->GetTextPage()->insertPlainText(text);
cursor.endEditBlock();
}
-void TextEdit::loadFile(const QString& fileName) {
+void TextEdit::LoadFile(const QString& fileName) {
QFile file(fileName);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
QMessageBox::warning(
@@ -421,27 +425,27 @@ void TextEdit::loadFile(const QString& fileName) {
}
QTextStream in(&file);
QApplication::setOverrideCursor(Qt::WaitCursor);
- curTextPage()->getTextPage()->setPlainText(in.readAll());
+ CurTextPage()->GetTextPage()->setPlainText(in.readAll());
QApplication::restoreOverrideCursor();
- slotCurPageTextEdit()->setFilePath(fileName);
- tabWidget->setTabText(tabWidget->currentIndex(), strippedName(fileName));
+ SlotCurPageTextEdit()->SetFilePath(fileName);
+ tab_widget_->setTabText(tab_widget_->currentIndex(), stripped_name(fileName));
file.close();
// statusBar()->showMessage(_("File loaded"), 2000);
}
-QString TextEdit::strippedName(const QString& full_file_name) {
+QString TextEdit::stripped_name(const QString& full_file_name) {
return QFileInfo(full_file_name).fileName();
}
-void TextEdit::slotPrint() {
- if (tabWidget->count() == 0) {
+void TextEdit::SlotPrint() {
+ if (tab_widget_->count() == 0) {
return;
}
#ifndef QT_NO_PRINTER
QTextDocument* document;
- if (curTextPage() != nullptr) {
- document = curTextPage()->getTextPage()->document();
+ if (CurTextPage() != nullptr) {
+ document = CurTextPage()->GetTextPage()->document();
}
QPrinter printer;
@@ -455,45 +459,45 @@ void TextEdit::slotPrint() {
#endif
}
-void TextEdit::slotShowModified() const {
- int index = tabWidget->currentIndex();
- QString title = tabWidget->tabText(index);
+void TextEdit::SlotShowModified() const {
+ int index = tab_widget_->currentIndex();
+ QString title = tab_widget_->tabText(index);
// if doc is modified now, add leading * to title,
// otherwise remove the leading * from the title
- if (curTextPage()->getTextPage()->document()->isModified()) {
- tabWidget->setTabText(index, title.prepend("* "));
+ if (CurTextPage()->GetTextPage()->document()->isModified()) {
+ tab_widget_->setTabText(index, title.prepend("* "));
} else {
- tabWidget->setTabText(index, title.remove(0, 2));
+ tab_widget_->setTabText(index, title.remove(0, 2));
}
}
-void TextEdit::slotSwitchTabUp() const {
- if (tabWidget->count() > 1) {
- int new_index = (tabWidget->currentIndex() + 1) % (tabWidget->count());
- tabWidget->setCurrentIndex(new_index);
+void TextEdit::SlotSwitchTabUp() const {
+ if (tab_widget_->count() > 1) {
+ int new_index = (tab_widget_->currentIndex() + 1) % (tab_widget_->count());
+ tab_widget_->setCurrentIndex(new_index);
}
}
-void TextEdit::slotSwitchTabDown() const {
- if (tabWidget->count() > 1) {
- int newindex = (tabWidget->currentIndex() - 1 + tabWidget->count()) %
- tabWidget->count();
- tabWidget->setCurrentIndex(newindex);
+void TextEdit::SlotSwitchTabDown() const {
+ if (tab_widget_->count() > 1) {
+ int newindex = (tab_widget_->currentIndex() - 1 + tab_widget_->count()) %
+ tab_widget_->count();
+ tab_widget_->setCurrentIndex(newindex);
}
}
/*
* return a hash of tabindexes and title of unsaved tabs
*/
-QHash<int, QString> TextEdit::unsavedDocuments() const {
+QHash<int, QString> TextEdit::UnsavedDocuments() const {
QHash<int, QString> unsavedDocs; // this list could be used to implement
// gedit like "unsaved changed"-dialog
- for (int i = 0; i < tabWidget->count(); i++) {
- auto* ep = qobject_cast<PlainTextEditorPage*>(tabWidget->widget(i));
+ for (int i = 0; i < tab_widget_->count(); i++) {
+ auto* ep = qobject_cast<PlainTextEditorPage*>(tab_widget_->widget(i));
if (ep != nullptr && ep->ReadDone() &&
- ep->getTextPage()->document()->isModified()) {
- QString doc_name = tabWidget->tabText(i);
+ ep->GetTextPage()->document()->isModified()) {
+ QString doc_name = tab_widget_->tabText(i);
LOG(INFO) << "unsaved" << doc_name.toStdString();
// remove * before name of modified doc
@@ -504,77 +508,77 @@ QHash<int, QString> TextEdit::unsavedDocuments() const {
return unsavedDocs;
}
-void TextEdit::slotCut() const {
- if (tabWidget->count() == 0 || curTextPage() == nullptr) {
+void TextEdit::SlotCut() const {
+ if (tab_widget_->count() == 0 || CurTextPage() == nullptr) {
return;
}
- curTextPage()->getTextPage()->cut();
+ CurTextPage()->GetTextPage()->cut();
}
-void TextEdit::slotCopy() const {
- if (tabWidget->count() == 0) {
+void TextEdit::SlotCopy() const {
+ if (tab_widget_->count() == 0) {
return;
}
- if (curTextPage() != nullptr) {
- curTextPage()->getTextPage()->copy();
+ if (CurTextPage() != nullptr) {
+ CurTextPage()->GetTextPage()->copy();
}
}
-void TextEdit::slotPaste() const {
- if (tabWidget->count() == 0 || curTextPage() == nullptr) {
+void TextEdit::SlotPaste() const {
+ if (tab_widget_->count() == 0 || CurTextPage() == nullptr) {
return;
}
- curTextPage()->getTextPage()->paste();
+ CurTextPage()->GetTextPage()->paste();
}
-void TextEdit::slotUndo() const {
- if (tabWidget->count() == 0 || curTextPage() == nullptr) {
+void TextEdit::SlotUndo() const {
+ if (tab_widget_->count() == 0 || CurTextPage() == nullptr) {
return;
}
- curTextPage()->getTextPage()->undo();
+ CurTextPage()->GetTextPage()->undo();
}
-void TextEdit::slotRedo() const {
- if (tabWidget->count() == 0 || curTextPage() == nullptr) {
+void TextEdit::SlotRedo() const {
+ if (tab_widget_->count() == 0 || CurTextPage() == nullptr) {
return;
}
- curTextPage()->getTextPage()->redo();
+ CurTextPage()->GetTextPage()->redo();
}
-void TextEdit::slotZoomIn() const {
- if (tabWidget->count() == 0) {
+void TextEdit::SlotZoomIn() const {
+ if (tab_widget_->count() == 0) {
return;
}
- if (curTextPage() != nullptr) {
- curTextPage()->getTextPage()->zoomIn();
+ if (CurTextPage() != nullptr) {
+ CurTextPage()->GetTextPage()->zoomIn();
}
}
-void TextEdit::slotZoomOut() const {
- if (tabWidget->count() == 0) {
+void TextEdit::SlotZoomOut() const {
+ if (tab_widget_->count() == 0) {
return;
}
- if (curTextPage() != nullptr) {
- curTextPage()->getTextPage()->zoomOut();
+ if (CurTextPage() != nullptr) {
+ CurTextPage()->GetTextPage()->zoomOut();
}
}
-void TextEdit::slotSelectAll() const {
- if (tabWidget->count() == 0 || curTextPage() == nullptr) {
+void TextEdit::SlotSelectAll() const {
+ if (tab_widget_->count() == 0 || CurTextPage() == nullptr) {
return;
}
- curTextPage()->getTextPage()->selectAll();
+ CurTextPage()->GetTextPage()->selectAll();
}
-void TextEdit::slotFilePagePathChanged(const QString& path) const {
- int index = tabWidget->currentIndex();
+void TextEdit::slot_file_page_path_changed(const QString& path) const {
+ int index = tab_widget_->currentIndex();
QString mPath;
QFileInfo fileInfo(path);
QString tPath = fileInfo.absoluteFilePath();
@@ -583,7 +587,7 @@ void TextEdit::slotFilePagePathChanged(const QString& path) const {
} else {
mPath = tPath;
}
- tabWidget->setTabText(index, mPath);
+ tab_widget_->setTabText(index, mPath);
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/TextEdit.h b/src/ui/widgets/TextEdit.h
index c1f44969..cb32bfb2 100644
--- a/src/ui/widgets/TextEdit.h
+++ b/src/ui/widgets/TextEdit.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,26 +8,28 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef __TEXTEDIT_H__
#define __TEXTEDIT_H__
-#include "ui/QuitDialog.h"
+#include "ui/dialog/QuitDialog.h"
#include "ui/widgets/FilePage.h"
#include "ui/widgets/HelpPage.h"
#include "ui/widgets/PlainTextEditorPage.h"
@@ -48,7 +52,7 @@ class TextEdit : public QWidget {
* @param fileName QString containing the filename to load
* @return nothing
*/
- void loadFile(const QString& fileName);
+ void LoadFile(const QString& fileName);
/**
* @details Checks if there are unsaved documents in any tab,
@@ -57,26 +61,36 @@ class TextEdit : public QWidget {
* @return \li false, if the close event should be aborted.
* \li true, otherwise
*/
- bool maybeSaveAnyTab();
+ bool MaybeSaveAnyTab();
- [[nodiscard]] int tabCount() const;
+ /**
+ * @brief
+ *
+ * @return int
+ */
+ [[nodiscard]] int TabCount() const;
/**
* @details textpage of the currently activated tab
* @return \li reference to QTextEdit if tab has one
* \li 0 otherwise (e.g. if helppage)
*/
- [[nodiscard]] PlainTextEditorPage* curTextPage() const;
+ [[nodiscard]] PlainTextEditorPage* CurTextPage() const;
- [[nodiscard]] FilePage* curFilePage() const;
+ /**
+ * @brief
+ *
+ * @return FilePage*
+ */
+ [[nodiscard]] FilePage* CurFilePage() const;
/**
* @details List of currently unsaved tabs.
- * @returns QHash<int, QString> Hash of tabindexes and title of unsaved tabs.
+ * @returns QHash<int, QString> Hash of tab indexes and title of unsaved tabs.
*/
- [[nodiscard]] QHash<int, QString> unsavedDocuments() const;
+ [[nodiscard]] QHash<int, QString> UnsavedDocuments() const;
- QTabWidget* tabWidget; /** Widget containing the tabs of the editor */
+ QTabWidget* tab_widget_; /** Widget containing the tabs of the editor */
public slots:
@@ -84,62 +98,62 @@ class TextEdit : public QWidget {
* @details Return pointer to the currently activated text edit tab page.
*
*/
- PlainTextEditorPage* slotCurPageTextEdit() const;
+ PlainTextEditorPage* SlotCurPageTextEdit() const;
/**
- * @details Return pointer to the currently activated file treeview tab page.
+ * @details Return pointer to the currently activated file tree view tab page.
*
*/
- FilePage* slotCurPageFileTreeView() const;
+ FilePage* SlotCurPageFileTreeView() const;
/**
- * @details Insert a ">" at the begining of every line of current textedit.
+ * @details Insert a ">" at the beginning of every line of current textedit.
*/
- void slotQuote() const;
+ void SlotQuote() const;
/**
* @details replace the text of currently active textedit with given text.
* @param text to fill on.
*/
- void slotFillTextEditWithText(const QString& text) const;
+ void SlotFillTextEditWithText(const QString& text) const;
/**
* @details Saves the content of the current tab, if it has a filepath
* otherwise it calls saveAs for the current tab
*/
- void slotSave();
+ void SlotSave();
/**
- * @details Opens a savefiledialog and calls saveFile with the choosen
+ * @details Opens a savefiledialog and calls save_file with the choosen
* filename.
*
* @return Return the return value of the savefile method
*/
- bool slotSaveAs();
+ bool SlotSaveAs();
/**
* @details Show an OpenFileDoalog and open the file in a new tab.
* Shows an error dialog, if the open fails.
* Set the focus to the tab of the opened file.
*/
- void slotOpen();
+ void SlotOpen();
/**
* @details Open a print-dialog for the current tab
*/
- void slotPrint();
+ void SlotPrint();
/**
* @details Adds a new tab with the title "untitled"+countpage+".txt"
* Sets the focus to the new tab. Increase Tab-Count by
* one
*/
- void slotNewTab();
+ void SlotNewTab();
/**
* @details Adds a new tab with opening file by path
*/
- void slotOpenFile(QString& path);
+ void SlotOpenFile(QString& path);
/**
* @details Adds a new tab with the given title and opens given html file.
@@ -152,31 +166,31 @@ class TextEdit : public QWidget {
/**
* New File Tab to do file operation
*/
- void slotNewFileTab() const;
+ void SlotNewFileTab() const;
/**
* @details put a * in front of current tabs title, if current textedit is
* modified
*/
- void slotShowModified() const;
+ void SlotShowModified() const;
/**
* @details close the current tab and decrease TabWidget->count by \a 1
*
*/
- void slotCloseTab();
+ void SlotCloseTab();
/**
* @details Switch to the next tab.
*
*/
- void slotSwitchTabUp() const;
+ void SlotSwitchTabUp() const;
/**
* @details Switch to the previous tab.
*
*/
- void slotSwitchTabDown() const;
+ void SlotSwitchTabDown() const;
private:
/**
@@ -185,96 +199,82 @@ class TextEdit : public QWidget {
* @param a filename path
* @return QString containing the filename
*/
- static QString strippedName(const QString& full_file_name);
+ static QString stripped_name(const QString& full_file_name);
/**
* @brief
*
* @param askToSave
*/
- bool maybeSaveCurrentTab(bool askToSave);
+ bool maybe_save_current_tab(bool askToSave);
- /****************************************************************************************
- * Name: countPage
- * Description: int cotaining the number of added tabs
- */
- int countPage; /* TODO */
+ int count_page_; ///< int containing the number of added tabs
private slots:
- void slotFilePagePathChanged(const QString& path) const;
+ void slot_file_page_path_changed(const QString& path) const;
/**
* @details Remove the tab with given index
*
* @param index Tab-number to remove
*/
- void removeTab(int index);
+ void slot_remove_tab(int index);
+
+ public slots:
/**
- * @details Cut selected text in current textpage.
+ * @details Cut selected text in current text page.
*/
- void slotCut() const;
+ void SlotCut() const;
/**
- * @details Copy selected text of current textpage to clipboard.
+ * @details Copy selected text of current text page to clipboard.
*/
- void slotCopy() const;
+ void SlotCopy() const;
/**
- * @details Paste text from clipboard to current textpage.
+ * @details Paste text from clipboard to current text page.
*/
- void slotPaste() const;
+ void SlotPaste() const;
/**
* @details Undo last change in current textpage.
*
*/
- void slotUndo() const;
- /****************************************************************************************
- * Name: redo
- * Description: redo last change in current textpage
- * Parameters: none
- * Return Values: none
- * Change on members: none
+ void SlotUndo() const;
+
+ /**
+ * @brief redo last change in current text page
+ *
*/
+ void SlotRedo() const;
+
/**
* @brief
*
*/
- void slotRedo() const;
-
- void slotZoomIn() const;
+ void SlotZoomIn() const;
- void slotZoomOut() const;
- /****************************************************************************************
- * Name: selectAll
- * Description: select all in current textpage
- * Parameters: none
- * Return Values: none
- * Change on members: none
- */
/**
* @brief
*
*/
- void slotSelectAll() const;
+ void SlotZoomOut() const;
- protected:
- /****************************************************************************************
- * Name: saveFile
- * Description: Saves the content of currentTab to the file filename
- * Parameters: QString filename contains the full path of the file to
- * save Return Values: true, if the file was saved succesfully false, if
- * parameter filename is empty or the saving failed Change on members: sets
- * isModified of the current tab to false
+ /**
+ * @brief select all in current text page
+ *
*/
+ void SlotSelectAll() const;
+
+ protected:
/**
- * @brief
+ * @brief Saves the content of currentTab to the file filename
*
* @param fileName
*/
- bool saveFile(const QString& fileName);
+ bool save_file(const QString& fileName);
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/VerifyKeyDetailBox.cpp b/src/ui/widgets/VerifyKeyDetailBox.cpp
index 5e4d06d0..4c936f4f 100644
--- a/src/ui/widgets/VerifyKeyDetailBox.cpp
+++ b/src/ui/widgets/VerifyKeyDetailBox.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,41 +8,43 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include "ui/widgets/VerifyKeyDetailBox.h"
-#include "gpg/function/GpgKeyGetter.h"
+#include "core/function/gpg/GpgKeyGetter.h"
namespace GpgFrontend::UI {
VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
QWidget* parent)
- : QGroupBox(parent), fpr(signature.GetFingerprint()) {
+ : QGroupBox(parent), fpr_(signature.GetFingerprint()) {
auto* vbox = new QVBoxLayout();
switch (gpg_err_code(signature.GetStatus())) {
case GPG_ERR_NO_PUBKEY: {
this->setTitle("A Error Signature");
auto* importButton = new QPushButton(_("Import from keyserver"));
- connect(importButton, SIGNAL(clicked()), this,
- SLOT(slotImportFormKeyserver()));
+ connect(importButton,&QPushButton::clicked, this,
+ &VerifyKeyDetailBox::slot_import_form_key_server);
- this->setTitle(QString(_("Key not present with id 0x")) + fpr.c_str());
+ this->setTitle(QString(_("Key not present with id 0x")) + fpr_.c_str());
auto grid = new QGridLayout();
@@ -55,7 +59,7 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
}
case GPG_ERR_NO_ERROR: {
this->setTitle(QString(_("A Signature")) + ":");
- auto gird = createKeyInfoGrid(signature);
+ auto gird = create_key_info_grid(signature);
if (gird != nullptr) {
vbox->addLayout(gird);
} else {
@@ -71,7 +75,7 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
this->setTitle("An Error Signature");
vbox->addWidget(
new QLabel(QString(_("Status")) + ":" + _("Cert Revoked")));
- auto gird = createKeyInfoGrid(signature);
+ auto gird = create_key_info_grid(signature);
if (gird != nullptr) {
vbox->addLayout(gird);
} else {
@@ -87,7 +91,7 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
this->setTitle("An Error Signature");
vbox->addWidget(
new QLabel(QString(_("Status")) + ":" + _("Signature Expired")));
- auto gird = createKeyInfoGrid(signature);
+ auto gird = create_key_info_grid(signature);
if (gird != nullptr) {
vbox->addLayout(gird);
} else {
@@ -105,7 +109,7 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
new QLabel(QString(_("Status")) + ":" + _("Key Expired")));
vbox->addWidget(
new QLabel(QString(_("Status")) + ":" + _("Key Expired")));
- auto gird = createKeyInfoGrid(signature);
+ auto gird = create_key_info_grid(signature);
if (gird != nullptr) {
vbox->addLayout(gird);
} else {
@@ -121,7 +125,7 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
this->setTitle("An Error Signature");
vbox->addWidget(
new QLabel(QString(_("Status")) + ":" + _("General Error")));
- auto gird = createKeyInfoGrid(signature);
+ auto gird = create_key_info_grid(signature);
if (gird != nullptr) {
vbox->addLayout(gird);
} else {
@@ -136,7 +140,7 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
default: {
this->setTitle("An Error Signature");
this->setTitle(QString(_("Status")) + ":" + _("Unknown Error "));
- auto gird = createKeyInfoGrid(signature);
+ auto gird = create_key_info_grid(signature);
if (gird != nullptr) {
vbox->addLayout(gird);
} else {
@@ -152,17 +156,17 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
this->setLayout(vbox);
}
-void VerifyKeyDetailBox::slotImportFormKeyserver() {
+void VerifyKeyDetailBox::slot_import_form_key_server() {
auto* importDialog = new KeyServerImportDialog(false, this);
auto key_ids = std::make_unique<KeyIdArgsList>();
- key_ids->push_back(fpr);
- importDialog->slotImport(key_ids);
+ key_ids->push_back(fpr_);
+ importDialog->SlotImport(key_ids);
}
-QGridLayout* VerifyKeyDetailBox::createKeyInfoGrid(
+QGridLayout* VerifyKeyDetailBox::create_key_info_grid(
const GpgSignature& signature) {
auto grid = new QGridLayout();
- GpgKey key = GpgKeyGetter::GetInstance().GetKey(fpr);
+ GpgKey key = GpgKeyGetter::GetInstance().GetKey(fpr_);
if (!key.IsGood()) return nullptr;
grid->addWidget(new QLabel(QString(_("Signer Name")) + ":"), 0, 0);
@@ -173,7 +177,7 @@ QGridLayout* VerifyKeyDetailBox::createKeyInfoGrid(
grid->addWidget(new QLabel(QString::fromStdString(key.GetName())), 0, 1);
grid->addWidget(new QLabel(QString::fromStdString(key.GetEmail())), 1, 1);
- grid->addWidget(new QLabel(beautify_fingerprint(fpr).c_str()), 2, 1);
+ grid->addWidget(new QLabel(beautify_fingerprint(fpr_).c_str()), 2, 1);
if (signature.GetSummary() & GPGME_SIGSUM_VALID) {
grid->addWidget(new QLabel(_("Fully Valid")), 3, 1);
diff --git a/src/ui/widgets/VerifyKeyDetailBox.h b/src/ui/widgets/VerifyKeyDetailBox.h
index b01d628d..18fa7963 100644
--- a/src/ui/widgets/VerifyKeyDetailBox.h
+++ b/src/ui/widgets/VerifyKeyDetailBox.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,43 +8,64 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef __VERIFYKEYDETAILBOX_H__
#define __VERIFYKEYDETAILBOX_H__
-#include "ui/KeyServerImportDialog.h"
+#include "ui/import_export/KeyServerImportDialog.h"
#include "ui/widgets/KeyList.h"
namespace GpgFrontend::UI {
-
+/**
+ * @brief
+ *
+ */
class VerifyKeyDetailBox : public QGroupBox {
Q_OBJECT
public:
+ /**
+ * @brief Construct a new Verify Key Detail Box object
+ *
+ * @param signature
+ * @param parent
+ */
explicit VerifyKeyDetailBox(const GpgSignature& signature, QWidget* parent);
private slots:
- void slotImportFormKeyserver();
+ /**
+ * @brief
+ *
+ */
+ void slot_import_form_key_server();
private:
- QGridLayout* createKeyInfoGrid(const GpgSignature& signature);
+ /**
+ * @brief Create a key info grid object
+ *
+ * @param signature
+ * @return QGridLayout*
+ */
+ QGridLayout* create_key_info_grid(const GpgSignature& signature);
- std::string fpr;
+ std::string fpr_; ///<
};
} // namespace GpgFrontend::UI
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index cee1720b..84fc9f9a 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,3 +1,29 @@
+#
+# Copyright (C) 2021 Saturneric
+#
+# This file is part of GpgFrontend.
+#
+# GpgFrontend is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# GpgFrontend is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+#
+# The initial version of the source code is inherited from
+# the gpg4usb project, which is under GPL-3.0-or-later.
+#
+# All the source code of GpgFrontend was modified and released by
+# Saturneric<[email protected]> starting on May 12, 2021.
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
find_package(GTest REQUIRED)
# Set configure for test
diff --git a/test/GpgCoreTest.cpp b/test/GpgCoreTest.cpp
index ab9dbf28..224fad18 100644
--- a/test/GpgCoreTest.cpp
+++ b/test/GpgCoreTest.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/test/GpgCoreTestBasicOpera.cpp b/test/GpgCoreTestBasicOpera.cpp
index 283ceb82..57339453 100644
--- a/test/GpgCoreTestBasicOpera.cpp
+++ b/test/GpgCoreTestBasicOpera.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
@@ -29,9 +33,9 @@
#include "GpgFrontendTest.h"
#include "gpg/GpgConstants.h"
-#include "gpg/function/BasicOperator.h"
+#include "gpg/function/GpgBasicOperator.h"
#include "gpg/function/GpgKeyGetter.h"
-#include "gpg/result_analyse/DecryptResultAnalyse.h"
+#include "gpg/result_analyse/GpgDecryptResultAnalyse.h"
using namespace GpgFrontend;
diff --git a/test/GpgCoreTestImportExport.cpp b/test/GpgCoreTestImportExport.cpp
index 1e226247..bef5660a 100644
--- a/test/GpgCoreTestImportExport.cpp
+++ b/test/GpgCoreTestImportExport.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/test/GpgCoreTestKeyModel.cpp b/test/GpgCoreTestKeyModel.cpp
index 79cd7dcd..41498e95 100644
--- a/test/GpgCoreTestKeyModel.cpp
+++ b/test/GpgCoreTestKeyModel.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/test/GpgCoreTestKeyModelAlone.cpp b/test/GpgCoreTestKeyModelAlone.cpp
index 3d5bd175..31d33bf9 100644
--- a/test/GpgCoreTestKeyModelAlone.cpp
+++ b/test/GpgCoreTestKeyModelAlone.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/test/GpgCoreTestKeygen.cpp b/test/GpgCoreTestKeygen.cpp
index b703ee40..ebfe398b 100644
--- a/test/GpgCoreTestKeygen.cpp
+++ b/test/GpgCoreTestKeygen.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/test/GpgCoreTestKeygenAlone.cpp b/test/GpgCoreTestKeygenAlone.cpp
index 4a725ba7..71deb626 100644
--- a/test/GpgCoreTestKeygenAlone.cpp
+++ b/test/GpgCoreTestKeygenAlone.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/test/GpgFrontendTest.h b/test/GpgFrontendTest.h
index 84476106..15efb650 100644
--- a/test/GpgFrontendTest.h
+++ b/test/GpgFrontendTest.h
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,19 +8,21 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
*
- * The source code version of this software was modified and released
- * by Saturneric<[email protected]> starting on May 12, 2021.
+ * SPDX-License-Identifier: GPL-3.0-or-later
*
*/
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index f6e74772..0df99211 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -1,3 +1,29 @@
+#
+# Copyright (C) 2021 Saturneric
+#
+# This file is part of GpgFrontend.
+#
+# GpgFrontend is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# GpgFrontend is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+#
+# The initial version of the source code is inherited from
+# the gpg4usb project, which is under GPL-3.0-or-later.
+#
+# All the source code of GpgFrontend was modified and released by
+# Saturneric<[email protected]> starting on May 12, 2021.
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
# easyloggingpp
set(build_static_lib 1 CACHE BOOL "" FORCE)
add_subdirectory(easyloggingpp)
@@ -153,9 +179,9 @@ endif ()
add_library(gpgme STATIC IMPORTED GLOBAL)
if (NOT MINGW)
-add_dependencies(gpgme libgpgme assuan gpg-error)
-set_target_properties(gpgme PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${GPGME_INCLUDES})
-endif()
+ add_dependencies(gpgme libgpgme assuan gpg-error)
+ set_target_properties(gpgme PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${GPGME_INCLUDES})
+endif ()
set_target_properties(gpgme PROPERTIES IMPORTED_LOCATION ${GPGME_STATIC_LIB})
if (SMTP_SUPPORT)
@@ -173,4 +199,19 @@ if (SMTP_SUPPORT)
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
endif ()
+endif ()
+
+# encoding detect library
+aux_source_directory(./encoding-detect ENCODING_DETECT_SOURCE_CODE)
+add_library(encoding_detect STATIC ${ENCODING_DETECT_SOURCE_CODE})
+
+# libarchive
+if (NOT MINGW)
+ remove_definitions(-DDEBUG)
+ add_subdirectory(libarchive)
+endif ()
+
+if (NOT MINGW)
+# libconfig
+add_subdirectory(libconfig)
endif () \ No newline at end of file
diff --git a/src/ui/encoding/TextEncodingDetect.cpp b/third_party/encoding-detect/TextEncodingDetect.cpp
index 22ae5897..22ae5897 100644
--- a/src/ui/encoding/TextEncodingDetect.cpp
+++ b/third_party/encoding-detect/TextEncodingDetect.cpp
diff --git a/src/ui/encoding/TextEncodingDetect.h b/third_party/encoding-detect/TextEncodingDetect.h
index 6d861716..6d861716 100644
--- a/src/ui/encoding/TextEncodingDetect.h
+++ b/third_party/encoding-detect/TextEncodingDetect.h
diff --git a/third_party/libarchive b/third_party/libarchive
new file mode 160000
+Subproject b1b501161013296d19dfe9acb84a341c8a1755b
diff --git a/third_party/libconfig b/third_party/libconfig
new file mode 160000
+Subproject 020a9ce12d1be7ab79ca0674fc957e732ab67f4
diff --git a/ui/FilePage.ui b/ui/FilePage.ui
index 4467e154..7a04c992 100644
--- a/ui/FilePage.ui
+++ b/ui/FilePage.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>1041</width>
- <height>619</height>
+ <width>798</width>
+ <height>476</height>
</rect>
</property>
<property name="sizePolicy">
@@ -136,6 +136,9 @@
<property name="autoFillBackground">
<bool>false</bool>
</property>
+ <property name="dragDropMode">
+ <enum>QAbstractItemView::InternalMove</enum>
+ </property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
@@ -158,31 +161,6 @@
</layout>
</item>
</layout>
- <action name="actionEncrypt">
- <property name="text">
- <string>Encrypt</string>
- </property>
- </action>
- <action name="actionEncryptSign">
- <property name="text">
- <string>EncryptSign</string>
- </property>
- </action>
- <action name="actionDecrypt">
- <property name="text">
- <string>Decrypt</string>
- </property>
- </action>
- <action name="actionSign">
- <property name="text">
- <string>Sign</string>
- </property>
- </action>
- <action name="actionVerify">
- <property name="text">
- <string>Verify</string>
- </property>
- </action>
<action name="actionOpenFile">
<property name="text">
<string>OpenFile</string>
@@ -213,6 +191,11 @@
<string>CreateEmptyFile</string>
</property>
</action>
+ <action name="actionCompressFiles">
+ <property name="text">
+ <string>CompressFiles</string>
+ </property>
+ </action>
</widget>
<resources>
<include location="../gpgfrontend.qrc"/>