aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2021-08-29 10:49:58 +0000
committerSaturneric <[email protected]>2021-08-29 10:49:58 +0000
commitdaaa83549d42395161e34a40e18c3615801b1501 (patch)
tree7ae4c67a31e9eea8a7bda4719fbdac3ac2e730a9 /src
parentUpdate version settings. (diff)
downloadGpgFrontend-daaa83549d42395161e34a40e18c3615801b1501.tar.gz
GpgFrontend-daaa83549d42395161e34a40e18c3615801b1501.zip
Start to rewrite gpg core.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt281
-rw-r--r--src/MainWindow.cpp2
-rw-r--r--src/advance/UnknownSignersChecker.cpp4
-rw-r--r--src/gpg/CMakeLists.txt10
-rw-r--r--src/gpg/GpgFileOpera.cpp12
-rw-r--r--src/gpg/GpgKey.cpp265
-rw-r--r--src/gpg/GpgKeySignature.cpp12
-rw-r--r--src/gpg/GpgSubKey.cpp29
-rw-r--r--src/gpg/GpgUID.cpp15
-rw-r--r--src/gpg/function/BasicOperator.cpp254
-rw-r--r--src/gpg/function/GpgKeyGetter.cpp38
-rw-r--r--src/gpg/function/GpgKeyManager.cpp76
-rw-r--r--src/gpg/function/UidOperator.cpp45
-rw-r--r--src/gpg/gpg_context/GpgContext.cpp177
-rw-r--r--src/gpg/gpg_context/GpgContextBasicOpera.cpp315
-rw-r--r--src/gpg/gpg_context/GpgContextKeyInfo.cpp62
-rw-r--r--src/gpg/gpg_context/GpgContextKeyOpera.cpp135
-rw-r--r--src/gpg/gpg_context/GpgContextSubkeyOpera.cpp8
-rw-r--r--src/gpg/gpg_context/GpgContextUIDOpera.cpp80
-rw-r--r--src/gpg/result_analyse/DecryptResultAnalyse.cpp4
-rw-r--r--src/gpg/result_analyse/SignResultAnalyse.cpp4
-rw-r--r--src/gpg/result_analyse/VerifyResultAnalyse.cpp8
-rw-r--r--src/main.cpp18
-rw-r--r--src/server/ComUtils.cpp20
-rw-r--r--src/server/api/PubkeyGetter.cpp2
-rw-r--r--src/server/api/PubkeyUploader.cpp2
-rw-r--r--src/ui/CMakeLists.txt4
-rwxr-xr-xsrc/ui/FileEncryptionDialog.cpp6
-rw-r--r--src/ui/KeyImportDetailDialog.cpp4
-rwxr-xr-xsrc/ui/KeyMgmt.cpp10
-rw-r--r--src/ui/KeyServerImportDialog.cpp4
-rw-r--r--src/ui/KeyUploadDialog.cpp2
-rw-r--r--src/ui/VerifyDetailsDialog.cpp2
-rw-r--r--src/ui/Wizard.cpp4
-rw-r--r--src/ui/help/AboutDialog.cpp2
-rw-r--r--src/ui/keygen/KeygenDialog.cpp2
-rw-r--r--src/ui/keygen/SubkeyGenerateDialog.cpp2
-rw-r--r--src/ui/keypair_details/KeyDetailsDialog.cpp2
-rw-r--r--src/ui/keypair_details/KeyNewUIDDialog.cpp2
-rw-r--r--src/ui/keypair_details/KeyPairDetailTab.cpp12
-rw-r--r--src/ui/keypair_details/KeyPairSubkeyTab.cpp2
-rw-r--r--src/ui/keypair_details/KeyPairUIDTab.cpp2
-rw-r--r--src/ui/keypair_details/KeySetExpireDateDialog.cpp2
-rw-r--r--src/ui/keypair_details/KeyUIDSignDialog.cpp2
-rw-r--r--src/ui/main_window/MainWindowFileSlotFunction.cpp8
-rw-r--r--src/ui/main_window/MainWindowServerSlotFunction.cpp4
-rw-r--r--src/ui/main_window/MainWindowSlotFunction.cpp16
-rw-r--r--src/ui/settings/SettingsDialog.cpp2
-rw-r--r--src/ui/settings/SettingsGeneral.cpp8
-rw-r--r--src/ui/widgets/InfoBoardWidget.cpp2
-rw-r--r--src/ui/widgets/KeyList.cpp12
-rw-r--r--src/ui/widgets/SignersPicker.cpp4
-rw-r--r--src/ui/widgets/VerifyKeyDetailBox.cpp4
53 files changed, 827 insertions, 1177 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 200f5beb..555e5b39 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,146 +1,187 @@
-add_subdirectory(gpg)
-add_subdirectory(ui)
-add_subdirectory(smtp)
-add_subdirectory(server)
-add_subdirectory(advance)
+if(QT_MOC_CONFIG)
+ file(GLOB_RECURSE GPGFRONTEND_HEADER_FILES RELACTIVE ${CMAKE_SOURCE_DIR}/include/*.h)
+ qt5_wrap_cpp(QT5_MOCS ${GPGFRONTEND_HEADER_FILES} TARGET ${AppName})
+endif()
+
+if(GPG_CORE)
+ message(STATUS "Build Gpg Core")
+ add_subdirectory(gpg)
+endif()
-aux_source_directory(. BASE_SOURCE)
+if(UI_CORE)
+ message(STATUS "Build UI Core")
+ add_subdirectory(ui)
+endif()
-set(APP_ICON_RESOURCE_WINDOWS "${CMAKE_SOURCE_DIR}/gpgfrontend.rc")
-set_property(SOURCE gpgfrontend.rc APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_SOURCE_DIR}/gpgfrontend.ico)
+if(SMTP_SUPPORT)
+ message(STATUS "Build SMTP Support")
+ add_subdirectory(smtp)
+endif()
+if(SERVER_SUPPORT)
+ message(STATUS "Build Server Support")
+ add_subdirectory(server)
+endif()
-file(GLOB_RECURSE GPGFRONTEND_HEADER_FILES RELACTIVE ${CMAKE_SOURCE_DIR}/include/*.h)
-qt5_wrap_cpp(QT5_MOCS ${GPGFRONTEND_HEADER_FILES} TARGET ${AppName})
+if(ADVANCE_SUPPORT)
+ message(STATUS "Build Advance Support")
+ add_subdirectory(advance)
+endif()
-# Set Binary Output Path
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/release)
-message(STATUS "CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
+if(APPLICATION_BUILD)
+ aux_source_directory(. BASE_SOURCE)
+ set(APP_ICON_RESOURCE_WINDOWS "${CMAKE_SOURCE_DIR}/gpgfrontend.rc")
+ set_property(SOURCE gpgfrontend.rc APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_SOURCE_DIR}/gpgfrontend.ico)
-# Set Resource Output Path
-if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
- if(APPLE)
- set(RESOURCE_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Resources)
- elseif(LINUX)
- file(COPY ${CMAKE_SOURCE_DIR}/resource/gpgfrontend DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
- set(RESOURCE_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gpgfrontend/usr/share)
+ # Set Binary Output Path
+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/release)
+ message(STATUS "CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
+endif()
+
+
+if(APPLICATION_BUILD)
+ # Set Resource Output Path
+ if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
+ if(APPLE)
+ set(RESOURCE_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Resources)
+ elseif(LINUX)
+ file(COPY ${CMAKE_SOURCE_DIR}/resource/gpgfrontend DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
+ set(RESOURCE_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gpgfrontend/usr/share)
+ else()
+ set(RESOURCE_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
+ endif()
else()
set(RESOURCE_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
-else()
- set(RESOURCE_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
+ message(STATUS "RESOURCE_OUTPUT_DIRECTORY ${RESOURCE_OUTPUT_DIRECTORY}")
endif()
-message(STATUS "RESOURCE_OUTPUT_DIRECTORY ${RESOURCE_OUTPUT_DIRECTORY}")
# Get ALL SOURCE FILES
file(GLOB_RECURSE ALL_SOURCE_FILES RELACTIVE ${CMAKE_SOURCE_DIR}/src/*.cpp)
-# Set Translation Files
-set(QT_TS_FILES
- gpgfrontend_en_us.ts gpgfrontend_zh_cn.ts
- gpgfrontend_fr.ts gpgfrontend_ru.ts gpgfrontend_es.ts)
-list(TRANSFORM QT_TS_FILES PREPEND ${CMAKE_SOURCE_DIR}/resource/ts/)
-message(STATUS "QT_TS_FILES ${QT_TS_FILES}")
-set(QT_QM_FILES_OUTPUT_DIR ${RESOURCE_OUTPUT_DIRECTORY}/ts)
-set_source_files_properties(${QT_TS_FILES} PROPERTIES OUTPUT_LOCATION ${QT_QM_FILES_OUTPUT_DIR})
-QT5_create_translation(QON_QM_FILES ${CMAKE_SOURCE_DIR} ${QT_TS_FILES})
-message(STATUS "QON_QM_FILES ${QON_QM_FILES}")
-add_custom_target(translations DEPENDS ${QON_QM_FILES})
-
-# Set Build Information
-configure_file(${CMAKE_SOURCE_DIR}/include/GpgFrontend.h.in ${CMAKE_SOURCE_DIR}/include/GpgFrontend.h @ONLY)
-configure_file(${CMAKE_SOURCE_DIR}/include/GpgFrontendBuildInfo.h.in ${CMAKE_SOURCE_DIR}/include/GpgFrontendBuildInfo.h @ONLY)
-
-# Copy Resource Files
-file(COPY ${CMAKE_SOURCE_DIR}/resource/css DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
-file(COPY ${CMAKE_SOURCE_DIR}/resource/icons DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
-file(COPY ${CMAKE_SOURCE_DIR}/resource/conf DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
-
-if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
- if(APPLE)
- file(COPY ${CMAKE_SOURCE_DIR}/gpgfrontend.icns DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
- # Refresh App Bundle
- file(REMOVE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${AppName}.app)
- elseif(LINUX)
- file(REMOVE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gpgfrontend/usr/bin/${AppName})
- endif()
+if(MULTI_LANG_SUPPORT)
+ # Set Translation Files
+ set(QT_TS_FILES
+ gpgfrontend_en_us.ts gpgfrontend_zh_cn.ts
+ gpgfrontend_fr.ts gpgfrontend_ru.ts gpgfrontend_es.ts)
+ list(TRANSFORM QT_TS_FILES PREPEND ${CMAKE_SOURCE_DIR}/resource/ts/)
+ message(STATUS "QT_TS_FILES ${QT_TS_FILES}")
+ set(QT_QM_FILES_OUTPUT_DIR ${RESOURCE_OUTPUT_DIRECTORY}/ts)
+ set_source_files_properties(${QT_TS_FILES} PROPERTIES OUTPUT_LOCATION ${QT_QM_FILES_OUTPUT_DIR})
+ QT5_create_translation(QON_QM_FILES ${CMAKE_SOURCE_DIR} ${QT_TS_FILES})
+ message(STATUS "QON_QM_FILES ${QON_QM_FILES}")
+ add_custom_target(translations DEPENDS ${QON_QM_FILES})
endif()
-# Copy Utils Files
-if(MINGW)
- message(STATUS "Copying Dependent DLL For Windows Runtime Env")
- file(COPY ${CMAKE_SOURCE_DIR}/resource/utils/lib/ DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
- file(COPY ${CMAKE_SOURCE_DIR}/resource/utils/gpgme/ DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
- file(COPY ${CMAKE_SOURCE_DIR}/resource/utils/bearer DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
- file(COPY ${CMAKE_SOURCE_DIR}/resource/utils/iconengines DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
- file(COPY ${CMAKE_SOURCE_DIR}/resource/utils/imageformats DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
- file(COPY ${CMAKE_SOURCE_DIR}/resource/utils/printsupport DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
- file(COPY ${CMAKE_SOURCE_DIR}/resource/utils/platforms DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
- file(COPY ${CMAKE_SOURCE_DIR}/resource/utils/openssl/ DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
+if(BASIC_ENV_CONFIG)
+ # Set Build Information
+ configure_file(${CMAKE_SOURCE_DIR}/include/GpgFrontend.h.in ${CMAKE_SOURCE_DIR}/include/GpgFrontend.h @ONLY)
+ configure_file(${CMAKE_SOURCE_DIR}/include/GpgFrontendBuildInfo.h.in ${CMAKE_SOURCE_DIR}/include/GpgFrontendBuildInfo.h @ONLY)
endif()
-set(RESOURCE_FILES ${CMAKE_SOURCE_DIR}/gpgfrontend.qrc ${APP_ICON_RESOURCE_WINDOWS} ${QON_QM_FILES})
-add_custom_target(resources ALL DEPENDS ${RESOURCE_FILES})
-add_dependencies(resources translations)
+if(APPLICATION_BUILD)
+ # Copy Resource Files
+ file(COPY ${CMAKE_SOURCE_DIR}/resource/css DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
+ file(COPY ${CMAKE_SOURCE_DIR}/resource/icons DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
+ file(COPY ${CMAKE_SOURCE_DIR}/resource/conf DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
+endif()
+
+if(APPLICATION_BUILD)
+ if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
+ if(APPLE)
+ file(COPY ${CMAKE_SOURCE_DIR}/gpgfrontend.icns DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
+ # Refresh App Bundle
+ file(REMOVE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${AppName}.app)
+ elseif(LINUX)
+ file(REMOVE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gpgfrontend/usr/bin/${AppName})
+ endif()
+ endif()
+endif()
-if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
+if(APPLICATION_BUILD)
+ # Copy Utils Files
if(MINGW)
- add_executable(${AppName} WIN32 ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
- elseif(APPLE)
- add_executable(${AppName} MACOSX_BUNDLE ${ICON_RESOURCE} ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
- set_target_properties(${AppName} PROPERTIES
- BUNDLE True
- MACOSX_BUNDLE_GUI_IDENTIFIER pub.gpgfrontend.gpgfrontend
- MACOSX_BUNDLE_BUNDLE_NAME ${AppName}
- MACOSX_BUNDLE_LONG_VERSION_STRING ${BUILD_VERSION}
- MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION}
- MACOSX_BUNDLE_BUNDLE_VERSION ${BUILD_VERSION}
- MACOSX_BUNDLE_ICON_FILE "gpgfrontend.icns")
- add_custom_command(TARGET ${AppName} POST_BUILD
- COMMAND /bin/rm -rf ./${AppName}.app/Contents/Resources
- WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
- COMMENT "Deleting Resources in App Bundle")
- add_custom_command(TARGET ${AppName} POST_BUILD
- COMMAND /bin/mv -n ./Resources ./${AppName}.app/Contents/
- WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
- COMMENT "Copying Resources into App Bundle Resource")
- elseif(LINUX)
- add_executable(${AppName} ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
- add_custom_command(TARGET ${AppName} POST_BUILD
- COMMAND /bin/mkdir ./gpgfrontend/usr/bin && /bin/mv -f ./${AppName} ./gpgfrontend/usr/bin/
- WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
- COMMENT "Copying Binary into App Image")
- add_custom_command(TARGET ${AppName} POST_BUILD
- COMMAND /bin/mkdir ./gpgfrontend/usr/lib
+ message(STATUS "Copying Dependent DLL For Windows Runtime Env")
+ file(COPY ${CMAKE_SOURCE_DIR}/resource/utils/lib/ DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
+ file(COPY ${CMAKE_SOURCE_DIR}/resource/utils/gpgme/ DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
+ file(COPY ${CMAKE_SOURCE_DIR}/resource/utils/bearer DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
+ file(COPY ${CMAKE_SOURCE_DIR}/resource/utils/iconengines DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
+ file(COPY ${CMAKE_SOURCE_DIR}/resource/utils/imageformats DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
+ file(COPY ${CMAKE_SOURCE_DIR}/resource/utils/printsupport DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
+ file(COPY ${CMAKE_SOURCE_DIR}/resource/utils/platforms DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
+ file(COPY ${CMAKE_SOURCE_DIR}/resource/utils/openssl/ DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN)
+ endif()
+endif()
+
+if(APPLICATION_BUILD)
+ set(RESOURCE_FILES ${CMAKE_SOURCE_DIR}/gpgfrontend.qrc ${APP_ICON_RESOURCE_WINDOWS} ${QON_QM_FILES})
+ add_custom_target(resources ALL DEPENDS ${RESOURCE_FILES})
+ if(MULTI_LANG_SUPPORT)
+ add_dependencies(resources translations)
+ endif()
+endif()
+
+if(APPLICATION_BUILD)
+ if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
+ if(MINGW)
+ add_executable(${AppName} WIN32 ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
+ elseif(APPLE)
+ add_executable(${AppName} MACOSX_BUNDLE ${ICON_RESOURCE} ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
+ set_target_properties(${AppName} PROPERTIES
+ BUNDLE True
+ MACOSX_BUNDLE_GUI_IDENTIFIER pub.gpgfrontend.gpgfrontend
+ MACOSX_BUNDLE_BUNDLE_NAME ${AppName}
+ MACOSX_BUNDLE_LONG_VERSION_STRING ${BUILD_VERSION}
+ MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION}
+ MACOSX_BUNDLE_BUNDLE_VERSION ${BUILD_VERSION}
+ MACOSX_BUNDLE_ICON_FILE "gpgfrontend.icns")
+ add_custom_command(TARGET ${AppName} POST_BUILD
+ COMMAND /bin/rm -rf ./${AppName}.app/Contents/Resources
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
- COMMENT "Complement to build the required architecture")
+ COMMENT "Deleting Resources in App Bundle")
+ add_custom_command(TARGET ${AppName} POST_BUILD
+ COMMAND /bin/mv -n ./Resources ./${AppName}.app/Contents/
+ WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
+ COMMENT "Copying Resources into App Bundle Resource")
+ elseif(LINUX)
+ add_executable(${AppName} ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
+ add_custom_command(TARGET ${AppName} POST_BUILD
+ COMMAND /bin/mkdir ./gpgfrontend/usr/bin && /bin/mv -f ./${AppName} ./gpgfrontend/usr/bin/
+ WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
+ COMMENT "Copying Binary into App Image")
+ add_custom_command(TARGET ${AppName} POST_BUILD
+ COMMAND /bin/mkdir ./gpgfrontend/usr/lib
+ WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
+ COMMENT "Complement to build the required architecture")
+ else()
+ add_executable(${AppName} ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
+ endif()
else()
add_executable(${AppName} ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
endif()
-else()
- add_executable(${AppName} ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
-endif()
-
-set(GPGFRONTEND_LIBS smtp gpgfrontend-ui advance server gpg)
-set(QT_DEPENDENCY_LIBS Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core)
-
-IF (MINGW)
- message(STATUS "Link Application Static Library For MINGW")
- target_link_libraries(${AppName}
- ${GPGFRONTEND_LIBS}
- ${QT_DEPENDENCY_LIBS}
- crypto ssl)
-elseif(APPLE)
- message(STATUS "Link Application Static Library For macOS")
- target_link_libraries(${AppName}
- ${GPGFRONTEND_LIBS}
- ${QT_DEPENDENCY_LIBS}
- crypto ssl)
-else()
- message(STATUS "Link Application Static Library For UNIX")
- target_link_libraries(${AppName}
- ${GPGFRONTEND_LIBS}
- ${QT_DEPENDENCY_LIBS}
- crypto ssl pthread)
+endif()
+
+if(APPLICATION_BUILD)
+ set(GPGFRONTEND_LIBS smtp gpgfrontend-ui advance server gpg_core)
+ set(QT_DEPENDENCY_LIBS Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core)
+ IF (MINGW)
+ message(STATUS "Link Application Static Library For MINGW")
+ target_link_libraries(${AppName}
+ ${GPGFRONTEND_LIBS}
+ ${QT_DEPENDENCY_LIBS}
+ crypto ssl)
+ elseif(APPLE)
+ message(STATUS "Link Application Static Library For macOS")
+ target_link_libraries(${AppName}
+ ${GPGFRONTEND_LIBS}
+ ${QT_DEPENDENCY_LIBS}
+ crypto ssl)
+ else()
+ message(STATUS "Link Application Static Library For UNIX")
+ target_link_libraries(${AppName}
+ ${GPGFRONTEND_LIBS}
+ ${QT_DEPENDENCY_LIBS}
+ crypto ssl pthread)
+ endif()
endif()
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 73f55672..d2c306ef 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -35,7 +35,7 @@ MainWindow::MainWindow()
auto waitingDialog = new WaitingDialog(tr("Loading Gnupg"), this);
// Init Gnupg
- auto ctx_thread = QThread::create([&]() { mCtx = new GpgME::GpgContext(); });
+ auto ctx_thread = QThread::create([&]() { mCtx = new GpgFrontend::GpgContext(); });
ctx_thread->start();
while (ctx_thread->isRunning())
QApplication::processEvents();
diff --git a/src/advance/UnknownSignersChecker.cpp b/src/advance/UnknownSignersChecker.cpp
index 1b087b5c..73516beb 100644
--- a/src/advance/UnknownSignersChecker.cpp
+++ b/src/advance/UnknownSignersChecker.cpp
@@ -25,7 +25,7 @@
#include "advance/UnknownSignersChecker.h"
-UnknownSignersChecker::UnknownSignersChecker(GpgME::GpgContext *ctx, gpgme_verify_result_t result) :
+UnknownSignersChecker::UnknownSignersChecker(GpgFrontend::GpgContext *ctx, gpgme_verify_result_t result) :
appPath(qApp->applicationDirPath()), settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini"), mCtx(ctx),
mResult(result) {
@@ -72,7 +72,7 @@ void UnknownSignersChecker::start() {
void UnknownSignersChecker::check_signer(gpgme_signature_t sign) {
- auto key = mCtx->getKeyByFpr(sign->fpr);
+ auto key = mCtx->getKeyRefByFpr(sign->fpr);
if (!key.good) {
qDebug() << "Find Unknown FingerPrint " << sign->fpr;
unknownFprs.append(sign->fpr);
diff --git a/src/gpg/CMakeLists.txt b/src/gpg/CMakeLists.txt
index 2bcacade..2eabceaf 100644
--- a/src/gpg/CMakeLists.txt
+++ b/src/gpg/CMakeLists.txt
@@ -1,8 +1,9 @@
aux_source_directory(./result_analyse GPG_SOURCE)
aux_source_directory(./gpg_context GPG_SOURCE)
+aux_source_directory(./function GPG_SOURCE)
aux_source_directory(. GPG_SOURCE)
-add_library(gpg STATIC ${GPG_SOURCE})
+add_library(gpg_core STATIC ${GPG_SOURCE})
set(UTILS_DIR ${CMAKE_SOURCE_DIR}/utils)
@@ -10,19 +11,18 @@ set(GPGME_LIB_DIR ${UTILS_DIR}/gpgme/lib)
if (MINGW)
message(STATUS "Link GPG Static Library For MINGW")
- target_link_libraries(gpg
+ target_link_libraries(gpg_core
gpgme gpg-error assuan
Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core
wsock32)
elseif(APPLE)
message(STATUS "Link GPG Static Library For macOS")
- target_link_libraries(gpg
+ target_link_libraries(gpg_core
/usr/local/lib/libgpgme.a /usr/local/lib/libgpg-error.a /usr/local/lib/libassuan.a
Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core)
else()
-
message(STATUS "Link GPG Static Library For Unix")
- target_link_libraries(gpg
+ target_link_libraries(gpg_core
/usr/local/lib/libgpgme.a /usr/local/lib/libgpg-error.a /usr/local/lib/libassuan.a
Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core)
endif()
diff --git a/src/gpg/GpgFileOpera.cpp b/src/gpg/GpgFileOpera.cpp
index af50c79a..727bfb6f 100644
--- a/src/gpg/GpgFileOpera.cpp
+++ b/src/gpg/GpgFileOpera.cpp
@@ -23,7 +23,7 @@
*/
#include "gpg/GpgFileOpera.h"
-gpgme_error_t GpgFileOpera::encryptFile(GpgME::GpgContext *ctx, QVector<GpgKey> &keys, const QString &mPath,
+gpgme_error_t GpgFileOpera::encryptFile(GpgFrontend::GpgContext *ctx, QVector<GpgKey> &keys, const QString &mPath,
gpgme_encrypt_result_t *result) {
QFileInfo fileInfo(mPath);
@@ -55,7 +55,7 @@ gpgme_error_t GpgFileOpera::encryptFile(GpgME::GpgContext *ctx, QVector<GpgKey>
return error;
}
-gpgme_error_t GpgFileOpera::decryptFile(GpgME::GpgContext *ctx, const QString &mPath, gpgme_decrypt_result_t *result) {
+gpgme_error_t GpgFileOpera::decryptFile(GpgFrontend::GpgContext *ctx, const QString &mPath, gpgme_decrypt_result_t *result) {
QFileInfo fileInfo(mPath);
@@ -96,7 +96,7 @@ gpgme_error_t GpgFileOpera::decryptFile(GpgME::GpgContext *ctx, const QString &m
return error;
}
-gpgme_error_t GpgFileOpera::signFile(GpgME::GpgContext *ctx, QVector<GpgKey> &keys, const QString &mPath,
+gpgme_error_t GpgFileOpera::signFile(GpgFrontend::GpgContext *ctx, QVector<GpgKey> &keys, const QString &mPath,
gpgme_sign_result_t *result) {
QFileInfo fileInfo(mPath);
@@ -130,7 +130,7 @@ gpgme_error_t GpgFileOpera::signFile(GpgME::GpgContext *ctx, QVector<GpgKey> &ke
return error;
}
-gpgme_error_t GpgFileOpera::verifyFile(GpgME::GpgContext *ctx, const QString &mPath, gpgme_verify_result_t *result) {
+gpgme_error_t GpgFileOpera::verifyFile(GpgFrontend::GpgContext *ctx, const QString &mPath, gpgme_verify_result_t *result) {
qDebug() << "Verify File Path" << mPath;
@@ -165,7 +165,7 @@ gpgme_error_t GpgFileOpera::verifyFile(GpgME::GpgContext *ctx, const QString &mP
}
}
-gpg_error_t GpgFileOpera::encryptSignFile(GpgME::GpgContext *ctx, QVector<GpgKey> &keys, const QString &mPath,
+gpg_error_t GpgFileOpera::encryptSignFile(GpgFrontend::GpgContext *ctx, QVector<GpgKey> &keys, const QString &mPath,
gpgme_encrypt_result_t *encr_res,
gpgme_sign_result_t *sign_res) {
@@ -205,7 +205,7 @@ gpg_error_t GpgFileOpera::encryptSignFile(GpgME::GpgContext *ctx, QVector<GpgKey
return error;
}
-gpg_error_t GpgFileOpera::decryptVerifyFile(GpgME::GpgContext *ctx, const QString &mPath, gpgme_decrypt_result_t *decr_res,
+gpg_error_t GpgFileOpera::decryptVerifyFile(GpgFrontend::GpgContext *ctx, const QString &mPath, gpgme_decrypt_result_t *decr_res,
gpgme_verify_result_t *verify_res) {
qDebug() << "Decrypt Verify File Path" << mPath;
diff --git a/src/gpg/GpgKey.cpp b/src/gpg/GpgKey.cpp
index cd62fc5d..47cc32f1 100644
--- a/src/gpg/GpgKey.cpp
+++ b/src/gpg/GpgKey.cpp
@@ -22,253 +22,44 @@
*
*/
-#include "gpg/GpgKey.h"
+#include "gpg/model/GpgKey.h"
-void GpgKey::parse(gpgme_key_t key) {
-
- if(key == nullptr) return;
-
- good = true;
- key_refer = key;
- gpgme_key_ref(key_refer);
-
- is_private_key = key->secret;
- fpr = key->fpr;
- protocol = key->protocol;
- expired = (key->expired != 0u);
- revoked = (key->revoked != 0u);
-
- disabled = key->disabled;
-
- can_authenticate = key->can_authenticate;
- can_certify = key->can_certify;
- can_encrypt = key->can_encrypt;
- can_sign = key->can_sign;
-
- last_update = QDateTime(QDateTime::fromTime_t(key->last_update));
-
- switch (key->owner_trust) {
- case GPGME_VALIDITY_UNKNOWN:
- owner_trust = "Unknown";
- break;
- case GPGME_VALIDITY_UNDEFINED:
- owner_trust = "Undefined";
- break;
- case GPGME_VALIDITY_NEVER:
- owner_trust = "Never";
- break;
- case GPGME_VALIDITY_MARGINAL:
- owner_trust = "Marginal";
- break;
- case GPGME_VALIDITY_FULL:
- owner_trust = "FULL";
- break;
- case GPGME_VALIDITY_ULTIMATE:
- owner_trust = "Ultimate";
- break;
- }
-
- uids.clear();
- auto uid = key->uids;
-
- while (uid != nullptr) {
- uids.push_back(GpgUID(uid));
- uid = uid->next;
- }
-
- if (!uids.isEmpty()) {
- name = uids.first().name;
- email = uids.first().email;
- comment = uids.first().comment;
- }
-
- subKeys.clear();
- auto next = key->subkeys;
-
- while (next != nullptr) {
- subKeys.push_back(GpgSubKey(next));
- next = next->next;
- }
-
- if (!subKeys.isEmpty()) {
- id = subKeys.first().id;
- expires = subKeys.first().expires;
- pubkey_algo = subKeys.first().pubkey_algo;
- create_time = subKeys.first().timestamp;
- length = subKeys.first().length;
- has_master_key = subKeys.first().secret;
- } else {
- id = "";
- }
-
-}
-
-GpgKey::GpgKey(GpgKey &&k) noexcept {
-
- id = std::move(k.id);
- name = std::move(k.name);
- email = std::move(k.email);
- comment = std::move(k.comment);
- fpr = std::move(k.fpr);
- protocol = std::move(k.protocol);
- owner_trust = std::move(k.owner_trust);
- pubkey_algo = std::move(k.pubkey_algo);
- last_update = std::move(k.last_update);
- expires = std::move(k.expires);
- create_time = std::move(k.create_time);
-
- length = k.length;
- k.length = 0;
-
- can_encrypt = k.can_encrypt;
- can_sign = k.can_sign;
- can_certify = k.can_certify;
- can_authenticate = k.can_authenticate;
-
-
- is_private_key = k.is_private_key;
- expired = k.expired;
- revoked = k.revoked;
- disabled = k.disabled;
- k.has_master_key = k.has_master_key;
-
- good = k.good;
- k.good = false;
-
- subKeys = std::move(k.subKeys);
- uids = std::move(k.uids);
-
- key_refer = k.key_refer;
- k.key_refer = nullptr;
-
-}
-
-GpgKey &GpgKey::operator=(const GpgKey &k) {
-
- id = k.id;
- name = k.name;
- email = k.email;
- comment = k.comment;
- fpr = k.fpr;
- protocol = k.protocol;
- owner_trust = k.owner_trust;
- pubkey_algo = k.pubkey_algo;
- last_update = k.last_update;
- expires = k.expires;
- create_time = k.create_time;
-
- length = k.length;
-
- can_encrypt = k.can_encrypt;
- can_sign = k.can_sign;
- can_certify = k.can_certify;
- can_authenticate = k.can_authenticate;
-
- is_private_key = k.is_private_key;
- expired = k.expired;
- revoked = k.revoked;
- disabled = k.disabled;
-
- has_master_key = k.has_master_key;
-
- good = k.good;
-
- subKeys = k.subKeys;
- uids = k.uids;
-
- key_refer = k.key_refer;
- gpgme_key_ref(key_refer);
-
- return *this;
-}
-
-GpgKey::GpgKey(const GpgKey &k) :
- id(k.id), name(k.name), email(k.email), comment(k.comment),
- fpr(k.fpr), protocol(k.protocol), owner_trust(k.owner_trust),
- pubkey_algo(k.pubkey_algo), last_update(k.last_update),
- expires(k.expires), create_time(k.create_time){
-
- length = k.length;
-
- can_encrypt = k.can_encrypt;
- can_sign = k.can_sign;
- can_certify = k.can_certify;
- can_authenticate = k.can_authenticate;
-
- is_private_key = k.is_private_key;
- expired = k.expired;
- revoked = k.revoked;
- disabled = k.disabled;
-
- has_master_key = k.has_master_key;
-
- good = k.good;
-
- subKeys = k.subKeys;
- uids = k.uids;
-
- key_refer = k.key_refer;
- gpgme_key_ref(key_refer);
+GpgFrontend::GpgKey::GpgKey(gpgme_key_t &&key) : _key_ref(key, [&](gpgme_key_t key) { gpgme_key_release(key); }) {}
+GpgFrontend::GpgKey::GpgKey(GpgKey &&k) noexcept {
+ swap(_key_ref, k._key_ref);
}
-GpgKey &GpgKey::operator=(GpgKey &&k) noexcept {
-
- id = std::move(k.id);
- name = std::move(k.name);
- email = std::move(k.email);
- comment = std::move(k.comment);
- fpr = std::move(k.fpr);
- protocol = std::move(k.protocol);
- owner_trust = std::move(k.owner_trust);
- pubkey_algo = std::move(k.pubkey_algo);
- last_update = std::move(k.last_update);
- expires = std::move(k.expires);
- create_time = std::move(k.create_time);
-
- length = k.length;
- k.length = 0;
-
- can_encrypt = k.can_encrypt;
- can_sign = k.can_sign;
- can_certify = k.can_certify;
- can_authenticate = k.can_authenticate;
-
-
- is_private_key = k.is_private_key;
- expired = k.expired;
- revoked = k.revoked;
- disabled = k.disabled;
-
- has_master_key = k.has_master_key;
-
- good = k.good;
- k.good = false;
-
- subKeys = std::move(k.subKeys);
- uids = std::move(k.uids);
-
- key_refer = k.key_refer;
- k.key_refer = nullptr;
-
+GpgFrontend::GpgKey &GpgFrontend::GpgKey::operator=(GpgKey &&k) noexcept {
+ swap(_key_ref, k._key_ref);
return *this;
}
-GpgKey::~GpgKey() {
- if(key_refer != nullptr && good) {
- gpgme_key_unref(key_refer);
+std::unique_ptr<std::vector<GpgFrontend::GpgSubKey>> GpgFrontend::GpgKey::subKeys() const {
+ auto p_keys = std::make_unique<std::vector<GpgSubKey>>();
+ auto next = _key_ref->subkeys;
+ while (next != nullptr) {
+ p_keys->push_back(std::move(GpgSubKey(next)));
+ next = next->next;
}
+ return p_keys;
}
-GpgKey::GpgKey(gpgme_key_t key) {
- parse(key);
+std::unique_ptr<std::vector<GpgFrontend::GpgUID>> GpgFrontend::GpgKey::uids() const {
+ auto p_uids = std::make_unique<std::vector<GpgUID>>();
+ auto uid_next = _key_ref->uids;
+ while (uid_next != nullptr) {
+ p_uids->push_back(std::move(GpgUID(uid_next)));
+ uid_next = uid_next->next;
+ }
+ return p_uids;
}
-void GpgKey::swapKeyRefer(gpgme_key_t key) {
-
- if(key == nullptr) return;
-
- gpgme_key_unref(key_refer);
- key_refer = nullptr;
- parse(key);
+bool GpgFrontend::GpgKey::canSignActual() const {
+ auto subkeys = subKeys();
+ if (std::any_of(subkeys->begin(), subkeys->end(), [](const GpgSubKey &subkey) -> bool {
+ return subkey.secret() && subkey.can_sign() && !subkey.disabled() && !subkey.revoked() && !subkey.expired();
+ }))
+ return true;
+ else return false;
}
diff --git a/src/gpg/GpgKeySignature.cpp b/src/gpg/GpgKeySignature.cpp
index 142d1550..d7e7c53e 100644
--- a/src/gpg/GpgKeySignature.cpp
+++ b/src/gpg/GpgKeySignature.cpp
@@ -22,13 +22,7 @@
*
*/
-#include "gpg/GpgKeySignature.h"
+#include "gpg/model/GpgKeySignature.h"
-GpgKeySignature::GpgKeySignature(gpgme_key_sig_t key_sig) :
- revoked(key_sig->revoked), expired(key_sig->expired), invalid(key_sig->invalid),
- exportable(key_sig->exportable), status(key_sig->status),
- keyid(key_sig->keyid), pubkey_algo(gpgme_pubkey_algo_name(key_sig->pubkey_algo)),
- uid(key_sig->uid), name(key_sig->name), email(key_sig->email), comment(key_sig->comment),
- create_time(QDateTime::fromTime_t(key_sig->timestamp)), expire_time(QDateTime::fromTime_t(key_sig->expires)){
-
-}
+GpgFrontend::GpgKeySignature::GpgKeySignature(gpgme_key_sig_t sig) : _signature_ref(sig,
+ [&](gpgme_key_sig_t signature) {}) {}
diff --git a/src/gpg/GpgSubKey.cpp b/src/gpg/GpgSubKey.cpp
index 4adda132..87476d56 100644
--- a/src/gpg/GpgSubKey.cpp
+++ b/src/gpg/GpgSubKey.cpp
@@ -21,31 +21,6 @@
* by Saturneric<[email protected]> starting on May 12, 2021.
*
*/
-#include "gpg/GpgSubKey.h"
+#include "gpg/model/GpgSubKey.h"
-GpgSubKey::GpgSubKey(gpgme_subkey_t key) {
-
- if (key == nullptr) return;
-
- id = key->keyid;
- pubkey_algo = gpgme_pubkey_algo_name(key->pubkey_algo);
- fpr = key->fpr;
-
- expired = key->expired;
- revoked = key->revoked;
- secret = key->secret;
-
- disabled = key->disabled;
-
- length = key->length;
-
- can_authenticate = key->can_authenticate;
- can_certify = key->can_certify;
- can_encrypt = key->can_encrypt;
- can_sign = key->can_sign;
- is_cardkey = key->is_cardkey;
- is_private_key = key->secret;
-
- timestamp = QDateTime::fromTime_t(key->timestamp);
- expires = QDateTime::fromTime_t(key->expires);
-}
+GpgFrontend::GpgSubKey::GpgSubKey(gpgme_subkey_t subkey) : _subkey_ref(subkey, [&](gpgme_subkey_t subkey) {}) {}
diff --git a/src/gpg/GpgUID.cpp b/src/gpg/GpgUID.cpp
index 0dc6abfd..ae58daf1 100644
--- a/src/gpg/GpgUID.cpp
+++ b/src/gpg/GpgUID.cpp
@@ -22,17 +22,6 @@
*
*/
-#include "gpg/GpgUID.h"
+#include "gpg/model/GpgUID.h"
-GpgUID::GpgUID(gpgme_user_id_t user_id) :
- uid(user_id->uid), name(user_id->name), email(user_id->email), comment(user_id->comment),
- revoked(user_id->revoked), invalid(user_id->invalid) {
-
- auto sig = user_id->signatures;
-
- while (sig != nullptr) {
- signatures.push_back(GpgKeySignature(sig));
- sig = sig->next;
- }
-
-} \ No newline at end of file
+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/function/BasicOperator.cpp b/src/gpg/function/BasicOperator.cpp
new file mode 100644
index 00000000..f81e9f71
--- /dev/null
+++ b/src/gpg/function/BasicOperator.cpp
@@ -0,0 +1,254 @@
+/**
+ * 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/function/BasicOperator.h"
+#include "gpg/function/GpgKeyGetter.h"
+
+/**
+ * Read gpgme-Data to QByteArray
+ * mainly from http://basket.kde.org/ (kgpgme.cpp)
+ */
+#define BUF_SIZE (32 * 1024)
+
+gpgme_error_t read_2_buffer(gpgme_data_t data_in, GpgFrontend::BypeArrayPtr &out_buffer) {
+ gpgme_off_t ret = gpgme_data_seek(data_in, 0, SEEK_SET);
+ gpgme_error_t err = gpg_error(GPG_ERR_NO_ERROR);
+
+ if (ret) {
+ err = gpgme_err_code_from_errno(errno);
+ GpgFrontend::check_gpg_error(err, "failed data_seek data_in read_2_buffer");
+ } else {
+ char buf[BUF_SIZE + 2];
+
+ while ((ret = gpgme_data_read(data_in, buf, BUF_SIZE)) > 0) {
+ const size_t size = out_buffer->size();
+ out_buffer->resize(static_cast<int>(size + ret));
+ memcpy(out_buffer->data() + size, buf, ret);
+ }
+ if (ret < 0) {
+ err = gpgme_err_code_from_errno(errno);
+ GpgFrontend::check_gpg_error(err, "failed data_read data_in read_2_buffer");
+ }
+ }
+ return err;
+}
+
+gpg_error_t GpgFrontend::BasicOperator::encrypt(std::vector<GpgKey> &keys, GpgFrontend::BypeArrayRef in_buffer,
+ GpgFrontend::BypeArrayPtr &out_buffer,
+ GpgFrontend::GpgEncrResult &result) {
+
+ gpgme_data_t data_in = nullptr, data_out = nullptr;
+ out_buffer->resize(0);
+
+ // gpgme_encrypt_result_t e_result;
+ gpgme_key_t recipients[keys.size() + 1];
+
+ int index = 0;
+ for (const auto &key : keys) recipients[index++] = gpgme_key_t(key);
+
+ // Last entry data_in array has to be nullptr
+ recipients[keys.size()] = nullptr;
+
+ gpgme_error_t err;
+
+ // If the last parameter isnt 0, a private copy of data is made
+ check_gpg_error(gpgme_data_new_from_mem(&data_in, in_buffer.data(), in_buffer.size(), 1));
+ check_gpg_error(gpgme_data_new(&data_out));
+ err = check_gpg_error(gpgme_op_encrypt(ctx, recipients, GPGME_ENCRYPT_ALWAYS_TRUST, data_in, data_out));
+ check_gpg_error(read_2_buffer(data_out, out_buffer));
+
+ if (data_in) gpgme_data_release(data_in);
+ if (data_out) gpgme_data_release(data_out);
+
+ result = GpgEncrResult(gpgme_op_encrypt_result(ctx), [&](gpgme_encrypt_result_t res) { gpgme_result_unref(res); });
+ return err;
+}
+
+gpgme_error_t GpgFrontend::BasicOperator::decrypt(BypeArrayRef in_buffer, GpgFrontend::BypeArrayPtr &out_buffer,
+ GpgFrontend::GpgDecrResult &result) {
+ gpgme_data_t data_in = nullptr, data_out = nullptr;
+ out_buffer->resize(0);
+
+ gpgme_error_t err;
+
+ check_gpg_error(gpgme_data_new_from_mem(&data_in, in_buffer.data(), in_buffer.size(), 1));
+ check_gpg_error(gpgme_data_new(&data_out));
+ err = check_gpg_error(gpgme_op_decrypt(ctx, data_in, data_out));
+ check_gpg_error(read_2_buffer(data_out, out_buffer));
+
+ if (data_in) gpgme_data_release(data_in);
+ if (data_out) gpgme_data_release(data_out);
+
+ result = GpgDecrResult(gpgme_op_decrypt_result(ctx), [&](gpgme_decrypt_result_t res) { gpgme_result_unref(res); });
+
+ return err;
+}
+
+gpgme_error_t GpgFrontend::BasicOperator::verify(QByteArray &in_buffer, QByteArray &sig_buffer,
+ GpgFrontend::GpgVerifyResult &result) const {
+ gpgme_data_t data_in;
+ gpgme_error_t err;
+ gpgme_verify_result_t m_result;
+
+ check_gpg_error(gpgme_data_new_from_mem(&data_in, in_buffer.data(), in_buffer.size(), 1));
+
+ if (sig_buffer != nullptr) {
+ gpgme_data_t sig_data;
+ check_gpg_error(gpgme_data_new_from_mem(&sig_data, sig_buffer.data(), sig_buffer.size(), 1));
+ err = check_gpg_error(gpgme_op_verify(ctx, sig_data, data_in, nullptr));
+ } else
+ err = check_gpg_error(gpgme_op_verify(ctx, data_in, nullptr, data_in));
+
+ result = GpgVerifyResult(gpgme_op_verify_result(ctx), [&](gpgme_verify_result_t res) { gpgme_result_unref(res); });
+
+ return err;
+}
+
+gpg_error_t
+GpgFrontend::BasicOperator::sign(KeyFprArgsList key_fprs, BypeArrayRef in_buffer, BypeArrayPtr &out_buffer,
+ gpgme_sig_mode_t mode, GpgSignResult &result) {
+ gpgme_error_t err;
+ gpgme_data_t data_in, data_out;
+
+ out_buffer->resize(0);
+
+ std::vector<GpgKey> keys;
+ auto &key_getter = GpgKeyGetter::getInstance();
+
+ for (const auto &key_fpr : key_fprs)
+ keys.push_back(key_getter.getKey(key_fpr));
+
+ // Set Singers of this opera
+ setSigners(keys);
+
+ check_gpg_error(gpgme_data_new_from_mem(&data_in, in_buffer.data(), in_buffer.size(), 1));
+ check_gpg_error(gpgme_data_new(&data_out));
+
+ /**
+ `GPGME_SIG_MODE_NORMAL'
+ A normal signature is made, the output includes the plaintext
+ and the signature.
+
+ `GPGME_SIG_MODE_DETACH'
+ A detached signature is made.
+
+ `GPGME_SIG_MODE_CLEAR'
+ A clear text signature is made. The ASCII armor and text
+ mode settings of the context are ignored.
+ */
+
+ err = check_gpg_error(gpgme_op_sign(ctx, data_in, data_out, mode));
+ check_gpg_error(read_2_buffer(data_out, out_buffer));
+
+ gpgme_data_release(data_in);
+ gpgme_data_release(data_out);
+
+ result = GpgSignResult(gpgme_op_sign_result(ctx), [&](gpgme_sign_result_t res) { gpgme_result_unref(res); });
+
+ return err;
+}
+
+gpgme_error_t
+GpgFrontend::BasicOperator::decryptVerify(const BypeArrayRef in_buffer, BypeArrayPtr &out_buffer,
+ GpgDecrResult &decrypt_result, GpgVerifyResult &verify_result) {
+ gpgme_error_t err;
+ gpgme_data_t data_in, data_out;
+ out_buffer->resize(0);
+
+ check_gpg_error(gpgme_data_new_from_mem(&data_in, in_buffer.data(), in_buffer.size(), 1));
+ check_gpg_error(gpgme_data_new(&data_out));
+ err = check_gpg_error(gpgme_op_decrypt_verify(ctx, data_in, data_out));
+
+ check_gpg_error(read_2_buffer(data_out, out_buffer));
+
+ if (data_in) gpgme_data_release(data_in);
+ if (data_out) gpgme_data_release(data_out);
+
+ decrypt_result = GpgDecrResult(gpgme_op_decrypt_result(ctx),
+ [&](gpgme_decrypt_result_t res) { gpgme_result_unref(res); });
+ verify_result = GpgVerifyResult(gpgme_op_verify_result(ctx),
+ [&](gpgme_verify_result_t res) { gpgme_result_unref(res); });
+
+
+ return err;
+}
+
+gpgme_error_t GpgFrontend::BasicOperator::encryptSign(std::vector<GpgKey> &keys, std::vector<GpgKey> &signers,
+ BypeArrayRef in_buffer,
+ BypeArrayPtr &out_buffer, GpgEncrResult &encr_result,
+ GpgSignResult &sign_result) {
+ gpgme_error_t err;
+ gpgme_data_t data_in, data_out;
+ out_buffer->resize(0);
+
+ setSigners(signers);
+
+ //gpgme_encrypt_result_t e_result;
+ gpgme_key_t recipients[keys.size() + 1];
+
+ // set key for user
+ int index = 0;
+ for (const auto &key : keys) recipients[index++] = gpgme_key_t(key);
+
+ // Last entry dataIn array has to be nullptr
+ recipients[keys.size()] = nullptr;
+
+ // If the last parameter isnt 0, a private copy of data is made
+ check_gpg_error(gpgme_data_new_from_mem(&data_in, in_buffer.data(), in_buffer.size(), 1));
+ check_gpg_error(gpgme_data_new(&data_out));
+ err = check_gpg_error(gpgme_op_encrypt_sign(ctx, recipients, GPGME_ENCRYPT_ALWAYS_TRUST, data_in, data_out));
+
+ check_gpg_error(read_2_buffer(data_out, out_buffer));
+
+ if (data_in) gpgme_data_release(data_in);
+ if (data_out) gpgme_data_release(data_out);
+
+ encr_result = GpgEncrResult(gpgme_op_encrypt_result(ctx),
+ [&](gpgme_encrypt_result_t res) { gpgme_result_unref(res); });
+ sign_result = GpgSignResult(gpgme_op_sign_result(ctx), [&](gpgme_sign_result_t res) { gpgme_result_unref(res); });
+
+ return err;
+}
+
+void GpgFrontend::BasicOperator::setSigners(KeyArgsList keys) {
+ gpgme_signers_clear(ctx);
+ for (const GpgKey &key : keys) {
+ if (key.canSignActual()) {
+ auto gpgmeError = gpgme_signers_add(ctx, gpgme_key_t(key));
+ check_gpg_error(gpgmeError);
+ }
+ }
+ if (keys.size() != gpgme_signers_count(ctx))
+ qDebug() << "No All Signers Added";
+}
+
+std::unique_ptr<std::vector<GpgFrontend::GpgKey>> GpgFrontend::BasicOperator::getSigners() {
+ auto count = gpgme_signers_count(ctx);
+ auto signers = std::make_unique<std::vector<GpgKey>>();
+ for (auto i = 0; i < count; i++) {
+ auto key = GpgKey(gpgme_signers_enum(ctx, i));
+ signers->push_back(std::move(GpgKey(std::move(key))));
+ }
+ return signers;
+}
diff --git a/src/gpg/function/GpgKeyGetter.cpp b/src/gpg/function/GpgKeyGetter.cpp
new file mode 100644
index 00000000..e4572290
--- /dev/null
+++ b/src/gpg/function/GpgKeyGetter.cpp
@@ -0,0 +1,38 @@
+/**
+ * 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/function/GpgKeyGetter.h"
+
+
+GpgFrontend::GpgKey &&GpgFrontend::GpgKeyGetter::getKey(const std::string &fpr) {
+ gpgme_key_t _p_key;
+ gpgme_get_key(ctx, fpr.c_str(), &_p_key, 1);
+ return std::move(GpgKey(std::move(_p_key)));
+}
+
+GpgFrontend::GpgKey &&GpgFrontend::GpgKeyGetter::getPubkey(const std::string &fpr) {
+ gpgme_key_t _p_key;
+ gpgme_get_key(ctx, fpr.c_str(), &_p_key, 0);
+ return std::move(GpgKey(std::move(_p_key)));
+}
diff --git a/src/gpg/function/GpgKeyManager.cpp b/src/gpg/function/GpgKeyManager.cpp
new file mode 100644
index 00000000..b27163c8
--- /dev/null
+++ b/src/gpg/function/GpgKeyManager.cpp
@@ -0,0 +1,76 @@
+/**
+ * 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/function/GpgKeyManager.h"
+#include "gpg/function/GpgKeyGetter.h"
+#include "gpg/function/BasicOperator.h"
+
+bool GpgFrontend::GpgKeyManager::signKey(const GpgFrontend::GpgKey &target, GpgFrontend::KeyArgsList &keys,
+ const QString &uid, std::unique_ptr<QDateTime> &expires) {
+ BasicOperator::getInstance().setSigners(keys);
+
+ unsigned int flags = 0;
+
+ unsigned int expires_time_t = 0;
+ if (expires == nullptr) flags |= GPGME_KEYSIGN_NOEXPIRE;
+ else expires_time_t = QDateTime::currentDateTime().secsTo(*expires);
+
+ auto err =
+ check_gpg_error(
+ gpgme_op_keysign(ctx, gpgme_key_t(target), uid.toUtf8().constData(), expires_time_t, flags));
+
+ if (gpg_err_code(err) == GPG_ERR_NO_ERROR) return true;
+ else return false;
+}
+
+bool
+GpgFrontend::GpgKeyManager::revSign(const GpgFrontend::GpgKey &key, const GpgFrontend::GpgKeySignature &signature) {
+
+ auto &key_getter = GpgKeyGetter::getInstance();
+ auto signing_key = key_getter.getKey(signature.keyid());
+
+ auto err = check_gpg_error(gpgme_op_revsig(ctx, gpgme_key_t(key), gpgme_key_t(signing_key),
+ signature.uid().data(), 0));
+ if (gpg_err_code(err) == GPG_ERR_NO_ERROR) return true;
+ else return false;
+
+}
+
+bool GpgFrontend::GpgKeyManager::setExpire(const GpgFrontend::GpgKey &key, std::unique_ptr<GpgSubKey> &subkey,
+ std::unique_ptr<QDateTime> &expires) {
+ unsigned long expires_time = 0;
+ if (expires != nullptr) {
+ qDebug() << "Expire Datetime" << expires->toString();
+ expires_time = QDateTime::currentDateTime().secsTo(*expires);
+ }
+
+ const char *sub_fprs = nullptr;
+
+ if (subkey != nullptr) sub_fprs = subkey->fpr().toUtf8().constData();
+
+ auto err = check_gpg_error(gpgme_op_setexpire(ctx, gpgme_key_t(key), expires_time, sub_fprs, 0));
+ if (gpg_err_code(err) == GPG_ERR_NO_ERROR) return true;
+ else return false;
+}
diff --git a/src/gpg/function/UidOperator.cpp b/src/gpg/function/UidOperator.cpp
new file mode 100644
index 00000000..91fe70fe
--- /dev/null
+++ b/src/gpg/function/UidOperator.cpp
@@ -0,0 +1,45 @@
+/**
+ * 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/function/UidOperator.h"
+
+bool GpgFrontend::UidOperator::addUID(const GpgFrontend::GpgKey &key, const GpgFrontend::GpgUID &uid) {
+ QString userid = QString("%1 (%3) <%2>").arg(uid.name(), uid.email(), uid.comment());
+ auto err = gpgme_op_adduid(ctx, gpgme_key_t(key), userid.toUtf8().constData(), 0);
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) return true;
+ else return false;
+}
+
+bool GpgFrontend::UidOperator::revUID(const GpgFrontend::GpgKey &key, const GpgFrontend::GpgUID &uid) {
+ auto err = check_gpg_error(gpgme_op_revuid(ctx, gpgme_key_t(key), uid.uid().toUtf8().constData(), 0));
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) return true;
+ else return false;
+}
+
+bool GpgFrontend::UidOperator::setPrimaryUID(const GpgFrontend::GpgKey &key, const GpgFrontend::GpgUID &uid) {
+ auto err = check_gpg_error(gpgme_op_set_uid_flag(ctx, gpgme_key_t(key),
+ uid.uid().toUtf8().constData(), "primary", nullptr));
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) return true;
+ else return false;
+}
diff --git a/src/gpg/gpg_context/GpgContext.cpp b/src/gpg/gpg_context/GpgContext.cpp
index 14b54b32..6887191b 100644
--- a/src/gpg/gpg_context/GpgContext.cpp
+++ b/src/gpg/gpg_context/GpgContext.cpp
@@ -36,36 +36,23 @@
#define INT2VOIDP(i) (void*)(uintptr_t)(i)
-namespace GpgME {
+namespace GpgFrontend {
- /** Constructor
+ /**
+ * Constructor
* Set up gpgme-context, set paths to app-run path
*/
GpgContext::GpgContext() {
- /** The function `gpgme_check_version' must be called before any other
- * function in the library, because it initializes the thread support
- * subsystem in GPGME. (from the info page) */
- gpgme_check_version(nullptr);
-
- // the locale set here is used for the other setlocale calls which have nullptr
- // -> nullptr means use default, which is configured here
- setlocale(LC_ALL, settings.value("int/lang").toLocale().name().toUtf8().constData());
-
- /** set locale, because tests do also */
- gpgme_set_locale(nullptr, LC_CTYPE, setlocale(LC_CTYPE, nullptr));
- //qDebug() << "Locale set to" << LC_CTYPE << " - " << setlocale(LC_CTYPE, nullptr);
-#ifndef _WIN32
- gpgme_set_locale(nullptr, LC_MESSAGES, setlocale(LC_MESSAGES, nullptr));
-#endif
-
- err = gpgme_new(&mCtx);
- checkErr(err);
+ gpgme_ctx_t _p_ctx;
+ err = gpgme_new(&_p_ctx);
+ check_gpg_error(err);
+ _ctx_ref = CtxRefHandler(_p_ctx, [&](gpgme_ctx_t ctx) { gpgme_release(ctx); });
gpgme_engine_info_t engineInfo;
- engineInfo = gpgme_ctx_get_engine_info(mCtx);
+ engineInfo = gpgme_ctx_get_engine_info(*this);
-// Check ENV before running
+ // Check ENV before running
bool check_pass = false, find_openpgp = false, find_gpgconf = false, find_assuan = false, find_cms = false;
while (engineInfo != nullptr) {
qDebug() << gpgme_get_protocol_name(engineInfo->protocol) << engineInfo->file_name << engineInfo->protocol
@@ -91,68 +78,30 @@ namespace GpgME {
} else good = true;
-/** Setting the output type must be done at the beginning */
-/** think this means ascii-armor --> ? */
- gpgme_set_armor(mCtx, 1);
-/** passphrase-callback */
- gpgme_set_passphrase_cb(mCtx, passphraseCb, this);
+ /** Setting the output type must be done at the beginning */
+ /** think this means ascii-armor --> ? */
+ gpgme_set_armor(*this, 1);
+ /** passphrase-callback */
+ gpgme_set_passphrase_cb(*this, passphraseCb, this);
-/** check if app is called with -d from command line */
+ /** check if app is called with -d from command line */
if (qApp->arguments().contains("-d")) {
qDebug() << "gpgme_data_t debug on";
debug = true;
- } else {
- debug = false;
- }
+ } else debug = false;
connect(this, SIGNAL(signalKeyDBChanged()),
this, SLOT(slotRefreshKeyList()), Qt::DirectConnection);
connect(this, SIGNAL(signalKeyUpdated(QString)),
this, SLOT(slotUpdateKeyList(QString)), Qt::DirectConnection);
- slotRefreshKeyList();
- }
- /** Destructor
- * Release gpgme-context
- */
- GpgContext::~GpgContext() {
- if (mCtx) gpgme_release(mCtx);
- mCtx = nullptr;
+ slotRefreshKeyList();
}
bool GpgContext::isGood() const {
return good;
}
- /** Read gpgme-Data to QByteArray
- * mainly from http://basket.kde.org/ (kgpgme.cpp)
- */
-#define BUF_SIZE (32 * 1024)
-
- gpgme_error_t GpgContext::readToBuffer(gpgme_data_t dataIn, QByteArray *outBuffer) {
- gpgme_off_t ret;
- gpgme_error_t gpgErrNoError = GPG_ERR_NO_ERROR;
-
- ret = gpgme_data_seek(dataIn, 0, SEEK_SET);
- if (ret) {
- gpgErrNoError = gpgme_err_code_from_errno(errno);
- checkErr(gpgErrNoError, "failed dataseek dataIn readToBuffer");
- } else {
- char buf[BUF_SIZE + 2];
-
- while ((ret = gpgme_data_read(dataIn, buf, BUF_SIZE)) > 0) {
- const size_t size = outBuffer->size();
- outBuffer->resize(static_cast<int>(size + ret));
- memcpy(outBuffer->data() + size, buf, ret);
- }
- if (ret < 0) {
- gpgErrNoError = gpgme_err_code_from_errno(errno);
- checkErr(gpgErrNoError, "failed data_read dataIn readToBuffer");
- }
- }
- return gpgErrNoError;
- }
-
/**
* The Passphrase window, if not provided by env-Var GPG_AGENT_INFO
* originally copied from http://basket.kde.org/ (kgpgme.cpp), but modified
@@ -229,24 +178,22 @@ namespace GpgME {
}
// error-handling
- void GpgContext::checkErr(gpgme_error_t gpgmeError, const QString &comment) {
+ gpgme_error_t check_gpg_error(gpgme_error_t err, const QString &comment) {
//if (gpgmeError != GPG_ERR_NO_ERROR && gpgmeError != GPG_ERR_CANCELED) {
- if (gpgmeError != GPG_ERR_NO_ERROR) {
- qDebug() << "[Error " << gpg_err_code(gpgmeError)
- << "] Source: " << gpgme_strsource(gpgmeError) << " Description: " << gpgErrString(gpgmeError);
+ if (gpg_err_code(err) != GPG_ERR_NO_ERROR) {
+ qDebug() << "[Error " << gpg_err_code(err)
+ << "] Source: " << gpgme_strsource(err) << " Description: " << gpgme_strerror(err);
}
+ return err;
}
- void GpgContext::checkErr(gpgme_error_t gpgmeError) {
+ gpgme_error_t check_gpg_error(gpgme_error_t err) {
//if (gpgmeError != GPG_ERR_NO_ERROR && gpgmeError != GPG_ERR_CANCELED) {
- if (gpg_err_code(gpgmeError) != GPG_ERR_NO_ERROR) {
- qDebug() << "[Error " << gpg_err_code(gpgmeError)
- << "] Source: " << gpgme_strsource(gpgmeError) << " Description: " << gpgErrString(gpgmeError);
+ if (gpg_err_code(err) != GPG_ERR_NO_ERROR) {
+ qDebug() << "[Error " << gpg_err_code(err)
+ << "] Source: " << gpgme_strsource(err) << " Description: " << gpgme_strerror(err);
}
- }
-
- QString GpgContext::gpgErrString(gpgme_error_t err) {
- return QString::fromUtf8(gpgme_strerror(err));
+ return err;
}
/** return type should be gpgme_error_t*/
@@ -329,82 +276,26 @@ namespace GpgME {
return mKeyList;
}
- void GpgContext::getSigners(QVector<GpgKey> &signer, gpgme_ctx_t ctx) {
- auto count = gpgme_signers_count(ctx);
- signer.clear();
- for (auto i = 0; i < count; i++) {
- auto key = gpgme_signers_enum(ctx, i);
- auto it = mKeyMap.find(key->subkeys->keyid);
- if (it == mKeyMap.end()) {
- qDebug() << "Inconsistent state";
- signer.push_back(GpgKey(key));
- } else {
- signer.push_back(*it.value());
- }
- }
- }
-
- void GpgContext::setSigners(const QVector<GpgKey> &keys, gpgme_ctx_t ctx) {
- gpgme_signers_clear(ctx);
- for (const auto &key : keys) {
- if (checkIfKeyCanSign(key)) {
- auto gpgmeError = gpgme_signers_add(ctx, key.key_refer);
- checkErr(gpgmeError);
- }
- }
- if (keys.length() != gpgme_signers_count(ctx)) {
- qDebug() << "No All Keys Added";
- }
- }
-
void GpgContext::slotUpdateKeyList(const QString &key_id) {
auto it = mKeyMap.find(key_id);
if (it != mKeyMap.end()) {
- gpgme_key_t new_key_refer;
- auto gpgmeErr = gpgme_get_key(mCtx, key_id.toUtf8().constData(), &new_key_refer, 0);
+ gpgme_key_t new_key_ref;
+
+ auto gpgmeErr = gpgme_get_key(*this, key_id.toUtf8().constData(), &new_key_ref, 0);
if (gpgme_err_code(gpgmeErr) == GPG_ERR_EOF) {
- gpgmeErr = gpgme_get_key(mCtx, key_id.toUtf8().constData(), &new_key_refer, 1);
+ gpgmeErr = gpgme_get_key(*this, key_id.toUtf8().constData(), &new_key_ref, 1);
- if (gpgme_err_code(gpgmeErr) == GPG_ERR_EOF) {
+ if (gpgme_err_code(gpgmeErr) == GPG_ERR_EOF)
throw std::runtime_error("key_id not found in key database");
- }
-
}
- if (new_key_refer != nullptr) {
- it.value()->swapKeyRefer(new_key_refer);
+ if (new_key_ref != nullptr) {
+ it->second = std::move(GpgKey(std::move(new_key_ref)));
emit signalKeyInfoChanged();
}
}
}
- bool GpgContext::revSign(const GpgKey &key, const GpgKeySignature &signature) {
-
- auto signing_key = getKeyById(signature.keyid);
-
- auto gpgmeError = gpgme_op_revsig(mCtx, key.key_refer,
- signing_key.key_refer,
- signature.uid.toUtf8().constData(), 0);
- if (gpg_err_code(gpgmeError) == GPG_ERR_NO_ERROR) {
- emit signalKeyUpdated(key.id);
- return true;
- } else {
- checkErr(gpgmeError);
- return false;
- }
- }
-
- gpgme_ctx_t GpgME::GpgContext::create_ctx() {
- gpgme_ctx_t ctx;
- err = gpgme_new(&ctx);
- checkErr(err);
-
- gpgme_set_armor(ctx, 1);
- gpgme_set_passphrase_cb(ctx, passphraseCb, this);
- return ctx;
- }
-
-
}
diff --git a/src/gpg/gpg_context/GpgContextBasicOpera.cpp b/src/gpg/gpg_context/GpgContextBasicOpera.cpp
deleted file mode 100644
index d9bf0bdb..00000000
--- a/src/gpg/gpg_context/GpgContextBasicOpera.cpp
+++ /dev/null
@@ -1,315 +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/GpgContext.h"
-
-/**
- * Encrypt data
- * @param keys keys used
- * @param inBuffer input byte array
- * @param outBuffer output byte array
- * @param result opera result
- * @return error information
- */
-gpg_error_t GpgME::GpgContext::encrypt(QVector<GpgKey> &keys, const QByteArray &inBuffer, QByteArray *outBuffer,
- gpgme_encrypt_result_t *result) {
-
- gpgme_data_t dataIn = nullptr, dataOut = nullptr;
- outBuffer->resize(0);
-
- // gpgme_encrypt_result_t e_result;
- gpgme_key_t recipients[keys.count() + 1];
-
- int index = 0;
- for (const auto &key : keys) recipients[index++] = key.key_refer;
-
- // Last entry dataIn array has to be nullptr
- recipients[keys.count()] = nullptr;
-
- // If the last parameter isnt 0, a private copy of data is made
- if (mCtx) {
- err = gpgme_data_new_from_mem(&dataIn, inBuffer.data(), inBuffer.size(), 1);
- checkErr(err);
- if (!err) {
- err = gpgme_data_new(&dataOut);
- checkErr(err);
- if (!err) {
- err = gpgme_op_encrypt(mCtx, recipients, GPGME_ENCRYPT_ALWAYS_TRUST, dataIn, dataOut);
- checkErr(err);
- if (!err) {
- err = readToBuffer(dataOut, outBuffer);
- checkErr(err);
- }
- }
- }
- }
- if (dataIn) gpgme_data_release(dataIn);
- if (dataOut) gpgme_data_release(dataOut);
-
- if (result != nullptr) *result = gpgme_op_encrypt_result(mCtx);
- return err;
-}
-
-/**
- * Decrypt data
- * @param keys keys used
- * @param inBuffer input byte array
- * @param outBuffer output byte array
- * @param result opera result
- * @return error information
- */
-gpgme_error_t GpgME::GpgContext::decrypt(const QByteArray &inBuffer, QByteArray *outBuffer,
- gpgme_decrypt_result_t *result) {
- gpgme_data_t dataIn = nullptr, dataOut = nullptr;
- gpgme_decrypt_result_t m_result = nullptr;
-
- outBuffer->resize(0);
- if (mCtx != nullptr) {
- err = gpgme_data_new_from_mem(&dataIn, inBuffer.data(), inBuffer.size(), 1);
- if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) {
- err = gpgme_data_new(&dataOut);
- if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) {
- err = gpgme_op_decrypt(mCtx, dataIn, dataOut);
- m_result = gpgme_op_decrypt_result(mCtx);
- if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) err = readToBuffer(dataOut, outBuffer);
- }
- }
- }
-
- if (!settings.value("general/rememberPassword").toBool()) clearPasswordCache();
-
- if (dataIn) gpgme_data_release(dataIn);
- if (dataOut) gpgme_data_release(dataOut);
-
- if (result != nullptr) *result = m_result;
-
- return err;
-}
-
-/**
- * Verify data
- * @param keys keys used
- * @param inBuffer input byte array
- * @param sigBuffer signature byte array (detected by format)
- * @param result opera result
- * @return error information
- */
-gpgme_error_t GpgME::GpgContext::verify(QByteArray *inBuffer, QByteArray *sigBuffer, gpgme_verify_result_t *result) {
-
- gpgme_data_t dataIn;
- gpgme_error_t gpgmeError;
- gpgme_verify_result_t m_result;
-
- gpgmeError = gpgme_data_new_from_mem(&dataIn, inBuffer->data(), inBuffer->size(), 1);
- checkErr(gpgmeError);
-
- if (sigBuffer != nullptr) {
- gpgme_data_t sigdata;
- gpgmeError = gpgme_data_new_from_mem(&sigdata, sigBuffer->data(), sigBuffer->size(), 1);
- checkErr(gpgmeError);
- gpgmeError = gpgme_op_verify(mCtx, sigdata, dataIn, nullptr);
- } else {
- gpgmeError = gpgme_op_verify(mCtx, dataIn, nullptr, dataIn);
- }
-
- checkErr(gpgmeError);
-
- m_result = gpgme_op_verify_result(mCtx);
-
- if (result != nullptr) {
- *result = m_result;
- }
-
- return gpgmeError;
-}
-
-/**
- * Sign data
- * @param keys keys used
- * @param inBuffer input byte array
- * @param outBuffer output byte array
- * @param mode sign mode
- * @param result opera result
- * @return
- */
-gpg_error_t GpgME::GpgContext::sign(const QVector<GpgKey> &keys, const QByteArray &inBuffer, QByteArray *outBuffer,
- gpgme_sig_mode_t mode, gpgme_sign_result_t *result, bool default_ctx) {
-
- gpgme_error_t gpgmeError;
- gpgme_data_t dataIn, dataOut;
- gpgme_sign_result_t m_result;
-
- auto _ctx = mCtx;
-
- if(!default_ctx)
- _ctx = create_ctx();
-
- if (keys.isEmpty()) {
- QMessageBox::critical(nullptr, tr("Key Selection"), tr("No Private Key Selected"));
- return false;
- }
-
- // Set Singers of this opera
- setSigners(keys, _ctx);
-
- gpgmeError = gpgme_data_new_from_mem(&dataIn, inBuffer.data(), inBuffer.size(), 1);
- checkErr(gpgmeError);
- gpgmeError = gpgme_data_new(&dataOut);
- checkErr(gpgmeError);
-
- /**
- `GPGME_SIG_MODE_NORMAL'
- A normal signature is made, the output includes the plaintext
- and the signature.
-
- `GPGME_SIG_MODE_DETACH'
- A detached signature is made.
-
- `GPGME_SIG_MODE_CLEAR'
- A clear text signature is made. The ASCII armor and text
- mode settings of the context are ignored.
- */
-
- gpgmeError = gpgme_op_sign(_ctx, dataIn, dataOut, mode);
- checkErr(gpgmeError);
-
- if (gpgmeError == GPG_ERR_CANCELED) return false;
-
- if (gpgmeError != GPG_ERR_NO_ERROR) {
- QMessageBox::critical(nullptr, tr("Error in signing:"), QString::fromUtf8(gpgme_strerror(gpgmeError)));
- return false;
- }
-
- if(default_ctx)
- m_result = gpgme_op_sign_result(_ctx);
- else m_result = nullptr;
-
- if (result != nullptr) *result = m_result;
-
- if(!default_ctx) gpgme_release(_ctx);
-
- gpgmeError = readToBuffer(dataOut, outBuffer);
- checkErr(gpgmeError);
-
- gpgme_data_release(dataIn);
- gpgme_data_release(dataOut);
-
- // Of no use yet
- if (!settings.value("general/rememberPassword").toBool()) clearPasswordCache();
-
- return gpgmeError;
-}
-
-/**
- * Encrypt and sign data
- * @param keys keys used
- * @param inBuffer input byte array
- * @param outBuffer output byte array
- * @param encr_result encrypt opera result
- * @param sign_result sign opera result
- * @return
- */
-gpgme_error_t
-GpgME::GpgContext::encryptSign(QVector<GpgKey> &keys, QVector<GpgKey> &signers, const QByteArray &inBuffer,
- QByteArray *outBuffer, gpgme_encrypt_result_t *encr_result,
- gpgme_sign_result_t *sign_result) {
- gpgme_data_t data_in = nullptr, data_out = nullptr;
- outBuffer->resize(0);
-
- setSigners(signers, mCtx);
-
- //gpgme_encrypt_result_t e_result;
- gpgme_key_t recipients[keys.count() + 1];
-
- // set key for user
- int index = 0;
- for (const auto &key : keys) recipients[index++] = key.key_refer;
-
- // Last entry dataIn array has to be nullptr
- recipients[keys.count()] = nullptr;
-
- // If the last parameter isnt 0, a private copy of data is made
- if (mCtx != nullptr) {
- err = gpgme_data_new_from_mem(&data_in, inBuffer.data(), inBuffer.size(), 1);
- if (gpg_err_code(err) == GPG_ERR_NO_ERROR) {
- err = gpgme_data_new(&data_out);
- if (gpg_err_code(err) == GPG_ERR_NO_ERROR) {
- err = gpgme_op_encrypt_sign(mCtx, recipients, GPGME_ENCRYPT_ALWAYS_TRUST, data_in, data_out);
- if (encr_result != nullptr)
- *encr_result = gpgme_op_encrypt_result(mCtx);
- if (sign_result != nullptr)
- *sign_result = gpgme_op_sign_result(mCtx);
- if (gpg_err_code(err) == GPG_ERR_NO_ERROR) {
- err = readToBuffer(data_out, outBuffer);
- }
- }
- }
- }
-
- if (gpgme_err_code(err) != GPG_ERR_NO_ERROR) checkErr(err);
-
- if (data_in) gpgme_data_release(data_in);
- if (data_out) gpgme_data_release(data_out);
-
- return err;
-}
-
-/**
- * Decrypt and verify data
- * @param inBuffer input byte array
- * @param outBuffer output byte array
- * @param decrypt_result decrypt opera result
- * @param verify_result verify opera result
- * @return error info
- */
-gpgme_error_t GpgME::GpgContext::decryptVerify(const QByteArray &inBuffer, QByteArray *outBuffer,
- gpgme_decrypt_result_t *decrypt_result,
- gpgme_verify_result_t *verify_result) {
- gpgme_data_t data_in = nullptr, data_out = nullptr;
-
- outBuffer->resize(0);
- if (mCtx != nullptr) {
- err = gpgme_data_new_from_mem(&data_in, inBuffer.data(), inBuffer.size(), 1);
- if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) {
- err = gpgme_data_new(&data_out);
- if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) {
- err = gpgme_op_decrypt_verify(mCtx, data_in, data_out);
- if (decrypt_result != nullptr)
- *decrypt_result = gpgme_op_decrypt_result(mCtx);
- if (verify_result != nullptr)
- *verify_result = gpgme_op_verify_result(mCtx);
- if (gpgme_err_code(err) == GPG_ERR_NO_ERROR) {
- err = readToBuffer(data_out, outBuffer);
- }
- }
- }
- }
-
- if (!settings.value("general/rememberPassword").toBool()) clearPasswordCache();
-
- if (data_in) gpgme_data_release(data_in);
- if (data_out) gpgme_data_release(data_out);
-
- return err;
-}
diff --git a/src/gpg/gpg_context/GpgContextKeyInfo.cpp b/src/gpg/gpg_context/GpgContextKeyInfo.cpp
index f6942e4e..3fa6a23b 100644
--- a/src/gpg/gpg_context/GpgContextKeyInfo.cpp
+++ b/src/gpg/gpg_context/GpgContextKeyInfo.cpp
@@ -29,9 +29,10 @@
* @param key target key
* @return if key sign
*/
-bool GpgME::GpgContext::checkIfKeyCanSign(const GpgKey &key) {
- if (std::any_of(key.subKeys.begin(), key.subKeys.end(), [](const GpgSubKey &subkey) -> bool {
- return subkey.secret && subkey.can_sign && !subkey.disabled && !subkey.revoked && !subkey.expired;
+bool GpgFrontend::GpgContext::checkIfKeyCanSign(const GpgKey &key) {
+ auto subkeys = key.subKeys();
+ if (std::any_of(subkeys->begin(), subkeys->end(), [](const GpgSubKey &subkey) -> bool {
+ return subkey.secret() && subkey.can_sign() && !subkey.disabled() && !subkey.revoked() && !subkey.expired();
}))
return true;
else return false;
@@ -42,8 +43,8 @@ bool GpgME::GpgContext::checkIfKeyCanSign(const GpgKey &key) {
* @param key target key
* @return if key certify
*/
-bool GpgME::GpgContext::checkIfKeyCanCert(const GpgKey &key) {
- return key.has_master_key && !key.expired && !key.revoked && !key.disabled;
+bool GpgFrontend::GpgContext::checkIfKeyCanCert(const GpgKey &key) {
+ return key.has_master_key() && !key.expired() && !key.revoked() && !key.disabled();
}
/**
@@ -51,9 +52,10 @@ bool GpgME::GpgContext::checkIfKeyCanCert(const GpgKey &key) {
* @param key target key
* @return if key authenticate
*/
-bool GpgME::GpgContext::checkIfKeyCanAuth(const GpgKey &key) {
- if (std::any_of(key.subKeys.begin(), key.subKeys.end(), [](const GpgSubKey &subkey) -> bool {
- return subkey.secret && subkey.can_authenticate && !subkey.disabled && !subkey.revoked && !subkey.expired;
+bool GpgFrontend::GpgContext::checkIfKeyCanAuth(const GpgKey &key) {
+ auto subkeys = key.subKeys();
+ if (std::any_of(subkeys->begin(), subkeys->end(), [](const GpgSubKey &subkey) -> bool {
+ return subkey.secret() && subkey.can_authenticate() && !subkey.disabled() && !subkey.revoked() && !subkey.expired();
}))
return true;
else return false;
@@ -64,47 +66,11 @@ bool GpgME::GpgContext::checkIfKeyCanAuth(const GpgKey &key) {
* @param key target key
* @return if key encrypt
*/
-bool GpgME::GpgContext::checkIfKeyCanEncr(const GpgKey &key) {
- if (std::any_of(key.subKeys.begin(), key.subKeys.end(), [](const GpgSubKey &subkey) -> bool {
- return subkey.can_encrypt && !subkey.disabled && !subkey.revoked && !subkey.expired;
+bool GpgFrontend::GpgContext::checkIfKeyCanEncr(const GpgKey &key) {
+ auto subkeys = key.subKeys();
+ if (std::any_of(subkeys->begin(), subkeys->end(), [](const GpgSubKey &subkey) -> bool {
+ return subkey.can_encrypt() && !subkey.disabled() && !subkey.revoked() && !subkey.expired();
}))
return true;
else return false;
}
-
-/**
- * Get target key
- * @param fpr master key's fingerprint
- * @return the key
- */
-GpgKey GpgME::GpgContext::getKeyByFpr(const QString &fpr) {
- for (const auto &key : mKeyList) {
- if (key.fpr == fpr) return key;
- else
- for (auto &subkey : key.subKeys) {
- if (subkey.fpr == fpr) return key;
- }
- }
- return GpgKey(nullptr);
-}
-
-
-/**
- * Get target key
- * @param id master key's id
- * @return the key
- */
-GpgKey GpgME::GpgContext::getKeyById(const QString &id) {
-
- for (const auto &key : mKeyList) {
- if (key.id == id) return key;
- else {
- auto sub_keys = key.subKeys;
- for (const auto &subkey : sub_keys) {
- if (subkey.id == id) return key;
- }
- }
- }
-
- return GpgKey(nullptr);
-}
diff --git a/src/gpg/gpg_context/GpgContextKeyOpera.cpp b/src/gpg/gpg_context/GpgContextKeyOpera.cpp
index a224231d..63b266ca 100644
--- a/src/gpg/gpg_context/GpgContextKeyOpera.cpp
+++ b/src/gpg/gpg_context/GpgContextKeyOpera.cpp
@@ -29,14 +29,14 @@
* @param inBuffer input byte array
* @return Import information
*/
-GpgImportInformation GpgME::GpgContext::importKey(QByteArray inBuffer) {
+GpgImportInformation GpgFrontend::GpgContext::importKey(QByteArray inBuffer) {
auto *importInformation = new GpgImportInformation();
err = gpgme_data_new_from_mem(&in, inBuffer.data(), inBuffer.size(), 1);
- checkErr(err);
- err = gpgme_op_import(mCtx, in);
+ check_gpg_error(err);
+ err = gpgme_op_import(*this, in);
gpgme_import_result_t result;
- result = gpgme_op_import_result(mCtx);
+ result = gpgme_op_import_result(*this);
if (result->unchanged) importInformation->unchanged = result->unchanged;
if (result->considered) importInformation->considered = result->considered;
@@ -61,7 +61,7 @@ GpgImportInformation GpgME::GpgContext::importKey(QByteArray inBuffer) {
importInformation->importedKeys.emplace_back(key);
status = status->next;
}
- checkErr(err);
+ check_gpg_error(err);
emit signalKeyDBChanged();
gpgme_data_release(in);
return *importInformation;
@@ -72,7 +72,7 @@ GpgImportInformation GpgME::GpgContext::importKey(QByteArray inBuffer) {
* @param params key generation args
* @return error information
*/
-gpgme_error_t GpgME::GpgContext::generateKey(GenKeyInfo *params) {
+gpgme_error_t GpgFrontend::GpgContext::generateKey(GenKeyInfo *params) {
auto userid_utf8 = params->getUserid().toUtf8();
const char *userid = userid_utf8.constData();
@@ -88,10 +88,10 @@ gpgme_error_t GpgME::GpgContext::generateKey(GenKeyInfo *params) {
if (params->isNonExpired()) flags |= GPGME_CREATE_NOEXPIRE;
if (params->isNoPassPhrase()) flags |= GPGME_CREATE_NOPASSWD;
- err = gpgme_op_createkey(mCtx, userid, algo, 0, expires, nullptr, flags);
+ err = gpgme_op_createkey(*this, userid, algo, 0, expires, nullptr, flags);
if (gpgme_err_code(err) != GPG_ERR_NO_ERROR) {
- checkErr(err);
+ check_gpg_error(err);
return err;
} else {
emit signalKeyDBChanged();
@@ -105,7 +105,7 @@ gpgme_error_t GpgME::GpgContext::generateKey(GenKeyInfo *params) {
* @param outBuffer output byte array
* @return if success
*/
-bool GpgME::GpgContext::exportKeys(QStringList *uidList, QByteArray *outBuffer) {
+bool GpgFrontend::GpgContext::exportKeys(QStringList *uidList, QByteArray *outBuffer) {
gpgme_data_t dataOut = nullptr;
outBuffer->resize(0);
@@ -119,15 +119,15 @@ bool GpgME::GpgContext::exportKeys(QStringList *uidList, QByteArray *outBuffer)
for (int i = 0; i < uidList->count(); i++) {
err = gpgme_data_new(&dataOut);
- checkErr(err);
+ check_gpg_error(err);
err = gpgme_op_export(ctx, uidList->at(i).toUtf8().constData(), 0, dataOut);
- checkErr(err);
+ check_gpg_error(err);
- qDebug() << "exportKeys read_bytes" << gpgme_data_seek(dataOut, 0, SEEK_END);
+ qDebug() << "exportKeys read_bytes" << gpgme_data_seek(dataOut, 0, SEEK_END);
err = readToBuffer(dataOut, outBuffer);
- checkErr(err);
+ check_gpg_error(err);
gpgme_data_release(dataOut);
}
@@ -139,7 +139,7 @@ bool GpgME::GpgContext::exportKeys(QStringList *uidList, QByteArray *outBuffer)
/**
* Get and store all key pairs info
*/
-void GpgME::GpgContext::fetch_keys() {
+void GpgFrontend::GpgContext::fetch_keys() {
gpgme_error_t gpgmeError;
@@ -155,47 +155,47 @@ void GpgME::GpgContext::fetch_keys() {
qDebug() << "Set Key Listing Mode";
- gpgmeError = gpgme_set_keylist_mode(mCtx,
+ gpgmeError = gpgme_set_keylist_mode(*this,
GPGME_KEYLIST_MODE_LOCAL
| GPGME_KEYLIST_MODE_WITH_SECRET
| GPGME_KEYLIST_MODE_SIGS
| GPGME_KEYLIST_MODE_SIG_NOTATIONS
| GPGME_KEYLIST_MODE_WITH_TOFU);
if (gpg_err_code(gpgmeError) != GPG_ERR_NO_ERROR) {
- checkErr(gpgmeError);
+ check_gpg_error(gpgmeError);
return;
}
qDebug() << "Operate KeyList Start";
- gpgmeError = gpgme_op_keylist_start(mCtx, nullptr, 0);
+ gpgmeError = gpgme_op_keylist_start(*this, nullptr, 0);
if (gpg_err_code(gpgmeError) != GPG_ERR_NO_ERROR) {
- checkErr(gpgmeError);
+ check_gpg_error(gpgmeError);
return;
}
qDebug() << "Start Loop";
- while ((gpgmeError = gpgme_op_keylist_next(mCtx, &key)) == GPG_ERR_NO_ERROR) {
+ while ((gpgmeError = gpgme_op_keylist_next(*this, &key)) == GPG_ERR_NO_ERROR) {
if (!key->subkeys)
continue;
qDebug() << "Append Key" << key->subkeys->keyid;
- keys.emplace_back(key);
- keys_map.insert(keys.back().id, &keys.back());
+ keys.emplace_back(gpgme_key_t(key));
+ keys_map.insert(keys.back().id(), &keys.back());
gpgme_key_unref(key);
}
if (gpg_err_code(gpgmeError) != GPG_ERR_EOF) {
- checkErr(gpgmeError);
+ check_gpg_error(gpgmeError);
return;
}
- gpgmeError = gpgme_op_keylist_end(mCtx);
+ gpgmeError = gpgme_op_keylist_end(*this);
if (gpg_err_code(gpgmeError) != GPG_ERR_NO_ERROR) {
- checkErr(gpgmeError);
+ check_gpg_error(gpgmeError);
return;
}
@@ -208,34 +208,34 @@ void GpgME::GpgContext::fetch_keys() {
* Delete keys
* @param uidList key ids
*/
-void GpgME::GpgContext::deleteKeys(QStringList *uidList) {
+void GpgFrontend::GpgContext::deleteKeys(QStringList *uidList) {
gpgme_error_t error;
gpgme_key_t key;
for (const auto &tmp : *uidList) {
- error = gpgme_op_keylist_start(mCtx, tmp.toUtf8().constData(), 0);
+ error = gpgme_op_keylist_start(*this, tmp.toUtf8().constData(), 0);
if (error != GPG_ERR_NO_ERROR) {
- checkErr(error);
+ check_gpg_error(error);
continue;
}
- error = gpgme_op_keylist_next(mCtx, &key);
+ error = gpgme_op_keylist_next(*this, &key);
if (error != GPG_ERR_NO_ERROR) {
- checkErr(error);
+ check_gpg_error(error);
continue;
}
- error = gpgme_op_keylist_end(mCtx);
+ error = gpgme_op_keylist_end(*this);
if (error != GPG_ERR_NO_ERROR) {
- checkErr(error);
+ check_gpg_error(error);
continue;
}
- error = gpgme_op_delete(mCtx, key, 1);
+ error = gpgme_op_delete(*this, key, 1);
if (error != GPG_ERR_NO_ERROR) {
- checkErr(error);
+ check_gpg_error(error);
continue;
}
@@ -249,7 +249,7 @@ void GpgME::GpgContext::deleteKeys(QStringList *uidList) {
* @param outBuffer output byte array
* @return if success
*/
-bool GpgME::GpgContext::exportKeys(const QVector<GpgKey> &keys, QByteArray &outBuffer) {
+bool GpgFrontend::GpgContext::exportKeys(const QVector <GpgKey> &keys, QByteArray &outBuffer) {
gpgme_data_t data_out = nullptr;
outBuffer.resize(0);
@@ -260,15 +260,15 @@ bool GpgME::GpgContext::exportKeys(const QVector<GpgKey> &keys, QByteArray &outB
for (const auto &key : keys) {
err = gpgme_data_new(&data_out);
- checkErr(err);
+ check_gpg_error(err);
- err = gpgme_op_export(mCtx, key.id.toUtf8().constData(), 0, data_out);
- checkErr(err);
+ err = gpgme_op_export(*this, key.id().toUtf8().constData(), 0, data_out);
+ check_gpg_error(err);
gpgme_data_seek(data_out, 0, SEEK_END);
err = readToBuffer(data_out, &outBuffer);
- checkErr(err);
+ check_gpg_error(err);
gpgme_data_release(data_out);
}
@@ -282,24 +282,25 @@ bool GpgME::GpgContext::exportKeys(const QVector<GpgKey> &keys, QByteArray &outB
* @param expires date and time
* @return if successful
*/
-bool GpgME::GpgContext::setExpire(const GpgKey &key, const GpgSubKey *subkey, QDateTime *expires) {
+bool GpgFrontend::GpgContext::setExpire(const GpgKey &key, std::unique_ptr <GpgSubKey> &subkey,
+ std::unique_ptr <QDateTime> &expires) {
unsigned long expires_time = 0;
if (expires != nullptr) {
qDebug() << "Expire Datetime" << expires->toString();
expires_time = QDateTime::currentDateTime().secsTo(*expires);
}
- const char *subfprs = nullptr;
+ const char *sub_fprs = nullptr;
- if (subkey != nullptr) subfprs = subkey->fpr.toUtf8().constData();
+ if (subkey != nullptr) sub_fprs = subkey->fpr().toUtf8().constData();
- auto gpgmeError = gpgme_op_setexpire(mCtx, key.key_refer,
- expires_time, subfprs, 0);
+ auto gpgmeError = gpgme_op_setexpire(*this, gpgme_key_t(key),
+ expires_time, sub_fprs, 0);
if (gpgmeError == GPG_ERR_NO_ERROR) {
- emit signalKeyUpdated(key.id);
+ emit signalKeyUpdated(key.id());
return true;
} else {
- checkErr(gpgmeError);
+ check_gpg_error(gpgmeError);
return false;
}
}
@@ -310,10 +311,10 @@ bool GpgME::GpgContext::setExpire(const GpgKey &key, const GpgSubKey *subkey, QD
* @param outBuffer output byte array
* @return if successful
*/
-bool GpgME::GpgContext::exportSecretKey(const GpgKey &key, QByteArray *outBuffer) {
- qDebug() << "Export Secret Key" << key.id;
+bool GpgFrontend::GpgContext::exportSecretKey(const GpgKey &key, QByteArray *outBuffer) const {
+ qDebug() << "Export Secret Key" << key.id();
gpgme_key_t target_key[2] = {
- key.key_refer,
+ gpgme_key_t(key),
nullptr
};
@@ -321,10 +322,10 @@ bool GpgME::GpgContext::exportSecretKey(const GpgKey &key, QByteArray *outBuffer
gpgme_data_new(&dataOut);
// export private key to outBuffer
- gpgme_error_t error = gpgme_op_export_keys(mCtx, target_key, GPGME_EXPORT_MODE_SECRET, dataOut);
+ gpgme_error_t error = gpgme_op_export_keys(*this, target_key, GPGME_EXPORT_MODE_SECRET, dataOut);
if (gpgme_err_code(error) != GPG_ERR_NO_ERROR) {
- checkErr(error);
+ check_gpg_error(error);
gpgme_data_release(dataOut);
return false;
}
@@ -335,42 +336,12 @@ bool GpgME::GpgContext::exportSecretKey(const GpgKey &key, QByteArray *outBuffer
}
/**
- * Sign a key pair(actually a certain uid)
- * @param target target key pair
- * @param uid target
- * @param expires expire date and time of the signature
- * @return if successful
- */
-bool GpgME::GpgContext::signKey(const GpgKey &target, const QVector<GpgKey> &keys, const QString &uid,
- const QDateTime *expires) {
-
- setSigners(keys, mCtx);
-
- unsigned int flags = 0;
-
- unsigned int expires_time_t = 0;
- if (expires == nullptr) flags |= GPGME_KEYSIGN_NOEXPIRE;
- else expires_time_t = QDateTime::currentDateTime().secsTo(*expires);
-
- auto gpgmeError =
- gpgme_op_keysign(mCtx, target.key_refer, uid.toUtf8().constData(), expires_time_t, flags);
-
- if (gpgmeError == GPG_ERR_NO_ERROR) {
- emit signalKeyUpdated(target.id);
- return true;
- } else {
- checkErr(gpgmeError);
- return false;
- }
-}
-
-/**
* Generate revoke cert of a key pair
* @param key target key pair
* @param outputFileName out file name(path)
* @return the process doing this job
*/
-void GpgME::GpgContext::generateRevokeCert(const GpgKey &key, const QString &outputFileName) {
+void GpgFrontend::GpgContext::generateRevokeCert(const GpgKey &key, const QString &outputFileName) {
executeGpgCommand({
"--command-fd",
"0",
@@ -380,7 +351,7 @@ void GpgME::GpgContext::generateRevokeCert(const GpgKey &key, const QString &out
"-o",
outputFileName,
"--gen-revoke",
- key.fpr
+ key.fpr()
},
[](QProcess *proc) -> void {
qDebug() << "Function Called" << proc;
diff --git a/src/gpg/gpg_context/GpgContextSubkeyOpera.cpp b/src/gpg/gpg_context/GpgContextSubkeyOpera.cpp
index 10243f5e..7e73db18 100644
--- a/src/gpg/gpg_context/GpgContextSubkeyOpera.cpp
+++ b/src/gpg/gpg_context/GpgContextSubkeyOpera.cpp
@@ -30,7 +30,7 @@
* @param params opera args
* @return error info
*/
-gpgme_error_t GpgME::GpgContext::generateSubkey(const GpgKey &key, GenKeyInfo *params) {
+gpgme_error_t GpgFrontend::GpgContext::generateSubkey(const GpgKey &key, GenKeyInfo *params) {
if (!params->isSubKey()) return GPG_ERR_CANCELED;
@@ -48,13 +48,13 @@ gpgme_error_t GpgME::GpgContext::generateSubkey(const GpgKey &key, GenKeyInfo *p
flags |= GPGME_CREATE_NOPASSWD;
- auto gpgmeError = gpgme_op_createsubkey(mCtx, key.key_refer,
+ auto gpgmeError = gpgme_op_createsubkey(*this, gpgme_key_t(key),
algo, 0, expires, flags);
if (gpgme_err_code(gpgmeError) == GPG_ERR_NO_ERROR) {
- emit signalKeyUpdated(key.id);
+ emit signalKeyUpdated(key.id());
return gpgmeError;
} else {
- checkErr(gpgmeError);
+ check_gpg_error(gpgmeError);
return gpgmeError;
}
}
diff --git a/src/gpg/gpg_context/GpgContextUIDOpera.cpp b/src/gpg/gpg_context/GpgContextUIDOpera.cpp
deleted file mode 100644
index b96f5f8f..00000000
--- a/src/gpg/gpg_context/GpgContextUIDOpera.cpp
+++ /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.
- *
- */
-
-#include "gpg/GpgContext.h"
-
-/**
- * create a new uid in certain key pair
- * @param key target key pair
- * @param uid uid args
- * @return if successful
- */
-bool GpgME::GpgContext::addUID(const GpgKey &key, const GpgUID &uid) {
- QString userid = QString("%1 (%3) <%2>").arg(uid.name, uid.email, uid.comment);
- auto gpgmeError = gpgme_op_adduid(mCtx, key.key_refer, userid.toUtf8().constData(), 0);
- if (gpgmeError == GPG_ERR_NO_ERROR) {
- emit signalKeyUpdated(key.id);
- return true;
- } else {
- checkErr(gpgmeError);
- return false;
- }
-
-}
-
-/**
- * Revoke(Delete) UID from certain key pair
- * @param key target key pair
- * @param uid target uid
- * @return if successful
- */
-bool GpgME::GpgContext::revUID(const GpgKey &key, const GpgUID &uid) {
- auto gpgmeError = gpgme_op_revuid(mCtx, key.key_refer, uid.uid.toUtf8().constData(), 0);
- if (gpgmeError == GPG_ERR_NO_ERROR) {
- emit signalKeyUpdated(key.id);
- return true;
- } else {
- checkErr(gpgmeError);
- return false;
- }
-}
-
-/**
- * Set one of a uid of a key pair as primary
- * @param key target key pair
- * @param uid target uid
- * @return if successful
- */
-bool GpgME::GpgContext::setPrimaryUID(const GpgKey &key, const GpgUID &uid) {
- auto gpgmeError = gpgme_op_set_uid_flag(mCtx, key.key_refer,
- uid.uid.toUtf8().constData(), "primary", nullptr);
- if (gpgmeError == GPG_ERR_NO_ERROR) {
- emit signalKeyUpdated(key.id);
- return true;
- } else {
- checkErr(gpgmeError);
- return false;
- }
-}
-
diff --git a/src/gpg/result_analyse/DecryptResultAnalyse.cpp b/src/gpg/result_analyse/DecryptResultAnalyse.cpp
index b4d0b14f..7c91e6b2 100644
--- a/src/gpg/result_analyse/DecryptResultAnalyse.cpp
+++ b/src/gpg/result_analyse/DecryptResultAnalyse.cpp
@@ -24,7 +24,7 @@
#include "gpg/result_analyse/DecryptResultAnalyse.h"
-DecryptResultAnalyse::DecryptResultAnalyse(GpgME::GpgContext *ctx, gpgme_error_t error, gpgme_decrypt_result_t result)
+DecryptResultAnalyse::DecryptResultAnalyse(GpgFrontend::GpgContext *ctx, gpgme_error_t error, gpgme_decrypt_result_t result)
: mCtx(ctx) {
stream << tr("[#] Decrypt Operation ");
@@ -65,7 +65,7 @@ bool DecryptResultAnalyse::printReci(QTextStream &stream, gpgme_recipient_t reci
bool keyFound = true;
stream << QApplication::tr(" {>} Recipient: ");
- auto key = mCtx->getKeyById(reci->keyid);
+ auto key = mCtx->getKeyRefById(reci->keyid);
if(key.good) {
stream << key.name;
if (!key.email.isEmpty()) {
diff --git a/src/gpg/result_analyse/SignResultAnalyse.cpp b/src/gpg/result_analyse/SignResultAnalyse.cpp
index 10d76678..efbbb4db 100644
--- a/src/gpg/result_analyse/SignResultAnalyse.cpp
+++ b/src/gpg/result_analyse/SignResultAnalyse.cpp
@@ -24,7 +24,7 @@
#include "gpg/result_analyse/SignResultAnalyse.h"
-SignResultAnalyse::SignResultAnalyse(GpgME::GpgContext *ctx, gpgme_error_t error, gpgme_sign_result_t result) {
+SignResultAnalyse::SignResultAnalyse(GpgFrontend::GpgContext *ctx, gpgme_error_t error, gpgme_sign_result_t result) {
qDebug() << "Start Sign Result Analyse";
@@ -58,7 +58,7 @@ SignResultAnalyse::SignResultAnalyse(GpgME::GpgContext *ctx, gpgme_error_t error
stream << Qt::endl;
- GpgKey singerKey = ctx->getKeyByFpr(new_sign->fpr);
+ GpgKey singerKey = ctx->getKeyRefByFpr(new_sign->fpr);
if(singerKey.good) {
stream << tr(" Signer: ") << singerKey.uids.first().uid << Qt::endl;
} else {
diff --git a/src/gpg/result_analyse/VerifyResultAnalyse.cpp b/src/gpg/result_analyse/VerifyResultAnalyse.cpp
index 75e07d33..a2c69d2e 100644
--- a/src/gpg/result_analyse/VerifyResultAnalyse.cpp
+++ b/src/gpg/result_analyse/VerifyResultAnalyse.cpp
@@ -25,7 +25,7 @@
#include "GpgFrontend.h"
#include "gpg/result_analyse/VerifyResultAnalyse.h"
-VerifyResultAnalyse::VerifyResultAnalyse(GpgME::GpgContext *ctx, gpgme_error_t error, gpgme_verify_result_t result)
+VerifyResultAnalyse::VerifyResultAnalyse(GpgFrontend::GpgContext *ctx, gpgme_error_t error, gpgme_verify_result_t result)
: mCtx(ctx) {
qDebug() << "Verify Result Analyse Started";
@@ -137,7 +137,7 @@ VerifyResultAnalyse::VerifyResultAnalyse(GpgME::GpgContext *ctx, gpgme_error_t e
break;
default:
stream << QApplication::tr("Error for key with fingerprint ") <<
- GpgME::GpgContext::beautifyFingerprint(QString(sign->fpr));
+ GpgFrontend::GpgContext::beautifyFingerprint(QString(sign->fpr));
setStatus(-1);
}
stream << Qt::endl;
@@ -149,9 +149,7 @@ VerifyResultAnalyse::VerifyResultAnalyse(GpgME::GpgContext *ctx, gpgme_error_t e
bool VerifyResultAnalyse::printSigner(QTextStream &stream, gpgme_signature_t sign) {
bool keyFound = true;
- auto key = mCtx->getKeyByFpr(sign->fpr);
-
- key = mCtx->getKeyByFpr(sign->fpr);
+ auto key = mCtx->getKeyRefByFpr(sign->fpr);
if (!key.good) {
stream << tr(" Signed By: ") << tr("<unknown>") << Qt::endl;
diff --git a/src/main.cpp b/src/main.cpp
index 1e54d6e7..831a6121 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -86,6 +86,24 @@ int main(int argc, char *argv[]) {
QApplication::setQuitOnLastWindowClosed(true);
+
+ /**
+ * The function `gpgme_check_version' must be called before any other
+ * function in the library, because it initializes the thread support
+ * subsystem in GPGME. (from the info page) */
+ gpgme_check_version(nullptr);
+
+ // the locale set here is used for the other setlocale calls which have nullptr
+ // -> nullptr means use default, which is configured here
+ setlocale(LC_ALL, settings.value("int/lang").toLocale().name().toUtf8().constData());
+
+ /** set locale, because tests do also */
+ gpgme_set_locale(nullptr, LC_CTYPE, setlocale(LC_CTYPE, nullptr));
+ //qDebug() << "Locale set to" << LC_CTYPE << " - " << setlocale(LC_CTYPE, nullptr);
+ #ifndef _WIN32
+ gpgme_set_locale(nullptr, LC_MESSAGES, setlocale(LC_MESSAGES, nullptr));
+ #endif
+
MainWindow window;
return_from_event_loop_code = QApplication::exec();
diff --git a/src/server/ComUtils.cpp b/src/server/ComUtils.cpp
index 01be4ea7..bbcc873c 100644
--- a/src/server/ComUtils.cpp
+++ b/src/server/ComUtils.cpp
@@ -29,7 +29,7 @@
* @param reply reply data in byte array
* @return if successful
*/
-bool ComUtils::checkServerReply(const QByteArray &reply) {
+bool GpgFrontend::ComUtils::checkServerReply(const QByteArray &reply) {
if(reply.isEmpty()) {
QMessageBox::critical(this, tr("Error"), tr("Nothing Reply. Please check the Internet connection."));
@@ -97,7 +97,7 @@ bool ComUtils::checkServerReply(const QByteArray &reply) {
* @param key key of value
* @return value in string format
*/
-QString ComUtils::getDataValueStr(const QString &key) const {
+QString GpgFrontend::ComUtils::getDataValueStr(const QString &key) const {
if (is_good) {
auto k_byte_array = key.toUtf8();
if (dataVal.HasMember(k_byte_array.data())) {
@@ -111,7 +111,7 @@ QString ComUtils::getDataValueStr(const QString &key) const {
* @param type service which server provides
* @return url
*/
-QString ComUtils::getUrl(ComUtils::ServiceType type) const {
+QString GpgFrontend::ComUtils::getUrl(ComUtils::ServiceType type) const {
auto host = settings.value("general/currentGpgfrontendServer",
"service.gpgfrontend.pub").toString();
@@ -145,19 +145,19 @@ QString ComUtils::getUrl(ComUtils::ServiceType type) const {
return url;
}
-bool ComUtils::checkDataValueStr(const QString &key) const {
+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 ComUtils::checkServiceTokenFormat(const QString &uuid) const {
+bool GpgFrontend::ComUtils::checkServiceTokenFormat(const QString &uuid) const {
return re_uuid.match(uuid).hasMatch();
}
-QByteArray ComUtils::getSignStringBase64(GpgME::GpgContext *ctx, const QString &str, const GpgKey &key) {
- QVector<GpgKey> keys{key};
+QByteArray GpgFrontend::ComUtils::getSignStringBase64(GpgFrontend::GpgContext *ctx, const QString &str, const GpgKey &key) {
+ std::vector<GpgKey> keys{key};
QByteArray outSignText;
auto signData = str.toUtf8();
@@ -173,7 +173,7 @@ QByteArray ComUtils::getSignStringBase64(GpgME::GpgContext *ctx, const QString &
return outSignText.toBase64();
}
-const rapidjson::Value &ComUtils::getDataValue(const QString &key) const {
+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())) {
@@ -183,14 +183,14 @@ const rapidjson::Value &ComUtils::getDataValue(const QString &key) const {
throw std::runtime_error("Inner Error");
}
-bool ComUtils::checkDataValue(const QString &key) const{
+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 ComUtils::clear() {
+void GpgFrontend::ComUtils::clear() {
this->dataVal.Clear();
this->replyDoc.Clear();
is_good = false;
diff --git a/src/server/api/PubkeyGetter.cpp b/src/server/api/PubkeyGetter.cpp
index 2ba55d11..6505cb3e 100644
--- a/src/server/api/PubkeyGetter.cpp
+++ b/src/server/api/PubkeyGetter.cpp
@@ -24,7 +24,7 @@
#include "server/api/PubkeyGetter.h"
-PubkeyGetter::PubkeyGetter(GpgME::GpgContext *ctx, const QVector<QString> &fprs) : BaseAPI(ComUtils::GetPubkey),
+PubkeyGetter::PubkeyGetter(GpgFrontend::GpgContext *ctx, const QVector<QString> &fprs) : BaseAPI(ComUtils::GetPubkey),
mCtx(ctx), mFprs(fprs) {
}
diff --git a/src/server/api/PubkeyUploader.cpp b/src/server/api/PubkeyUploader.cpp
index c6101c65..2842c2d7 100644
--- a/src/server/api/PubkeyUploader.cpp
+++ b/src/server/api/PubkeyUploader.cpp
@@ -24,7 +24,7 @@
#include "server/api/PubkeyUploader.h"
-PubkeyUploader::PubkeyUploader(GpgME::GpgContext *ctx, const QVector<GpgKey> &keys) : BaseAPI(ComUtils::UploadPubkey),
+PubkeyUploader::PubkeyUploader(GpgFrontend::GpgContext *ctx, const QVector<GpgKey> &keys) : BaseAPI(ComUtils::UploadPubkey),
mCtx(ctx),
mKeys(keys) {
}
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index b6552227..170e7454 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -9,6 +9,4 @@ aux_source_directory(./settings UI_SOURCE)
add_library(gpgfrontend-ui STATIC ${UI_SOURCE})
target_link_libraries(gpgfrontend-ui
- Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core)
-
-message(STATUS "UI SOURCE ${UI_SOURCE}") \ No newline at end of file
+ Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core) \ No newline at end of file
diff --git a/src/ui/FileEncryptionDialog.cpp b/src/ui/FileEncryptionDialog.cpp
index 23ec0b2a..55c8e5f0 100755
--- a/src/ui/FileEncryptionDialog.cpp
+++ b/src/ui/FileEncryptionDialog.cpp
@@ -24,7 +24,7 @@
#include "ui/FileEncryptionDialog.h"
-FileEncryptionDialog::FileEncryptionDialog(GpgME::GpgContext *ctx, QStringList keyList, DialogAction action,
+FileEncryptionDialog::FileEncryptionDialog(GpgFrontend::GpgContext *ctx, QStringList keyList, DialogAction action,
QWidget *parent)
: QDialog(parent), mAction(action), mCtx(ctx){
@@ -92,13 +92,13 @@ FileEncryptionDialog::FileEncryptionDialog(GpgME::GpgContext *ctx, QStringList k
if(mAction == Encrypt)
mKeyList->setFilter([](const GpgKey &key) -> bool {
- if(!GpgME::GpgContext::checkIfKeyCanEncr(key)) return false;
+ if(!GpgFrontend::GpgContext::checkIfKeyCanEncr(key)) return false;
else return true;
});
if(mAction == Sign)
mKeyList->setFilter([](const GpgKey &key) -> bool {
- if(!GpgME::GpgContext::checkIfKeyCanSign(key)) return false;
+ if(!GpgFrontend::GpgContext::checkIfKeyCanSign(key)) return false;
else return true;
});
diff --git a/src/ui/KeyImportDetailDialog.cpp b/src/ui/KeyImportDetailDialog.cpp
index 8d303886..8614051b 100644
--- a/src/ui/KeyImportDetailDialog.cpp
+++ b/src/ui/KeyImportDetailDialog.cpp
@@ -24,7 +24,7 @@
#include <ui/KeyImportDetailDialog.h>
-KeyImportDetailDialog::KeyImportDetailDialog(GpgME::GpgContext *ctx, GpgImportInformation result, bool automatic,
+KeyImportDetailDialog::KeyImportDetailDialog(GpgFrontend::GpgContext *ctx, GpgImportInformation result, bool automatic,
QWidget *parent)
: QDialog(parent), mCtx(ctx), mResult(std::move(result)) {
@@ -115,7 +115,7 @@ void KeyImportDetailDialog::createKeysTable() {
int row = 0;
for (const auto &impKey : mResult.importedKeys) {
keysTable->setRowCount(row + 1);
- GpgKey key = mCtx->getKeyByFpr(impKey.fpr);
+ GpgKey key = mCtx->getKeyRefByFpr(impKey.fpr);
if(!key.good) continue;
keysTable->setItem(row, 0, new QTableWidgetItem(key.name));
keysTable->setItem(row, 1, new QTableWidgetItem(key.email));
diff --git a/src/ui/KeyMgmt.cpp b/src/ui/KeyMgmt.cpp
index 77f3b760..9f3665d3 100755
--- a/src/ui/KeyMgmt.cpp
+++ b/src/ui/KeyMgmt.cpp
@@ -26,7 +26,7 @@
#include <utility>
-KeyMgmt::KeyMgmt(GpgME::GpgContext *ctx, QWidget *parent) :
+KeyMgmt::KeyMgmt(GpgFrontend::GpgContext *ctx, QWidget *parent) :
QMainWindow(parent), appPath(qApp->applicationDirPath()),
settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) {
mCtx = ctx;
@@ -251,7 +251,7 @@ void KeyMgmt::deleteKeysWithWarning(QStringList *uidList) {
}
QString keynames;
for (const auto &uid : *uidList) {
- auto key = mCtx->getKeyById(uid);
+ auto key = mCtx->getKeyRefById(uid);
if (!key.good) continue;
keynames.append(key.name);
keynames.append("<i> &lt;");
@@ -275,7 +275,7 @@ void KeyMgmt::slotShowKeyDetails() {
return;
}
- auto key = mCtx->getKeyById(mKeyList->getSelected()->first());
+ auto key = mCtx->getKeyRefById(mKeyList->getSelected()->first());
if (!key.good) {
QMessageBox::critical(nullptr, tr("Error"), tr("Key Not Found."));
@@ -291,7 +291,7 @@ void KeyMgmt::slotExportKeyToFile() {
delete keyArray;
return;
}
- auto key = mCtx->getKeyById(mKeyList->getSelected()->first());
+ auto key = mCtx->getKeyRefById(mKeyList->getSelected()->first());
if (!key.good) {
QMessageBox::critical(nullptr, tr("Error"), tr("Key Not Found."));
return;
@@ -339,7 +339,7 @@ void KeyMgmt::slotGenerateSubKey() {
tr("Please select one KeyPair before doing this operation."));
return;
}
- const auto key = mCtx->getKeyById(selectedList->first());
+ const auto key = mCtx->getKeyRefById(selectedList->first());
if (!key.good) {
QMessageBox::critical(nullptr, tr("Error"), tr("Key Not Found."));
return;
diff --git a/src/ui/KeyServerImportDialog.cpp b/src/ui/KeyServerImportDialog.cpp
index a1355120..4343eb79 100644
--- a/src/ui/KeyServerImportDialog.cpp
+++ b/src/ui/KeyServerImportDialog.cpp
@@ -26,7 +26,7 @@
#include <utility>
-KeyServerImportDialog::KeyServerImportDialog(GpgME::GpgContext *ctx, KeyList *keyList, bool automatic,
+KeyServerImportDialog::KeyServerImportDialog(GpgFrontend::GpgContext *ctx, KeyList *keyList, bool automatic,
QWidget *parent)
: QDialog(parent), appPath(qApp->applicationDirPath()),
settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat),
@@ -437,7 +437,7 @@ void KeyServerImportDialog::setLoading(bool status) {
}
}
-KeyServerImportDialog::KeyServerImportDialog(GpgME::GpgContext *ctx, QWidget *parent)
+KeyServerImportDialog::KeyServerImportDialog(GpgFrontend::GpgContext *ctx, QWidget *parent)
: QDialog(parent), appPath(qApp->applicationDirPath()),
settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat),
mCtx(ctx), mAutomatic(true) {
diff --git a/src/ui/KeyUploadDialog.cpp b/src/ui/KeyUploadDialog.cpp
index ab38569f..321441b7 100644
--- a/src/ui/KeyUploadDialog.cpp
+++ b/src/ui/KeyUploadDialog.cpp
@@ -24,7 +24,7 @@
#include "ui/KeyUploadDialog.h"
-KeyUploadDialog::KeyUploadDialog(GpgME::GpgContext *ctx, const QVector<GpgKey> &keys, QWidget *parent)
+KeyUploadDialog::KeyUploadDialog(GpgFrontend::GpgContext *ctx, const QVector<GpgKey> &keys, QWidget *parent)
: appPath(qApp->applicationDirPath()),
settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat),
mCtx(ctx),
diff --git a/src/ui/VerifyDetailsDialog.cpp b/src/ui/VerifyDetailsDialog.cpp
index 641c09e9..3462ad69 100644
--- a/src/ui/VerifyDetailsDialog.cpp
+++ b/src/ui/VerifyDetailsDialog.cpp
@@ -24,7 +24,7 @@
#include "ui/VerifyDetailsDialog.h"
-VerifyDetailsDialog::VerifyDetailsDialog(QWidget *parent, GpgME::GpgContext *ctx, KeyList *keyList, gpg_error_t error,
+VerifyDetailsDialog::VerifyDetailsDialog(QWidget *parent, GpgFrontend::GpgContext *ctx, KeyList *keyList, gpg_error_t error,
gpgme_verify_result_t result) :
QDialog(parent), mCtx(ctx), mKeyList(keyList), sign(result->signatures), error(error) {
diff --git a/src/ui/Wizard.cpp b/src/ui/Wizard.cpp
index 8b482675..4c7b8d7c 100644
--- a/src/ui/Wizard.cpp
+++ b/src/ui/Wizard.cpp
@@ -24,7 +24,7 @@
#include "ui/Wizard.h"
-Wizard::Wizard(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent)
+Wizard::Wizard(GpgFrontend::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent)
: QWizard(parent), appPath(qApp->applicationDirPath()),
settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) {
mCtx = ctx;
@@ -177,7 +177,7 @@ void ChoosePage::slotJumpPage(const QString &page) {
wizard()->next();
}
-KeyGenPage::KeyGenPage(GpgME::GpgContext *ctx, QWidget *parent)
+KeyGenPage::KeyGenPage(GpgFrontend::GpgContext *ctx, QWidget *parent)
: QWizardPage(parent) {
mCtx = ctx;
setTitle(tr("Create a keypair..."));
diff --git a/src/ui/help/AboutDialog.cpp b/src/ui/help/AboutDialog.cpp
index e5798541..deb6a3bc 100644
--- a/src/ui/help/AboutDialog.cpp
+++ b/src/ui/help/AboutDialog.cpp
@@ -82,7 +82,7 @@ InfoTab::InfoTab(QWidget *parent)
"If you have any questions or suggestions, raise an issue<br/>"
"at <a href=\"https://github.com/saturneric/GpgFrontend\">GitHub</a> or send a mail to my mailing list at <a href=\"mailto:[email protected]\">[email protected]</a>.") +
tr("<br><br> Built with Qt ") + qVersion()
- + tr(" and GPGME ") + GpgME::GpgContext::getGpgmeVersion() +
+ + tr(" and GPGME ") + GpgFrontend::GpgContext::getGpgmeVersion() +
tr("<br>Built at ") + BUILD_TIMESTAMP + "</center>");
auto *layout = new QGridLayout();
diff --git a/src/ui/keygen/KeygenDialog.cpp b/src/ui/keygen/KeygenDialog.cpp
index 98216dc6..958f9ecc 100644
--- a/src/ui/keygen/KeygenDialog.cpp
+++ b/src/ui/keygen/KeygenDialog.cpp
@@ -25,7 +25,7 @@
#include "ui/keygen/KeygenDialog.h"
#include "ui/WaitingDialog.h"
-KeyGenDialog::KeyGenDialog(GpgME::GpgContext *ctx, QWidget *parent)
+KeyGenDialog::KeyGenDialog(GpgFrontend::GpgContext *ctx, QWidget *parent)
: QDialog(parent), mCtx(ctx) {
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
diff --git a/src/ui/keygen/SubkeyGenerateDialog.cpp b/src/ui/keygen/SubkeyGenerateDialog.cpp
index 3d709d81..8e5d01a3 100644
--- a/src/ui/keygen/SubkeyGenerateDialog.cpp
+++ b/src/ui/keygen/SubkeyGenerateDialog.cpp
@@ -25,7 +25,7 @@
#include "ui/keygen/SubkeyGenerateDialog.h"
#include "ui/WaitingDialog.h"
-SubkeyGenerateDialog::SubkeyGenerateDialog(GpgME::GpgContext *ctx, const GpgKey &key, QWidget *parent)
+SubkeyGenerateDialog::SubkeyGenerateDialog(GpgFrontend::GpgContext *ctx, const GpgKey &key, QWidget *parent)
: genKeyInfo(true), mCtx(ctx), mKey(key), QDialog(parent) {
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
diff --git a/src/ui/keypair_details/KeyDetailsDialog.cpp b/src/ui/keypair_details/KeyDetailsDialog.cpp
index c80374d4..0d94e584 100644
--- a/src/ui/keypair_details/KeyDetailsDialog.cpp
+++ b/src/ui/keypair_details/KeyDetailsDialog.cpp
@@ -24,7 +24,7 @@
#include "ui/keypair_details/KeyDetailsDialog.h"
-KeyDetailsDialog::KeyDetailsDialog(GpgME::GpgContext *ctx, const GpgKey& key, QWidget *parent)
+KeyDetailsDialog::KeyDetailsDialog(GpgFrontend::GpgContext *ctx, const GpgKey& key, QWidget *parent)
: QDialog(parent) {
tabWidget = new QTabWidget();
diff --git a/src/ui/keypair_details/KeyNewUIDDialog.cpp b/src/ui/keypair_details/KeyNewUIDDialog.cpp
index e12af750..7c6e1ca5 100644
--- a/src/ui/keypair_details/KeyNewUIDDialog.cpp
+++ b/src/ui/keypair_details/KeyNewUIDDialog.cpp
@@ -24,7 +24,7 @@
#include "ui/keypair_details/KeyNewUIDDialog.h"
-KeyNewUIDDialog::KeyNewUIDDialog(GpgME::GpgContext *ctx, const GpgKey &key, QWidget *parent) :
+KeyNewUIDDialog::KeyNewUIDDialog(GpgFrontend::GpgContext *ctx, const GpgKey &key, QWidget *parent) :
mCtx(ctx), mKey(key), QDialog(parent) {
name = new QLineEdit();
diff --git a/src/ui/keypair_details/KeyPairDetailTab.cpp b/src/ui/keypair_details/KeyPairDetailTab.cpp
index c0a2df99..1f5d4095 100644
--- a/src/ui/keypair_details/KeyPairDetailTab.cpp
+++ b/src/ui/keypair_details/KeyPairDetailTab.cpp
@@ -25,7 +25,7 @@
#include "ui/keypair_details/KeyPairDetailTab.h"
#include "ui/WaitingDialog.h"
-KeyPairDetailTab::KeyPairDetailTab(GpgME::GpgContext *ctx, const GpgKey &mKey, QWidget *parent) : mKey(mKey),
+KeyPairDetailTab::KeyPairDetailTab(GpgFrontend::GpgContext *ctx, const GpgKey &mKey, QWidget *parent) : mKey(mKey),
QWidget(parent) {
mCtx = ctx;
@@ -214,7 +214,7 @@ void KeyPairDetailTab::slotExportPrivateKey() {
return;
}
- auto key = mCtx->getKeyById(*keyid);
+ auto key = mCtx->getKeyRefById(*keyid);
if (!key.good) {
QMessageBox::critical(nullptr, tr("Error"), tr("Key Not Found."));
return;
@@ -279,13 +279,13 @@ void KeyPairDetailTab::slotRefreshKeyInfo() {
QString actualUsage;
QTextStream actual_usage_steam(&actualUsage);
- if (GpgME::GpgContext::checkIfKeyCanCert(mKey))
+ if (GpgFrontend::GpgContext::checkIfKeyCanCert(mKey))
actual_usage_steam << "Cert ";
- if (GpgME::GpgContext::checkIfKeyCanEncr(mKey))
+ if (GpgFrontend::GpgContext::checkIfKeyCanEncr(mKey))
actual_usage_steam << "Encr ";
- if (GpgME::GpgContext::checkIfKeyCanSign(mKey))
+ if (GpgFrontend::GpgContext::checkIfKeyCanSign(mKey))
actual_usage_steam << "Sign ";
- if (GpgME::GpgContext::checkIfKeyCanAuth(mKey))
+ if (GpgFrontend::GpgContext::checkIfKeyCanAuth(mKey))
actual_usage_steam << "Auth ";
actualUsageVarLabel->setText(actualUsage);
diff --git a/src/ui/keypair_details/KeyPairSubkeyTab.cpp b/src/ui/keypair_details/KeyPairSubkeyTab.cpp
index 6a924394..e2714303 100644
--- a/src/ui/keypair_details/KeyPairSubkeyTab.cpp
+++ b/src/ui/keypair_details/KeyPairSubkeyTab.cpp
@@ -24,7 +24,7 @@
#include "ui/keypair_details/KeyPairSubkeyTab.h"
-KeyPairSubkeyTab::KeyPairSubkeyTab(GpgME::GpgContext *ctx, const GpgKey &key, QWidget *parent) : mCtx(ctx), mKey(key), QWidget(parent) {
+KeyPairSubkeyTab::KeyPairSubkeyTab(GpgFrontend::GpgContext *ctx, const GpgKey &key, QWidget *parent) : mCtx(ctx), mKey(key), QWidget(parent) {
createSubkeyList();
createSubkeyOperaMenu();
diff --git a/src/ui/keypair_details/KeyPairUIDTab.cpp b/src/ui/keypair_details/KeyPairUIDTab.cpp
index 2954aadb..fed500a4 100644
--- a/src/ui/keypair_details/KeyPairUIDTab.cpp
+++ b/src/ui/keypair_details/KeyPairUIDTab.cpp
@@ -24,7 +24,7 @@
#include "ui/keypair_details/KeyPairUIDTab.h"
-KeyPairUIDTab::KeyPairUIDTab(GpgME::GpgContext *ctx, const GpgKey &key, QWidget *parent) : QWidget(parent), mKey(key) {
+KeyPairUIDTab::KeyPairUIDTab(GpgFrontend::GpgContext *ctx, const GpgKey &key, QWidget *parent) : QWidget(parent), mKey(key) {
mCtx = ctx;
diff --git a/src/ui/keypair_details/KeySetExpireDateDialog.cpp b/src/ui/keypair_details/KeySetExpireDateDialog.cpp
index f76fa3ab..da4f63cf 100644
--- a/src/ui/keypair_details/KeySetExpireDateDialog.cpp
+++ b/src/ui/keypair_details/KeySetExpireDateDialog.cpp
@@ -24,7 +24,7 @@
#include "ui/keypair_details/KeySetExpireDateDialog.h"
-KeySetExpireDateDialog::KeySetExpireDateDialog(GpgME::GpgContext *ctx, const GpgKey &key, const GpgSubKey *subkey, QWidget *parent) :
+KeySetExpireDateDialog::KeySetExpireDateDialog(GpgFrontend::GpgContext *ctx, const GpgKey &key, const GpgSubKey *subkey, QWidget *parent) :
QDialog(parent), mKey(key), mSubkey(subkey), mCtx(ctx) {
QDateTime maxDateTime = QDateTime::currentDateTime().addYears(2);
diff --git a/src/ui/keypair_details/KeyUIDSignDialog.cpp b/src/ui/keypair_details/KeyUIDSignDialog.cpp
index 9232cfce..90b2033c 100644
--- a/src/ui/keypair_details/KeyUIDSignDialog.cpp
+++ b/src/ui/keypair_details/KeyUIDSignDialog.cpp
@@ -24,7 +24,7 @@
#include "ui/keypair_details/KeyUIDSignDialog.h"
-KeyUIDSignDialog::KeyUIDSignDialog(GpgME::GpgContext *ctx, const GpgKey &key, const QVector<GpgUID> &uid, QWidget *parent) :
+KeyUIDSignDialog::KeyUIDSignDialog(GpgFrontend::GpgContext *ctx, const GpgKey &key, const QVector<GpgUID> &uid, QWidget *parent) :
mKey(key), mCtx(ctx), mUids(uid), QDialog(parent) {
mKeyList = new KeyList(ctx,
diff --git a/src/ui/main_window/MainWindowFileSlotFunction.cpp b/src/ui/main_window/MainWindowFileSlotFunction.cpp
index e391c666..eff84fcf 100644
--- a/src/ui/main_window/MainWindowFileSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowFileSlotFunction.cpp
@@ -64,7 +64,7 @@ void MainWindow::slotFileEncrypt() {
}
for (const auto &key : keys) {
- if (!GpgME::GpgContext::checkIfKeyCanEncr(key)) {
+ if (!GpgFrontend::GpgContext::checkIfKeyCanEncr(key)) {
QMessageBox::information(this,
tr("Invalid Operation"),
tr("The selected key contains a key that does not actually have a encrypt usage.<br/>")
@@ -241,7 +241,7 @@ void MainWindow::slotFileSign() {
}
for (const auto &key : keys) {
- if (!GpgME::GpgContext::checkIfKeyCanEncr(key)) {
+ if (!GpgFrontend::GpgContext::checkIfKeyCanEncr(key)) {
QMessageBox::information(this,
tr("Invalid Operation"),
tr("The selected key contains a key that does not actually have a encrypt usage.<br/>")
@@ -426,8 +426,8 @@ void MainWindow::slotFileEncryptSign() {
bool can_sign = false, can_encr = false;
for (const auto &key : keys) {
- bool key_can_sign = GpgME::GpgContext::checkIfKeyCanSign(key);
- bool key_can_encr = GpgME::GpgContext::checkIfKeyCanEncr(key);
+ bool key_can_sign = GpgFrontend::GpgContext::checkIfKeyCanSign(key);
+ bool key_can_encr = GpgFrontend::GpgContext::checkIfKeyCanEncr(key);
if (!key_can_sign && !key_can_encr) {
QMessageBox::critical(nullptr,
diff --git a/src/ui/main_window/MainWindowServerSlotFunction.cpp b/src/ui/main_window/MainWindowServerSlotFunction.cpp
index 3a7e9f71..dbbf178a 100644
--- a/src/ui/main_window/MainWindowServerSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowServerSlotFunction.cpp
@@ -38,7 +38,7 @@ QString MainWindow::getCryptText(const QString &shortenCryptoText) {
QString ownKeyId = settings.value("general/ownKeyId").toString();
- GpgKey key = mCtx->getKeyById(ownKeyId);
+ GpgKey key = mCtx->getKeyRefById(ownKeyId);
if (!key.good) {
QMessageBox::critical(this, tr("Invalid Own Key"),
tr("Own Key can not be use to do any operation. "
@@ -149,7 +149,7 @@ void MainWindow::shortenCryptText() {
QNetworkRequest request(reqUrl);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
- GpgKey key = mCtx->getKeyById(ownKeyId);
+ GpgKey key = mCtx->getKeyRefById(ownKeyId);
if (!key.good) {
QMessageBox::critical(this, tr("Invalid Own Key"), tr("Own Key can not be use to do any operation."));
return;
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp
index 501418d6..347cf412 100644
--- a/src/ui/main_window/MainWindowSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowSlotFunction.cpp
@@ -47,7 +47,7 @@ void MainWindow::slotEncrypt() {
}
for (const auto &key : keys) {
- if (!GpgME::GpgContext::checkIfKeyCanEncr(key)) {
+ if (!GpgFrontend::GpgContext::checkIfKeyCanEncr(key)) {
QMessageBox::information(nullptr,
tr("Invalid Operation"),
tr("The selected key contains a key that does not actually have a encrypt usage.<br/>")
@@ -127,7 +127,7 @@ void MainWindow::slotSign() {
}
for (const auto &key : keys) {
- if (!GpgME::GpgContext::checkIfKeyCanSign(key)) {
+ if (!GpgFrontend::GpgContext::checkIfKeyCanSign(key)) {
QMessageBox::information(this,
tr("Invalid Operation"),
tr("The selected key contains a key that does not actually have a signature usage.<br/>")
@@ -179,7 +179,7 @@ void MainWindow::slotDecrypt() {
auto decrypted = QByteArray();
QByteArray text = edit->curTextPage()->toPlainText().toUtf8();
- GpgME::GpgContext::preventNoDataErr(&text);
+ GpgFrontend::GpgContext::preventNoDataErr(&text);
if (text.trimmed().startsWith(GpgConstants::GPG_FRONTEND_SHORT_CRYPTO_HEAD)) {
QMessageBox::critical(this, tr("Notice"), tr("Short Crypto Text only supports Decrypt & Verify."));
@@ -244,7 +244,7 @@ void MainWindow::slotVerify() {
if (edit->slotCurPageTextEdit() != nullptr) {
QByteArray text = edit->curTextPage()->toPlainText().toUtf8();
- GpgME::GpgContext::preventNoDataErr(&text);
+ GpgFrontend::GpgContext::preventNoDataErr(&text);
gpgme_verify_result_t result;
@@ -298,7 +298,7 @@ void MainWindow::slotEncryptSign() {
}
for (const auto &key : keys) {
- bool key_can_encr = GpgME::GpgContext::checkIfKeyCanEncr(key);
+ bool key_can_encr = GpgFrontend::GpgContext::checkIfKeyCanEncr(key);
if (!key_can_encr) {
QMessageBox::critical(nullptr,
@@ -432,7 +432,7 @@ void MainWindow::slotDecryptVerify() {
QByteArray text = plainText.toUtf8();
- GpgME::GpgContext::preventNoDataErr(&text);
+ GpgFrontend::GpgContext::preventNoDataErr(&text);
gpgme_decrypt_result_t d_result = nullptr;
gpgme_verify_result_t v_result = nullptr;
@@ -516,7 +516,7 @@ void MainWindow::slotCopyMailAddressToClipboard() {
if (mKeyList->getSelected()->isEmpty()) {
return;
}
- auto key = mCtx->getKeyById(mKeyList->getSelected()->first());
+ auto key = mCtx->getKeyRefById(mKeyList->getSelected()->first());
if (!key.good) {
QMessageBox::critical(nullptr, tr("Error"), tr("Key Not Found."));
return;
@@ -530,7 +530,7 @@ void MainWindow::slotShowKeyDetails() {
if (mKeyList->getSelected()->isEmpty()) {
return;
}
- auto key = mCtx->getKeyById(mKeyList->getSelected()->first());
+ auto key = mCtx->getKeyRefById(mKeyList->getSelected()->first());
if (key.good) {
new KeyDetailsDialog(mCtx, key, this);
} else {
diff --git a/src/ui/settings/SettingsDialog.cpp b/src/ui/settings/SettingsDialog.cpp
index 0ca188f7..33595b25 100644
--- a/src/ui/settings/SettingsDialog.cpp
+++ b/src/ui/settings/SettingsDialog.cpp
@@ -25,7 +25,7 @@
#include "ui/SettingsDialog.h"
#include "ui/WaitingDialog.h"
-SettingsDialog::SettingsDialog(GpgME::GpgContext *ctx, QWidget *parent)
+SettingsDialog::SettingsDialog(GpgFrontend::GpgContext *ctx, QWidget *parent)
: QDialog(parent) {
mCtx = ctx;
tabWidget = new QTabWidget;
diff --git a/src/ui/settings/SettingsGeneral.cpp b/src/ui/settings/SettingsGeneral.cpp
index bec66154..666556a0 100644
--- a/src/ui/settings/SettingsGeneral.cpp
+++ b/src/ui/settings/SettingsGeneral.cpp
@@ -28,7 +28,7 @@
#include "rapidjson/prettywriter.h"
-GeneralTab::GeneralTab(GpgME::GpgContext *ctx, QWidget *parent)
+GeneralTab::GeneralTab(GpgFrontend::GpgContext *ctx, QWidget *parent)
: QWidget(parent), appPath(qApp->applicationDirPath()),
settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini",
QSettings::IniFormat) {
@@ -104,7 +104,7 @@ GeneralTab::GeneralTab(GpgME::GpgContext *ctx, QWidget *parent)
keyIds.insert("", tr("<none>"));
for (const auto &keyid : *mKeyList->getAllPrivateKeys()) {
- auto key = mCtx->getKeyById(keyid);
+ auto key = mCtx->getKeyRefById(keyid);
if (!key.good) continue;
keyIds.insert(key.id, key.uids.first().uid);
}
@@ -260,7 +260,7 @@ void GeneralTab::slotGetServiceToken() {
QByteArray keyDataBuf;
mCtx->exportKeys(&selectedKeyIds, &keyDataBuf);
- GpgKey key = mCtx->getKeyById(keyId);
+ GpgKey key = mCtx->getKeyRefById(keyId);
if (!key.good) {
QMessageBox::critical(this, tr("Error"),
@@ -341,7 +341,7 @@ void GeneralTab::slotGetServiceToken() {
QString serviceTokenTemp = utils->getDataValueStr("serviceToken");
QString fpr = utils->getDataValueStr("fpr");
- auto key = mCtx->getKeyByFpr(fpr);
+ auto key = mCtx->getKeyRefByFpr(fpr);
if (utils->checkServiceTokenFormat(serviceTokenTemp) && key.good) {
serviceToken = serviceTokenTemp;
qDebug() << "Get Service Token" << serviceToken;
diff --git a/src/ui/widgets/InfoBoardWidget.cpp b/src/ui/widgets/InfoBoardWidget.cpp
index b9372c59..0c0b6bcd 100644
--- a/src/ui/widgets/InfoBoardWidget.cpp
+++ b/src/ui/widgets/InfoBoardWidget.cpp
@@ -24,7 +24,7 @@
#include "ui/widgets/InfoBoardWidget.h"
-InfoBoardWidget::InfoBoardWidget(QWidget *parent, GpgME::GpgContext *ctx, KeyList *keyList) :
+InfoBoardWidget::InfoBoardWidget(QWidget *parent, GpgFrontend::GpgContext *ctx, KeyList *keyList) :
QWidget(parent), mCtx(ctx), mKeyList(keyList), appPath(qApp->applicationDirPath()),
settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini",
QSettings::IniFormat) {
diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp
index 9c9c6763..8a334e3e 100644
--- a/src/ui/widgets/KeyList.cpp
+++ b/src/ui/widgets/KeyList.cpp
@@ -26,7 +26,7 @@
#include <utility>
-KeyList::KeyList(GpgME::GpgContext *ctx,
+KeyList::KeyList(GpgFrontend::GpgContext *ctx,
KeyListRow::KeyType selectType,
KeyListColumn::InfoType infoType,
QWidget *parent)
@@ -175,13 +175,13 @@ void KeyList::slotRefresh() {
QString usage;
QTextStream usage_steam(&usage);
- if (GpgME::GpgContext::checkIfKeyCanCert(*it))
+ if (GpgFrontend::GpgContext::checkIfKeyCanCert(*it))
usage_steam << "C";
- if (GpgME::GpgContext::checkIfKeyCanEncr(*it))
+ if (GpgFrontend::GpgContext::checkIfKeyCanEncr(*it))
usage_steam << "E";
- if (GpgME::GpgContext::checkIfKeyCanSign(*it))
+ if (GpgFrontend::GpgContext::checkIfKeyCanSign(*it))
usage_steam << "S";
- if (GpgME::GpgContext::checkIfKeyCanAuth(*it))
+ if (GpgFrontend::GpgContext::checkIfKeyCanAuth(*it))
usage_steam << "A";
auto *temp_usage = new QTableWidgetItem(usage);
@@ -390,7 +390,7 @@ void KeyList::setFilter(std::function<bool(const GpgKey &)> filter) {
void KeyList::slotDoubleClicked(const QModelIndex &index) {
if (mAction != nullptr) {
- const auto key = mCtx->getKeyById(buffered_keys[index.row()].id);
+ const auto key = mCtx->getKeyRefById(buffered_keys[index.row()].id);
mAction(key, this);
}
diff --git a/src/ui/widgets/SignersPicker.cpp b/src/ui/widgets/SignersPicker.cpp
index 00df5fdd..b48752c7 100644
--- a/src/ui/widgets/SignersPicker.cpp
+++ b/src/ui/widgets/SignersPicker.cpp
@@ -24,7 +24,7 @@
#include "ui/widgets/SignersPicker.h"
-SignersPicker::SignersPicker(GpgME::GpgContext *ctx, QWidget *parent) : mCtx(ctx), QDialog(parent) {
+SignersPicker::SignersPicker(GpgFrontend::GpgContext *ctx, QWidget *parent) : mCtx(ctx), QDialog(parent) {
auto confirmButton = new QPushButton(tr("Confirm"));
connect(confirmButton, SIGNAL(clicked(bool)), this, SLOT(accept()));
@@ -33,7 +33,7 @@ SignersPicker::SignersPicker(GpgME::GpgContext *ctx, QWidget *parent) : mCtx(ctx
KeyListColumn::NAME | KeyListColumn::EmailAddress | KeyListColumn::Usage);
mKeyList->setFilter([](const GpgKey &key) -> bool {
- if (!GpgME::GpgContext::checkIfKeyCanSign(key)) return false;
+ if (!GpgFrontend::GpgContext::checkIfKeyCanSign(key)) return false;
else return true;
});
diff --git a/src/ui/widgets/VerifyKeyDetailBox.cpp b/src/ui/widgets/VerifyKeyDetailBox.cpp
index e0f79c3e..4d88389c 100644
--- a/src/ui/widgets/VerifyKeyDetailBox.cpp
+++ b/src/ui/widgets/VerifyKeyDetailBox.cpp
@@ -24,7 +24,7 @@
#include "ui/widgets/VerifyKeyDetailBox.h"
-VerifyKeyDetailBox::VerifyKeyDetailBox(QWidget *parent, GpgME::GpgContext *ctx, KeyList *keyList,
+VerifyKeyDetailBox::VerifyKeyDetailBox(QWidget *parent, GpgFrontend::GpgContext *ctx, KeyList *keyList,
gpgme_signature_t signature) :
QGroupBox(parent), mCtx(ctx), mKeyList(keyList), fpr(signature->fpr) {
@@ -153,7 +153,7 @@ QString VerifyKeyDetailBox::beautifyFingerprint(QString fingerprint) {
QGridLayout *VerifyKeyDetailBox::createKeyInfoGrid(gpgme_signature_t &signature) {
auto grid = new QGridLayout();
- GpgKey key = mCtx->getKeyByFpr(signature->fpr);
+ GpgKey key = mCtx->getKeyRefByFpr(signature->fpr);
if(!key.good) return nullptr;
grid->addWidget(new QLabel(tr("Signer Name:")), 0, 0);