aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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/encoding/TextEncodingDetect.cpp313
-rw-r--r--src/ui/encoding/TextEncodingDetect.h85
-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
228 files changed, 10940 insertions, 8679 deletions
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/encoding/TextEncodingDetect.cpp b/src/ui/encoding/TextEncodingDetect.cpp
deleted file mode 100644
index 22ae5897..00000000
--- a/src/ui/encoding/TextEncodingDetect.cpp
+++ /dev/null
@@ -1,313 +0,0 @@
-//
-// Copyright 2015-2016 Jonathan Bennett <[email protected]>
-//
-// https://www.autoitscript.com
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-// Includes
-#include "TextEncodingDetect.h"
-
-using namespace AutoIt::Common;
-
-static const unsigned char TextEncodingDetect_UTF16_BOM_LE[] = {
- (unsigned char)(0xFF), (unsigned char)(0xFE)};
-static const unsigned char TextEncodingDetect_UTF16_BOM_BE[] = {
- (unsigned char)(0xFE), (unsigned char)(0xFF)};
-static const unsigned char TextEncodingDetect_UTF8_BOM[] = {
- (unsigned char)(0xEF), (unsigned char)(0xBB), (unsigned char)(0xBF)};
-
-const unsigned char *TextEncodingDetect::utf16_bom_le_ =
- TextEncodingDetect_UTF16_BOM_LE;
-const unsigned char *TextEncodingDetect::utf16_bom_be_ =
- TextEncodingDetect_UTF16_BOM_BE;
-const unsigned char *TextEncodingDetect::utf8_bom_ =
- TextEncodingDetect_UTF8_BOM;
-
-///////////////////////////////////////////////////////////////////////////////
-// Constructor()
-// Default constructor
-///////////////////////////////////////////////////////////////////////////////
-
-TextEncodingDetect::TextEncodingDetect() {
- // By default, assume nulls can't appear in ANSI/ASCII/UTF8 text files
- null_suggests_binary_ = true;
-
- // Set defaults for utf16 detection based the use of odd/even nulls
- utf16_expected_null_percent_ = 70;
- utf16_unexpected_null_percent_ = 10;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Set the percentages used in utf16 detection using nulls.
-///////////////////////////////////////////////////////////////////////////////
-
-void TextEncodingDetect::SetUtf16UnexpectedNullPercent(int percent) {
- if (percent > 0 && percent < 100) utf16_expected_null_percent_ = percent;
-}
-
-void TextEncodingDetect::SetUtf16ExpectedNullPercent(int percent) {
- if (percent > 0 && percent < 100) utf16_unexpected_null_percent_ = percent;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Simple function to return the length of the BOM for a particular encoding
-// mode.
-///////////////////////////////////////////////////////////////////////////////
-
-int TextEncodingDetect::GetBOMLengthFromEncodingMode(Encoding encoding) {
- int length = 0;
-
- if (encoding == UTF16_BE_BOM || encoding == UTF16_LE_BOM)
- length = 2;
- else if (encoding == UTF8_BOM)
- length = 3;
-
- return length;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Checks if a buffer contains a valid BOM and returns the encoding based on it.
-// Returns encoding "None" if there is no BOM.
-///////////////////////////////////////////////////////////////////////////////
-
-TextEncodingDetect::Encoding TextEncodingDetect::CheckBOM(
- const unsigned char *pBuffer, size_t size) {
- // Check for BOM
- if (size >= 2 && pBuffer[0] == utf16_bom_le_[0] &&
- pBuffer[1] == utf16_bom_le_[1]) {
- return UTF16_LE_BOM;
- } else if (size >= 2 && pBuffer[0] == utf16_bom_be_[0] &&
- pBuffer[1] == utf16_bom_be_[1]) {
- return UTF16_BE_BOM;
- } else if (size >= 3 && pBuffer[0] == utf8_bom_[0] &&
- pBuffer[1] == utf8_bom_[1] && pBuffer[2] == utf8_bom_[2]) {
- return UTF8_BOM;
- } else {
- return None;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Checks if a buffer contains a valid BOM and returns the encoding based on it.
-// If it doesn't contain a BOM it tries to guess what the encoding is or
-// "None" if it just looks like binary data.
-///////////////////////////////////////////////////////////////////////////////
-
-TextEncodingDetect::Encoding TextEncodingDetect::DetectEncoding(
- const unsigned char *pBuffer, size_t size) const {
- // First check if we have a BOM and return that if so
- Encoding encoding = CheckBOM(pBuffer, size);
- if (encoding != None) return encoding;
-
- // Now check for valid UTF8
- encoding = CheckUTF8(pBuffer, size);
- if (encoding != None) return encoding;
-
- // Now try UTF16
- encoding = CheckUTF16NewlineChars(pBuffer, size);
- if (encoding != None) return encoding;
-
- encoding = CheckUTF16ASCII(pBuffer, size);
- if (encoding != None) return encoding;
-
- // ANSI or None (binary) then
- if (!DoesContainNulls(pBuffer, size))
- return ANSI;
- else {
- // Found a null, return based on the preference in null_suggests_binary_
- if (null_suggests_binary_)
- return None;
- else
- return ANSI;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Checks if a buffer contains valid utf8. Returns:
-// None - not valid utf8
-// UTF8_NOBOM - valid utf8 encodings and multibyte sequences
-// ASCII - Only data in the 0-127 range.
-///////////////////////////////////////////////////////////////////////////////
-
-TextEncodingDetect::Encoding TextEncodingDetect::CheckUTF8(
- const unsigned char *pBuffer, size_t size) const {
- // UTF8 Valid sequences
- // 0xxxxxxx ASCII
- // 110xxxxx 10xxxxxx 2-byte
- // 1110xxxx 10xxxxxx 10xxxxxx 3-byte
- // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx 4-byte
- //
- // Width in UTF8
- // Decimal Width
- // 0-127 1 byte
- // 194-223 2 bytes
- // 224-239 3 bytes
- // 240-244 4 bytes
- //
- // Subsequent chars are in the range 128-191
-
- bool only_saw_ascii_range = true;
- size_t pos = 0;
- int more_chars;
-
- while (pos < size) {
- unsigned char ch = pBuffer[pos++];
-
- if (ch == 0 && null_suggests_binary_) {
- return None;
- } else if (ch <= 127) {
- // 1 byte
- more_chars = 0;
- } else if (ch >= 194 && ch <= 223) {
- // 2 Byte
- more_chars = 1;
- } else if (ch >= 224 && ch <= 239) {
- // 3 Byte
- more_chars = 2;
- } else if (ch >= 240 && ch <= 244) {
- // 4 Byte
- more_chars = 3;
- } else {
- return None; // Not utf8
- }
-
- // Check secondary chars are in range if we are expecting any
- while (more_chars && pos < size) {
- only_saw_ascii_range = false; // Seen non-ascii chars now
-
- ch = pBuffer[pos++];
- if (ch < 128 || ch > 191) return None; // Not utf8
-
- --more_chars;
- }
- }
-
- // If we get to here then only valid UTF-8 sequences have been processed
-
- // If we only saw chars in the range 0-127 then we can't assume UTF8 (the
- // caller will need to decide)
- if (only_saw_ascii_range)
- return ASCII;
- else
- return UTF8_NOBOM;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Checks if a buffer contains text that looks like utf16 by scanning for
-// newline chars that would be present even in non-english text.
-// Returns:
-// None - not valid utf16
-// UTF16_LE_NOBOM - looks like utf16 le
-// UTF16_BE_NOBOM - looks like utf16 be
-///////////////////////////////////////////////////////////////////////////////
-
-TextEncodingDetect::Encoding TextEncodingDetect::CheckUTF16NewlineChars(
- const unsigned char *pBuffer, size_t size) {
- if (size < 2) return None;
-
- // Reduce size by 1 so we don't need to worry about bounds checking for pairs
- // of bytes
- size--;
-
- int le_control_chars = 0;
- int be_control_chars = 0;
- unsigned char ch1, ch2;
-
- size_t pos = 0;
- while (pos < size) {
- ch1 = pBuffer[pos++];
- ch2 = pBuffer[pos++];
-
- if (ch1 == 0) {
- if (ch2 == 0x0a || ch2 == 0x0d) ++be_control_chars;
- } else if (ch2 == 0) {
- if (ch1 == 0x0a || ch1 == 0x0d) ++le_control_chars;
- }
-
- // If we are getting both LE and BE control chars then this file is not
- // utf16
- if (le_control_chars && be_control_chars) return None;
- }
-
- if (le_control_chars)
- return UTF16_LE_NOBOM;
- else if (be_control_chars)
- return UTF16_BE_NOBOM;
- else
- return None;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Checks if a buffer contains text that looks like utf16. This is done based
-// the use of nulls which in ASCII/script like text can be useful to identify.
-// Returns:
-// None - not valid utf16
-// UTF16_LE_NOBOM - looks like utf16 le
-// UTF16_BE_NOBOM - looks like utf16 be
-///////////////////////////////////////////////////////////////////////////////
-
-TextEncodingDetect::Encoding TextEncodingDetect::CheckUTF16ASCII(
- const unsigned char *pBuffer, size_t size) const {
- int num_odd_nulls = 0;
- int num_even_nulls = 0;
-
- // Get even nulls
- size_t pos = 0;
- while (pos < size) {
- if (pBuffer[pos] == 0) num_even_nulls++;
-
- pos += 2;
- }
-
- // Get odd nulls
- pos = 1;
- while (pos < size) {
- if (pBuffer[pos] == 0) num_odd_nulls++;
-
- pos += 2;
- }
-
- double even_null_threshold = (num_even_nulls * 2.0) / size;
- double odd_null_threshold = (num_odd_nulls * 2.0) / size;
- double expected_null_threshold = utf16_expected_null_percent_ / 100.0;
- double unexpected_null_threshold = utf16_unexpected_null_percent_ / 100.0;
-
- // Lots of odd nulls, low number of even nulls
- if (even_null_threshold < unexpected_null_threshold &&
- odd_null_threshold > expected_null_threshold)
- return UTF16_LE_NOBOM;
-
- // Lots of even nulls, low number of odd nulls
- if (odd_null_threshold < unexpected_null_threshold &&
- even_null_threshold > expected_null_threshold)
- return UTF16_BE_NOBOM;
-
- // Don't know
- return None;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Checks if a buffer contains any nulls. Used to check for binary vs text data.
-///////////////////////////////////////////////////////////////////////////////
-
-bool TextEncodingDetect::DoesContainNulls(const unsigned char *pBuffer,
- size_t size) {
- size_t pos = 0;
- while (pos < size) {
- if (pBuffer[pos++] == 0) return true;
- }
-
- return false;
-}
diff --git a/src/ui/encoding/TextEncodingDetect.h b/src/ui/encoding/TextEncodingDetect.h
deleted file mode 100644
index 6d861716..00000000
--- a/src/ui/encoding/TextEncodingDetect.h
+++ /dev/null
@@ -1,85 +0,0 @@
-#pragma once
-#ifndef TEXT_ENCODING_DETECT_H_
-#define TEXT_ENCODING_DETECT_H_
-
-//
-// Copyright 2015 Jonathan Bennett <[email protected]>
-//
-// https://www.autoitscript.com
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-// Includes
-#include <stddef.h>
-
-namespace AutoIt::Common {
-class TextEncodingDetect {
- public:
- enum Encoding {
- None, // Unknown or binary
- ANSI, // 0-255
- ASCII, // 0-127
- UTF8_BOM, // UTF8 with BOM
- UTF8_NOBOM, // UTF8 without BOM
- UTF16_LE_BOM, // UTF16 LE with BOM
- UTF16_LE_NOBOM, // UTF16 LE without BOM
- UTF16_BE_BOM, // UTF16-BE with BOM
- UTF16_BE_NOBOM, // UTF16-BE without BOM
- };
-
- TextEncodingDetect();
- ~TextEncodingDetect() = default;
-
- static Encoding CheckBOM(
- const unsigned char *pBuffer,
- size_t size); // Just check if there is a BOM and return
- Encoding DetectEncoding(const unsigned char *pBuffer, size_t size)
- const; // Check BOM and also guess if there is no BOM
- static int GetBOMLengthFromEncodingMode(
- Encoding encoding); // Just return the BOM length of a given mode
-
- void SetNullSuggestsBinary(bool null_suggests_binary) {
- null_suggests_binary_ = null_suggests_binary;
- }
- void SetUtf16UnexpectedNullPercent(int percent);
- void SetUtf16ExpectedNullPercent(int percent);
-
- private:
- TextEncodingDetect(const TextEncodingDetect &);
- const TextEncodingDetect &operator=(const TextEncodingDetect &);
-
- static const unsigned char *utf16_bom_le_;
- static const unsigned char *utf16_bom_be_;
- static const unsigned char *utf8_bom_;
-
- bool null_suggests_binary_;
- int utf16_expected_null_percent_;
- int utf16_unexpected_null_percent_;
-
- Encoding CheckUTF8(const unsigned char *pBuffer,
- size_t size) const; // Check for valid UTF8 with no BOM
- static Encoding CheckUTF16NewlineChars(
- const unsigned char *pBuffer,
- size_t size); // Check for valid UTF16 with no BOM via control chars
- Encoding CheckUTF16ASCII(const unsigned char *pBuffer, size_t size)
- const; // Check for valid UTF16 with no BOM via null distribution
- static bool DoesContainNulls(const unsigned char *pBuffer,
- size_t size); // Check for nulls
-};
-
-} // namespace AutoIt::Common
-
-//////////////////////////////////////////////////////////////////////
-
-#endif
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