diff options
Diffstat (limited to 'lang/qt')
225 files changed, 0 insertions, 32249 deletions
diff --git a/lang/qt/Makefile.am b/lang/qt/Makefile.am deleted file mode 100644 index 9c93c101..00000000 --- a/lang/qt/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -# Makefile.am - Makefile for QGpgME. -# Copyright (C) 2016 Bundesamt für Sicherheit in der Informationstechnik -# Software engineering by Intevation GmbH -# -# This file is part of QGpgME, the Qt API binding for GpgME. -# -# QGpgME 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 2 of the License, or -# (at your option) any later version. -# -# QGpgME is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see <https://gnu.org/licenses/>. -# SPDX-License-Identifier: GPL-2.0-or-later - -if RUN_GPG_TESTS -tests = tests -else -tests = -endif - -SUBDIRS = src ${tests} doc - -EXTRA_DIST = README diff --git a/lang/qt/README b/lang/qt/README deleted file mode 100644 index ea185a81..00000000 --- a/lang/qt/README +++ /dev/null @@ -1,130 +0,0 @@ -Qt API bindings/wrapper for GPGME ---------------------------------- -Based on KF5gpgmepp QGpgME and libkleo/backends/qgpgme - -Please note that QGpgME has a different license (GPL only) -then GPGME itself. See the License section in this -document for more information. - -Overview --------- -QGpgme provides a very high level Qt API around GpgMEpp. -As such it depends on GpgMEpp additionally to GpgME. - -There are two general concepts in QGpgME. Data abstraction -through GpgMEpp's Dataprovider interface and the Job pattern. - -Data can be provided with QByteArrayDataProvider or -QIODeviceDataProvider which can be constructed from their -respective types. This means you can pass a QFile, QProcess, -QString, etc.. directly to GPGME. - -To provide a stable API / ABI and because of historic reasons -in libkleo (Where QGpgME was originally developed as an abstract -crypto backend) QGpgME only provides abstract interfaces as -public API while the actual implementation happens in the -private QGpgME prefixed classes. - -Usage ------ - -To use QGpgME first you need to obtain a Protocol class -either for CMS (S/MIME) or OpenPGP. This Protocol class -can then be used to create a Job. - -Each Job can be started asynchronously and emits a result -signal when done. The jobs are deleted automatically -with QObject::deleteLater so they can be started without -result handlers. - -The result signal provides a tuple of objects with the -appropriate result information for this job. For historic -reasons each result signal also includes an AuditLog -and an AuditLog Error. These are only useful for -S/MIME signature validation but are part of other jobs -for API stability reasons. - -Some jobs like the verification or decryption jobs have -dedicated result classes. Each result class at least -has the member function error() that can be used -to check if a job failed. Additionally errors are emitted -in the result signal. - -Jobs also provide progress signal whenever GnuPG emits -a progress status line. - -Most jobs also provide a way synchronously execute them. -Please not that synchronous use does not cause the autodeletion -to take place so you have to manually delete them. - -Async usage: - - /* Create a job */ - EncryptJob *job = openpgp()->encryptJob(/*ASCII Armor */false, /* Textmode */ false); - /* Connect something to the result signal */ - connect(job, &EncryptJob::result, this, [] (const GpgME::EncryptionResult &result, - const QByteArray &cipherText, - const QString, - const GpgME::Error) { - /* Handle the result / do something with the ciphertext */ - }); - /* Start the job */ - job->start(keys, inptr, outptr, Context::AlwaysTrust); - /* Do not delete the job as it is autodeleted. */ - -Synchronous usage: - - /* Create a job */ - KeyListJob *listjob = openpgp()->keyListJob(false, false, false); - /* Prepare result vector */ - std::vector<Key> keys; - /* Execute it synchronusly */ - KeyListResult result = listjob->exec(QStringList() << QStringLiteral("[email protected]"), - false, keys); - /* Delete the job */ - delete listjob; - /* Work with the result */ - -See the generated documentation for more info on the classes -in QGpgME. (Subdir doc) - -Examples / Tests ----------------- - -The tests in the tests subdir can be used to get a better -idea of QGpgME's usage. They also serve to test the C++ -API. Kleopatra and KMails Messagelib also make extensive -use of QGpgME and can be used as further examples. - -Hacking -------- -QGpgME comes from a KDE background. As such it does not use -GNU Coding styles but KDE Coding styles. See: -https://techbase.kde.org/Policies/Frameworks_Coding_Style - -License -------- -QGpgME 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 2 of the -License, or (at your option) any later version. - -QGpgME is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -In addition, as a special exception, the copyright holders give -permission to link the code of this program with any edition of -the Qt library by Trolltech AS, Norway (or with modified versions -of Qt that use the same license as Qt), and distribute linked -combinations including the two. You must obey the GNU General -Public License in all respects for all of the code used other than -Qt. If you modify this file, you may extend this exception to -your version of the file, but you are not obligated to do so. If -you do not wish to do so, delete this exception statement from -your version. diff --git a/lang/qt/doc/Doxyfile.in b/lang/qt/doc/Doxyfile.in deleted file mode 100644 index ccccbc4a..00000000 --- a/lang/qt/doc/Doxyfile.in +++ /dev/null @@ -1,2352 +0,0 @@ -# Doxyfile 1.8.8 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a double hash (##) is considered a comment and is placed in -# front of the TAG it is preceding. -# -# All text after a single hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists, items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (\" \"). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See https://www.gnu.org/software/libiconv -# for the list of possible encodings. -# The default value is: UTF-8. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by -# double-quotes, unless you are using Doxywizard) that should identify the -# project for which the documentation is generated. This name is used in the -# title of most generated pages and in a few other places. -# The default value is: My Project. - -PROJECT_NAME = "QGpgME" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. This -# could be handy for archiving the generated documentation or if some version -# control system is used. - -PROJECT_NUMBER = "@LIBQGPGME_LT_CURRENT@.@LIBQGPGME_LT_AGE@.@LIBQGPGME_LT_REVISION@.@BUILD_REVISION@" - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer a -# quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = "Qt API for GpgME" - -# With the PROJECT_LOGO tag one can specify an logo or icon that is included in -# the documentation. The maximum height of the logo should not exceed 55 pixels -# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo -# to the output directory. - -PROJECT_LOGO = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path -# into which the generated documentation will be written. If a relative path is -# entered, it will be relative to the location where doxygen was started. If -# left blank the current directory will be used. - -OUTPUT_DIRECTORY = "@abs_builddir@/generated" - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub- -# directories (in 2 levels) under the output directory of each output format and -# will distribute the generated files over these directories. Enabling this -# option can be useful when feeding doxygen a huge amount of source files, where -# putting all generated files in the same directory would otherwise causes -# performance problems for the file system. -# The default value is: NO. - -CREATE_SUBDIRS = NO - -# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII -# characters to appear in the names of generated files. If set to NO, non-ASCII -# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode -# U+3044. -# The default value is: NO. - -ALLOW_UNICODE_NAMES = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, -# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), -# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, -# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), -# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, -# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, -# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, -# Ukrainian and Vietnamese. -# The default value is: English. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member -# descriptions after the members that are listed in the file and class -# documentation (similar to Javadoc). Set to NO to disable this. -# The default value is: YES. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief -# description of a member or function before the detailed description -# -# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. -# The default value is: YES. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator that is -# used to form the text in various listings. Each string in this list, if found -# as the leading text of the brief description, will be stripped from the text -# and the result, after processing the whole list, is used as the annotated -# text. Otherwise, the brief description is used as-is. If left blank, the -# following values are used ($name is automatically replaced with the name of -# the entity):The $name class, The $name widget, The $name file, is, provides, -# specifies, contains, represents, a, an and the. - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# doxygen will generate a detailed section even if there is only a brief -# description. -# The default value is: NO. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. -# The default value is: NO. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path -# before files name in the file list and in the header files. If set to NO the -# shortest path that makes the file name unique will be used -# The default value is: YES. - -FULL_PATH_NAMES = NO - -# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. -# Stripping is only done if one of the specified strings matches the left-hand -# part of the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the path to -# strip. -# -# Note that you can specify absolute paths here, but also relative paths, which -# will be relative from the directory where doxygen is started. -# This tag requires that the tag FULL_PATH_NAMES is set to YES. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the -# path mentioned in the documentation of a class, which tells the reader which -# header file to include in order to use a class. If left blank only the name of -# the header file containing the class definition is used. Otherwise one should -# specify the list of include paths that are normally passed to the compiler -# using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but -# less readable) file names. This can be useful is your file systems doesn't -# support long names like on DOS, Mac, or CD-ROM. -# The default value is: NO. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the -# first line (until the first dot) of a Javadoc-style comment as the brief -# description. If set to NO, the Javadoc-style will behave just like regular Qt- -# style comments (thus requiring an explicit @brief command for a brief -# description.) -# The default value is: NO. - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first -# line (until the first dot) of a Qt-style comment as the brief description. If -# set to NO, the Qt-style will behave just like regular Qt-style comments (thus -# requiring an explicit \brief command for a brief description.) -# The default value is: NO. - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a -# multi-line C++ special comment block (i.e. a block of //! or /// comments) as -# a brief description. This used to be the default behavior. The new default is -# to treat a multi-line C++ comment block as a detailed description. Set this -# tag to YES if you prefer the old behavior instead. -# -# Note that setting this tag to YES also means that rational rose comments are -# not recognized any more. -# The default value is: NO. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the -# documentation from any documented member that it re-implements. -# The default value is: YES. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a -# new page for each member. If set to NO, the documentation of a member will be -# part of the file/class/namespace that contains it. -# The default value is: NO. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen -# uses this value to replace tabs by spaces in code fragments. -# Minimum value: 1, maximum value: 16, default value: 4. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that act as commands in -# the documentation. An alias has the form: -# name=value -# For example adding -# "sideeffect=@par Side Effects:\n" -# will allow you to put the command \sideeffect (or @sideeffect) in the -# documentation, which will result in a user-defined paragraph with heading -# "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. For -# instance, some of the names that are used will be different. The list of all -# members will be omitted, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or -# Python sources only. Doxygen will then generate output that is more tailored -# for that language. For instance, namespaces will be presented as packages, -# qualified scopes will look different, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources. Doxygen will then generate output that is tailored for Fortran. -# The default value is: NO. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for VHDL. -# The default value is: NO. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: -# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: -# Fortran. In the later case the parser tries to guess whether the code is fixed -# or free formatted code, this is the default for Fortran type files), VHDL. For -# instance to make doxygen treat .inc files as Fortran files (default is PHP), -# and .f files as C (default is Fortran), use: inc=Fortran f=C. -# -# Note For files without extension you can use no_extension as a placeholder. -# -# Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments -# according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you can -# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in -# case of backward compatibilities issues. -# The default value is: YES. - -MARKDOWN_SUPPORT = YES - -# When enabled doxygen tries to link words that correspond to documented -# classes, or namespaces to their corresponding documentation. Such a link can -# be prevented in individual cases by by putting a % sign in front of the word -# or globally by setting AUTOLINK_SUPPORT to NO. -# The default value is: YES. - -AUTOLINK_SUPPORT = YES - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should set this -# tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); -# versus func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. -# The default value is: NO. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. -# The default value is: NO. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen -# will parse them like normal C++ but will assume all classes use public instead -# of private inheritance when no explicit protection keyword is present. -# The default value is: NO. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES will make -# doxygen to replace the get and set methods by a property in the documentation. -# This will only work if the methods are indeed getting or setting a simple -# type. If this is not the case, or you want to show the methods anyway, you -# should set this option to NO. -# The default value is: YES. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. -# The default value is: NO. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES to allow class member groups of the same type -# (for instance a group of public functions) to be put as a subgroup of that -# type (e.g. under the Public Functions section). Set it to NO to prevent -# subgrouping. Alternatively, this can be done per class using the -# \nosubgrouping command. -# The default value is: YES. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions -# are shown inside the group in which they are included (e.g. using \ingroup) -# instead of on a separate page (for HTML and Man pages) or section (for LaTeX -# and RTF). -# -# Note that this feature does not work in combination with -# SEPARATE_MEMBER_PAGES. -# The default value is: NO. - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions -# with only public data fields or simple typedef fields will be shown inline in -# the documentation of the scope in which they are defined (i.e. file, -# namespace, or group documentation), provided this scope is documented. If set -# to NO, structs, classes, and unions are shown on a separate page (for HTML and -# Man pages) or section (for LaTeX and RTF). -# The default value is: NO. - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or -# enum is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically be -# useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. -# The default value is: NO. - -TYPEDEF_HIDES_STRUCT = NO - -# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This -# cache is used to resolve symbols given their name and scope. Since this can be -# an expensive process and often the same symbol appears multiple times in the -# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small -# doxygen will become slower. If the cache is too large, memory is wasted. The -# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range -# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 -# symbols. At the end of a run doxygen will report the cache usage and suggest -# the optimal cache size from a speed point of view. -# Minimum value: 0, maximum value: 9, default value: 0. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. Private -# class members and static file members will be hidden unless the -# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. -# Note: This will also disable the warnings about undocumented members that are -# normally produced when WARNINGS is set to YES. -# The default value is: NO. - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will -# be included in the documentation. -# The default value is: NO. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal -# scope will be included in the documentation. -# The default value is: NO. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file will be -# included in the documentation. -# The default value is: NO. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined -# locally in source files will be included in the documentation. If set to NO -# only classes defined in header files are included. Does not have any effect -# for Java sources. -# The default value is: YES. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local methods, -# which are defined in the implementation section but not in the interface are -# included in the documentation. If set to NO only methods in the interface are -# included. -# The default value is: NO. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base name of -# the file that contains the anonymous namespace. By default anonymous namespace -# are hidden. -# The default value is: NO. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all -# undocumented members inside documented classes or files. If set to NO these -# members will be included in the various overviews, but no documentation -# section is generated. This option has no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. If set -# to NO these classes will be included in the various overviews. This option has -# no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO these declarations will be -# included in the documentation. -# The default value is: NO. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any -# documentation blocks found inside the body of a function. If set to NO these -# blocks will be appended to the function's detailed documentation block. -# The default value is: NO. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation that is typed after a -# \internal command is included. If the tag is set to NO then the documentation -# will be excluded. Set it to YES to include the internal documentation. -# The default value is: NO. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. -# The default value is: system dependent. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with -# their full class and namespace scopes in the documentation. If set to YES the -# scope will be hidden. -# The default value is: NO. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of -# the files that are included by a file in the documentation of that file. -# The default value is: YES. - -SHOW_INCLUDE_FILES = YES - -# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each -# grouped member an include statement to the documentation, telling the reader -# which file to include in order to use the member. -# The default value is: NO. - -SHOW_GROUPED_MEMB_INC = NO - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include -# files with double quotes in the documentation rather than with sharp brackets. -# The default value is: NO. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the -# documentation for inline members. -# The default value is: YES. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the -# (detailed) documentation of file and class members alphabetically by member -# name. If set to NO the members will appear in declaration order. -# The default value is: YES. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief -# descriptions of file, namespace and class members alphabetically by member -# name. If set to NO the members will appear in declaration order. Note that -# this will also influence the order of the classes in the class list. -# The default value is: NO. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the -# (brief and detailed) documentation of class members so that constructors and -# destructors are listed first. If set to NO the constructors will appear in the -# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. -# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief -# member documentation. -# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting -# detailed member documentation. -# The default value is: NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy -# of group names into alphabetical order. If set to NO the group names will -# appear in their defined order. -# The default value is: NO. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by -# fully-qualified names, including namespaces. If set to NO, the class list will -# be sorted only by class name, not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the alphabetical -# list. -# The default value is: NO. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper -# type resolution of all parameters of a function it will reject a match between -# the prototype and the implementation of a member function even if there is -# only one candidate or it is obvious which candidate to choose by doing a -# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still -# accept a match between prototype and implementation in such cases. -# The default value is: NO. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the -# todo list. This list is created by putting \todo commands in the -# documentation. -# The default value is: YES. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the -# test list. This list is created by putting \test commands in the -# documentation. -# The default value is: YES. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug -# list. This list is created by putting \bug commands in the documentation. -# The default value is: YES. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO) -# the deprecated list. This list is created by putting \deprecated commands in -# the documentation. -# The default value is: YES. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional documentation -# sections, marked by \if <section_label> ... \endif and \cond <section_label> -# ... \endcond blocks. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the -# initial value of a variable or macro / define can have for it to appear in the -# documentation. If the initializer consists of more lines than specified here -# it will be hidden. Use a value of 0 to hide initializers completely. The -# appearance of the value of individual variables and macros / defines can be -# controlled using \showinitializer or \hideinitializer command in the -# documentation regardless of this setting. -# Minimum value: 0, maximum value: 10000, default value: 30. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at -# the bottom of the documentation of classes and structs. If set to YES the list -# will mention the files that were used to generate the documentation. -# The default value is: YES. - -SHOW_USED_FILES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This -# will remove the Files entry from the Quick Index and from the Folder Tree View -# (if specified). -# The default value is: YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces -# page. This will remove the Namespaces entry from the Quick Index and from the -# Folder Tree View (if specified). -# The default value is: YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command command input-file, where command is the value of the -# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided -# by doxygen. Whatever the program writes to standard output is used as the file -# version. For an example see the documentation. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. You can -# optionally specify a file name after the option, if omitted DoxygenLayout.xml -# will be used as the name of the layout file. -# -# Note that if you run doxygen from a directory containing a file called -# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE -# tag is left empty. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files containing -# the reference definitions. This must be a list of .bib files. The .bib -# extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. -# For LaTeX the style of the bibliography can be controlled using -# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the -# search path. See also \cite for info how to create references. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# Configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated to -# standard output by doxygen. If QUIET is set to YES this implies that the -# messages are off. -# The default value is: NO. - -QUIET = YES - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES -# this implies that the warnings are on. -# -# Tip: Turn warnings on while writing the documentation. -# The default value is: YES. - -WARNINGS = YES - -# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate -# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag -# will automatically be disabled. -# The default value is: YES. - -WARN_IF_UNDOCUMENTED = NO - -# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some parameters -# in a documented function, or documenting parameters that don't exist or using -# markup commands wrongly. -# The default value is: YES. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that -# are documented, but have no documentation for their parameters or return -# value. If set to NO doxygen will only warn about wrong or incomplete parameter -# documentation, but not about the absence of documentation. -# The default value is: NO. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that doxygen -# can produce. The string should contain the $file, $line, and $text tags, which -# will be replaced by the file and line number from which the warning originated -# and the warning text. Optionally the format may contain $version, which will -# be replaced by the version of the file (if it could be obtained via -# FILE_VERSION_FILTER) -# The default value is: $file:$line: $text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning and error -# messages should be written. If left blank the output is written to standard -# error (stderr). - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# Configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag is used to specify the files and/or directories that contain -# documented source files. You may enter file names like myfile.cpp or -# directories like /usr/src/myproject. Separate the files or directories with -# spaces. -# Note: If this tag is empty the current directory is searched. - -INPUT = "@top_srcdir@/lang/qt/src" - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses -# libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: https://www.gnu.org/software/libiconv) for the list of -# possible encodings. -# The default value is: UTF-8. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank the -# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii, -# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, -# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, -# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, -# *.qsf, *.as and *.js. - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to specify whether or not subdirectories should -# be searched for input files as well. -# The default value is: NO. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. -# The default value is: NO. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories use the pattern */test/* - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or directories -# that contain example code fragments that are included (see the \include -# command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank all -# files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude commands -# irrespective of the value of the RECURSIVE tag. -# The default value is: NO. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or directories -# that contain images that are to be included in the documentation (see the -# \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command: -# -# <filter> <input-file> -# -# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the -# name of an input file. Doxygen will then use the output that the filter -# program writes to standard output. If FILTER_PATTERNS is specified, this tag -# will be ignored. -# -# Note that the filter must not add or remove lines; it is applied before the -# code is scanned, but not when the output code is generated. If lines are added -# or removed, the anchors will not be placed correctly. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: pattern=filter -# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how -# filters are used. If the FILTER_PATTERNS tag is empty or if none of the -# patterns match the file name, INPUT_FILTER is applied. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER ) will also be used to filter the input files that are used for -# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). -# The default value is: NO. - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and -# it is also possible to disable source filtering for a specific pattern using -# *.ext= (so without naming a filter). -# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. - -FILTER_SOURCE_PATTERNS = - -# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that -# is part of the input, its contents will be placed on the main page -# (index.html). This can be useful if you have a project on for instance GitHub -# and want to reuse the introduction page also for the doxygen output. - -USE_MDFILE_AS_MAINPAGE = - -#--------------------------------------------------------------------------- -# Configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will be -# generated. Documented entities will be cross-referenced with these sources. -# -# Note: To get rid of all source code in the generated output, make sure that -# also VERBATIM_HEADERS is set to NO. -# The default value is: NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body of functions, -# classes and enums directly into the documentation. -# The default value is: NO. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any -# special comment blocks from generated source code fragments. Normal C, C++ and -# Fortran comments will always remain visible. -# The default value is: YES. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. -# The default value is: NO. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES then for each documented function -# all documented entities called/used by that function will be listed. -# The default value is: NO. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set -# to YES, then the hyperlinks from functions in REFERENCES_RELATION and -# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will -# link to the documentation. -# The default value is: YES. - -REFERENCES_LINK_SOURCE = YES - -# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the -# source code will show a tooltip with additional information such as prototype, -# brief description and links to the definition and documentation. Since this -# will make the HTML file larger and loading of large files a bit slower, you -# can opt to disable this feature. -# The default value is: YES. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -SOURCE_TOOLTIPS = YES - -# If the USE_HTAGS tag is set to YES then the references to source code will -# point to the HTML generated by the htags(1) tool instead of doxygen built-in -# source browser. The htags tool is part of GNU's global source tagging system -# (see https://www.gnu.org/software/global/global.html). You will need version -# 4.8.6 or higher. -# -# To use it do the following: -# - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file -# - Make sure the INPUT points to the root of the source tree -# - Run doxygen as normal -# -# Doxygen will invoke htags (and that will in turn invoke gtags), so these -# tools must be available from the command line (i.e. in the search path). -# -# The result: instead of the source browser generated by doxygen, the links to -# source code will now point to the output of htags. -# The default value is: NO. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a -# verbatim copy of the header file for each class for which an include is -# specified. Set to NO to disable this. -# See also: Section \class. -# The default value is: YES. - -VERBATIM_HEADERS = YES - -# If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the -# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the -# cost of reduced performance. This can be particularly helpful with template -# rich C++ code for which doxygen's built-in parser lacks the necessary type -# information. -# Note: The availability of this option depends on whether or not doxygen was -# compiled with the --with-libclang option. -# The default value is: NO. - -CLANG_ASSISTED_PARSING = NO - -# If clang assisted parsing is enabled you can provide the compiler with command -# line options that you would normally use when invoking the compiler. Note that -# the include paths will already be set by doxygen for the files and directories -# specified with INPUT and INCLUDE_PATH. -# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. - -CLANG_OPTIONS = - -#--------------------------------------------------------------------------- -# Configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all -# compounds will be generated. Enable this if the project contains a lot of -# classes, structs, unions or interfaces. -# The default value is: YES. - -ALPHABETICAL_INDEX = YES - -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all classes will -# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag -# can be used to specify a prefix (or a list of prefixes) that should be ignored -# while generating the index headers. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output -# The default value is: YES. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. -# The default directory is: html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each -# generated HTML page (for example: .htm, .php, .asp). -# The default value is: .html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a user-defined HTML header file for -# each generated HTML page. If the tag is left blank doxygen will generate a -# standard header. -# -# To get valid HTML the header file that includes any scripts and style sheets -# that doxygen needs, which is dependent on the configuration options used (e.g. -# the setting GENERATE_TREEVIEW). It is highly recommended to start with a -# default header using -# doxygen -w html new_header.html new_footer.html new_stylesheet.css -# YourConfigFile -# and then modify the file new_header.html. See also section "Doxygen usage" -# for information on how to generate the default header that doxygen normally -# uses. -# Note: The header is subject to change so you typically have to regenerate the -# default header when upgrading to a newer version of doxygen. For a description -# of the possible markers and block names see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each -# generated HTML page. If the tag is left blank doxygen will generate a standard -# footer. See HTML_HEADER for more information on how to generate a default -# footer and what special commands can be used inside the footer. See also -# section "Doxygen usage" for information on how to generate the default footer -# that doxygen normally uses. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style -# sheet that is used by each HTML page. It can be used to fine-tune the look of -# the HTML output. If left blank doxygen will generate a default style sheet. -# See also section "Doxygen usage" for information on how to generate the style -# sheet that doxygen normally uses. -# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as -# it is more robust and this tag (HTML_STYLESHEET) will in the future become -# obsolete. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined -# cascading style sheets that are included after the standard style sheets -# created by doxygen. Using this option one can overrule certain style aspects. -# This is preferred over using HTML_STYLESHEET since it does not replace the -# standard style sheet and is therefore more robust against future updates. -# Doxygen will copy the style sheet files to the output directory. -# Note: The order of the extra stylesheet files is of importance (e.g. the last -# stylesheet in the list overrules the setting of the previous ones in the -# list). For an example see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_STYLESHEET = - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that the -# files will be copied as-is; there are no commands or markers available. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen -# will adjust the colors in the stylesheet and background images according to -# this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value -# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 -# purple, and 360 is red again. -# Minimum value: 0, maximum value: 359, default value: 220. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors -# in the HTML output. For a value of 0 the output will use grayscales only. A -# value of 255 will produce the most vivid colors. -# Minimum value: 0, maximum value: 255, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the -# luminance component of the colors in the HTML output. Values below 100 -# gradually make the output lighter, whereas values above 100 make the output -# darker. The value divided by 100 is the actual gamma applied, so 80 represents -# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not -# change the gamma. -# Minimum value: 40, maximum value: 240, default value: 80. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting this -# to NO can help when comparing the output of multiple runs. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_TIMESTAMP = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_DYNAMIC_SECTIONS = NO - -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries -# shown in the various tree structured indices initially; the user can expand -# and collapse entries dynamically later on. Doxygen will expand the tree to -# such a level that at most the specified number of entries are visible (unless -# a fully collapsed tree already exceeds this amount). So setting the number of -# entries 1 will produce a full collapsed tree by default. 0 is a special value -# representing an infinite number of entries and will result in a full expanded -# tree by default. -# Minimum value: 0, maximum value: 9999, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_INDEX_NUM_ENTRIES = 100 - -# If the GENERATE_DOCSET tag is set to YES, additional index files will be -# generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_DOCSET = NO - -# This tag determines the name of the docset feed. A documentation feed provides -# an umbrella under which multiple documentation sets from a single provider -# (such as a company or product suite) can be grouped. -# The default value is: Doxygen generated docs. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# This tag specifies a string that should uniquely identify the documentation -# set bundle. This should be a reverse domain-name style string, e.g. -# com.mycompany.MyDocSet. Doxygen will append .docset to the name. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. -# The default value is: org.doxygen.Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. -# The default value is: Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three -# additional HTML index files: index.hhp, index.hhc, and index.hhk. The -# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. -# -# The HTML Help Workshop contains a compiler that can convert all HTML output -# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML -# files are now used as the Windows 98 help format, and will replace the old -# Windows help format (.hlp) on all Windows platforms in the future. Compressed -# HTML files also contain an index, a table of contents, and you can search for -# words in the documentation. The HTML workshop also contains a viewer for -# compressed HTML files. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_HTMLHELP = NO - -# The CHM_FILE tag can be used to specify the file name of the resulting .chm -# file. You can add a path in front of the file if the result should not be -# written to the html output directory. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_FILE = - -# The HHC_LOCATION tag can be used to specify the location (absolute path -# including file name) of the HTML help compiler ( hhc.exe). If non-empty -# doxygen will try to run the HTML help compiler on the generated index.hhp. -# The file has to be specified with full path. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -HHC_LOCATION = - -# The GENERATE_CHI flag controls if a separate .chi index file is generated ( -# YES) or that it should be included in the master .chm file ( NO). -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -GENERATE_CHI = NO - -# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc) -# and project file content. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_INDEX_ENCODING = - -# The BINARY_TOC flag controls whether a binary table of contents is generated ( -# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it -# enables the Previous and Next buttons. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members to -# the table of contents of the HTML help documentation and to the tree view. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that -# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help -# (.qch) of the generated HTML documentation. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify -# the file name of the resulting .qch file. The path specified is relative to -# the HTML output folder. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help -# Project output. For more information please see Qt Help Project / Namespace -# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt -# Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- -# folders). -# The default value is: doc. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_VIRTUAL_FOLDER = doc - -# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom -# filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_SECT_FILTER_ATTRS = - -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be -# generated, together with the HTML files, they form an Eclipse help plugin. To -# install this plugin and make it available under the help contents menu in -# Eclipse, the contents of the directory containing the HTML and XML files needs -# to be copied into the plugins directory of eclipse. The name of the directory -# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. -# After copying Eclipse needs to be restarted before the help appears. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the Eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have this -# name. Each documentation set should have its own identifier. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# If you want full control over the layout of the generated HTML pages it might -# be necessary to disable the index and replace it with your own. The -# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top -# of each HTML page. A value of NO enables the index and the value YES disables -# it. Since the tabs in the index contain the same information as the navigation -# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. If the tag -# value is set to YES, a side panel will be generated containing a tree-like -# index structure (just like the one that is generated for HTML Help). For this -# to work a browser that supports JavaScript, DHTML, CSS and frames is required -# (i.e. any modern browser). Windows users are probably better off using the -# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can -# further fine-tune the look of the index. As an example, the default style -# sheet generated by doxygen has an example that shows how to put an image at -# the root of the tree instead of the PROJECT_NAME. Since the tree basically has -# the same information as the tab index, you could consider setting -# DISABLE_INDEX to YES when enabling this option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_TREEVIEW = NO - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that -# doxygen will group on one line in the generated HTML documentation. -# -# Note that a value of 0 will completely suppress the enum values from appearing -# in the overview section. -# Minimum value: 0, maximum value: 20, default value: 4. -# This tag requires that the tag GENERATE_HTML is set to YES. - -ENUM_VALUES_PER_LINE = 4 - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used -# to set the initial width (in pixels) of the frame in which the tree is shown. -# Minimum value: 0, maximum value: 1500, default value: 250. -# This tag requires that the tag GENERATE_HTML is set to YES. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to -# external symbols imported via tag files in a separate window. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of LaTeX formulas included as images in -# the HTML documentation. When you change the font size after a successful -# doxygen run you need to manually remove any form_*.png images from the HTML -# output directory to force them to be regenerated. -# Minimum value: 8, maximum value: 50, default value: 10. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are not -# supported properly for IE 6.0, but are supported on all modern browsers. -# -# Note that when changing this option you need to delete any form_*.png files in -# the HTML output directory before the changes have effect. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering -# instead of using prerendered bitmaps. Use this if you do not have LaTeX -# installed or if you want to formulas look prettier in the HTML output. When -# enabled you may also need to install MathJax separately and configure the path -# to it using the MATHJAX_RELPATH option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -USE_MATHJAX = NO - -# When MathJax is enabled you can set the default output format to be used for -# the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. -# Possible values are: HTML-CSS (which is slower, but has the best -# compatibility), NativeMML (i.e. MathML) and SVG. -# The default value is: HTML-CSS. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_FORMAT = HTML-CSS - -# When MathJax is enabled you need to specify the location relative to the HTML -# output directory using the MATHJAX_RELPATH option. The destination directory -# should contain the MathJax.js script. For instance, if the mathjax directory -# is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax -# Content Delivery Network so you can quickly see the result without installing -# MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest - -# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax -# extension names that should be enabled during MathJax rendering. For example -# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_EXTENSIONS = - -# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces -# of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an -# example see the documentation. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_CODEFILE = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box for -# the HTML output. The underlying search engine uses javascript and DHTML and -# should work on any modern browser. Note that when using HTML help -# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) -# there is already a search function so this one should typically be disabled. -# For large projects the javascript based search engine can be slow, then -# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to -# search using the keyboard; to jump to the search box use <access key> + S -# (what the <access key> is depends on the OS and browser, but it is typically -# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down -# key> to jump into the search results window, the results can be navigated -# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel -# the search. The filter options can be selected when the cursor is inside the -# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys> -# to select a filter and <Enter> or <escape> to activate or cancel the filter -# option. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a web server instead of a web client using Javascript. There -# are two flavors of web server based searching depending on the EXTERNAL_SEARCH -# setting. When disabled, doxygen will generate a PHP script for searching and -# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing -# and searching needs to be provided by external tools. See the section -# "External Indexing and Searching" for details. -# The default value is: NO. -# This tag requires that the tag SEARCHENGINE is set to YES. - -SERVER_BASED_SEARCH = NO - -# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP -# script for searching. Instead the search results are written to an XML file -# which needs to be processed by an external indexer. Doxygen will invoke an -# external search engine pointed to by the SEARCHENGINE_URL option to obtain the -# search results. -# -# Doxygen ships with an example indexer ( doxyindexer) and search engine -# (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). -# -# See the section "External Indexing and Searching" for details. -# The default value is: NO. -# This tag requires that the tag SEARCHENGINE is set to YES. - -EXTERNAL_SEARCH = NO - -# The SEARCHENGINE_URL should point to a search engine hosted by a web server -# which will return the search results when EXTERNAL_SEARCH is enabled. -# -# Doxygen ships with an example indexer ( doxyindexer) and search engine -# (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). See the section "External Indexing and -# Searching" for details. -# This tag requires that the tag SEARCHENGINE is set to YES. - -SEARCHENGINE_URL = - -# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed -# search data is written to a file for indexing by an external tool. With the -# SEARCHDATA_FILE tag the name of this file can be specified. -# The default file is: searchdata.xml. -# This tag requires that the tag SEARCHENGINE is set to YES. - -SEARCHDATA_FILE = searchdata.xml - -# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the -# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is -# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple -# projects and redirect the results back to the right project. -# This tag requires that the tag SEARCHENGINE is set to YES. - -EXTERNAL_SEARCH_ID = - -# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen -# projects other than the one defined by this configuration file, but that are -# all added to the same external search index. Each project needs to have a -# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of -# to a relative location where the documentation can be found. The format is: -# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ... -# This tag requires that the tag SEARCHENGINE is set to YES. - -EXTRA_SEARCH_MAPPINGS = - -#--------------------------------------------------------------------------- -# Configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES doxygen will generate LaTeX output. -# The default value is: YES. - -GENERATE_LATEX = YES - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. -# The default directory is: latex. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. -# -# Note that when enabling USE_PDFLATEX this option is only used for generating -# bitmaps for formulas in the HTML output, but not in the Makefile that is -# written to the output directory. -# The default file is: latex. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate -# index for LaTeX. -# The default file is: makeindex. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES doxygen generates more compact LaTeX -# documents. This may be useful for small projects and may help to save some -# trees in general. -# The default value is: NO. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used by the -# printer. -# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x -# 14 inches) and executive (7.25 x 10.5 inches). -# The default value is: a4. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -PAPER_TYPE = a4 - -# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names -# that should be included in the LaTeX output. To get the times font for -# instance you can specify -# EXTRA_PACKAGES=times -# If left blank no extra packages will be included. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the -# generated LaTeX document. The header should contain everything until the first -# chapter. If it is left blank doxygen will generate a standard header. See -# section "Doxygen usage" for information on how to let doxygen write the -# default header to a separate file. -# -# Note: Only use a user-defined header if you know what you are doing! The -# following commands have a special meaning inside the header: $title, -# $datetime, $date, $doxygenversion, $projectname, $projectnumber, -# $projectbrief, $projectlogo. Doxygen will replace $title with the empty string, -# for the replacement values of the other commands the user is referred to -# HTML_HEADER. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_HEADER = - -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the -# generated LaTeX document. The footer should contain everything after the last -# chapter. If it is left blank doxygen will generate a standard footer. See -# LATEX_HEADER for more information on how to generate a default footer and what -# special commands can be used inside the footer. -# -# Note: Only use a user-defined footer if you know what you are doing! -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_FOOTER = - -# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the LATEX_OUTPUT output -# directory. Note that the files will be copied as-is; there are no commands or -# markers available. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_EXTRA_FILES = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is -# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will -# contain links (just like the HTML output) instead of page references. This -# makes the output suitable for online browsing using a PDF viewer. -# The default value is: YES. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate -# the PDF file directly from the LaTeX files. Set this option to YES to get a -# higher quality PDF documentation. -# The default value is: YES. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode -# command to the generated LaTeX files. This will instruct LaTeX to keep running -# if errors occur, instead of asking the user for help. This option is also used -# when generating formulas in HTML. -# The default value is: NO. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_BATCHMODE = NO - -# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the -# index chapters (such as File Index, Compound Index, etc.) in the output. -# The default value is: NO. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_HIDE_INDICES = NO - -# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source -# code with syntax highlighting in the LaTeX output. -# -# Note that which sources are shown also depends on other settings such as -# SOURCE_BROWSER. -# The default value is: NO. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_SOURCE_CODE = NO - -# The LATEX_BIB_STYLE tag can be used to specify the style to use for the -# bibliography, e.g. plainnat, or ieeetr. See -# http://en.wikipedia.org/wiki/BibTeX and \cite for more info. -# The default value is: plain. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_BIB_STYLE = plain - -#--------------------------------------------------------------------------- -# Configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES doxygen will generate RTF output. The -# RTF output is optimized for Word 97 and may not look too pretty with other RTF -# readers/editors. -# The default value is: NO. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. -# The default directory is: rtf. -# This tag requires that the tag GENERATE_RTF is set to YES. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES doxygen generates more compact RTF -# documents. This may be useful for small projects and may help to save some -# trees in general. -# The default value is: NO. -# This tag requires that the tag GENERATE_RTF is set to YES. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will -# contain hyperlink fields. The RTF file will contain links (just like the HTML -# output) instead of page references. This makes the output suitable for online -# browsing using Word or some other Word compatible readers that support those -# fields. -# -# Note: WordPad (write) and others do not support links. -# The default value is: NO. -# This tag requires that the tag GENERATE_RTF is set to YES. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's config -# file, i.e. a series of assignments. You only have to provide replacements, -# missing definitions are set to their default value. -# -# See also section "Doxygen usage" for information on how to generate the -# default style sheet that doxygen normally uses. -# This tag requires that the tag GENERATE_RTF is set to YES. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an RTF document. Syntax is -# similar to doxygen's config file. A template extensions file can be generated -# using doxygen -e rtf extensionFile. -# This tag requires that the tag GENERATE_RTF is set to YES. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# Configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES doxygen will generate man pages for -# classes and files. -# The default value is: NO. - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. A directory man3 will be created inside the directory specified by -# MAN_OUTPUT. -# The default directory is: man. -# This tag requires that the tag GENERATE_MAN is set to YES. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to the generated -# man pages. In case the manual section does not start with a number, the number -# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is -# optional. -# The default value is: .3. -# This tag requires that the tag GENERATE_MAN is set to YES. - -MAN_EXTENSION = .3 - -# The MAN_SUBDIR tag determines the name of the directory created within -# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by -# MAN_EXTENSION with the initial . removed. -# This tag requires that the tag GENERATE_MAN is set to YES. - -MAN_SUBDIR = - -# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it -# will generate one additional man file for each entity documented in the real -# man page(s). These additional files only source the real man page, but without -# them the man command would be unable to find the correct page. -# The default value is: NO. -# This tag requires that the tag GENERATE_MAN is set to YES. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# Configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES doxygen will generate an XML file that -# captures the structure of the code including all documentation. -# The default value is: NO. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. -# The default directory is: xml. -# This tag requires that the tag GENERATE_XML is set to YES. - -XML_OUTPUT = xml - -# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program -# listings (including syntax highlighting and cross-referencing information) to -# the XML output. Note that enabling this will significantly increase the size -# of the XML output. -# The default value is: YES. -# This tag requires that the tag GENERATE_XML is set to YES. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# Configuration options related to the DOCBOOK output -#--------------------------------------------------------------------------- - -# If the GENERATE_DOCBOOK tag is set to YES doxygen will generate Docbook files -# that can be used to generate PDF. -# The default value is: NO. - -GENERATE_DOCBOOK = NO - -# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in -# front of it. -# The default directory is: docbook. -# This tag requires that the tag GENERATE_DOCBOOK is set to YES. - -DOCBOOK_OUTPUT = docbook - -# If the DOCBOOK_PROGRAMLISTING tag is set to YES doxygen will include the -# program listings (including syntax highlighting and cross-referencing -# information) to the DOCBOOK output. Note that enabling this will significantly -# increase the size of the DOCBOOK output. -# The default value is: NO. -# This tag requires that the tag GENERATE_DOCBOOK is set to YES. - -DOCBOOK_PROGRAMLISTING = NO - -#--------------------------------------------------------------------------- -# Configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES doxygen will generate an AutoGen -# Definitions (see http://autogen.sf.net) file that captures the structure of -# the code including all documentation. Note that this feature is still -# experimental and incomplete at the moment. -# The default value is: NO. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# Configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES doxygen will generate a Perl module -# file that captures the structure of the code including all documentation. -# -# Note that this feature is still experimental and incomplete at the moment. -# The default value is: NO. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES doxygen will generate the necessary -# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI -# output from the Perl module output. -# The default value is: NO. -# This tag requires that the tag GENERATE_PERLMOD is set to YES. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be nicely -# formatted so it can be parsed by a human reader. This is useful if you want to -# understand what is going on. On the other hand, if this tag is set to NO the -# size of the Perl module output will be much smaller and Perl will parse it -# just the same. -# The default value is: YES. -# This tag requires that the tag GENERATE_PERLMOD is set to YES. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file are -# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful -# so different doxyrules.make files included by the same Makefile don't -# overwrite each other's variables. -# This tag requires that the tag GENERATE_PERLMOD is set to YES. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES doxygen will evaluate all -# C-preprocessor directives found in the sources and include files. -# The default value is: YES. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES doxygen will expand all macro names -# in the source code. If set to NO only conditional compilation will be -# performed. Macro expansion can be done in a controlled way by setting -# EXPAND_ONLY_PREDEF to YES. -# The default value is: NO. -# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then -# the macro expansion is limited to the macros specified with the PREDEFINED and -# EXPAND_AS_DEFINED tags. -# The default value is: NO. -# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES the includes files in the -# INCLUDE_PATH will be searched if a #include is found. -# The default value is: YES. -# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by the -# preprocessor. -# This tag requires that the tag SEARCH_INCLUDES is set to YES. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will be -# used. -# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that are -# defined before the preprocessor is started (similar to the -D option of e.g. -# gcc). The argument of the tag is a list of macros of the form: name or -# name=definition (no spaces). If the definition and the "=" are omitted, "=1" -# is assumed. To prevent a macro definition from being undefined via #undef or -# recursively expanded use the := operator instead of the = operator. -# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this -# tag can be used to specify a list of macro names that should be expanded. The -# macro definition that is found in the sources will be used. Use the PREDEFINED -# tag if you want to use a different macro definition that overrules the -# definition found in the source code. -# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will -# remove all references to function-like macros that are alone on a line, have -# an all uppercase name, and do not end with a semicolon. Such function macros -# are typically used for boiler-plate code, and will confuse the parser if not -# removed. -# The default value is: YES. -# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration options related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES tag can be used to specify one or more tag files. For each tag -# file the location of the external documentation should be added. The format of -# a tag file without this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where loc1 and loc2 can be relative or absolute paths or URLs. See the -# section "Linking to external documentation" for more information about the use -# of tag files. -# Note: Each tag file must have a unique name (where the name does NOT include -# the path). If a tag file is not located in the directory in which doxygen is -# run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create a -# tag file that is based on the input files it reads. See section "Linking to -# external documentation" for more information about the usage of tag files. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external class will be listed in the -# class index. If set to NO only the inherited external classes will be listed. -# The default value is: NO. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed in -# the modules index. If set to NO, only the current project's groups will be -# listed. -# The default value is: YES. - -EXTERNAL_GROUPS = YES - -# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed in -# the related pages index. If set to NO, only the current project's pages will -# be listed. -# The default value is: YES. - -EXTERNAL_PAGES = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of 'which perl'). -# The default file (with absolute path) is: /usr/bin/perl. - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES doxygen will generate a class diagram -# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to -# NO turns the diagrams off. Note that this option also works with HAVE_DOT -# disabled, but it is recommended to install and use dot, since it yields more -# powerful graphs. -# The default value is: YES. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see: -# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# You can include diagrams made with dia in doxygen documentation. Doxygen will -# then run dia to produce the diagram and insert it in the documentation. The -# DIA_PATH tag allows you to specify the directory where the dia binary resides. -# If left empty dia is assumed to be found in the default search path. - -DIA_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide inheritance -# and usage relations if the target is undocumented or is not a class. -# The default value is: YES. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz (see: -# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent -# Bell Labs. The other options in this section have no effect if this option is -# set to NO -# The default value is: YES. - -HAVE_DOT = @HAVE_DOT@ - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed -# to run in parallel. When set to 0 doxygen will base this on the number of -# processors available in the system. You can set it explicitly to a value -# larger than 0 to get control over the balance between CPU load and processing -# speed. -# Minimum value: 0, maximum value: 32, default value: 0. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_NUM_THREADS = 0 - -# When you want a differently looking font in the dot files that doxygen -# generates you can specify the font name using DOT_FONTNAME. You need to make -# sure dot is able to find the font, which can be done by putting it in a -# standard location or by setting the DOTFONTPATH environment variable or by -# setting DOT_FONTPATH to the directory containing the font. -# The default value is: Helvetica. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_FONTNAME = Helvetica - -# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of -# dot graphs. -# Minimum value: 4, maximum value: 24, default value: 10. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the default font as specified with -# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set -# the path where dot can find it using this tag. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_FONTPATH = - -# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for -# each documented class showing the direct and indirect inheritance relations. -# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a -# graph for each documented class showing the direct and indirect implementation -# dependencies (inheritance, containment, and class references variables) of the -# class with other documented classes. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for -# groups, showing the direct groups dependencies. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -UML_LOOK = NO - -# If the UML_LOOK tag is enabled, the fields and methods are shown inside the -# class node. If there are many fields or methods and many nodes the graph may -# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the -# number of items for each type to make the size more manageable. Set this to 0 -# for no limit. Note that the threshold may be exceeded by 50% before the limit -# is enforced. So when you set the threshold to 10, up to 15 fields may appear, -# but if the number exceeds 15, the total amount of fields shown is limited to -# 10. -# Minimum value: 0, maximum value: 100, default value: 10. -# This tag requires that the tag HAVE_DOT is set to YES. - -UML_LIMIT_NUM_FIELDS = 10 - -# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and -# collaboration graphs will show the relations between templates and their -# instances. -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -TEMPLATE_RELATIONS = NO - -# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to -# YES then doxygen will generate a graph for each documented file showing the -# direct and indirect include dependencies of the file with other documented -# files. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -INCLUDE_GRAPH = YES - -# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are -# set to YES then doxygen will generate a graph for each documented file showing -# the direct and indirect include dependencies of the file with other documented -# files. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH tag is set to YES then doxygen will generate a call -# dependency graph for every global function or class method. -# -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller -# dependency graph for every global function or class method. -# -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical -# hierarchy of all classes instead of a textual one. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the -# dependencies a directory has on other directories in a graphical way. The -# dependency relations are determined by the #include relations between the -# files in the directories. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. -# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order -# to make the SVG files visible in IE 9+ (other browsers do not have this -# requirement). -# Possible values are: png, png:cairo, png:cairo:cairo, png:cairo:gd, png:gd, -# png:gd:gd, jpg, jpg:cairo, jpg:cairo:gd, jpg:gd, jpg:gd:gd, gif, gif:cairo, -# gif:cairo:gd, gif:gd, gif:gd:gd and svg. -# The default value is: png. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_IMAGE_FORMAT = png - -# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to -# enable generation of interactive SVG images that allow zooming and panning. -# -# Note that this requires a modern browser other than Internet Explorer. Tested -# and working are Firefox, Chrome, Safari, and Opera. -# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make -# the SVG files visible. Older versions of IE do not have SVG support. -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -INTERACTIVE_SVG = NO - -# The DOT_PATH tag can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the \dotfile -# command). -# This tag requires that the tag HAVE_DOT is set to YES. - -DOTFILE_DIRS = - -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the \mscfile -# command). - -MSCFILE_DIRS = - -# The DIAFILE_DIRS tag can be used to specify one or more directories that -# contain dia files that are included in the documentation (see the \diafile -# command). - -DIAFILE_DIRS = - -# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the -# path where java can find the plantuml.jar file. If left blank, it is assumed -# PlantUML is not used or called during a preprocessing step. Doxygen will -# generate a warning when it encounters a \startuml command in this case and -# will not generate output for the diagram. -# This tag requires that the tag HAVE_DOT is set to YES. - -PLANTUML_JAR_PATH = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes -# that will be shown in the graph. If the number of nodes in a graph becomes -# larger than this value, doxygen will truncate the graph, which is visualized -# by representing a node as a red box. Note that doxygen if the number of direct -# children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that -# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. -# Minimum value: 0, maximum value: 10000, default value: 50. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs -# generated by dot. A depth value of 3 means that only nodes reachable from the -# root by following a path via at most 3 edges will be shown. Nodes that lay -# further from the root node will be omitted. Note that setting this option to 1 -# or 2 may greatly reduce the computation time needed for large code bases. Also -# note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. -# Minimum value: 0, maximum value: 1000, default value: 0. -# This tag requires that the tag HAVE_DOT is set to YES. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not seem -# to support this out of the box. -# -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) support -# this, this feature is disabled by default. -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page -# explaining the meaning of the various boxes and arrows in the dot generated -# graphs. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES doxygen will remove the intermediate dot -# files that are used to generate the various graphs. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_CLEANUP = YES diff --git a/lang/qt/doc/Makefile.am b/lang/qt/doc/Makefile.am deleted file mode 100644 index 73267278..00000000 --- a/lang/qt/doc/Makefile.am +++ /dev/null @@ -1,33 +0,0 @@ -# Makefile.am - Makefile for QGpgME docs. -# Copyright (C) 2016 Bundesamt für Sicherheit in der Informationstechnik -# Software engineering by Intevation GmbH -# -# This file is part of QGpgME. -# -# QGpgME 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 2 of the License, or -# (at your option) any later version. -# -# QGpgME is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see <https://gnu.org/licenses/>. -# SPDX-License-Identifier: GPL-2.0-or-later - -## Process this file with automake to produce Makefile.in - -if HAVE_DOXYGEN -doxyfile.stamp: - $(DOXYGEN) Doxyfile - touch doxyfile.stamp - -CLEANFILES = doxyfile.stamp - -all-local: doxyfile.stamp -clean-local: - rm -rf $(abs_builddir)/generated -endif diff --git a/lang/qt/src/Makefile.am b/lang/qt/src/Makefile.am deleted file mode 100644 index 9b904e2d..00000000 --- a/lang/qt/src/Makefile.am +++ /dev/null @@ -1,509 +0,0 @@ -# Makefile.am for QGpgME. -# Copyright (C) 2016 Bundesamt für Sicherheit in der Informationstechnik -# Software engineering by Intevation GmbH -# -# This file is part of QGpgME, the Qt API binding for GpgME. -# -# QGpgME 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 2 of the License, or -# (at your option) any later version. -# -# QGpgME is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA - -if WANT_QT5 -libqgpgme_la = libqgpgme.la -endif -if WANT_QT6 -libqgpgmeqt6_la = libqgpgmeqt6.la -endif -lib_LTLIBRARIES = $(libqgpgme_la) $(libqgpgmeqt6_la) - -EXTRA_DIST = QGpgmeConfig.cmake.in.in QGpgmeConfigVersion.cmake.in \ - qgpgme_debug.h qgpgme_version.h.in \ - QGpgmeConfig-w32.cmake.in.in QGpgmeQt6Config.cmake.in.in \ - QGpgmeQt6Config-w32.cmake.in.in QGpgmeQt6ConfigVersion.cmake.in - -qgpgme_sources = \ - cleaner.cpp \ - dataprovider.cpp \ - debug.cpp \ - decryptverifyarchivejob.cpp \ - decryptverifyjob.cpp \ - encryptarchivejob.cpp \ - filelistdataprovider.cpp \ - job.cpp multideletejob.cpp qgpgmeadduseridjob.cpp \ - qgpgmeaddexistingsubkeyjob.cpp \ - qgpgmebackend.cpp qgpgmechangeexpiryjob.cpp qgpgmechangeownertrustjob.cpp \ - qgpgmechangepasswdjob.cpp qgpgmedecryptjob.cpp \ - qgpgmedecryptverifyarchivejob.cpp \ - qgpgmedecryptverifyjob.cpp qgpgmedeletejob.cpp qgpgmedownloadjob.cpp \ - qgpgmeencryptarchivejob.cpp \ - qgpgmeencryptjob.cpp qgpgmeexportjob.cpp qgpgmeimportfromkeyserverjob.cpp \ - qgpgmeimportjob.cpp qgpgmekeygenerationjob.cpp qgpgmekeylistjob.cpp \ - listallkeysjob.cpp qgpgmelistallkeysjob.cpp qgpgmenewcryptoconfig.cpp \ - qgpgmereceivekeysjob.cpp \ - qgpgmerefreshsmimekeysjob.cpp \ - qgpgmerevokekeyjob.cpp \ - qgpgmesetprimaryuseridjob.cpp \ - qgpgmesignarchivejob.cpp \ - qgpgmesignencryptjob.cpp \ - qgpgmesignencryptarchivejob.cpp \ - qgpgmesignjob.cpp qgpgmesignkeyjob.cpp qgpgmeverifydetachedjob.cpp \ - qgpgmeverifyopaquejob.cpp qgpgmewkdlookupjob.cpp threadedjobmixin.cpp \ - qgpgmewkdrefreshjob.cpp \ - qgpgmekeyformailboxjob.cpp qgpgme_debug.cpp \ - qgpgmetofupolicyjob.cpp qgpgmequickjob.cpp \ - defaultkeygenerationjob.cpp qgpgmewkspublishjob.cpp \ - qgpgmegpgcardjob.cpp changeexpiryjob.cpp encryptjob.cpp importjob.cpp \ - quickjob.cpp \ - signarchivejob.cpp \ - signencryptjob.cpp \ - signencryptarchivejob.cpp \ - signjob.cpp \ - dn.cpp cryptoconfig.cpp wkdlookupresult.cpp \ - util.cpp \ - verifydetachedjob.cpp \ - verifyopaquejob.cpp \ - wkdrefreshjob.cpp - -# If you add one here make sure that you also add one in camelcase -qgpgme_headers= \ - abstractimportjob.h \ - addexistingsubkeyjob.h \ - adduseridjob.h \ - changeexpiryjob.h \ - changeownertrustjob.h \ - changepasswdjob.h \ - dataprovider.h \ - debug.h \ - decryptjob.h \ - decryptverifyarchivejob.h \ - decryptverifyjob.h \ - downloadjob.h \ - encryptarchivejob.h \ - encryptjob.h \ - exportjob.h \ - filelistdataprovider.h \ - hierarchicalkeylistjob.h \ - job.h \ - keyformailboxjob.h \ - multideletejob.h \ - protocol.h \ - qgpgme_export.h \ - qgpgmenewcryptoconfig.h \ - quickjob.h \ - receivekeysjob.h \ - revokekeyjob.h \ - setprimaryuseridjob.h \ - specialjob.h \ - signarchivejob.h \ - signjob.h \ - signkeyjob.h \ - signencryptjob.h \ - signencryptarchivejob.h \ - verifyopaquejob.h \ - refreshkeysjob.h \ - cryptoconfig.h \ - deletejob.h \ - importfromkeyserverjob.h \ - importjob.h \ - keygenerationjob.h \ - keylistjob.h \ - listallkeysjob.h \ - verifydetachedjob.h \ - defaultkeygenerationjob.h \ - tofupolicyjob.h \ - wkdlookupjob.h \ - wkdlookupresult.h \ - wkdrefreshjob.h \ - wkspublishjob.h \ - gpgcardjob.h \ - dn.h - -camelcase_headers= \ - AddExistingSubkeyJob \ - AddUserIDJob \ - AbstractImportJob \ - ChangeExpiryJob \ - ChangeOwnerTrustJob \ - ChangePasswdJob \ - DataProvider \ - Debug \ - DecryptJob \ - DecryptVerifyArchiveJob \ - DecryptVerifyJob \ - DN \ - DownloadJob \ - EncryptArchiveJob \ - EncryptJob \ - ExportJob \ - FileListDataProvider \ - HierarchicalKeyListJob \ - Job \ - MultiDeleteJob \ - Protocol \ - QGpgMENewCryptoConfig \ - QuickJob \ - ReceiveKeysJob \ - RevokeKeyJob \ - SetPrimaryUserIDJob \ - SpecialJob \ - SignArchiveJob \ - SignJob \ - SignKeyJob \ - SignEncryptArchiveJob \ - SignEncryptJob \ - VerifyOpaqueJob \ - RefreshKeysJob \ - CryptoConfig \ - DeleteJob \ - ImportFromKeyserverJob \ - ImportJob \ - KeyGenerationJob \ - KeyListJob \ - ListAllKeysJob \ - VerifyDetachedJob \ - KeyForMailboxJob \ - DefaultKeyGenerationJob \ - WKDLookupJob \ - WKDLookupResult \ - WKDRefreshJob \ - WKSPublishJob \ - TofuPolicyJob \ - GpgCardJob - -private_qgpgme_headers = \ - changeexpiryjob_p.h \ - cleaner.h \ - decryptverifyarchivejob_p.h \ - decryptverifyjob_p.h \ - encryptarchivejob_p.h \ - encryptjob_p.h \ - importjob_p.h \ - listallkeysjob_p.h \ - qgpgme_export.h \ - protocol_p.h \ - job_p.h \ - qgpgmeaddexistingsubkeyjob.h \ - qgpgmeadduseridjob.h \ - qgpgmebackend.h \ - qgpgmechangeexpiryjob.h \ - qgpgmechangeownertrustjob.h \ - qgpgmechangepasswdjob.h \ - qgpgmedecryptjob.h \ - qgpgmedecryptverifyarchivejob.h \ - qgpgmedecryptverifyjob.h \ - qgpgmedeletejob.h \ - qgpgmedownloadjob.h \ - qgpgmeencryptarchivejob.h \ - qgpgmeencryptjob.h \ - qgpgmeexportjob.h \ - qgpgmeimportfromkeyserverjob.h \ - qgpgmeimportjob.h \ - qgpgmekeygenerationjob.h \ - qgpgmekeylistjob.h \ - qgpgmelistallkeysjob.h \ - qgpgmereceivekeysjob.h \ - qgpgmerefreshsmimekeysjob.h \ - qgpgmerevokekeyjob.h \ - qgpgmesetprimaryuseridjob.h \ - qgpgmesignarchivejob.h \ - qgpgmesignencryptjob.h \ - qgpgmesignencryptarchivejob.h \ - qgpgmesignjob.h \ - qgpgmesignkeyjob.h \ - qgpgmeverifydetachedjob.h \ - qgpgmeverifyopaquejob.h \ - qgpgmewkdlookupjob.h \ - qgpgmewkdrefreshjob.h \ - qgpgmekeyformailboxjob.h \ - qgpgmewkspublishjob.h \ - qgpgmetofupolicyjob.h \ - qgpgmegpgcardjob.h \ - qgpgmequickjob.h \ - quickjob_p.h \ - signarchivejob_p.h \ - signencryptjob_p.h \ - signencryptarchivejob_p.h \ - signjob_p.h \ - threadedjobmixin.h \ - util.h \ - verifydetachedjob_p.h \ - verifyopaquejob_p.h \ - wkdrefreshjob_p.h - -qgpgme_moc_sources = \ - abstractimportjob.moc \ - addexistingsubkeyjob.moc \ - adduseridjob.moc \ - changeexpiryjob.moc \ - changeownertrustjob.moc \ - changepasswdjob.moc \ - cleaner.moc \ - decryptjob.moc \ - decryptverifyarchivejob.moc \ - decryptverifyjob.moc \ - deletejob.moc \ - downloadjob.moc \ - encryptarchivejob.moc \ - encryptjob.moc \ - exportjob.moc \ - hierarchicalkeylistjob.moc \ - importfromkeyserverjob.moc \ - importjob.moc \ - job.moc \ - keygenerationjob.moc \ - keylistjob.moc \ - listallkeysjob.moc \ - multideletejob.moc \ - qgpgmeaddexistingsubkeyjob.moc \ - qgpgmeadduseridjob.moc \ - qgpgmechangeexpiryjob.moc \ - qgpgmechangeownertrustjob.moc \ - qgpgmechangepasswdjob.moc \ - qgpgmedecryptjob.moc \ - qgpgmedecryptverifyarchivejob.moc \ - qgpgmedecryptverifyjob.moc \ - qgpgmedeletejob.moc \ - qgpgmedownloadjob.moc \ - qgpgmeencryptarchivejob.moc \ - qgpgmeencryptjob.moc \ - qgpgmeexportjob.moc \ - qgpgmeimportfromkeyserverjob.moc \ - qgpgmeimportjob.moc \ - qgpgmekeygenerationjob.moc \ - qgpgmekeylistjob.moc \ - qgpgmelistallkeysjob.moc \ - qgpgmereceivekeysjob.moc \ - qgpgmerefreshsmimekeysjob.moc \ - qgpgmerevokekeyjob.moc \ - qgpgmesetprimaryuseridjob.moc \ - qgpgmesignarchivejob.moc \ - qgpgmesignencryptjob.moc \ - qgpgmesignencryptarchivejob.moc \ - qgpgmesignjob.moc \ - qgpgmesignkeyjob.moc \ - qgpgmeverifydetachedjob.moc \ - qgpgmeverifyopaquejob.moc \ - qgpgmewkdlookupjob.moc \ - qgpgmewkdrefreshjob.moc \ - qgpgmewkspublishjob.moc \ - tofupolicyjob.moc \ - qgpgmetofupolicyjob.moc \ - receivekeysjob.moc \ - refreshkeysjob.moc \ - revokekeyjob.moc \ - setprimaryuseridjob.moc \ - signarchivejob.moc \ - signencryptjob.moc \ - signencryptarchivejob.moc \ - signjob.moc \ - signkeyjob.moc \ - specialjob.moc \ - verifydetachedjob.moc \ - verifyopaquejob.moc \ - wkdlookupjob.moc \ - wkdrefreshjob.moc \ - keyformailboxjob.moc \ - wkspublishjob.moc \ - qgpgmekeyformailboxjob.moc \ - defaultkeygenerationjob.moc \ - quickjob.moc \ - qgpgmequickjob.moc \ - gpgcardjob.moc \ - qgpgmegpgcardjob.moc - -if WANT_QT5 -includeprefix5 = qgpgme-qt5 -qgpgme5includedir = $(includedir)/$(includeprefix5)/qgpgme -qgpgme5include_HEADERS = $(qgpgme_headers) -nodist_qgpgme5include_HEADERS = qgpgme_version.h -camelcase5includedir = $(includedir)/$(includeprefix5)/QGpgME -nodist_camelcase5include_HEADERS = $(camelcase_headers) -endif -if WANT_QT6 -includeprefix6 = qgpgme-qt6 -qgpgme6includedir = $(includedir)/$(includeprefix6)/qgpgme -qgpgme6include_HEADERS = $(qgpgme_headers) -nodist_qgpgme6include_HEADERS = qgpgme_version.h -camelcase6includedir = $(includedir)/$(includeprefix6)/QGpgME -nodist_camelcase6include_HEADERS = $(camelcase_headers) -endif - -# generate the moc files in two steps: -# 1. generate Qt 5/6-specific moc files in builddir with extension .moc5/.moc6; -# this ensures correct dependencies on the source files -# 2. generate forwarding headers in subfolders moc5/moc6 with extension .moc; -# this ensures that the "foo.moc" includes in the source files work and -# include the correct version of the generated moc files for Qt 5/6 -# GNU make's pattern rules would make this easier, but we don't want to use them -if WANT_QT5 -moc5_dir = moc5 -qgpgme_moc5_sources = $(qgpgme_moc_sources:%.moc=%.moc5) -qgpgme_moc5_forward_headers = $(qgpgme_moc_sources:%=$(moc5_dir)/%) - -.h.moc5: - $(MOC5) `test -f '$<' || echo '$(srcdir)/'`$< -o $@ - -$(moc5_dir): - mkdir $(moc5_dir) - -$(qgpgme_moc5_forward_headers): Makefile.am | $(moc5_dir) - echo "#include \"../$(notdir $@)5\"" > "$@" -endif -if WANT_QT6 -moc6_dir = moc6 -qgpgme_moc6_sources = $(qgpgme_moc_sources:%.moc=%.moc6) -qgpgme_moc6_forward_headers = $(qgpgme_moc_sources:%=$(moc6_dir)/%) - -.h.moc6: - $(MOC6) `test -f '$<' || echo '$(srcdir)/'`$< -o $@ - -$(moc6_dir): - mkdir $(moc6_dir) - -$(qgpgme_moc6_forward_headers): Makefile.am | $(moc6_dir) - echo "#include \"../$(notdir $@)6\"" > "$@" -endif - -if WANT_QT5 -libqgpgme_la_CPPFLAGS = -I./moc5 -I$(top_builddir)/lang/cpp/src -I$(top_builddir)/src \ - @GPGME_QT5_CFLAGS@ @GPG_ERROR_CFLAGS@ @LIBASSUAN_CFLAGS@ \ - -DBUILDING_QGPGME -Wsuggest-override \ - -Wzero-as-null-pointer-constant - -libqgpgme_la_SOURCES = $(qgpgme_sources) $(qgpgme_headers) $(private_qgpgme_headers) - -nodist_libqgpgme_la_SOURCES = $(qgpgme_moc5_sources) $(qgpgme_moc5_forward_headers) - -libqgpgme_la_LIBADD = ../../cpp/src/libgpgmepp.la ../../../src/libgpgme.la \ - @LIBASSUAN_LIBS@ @GPG_ERROR_LIBS@ @GPGME_QT5_LIBS@ -libqgpgme_la_LDFLAGS = -no-undefined -version-info \ - @LIBQGPGME_LT_CURRENT@:@LIBQGPGME_LT_REVISION@:@LIBQGPGME_LT_AGE@ -endif -if WANT_QT6 -libqgpgmeqt6_la_CPPFLAGS = -I./moc6 -I$(top_builddir)/lang/cpp/src -I$(top_builddir)/src \ - @GPGME_QT6_CFLAGS@ @GPG_ERROR_CFLAGS@ @LIBASSUAN_CFLAGS@ \ - -DBUILDING_QGPGME -Wsuggest-override \ - -Wzero-as-null-pointer-constant - -libqgpgmeqt6_la_SOURCES = $(qgpgme_sources) $(qgpgme_headers) $(private_qgpgme_headers) - -nodist_libqgpgmeqt6_la_SOURCES = $(qgpgme_moc6_sources) $(qgpgme_moc6_forward_headers) - -libqgpgmeqt6_la_LIBADD = ../../cpp/src/libgpgmepp.la ../../../src/libgpgme.la \ - @LIBASSUAN_LIBS@ @GPG_ERROR_LIBS@ @GPGME_QT6_LIBS@ -libqgpgmeqt6_la_LDFLAGS = -no-undefined -version-info \ - @LIBQGPGME_LT_CURRENT@:@LIBQGPGME_LT_REVISION@:@LIBQGPGME_LT_AGE@ -endif - -if HAVE_MACOS_SYSTEM -libsuffix=.dylib -else -libsuffix=.so -endif - -if WANT_QT5 -if HAVE_W32_SYSTEM -QGpgmeConfig.cmake: QGpgmeConfig-w32.cmake.in - sed -e 's|[@]resolved_bindir@|$(bindir)|g' < "$<" | \ - sed -e 's|[@]resolved_libdir@|$(libdir)|g' | \ - sed -e 's|[@]resolved_includedir@|$(includedir)/$(includeprefix5)|g' > $@ -else -QGpgmeConfig.cmake: QGpgmeConfig.cmake.in - sed -e 's|[@]resolved_libdir@|$(libdir)|g' < "$<" | \ - sed -e 's|[@]libsuffix@|$(libsuffix)|g' | \ - sed -e 's|[@]resolved_includedir@|$(includedir)/$(includeprefix5)|g' > $@ -endif -endif -if WANT_QT6 -if HAVE_W32_SYSTEM -QGpgmeQt6Config.cmake: QGpgmeQt6Config-w32.cmake.in - sed -e 's|[@]resolved_bindir@|$(bindir)|g' < "$<" | \ - sed -e 's|[@]resolved_libdir@|$(libdir)|g' | \ - sed -e 's|[@]resolved_includedir@|$(includedir)/$(includeprefix6)|g' > $@ -else -QGpgmeQt6Config.cmake: QGpgmeQt6Config.cmake.in - sed -e 's|[@]resolved_libdir@|$(libdir)|g' < "$<" | \ - sed -e 's|[@]libsuffix@|$(libsuffix)|g' | \ - sed -e 's|[@]resolved_includedir@|$(includedir)/$(includeprefix6)|g' > $@ -endif -endif - -$(camelcase_headers): Makefile.am - echo -n "#include \"qgpgme/" > "$@" - echo -n "$@" | tr '[:upper:]' '[:lower:]' >> "$@" - echo ".h\"" >> "$@" - -if WANT_QT5 -install-cmake-files-qt5: QGpgmeConfig.cmake QGpgmeConfigVersion.cmake - -$(INSTALL) -d $(DESTDIR)$(libdir)/cmake/QGpgme - $(INSTALL) -m 644 QGpgmeConfig.cmake \ - $(DESTDIR)$(libdir)/cmake/QGpgme/QGpgmeConfig.cmake - $(INSTALL) -m 644 QGpgmeConfigVersion.cmake \ - $(DESTDIR)$(libdir)/cmake/QGpgme/QGpgmeConfigVersion.cmake -install_cmake_files_qt5 = install-cmake-files-qt5 - -uninstall-cmake-files-qt5: - -rm $(DESTDIR)$(libdir)/cmake/QGpgme/QGpgmeConfigVersion.cmake - -rm $(DESTDIR)$(libdir)/cmake/QGpgme/QGpgmeConfig.cmake - -rmdir $(DESTDIR)$(libdir)/cmake/QGpgme/ -uninstall_cmake_files_qt5 = uninstall-cmake-files-qt5 - -uninstall-include-dirs-qt5: - -rmdir $(DESTDIR)$(qgpgme5includedir) - -rmdir $(DESTDIR)$(camelcase5includedir) - -rmdir $(DESTDIR)$(includedir)/$(includeprefix5) -uninstall_include_dirs_qt5 = uninstall-include-dirs-qt5 -endif -if WANT_QT6 -install-cmake-files-qt6: QGpgmeQt6Config.cmake QGpgmeQt6ConfigVersion.cmake - -$(INSTALL) -d $(DESTDIR)$(libdir)/cmake/QGpgmeQt6 - $(INSTALL) -m 644 QGpgmeQt6Config.cmake \ - $(DESTDIR)$(libdir)/cmake/QGpgmeQt6/QGpgmeQt6Config.cmake - $(INSTALL) -m 644 QGpgmeQt6ConfigVersion.cmake \ - $(DESTDIR)$(libdir)/cmake/QGpgmeQt6/QGpgmeQt6ConfigVersion.cmake -install_cmake_files_qt6 = install-cmake-files-qt6 - -uninstall-cmake-files-qt6: - -rm $(DESTDIR)$(libdir)/cmake/QGpgmeQt6/QGpgmeQt6ConfigVersion.cmake - -rm $(DESTDIR)$(libdir)/cmake/QGpgmeQt6/QGpgmeQt6Config.cmake - -rmdir $(DESTDIR)$(libdir)/cmake/QGpgmeQt6/ -uninstall_cmake_files_qt6 = uninstall-cmake-files-qt6 - -uninstall-include-dirs-qt6: - -rmdir $(DESTDIR)$(qgpgme6includedir) - -rmdir $(DESTDIR)$(camelcase6includedir) - -rmdir $(DESTDIR)$(includedir)/$(includeprefix6) -uninstall_include_dirs_qt6 = uninstall-include-dirs-qt6 -endif - -install-data-local: $(install_cmake_files_qt5) $(install_cmake_files_qt6) - -uninstall-hook: $(uninstall_cmake_files_qt5) $(uninstall_cmake_files_qt6) \ - $(uninstall_include_dirs_qt5) $(uninstall_include_dirs_qt6) - -BUILT_SOURCES = $(qgpgme_moc5_sources) $(qgpgme_moc5_forward_headers) \ - $(qgpgme_moc6_sources) $(qgpgme_moc6_forward_headers) \ - $(camelcase_headers) - -CLEANFILES = $(qgpgme_moc5_sources) $(qgpgme_moc5_forward_headers) \ - $(qgpgme_moc6_sources) $(qgpgme_moc6_forward_headers) \ - $(camelcase_headers) QGpgmeConfig.cmake \ - qgpgme_version.h QGpgmeConfig.cmake.in \ - QGpgmeConfig-w32.cmake.in QGpgmeConfigVersion.cmake \ - QGpgmeQt6Config.cmake.in QGpgmeQt6Config-w32.cmake.in \ - QGpgmeQt6Config.cmake QGpgmeQt6ConfigVersion.cmake - -clean-local: - -test -z "$(moc5_dir)" || rm -rf $(moc5_dir) - -test -z "$(moc6_dir)" || rm -rf $(moc6_dir) diff --git a/lang/qt/src/QGpgmeConfig-w32.cmake.in.in b/lang/qt/src/QGpgmeConfig-w32.cmake.in.in deleted file mode 100644 index 709f5fc3..00000000 --- a/lang/qt/src/QGpgmeConfig-w32.cmake.in.in +++ /dev/null @@ -1,109 +0,0 @@ -# CMake Config file for QGPGME. -# Copyright (C) 2016 Intevation GmbH -# -# This file is part of QGpgME. -# -# QGpgME 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 2 of the License, or -# (at your option) any later version. -# -# QGpgME is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA - -# based on a generated file from cmake. -# Generated by CMake 3.0.2 - -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) - message(FATAL_ERROR "CMake >= 2.6.0 required") -endif() -cmake_policy(PUSH) -cmake_policy(VERSION 2.6) -#---------------------------------------------------------------- -# Generated CMake target import file. -#---------------------------------------------------------------- - -# Commands may need to know the format version. -set(CMAKE_IMPORT_FILE_VERSION 1) - -# Protect against multiple inclusion, which would fail when already imported targets are added once more. -set(_targetsDefined) -set(_targetsNotDefined) -set(_expectedTargets) -foreach(_expectedTarget QGpgme) - list(APPEND _expectedTargets ${_expectedTarget}) - if(NOT TARGET ${_expectedTarget}) - list(APPEND _targetsNotDefined ${_expectedTarget}) - endif() - if(TARGET ${_expectedTarget}) - list(APPEND _targetsDefined ${_expectedTarget}) - endif() -endforeach() -if("${_targetsDefined}" STREQUAL "${_expectedTargets}") - set(CMAKE_IMPORT_FILE_VERSION) - cmake_policy(POP) - return() -endif() -if(NOT "${_targetsDefined}" STREQUAL "") - message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") -endif() -unset(_targetsDefined) -unset(_targetsNotDefined) -unset(_expectedTargets) - -# Create imported target QGpgme -add_library(QGpgme SHARED IMPORTED) - -set_target_properties(QGpgme PROPERTIES - IMPORTED_IMPLIB_RELEASE "@resolved_libdir@/libqgpgme.dll.a" - INTERFACE_INCLUDE_DIRECTORIES "@resolved_includedir@/qgpgme;@resolved_includedir@" - INTERFACE_LINK_LIBRARIES "Gpgmepp;Qt5::Core" - IMPORTED_LOCATION "@resolved_bindir@/libqgpgme-15.dll" -) -get_target_property(_libpath QGpgme IMPORTED_IMPLIB_RELEASE) -get_target_property(_dllpath QGpgme IMPORTED_LOCATION) - -list(APPEND _IMPORT_CHECK_TARGETS QGpgme ) -list(APPEND _IMPORT_CHECK_FILES_FOR_QGpgme "${_libpath}" "${_dllpath}" ) - -if(CMAKE_VERSION VERSION_LESS 2.8.12) - message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.") -endif() - -# Loop over all imported files and verify that they actually exist -foreach(target ${_IMPORT_CHECK_TARGETS} ) - foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) - if(NOT EXISTS "${file}" ) - message(FATAL_ERROR "The imported target \"${target}\" references the file - \"${file}\" -but this file does not exist. Possible reasons include: -* The file was deleted, renamed, or moved to another location. -* An install or uninstall procedure did not complete successfully. -* The installation package was faulty and contained - \"${CMAKE_CURRENT_LIST_FILE}\" -but not all the files it references. -") - endif() - endforeach() - unset(_IMPORT_CHECK_FILES_FOR_${target}) -endforeach() -unset(_IMPORT_CHECK_TARGETS) -unset(_dllpath) -unset(_libpath) - -# This file does not depend on other imported targets which have -# been exported from the same project but in a separate export set. - -# Commands beyond this point should not need to know the version. -set(CMAKE_IMPORT_FILE_VERSION) -cmake_policy(POP) - -# Gpgmepp is a requirement for qgpgme -find_package(Gpgmepp CONFIG REQUIRED) diff --git a/lang/qt/src/QGpgmeConfig.cmake.in.in b/lang/qt/src/QGpgmeConfig.cmake.in.in deleted file mode 100644 index fc13bfb7..00000000 --- a/lang/qt/src/QGpgmeConfig.cmake.in.in +++ /dev/null @@ -1,101 +0,0 @@ -# CMake Config file for QGPGME. -# Copyright (C) 2016 Intevation GmbH -# -# This file is part of QGpgME. -# -# QGpgME 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 2 of the License, or -# (at your option) any later version. -# -# QGpgME is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA - -# based on a generated file from cmake. -# Generated by CMake 3.0.2 - -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) - message(FATAL_ERROR "CMake >= 2.6.0 required") -endif() -cmake_policy(PUSH) -cmake_policy(VERSION 2.6) -#---------------------------------------------------------------- -# Generated CMake target import file. -#---------------------------------------------------------------- - -# Commands may need to know the format version. -set(CMAKE_IMPORT_FILE_VERSION 1) - -# Protect against multiple inclusion, which would fail when already imported targets are added once more. -set(_targetsDefined) -set(_targetsNotDefined) -set(_expectedTargets) -foreach(_expectedTarget QGpgme) - list(APPEND _expectedTargets ${_expectedTarget}) - if(NOT TARGET ${_expectedTarget}) - list(APPEND _targetsNotDefined ${_expectedTarget}) - endif() - if(TARGET ${_expectedTarget}) - list(APPEND _targetsDefined ${_expectedTarget}) - endif() -endforeach() -if("${_targetsDefined}" STREQUAL "${_expectedTargets}") - set(CMAKE_IMPORT_FILE_VERSION) - cmake_policy(POP) - return() -endif() -if(NOT "${_targetsDefined}" STREQUAL "") - message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") -endif() -unset(_targetsDefined) -unset(_targetsNotDefined) -unset(_expectedTargets) - -# Create imported target QGpgme -add_library(QGpgme SHARED IMPORTED) - -set_target_properties(QGpgme PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "@resolved_includedir@/qgpgme;@resolved_includedir@" - INTERFACE_LINK_LIBRARIES "Gpgmepp;Qt5::Core" - IMPORTED_LOCATION "@resolved_libdir@/libqgpgme@libsuffix@" -) - -if(CMAKE_VERSION VERSION_LESS 2.8.12) - message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.") -endif() - -# Loop over all imported files and verify that they actually exist -foreach(target ${_IMPORT_CHECK_TARGETS} ) - foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) - if(NOT EXISTS "${file}" ) - message(FATAL_ERROR "The imported target \"${target}\" references the file - \"${file}\" -but this file does not exist. Possible reasons include: -* The file was deleted, renamed, or moved to another location. -* An install or uninstall procedure did not complete successfully. -* The installation package was faulty and contained - \"${CMAKE_CURRENT_LIST_FILE}\" -but not all the files it references. -") - endif() - endforeach() - unset(_IMPORT_CHECK_FILES_FOR_${target}) -endforeach() -unset(_IMPORT_CHECK_TARGETS) - -# This file does not depend on other imported targets which have -# been exported from the same project but in a separate export set. - -# Commands beyond this point should not need to know the version. -set(CMAKE_IMPORT_FILE_VERSION) -cmake_policy(POP) - -# Gpgmepp is a requirement for qgpgme -find_package(Gpgmepp CONFIG REQUIRED) diff --git a/lang/qt/src/QGpgmeConfigVersion.cmake.in b/lang/qt/src/QGpgmeConfigVersion.cmake.in deleted file mode 100644 index cbc21856..00000000 --- a/lang/qt/src/QGpgmeConfigVersion.cmake.in +++ /dev/null @@ -1,31 +0,0 @@ -# CMake Version file for QGPGME. -# Copyright (C) 2016 Intevation GmbH -# -# This file is part of QGpgME. -# -# QGpgME 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 2 of the License, or -# (at your option) any later version. -# -# QGpgME is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA - -# based on a generated file from cmake. -set(PACKAGE_VERSION "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_MICRO@") - -if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) - set(PACKAGE_VERSION_COMPATIBLE FALSE) -else() - set(PACKAGE_VERSION_COMPATIBLE TRUE) - if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") - set(PACKAGE_VERSION_EXACT TRUE) - endif() -endif() diff --git a/lang/qt/src/QGpgmeQt6Config-w32.cmake.in.in b/lang/qt/src/QGpgmeQt6Config-w32.cmake.in.in deleted file mode 100644 index 520ce62d..00000000 --- a/lang/qt/src/QGpgmeQt6Config-w32.cmake.in.in +++ /dev/null @@ -1,109 +0,0 @@ -# CMake Config file for QGpgME for Qt 6 -# Copyright (C) 2016 Intevation GmbH -# -# This file is part of QGpgME. -# -# QGpgME 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 2 of the License, or -# (at your option) any later version. -# -# QGpgME is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA - -# based on a generated file from cmake. -# Generated by CMake 3.0.2 - -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) - message(FATAL_ERROR "CMake >= 2.6.0 required") -endif() -cmake_policy(PUSH) -cmake_policy(VERSION 2.6) -#---------------------------------------------------------------- -# Generated CMake target import file. -#---------------------------------------------------------------- - -# Commands may need to know the format version. -set(CMAKE_IMPORT_FILE_VERSION 1) - -# Protect against multiple inclusion, which would fail when already imported targets are added once more. -set(_targetsDefined) -set(_targetsNotDefined) -set(_expectedTargets) -foreach(_expectedTarget QGpgmeQt6) - list(APPEND _expectedTargets ${_expectedTarget}) - if(NOT TARGET ${_expectedTarget}) - list(APPEND _targetsNotDefined ${_expectedTarget}) - endif() - if(TARGET ${_expectedTarget}) - list(APPEND _targetsDefined ${_expectedTarget}) - endif() -endforeach() -if("${_targetsDefined}" STREQUAL "${_expectedTargets}") - set(CMAKE_IMPORT_FILE_VERSION) - cmake_policy(POP) - return() -endif() -if(NOT "${_targetsDefined}" STREQUAL "") - message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") -endif() -unset(_targetsDefined) -unset(_targetsNotDefined) -unset(_expectedTargets) - -# Create imported target QGpgmeQt6 -add_library(QGpgmeQt6 SHARED IMPORTED) - -set_target_properties(QGpgmeQt6 PROPERTIES - IMPORTED_IMPLIB_RELEASE "@resolved_libdir@/libqgpgmeqt6.dll.a" - INTERFACE_INCLUDE_DIRECTORIES "@resolved_includedir@/qgpgme;@resolved_includedir@" - INTERFACE_LINK_LIBRARIES "Gpgmepp;Qt6::Core" - IMPORTED_LOCATION "@resolved_bindir@/libqgpgmeqt6-15.dll" -) -get_target_property(_libpath QGpgmeQt6 IMPORTED_IMPLIB_RELEASE) -get_target_property(_dllpath QGpgmeQt6 IMPORTED_LOCATION) - -list(APPEND _IMPORT_CHECK_TARGETS QGpgmeQt6 ) -list(APPEND _IMPORT_CHECK_FILES_FOR_QGpgmeQt6 "${_libpath}" "${_dllpath}" ) - -if(CMAKE_VERSION VERSION_LESS 2.8.12) - message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.") -endif() - -# Loop over all imported files and verify that they actually exist -foreach(target ${_IMPORT_CHECK_TARGETS} ) - foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) - if(NOT EXISTS "${file}" ) - message(FATAL_ERROR "The imported target \"${target}\" references the file - \"${file}\" -but this file does not exist. Possible reasons include: -* The file was deleted, renamed, or moved to another location. -* An install or uninstall procedure did not complete successfully. -* The installation package was faulty and contained - \"${CMAKE_CURRENT_LIST_FILE}\" -but not all the files it references. -") - endif() - endforeach() - unset(_IMPORT_CHECK_FILES_FOR_${target}) -endforeach() -unset(_IMPORT_CHECK_TARGETS) -unset(_dllpath) -unset(_libpath) - -# This file does not depend on other imported targets which have -# been exported from the same project but in a separate export set. - -# Commands beyond this point should not need to know the version. -set(CMAKE_IMPORT_FILE_VERSION) -cmake_policy(POP) - -# Gpgmepp is a requirement for QGpgME -find_package(Gpgmepp CONFIG REQUIRED) diff --git a/lang/qt/src/QGpgmeQt6Config.cmake.in.in b/lang/qt/src/QGpgmeQt6Config.cmake.in.in deleted file mode 100644 index 14fa54e1..00000000 --- a/lang/qt/src/QGpgmeQt6Config.cmake.in.in +++ /dev/null @@ -1,101 +0,0 @@ -# CMake Config file for QGpgME for Qt 6 -# Copyright (C) 2016 Intevation GmbH -# -# This file is part of QGpgME. -# -# QGpgME 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 2 of the License, or -# (at your option) any later version. -# -# QGpgME is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA - -# based on a generated file from cmake. -# Generated by CMake 3.0.2 - -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) - message(FATAL_ERROR "CMake >= 2.6.0 required") -endif() -cmake_policy(PUSH) -cmake_policy(VERSION 2.6) -#---------------------------------------------------------------- -# Generated CMake target import file. -#---------------------------------------------------------------- - -# Commands may need to know the format version. -set(CMAKE_IMPORT_FILE_VERSION 1) - -# Protect against multiple inclusion, which would fail when already imported targets are added once more. -set(_targetsDefined) -set(_targetsNotDefined) -set(_expectedTargets) -foreach(_expectedTarget QGpgmeQt6) - list(APPEND _expectedTargets ${_expectedTarget}) - if(NOT TARGET ${_expectedTarget}) - list(APPEND _targetsNotDefined ${_expectedTarget}) - endif() - if(TARGET ${_expectedTarget}) - list(APPEND _targetsDefined ${_expectedTarget}) - endif() -endforeach() -if("${_targetsDefined}" STREQUAL "${_expectedTargets}") - set(CMAKE_IMPORT_FILE_VERSION) - cmake_policy(POP) - return() -endif() -if(NOT "${_targetsDefined}" STREQUAL "") - message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") -endif() -unset(_targetsDefined) -unset(_targetsNotDefined) -unset(_expectedTargets) - -# Create imported target QGpgmeQt6 -add_library(QGpgmeQt6 SHARED IMPORTED) - -set_target_properties(QGpgmeQt6 PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "@resolved_includedir@/qgpgme;@resolved_includedir@" - INTERFACE_LINK_LIBRARIES "Gpgmepp;Qt6::Core" - IMPORTED_LOCATION "@resolved_libdir@/libqgpgmeqt6@libsuffix@" -) - -if(CMAKE_VERSION VERSION_LESS 2.8.12) - message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.") -endif() - -# Loop over all imported files and verify that they actually exist -foreach(target ${_IMPORT_CHECK_TARGETS} ) - foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) - if(NOT EXISTS "${file}" ) - message(FATAL_ERROR "The imported target \"${target}\" references the file - \"${file}\" -but this file does not exist. Possible reasons include: -* The file was deleted, renamed, or moved to another location. -* An install or uninstall procedure did not complete successfully. -* The installation package was faulty and contained - \"${CMAKE_CURRENT_LIST_FILE}\" -but not all the files it references. -") - endif() - endforeach() - unset(_IMPORT_CHECK_FILES_FOR_${target}) -endforeach() -unset(_IMPORT_CHECK_TARGETS) - -# This file does not depend on other imported targets which have -# been exported from the same project but in a separate export set. - -# Commands beyond this point should not need to know the version. -set(CMAKE_IMPORT_FILE_VERSION) -cmake_policy(POP) - -# Gpgmepp is a requirement for QGpgME -find_package(Gpgmepp CONFIG REQUIRED) diff --git a/lang/qt/src/QGpgmeQt6ConfigVersion.cmake.in b/lang/qt/src/QGpgmeQt6ConfigVersion.cmake.in deleted file mode 100644 index a0ba9505..00000000 --- a/lang/qt/src/QGpgmeQt6ConfigVersion.cmake.in +++ /dev/null @@ -1,31 +0,0 @@ -# CMake Version file for QGpgME for Qt 6 -# Copyright (C) 2016 Intevation GmbH -# -# This file is part of QGpgME. -# -# QGpgME 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 2 of the License, or -# (at your option) any later version. -# -# QGpgME is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA - -# based on a generated file from cmake. -set(PACKAGE_VERSION "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_MICRO@") - -if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) - set(PACKAGE_VERSION_COMPATIBLE FALSE) -else() - set(PACKAGE_VERSION_COMPATIBLE TRUE) - if("${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") - set(PACKAGE_VERSION_EXACT TRUE) - endif() -endif() diff --git a/lang/qt/src/abstractimportjob.h b/lang/qt/src/abstractimportjob.h deleted file mode 100644 index ab6b530d..00000000 --- a/lang/qt/src/abstractimportjob.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - abstractimportjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2009 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_ABSTRACTIMPORTJOB_H__ -#define __KLEO_ABSTRACTIMPORTJOB_H__ - -#include "job.h" - -#include "qgpgme_export.h" - -namespace GpgME -{ -class Error; -class ImportResult; -} - -namespace QGpgME -{ - -class QGPGME_EXPORT AbstractImportJob : public Job -{ - Q_OBJECT -protected: - explicit AbstractImportJob(QObject *parent); -public: - ~AbstractImportJob(); - -Q_SIGNALS: - void result(const GpgME::ImportResult &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __KLEO_IMPORTJOB_H__ diff --git a/lang/qt/src/addexistingsubkeyjob.h b/lang/qt/src/addexistingsubkeyjob.h deleted file mode 100644 index 5465778c..00000000 --- a/lang/qt/src/addexistingsubkeyjob.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - addexistingsubkeyjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_ADDEXISTINGSUBKEYJOB_H__ -#define __QGPGME_ADDEXISTINGSUBKEYJOB_H__ - -#include "job.h" -#include "qgpgme_export.h" - -class QString; - -namespace GpgME -{ -class Error; -class Key; -class Subkey; -} - -namespace QGpgME -{ - -class QGPGME_EXPORT AddExistingSubkeyJob : public Job -{ - Q_OBJECT -protected: - explicit AddExistingSubkeyJob(QObject *parent); - -public: - ~AddExistingSubkeyJob(); - - /** - Starts the operation. \a key is the key to add the subkey \a subkey to. - - The job deletes itself after it has completed the operation. - */ - virtual GpgME::Error start(const GpgME::Key &key, const GpgME::Subkey &subkey) = 0; - - /** - Runs the operation. \a key is the key to add the subkey \a subkey to. - */ - virtual GpgME::Error exec(const GpgME::Key &key, const GpgME::Subkey &subkey) = 0; - -Q_SIGNALS: - void result(const GpgME::Error &result, const QString &auditLogAsHtml = {}, const GpgME::Error &auditLogError = {}); -}; - -} - -#endif // __QGPGME_ADDEXISTINGSUBKEYJOB_H__ diff --git a/lang/qt/src/adduseridjob.h b/lang/qt/src/adduseridjob.h deleted file mode 100644 index cc3963c9..00000000 --- a/lang/qt/src/adduseridjob.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - adduseridjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_ADDUSERIDJOB_H__ -#define __KLEO_ADDUSERIDJOB_H__ - -#include "job.h" - -#include <QtCore/QString> - -namespace GpgME -{ -class Error; -class Key; -} - -namespace QGpgME -{ - -/** - @short An abstract base class to asynchronously add UIDs to OpenPGP keys - - To use a AddUserIDJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the job with a call - to start(). This call might fail, in which case the AddUserIDJob - instance will have scheduled it's own destruction with a call to - QObject::deleteLater(). - - After result() is emitted, the AddUserIDJob will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT AddUserIDJob : public Job -{ - Q_OBJECT -protected: - explicit AddUserIDJob(QObject *parent); -public: - ~AddUserIDJob(); - - /** - Starts the operation. \a key is the key to add the UID to. \a - name, \a email and \a comment are the components of the user id. - */ - virtual GpgME::Error start(const GpgME::Key &key, const QString &name, - const QString &email, const QString &comment = QString()) = 0; - -Q_SIGNALS: - void result(const GpgME::Error &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __KLEO_ADDUSERIDJOB_H__ diff --git a/lang/qt/src/changeexpiryjob.cpp b/lang/qt/src/changeexpiryjob.cpp deleted file mode 100644 index 333fbabe..00000000 --- a/lang/qt/src/changeexpiryjob.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - changeexpiryjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2021 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "changeexpiryjob.h" -#include "changeexpiryjob_p.h" - -#include <gpgme++/context.h> - -using namespace GpgME; -using namespace QGpgME; - -void ChangeExpiryJob::setOptions(ChangeExpiryJob::Options options) -{ - auto d = jobPrivate<ChangeExpiryJobPrivate>(this); - d->m_options = options; -} - -ChangeExpiryJob::Options ChangeExpiryJob::options() const -{ - auto d = jobPrivate<ChangeExpiryJobPrivate>(this); - return d->m_options; -} - -/* For ABI compat not pure virtual. */ -Error ChangeExpiryJob::start(const Key &, const QDateTime &, const std::vector<Subkey> &) -{ - return {}; -} diff --git a/lang/qt/src/changeexpiryjob.h b/lang/qt/src/changeexpiryjob.h deleted file mode 100644 index abec51ea..00000000 --- a/lang/qt/src/changeexpiryjob.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - changeexpiryjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_CHANGEEXPIRYJOB_H__ -#define __KLEO_CHANGEEXPIRYJOB_H__ - -#include "job.h" - -#include <gpgme++/key.h> - -#include <vector> - -namespace GpgME -{ -class Error; -} - -class QDateTime; - -namespace QGpgME -{ - -/** - @short An abstract base class to change expiry asynchronously - - To use a ChangeExpiryJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the job with a call - to start(). This call might fail, in which case the ChangeExpiryJob - instance will have scheduled it's own destruction with a call to - QObject::deleteLater(). - - After result() is emitted, the ChangeExpiryJob will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT ChangeExpiryJob : public Job -{ - Q_OBJECT -public: - enum Option { - Default = 0x00, - UpdatePrimaryKey = 0x01, - UpdateAllSubkeys = 0x02, - }; - Q_DECLARE_FLAGS(Options, Option) - -protected: - explicit ChangeExpiryJob(QObject *parent); -public: - ~ChangeExpiryJob(); - - void setOptions(Options options); - Options options() const; - - /** - Starts the change-expiry operation. \a key is the key to change - the expiry of. \a expiry is the new expiry time. If \a expiry - is not valid, \a key is set to never expire. - */ - virtual GpgME::Error start(const GpgME::Key &key, const QDateTime &expiry) = 0; - - /** - Starts the change-expiry operation. \a key is the key to change, - \a subkeys is a list of subkeys of the key, and \a expiry is the - new expiry time. If \a subkeys is empty, then the expiry of \a key - is changed. Otherwise, the expiry of \a subkeys is changed. If - \a expiry is not valid, then \a key or \a subkeys are set to never expire. - */ - virtual GpgME::Error start(const GpgME::Key &key, const QDateTime &expiry, - const std::vector<GpgME::Subkey> &subkeys); - -Q_SIGNALS: - void result(const GpgME::Error &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(ChangeExpiryJob::Options) - -} - -#endif // __KLEO_CHANGEEXPIRYJOB_H__ diff --git a/lang/qt/src/changeexpiryjob_p.h b/lang/qt/src/changeexpiryjob_p.h deleted file mode 100644 index c6c91c25..00000000 --- a/lang/qt/src/changeexpiryjob_p.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - changeexpiryjob_p.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2021,2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_CHANGEEXPIRYJOB_P_H__ -#define __QGPGME_CHANGEEXPIRYJOB_P_H__ - -#include "job_p.h" - -#include "changeexpiryjob.h" - -namespace QGpgME -{ - -struct ChangeExpiryJobPrivate : public JobPrivate -{ - ChangeExpiryJob::Options m_options = ChangeExpiryJob::Default; -}; - -} - -#endif // __QGPGME_CHANGEEXPIRYJOB_P_H__ diff --git a/lang/qt/src/changeownertrustjob.h b/lang/qt/src/changeownertrustjob.h deleted file mode 100644 index 6e4613ee..00000000 --- a/lang/qt/src/changeownertrustjob.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - changeownertrustjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_CHANGEOWNERTRUST_H__ -#define __KLEO_CHANGEOWNERTRUST_H__ - -#include "job.h" - -#include <gpgme++/key.h> - -namespace QGpgME -{ - -/** - @short An abstract base class to change owner trust asynchronously - - To use a ChangeOwnerTrustJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the job with a call - to start(). This call might fail, in which case the ChangeOwnerTrustJob - instance will have scheduled it's own destruction with a call to - QObject::deleteLater(). - - After result() is emitted, the ChangeOwnerTrustJob will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT ChangeOwnerTrustJob : public Job -{ - Q_OBJECT -protected: - explicit ChangeOwnerTrustJob(QObject *parent); -public: - ~ChangeOwnerTrustJob(); - - /** - Starts the change-owner trust operation. \a key is the key to change - the owner trust of . \a trust is the new trust level. - */ - virtual GpgME::Error start(const GpgME::Key &key, GpgME::Key::OwnerTrust trust) = 0; - -Q_SIGNALS: - void result(const GpgME::Error &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __KLEO_CHANGEOWNERTRUSTJOB_H__ diff --git a/lang/qt/src/changepasswdjob.h b/lang/qt/src/changepasswdjob.h deleted file mode 100644 index 44de77c4..00000000 --- a/lang/qt/src/changepasswdjob.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - changepasswdjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2010 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_CHANGEPASSWDJOB_H__ -#define __KLEO_CHANGEPASSWDJOB_H__ - -#include "job.h" - -namespace GpgME -{ -class Error; -class Key; -} - -namespace QGpgME -{ - -/** - @short An abstract base class to change a key's passphrase asynchronously - - To use a ChangePasswdJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the job with a call - to start(). This call might fail, in which case the ChangePasswdJob - instance will have scheduled it's own destruction with a call to - QObject::deleteLater(). - - After result() is emitted, the ChangePasswdJob will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT ChangePasswdJob : public Job -{ - Q_OBJECT -protected: - explicit ChangePasswdJob(QObject *parent); -public: - ~ChangePasswdJob(); - - /** - Starts the passphrase-change operation. \a key is the key to - change the passphrase of. The passphrase is queried by the - backend directly, you cannot give it to the job beforehand. - */ - virtual GpgME::Error start(const GpgME::Key &key) = 0; - -Q_SIGNALS: - void result(const GpgME::Error &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __KLEO_CHANGEPASSWDJOB_H__ diff --git a/lang/qt/src/cleaner.cpp b/lang/qt/src/cleaner.cpp deleted file mode 100644 index b46d1a23..00000000 --- a/lang/qt/src/cleaner.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - cleaner.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#include "cleaner.h" - -#include <qgpgme_debug.h> - -#include <QCoreApplication> -#include <QFile> - -#include <chrono> - -static const auto timeout = std::chrono::seconds{10}; - -static bool remove_file(const QString &filePath) -{ - if (filePath.isEmpty()) { - qCWarning(QGPGME_LOG) << __func__ << "- called with empty file path"; - return true; - } - if (QFile::exists(filePath)) { - qCDebug(QGPGME_LOG) << __func__ << "- Removing file" << filePath; - if (!QFile::remove(filePath)) { - qCDebug(QGPGME_LOG) << __func__ << "- Removing file" << filePath << "failed"; - return false; - } - } else { - qCDebug(QGPGME_LOG) << __func__ << "- File" << filePath << "doesn't exist"; - } - return true; -} - -void Cleaner::removeFile(const QString &filePath) -{ - if (!remove_file(filePath)) { - // use invokeMethod because we might not be called from the GUI thread - // but we want to delegate the Cleaner's clean-up to the application instance - QMetaObject::invokeMethod(qApp, [filePath]() { - new Cleaner{filePath, qApp}; - }, Qt::QueuedConnection); - } -} - -Cleaner::Cleaner(const QString &filePath, QObject *parent) - : QObject{parent} - , mFilePath{filePath} -{ - qCDebug(QGPGME_LOG) << this << __func__ << filePath; - mTimer.setSingleShot(true); - mTimer.callOnTimeout([this]() { - if (remove_file(mFilePath)) { - mFilePath.clear(); - deleteLater(); - } else { - mTimer.start(timeout); - } - }); - mTimer.start(timeout); -} - -Cleaner::~Cleaner() -{ - qCDebug(QGPGME_LOG) << this << __func__; - if (!mFilePath.isEmpty()) { - remove_file(mFilePath); - } -} - -#include "cleaner.moc" diff --git a/lang/qt/src/cleaner.h b/lang/qt/src/cleaner.h deleted file mode 100644 index 2307c34e..00000000 --- a/lang/qt/src/cleaner.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - cleaner.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_CLEANER_H__ -#define __QGPGME_CLEANER_H__ - -#include <QObject> -#include <QString> -#include <QTimer> - -/** Helper class that tries to remove files at regular intervals and on destruction. */ -class Cleaner : public QObject -{ - Q_OBJECT -public: - /** Tries to remove the file. If this fails it creates a Cleaner for the file. */ - static void removeFile(const QString &filePath); - -private: - explicit Cleaner(const QString &filePath, QObject *parent=nullptr); - ~Cleaner() override; - - Q_DISABLE_COPY_MOVE(Cleaner) - -private: - QString mFilePath; - QTimer mTimer; -}; - -#endif // __QGPGME_CLEANER_H__ diff --git a/lang/qt/src/cryptoconfig.cpp b/lang/qt/src/cryptoconfig.cpp deleted file mode 100644 index fe808827..00000000 --- a/lang/qt/src/cryptoconfig.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - cryptoconfig.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2017 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#include "cryptoconfig.h" -#include "qgpgmenewcryptoconfig.h" - -using namespace QGpgME; - -QStringList CryptoConfigEntry::stringValueList() const -{ - const QGpgMENewCryptoConfigEntry *entry = dynamic_cast <const QGpgMENewCryptoConfigEntry*> (this); - if (!entry) { - return QStringList(); - } - return entry->stringValueList(); -} - -QVariant CryptoConfigEntry::defaultValue() const -{ - const QGpgMENewCryptoConfigEntry *entry = dynamic_cast <const QGpgMENewCryptoConfigEntry*>(this); - if (!entry) { - return {}; - } - return entry->defaultValue(); -} - -QGpgME::CryptoConfigEntry *CryptoConfig::entry(const QString &componentName, const QString &entryName) const -{ - const CryptoConfigComponent *comp = component(componentName); - const QStringList groupNames = comp ? comp->groupList() : QStringList(); - for (const auto &groupName : groupNames) { - const CryptoConfigGroup *group = comp->group(groupName); - CryptoConfigEntry *entry = group ? group->entry(entryName) : nullptr; - if (entry) { - return entry; - } - } - return nullptr; -} - -QGpgME::CryptoConfigEntry *CryptoConfig::entry(const QString &componentName, const QString &groupName, const QString &entryName) const -{ - const CryptoConfigComponent *comp = component(componentName); - const CryptoConfigGroup *group = comp ? comp->group(groupName) : nullptr; - return group ? group->entry(entryName) : nullptr; -} diff --git a/lang/qt/src/cryptoconfig.h b/lang/qt/src/cryptoconfig.h deleted file mode 100644 index d87f7d46..00000000 --- a/lang/qt/src/cryptoconfig.h +++ /dev/null @@ -1,424 +0,0 @@ -/* - cryptoconfig.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef CRYPTOCONFIG_H -#define CRYPTOCONFIG_H - -#include "qgpgme_export.h" -#ifdef __cplusplus -/* we read this file from a C compiler, and are only interested in the - * enums... */ - -#include <QUrl> - -#include <vector> - -class QVariant; - -/* Start reading this file from the bottom up :) */ - -namespace QGpgME -{ - -/** - * Description of a single option - */ -class QGPGME_EXPORT CryptoConfigEntry -{ - -public: -#endif /* __cplusplus */ - /** - @li basic This option should always be offered to the user. - @li advanced This option may be offered to advanced users. - @li expert This option should only be offered to expert users. - */ - enum Level { Level_Basic = 0, - Level_Advanced = 1, - Level_Expert = 2 - }; - - /** - Type of the argument - @li ArgType_None The option is set or not set, but no argument. - @li ArgType_String An unformatted string. - @li ArgType_Int A signed integer number. - @li ArgType_UInt An unsigned integer number. - @li ArgType_Path A string that describes the pathname of a file. - The file does not necessarily need to exist. - Separated from string so that e.g. a FileDialog can be used. - @li ArgType_DirPath A string that describes the pathname of a directory. - The directory does not necessarily need to exist. - Separated from path so that e.g. a FileDialog can be used which only - allows directories to be selected. - @li ArgType_LDAPURL A LDAP URL - Separated from URL so that a more specific widget can be shown, hiding the url syntax - */ - enum ArgType { ArgType_None = 0, - ArgType_String = 1, - ArgType_Int = 2, - ArgType_UInt = 3, - ArgType_Path = 4, - /* Nr. 5 was URL historically. */ - ArgType_LDAPURL = 6, - ArgType_DirPath = 7, - - NumArgType - }; - -#ifdef __cplusplus - virtual ~CryptoConfigEntry() {} - - /** - * Return the internal name of this entry - */ - virtual QString name() const = 0; - - /** - * @return user-visible description of this entry - */ - virtual QString description() const = 0; - - /** - * @return "component/group/name" - */ - virtual QString path() const = 0; - - /** - * @return true if the argument is optional - */ - virtual bool isOptional() const = 0; - - /** - * @return true if the entry is readonly - */ - virtual bool isReadOnly() const = 0; - - /** - * @return true if the argument can be given multiple times - */ - virtual bool isList() const = 0; - - /** - * @return true if the argument can be changed at runtime - */ - virtual bool isRuntime() const = 0; - - /** - * User level - */ - virtual Level level() const = 0; - - /** - * Argument type - */ - virtual ArgType argType() const = 0; - - /** - * Return true if the option is set, i.e. different from default - */ - virtual bool isSet() const = 0; - - /** - * Return value as a bool (only allowed for ArgType_None) - */ - virtual bool boolValue() const = 0; - - /** - * Return value as a string (available for all argtypes) - * The returned string can be empty (explicitly set to empty) or null (not set). - */ - virtual QString stringValue() const = 0; - - /** - * Return value as a signed int - */ - virtual int intValue() const = 0; - - /** - * Return value as an unsigned int - */ - virtual unsigned int uintValue() const = 0; - - /** - * Return value as a URL (only meaningful for Path and URL argtypes) - */ - virtual QUrl urlValue() const = 0; - - /** - * Return number of times the option is set (only valid for ArgType_None, if isList()) - */ - virtual unsigned int numberOfTimesSet() const = 0; - - /** - * Return value as a list of signed ints - */ - virtual std::vector<int> intValueList() const = 0; - - /** - * Return value as a list of unsigned ints - */ - virtual std::vector<unsigned int> uintValueList() const = 0; - - /** - * Return value as a list of URLs (only meaningful for Path and URL argtypes, if isList()) - */ - virtual QList<QUrl> urlValueList() const = 0; - - /** - * Reset an option to its default value - */ - virtual void resetToDefault() = 0; - - /** - * Define whether the option is set or not (only allowed for ArgType_None) - * #### TODO: and for options with optional args - */ - virtual void setBoolValue(bool) = 0; - - /** - * Set string value (allowed for all argtypes) - */ - virtual void setStringValue(const QString &) = 0; - - /** - * Set a new signed int value - */ - virtual void setIntValue(int) = 0; - - /** - * Set a new unsigned int value - */ - virtual void setUIntValue(unsigned int) = 0; - - /** - * Set value as a URL (only meaningful for Path (if local) and URL argtypes) - */ - virtual void setURLValue(const QUrl &) = 0; - - /** - * Set the number of times the option is set (only valid for ArgType_None, if isList()) - */ - virtual void setNumberOfTimesSet(unsigned int) = 0; - - /** - * Set a new list of signed int values - */ - virtual void setIntValueList(const std::vector<int> &) = 0; - - /** - * Set a new list of unsigned int values - */ - virtual void setUIntValueList(const std::vector<unsigned int> &) = 0; - - /** - * Set value as a URL list (only meaningful for Path (if all URLs are local) and URL argtypes, if isList()) - */ - virtual void setURLValueList(const QList<QUrl> &) = 0; - - /** - * @return true if the value was changed - */ - virtual bool isDirty() const = 0; - - // Design change from here on we are closely bound to one implementation - // of cryptoconfig. To avoid ABI breaks with every new function we - // add real functions from now on. - - /** - * @return a stringValueList. - */ - QStringList stringValueList() const; - - /** - * Return the default value as a variant (available for all argtypes). - */ - QVariant defaultValue() const; -}; - -/** - * Group containing a set of config options - */ -class QGPGME_EXPORT CryptoConfigGroup -{ - -public: - virtual ~CryptoConfigGroup() {} - - /** - * Return the internal name of this group - */ - virtual QString name() const = 0; - - /** - * Return the name of the icon for this group - */ - virtual QString iconName() const = 0; - - /** - * @return user-visible description of this group - */ - virtual QString description() const = 0; - - /** - * @return "component/group" - */ - virtual QString path() const = 0; - - /** - * User level - */ - virtual CryptoConfigEntry::Level level() const = 0; - - /** - * Returns the list of entries that are known by this group. - * - * @return list of group entry names. - **/ - virtual QStringList entryList() const = 0; - - /** - * @return the configuration object for a given entry in this group - * The object is owned by CryptoConfigGroup, don't delete it. - * Groups cannot be nested, so all entries returned here are pure entries, no groups. - */ - virtual CryptoConfigEntry *entry(const QString &name) const = 0; -}; - -/** - * Crypto config for one component (e.g. gpg-agent, dirmngr etc.) - */ -class QGPGME_EXPORT CryptoConfigComponent -{ - -public: - virtual ~CryptoConfigComponent() {} - - /** - * Return the internal name of this component - */ - virtual QString name() const = 0; - - /** - * Return the name of the icon for this component - */ - virtual QString iconName() const = 0; - - /** - * Return user-visible description of this component - */ - virtual QString description() const = 0; - - /** - * Returns the list of groups that are known about. - * - * @return list of group names. One of them can be "<nogroup>", which is the group where all - * "toplevel" options (belonging to no group) are. - */ - virtual QStringList groupList() const = 0; - - /** - * @return the configuration object for a given group - * The object is owned by CryptoConfigComponent, don't delete it. - */ - virtual CryptoConfigGroup *group(const QString &name) const = 0; - -}; - -/** - * Main interface to crypto configuration. - */ -class QGPGME_EXPORT CryptoConfig -{ - -public: - virtual ~CryptoConfig() {} - - /** - * Returns the list of known components (e.g. "gpg-agent", "dirmngr" etc.). - * Use @ref component() to retrieve more information about each one. - * @return list of component names. - **/ - virtual QStringList componentList() const = 0; - - /** - * @return the configuration object for a given component - * The object is owned by CryptoConfig, don't delete it. - */ - virtual CryptoConfigComponent *component(const QString &name) const = 0; - - /** - * Convenience method to get hold of a single configuration entry when - * its component and name are known. This can be used to read - * the value and/or to set a value to it. - * - * @return the configuration object for a single configuration entry, 0 if not found. - * The object is owned by CryptoConfig, don't delete it. - */ - CryptoConfigEntry *entry(const QString &componentName, const QString &entryName) const; - - /** - * This function is obsolete. It is provided to keep old source code working. - * We strongly advise against using it in new code. - * - * This function overloads @ref entry(). - * - * Use the entry overload that does not require a group name instead. The group name - * is not needed to identify a configuration entry because it only provides logical - * grouping for user interfaces. Sometimes configuration entries are moved to different - * groups to improve usability. - */ - QGPGME_DEPRECATED CryptoConfigEntry *entry(const QString &componentName, const QString &groupName, const QString &entryName) const; - - /** - * Write back changes - * - * @param runtime this parameter is ignored. Changes will always - * be made with --runtime set. - */ - virtual void sync(bool runtime) = 0; - - /** - * Tells the CryptoConfig to discard any cached information, including - * all components, groups and entries. - * Call this to free some memory when you won't be using the object - * for some time. - * DON'T call this if you're holding pointers to components, groups or entries. - */ - virtual void clear() = 0; -}; - -} -#endif /* __cplusplus */ -#endif /* CRYPTOCONFIG_H */ diff --git a/lang/qt/src/dataprovider.cpp b/lang/qt/src/dataprovider.cpp deleted file mode 100644 index e376ca8d..00000000 --- a/lang/qt/src/dataprovider.cpp +++ /dev/null @@ -1,301 +0,0 @@ -/* dataprovider.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (C) 2004 Klarävdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -// -*- c++ -*- - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <dataprovider.h> - -#include <gpgme++/error.h> - -#include <QIODevice> -#include <QProcess> - -#include <cstdio> -#include <cstring> -#include <cassert> - -using namespace QGpgME; -using namespace GpgME; - -// -// -// QByteArrayDataProvider -// -// - -static bool resizeAndInit(QByteArray &ba, size_t newSize) -{ - const size_t oldSize = ba.size(); - ba.resize(newSize); - const bool ok = (newSize == static_cast<size_t>(ba.size())); - if (ok) { - memset(ba.data() + oldSize, 0, newSize - oldSize); - } - return ok; -} - -QByteArrayDataProvider::QByteArrayDataProvider() - : GpgME::DataProvider(), mOff(0) {} - -QByteArrayDataProvider::QByteArrayDataProvider(const QByteArray &initialData) - : GpgME::DataProvider(), mArray(initialData), mOff(0) {} - -QByteArrayDataProvider::~QByteArrayDataProvider() {} - -ssize_t QByteArrayDataProvider::read(void *buffer, size_t bufSize) -{ -#ifndef NDEBUG - //qDebug( "QByteArrayDataProvider::read( %p, %d )", buffer, bufSize ); -#endif - if (bufSize == 0) { - return 0; - } - if (!buffer) { - Error::setSystemError(GPG_ERR_EINVAL); - return -1; - } - if (mOff >= mArray.size()) { - return 0; // EOF - } - size_t amount = qMin(bufSize, static_cast<size_t>(mArray.size() - mOff)); - assert(amount > 0); - memcpy(buffer, mArray.data() + mOff, amount); - mOff += amount; - return amount; -} - -ssize_t QByteArrayDataProvider::write(const void *buffer, size_t bufSize) -{ -#ifndef NDEBUG - //qDebug( "QByteArrayDataProvider::write( %p, %lu )", buffer, static_cast<unsigned long>( bufSize ) ); -#endif - if (bufSize == 0) { - return 0; - } - if (!buffer) { - Error::setSystemError(GPG_ERR_EINVAL); - return -1; - } - if (mOff >= mArray.size()) { - resizeAndInit(mArray, mOff + bufSize); - } - if (mOff >= mArray.size()) { - Error::setSystemError(GPG_ERR_EIO); - return -1; - } - assert(bufSize <= static_cast<size_t>(mArray.size()) - mOff); - memcpy(mArray.data() + mOff, buffer, bufSize); - mOff += bufSize; - return bufSize; -} - -off_t QByteArrayDataProvider::seek(off_t offset, int whence) -{ -#ifndef NDEBUG - //qDebug( "QByteArrayDataProvider::seek( %d, %d )", int(offset), whence ); -#endif - int newOffset = mOff; - switch (whence) { - case SEEK_SET: - newOffset = offset; - break; - case SEEK_CUR: - newOffset += offset; - break; - case SEEK_END: - newOffset = mArray.size() + offset; - break; - default: - Error::setSystemError(GPG_ERR_EINVAL); - return (off_t) - 1; - } - return mOff = newOffset; -} - -void QByteArrayDataProvider::release() -{ -#ifndef NDEBUG - //qDebug( "QByteArrayDataProvider::release()" ); -#endif - mArray = QByteArray(); -} - -// -// -// QIODeviceDataProvider -// -// - -QIODeviceDataProvider::QIODeviceDataProvider(const std::shared_ptr<QIODevice> &io) - : GpgME::DataProvider(), - mIO(io), - mErrorOccurred(false), - mHaveQProcess(qobject_cast<QProcess *>(io.get())) -{ - assert(mIO); -} - -QIODeviceDataProvider::~QIODeviceDataProvider() {} - -bool QIODeviceDataProvider::isSupported(Operation op) const -{ - const QProcess *const proc = qobject_cast<QProcess *>(mIO.get()); - bool canRead = true; - if (proc) { - canRead = proc->readChannel() == QProcess::StandardOutput; - } - - switch (op) { - case Read: return mIO->isReadable() && canRead; - case Write: return mIO->isWritable(); - case Seek: return !mIO->isSequential(); - case Release: return true; - default: return false; - } -} - -static qint64 blocking_read(const std::shared_ptr<QIODevice> &io, char *buffer, qint64 maxSize) -{ - while (!io->bytesAvailable()) { - if (!io->waitForReadyRead(-1)) { - if (const QProcess *const p = qobject_cast<QProcess *>(io.get())) { - if (p->error() == QProcess::UnknownError && - p->exitStatus() == QProcess::NormalExit && - p->exitCode() == 0) { - if (io->atEnd()) { - // EOF - return 0; - } // continue reading even if process ended to ensure - // everything is read. - } else { - Error::setSystemError(GPG_ERR_EIO); - return -1; - } - } else { - return 0; // assume EOF (loses error cases :/ ) - } - } - } - return io->read(buffer, maxSize); -} - -ssize_t QIODeviceDataProvider::read(void *buffer, size_t bufSize) -{ -#ifndef NDEBUG - //qDebug( "QIODeviceDataProvider::read( %p, %lu )", buffer, bufSize ); -#endif - if (bufSize == 0) { - return 0; - } - if (!buffer) { - Error::setSystemError(GPG_ERR_EINVAL); - return -1; - } - const qint64 numRead = mHaveQProcess - ? blocking_read(mIO, static_cast<char *>(buffer), bufSize) - : mIO->read(static_cast<char *>(buffer), bufSize); - - //workaround: some QIODevices (known example: QProcess) might not return 0 (EOF), but immediately -1 when finished. If no - //errno is set, gpgme doesn't detect the error and loops forever. So return 0 on the very first -1 in case errno is 0 - - ssize_t rc = numRead; - if (numRead < 0 && !Error::hasSystemError()) { - if (mErrorOccurred) { - Error::setSystemError(GPG_ERR_EIO); - } else { - rc = 0; - } - } - if (numRead < 0) { - mErrorOccurred = true; - } - return rc; -} - -ssize_t QIODeviceDataProvider::write(const void *buffer, size_t bufSize) -{ -#ifndef NDEBUG - //qDebug( "QIODeviceDataProvider::write( %p, %lu )", buffer, static_cast<unsigned long>( bufSize ) ); -#endif - if (bufSize == 0) { - return 0; - } - if (!buffer) { - Error::setSystemError(GPG_ERR_EINVAL); - return -1; - } - - ssize_t ret = mIO->write(static_cast<const char *>(buffer), bufSize); - if (mHaveQProcess) { - /* XXX: With at least Qt 5.12 we have the problem that the acutal write - * would be triggered by an event / slot. So as we have moved the io - * device to our thread this is never triggered until the job is finished - * calling waitForBytesWritten internally triggers a _q_canWrite which will - * actually write. This is what we want as we want to stream and not to - * buffer endlessly. */ - qobject_cast<QProcess *>(mIO.get())->waitForBytesWritten(0); - } - return ret; -} - -off_t QIODeviceDataProvider::seek(off_t offset, int whence) -{ -#ifndef NDEBUG - //qDebug( "QIODeviceDataProvider::seek( %d, %d )", int(offset), whence ); -#endif - if (mIO->isSequential()) { - Error::setSystemError(GPG_ERR_ESPIPE); - return (off_t) - 1; - } - qint64 newOffset = mIO->pos(); - switch (whence) { - case SEEK_SET: - newOffset = offset; - break; - case SEEK_CUR: - newOffset += offset; - break; - case SEEK_END: - newOffset = mIO->size() + offset; - break; - default: - Error::setSystemError(GPG_ERR_EINVAL); - return (off_t) - 1; - } - if (!mIO->seek(newOffset)) { - Error::setSystemError(GPG_ERR_EINVAL); - return (off_t) - 1; - } - return newOffset; -} - -void QIODeviceDataProvider::release() -{ -#ifndef NDEBUG - //qDebug( "QIODeviceDataProvider::release()" ); -#endif - mIO->close(); -} diff --git a/lang/qt/src/dataprovider.h b/lang/qt/src/dataprovider.h deleted file mode 100644 index c0bd361b..00000000 --- a/lang/qt/src/dataprovider.h +++ /dev/null @@ -1,98 +0,0 @@ -/* dataprovider.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (C) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -// -*- c++ -*- -#ifndef __QGPGME_DATAPROVIDER_H__ -#define __QGPGME_DATAPROVIDER_H__ - -#include "qgpgme_export.h" - -#include <gpgme++/interfaces/dataprovider.h> - -#include <memory> - -#include <QtCore/QByteArray> - - -class QIODevice; - -namespace QGpgME -{ - -class QGPGME_EXPORT QByteArrayDataProvider : public GpgME::DataProvider -{ -public: - QByteArrayDataProvider(); - explicit QByteArrayDataProvider(const QByteArray &initialData); - ~QByteArrayDataProvider(); - - const QByteArray &data() const - { - return mArray; - } - -private: - // these shall only be accessed through the dataprovider - // interface, where they're public: - bool isSupported(Operation) const override - { - return true; - } - ssize_t read(void *buffer, size_t bufSize) override; - ssize_t write(const void *buffer, size_t bufSize) override; - off_t seek(off_t offset, int whence) override; - void release() override; - -private: - QByteArray mArray; - off_t mOff; -}; - -class QGPGME_EXPORT QIODeviceDataProvider : public GpgME::DataProvider -{ -public: - explicit QIODeviceDataProvider(const std::shared_ptr<QIODevice> &initialData); - ~QIODeviceDataProvider(); - - const std::shared_ptr<QIODevice> &ioDevice() const - { - return mIO; - } - -private: - // these shall only be accessed through the dataprovider - // interface, where they're public: - bool isSupported(Operation) const override; - ssize_t read(void *buffer, size_t bufSize) override; - ssize_t write(const void *buffer, size_t bufSize) override; - off_t seek(off_t offset, int whence) override; - void release() override; - -private: - const std::shared_ptr<QIODevice> mIO; - bool mErrorOccurred : 1; - bool mHaveQProcess : 1; -}; - -} // namespace QGpgME - -#endif diff --git a/lang/qt/src/debug.cpp b/lang/qt/src/debug.cpp deleted file mode 100644 index acde9d42..00000000 --- a/lang/qt/src/debug.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - debug.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2020 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <gpgme++/error.h> -#include "debug.h" - -#include <QDebug> - -QDebug operator<<(QDebug debug, const GpgME::Error &err) -{ -#ifdef Q_OS_WIN - // On Windows, we tell libgpg-error to return (translated) error messages as UTF-8 - const auto errAsString = QString::fromStdString(err.asStdString()); -#else - const auto errAsString = QString::fromLocal8Bit(err.asStdString().c_str()); -#endif - const bool oldSetting = debug.autoInsertSpaces(); - debug.nospace() << errAsString << " (code: " << err.code() << ", source: " << err.source() << ")"; - debug.setAutoInsertSpaces(oldSetting); - return debug.maybeSpace(); -} diff --git a/lang/qt/src/debug.h b/lang/qt/src/debug.h deleted file mode 100644 index 03894768..00000000 --- a/lang/qt/src/debug.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - debug.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2020 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef QGPGME_DEBUG_H -#define QGPGME_DEBUG_H - -#include "qgpgme_export.h" - -#include <sstream> - -namespace GpgME -{ -class Error; -} - -class QDebug; - -QGPGME_EXPORT QDebug operator<<(QDebug debug, const GpgME::Error &err); - -namespace QGpgME -{ -/** - * Helper to log GpgME objects which provide the output stream operator. - */ -template<class GpgMEClass> -std::string toLogString(const GpgMEClass &object) -{ - std::stringstream stream; - stream << object; - return stream.str(); -} -} - -#endif // QGPGME_DEBUG_H diff --git a/lang/qt/src/decryptjob.h b/lang/qt/src/decryptjob.h deleted file mode 100644 index 51954074..00000000 --- a/lang/qt/src/decryptjob.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - decryptjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004, 2007 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_DECRYPTJOB_H__ -#define __KLEO_DECRYPTJOB_H__ - -#include "job.h" - -#include <memory> - -class QByteArray; -class QIODevice; - -namespace GpgME -{ -class Error; -class DecryptionResult; -} - -namespace QGpgME -{ - -/** - @short An abstract base class for asynchronous decrypters - - To use a DecryptJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the decryption with a - call to start(). This call might fail, in which case the - DecryptJob instance will have scheduled it's own destruction with - a call to QObject::deleteLater(). - - After result() is emitted, the DecryptJob will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT DecryptJob : public Job -{ - Q_OBJECT -protected: - explicit DecryptJob(QObject *parent); -public: - ~DecryptJob(); - - /** - Starts the decryption operation. \a cipherText is the data to - decrypt. - */ - virtual GpgME::Error start(const QByteArray &cipherText) = 0; - - /*! - \overload - - If \a plainText is non-null, the plaintext is written - there. Otherwise, it will be delivered in the second argument - of result(). - */ - virtual void start(const std::shared_ptr<QIODevice> &cipherText, const std::shared_ptr<QIODevice> &plainText = std::shared_ptr<QIODevice>()) = 0; - - virtual GpgME::DecryptionResult exec(const QByteArray &cipherText, - QByteArray &plainText) = 0; - -Q_SIGNALS: - void result(const GpgME::DecryptionResult &result, const QByteArray &plainText, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __KLEO_DECRYPTJOB_H__ diff --git a/lang/qt/src/decryptverifyarchivejob.cpp b/lang/qt/src/decryptverifyarchivejob.cpp deleted file mode 100644 index d427e1fd..00000000 --- a/lang/qt/src/decryptverifyarchivejob.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - decryptverifyarchivejob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "decryptverifyarchivejob.h" -#include "decryptverifyarchivejob_p.h" - -#include <gpgme++/engineinfo.h> - -using namespace QGpgME; - -DecryptVerifyArchiveJob::DecryptVerifyArchiveJob(QObject *parent) - : Job{parent} -{ -} - -DecryptVerifyArchiveJob::~DecryptVerifyArchiveJob() = default; - -// static -bool DecryptVerifyArchiveJob::isSupported() -{ - static const auto gpgVersion = GpgME::engineInfo(GpgME::GpgEngine).engineVersion(); - return (gpgVersion >= "2.4.1") || (gpgVersion >= "2.2.42" && gpgVersion < "2.3.0"); -} - -void DecryptVerifyArchiveJob::setProcessAllSignatures (bool processAll) -{ - auto d = jobPrivate<DecryptVerifyArchiveJobPrivate>(this); - d->m_processAllSignatures = processAll; -} - -bool DecryptVerifyArchiveJob::processAllSignatures() const -{ - auto d = jobPrivate<DecryptVerifyArchiveJobPrivate>(this); - return d->m_processAllSignatures; -} - -void DecryptVerifyArchiveJob::setInputFile(const QString &path) -{ - auto d = jobPrivate<DecryptVerifyArchiveJobPrivate>(this); - d->m_inputFilePath = path; -} - -QString DecryptVerifyArchiveJob::inputFile() const -{ - auto d = jobPrivate<DecryptVerifyArchiveJobPrivate>(this); - return d->m_inputFilePath; -} - -void DecryptVerifyArchiveJob::setOutputDirectory(const QString &outputDirectory) -{ - auto d = jobPrivate<DecryptVerifyArchiveJobPrivate>(this); - d->m_outputDirectory = outputDirectory; -} - -QString DecryptVerifyArchiveJob::outputDirectory() const -{ - auto d = jobPrivate<DecryptVerifyArchiveJobPrivate>(this); - return d->m_outputDirectory; -} - -#include "decryptverifyarchivejob.moc" diff --git a/lang/qt/src/decryptverifyarchivejob.h b/lang/qt/src/decryptverifyarchivejob.h deleted file mode 100644 index 3139ae66..00000000 --- a/lang/qt/src/decryptverifyarchivejob.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - decryptverifyarchivejob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_DECRYPTVERIFYARCHIVEJOB_H__ -#define __QGPGME_DECRYPTVERIFYARCHIVEJOB_H__ - -#include "job.h" - -#include <gpgme++/context.h> - -namespace GpgME -{ -class Key; -} - -namespace QGpgME -{ - -/** - * Abstract base class for job for decrypting encrypted (signed) archives - */ -class QGPGME_EXPORT DecryptVerifyArchiveJob : public Job -{ - Q_OBJECT -protected: - explicit DecryptVerifyArchiveJob(QObject *parent); -public: - ~DecryptVerifyArchiveJob() override; - - static bool isSupported(); - - /** - * Enables processing of all signatures if \a processAll is true. - * - * By default, gpg (in batch mode used by GpgME) stops the verification of - * data signatures when a bad signature is encountered. This can be changed - * by setting this flag. It's equivalent to setting the context flag - * "proc-all-sigs". - * - * This is only supported for OpenPGP and requires GnuPG 2.2.45, 2.4.6, or - * 2.5.1. - */ - void setProcessAllSignatures(bool processAll); - bool processAllSignatures() const; - - /** - * Sets the path of the file to read the archive from. - * - * Used if the job is started with startIt(). - */ - void setInputFile(const QString &path); - QString inputFile() const; - - /** - * Sets the directory the content of the decrypted archive shall be - * written to. - */ - void setOutputDirectory(const QString &outputDirectory); - QString outputDirectory() const; - - /** - * Starts the decryption of an encrypted (and signed) archive. - * - * Decrypts and extracts the encrypted archive in \a cipherText. If the - * archive is signed, then the signature is verified. - * If a non-empty output directory was set, then the content of the archive - * is extracted into this directory. Otherwise, it is extracted into a - * directory named \c GPGARCH_n_ (where \c n is a number). - * - * Emits result() when the job has finished. - */ - virtual GpgME::Error start(const std::shared_ptr<QIODevice> &cipherText) = 0; - -Q_SIGNALS: - /** - * This signal is emitted whenever gpgtar sends a progress status update for - * the number of files. In the scanning phase (i.e. while gpgtar checks - * which files to put into the archive), \a current is the current number of - * files and \a total is 0. In the writing phase, \a current is the number - * of processed files and \a total is the total number of files. - */ - void fileProgress(int current, int total); - - /** - * This signal is emitted whenever gpgtar sends a progress status update for - * the amount of processed data. It is only emitted in the writing phase. - * \a current is the processed amount data and \a total is the total amount - * of data to process. Both values never exceed 2^20. - */ - void dataProgress(int current, int total); - - void result(const GpgME::DecryptionResult &decryptionResult, - const GpgME::VerificationResult &verificationResult, - const QString &auditLogAsHtml = {}, - const GpgME::Error &auditLogError = {}); -}; - -} - -#endif // __QGPGME_DECRYPTVERIFYARCHIVEJOB_H__ diff --git a/lang/qt/src/decryptverifyarchivejob_p.h b/lang/qt/src/decryptverifyarchivejob_p.h deleted file mode 100644 index bce093db..00000000 --- a/lang/qt/src/decryptverifyarchivejob_p.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - decryptverifyarchivejob_p.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_DECRYPTVERIFYARCHIVEJOB_P_H__ -#define __QGPGME_DECRYPTVERIFYARCHIVEJOB_P_H__ - -#include "job_p.h" - -namespace QGpgME -{ - -struct DecryptVerifyArchiveJobPrivate : public JobPrivate -{ - QString m_inputFilePath; - QString m_outputDirectory; - bool m_processAllSignatures = false; -}; - -} - -#endif // __QGPGME_DECRYPTVERIFYARCHIVEJOB_P_H__ diff --git a/lang/qt/src/decryptverifyjob.cpp b/lang/qt/src/decryptverifyjob.cpp deleted file mode 100644 index f96305b9..00000000 --- a/lang/qt/src/decryptverifyjob.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - decryptverifyjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "decryptverifyjob.h" -#include "decryptverifyjob_p.h" - -using namespace QGpgME; - -DecryptVerifyJob::DecryptVerifyJob(QObject *parent) - : Job{parent} -{ -} - -DecryptVerifyJob::~DecryptVerifyJob() = default; - -void DecryptVerifyJob::setProcessAllSignatures (bool processAll) -{ - auto d = jobPrivate<DecryptVerifyJobPrivate>(this); - d->m_processAllSignatures = processAll; -} - -bool DecryptVerifyJob::processAllSignatures() const -{ - auto d = jobPrivate<DecryptVerifyJobPrivate>(this); - return d->m_processAllSignatures; -} - -void DecryptVerifyJob::setInputFile(const QString &path) -{ - auto d = jobPrivate<DecryptVerifyJobPrivate>(this); - d->m_inputFilePath = path; -} - -QString DecryptVerifyJob::inputFile() const -{ - auto d = jobPrivate<DecryptVerifyJobPrivate>(this); - return d->m_inputFilePath; -} - -void DecryptVerifyJob::setOutputFile(const QString &path) -{ - auto d = jobPrivate<DecryptVerifyJobPrivate>(this); - d->m_outputFilePath = path; -} - -QString DecryptVerifyJob::outputFile() const -{ - auto d = jobPrivate<DecryptVerifyJobPrivate>(this); - return d->m_outputFilePath; -} - -#include "decryptverifyjob.moc" diff --git a/lang/qt/src/decryptverifyjob.h b/lang/qt/src/decryptverifyjob.h deleted file mode 100644 index 73dbea15..00000000 --- a/lang/qt/src/decryptverifyjob.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - decryptverifyjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004, 2007 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_DECRYPTVERIFYJOB_H__ -#define __KLEO_DECRYPTVERIFYJOB_H__ - -#include "job.h" - -#include <memory> - -class QByteArray; -class QIODevice; - -namespace GpgME -{ -class Error; -class DecryptionResult; -class VerificationResult; -} - -namespace QGpgME -{ - -/** - @short An abstract base class for asynchronous combined decrypters and verifiers - - To use a DecryptVerifyJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the operation with a - call to start(). This call might fail, in which case the - DecryptVerifyJob instance will have scheduled it's own destruction with - a call to QObject::deleteLater(). - - Alternatively, the job can be started with startIt() after setting - an input file and an output file. If the job is started this way then - the backend reads the input and writes the output directly from/to the - specified input file and output file. In this case the plainText value of - the result signal will always be empty. This direct IO mode is currently - only supported for OpenPGP. Note that startIt() does not schedule the job's - destruction if starting the job failed. - - After result() is emitted, the DecryptVerifyJob will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT DecryptVerifyJob : public Job -{ - Q_OBJECT -protected: - explicit DecryptVerifyJob(QObject *parent); -public: - ~DecryptVerifyJob() override; - - /** - * Enables processing of all signatures if \a processAll is true. - * - * By default, gpg (in batch mode used by GpgME) stops the verification of - * data signatures when a bad signature is encountered. This can be changed - * by setting this flag. It's equivalent to setting the context flag - * "proc-all-sigs". - * - * This is only supported for OpenPGP and requires GnuPG 2.2.45, 2.4.6, or - * 2.5.1. - */ - void setProcessAllSignatures(bool processAll); - bool processAllSignatures() const; - - /** - * Sets the path of the file to decrypt (and verify). - * - * Used if the job is started with startIt(). - */ - void setInputFile(const QString &path); - QString inputFile() const; - - /** - * Sets the path of the file to write the result to. - * - * Used if the job is started with startIt(). - * - * \note If a file with this path exists, then the job will fail, i.e. you - * need to delete an existing file that shall be overwritten before you - * start the job. - */ - void setOutputFile(const QString &path); - QString outputFile() const; - - /** - Starts the combined decryption and verification operation. - \a cipherText is the data to decrypt and later verify. - */ - virtual GpgME::Error start(const QByteArray &cipherText) = 0; - - /*! - \overload - - If \a plainText is non-null, the plaintext is written - there. Otherwise, it will be delivered in the third argument - of result(). - */ - virtual void start(const std::shared_ptr<QIODevice> &cipherText, const std::shared_ptr<QIODevice> &plainText = std::shared_ptr<QIODevice>()) = 0; - - /** Synchronous equivalent of start() */ - virtual std::pair<GpgME::DecryptionResult, GpgME::VerificationResult> - exec(const QByteArray &cipherText, QByteArray &plainText) = 0; - -Q_SIGNALS: - void result(const GpgME::DecryptionResult &decryptionresult, - const GpgME::VerificationResult &verificationresult, - const QByteArray &plainText, const QString &auditLogAsHtml = QString(), - const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __KLEO_DECRYPTVERIFYJOB_H__ diff --git a/lang/qt/src/decryptverifyjob_p.h b/lang/qt/src/decryptverifyjob_p.h deleted file mode 100644 index 10701da1..00000000 --- a/lang/qt/src/decryptverifyjob_p.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - decryptverifyjob_p.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_DECRYPTVERIFYJOB_P_H__ -#define __QGPGME_DECRYPTVERIFYJOB_P_H__ - -#include "job_p.h" - -namespace QGpgME -{ - -struct DecryptVerifyJobPrivate : public JobPrivate -{ - QString m_inputFilePath; - QString m_outputFilePath; - bool m_processAllSignatures = false; -}; - -} - -#endif // __QGPGME_DECRYPTVERIFYJOB_P_H__ diff --git a/lang/qt/src/defaultkeygenerationjob.cpp b/lang/qt/src/defaultkeygenerationjob.cpp deleted file mode 100644 index f589384e..00000000 --- a/lang/qt/src/defaultkeygenerationjob.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* defaultkeygenerationjob.cpp - - Copyright (c) 2016 Klarälvdalens Datakonsult AB - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "defaultkeygenerationjob.h" -#include "protocol.h" -#include "keygenerationjob.h" - -#include <QPointer> -#include <QEvent> - -using namespace QGpgME; - -namespace QGpgME { - -class DefaultKeyGenerationJob::Private -{ -public: - Private() - {} - - ~Private() - { - if (job) { - job->deleteLater(); - } - } - - QPointer<KeyGenerationJob> job; -}; -} - - -DefaultKeyGenerationJob::DefaultKeyGenerationJob(QObject* parent) - : Job(parent) - , d(new DefaultKeyGenerationJob::Private()) -{ -} - -DefaultKeyGenerationJob::~DefaultKeyGenerationJob() -{ - delete d; -} - -QString DefaultKeyGenerationJob::auditLogAsHtml() const -{ - return d->job ? d->job->auditLogAsHtml() : QString(); -} - -GpgME::Error DefaultKeyGenerationJob::auditLogError() const -{ - return d->job ? d->job->auditLogError() : GpgME::Error(); -} - -void DefaultKeyGenerationJob::slotCancel() -{ - if (d->job) { - d->job->slotCancel(); - } -} - -GpgME::Error DefaultKeyGenerationJob::start(const QString &email, const QString &name) -{ - const QString namePart = name.isEmpty() ? QString() : - QStringLiteral("name-real: %1\n").arg(name); - const QString mailPart = email.isEmpty() ? QString() : - QStringLiteral("name-email: %1\n").arg(email); - - const QString args = QStringLiteral("<GnupgKeyParms format=\"internal\">\n" - "%ask-passphrase\n" - "key-type: RSA\n" - "key-length: 2048\n" - "key-usage: sign\n" - "subkey-type: RSA\n" - "subkey-length: 2048\n" - "subkey-usage: encrypt\n" - "%1" - "%2" - "</GnupgKeyParms>").arg(mailPart, namePart); - - d->job = openpgp()->keyGenerationJob(); - d->job->installEventFilter(this); - connect(d->job.data(), &KeyGenerationJob::result, - this, &DefaultKeyGenerationJob::result); - connect(d->job.data(), &KeyGenerationJob::done, - this, &DefaultKeyGenerationJob::done); - connect(d->job.data(), &KeyGenerationJob::done, - this, &QObject::deleteLater); - return d->job->start(args); -} - -bool DefaultKeyGenerationJob::eventFilter(QObject *watched, QEvent *event) -{ - // Intercept the KeyGenerationJob's deferred delete event. We want the job - // to live at least as long as we do so we can delegate calls to it. We will - // delete the job manually afterwards. - if (watched == d->job && event->type() == QEvent::DeferredDelete) { - return true; - } - - return Job::eventFilter(watched, event); -} - -#include "defaultkeygenerationjob.moc" diff --git a/lang/qt/src/defaultkeygenerationjob.h b/lang/qt/src/defaultkeygenerationjob.h deleted file mode 100644 index c59e0c6d..00000000 --- a/lang/qt/src/defaultkeygenerationjob.h +++ /dev/null @@ -1,80 +0,0 @@ -/* defaultkeygenerationjob.h - - Copyright (c) 2016 Klarälvdalens Datakonsult AB - 2016 Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifndef QGPGME_DEFAULTKEYGENERATION_H -#define QGPGME_DEFAULTKEYGENERATION_H - -#include "job.h" - -#include "qgpgme_export.h" - -namespace GpgME { -class KeyGenerationResult; -} - -namespace QGpgME{ - -/** - * Generates a PGP RSA/2048 bit key pair for given name and email address. - * - * This job is deprecated. Use QuickJob::startCreate instead. - */ -class QGPGME_DEPRECATED_EXPORT DefaultKeyGenerationJob : public Job -{ - Q_OBJECT -public: - explicit DefaultKeyGenerationJob(QObject *parent = nullptr); - ~DefaultKeyGenerationJob(); - - GpgME::Error start(const QString &email, const QString &name); - - QString auditLogAsHtml() const override; - GpgME::Error auditLogError() const override; - - -public Q_SLOTS: - void slotCancel() override; - -Q_SIGNALS: - void result(const GpgME::KeyGenerationResult &result, const QByteArray &pubkeyData, - const QString &auditLogAsHtml, const GpgME::Error &auditLogError); - -protected: - bool eventFilter(QObject *watched, QEvent *event) override; - -private: - class Private; - Private * const d; -}; - -} - -#endif diff --git a/lang/qt/src/deletejob.h b/lang/qt/src/deletejob.h deleted file mode 100644 index 7ab0dd05..00000000 --- a/lang/qt/src/deletejob.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - deletejob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_DELETEJOB_H__ -#define __KLEO_DELETEJOB_H__ - -#include "qgpgme_export.h" -#include "job.h" - -namespace GpgME -{ -class Error; -class Key; -} - -namespace QGpgME -{ - -/** - @short An abstract base class for asynchronous deleters - - To use a DeleteJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the delete with a call - to start(). This call might fail, in which case the DeleteJob - instance will have scheduled it's own destruction with a call to - QObject::deleteLater(). - - After result() is emitted, the DeleteJob will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT DeleteJob : public Job -{ - Q_OBJECT -protected: - explicit DeleteJob(QObject *parent); -public: - ~DeleteJob(); - - /** - Starts the delete operation. \a key represents the key to - delete, \a allowSecretKeyDeletion specifies if a key may also - be deleted if the secret key part is available, too. - */ - virtual GpgME::Error start(const GpgME::Key &key, bool allowSecretKeyDeletion = false) = 0; - -Q_SIGNALS: - void result(const GpgME::Error &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __KLEO_DELETEJOB_H__ diff --git a/lang/qt/src/dn.cpp b/lang/qt/src/dn.cpp deleted file mode 100644 index 836158b0..00000000 --- a/lang/qt/src/dn.cpp +++ /dev/null @@ -1,497 +0,0 @@ -/* - dn.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "dn.h" - -#include <gpg-error.h> - -static const struct { - const char *name; - const char *oid; -} oidmap[] = { - // keep them ordered by oid: - { "SP", "ST" }, // hack to show the Sphinx-required/desired SP for - // StateOrProvince, otherwise known as ST or even S - { "NameDistinguisher", "0.2.262.1.10.7.20" }, - { "EMAIL", "1.2.840.113549.1.9.1" }, - { "SN", "2.5.4.4" }, - { "SerialNumber", "2.5.4.5" }, - { "T", "2.5.4.12" }, - { "D", "2.5.4.13" }, - { "BC", "2.5.4.15" }, - { "ADDR", "2.5.4.16" }, - { "PC", "2.5.4.17" }, - { "GN", "2.5.4.42" }, - { "Pseudo", "2.5.4.65" }, -}; -static const unsigned int numOidMaps = sizeof oidmap / sizeof * oidmap; - -class QGpgME::DN::Private -{ -public: - Private() : mRefCount(0) {} - Private(const Private &other) - : attributes(other.attributes), - reorderedAttributes(other.reorderedAttributes), - order{"CN", "L", "_X_", "OU", "O", "C"}, - mRefCount(0) - { - } - - int ref() - { - return ++mRefCount; - } - - int unref() - { - if (--mRefCount <= 0) { - delete this; - return 0; - } else { - return mRefCount; - } - } - - int refCount() const - { - return mRefCount; - } - - DN::Attribute::List attributes; - DN::Attribute::List reorderedAttributes; - QStringList order; -private: - int mRefCount; -}; - -namespace -{ -struct DnPair { - char *key; - char *value; -}; -} - -// copied from CryptPlug and adapted to work on DN::Attribute::List: - -#define digitp(p) (*(p) >= '0' && *(p) <= '9') -#define hexdigitp(a) (digitp (a) \ - || (*(a) >= 'A' && *(a) <= 'F') \ - || (*(a) >= 'a' && *(a) <= 'f')) -#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \ - *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10)) -#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1)) - -static char * -trim_trailing_spaces(char *string) -{ - char *p, *mark; - - for (mark = NULL, p = string; *p; p++) { - if (isspace(*p)) { - if (!mark) { - mark = p; - } - } else { - mark = NULL; - } - } - if (mark) { - *mark = '\0'; - } - - return string; -} - -/* Parse a DN and return an array-ized one. This is not a validating - parser and it does not support any old-stylish syntax; gpgme is - expected to return only rfc2253 compatible strings. */ -static const unsigned char * -parse_dn_part(DnPair *array, const unsigned char *string) -{ - const unsigned char *s, *s1; - size_t n; - char *p; - - /* parse attributeType */ - for (s = string + 1; *s && *s != '='; s++) - ; - if (!*s) { - return NULL; /* error */ - } - n = s - string; - if (!n) { - return NULL; /* empty key */ - } - p = (char *)malloc(n + 1); - - memcpy(p, string, n); - p[n] = 0; - trim_trailing_spaces((char *)p); - // map OIDs to their names: - for (unsigned int i = 0; i < numOidMaps; ++i) - if (!strcasecmp((char *)p, oidmap[i].oid)) { - free(p); - gpgrt_asprintf(&p, "%s", oidmap[i].name); - break; - } - array->key = p; - string = s + 1; - - if (*string == '#') { - /* hexstring */ - string++; - for (s = string; hexdigitp(s); s++) - ; - n = s - string; - if (!n || (n & 1)) { - return NULL; /* empty or odd number of digits */ - } - n /= 2; - array->value = p = (char *)malloc(n + 1); - - for (s1 = string; n; s1 += 2, n--) { - *p++ = xtoi_2(s1); - } - *p = 0; - } else { - /* regular v3 quoted string */ - for (n = 0, s = string; *s; s++) { - if (*s == '\\') { - /* pair */ - s++; - if (*s == ',' || *s == '=' || *s == '+' - || *s == '<' || *s == '>' || *s == '#' || *s == ';' - || *s == '\\' || *s == '\"' || *s == ' ') { - n++; - } else if (hexdigitp(s) && hexdigitp(s + 1)) { - s++; - n++; - } else { - return NULL; /* invalid escape sequence */ - } - } else if (*s == '\"') { - return NULL; /* invalid encoding */ - } else if (*s == ',' || *s == '=' || *s == '+' - || *s == '<' || *s == '>' || *s == '#' || *s == ';') { - break; - } else { - n++; - } - } - - array->value = p = (char *)malloc(n + 1); - - for (s = string; n; s++, n--) { - if (*s == '\\') { - s++; - if (hexdigitp(s)) { - *p++ = xtoi_2(s); - s++; - } else { - *p++ = *s; - } - } else { - *p++ = *s; - } - } - *p = 0; - } - return s; -} - -/* Parse a DN and return an array-ized one. This is not a validating - parser and it does not support any old-stylish syntax; gpgme is - expected to return only rfc2253 compatible strings. */ -static QGpgME::DN::Attribute::List -parse_dn(const unsigned char *string) -{ - if (!string) { - return QVector<QGpgME::DN::Attribute>(); - } - - QVector<QGpgME::DN::Attribute> result; - while (*string) { - while (*string == ' ') { - string++; - } - if (!*string) { - break; /* ready */ - } - - DnPair pair = { nullptr, nullptr }; - string = parse_dn_part(&pair, string); - if (!string) { - goto failure; - } - if (pair.key && pair.value) - result.push_back(QGpgME::DN::Attribute(QString::fromUtf8(pair.key), - QString::fromUtf8(pair.value))); - free(pair.key); - free(pair.value); - - while (*string == ' ') { - string++; - } - if (*string && *string != ',' && *string != ';' && *string != '+') { - goto failure; /* invalid delimiter */ - } - if (*string) { - string++; - } - } - return result; - -failure: - return QVector<QGpgME::DN::Attribute>(); -} - -static QVector<QGpgME::DN::Attribute> -parse_dn(const QString &dn) -{ - return parse_dn((const unsigned char *)dn.toUtf8().data()); -} - -static QString dn_escape(const QString &s) -{ - QString result; - for (unsigned int i = 0, end = s.length(); i != end; ++i) { - const QChar ch = s[i]; - switch (ch.unicode()) { - case ',': - case '+': - case '"': - case '\\': - case '<': - case '>': - case ';': - result += QLatin1Char('\\'); - // fall through - default: - result += ch; - } - } - return result; -} - -static QString -serialise(const QVector<QGpgME::DN::Attribute> &dn, const QString &sep) -{ - QStringList result; - for (QVector<QGpgME::DN::Attribute>::const_iterator it = dn.begin(); it != dn.end(); ++it) - if (!(*it).name().isEmpty() && !(*it).value().isEmpty()) { - result.push_back((*it).name().trimmed() + QLatin1Char('=') + dn_escape((*it).value().trimmed())); - } - return result.join(sep); -} - -static QGpgME::DN::Attribute::List -reorder_dn(const QGpgME::DN::Attribute::List &dn, const QStringList &attrOrder) -{ - QGpgME::DN::Attribute::List unknownEntries; - QGpgME::DN::Attribute::List result; - unknownEntries.reserve(dn.size()); - result.reserve(dn.size()); - - // find all unknown entries in their order of appearance - for (QGpgME::DN::const_iterator it = dn.begin(); it != dn.end(); ++it) - if (!attrOrder.contains((*it).name())) { - unknownEntries.push_back(*it); - } - - // process the known attrs in the desired order - for (QStringList::const_iterator oit = attrOrder.begin(); oit != attrOrder.end(); ++oit) - if (*oit == QLatin1String("_X_")) { - // insert the unknown attrs - std::copy(unknownEntries.begin(), unknownEntries.end(), - std::back_inserter(result)); - unknownEntries.clear(); // don't produce dup's - } else { - for (QGpgME::DN::const_iterator dnit = dn.begin(); dnit != dn.end(); ++dnit) - if ((*dnit).name() == *oit) { - result.push_back(*dnit); - } - } - - return result; -} - -// -// -// class DN -// -// - -QGpgME::DN::DN() -{ - d = new Private(); - d->ref(); -} - -QGpgME::DN::DN(const QString &dn) -{ - d = new Private(); - d->ref(); - d->attributes = parse_dn(dn); -} - -QGpgME::DN::DN(const char *utf8DN) -{ - d = new Private(); - d->ref(); - if (utf8DN) { - d->attributes = parse_dn((const unsigned char *)utf8DN); - } -} - -QGpgME::DN::DN(const DN &other) - : d(other.d) -{ - if (d) { - d->ref(); - } -} - -QGpgME::DN::~DN() -{ - if (d) { - d->unref(); - } -} - -const QGpgME::DN &QGpgME::DN::operator=(const DN &that) -{ - if (this->d == that.d) { - return *this; - } - - if (that.d) { - that.d->ref(); - } - if (this->d) { - this->d->unref(); - } - - this->d = that.d; - - return *this; -} - -QString QGpgME::DN::prettyDN() const -{ - if (!d) { - return QString(); - } - if (d->reorderedAttributes.empty()) { - d->reorderedAttributes = reorder_dn(d->attributes, d->order); - } - return serialise(d->reorderedAttributes, QStringLiteral(",")); -} - -QString QGpgME::DN::dn() const -{ - return d ? serialise(d->attributes, QStringLiteral(",")) : QString(); -} - -QString QGpgME::DN::dn(const QString &sep) const -{ - return d ? serialise(d->attributes, sep) : QString(); -} - -// static -QString QGpgME::DN::escape(const QString &value) -{ - return dn_escape(value); -} - -void QGpgME::DN::detach() -{ - if (!d) { - d = new QGpgME::DN::Private(); - d->ref(); - } else if (d->refCount() > 1) { - QGpgME::DN::Private *d_save = d; - d = new QGpgME::DN::Private(*d); - d->ref(); - d_save->unref(); - } -} - -void QGpgME::DN::append(const Attribute &attr) -{ - detach(); - d->attributes.push_back(attr); - d->reorderedAttributes.clear(); -} - -QString QGpgME::DN::operator[](const QString &attr) const -{ - if (!d) { - return QString(); - } - const QString attrUpper = attr.toUpper(); - for (QVector<Attribute>::const_iterator it = d->attributes.constBegin(); - it != d->attributes.constEnd(); ++it) - if ((*it).name() == attrUpper) { - return (*it).value(); - } - return QString(); -} - -static QVector<QGpgME::DN::Attribute> empty; - -QGpgME::DN::const_iterator QGpgME::DN::begin() const -{ - return d ? d->attributes.constBegin() : empty.constBegin(); -} - -QGpgME::DN::const_iterator QGpgME::DN::end() const -{ - return d ? d->attributes.constEnd() : empty.constEnd(); -} - -void QGpgME::DN::setAttributeOrder (const QStringList &order) const -{ - d->order = order; -} - -const QStringList & QGpgME::DN::attributeOrder () const -{ - return d->order; -} diff --git a/lang/qt/src/dn.h b/lang/qt/src/dn.h deleted file mode 100644 index 2d655c55..00000000 --- a/lang/qt/src/dn.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - dn.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifndef QGPGME_DN_H -#define QGPGME_DN_H - -#include "qgpgme_export.h" - -#include <QString> -#include <QStringList> - -#include <QVector> - -namespace QGpgME -{ - -/** - @short DN parser and reorderer -*/ -class QGPGME_EXPORT DN -{ -public: - class Attribute; - typedef QVector<Attribute> AttributeList; - typedef AttributeList::const_iterator const_iterator; - - DN(); - explicit DN(const QString &dn); - explicit DN(const char *utf8DN); - DN(const DN &other); - ~DN(); - - const DN &operator=(const DN &other); - - /** @return the value in rfc-2253-escaped form */ - static QString escape(const QString &value); - - /** @return the DN in a reordered form, according to the settings in - the [DN] group of the application's config file */ - QString prettyDN() const; - /** @return the DN in the original form */ - QString dn() const; - /** - \overload - Uses \a sep as separator (default: ,) - */ - QString dn(const QString &sep) const; - - QString operator[](const QString &attr) const; - - void append(const Attribute &attr); - - const_iterator begin() const; - const_iterator end() const; - - /** Set the order in which prettyDN will reorder the Attributes. */ - void setAttributeOrder(const QStringList &order) const; - - /** Get the used attribute order. */ - const QStringList & attributeOrder() const; - -private: - void detach(); -private: - class Private; - Private *d; -}; - -class QGPGME_EXPORT DN::Attribute -{ -public: - typedef DN::AttributeList List; - - explicit Attribute(const QString &name = QString(), const QString &value = QString()) - : mName(name.toUpper()), mValue(value) {} - Attribute(const Attribute &other) - : mName(other.name()), mValue(other.value()) {} - - const Attribute &operator=(const Attribute &other) - { - if (this != &other) { - mName = other.name(); - mValue = other.value(); - } - return *this; - } - - const QString &name() const - { - return mName; - } - const QString &value() const - { - return mValue; - } - - void setValue(const QString &value) - { - mValue = value; - } - -private: - QString mName; - QString mValue; -}; -} // namespace QGpgME -#endif // QGPGME_DN_H diff --git a/lang/qt/src/downloadjob.h b/lang/qt/src/downloadjob.h deleted file mode 100644 index dc1201ee..00000000 --- a/lang/qt/src/downloadjob.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - downloadjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_DOWNLOADJOB_H__ -#define __KLEO_DOWNLOADJOB_H__ - -#include "job.h" - -#include <QtCore/QByteArray> -#include <QtCore/QStringList> - -#include <memory> - -namespace GpgME -{ -class Error; -} - -class QIODevice; -class QByteArray; - -namespace QGpgME -{ - -/** - @short An abstract base class for asynchronous downloaders - - To use a DownloadJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the download with a call - to start(). This call might fail, in which case the DownloadJob - instance will have scheduled it's own destruction with a call to - QObject::deleteLater(). - - After result() is emitted, the DownloadJob will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT DownloadJob : public Job -{ - Q_OBJECT -protected: - explicit DownloadJob(QObject *parent); -public: - ~DownloadJob(); - - /** - Starts the download operation. \a fingerprint is the - fingerprint of the key to download. If \a fingerprint is empty, - contains only whitespace or anything other than a fingerprint, - the result is undefined. - - Output is written to \a keyData, if given. Otherwise, it is - passed as the second argument of result(). - */ - virtual GpgME::Error start(const QByteArray &fingerprint, - const std::shared_ptr<QIODevice> &keyData) = 0; - - /** - Starts the download operation. \a fingerprints is a list of - fingerprints used to specify the list of keys downloaded. Empty - patterns are ignored. If \a fingerprints is empty, contains - only empty strings or anything other than fingerprints, the - result is undefined. - */ - QGPGME_DEPRECATED virtual GpgME::Error start(const QStringList &fingerprints) = 0; - -Q_SIGNALS: - void result(const GpgME::Error &result, const QByteArray &keyData, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __KLEO_DOWNLOADJOB_H__ diff --git a/lang/qt/src/encryptarchivejob.cpp b/lang/qt/src/encryptarchivejob.cpp deleted file mode 100644 index f4cf288f..00000000 --- a/lang/qt/src/encryptarchivejob.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - encryptarchivejob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "encryptarchivejob.h" -#include "encryptarchivejob_p.h" - -#include <gpgme++/engineinfo.h> - -using namespace QGpgME; - -EncryptArchiveJob::EncryptArchiveJob(QObject *parent) - : Job{parent} -{ -} - -EncryptArchiveJob::~EncryptArchiveJob() = default; - -// static -bool EncryptArchiveJob::isSupported() -{ - static const auto gpgVersion = GpgME::engineInfo(GpgME::GpgEngine).engineVersion(); - return (gpgVersion >= "2.4.1") || (gpgVersion >= "2.2.42" && gpgVersion < "2.3.0"); -} - -void EncryptArchiveJob::setRecipients(const std::vector<GpgME::Key> &recipients) -{ - auto d = jobPrivate<EncryptArchiveJobPrivate>(this); - d->m_recipients = recipients; -} - -std::vector<GpgME::Key> EncryptArchiveJob::recipients() const -{ - auto d = jobPrivate<EncryptArchiveJobPrivate>(this); - return d->m_recipients; -} - -void EncryptArchiveJob::setInputPaths(const std::vector<QString> &paths) -{ - auto d = jobPrivate<EncryptArchiveJobPrivate>(this); - d->m_inputPaths = paths; -} - -std::vector<QString> EncryptArchiveJob::inputPaths() const -{ - auto d = jobPrivate<EncryptArchiveJobPrivate>(this); - return d->m_inputPaths; -} - -void EncryptArchiveJob::setOutputFile(const QString &path) -{ - auto d = jobPrivate<EncryptArchiveJobPrivate>(this); - d->m_outputFilePath = path; -} - -QString EncryptArchiveJob::outputFile() const -{ - auto d = jobPrivate<EncryptArchiveJobPrivate>(this); - return d->m_outputFilePath; -} - -void EncryptArchiveJob::setEncryptionFlags(GpgME::Context::EncryptionFlags flags) -{ - auto d = jobPrivate<EncryptArchiveJobPrivate>(this); - d->m_encryptionFlags = static_cast<GpgME::Context::EncryptionFlags>(flags | GpgME::Context::EncryptArchive); -} - -GpgME::Context::EncryptionFlags EncryptArchiveJob::encryptionFlags() const -{ - auto d = jobPrivate<EncryptArchiveJobPrivate>(this); - return d->m_encryptionFlags; -} - -void EncryptArchiveJob::setBaseDirectory(const QString &baseDirectory) -{ - auto d = jobPrivate<EncryptArchiveJobPrivate>(this); - d->m_baseDirectory = baseDirectory; -} - -QString EncryptArchiveJob::baseDirectory() const -{ - auto d = jobPrivate<EncryptArchiveJobPrivate>(this); - return d->m_baseDirectory; -} - -#include "encryptarchivejob.moc" diff --git a/lang/qt/src/encryptarchivejob.h b/lang/qt/src/encryptarchivejob.h deleted file mode 100644 index bba8acb6..00000000 --- a/lang/qt/src/encryptarchivejob.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - encryptarchivejob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_ENCRYPTARCHIVEJOB_H__ -#define __QGPGME_ENCRYPTARCHIVEJOB_H__ - -#include "job.h" - -#include <gpgme++/context.h> - -namespace GpgME -{ -class Key; -} - -namespace QGpgME -{ - -/** - * Abstract base class for job for creating encrypted archives - */ -class QGPGME_EXPORT EncryptArchiveJob : public Job -{ - Q_OBJECT -protected: - explicit EncryptArchiveJob(QObject *parent); -public: - ~EncryptArchiveJob() override; - - static bool isSupported(); - - /** - * Sets the keys to use for encrypting the archive. - * - * Used if the job is started with startIt(). - */ - void setRecipients(const std::vector<GpgME::Key> &recipients); - std::vector<GpgME::Key> recipients() const; - - /** - * Sets the paths of the files and folders to put into the archive. - * - * If base directory is set, then the paths must be relative to the - * base directory. - * - * Used if the job is started with startIt(). - */ - void setInputPaths(const std::vector<QString> &paths); - std::vector<QString> inputPaths() const; - - /** - * Sets the path of the file to write the created archive to. - * - * If \a path is a relative path and base directory is set, then the - * path is interpreted relative to the base directory. - * - * Used if the job is started with startIt(). - * - * \note If a file with this path exists, then the job will fail, i.e. you - * need to delete an existing file that shall be overwritten before you - * start the job. - */ - void setOutputFile(const QString &path); - QString outputFile() const; - - /** - * Sets the flags to use for encryption. Defaults to \c EncryptArchive. - * The \c EncryptArchive flag is always assumed set for this job. - * - * Used if the job is started with startIt(). - */ - void setEncryptionFlags(GpgME::Context::EncryptionFlags flags); - GpgME::Context::EncryptionFlags encryptionFlags() const; - - /** - * Sets the base directory for the relative paths of the input files and - * the output file. - */ - void setBaseDirectory(const QString &baseDirectory); - QString baseDirectory() const; - - /** - * Starts the creation of an encrypted archive. - * - * Encrypts the files and directories in \a paths into an archive for the - * keys in \a recipients. If \a recipients is empty, then symmetric - * encryption is performed. The encrypted archive is written to \a cipherText. - * - * Emits result() when the job has finished. - */ - virtual GpgME::Error start(const std::vector<GpgME::Key> &recipients, - const std::vector<QString> &paths, - const std::shared_ptr<QIODevice> &cipherText, - const GpgME::Context::EncryptionFlags flags) = 0; - -Q_SIGNALS: - /** - * This signal is emitted whenever gpgtar sends a progress status update for - * the number of files. In the scanning phase (i.e. while gpgtar checks - * which files to put into the archive), \a current is the current number of - * files and \a total is 0. In the writing phase, \a current is the number - * of processed files and \a total is the total number of files. - */ - void fileProgress(int current, int total); - - /** - * This signal is emitted whenever gpgtar sends a progress status update for - * the amount of processed data. It is only emitted in the writing phase. - * \a current is the processed amount data and \a total is the total amount - * of data to process. Both values never exceed 2^20. - */ - void dataProgress(int current, int total); - - void result(const GpgME::EncryptionResult &result, - const QString &auditLogAsHtml = {}, - const GpgME::Error &auditLogError = {}); -}; - -} - -#endif // __QGPGME_ENCRYPTARCHIVEJOB_H__ diff --git a/lang/qt/src/encryptarchivejob_p.h b/lang/qt/src/encryptarchivejob_p.h deleted file mode 100644 index f2d5eea9..00000000 --- a/lang/qt/src/encryptarchivejob_p.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - encryptarchivejob_p.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_ENCRYPTARCHIVEJOB_P_H__ -#define __QGPGME_ENCRYPTARCHIVEJOB_P_H__ - -#include "job_p.h" - -namespace QGpgME -{ - -struct EncryptArchiveJobPrivate : public JobPrivate -{ - std::vector<GpgME::Key> m_recipients; - std::vector<QString> m_inputPaths; - QString m_outputFilePath; - QString m_baseDirectory; - GpgME::Context::EncryptionFlags m_encryptionFlags = GpgME::Context::EncryptArchive; -}; - -} - -#endif // __QGPGME_ENCRYPTARCHIVEJOB_P_H__ diff --git a/lang/qt/src/encryptjob.cpp b/lang/qt/src/encryptjob.cpp deleted file mode 100644 index d4337bad..00000000 --- a/lang/qt/src/encryptjob.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - encryptjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "encryptjob.h" -#include "encryptjob_p.h" - -using namespace QGpgME; - -EncryptJob::EncryptJob(QObject *parent) - : Job{parent} -{ -} - -EncryptJob::~EncryptJob() = default; - -void EncryptJob::setFileName(const QString &fileName) -{ - auto d = jobPrivate<EncryptJobPrivate>(this); - d->m_fileName = fileName; -} - -QString EncryptJob::fileName() const -{ - auto d = jobPrivate<EncryptJobPrivate>(this); - return d->m_fileName; -} - -void EncryptJob::setInputEncoding(GpgME::Data::Encoding inputEncoding) -{ - auto d = jobPrivate<EncryptJobPrivate>(this); - d->m_inputEncoding = inputEncoding; -} - -GpgME::Data::Encoding EncryptJob::inputEncoding() const -{ - auto d = jobPrivate<EncryptJobPrivate>(this); - return d->m_inputEncoding; -} - -void EncryptJob::setRecipients(const std::vector<GpgME::Key> &recipients) -{ - auto d = jobPrivate<EncryptJobPrivate>(this); - d->m_recipients = recipients; -} - -std::vector<GpgME::Key> EncryptJob::recipients() const -{ - auto d = jobPrivate<EncryptJobPrivate>(this); - return d->m_recipients; -} - -void EncryptJob::setInputFile(const QString &path) -{ - auto d = jobPrivate<EncryptJobPrivate>(this); - d->m_inputFilePath = path; -} - -QString EncryptJob::inputFile() const -{ - auto d = jobPrivate<EncryptJobPrivate>(this); - return d->m_inputFilePath; -} - -void EncryptJob::setOutputFile(const QString &path) -{ - auto d = jobPrivate<EncryptJobPrivate>(this); - d->m_outputFilePath = path; -} - -QString EncryptJob::outputFile() const -{ - auto d = jobPrivate<EncryptJobPrivate>(this); - return d->m_outputFilePath; -} - -void EncryptJob::setEncryptionFlags(GpgME::Context::EncryptionFlags flags) -{ - auto d = jobPrivate<EncryptJobPrivate>(this); - d->m_encryptionFlags = static_cast<GpgME::Context::EncryptionFlags>(flags | GpgME::Context::EncryptFile); -} - -GpgME::Context::EncryptionFlags EncryptJob::encryptionFlags() const -{ - auto d = jobPrivate<EncryptJobPrivate>(this); - return d->m_encryptionFlags; -} - -#include "encryptjob.moc" diff --git a/lang/qt/src/encryptjob.h b/lang/qt/src/encryptjob.h deleted file mode 100644 index dde9d6e8..00000000 --- a/lang/qt/src/encryptjob.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - encryptjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004, 2007 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_ENCRYPTJOB_H__ -#define __KLEO_ENCRYPTJOB_H__ - -#include "job.h" -#include <gpgme++/data.h> - -#include <memory> -#include <vector> - -#include <gpgme++/context.h> - -class QByteArray; -class QIODevice; - -namespace GpgME -{ -class Error; -class Key; -class EncryptionResult; -} - -namespace QGpgME -{ - -/** - @short An abstract base class for asynchronous encrypters - - To use a EncryptJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the encryption with a - call to start(). This call might fail, in which case the - EncryptJob instance will have scheduled it's own destruction with - a call to QObject::deleteLater(). - - Alternatively, the job can be started with startIt() after setting - an input file and an output file and, optionally, recipients or flags. - If the job is started this way then the backend reads the input and - writes the output directly from/to the specified input file and output - file. In this case the cipherText value of the result signal will always - be empty. This direct IO mode is currently only supported for OpenPGP. - Note that startIt() does not schedule the job's destruction if starting - the job failed. - - After result() is emitted, the EncryptJob will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT EncryptJob : public Job -{ - Q_OBJECT -protected: - explicit EncryptJob(QObject *parent); -public: - ~EncryptJob() override; - - /** - * Sets the file name to embed in the encryption result. - * - * This is only used if one of the start() functions is used. - */ - void setFileName(const QString &fileName); - QString fileName() const; - - /** - * Sets the encoding of the plaintext. - * - * This is only used if one of the start() functions is used. - */ - void setInputEncoding(GpgME::Data::Encoding); - GpgME::Data::Encoding inputEncoding() const; - - /** - * Sets the keys to use for encryption. - * - * Used if the job is started with startIt(). - */ - void setRecipients(const std::vector<GpgME::Key> &recipients); - std::vector<GpgME::Key> recipients() const; - - /** - * Sets the path of the file to encrypt. - * - * Used if the job is started with startIt(). - */ - void setInputFile(const QString &path); - QString inputFile() const; - - /** - * Sets the path of the file to write the encryption result to. - * - * Used if the job is started with startIt(). - * - * \note If a file with this path exists, then the job will fail, i.e. you - * need to delete an existing file that shall be overwritten before you - * start the job. - */ - void setOutputFile(const QString &path); - QString outputFile() const; - - /** - * Sets the flags to use for encryption. - * - * Defaults to \c EncryptFile. - * - * Used if the job is started with startIt(). The \c EncryptFile flag is - * always assumed set. - */ - void setEncryptionFlags(GpgME::Context::EncryptionFlags flags); - GpgME::Context::EncryptionFlags encryptionFlags() const; - - /** - Starts the encryption operation. \a recipients is the a list of - keys to encrypt \a plainText to. Empty (null) keys are - ignored. If \a recipients is empty, performs symmetric - (passphrase) encryption. - - If \a alwaysTrust is true, validity checking for the keys will - not be performed, but full validity assumed for all keys - without further checks. - */ - virtual GpgME::Error start(const std::vector<GpgME::Key> &recipients, - const QByteArray &plainText, bool alwaysTrust = false) = 0; - - /*! - \overload - - If \a cipherText is non-null, the ciphertext is written - there. Otherwise, it will be delivered in the second argument of - result(). - */ - virtual void start(const std::vector<GpgME::Key> &recipients, - const std::shared_ptr<QIODevice> &plainText, - const std::shared_ptr<QIODevice> &cipherText = std::shared_ptr<QIODevice>(), - bool alwaysTrust = false) = 0; - - virtual GpgME::EncryptionResult exec(const std::vector<GpgME::Key> &recipients, - const QByteArray &plainText, - bool alwaysTrust, QByteArray &cipherText) = 0; - /*! - This is a hack to request BASE64 output (instead of whatever - comes out normally). - */ - virtual void setOutputIsBase64Encoded(bool) = 0; - - /** Like start but with an additional argument for EncryptionFlags for - * more flexibility. */ - virtual void start(const std::vector<GpgME::Key> &recipients, - const std::shared_ptr<QIODevice> &plainText, - const std::shared_ptr<QIODevice> &cipherText = std::shared_ptr<QIODevice>(), - const GpgME::Context::EncryptionFlags flags = GpgME::Context::None) = 0; - - /** Like exec but with an additional argument for EncryptionFlags for - * more flexibility. */ - virtual GpgME::EncryptionResult exec(const std::vector<GpgME::Key> &recipients, - const QByteArray &plainText, - const GpgME::Context::EncryptionFlags flags, QByteArray &cipherText) = 0; -Q_SIGNALS: - void result(const GpgME::EncryptionResult &result, const QByteArray &cipherText, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __KLEO_ENCRYPTJOB_H__ diff --git a/lang/qt/src/encryptjob_p.h b/lang/qt/src/encryptjob_p.h deleted file mode 100644 index 95126e13..00000000 --- a/lang/qt/src/encryptjob_p.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - encryptjob_p.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022,2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_ENCRYPTJOB_P_H__ -#define __QGPGME_ENCRYPTJOB_P_H__ - -#include "job_p.h" - -#include <gpgme++/data.h> -#include <gpgme++/key.h> - -namespace QGpgME -{ - -struct EncryptJobPrivate : public JobPrivate -{ - // used by start() functions - QString m_fileName; - GpgME::Data::Encoding m_inputEncoding; - - // used by startIt() - std::vector<GpgME::Key> m_recipients; - QString m_inputFilePath; - QString m_outputFilePath; - GpgME::Context::EncryptionFlags m_encryptionFlags = GpgME::Context::EncryptFile; -}; - -} - -#endif // __QGPGME_ENCRYPTJOB_P_H__ diff --git a/lang/qt/src/exportjob.h b/lang/qt/src/exportjob.h deleted file mode 100644 index 91b5c90e..00000000 --- a/lang/qt/src/exportjob.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - exportjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_EXPORTJOB_H__ -#define __QGPGME_EXPORTJOB_H__ - -#include "qgpgme_export.h" -#include "job.h" - -#include <QtCore/QByteArray> -#include <QtCore/QStringList> - -namespace GpgME -{ -class Error; -} - -namespace QGpgME -{ - -/** - @short An abstract base class for asynchronous exporters - - To use a ExportJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the export with a call - to start(). This call might fail, in which case the ExportJob - instance will have scheduled it's own destruction with a call to - QObject::deleteLater(). - - After result() is emitted, the ExportJob will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT ExportJob : public Job -{ - Q_OBJECT -protected: - explicit ExportJob(QObject *parent); -public: - ~ExportJob(); - - /** - Starts the export operation. \a patterns is a list of patterns - used to restrict the list of keys exported. Empty patterns are - ignored. If \a patterns is empty or contains only empty - strings, all available keys are exported. - */ - virtual GpgME::Error start(const QStringList &patterns) = 0; - - virtual void setExportFlags (unsigned int flags); - - /** - * Starts the export operation synchronously, otherwise behaves identical to - * ExportJob::start - */ - virtual GpgME::Error exec(const QStringList &patterns, QByteArray &data); - -Q_SIGNALS: - void result(const GpgME::Error &result, const QByteArray &keyData, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __QGPGME_EXPORTJOB_H__ diff --git a/lang/qt/src/filelistdataprovider.cpp b/lang/qt/src/filelistdataprovider.cpp deleted file mode 100644 index 004854ef..00000000 --- a/lang/qt/src/filelistdataprovider.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - filelistdataprovider.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "filelistdataprovider.h" - -#include "dataprovider.h" - -#include <QString> - -#include <gpgme++/error.h> - -#include <numeric> - -using namespace QGpgME; -using namespace GpgME; - -static QByteArray encodeFilenames(const std::vector<QString> &filenames) -{ - QByteArray ret; - if (filenames.empty()) { - return ret; - } - // calculate and reserve the needed minimum size of the result - const auto addSize = [](unsigned int n, const QString &s) { return n + s.size(); }; - const unsigned int minSize = filenames.size() - + std::accumulate(filenames.cbegin(), filenames.cend(), 0u, addSize); - ret.reserve(minSize); - // pack the filenames into the byte array - for (const auto &f : filenames) { - if (!f.isEmpty()) { - ret += f.toUtf8() + '\0'; - } - } - ret.chop(1); // remove the trailing nul - return ret; -} - -FileListDataProvider::FileListDataProvider(const std::vector<QString> &filenames) - : mProvider{new QByteArrayDataProvider{encodeFilenames(filenames)}} -{ -} - -FileListDataProvider::~FileListDataProvider() = default; - -ssize_t FileListDataProvider::read(void* buffer, size_t bufSize) -{ - return mProvider->read(buffer, bufSize); -} - -ssize_t FileListDataProvider::write(const void *, size_t) -{ - Error::setSystemError(GPG_ERR_EBADF); - return -1; -} - -off_t FileListDataProvider::seek(off_t offset, int whence) -{ - return mProvider->seek(offset, whence); -} - -void FileListDataProvider::release() -{ - mProvider->release(); -} diff --git a/lang/qt/src/filelistdataprovider.h b/lang/qt/src/filelistdataprovider.h deleted file mode 100644 index 60bb0548..00000000 --- a/lang/qt/src/filelistdataprovider.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - filelistdataprovider.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_FILELISTDATAPROVIDER_H__ -#define __QGPGME_FILELISTDATAPROVIDER_H__ - -#include "qgpgme_export.h" - -#include <gpgme++/interfaces/dataprovider.h> - -#include <memory> -#include <vector> - -class QString; - -namespace QGpgME -{ - -/** - * This read-only data provider simplifies providing a nul-separated list of - * UTF-8-encoded filenames, e.g. for creating signed or encrypted archives. - */ -class QGPGME_EXPORT FileListDataProvider : public GpgME::DataProvider -{ -public: - explicit FileListDataProvider(const std::vector<QString> &filenames); - ~FileListDataProvider() override; - -private: - bool isSupported(Operation op) const override - { - return op != Operation::Write; - } - ssize_t read(void *buffer, size_t bufSize) override; - ssize_t write(const void *buffer, size_t bufSize) override; - off_t seek(off_t offset, int whence) override; - void release() override; - -private: - std::unique_ptr<GpgME::DataProvider> mProvider; -}; - -} - -#endif // __QGPGME_FILELISTDATAPROVIDER_H__ diff --git a/lang/qt/src/gpgcardjob.h b/lang/qt/src/gpgcardjob.h deleted file mode 100644 index 3f1b2391..00000000 --- a/lang/qt/src/gpgcardjob.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - gpgcardjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2020 g10 Code GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifndef __KLEO_GPGCARDJOB_H__ -#define __KLEO_GPGCARDJOB_H__ - -#include <QStringList> - -#include "job.h" - -namespace GpgME -{ -class Error; -} - -namespace QGpgME -{ - -class QGPGME_EXPORT GpgCardJob: public Job -{ - Q_OBJECT -protected: - explicit GpgCardJob(QObject *parent); - -public: - ~GpgCardJob(); - - /** - Starts the operation. \a cmds are the commands to - execute. - */ - virtual GpgME::Error start(const QStringList &cmds) = 0; - - virtual GpgME::Error exec(const QStringList &cmds, QString &std_out, QString &std_err, int &exitCode) = 0; - -Q_SIGNALS: - /** The resulting stdout and stderr of gpgcard and the exitCode - * - * The auditlog params are always null / empty. - */ - void result(const QString &std_out, const QString &std_err, int exitCode, - const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} -#endif diff --git a/lang/qt/src/hierarchicalkeylistjob.h b/lang/qt/src/hierarchicalkeylistjob.h deleted file mode 100644 index 431ff712..00000000 --- a/lang/qt/src/hierarchicalkeylistjob.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - hierarchicalkeylistjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_HIERARCHICALKEYLISTJOB_H__ -#define __KLEO_HIERARCHICALKEYLISTJOB_H__ - -#include "qgpgme_export.h" -#include "keylistjob.h" -#include "cryptobackend.h" - -#include <gpgme++/keylistresult.h> - -#include <QPointer> - -#include <set> - -namespace GpgME -{ -class Error; -class Key; -} - -namespace QGpgME -{ -class KeyListJob; -} - -namespace QGpgME -{ - -/** - @short A convenience job that additionally fetches all available issuers. - - To use a HierarchicalKeyListJob, pass it a CryptoBackend - implementation, connect the progress() and result() signals to - suitable slots and then start the keylisting with a call to - start(). This call might fail, in which case the - HierarchicalKeyListJob instance will have scheduled it's own - destruction with a call to QObject::deleteLater(). - - After result() is emitted, the HierarchicalKeyListJob will - schedule its own destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT HierarchicalKeyListJob : public KeyListJob -{ - Q_OBJECT -public: - explicit HierarchicalKeyListJob(const Protocol *protocol, - bool remote = false, bool includeSigs = false, - bool validating = false); - ~HierarchicalKeyListJob(); - - /** - Starts the keylist operation. \a patterns is a list of patterns - used to restrict the list of keys returned. Empty patterns are - ignored. \a patterns must not be empty or contain only empty - patterns; use the normal KeyListJob for a full listing. - - The \a secretOnly parameter is ignored by - HierarchicalKeyListJob and must be set to false. - */ - GpgME::Error start(const QStringList &patterns, bool secretOnly = false) override; - - GpgME::KeyListResult exec(const QStringList &patterns, bool secretOnly, - std::vector<GpgME::Key> &keys) override; - -private Q_SLOTS: - void slotResult(const GpgME::KeyListResult &); - void slotNextKey(const GpgME::Key &key); - /* from Job */ - void slotCancel() override; - -private: - GpgME::Error startAJob(); - -private: - const Protocol *const mProtocol; - const bool mRemote; - const bool mIncludeSigs; - const bool mValidating; - bool mTruncated; - std::set<QString> mSentSet; // keys already sent (prevent duplicates even if the backend should return them) - std::set<QString> mScheduledSet; // keys already scheduled (by starting a job for them) - std::set<QString> mNextSet; // keys to schedule for the next iteraton - GpgME::KeyListResult mIntermediateResult; - QPointer<KeyListJob> mJob; -}; - -} - -#endif // __KLEO_HIERARCHICALKEYLISTJOB_H__ diff --git a/lang/qt/src/importfromkeyserverjob.h b/lang/qt/src/importfromkeyserverjob.h deleted file mode 100644 index cc4a22da..00000000 --- a/lang/qt/src/importfromkeyserverjob.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - importfromkeyserverjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_IMPORTFROMKEYSERVERJOB_H__ -#define __KLEO_IMPORTFROMKEYSERVERJOB_H__ - -#include "abstractimportjob.h" -#include "qgpgme_export.h" - -namespace GpgME -{ -class Key; -class Error; -class ImportResult; -} - -#include <vector> - -namespace QGpgME -{ - -/** - @short An abstract base class for asynchronous keyserver-importers - - To use a ImportJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the import with a call - to start(). This call might fail, in which case the ImportJob - instance will have scheduled it's own destruction with a call to - QObject::deleteLater(). - - After result() is emitted, the ImportJob will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT ImportFromKeyserverJob : public AbstractImportJob -{ - Q_OBJECT -protected: - explicit ImportFromKeyserverJob(QObject *parent); -public: - ~ImportFromKeyserverJob(); - - /** - Starts the importing operation. \a keyData contains the data to - import from. - */ - virtual GpgME::Error start(const std::vector<GpgME::Key> &keys) = 0; - - virtual GpgME::ImportResult exec(const std::vector<GpgME::Key> &keys) = 0; -}; - -} - -#endif // __KLEO_IMPORTFROMKEYSERVERJOB_H__ diff --git a/lang/qt/src/importjob.cpp b/lang/qt/src/importjob.cpp deleted file mode 100644 index f0ec63ca..00000000 --- a/lang/qt/src/importjob.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - importjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2021 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "importjob.h" -#include "importjob_p.h" - -#include <gpgme++/context.h> - -using namespace GpgME; -using namespace QGpgME; - -void QGpgME::ImportJob::setImportFilter(const QString &filter) -{ - const auto d = jobPrivate<ImportJobPrivate>(this); - d->m_importFilter = filter; -} - -QString QGpgME::ImportJob::importFilter() const -{ - const auto d = jobPrivate<ImportJobPrivate>(this); - return d->m_importFilter; -} - -void QGpgME::ImportJob::setImportOptions(const QStringList &options) -{ - const auto d = jobPrivate<ImportJobPrivate>(this); - d->m_importOptions = options; -} - -QStringList QGpgME::ImportJob::importOptions() const -{ - const auto d = jobPrivate<ImportJobPrivate>(this); - return d->m_importOptions; -} - -void ImportJob::setKeyOrigin(GpgME::Key::Origin origin, const QString &url) -{ - const auto d = jobPrivate<ImportJobPrivate>(this); - d->m_keyOrigin = origin; - d->m_keyOriginUrl = url; -} - -GpgME::Key::Origin ImportJob::keyOrigin() const -{ - const auto d = jobPrivate<ImportJobPrivate>(this); - return d->m_keyOrigin; -} - -QString ImportJob::keyOriginUrl() const -{ - const auto d = jobPrivate<ImportJobPrivate>(this); - return d->m_keyOriginUrl; -} diff --git a/lang/qt/src/importjob.h b/lang/qt/src/importjob.h deleted file mode 100644 index e92f7415..00000000 --- a/lang/qt/src/importjob.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - importjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_IMPORTJOB_H__ -#define __KLEO_IMPORTJOB_H__ - -#include "abstractimportjob.h" -#include "qgpgme_export.h" - -#include <gpgme++/key.h> - -namespace GpgME -{ -class Error; -class ImportResult; -} - -namespace QGpgME -{ - -/** - @short An abstract base class for asynchronous importers - - To use a ImportJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the import with a call - to start(). This call might fail, in which case the ImportJob - instance will have scheduled it's own destruction with a call to - QObject::deleteLater(). - - After result() is emitted, the ImportJob will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT ImportJob : public AbstractImportJob -{ - Q_OBJECT -protected: - explicit ImportJob(QObject *parent); -public: - ~ImportJob() override; - - void setImportFilter(const QString &filter); - QString importFilter() const; - - void setImportOptions(const QStringList &options); - QStringList importOptions() const; - - void setKeyOrigin(GpgME::Key::Origin origin, const QString &url = {}); - GpgME::Key::Origin keyOrigin() const; - QString keyOriginUrl() const; - - /** - Starts the importing operation. \a keyData contains the data to - import from. - */ - virtual GpgME::Error start(const QByteArray &keyData) = 0; - - virtual GpgME::ImportResult exec(const QByteArray &keyData) = 0; - - virtual GpgME::Error startLater(const QByteArray &keyData) = 0; -}; - -} - -#endif // __KLEO_IMPORTJOB_H__ diff --git a/lang/qt/src/importjob_p.h b/lang/qt/src/importjob_p.h deleted file mode 100644 index 7ee8f914..00000000 --- a/lang/qt/src/importjob_p.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - importjob_p.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2021,2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_IMPORTJOB_P_H__ -#define __QGPGME_IMPORTJOB_P_H__ - -#include "job_p.h" - -#include <gpgme++/key.h> - -namespace QGpgME -{ - -struct ImportJobPrivate : public JobPrivate -{ - QString m_importFilter; - QStringList m_importOptions; - GpgME::Key::Origin m_keyOrigin = GpgME::Key::OriginUnknown; - QString m_keyOriginUrl; -}; - -} - -#endif // __QGPGME_IMPORTJOB_P_H__ diff --git a/lang/qt/src/job.cpp b/lang/qt/src/job.cpp deleted file mode 100644 index bbbca293..00000000 --- a/lang/qt/src/job.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/* - job.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2005 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2021 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "job.h" -#include "job_p.h" - -#include "keylistjob.h" -#include "listallkeysjob.h" -#include "decryptjob.h" -#include "signkeyjob.h" -#include "keygenerationjob.h" -#include "importjob.h" -#include "importfromkeyserverjob.h" -#include "exportjob.h" -#include "changeexpiryjob.h" -#include "changeownertrustjob.h" -#include "changepasswdjob.h" -#include "downloadjob.h" -#include "deletejob.h" -#include "refreshkeysjob.h" -#include "addexistingsubkeyjob.h" -#include "adduseridjob.h" -#include "specialjob.h" -#include "keyformailboxjob.h" -#include "wkdlookupjob.h" -#include "wkspublishjob.h" -#include "tofupolicyjob.h" -#include "threadedjobmixin.h" -#include "gpgcardjob.h" -#include "receivekeysjob.h" -#include "revokekeyjob.h" -#include "setprimaryuseridjob.h" - -#include <QCoreApplication> -#include <QDebug> - -#include <gpg-error.h> - -#include <unordered_map> - -namespace -{ -typedef std::unordered_map<const QGpgME::Job*, std::unique_ptr<QGpgME::JobPrivate>> JobPrivateHash; -Q_GLOBAL_STATIC(JobPrivateHash, d_func) -} - -void QGpgME::setJobPrivate(const Job *job, std::unique_ptr<JobPrivate> d) -{ - auto &ref = d_func()->operator[](job); - ref = std::move(d); -} - -const QGpgME::JobPrivate *QGpgME::getJobPrivate(const Job *job) -{ - return d_func()->operator[](job).get(); -} - -QGpgME::JobPrivate *QGpgME::getJobPrivate(Job *job) -{ - return d_func()->operator[](job).get(); -} - -QGpgME::Job::Job(QObject *parent) - : QObject(parent) -{ - if (QCoreApplication *app = QCoreApplication::instance()) { - connect(app, &QCoreApplication::aboutToQuit, this, &Job::slotCancel); - } -} - -QGpgME::Job::~Job() -{ - ::d_func()->erase(this); -} - -QString QGpgME::Job::auditLogAsHtml() const -{ - qDebug() << "QGpgME::Job::auditLogAsHtml() should be reimplemented in Kleo::Job subclasses!"; - return QString(); -} - -GpgME::Error QGpgME::Job::auditLogError() const -{ - qDebug() << "QGpgME::Job::auditLogError() should be reimplemented in Kleo::Job subclasses!"; - return GpgME::Error::fromCode(GPG_ERR_NOT_IMPLEMENTED); -} - -bool QGpgME::Job::isAuditLogSupported() const -{ - return auditLogError().code() != GPG_ERR_NOT_IMPLEMENTED; -} - -QMap <QGpgME::Job *, GpgME::Context *> QGpgME::g_context_map; - -/* static */ -GpgME::Context *QGpgME::Job::context(QGpgME::Job *job) -{ - return QGpgME::g_context_map.value (job, nullptr); -} - -GpgME::Error QGpgME::Job::startIt() -{ - auto d = getJobPrivate(this); - Q_ASSERT(d && "This Job class has no JobPrivate class"); - return d->startIt(); -} - -void QGpgME::Job::startNow() -{ - auto d = getJobPrivate(this); - Q_ASSERT(d && "This Job class has no JobPrivate class"); - d->startNow(); -} - -#define make_job_subclass_ext(x,y) \ - QGpgME::x::x( QObject * parent ) : y( parent ) {} \ - QGpgME::x::~x() {} - -#define make_job_subclass(x) make_job_subclass_ext(x,Job) - -make_job_subclass(KeyListJob) -make_job_subclass(ListAllKeysJob) -make_job_subclass(DecryptJob) -make_job_subclass(SignKeyJob) -make_job_subclass(KeyGenerationJob) -make_job_subclass(AbstractImportJob) -make_job_subclass_ext(ImportJob, AbstractImportJob) -make_job_subclass_ext(ImportFromKeyserverJob, AbstractImportJob) -make_job_subclass_ext(ReceiveKeysJob, AbstractImportJob) -make_job_subclass(ExportJob) -make_job_subclass(ChangeExpiryJob) -make_job_subclass(ChangeOwnerTrustJob) -make_job_subclass(ChangePasswdJob) -make_job_subclass(DownloadJob) -make_job_subclass(DeleteJob) -make_job_subclass(RefreshKeysJob) -make_job_subclass(AddExistingSubkeyJob) -make_job_subclass(AddUserIDJob) -make_job_subclass(SpecialJob) -make_job_subclass(KeyForMailboxJob) -make_job_subclass(WKDLookupJob) -make_job_subclass(WKSPublishJob) -make_job_subclass(TofuPolicyJob) -make_job_subclass(GpgCardJob) -make_job_subclass(RevokeKeyJob) -make_job_subclass(SetPrimaryUserIDJob) - -#undef make_job_subclass - -#include "job.moc" - -#include "keylistjob.moc" -#include "listallkeysjob.moc" -#include "decryptjob.moc" -#include "signkeyjob.moc" -#include "keygenerationjob.moc" -#include "abstractimportjob.moc" -#include "importjob.moc" -#include "importfromkeyserverjob.moc" -#include "exportjob.moc" -#include "changeexpiryjob.moc" -#include "changeownertrustjob.moc" -#include "changepasswdjob.moc" -#include "downloadjob.moc" -#include "deletejob.moc" -#include "refreshkeysjob.moc" -#include "addexistingsubkeyjob.moc" -#include "adduseridjob.moc" -#include "specialjob.moc" -#include "keyformailboxjob.moc" -#include "wkdlookupjob.moc" -#include "wkspublishjob.moc" -#include "tofupolicyjob.moc" -#include "gpgcardjob.moc" -#include "receivekeysjob.moc" -#include "revokekeyjob.moc" -#include "setprimaryuseridjob.moc" diff --git a/lang/qt/src/job.h b/lang/qt/src/job.h deleted file mode 100644 index 56da33d7..00000000 --- a/lang/qt/src/job.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - job.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_JOB_H__ -#define __KLEO_JOB_H__ - -#include "qgpgme_export.h" - -#include <QObject> -#include <QString> -#include <QMap> - -#include <gpgme++/error.h> - -class QWidget; - -namespace QGpgME -{ - -/** - @short An abstract base class for asynchronous crypto operations - - During the operation, you might receive progress updates through - the progress() signal as they arrive, but an implementation is - free to not send progress information. You should show a busy - progressbar until the first progress() signal is received. - - The done() signal is emitted _before_ the result() signals of - subclasses and should be used to hide and/or reset progress bars, - not to learn of the end of the operation. Use the result() - signals for that. - - To cancel the operation, simply call slotCancel(). The result() - signal of subclasses will still be emitted, though, and will - carry the information that the operation was canceled. -*/ -class QGPGME_EXPORT Job : public QObject -{ - Q_OBJECT -protected: - explicit Job(QObject *parent); -public: - ~Job(); - - virtual QString auditLogAsHtml() const; - virtual GpgME::Error auditLogError() const; - bool isAuditLogSupported() const; - - /** Get the underlying context to set some additional options for a job. - * - * This is intended to provide more flexibility on configuring jobs before - * they are started. - * The context is still owned by the thread, do not delete it. - * - * This is a static method that takes the job as argument. - * - * This function may not be called for running jobs. - * - * @returns the context used by the job job or null. - */ - static GpgME::Context *context(Job *job); - - /** Starts the job. - * - * Starts the job with the values set for the concrete job. If starting - * the job failed then you are responsible for destroying it. Therefore, - * it's recommended to store the job in a std::unique_ptr until it has - * been started successfully. - */ - GpgME::Error startIt(); - - /** Starts a deferred job. - * - * The job needs to have been prepared for a deferred start by calling the - * startLater() function instead of the start() function of a leaf class. - */ - void startNow(); - -public Q_SLOTS: - virtual void slotCancel() = 0; - -Q_SIGNALS: - /** - * This signal is emitted whenever the backend sends a progress status - * message. For most jobs, \a current is the amount of processed data - * (or files) and \a total is the total amount of data (of files). If - * \a total is 0, then the total amount is unknown or not yet known. - * For GnuPG 2.1.13 and later, \a current and \a total do not exceed - * 2^20, i.e. for larger values they are scaled down and you should not - * assume that they represent absolute values. - * - * Check the documentation on progress in the GpgME manual for details. - * - * Note: Some jobs provide special progress signals, e.g. for file-count- - * or data-based progress. - */ - void jobProgress(int current, int total); - - /** - * This signal is emitted whenever the backend sends a progress status - * message. Compared to the jobProgress signal this signal also provides the - * what value and the type value reported by the backend. Usually, these - * values can safely be ignored, so that you are better off using the - * simpler jobProgress signal. - * Check the documentation on progress in the GpgME manual for details - * on what and type. - * - * Note: Some jobs provide special progress signals, so that you do not - * have to deal with what and type yourself. - */ - void rawProgress(const QString &what, int type, int current, int total); - - QGPGME_DEPRECATED void progress(const QString &what, int current, int total); - - void done(); -}; - -extern QMap <Job *, GpgME::Context *> g_context_map; -} - -#endif // __KLEO_JOB_H__ diff --git a/lang/qt/src/job_p.h b/lang/qt/src/job_p.h deleted file mode 100644 index 597b1a17..00000000 --- a/lang/qt/src/job_p.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - job_p.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2021 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_JOB_P_H__ -#define __QGPGME_JOB_P_H__ - -#include "job.h" - -#include "qgpgme_debug.h" - -#include <memory> - -namespace QGpgME -{ - -// Base class for pimpl classes for Job subclasses -class JobPrivate -{ -public: - virtual ~JobPrivate() {} - - virtual GpgME::Error startIt() = 0; - - virtual void startNow() = 0; -}; - -// Setter and getters for the externally stored pimpl instances of jobs -// BCI: Add a real d-pointer to Job -void setJobPrivate(const Job *job, std::unique_ptr<JobPrivate> d); - -const JobPrivate *getJobPrivate(const Job *job); - -JobPrivate *getJobPrivate(Job *job); - -template <typename T> -static const T *jobPrivate(const Job *job) { - auto d = getJobPrivate(job); - return dynamic_cast<const T *>(d); -} - -template <typename T> -static T *jobPrivate(Job *job) { - auto d = getJobPrivate(job); - return dynamic_cast<T *>(d); -} - -// Helper for the archive job classes -template<class JobClass> -void emitArchiveProgressSignals(JobClass *job, const QString &what, int type, int current, int total) -{ - if (what != QLatin1String{"gpgtar"}) { - return; - } - switch (type) { - case 'c': - Q_EMIT job->fileProgress(current, total); - break; - case 's': - Q_EMIT job->dataProgress(current, total); - break; - default: - qCDebug(QGPGME_LOG) << job << __func__ << "Received progress for gpgtar with unknown type" << char(type); - }; -} - -} - -#endif // __QGPGME_JOB_P_H__ diff --git a/lang/qt/src/keyformailboxjob.h b/lang/qt/src/keyformailboxjob.h deleted file mode 100644 index 33027c0c..00000000 --- a/lang/qt/src/keyformailboxjob.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - keyformailboxjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifndef __KLEO_KEYFORMAILBOX_H__ -#define __KLEO_KEYFORMAILBOX_H__ - -#include <QString> - -#include "job.h" - -#include <gpgme++/key.h> - -namespace GpgME -{ -class Error; -class KeyListResult; -} - -namespace QGpgME -{ - -/** - @short Get the best key to use for a Mailbox - - To use the keyformailboxjob, first obtain an instance from the - CryptoBackend and either exec it or start and - connect the result() signal to a suitable slot. - - The best key is defined as the key with a UID that has an - E-Mail that matches the mailbox provided. If multiple - keys are found the one with the highest validity is returned. - - After result() is emitted, the job will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT KeyForMailboxJob: public Job -{ - Q_OBJECT -protected: - explicit KeyForMailboxJob(QObject *parent); - -public: - ~KeyForMailboxJob(); - - /** - Starts the operation. \a mailbox is the mailbox to - look for. - - The result is the same as for the LocateKeysJob. - - If \a canEncrypt is true, only keys that have a subkey for encryption - usage are returned. Use this if you need to select a - key for signing. - */ - virtual GpgME::Error start(const QString &mailbox, bool canEncrypt = true) = 0; - - virtual GpgME::KeyListResult exec(const QString &mailbox, bool canEncrypt, GpgME::Key &key, GpgME::UserID &uid) = 0; - -Q_SIGNALS: - /** The result. \a Key is the key found or a Null key. - * - * The userid is the uid where the mailbox matches. - * - * The auditlog params are always null / empty. - */ - void result(const GpgME::KeyListResult &result, const GpgME::Key &key, const GpgME::UserID &uid, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} -#endif diff --git a/lang/qt/src/keygenerationjob.h b/lang/qt/src/keygenerationjob.h deleted file mode 100644 index 04b97d9f..00000000 --- a/lang/qt/src/keygenerationjob.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - keygenerationjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_KEYGENERATIONJOB_H__ -#define __KLEO_KEYGENERATIONJOB_H__ - -#include "job.h" -#include "qgpgme_export.h" - -#include <QtCore/QByteArray> - -namespace GpgME -{ -class Error; -class KeyGenerationResult; -} - -namespace QGpgME -{ - -/** - @short An abstract base class for asynchronous key generation - - To use a KeyGenerationJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the key generation with - a call to start(). This call might fail, in which case the - KeyGenerationJob instance will have scheduled it's own - destruction with a call to QObject::deleteLater(). - - After result() is emitted, the KeyGenerationJob will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT KeyGenerationJob : public Job -{ - Q_OBJECT -protected: - explicit KeyGenerationJob(QObject *parent); -public: - ~KeyGenerationJob(); - - /** - Starts the key generation operation. \a parameters is a - backend-specific string containing the parameters of the key to - create (length, capabilities, etc). - */ - virtual GpgME::Error start(const QString ¶meters) = 0; - -Q_SIGNALS: - void result(const GpgME::KeyGenerationResult &result, const QByteArray &pubKeyData, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __KLEO_KEYGENERATIONJOB_H__ diff --git a/lang/qt/src/keylistjob.h b/lang/qt/src/keylistjob.h deleted file mode 100644 index 7a4bd712..00000000 --- a/lang/qt/src/keylistjob.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - keylistjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_KEYLISTJOB_H__ -#define __KLEO_KEYLISTJOB_H__ - -#include "job.h" -#include "qgpgme_export.h" - -#include <gpgme++/key.h> - -#include <QtCore/QStringList> - -#include <vector> - -namespace GpgME -{ -class Error; -class KeyListResult; -} - -namespace QGpgME -{ - -/** - @short An abstract base class for asynchronous key listers - - To use a KeyListJob, first obtain an instance from the - CryptoBackend implementation, connect the nextKey(), progress() - and result() signals to suitable slots and then start the key - listing with a call to start(). This call might fail, in which - case the KeylistJob instance will have scheduled it's own - destruction with a call to QObject::deleteLater(). - - During keylisting, you will receive new key objects through the - nextKey() signal as they arrive. After result() is emitted, the - KeyListJob will schedule it's own destruction by calling - QObject::deleteLater(). -*/ -class QGPGME_EXPORT KeyListJob : public Job -{ - Q_OBJECT -protected: - explicit KeyListJob(QObject *parent); - -public: - ~KeyListJob(); - - /** - Starts the keylist operation. \a pattern is a list of patterns - used to restrict the list of keys returned. Empty patterns are - ignored. If \a pattern is empty or contains only empty strings, - all keys are returned (however, the backend is free to truncate - the result and should do so; when this happens, it will be - reported by the reult object). - - If \a secretOnly is true, only keys for which the secret key is - also available are returned. Use this if you need to select a - key for signing. - */ - virtual GpgME::Error start(const QStringList &patterns, bool secretOnly = false) = 0; - - virtual GpgME::KeyListResult exec(const QStringList &patterns, bool secretOnly, std::vector<GpgME::Key> &keys) = 0; - - /** Add a flag to the keylistmode used. */ - virtual void addMode(GpgME::KeyListMode mode) = 0; - -Q_SIGNALS: - void nextKey(const GpgME::Key &key); - void result(const GpgME::KeyListResult &result, const std::vector<GpgME::Key> &keys = std::vector<GpgME::Key>(), const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __KLEO_KEYLISTJOB_H__ diff --git a/lang/qt/src/listallkeysjob.cpp b/lang/qt/src/listallkeysjob.cpp deleted file mode 100644 index 1dce75bf..00000000 --- a/lang/qt/src/listallkeysjob.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - listallkeysjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "listallkeysjob.h" -#include "listallkeysjob_p.h" - -using namespace QGpgME; - -void ListAllKeysJob::setOptions(ListAllKeysJob::Options options) -{ - auto d = jobPrivate<ListAllKeysJobPrivate>(this); - d->m_options = options; -} - -ListAllKeysJob::Options ListAllKeysJob::options() const -{ - auto d = jobPrivate<ListAllKeysJobPrivate>(this); - return d->m_options; -} diff --git a/lang/qt/src/listallkeysjob.h b/lang/qt/src/listallkeysjob.h deleted file mode 100644 index fa2f53a9..00000000 --- a/lang/qt/src/listallkeysjob.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - listallkeysjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_LISTALLKEYSJOB_H__ -#define __KLEO_LISTALLKEYSJOB_H__ - -#include "job.h" -#include "qgpgme_export.h" - -#include <gpgme++/key.h> - -#include <vector> - -namespace GpgME -{ -class Error; -class KeyListResult; -} - -namespace QGpgME -{ - -/** - @short An abstract base class for asynchronously listing all keys - - To use a ListAllKeysJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() - and result() signals to suitable slots and then start the key - listing with a call to start(). This call might fail, in which - case the ListAllKeysJob instance will have schedules it's own - destruction with a call to QObject::deleteLater(). - - After result() is emitted, the ListAllKeysJob will schedule it's - own destruction by calling QObject::deleteLater(). - - This is potentially much faster than a KeyListJob with empty - pattern. -*/ -class QGPGME_EXPORT ListAllKeysJob : public Job -{ - Q_OBJECT -public: - enum Option { - Default = 0x00, - DisableAutomaticTrustDatabaseCheck = 0x01, - }; - Q_DECLARE_FLAGS(Options, Option) - -protected: - explicit ListAllKeysJob(QObject *parent); - -public: - ~ListAllKeysJob(); - - void setOptions(Options options); - Options options() const; - - /** - Starts the listallkeys operation. In general, all keys are - returned (however, the backend is free to truncate the result - and should do so; when this happens, it will be reported by the - result object). - - If GnuPG 2.1 or later is used, then \a mergeKeys is ignored. Otherwise, - if \a mergeKeys is true, then some (but not all) information of the - secret keys is merged into public keys. - */ - virtual GpgME::Error start(bool mergeKeys = false) = 0; - - /** - Synchronous version of start(). - */ - virtual GpgME::KeyListResult exec(std::vector<GpgME::Key> &pub, std::vector<GpgME::Key> &sec, bool mergeKeys = false) = 0; - -Q_SIGNALS: - void result(const GpgME::KeyListResult &result, const std::vector<GpgME::Key> &pub = std::vector<GpgME::Key>(), const std::vector<GpgME::Key> &sec = std::vector<GpgME::Key>(), const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(ListAllKeysJob::Options) - -} - -#endif // __KLEO_LISTALLKEYSJOB_H__ diff --git a/lang/qt/src/listallkeysjob_p.h b/lang/qt/src/listallkeysjob_p.h deleted file mode 100644 index 582f028b..00000000 --- a/lang/qt/src/listallkeysjob_p.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - listallkeysjob_p.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022,2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_LISTALLKEYSJOB_P_H__ -#define __QGPGME_LISTALLKEYSJOB_P_H__ - -#include "job_p.h" - -#include "listallkeysjob.h" - -namespace QGpgME -{ - -struct ListAllKeysJobPrivate : public JobPrivate -{ - ListAllKeysJob::Options m_options = ListAllKeysJob::Default; -}; - -} - -#endif // __QGPGME_LISTALLKEYSJOB_P_H__ diff --git a/lang/qt/src/multideletejob.cpp b/lang/qt/src/multideletejob.cpp deleted file mode 100644 index 1c1e15d0..00000000 --- a/lang/qt/src/multideletejob.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - multideletejob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "multideletejob.h" -#include "protocol.h" -#include "deletejob.h" - -#include <gpgme++/key.h> -#include <gpgme++/context.h> -#include <gpgme++/data.h> - -#include <iterator> - -#include <assert.h> - -QGpgME::MultiDeleteJob::MultiDeleteJob(const Protocol *protocol) - : Job(nullptr), - mProtocol(protocol), - mJob(nullptr) -{ - assert(protocol); -} - -QGpgME::MultiDeleteJob::~MultiDeleteJob() -{ - -} - -GpgME::Error QGpgME::MultiDeleteJob::start(const std::vector<GpgME::Key> &keys, bool allowSecretKeyDeletion) -{ - mKeys = keys; - mAllowSecretKeyDeletion = allowSecretKeyDeletion; - mIt = mKeys.begin(); - - const GpgME::Error err = startAJob(); - - if (err) { - deleteLater(); - } - return err; -} - -void QGpgME::MultiDeleteJob::slotCancel() -{ - if (mJob) { - mJob->slotCancel(); - } - mIt = mKeys.end(); -} - -void QGpgME::MultiDeleteJob::slotResult(const GpgME::Error &err) -{ - mJob = nullptr; - GpgME::Error error = err; - if (error || // error in last op - mIt == mKeys.end() || // (shouldn't happen) - ++mIt == mKeys.end() || // was the last key - (error = startAJob())) { // error starting the job for the new key - Q_EMIT done(); - Q_EMIT result(error, error && mIt != mKeys.end() ? *mIt : GpgME::Key::null); - deleteLater(); - return; - } - - const int current = mIt - mKeys.begin(); - const int total = mKeys.size(); - const QString what = QStringLiteral("%1/%2").arg(current).arg(total); - Q_EMIT jobProgress(current, total); - Q_EMIT rawProgress(what, '?', current, total); - QT_WARNING_PUSH - QT_WARNING_DISABLE_DEPRECATED - Q_EMIT progress(what, current, total); - QT_WARNING_POP -} - -GpgME::Error QGpgME::MultiDeleteJob::startAJob() -{ - if (mIt == mKeys.end()) { - return GpgME::Error(0); - } - mJob = mProtocol->deleteJob(); - assert(mJob); // FIXME: we need a way to generate errors ourselves, - // but I don't like the dependency on gpg-error :/ - - connect(mJob.data(), &DeleteJob::result, this, &MultiDeleteJob::slotResult); - - return mJob->start(*mIt, mAllowSecretKeyDeletion); -} - -#include "multideletejob.moc" diff --git a/lang/qt/src/multideletejob.h b/lang/qt/src/multideletejob.h deleted file mode 100644 index 308490fa..00000000 --- a/lang/qt/src/multideletejob.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - multideletejob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_MULTIDELETEJOB_H__ -#define __KLEO_MULTIDELETEJOB_H__ - -#include "qgpgme_export.h" -#include "job.h" -#include "protocol.h" - -#include <QPointer> - -#include <vector> - -namespace GpgME -{ -class Error; -class Key; -} - -namespace QGpgME -{ -class DeleteJob; -} - -namespace QGpgME -{ - -/** - @short A convenience class bundling together multiple DeleteJobs. - - To use a MultiDeleteJob, pass it a CryptoBackend implementation, - connect the progress() and result() signals to suitable slots and - then start the delete with a call to start(). This call might - fail, in which case the MultiDeleteJob instance will have scheduled - it's own destruction with a call to QObject::deleteLater(). - - After result() is emitted, the MultiDeleteJob will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT MultiDeleteJob : public Job -{ - Q_OBJECT -public: - explicit MultiDeleteJob(const Protocol *protocol); - ~MultiDeleteJob(); - - /** - Starts the delete operation. \a keys is the list of keys to - delete, \a allowSecretKeyDeletion specifies if a key may also - be deleted if the secret key part is available, too. - */ - GpgME::Error start(const std::vector<GpgME::Key> &keys, bool allowSecretKeyDeletion = false); - - /* from Job */ - void slotCancel() override; - -Q_SIGNALS: - void result(const GpgME::Error &result, const GpgME::Key &errorKey); - -private Q_SLOTS: - void slotResult(const GpgME::Error &); - -private: - GpgME::Error startAJob(); - -private: - const Protocol *mProtocol; - QPointer<DeleteJob> mJob; - std::vector<GpgME::Key> mKeys; - std::vector<GpgME::Key>::const_iterator mIt; - bool mAllowSecretKeyDeletion; -}; - -} - -#endif // __KLEO_MULTIDELETEJOB_H__ diff --git a/lang/qt/src/protocol.h b/lang/qt/src/protocol.h deleted file mode 100644 index 74fb921d..00000000 --- a/lang/qt/src/protocol.h +++ /dev/null @@ -1,235 +0,0 @@ -/* - protocol.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2005 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifndef __QGPGME_PROTOCOL_H__ -#define __QGPGME_PROTOCOL_H__ - -#include <QString> -#include <QVariant> - -#include "qgpgme_export.h" - -namespace QGpgME { -class AddExistingSubkeyJob; -class CryptoConfig; -class KeyListJob; -class ListAllKeysJob; -class KeyGenerationJob; -class ImportJob; -class ImportFromKeyserverJob; -class ExportJob; -class DownloadJob; -class DeleteJob; -class EncryptArchiveJob; -class EncryptJob; -class DecryptJob; -class SignArchiveJob; -class SignEncryptArchiveJob; -class SignJob; -class SignKeyJob; -class VerifyDetachedJob; -class VerifyOpaqueJob; -class SignEncryptJob; -class DecryptVerifyArchiveJob; -class DecryptVerifyJob; -class RefreshKeysJob; -class ChangeExpiryJob; -class ChangeOwnerTrustJob; -class ChangePasswdJob; -class AddUserIDJob; -class SpecialJob; -class KeyForMailboxJob; -class WKDLookupJob; -class WKSPublishJob; -class TofuPolicyJob; -class QuickJob; -class GpgCardJob; -class ReceiveKeysJob; -class RevokeKeyJob; -class SetPrimaryUserIDJob; -class WKDRefreshJob; - -/** The main entry point for QGpgME Comes in OpenPGP and SMIME(CMS) flavors. - * - * Use the proctocol class to obtain an instance of a job. Jobs - * provide async API for GnuPG that can be connected to signals / slots. - * - * A job is usually started with start() and emits a result signal. - * The parameters of the result signal depend on the job but the last - * two are always a QString for the auditlog and an GpgME::Error for - * an eventual error. - * - * In case async API is used and the result signal is emitted a - * job schedules its own deletion. - * - * Most jobs also provide a synchronous call exec in which case - * you have to explicitly delete the job if you don't need it anymore. - * - * \code - * // Async example: - * KeyListJob *job = openpgp()->keyListJob(); - * connect(job, &KeyListJob::result, job, [this, job](KeyListResult, std::vector<Key> keys, QString, Error) - * { - * // keys and resuls can now be used. - * }); - * job->start({QStringLiteral("[email protected]")}, false); - * \endcode - * - * \code - * // Sync eaxmple: - * KeyListJob *job = openpgp()->keyListJob(false, false, false); - * std::vector<GpgME::Key> keys; - * GpgME::KeyListResult result = job->exec(QStringList() << - * QStringLiteral("[email protected]"), - * false, keys); - * delete job; - * \endcode - */ -class QGPGME_EXPORT Protocol -{ -public: - virtual ~Protocol() {} - - virtual QString name() const = 0; - - virtual QString displayName() const = 0; - - virtual KeyListJob *keyListJob(bool remote = false, bool includeSigs = false, bool validate = false) const = 0; - virtual ListAllKeysJob *listAllKeysJob(bool includeSigs = false, bool validate = false) const = 0; - virtual EncryptJob *encryptJob(bool armor = false, bool textmode = false) const = 0; - virtual DecryptJob *decryptJob() const = 0; - virtual SignJob *signJob(bool armor = false, bool textMode = false) const = 0; - virtual VerifyDetachedJob *verifyDetachedJob(bool textmode = false) const = 0; - virtual VerifyOpaqueJob *verifyOpaqueJob(bool textmode = false) const = 0; - virtual KeyGenerationJob *keyGenerationJob() const = 0; - virtual ImportJob *importJob() const = 0; - virtual ImportFromKeyserverJob *importFromKeyserverJob() const = 0; - virtual ExportJob *publicKeyExportJob(bool armor = false) const = 0; - // the second parameter is ignored; the passphrase in the exported file is always utf-8 encoded - virtual ExportJob *secretKeyExportJob(bool armor = false, const QString & = QString()) const = 0; - virtual DownloadJob *downloadJob(bool armor = false) const = 0; - virtual DeleteJob *deleteJob() const = 0; - virtual SignEncryptJob *signEncryptJob(bool armor = false, bool textMode = false) const = 0; - virtual DecryptVerifyJob *decryptVerifyJob(bool textmode = false) const = 0; - - /** - * For S/MIME keys this job performs a full validation check of the keys - * with updated CRLs. - * For OpenPGP keys, use receiveKeysJob. - */ - virtual RefreshKeysJob *refreshKeysJob() const = 0; - virtual ChangeExpiryJob *changeExpiryJob() const = 0; - virtual SignKeyJob *signKeyJob() const = 0; - virtual ChangePasswdJob *changePasswdJob() const = 0; - virtual ChangeOwnerTrustJob *changeOwnerTrustJob() const = 0; - virtual AddUserIDJob *addUserIDJob() const = 0; - virtual SpecialJob *specialJob(const char *type, const QMap<QString, QVariant> &args) const = 0; - - /** A key locate job. - * - * This tries to find a key in local - * and remote sources, if the key was remote it is imported - * by GnuPG. Same as KeyListJob but intended to be used - * to locate keys automatically. This ends up calling --locate-keys. - * - * Only available for OpenPGP - * - * Results are validated. As if keyListJob was called - * with both includeSigs and validate options. - */ - virtual KeyListJob *locateKeysJob() const = 0; - /** Find the best key to use for a mailbox. */ - virtual KeyForMailboxJob *keyForMailboxJob() const = 0; - - /** A Job for interacting with gnupg's wks tools. */ - virtual WKSPublishJob *wksPublishJob() const = 0; - - /** A Job to set tofu policy */ - virtual TofuPolicyJob *tofuPolicyJob() const = 0; - - /** A Job for the quick commands */ - virtual QuickJob *quickJob() const = 0; - - /** This job looks up a key via WKD without importing it. */ - virtual WKDLookupJob *wkdLookupJob() const = 0; - - virtual ExportJob *secretSubkeyExportJob(bool armor = false) const = 0; - virtual AddExistingSubkeyJob *addExistingSubkeyJob() const = 0; - virtual ReceiveKeysJob *receiveKeysJob() const = 0; - - virtual RevokeKeyJob *revokeKeyJob() const = 0; - - /** - * Returns a job for flagging a user ID as the primary user ID of an - * OpenPGP key. - */ - virtual SetPrimaryUserIDJob *setPrimaryUserIDJob() const = 0; - - virtual EncryptArchiveJob *encryptArchiveJob(bool armor = false) const = 0; - virtual SignArchiveJob *signArchiveJob(bool armor = false) const = 0; - virtual SignEncryptArchiveJob *signEncryptArchiveJob(bool armor = false) const = 0; - virtual DecryptVerifyArchiveJob *decryptVerifyArchiveJob() const = 0; - - virtual WKDRefreshJob *wkdRefreshJob() const = 0; -}; - -/** Obtain a reference to the OpenPGP Protocol. - * - * The reference is to a static object. - * @returns Reference to the OpenPGP Protocol. - */ -QGPGME_EXPORT Protocol *openpgp(); - -/** Obtain a reference to the smime Protocol. - * - * The reference is to a static object. - * @returns Reference to the smime Protocol. - */ -QGPGME_EXPORT Protocol *smime(); - -/** Obtain a reference to a cryptoConfig object. - * - * The reference is to a static object. - * @returns reference to cryptoConfig object. - */ -QGPGME_EXPORT CryptoConfig *cryptoConfig(); - -/** Obtain a reference to a protocol agnostic GpgCardJob. - * - * The reference is to a static object. - * @returns reference to a GpgCardJob following the job pattern. - */ -QGPGME_EXPORT GpgCardJob *gpgCardJob(); - -} -#endif diff --git a/lang/qt/src/protocol_p.h b/lang/qt/src/protocol_p.h deleted file mode 100644 index b34b7a37..00000000 --- a/lang/qt/src/protocol_p.h +++ /dev/null @@ -1,575 +0,0 @@ -/* - protocol_p.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2005 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2022 by g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifndef __QGPGME_PROTOCOL_P_H__ -#define __QGPGME_PROTOCOL_P_H__ -#include "qgpgmenewcryptoconfig.h" - -#include "qgpgmekeygenerationjob.h" -#include "qgpgmekeylistjob.h" -#include "qgpgmelistallkeysjob.h" -#include "qgpgmedecryptjob.h" -#include "qgpgmedecryptverifyarchivejob.h" -#include "qgpgmedecryptverifyjob.h" -#include "qgpgmerefreshsmimekeysjob.h" -#include "qgpgmedeletejob.h" -#include "qgpgmedownloadjob.h" -#include "qgpgmesignencryptjob.h" -#include "qgpgmeencryptarchivejob.h" -#include "qgpgmeencryptjob.h" -#include "qgpgmesignarchivejob.h" -#include "qgpgmesignencryptarchivejob.h" -#include "qgpgmesignjob.h" -#include "qgpgmesignkeyjob.h" -#include "qgpgmeexportjob.h" -#include "qgpgmeverifydetachedjob.h" -#include "qgpgmeimportjob.h" -#include "qgpgmeimportfromkeyserverjob.h" -#include "qgpgmeverifyopaquejob.h" -#include "qgpgmechangeexpiryjob.h" -#include "qgpgmechangeownertrustjob.h" -#include "qgpgmechangepasswdjob.h" -#include "qgpgmeaddexistingsubkeyjob.h" -#include "qgpgmeadduseridjob.h" -#include "qgpgmekeyformailboxjob.h" -#include "qgpgmewkdlookupjob.h" -#include "qgpgmewkspublishjob.h" -#include "qgpgmetofupolicyjob.h" -#include "qgpgmequickjob.h" -#include "qgpgmereceivekeysjob.h" -#include "qgpgmerevokekeyjob.h" -#include "qgpgmesetprimaryuseridjob.h" -#include "qgpgmewkdrefreshjob.h" - -namespace -{ - -class Protocol : public QGpgME::Protocol -{ - GpgME::Protocol mProtocol; -public: - explicit Protocol(GpgME::Protocol proto) : mProtocol(proto) {} - - QString name() const override - { - switch (mProtocol) { - case GpgME::OpenPGP: return QStringLiteral("OpenPGP"); - case GpgME::CMS: return QStringLiteral("SMIME"); - default: return QString(); - } - } - - QString displayName() const override - { - // ah (2.4.16): Where is this used and isn't this inverted - // with name - switch (mProtocol) { - case GpgME::OpenPGP: return QStringLiteral("gpg"); - case GpgME::CMS: return QStringLiteral("gpgsm"); - default: return QStringLiteral("unknown"); - } - } - - QGpgME::SpecialJob *specialJob(const char *, const QMap<QString, QVariant> &) const override - { - return nullptr; - } - - QGpgME::KeyListJob *keyListJob(bool remote, bool includeSigs, bool validate) const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - - unsigned int mode = context->keyListMode(); - if (remote) { - mode |= GpgME::Extern; - mode &= ~GpgME::Local; - } else { - mode |= GpgME::Local; - mode &= ~GpgME::Extern; - } - if (includeSigs) { - mode |= GpgME::Signatures; - } - if (validate) { - mode |= GpgME::Validate; - } - context->setKeyListMode(mode); - return new QGpgME::QGpgMEKeyListJob(context); - } - - QGpgME::ListAllKeysJob *listAllKeysJob(bool includeSigs, bool validate) const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - - unsigned int mode = context->keyListMode(); - mode |= GpgME::Local; - mode &= ~GpgME::Extern; - if (includeSigs) { - mode |= GpgME::Signatures; - } - if (validate) { - mode |= GpgME::Validate; - /* Setting the context to offline mode disables CRL / OCSP checks in - this Job. Otherwise we would try to fetch the CRL's for all CMS - keys in the users keyring because GpgME::Validate includes remote - resources by default in the validity check. - This setting only has any effect if gpgsm >= 2.1.6 is used. - */ - context->setOffline(true); - } - context->setKeyListMode(mode); - return new QGpgME::QGpgMEListAllKeysJob(context); - } - - QGpgME::EncryptJob *encryptJob(bool armor, bool textmode) const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - - context->setArmor(armor); - context->setTextMode(textmode); - return new QGpgME::QGpgMEEncryptJob(context); - } - - QGpgME::DecryptJob *decryptJob() const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMEDecryptJob(context); - } - - QGpgME::SignJob *signJob(bool armor, bool textMode) const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - - context->setArmor(armor); - context->setTextMode(textMode); - return new QGpgME::QGpgMESignJob(context); - } - - QGpgME::VerifyDetachedJob *verifyDetachedJob(bool textMode) const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - - context->setTextMode(textMode); - return new QGpgME::QGpgMEVerifyDetachedJob(context); - } - - QGpgME::VerifyOpaqueJob *verifyOpaqueJob(bool textMode) const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - - context->setTextMode(textMode); - return new QGpgME::QGpgMEVerifyOpaqueJob(context); - } - - QGpgME::KeyGenerationJob *keyGenerationJob() const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMEKeyGenerationJob(context); - } - - QGpgME::ImportJob *importJob() const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMEImportJob(context); - } - - QGpgME::ImportFromKeyserverJob *importFromKeyserverJob() const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMEImportFromKeyserverJob(context); - } - - QGpgME::ReceiveKeysJob *receiveKeysJob() const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; - } - - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMEReceiveKeysJob{context}; - } - - QGpgME::ExportJob *publicKeyExportJob(bool armor) const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - - context->setArmor(armor); - return new QGpgME::QGpgMEExportJob(context); - } - - QGpgME::ExportJob *secretKeyExportJob(bool armor, const QString &) const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - - context->setArmor(armor); - return new QGpgME::QGpgMEExportJob(context, GpgME::Context::ExportSecret); - } - - QGpgME::ExportJob *secretSubkeyExportJob(bool armor) const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - - context->setArmor(armor); - return new QGpgME::QGpgMEExportJob(context, GpgME::Context::ExportSecretSubkey); - } - - QGpgME::RefreshKeysJob *refreshKeysJob() const override - { - if (mProtocol != GpgME::CMS) { - return nullptr; - } - - return new QGpgME::QGpgMERefreshSMIMEKeysJob; - } - - QGpgME::DownloadJob *downloadJob(bool armor) const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - - context->setArmor(armor); - // this is the hackish interface for downloading from keyserers currently: - context->setKeyListMode(GpgME::Extern); - return new QGpgME::QGpgMEDownloadJob(context); - } - - QGpgME::DeleteJob *deleteJob() const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMEDeleteJob(context); - } - - QGpgME::SignEncryptJob *signEncryptJob(bool armor, bool textMode) const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - - context->setArmor(armor); - context->setTextMode(textMode); - return new QGpgME::QGpgMESignEncryptJob(context); - } - - QGpgME::DecryptVerifyJob *decryptVerifyJob(bool textMode) const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - - context->setTextMode(textMode); - return new QGpgME::QGpgMEDecryptVerifyJob(context); - } - - QGpgME::ChangeExpiryJob *changeExpiryJob() const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; // only supported by gpg - } - - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMEChangeExpiryJob(context); - } - - QGpgME::ChangePasswdJob *changePasswdJob() const override - { - if (!GpgME::hasFeature(GpgME::PasswdFeature, 0)) { - return nullptr; - } - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMEChangePasswdJob(context); - } - - QGpgME::SignKeyJob *signKeyJob() const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; // only supported by gpg - } - - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMESignKeyJob(context); - } - - QGpgME::ChangeOwnerTrustJob *changeOwnerTrustJob() const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; // only supported by gpg - } - - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMEChangeOwnerTrustJob(context); - } - - QGpgME:: AddExistingSubkeyJob *addExistingSubkeyJob() const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; // only supported by gpg - } - - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMEAddExistingSubkeyJob{context}; - } - - QGpgME::AddUserIDJob *addUserIDJob() const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; // only supported by gpg - } - - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMEAddUserIDJob(context); - } - - QGpgME::KeyListJob *locateKeysJob() const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; - } - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - context->setKeyListMode(GpgME::Locate | GpgME::Signatures | GpgME::Validate); - return new QGpgME::QGpgMEKeyListJob(context); - } - - QGpgME::KeyForMailboxJob *keyForMailboxJob() const override - { - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMEKeyForMailboxJob(context); - } - - QGpgME::WKDLookupJob *wkdLookupJob() const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; - } - auto context = GpgME::Context::createForEngine(GpgME::AssuanEngine); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMEWKDLookupJob(context.release()); - } - - QGpgME::WKSPublishJob *wksPublishJob() const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; - } - auto context = GpgME::Context::createForEngine(GpgME::SpawnEngine); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMEWKSPublishJob(context.release()); - } - - QGpgME::TofuPolicyJob *tofuPolicyJob() const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; - } - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMETofuPolicyJob(context); - } - - QGpgME::QuickJob *quickJob() const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; - } - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMEQuickJob(context); - } - - QGpgME::RevokeKeyJob *revokeKeyJob() const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; - } - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMERevokeKeyJob(context); - } - - QGpgME::SetPrimaryUserIDJob *setPrimaryUserIDJob() const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; - } - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMESetPrimaryUserIDJob{context}; - } - - QGpgME::EncryptArchiveJob *encryptArchiveJob(bool armor) const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; - } - if (auto context = GpgME::Context::createForProtocol(mProtocol)) { - context->setArmor(armor); - return new QGpgME::QGpgMEEncryptArchiveJob{context}; - } - return nullptr; - } - - QGpgME::SignArchiveJob *signArchiveJob(bool armor) const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; - } - if (auto context = GpgME::Context::createForProtocol(mProtocol)) { - context->setArmor(armor); - return new QGpgME::QGpgMESignArchiveJob{context}; - } - return nullptr; - } - - QGpgME::SignEncryptArchiveJob *signEncryptArchiveJob(bool armor) const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; - } - if (auto context = GpgME::Context::createForProtocol(mProtocol)) { - context->setArmor(armor); - return new QGpgME::QGpgMESignEncryptArchiveJob{context}; - } - return nullptr; - } - - QGpgME::DecryptVerifyArchiveJob *decryptVerifyArchiveJob() const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; - } - if (auto context = GpgME::Context::createForProtocol(mProtocol)) { - return new QGpgME::QGpgMEDecryptVerifyArchiveJob{context}; - } - return nullptr; - } - - QGpgME::WKDRefreshJob *wkdRefreshJob() const override - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; - } - if (auto context = GpgME::Context::createForProtocol(mProtocol)) { - return new QGpgME::QGpgMEWKDRefreshJob{context}; - } - return nullptr; - } -}; - -} -#endif diff --git a/lang/qt/src/qgpgme_debug.cpp b/lang/qt/src/qgpgme_debug.cpp deleted file mode 100644 index 513a9b08..00000000 --- a/lang/qt/src/qgpgme_debug.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgme_debug.h" - - -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) -Q_LOGGING_CATEGORY(QGPGME_LOG, "gpg.qgpgme", QtWarningMsg) -Q_LOGGING_CATEGORY(QGPGME_CONFIG_LOADING_LOG, "gpg.qgpgme.config_loading", QtInfoMsg) -#else -Q_LOGGING_CATEGORY(QGPGME_LOG, "gpg.qgpgme") -Q_LOGGING_CATEGORY(QGPGME_CONFIG_LOADING_LOG, "gpg.qgpgme.config_loading") -#endif diff --git a/lang/qt/src/qgpgme_debug.h b/lang/qt/src/qgpgme_debug.h deleted file mode 100644 index 9cdd1a8c..00000000 --- a/lang/qt/src/qgpgme_debug.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef QGPGME_QGPGME_DEBUG_H -#define QGPGME_QGPGME_DEBUG_H - -#include <QLoggingCategory> - -Q_DECLARE_LOGGING_CATEGORY(QGPGME_LOG) -Q_DECLARE_LOGGING_CATEGORY(QGPGME_CONFIG_LOADING_LOG) - - -#endif diff --git a/lang/qt/src/qgpgme_export.h b/lang/qt/src/qgpgme_export.h deleted file mode 100644 index 72927fe3..00000000 --- a/lang/qt/src/qgpgme_export.h +++ /dev/null @@ -1,84 +0,0 @@ -/* qgpgme_export.h - Export macros for qgpgme - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef QGPGME_EXPORT_H -#define QGPGME_EXPORT_H - -#ifdef QGPGME_STATIC_DEFINE -# define QGPGME_EXPORT -# define QGPGME_NO_EXPORT -#else -# ifndef QGPGME_EXPORT -# ifdef BUILDING_QGPGME - /* We are building this library */ -# ifdef WIN32 -# define QGPGME_EXPORT __declspec(dllexport) -# else -# define QGPGME_EXPORT __attribute__((visibility("default"))) -# endif -# else - /* We are using this library */ -# ifdef WIN32 -# define QGPGME_EXPORT __declspec(dllimport) -# else -# define QGPGME_EXPORT __attribute__((visibility("default"))) -# endif -# endif -# endif - -# ifndef QGPGME_NO_EXPORT -# ifdef WIN32 -# define QGPGME_NO_EXPORT -# else -# define QGPGME_NO_EXPORT __attribute__((visibility("hidden"))) -# endif -# endif -#endif - -#ifndef QGPGME_DEPRECATED -# define QGPGME_DEPRECATED __attribute__ ((__deprecated__)) -#endif - -#ifndef QGPGME_DEPRECATED_EXPORT -# define QGPGME_DEPRECATED_EXPORT QGPGME_EXPORT QGPGME_DEPRECATED -#endif - -#ifndef QGPGME_DEPRECATED_NO_EXPORT -# define QGPGME_DEPRECATED_NO_EXPORT QGPGME_NO_EXPORT QGPGME_DEPRECATED -#endif - -#define DEFINE_NO_DEPRECATED 0 -#if DEFINE_NO_DEPRECATED -# define QGPGME_NO_DEPRECATED -#endif - -#endif diff --git a/lang/qt/src/qgpgme_version.h.in b/lang/qt/src/qgpgme_version.h.in deleted file mode 100644 index 1bc56949..00000000 --- a/lang/qt/src/qgpgme_version.h.in +++ /dev/null @@ -1,42 +0,0 @@ -/* qgpgme_version.h - Version macros for qgpgme - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - - -#ifndef QGPGME_VERSION_H -#define QGPGME_VERSION_H - -#define QGPGME_VERSION_STRING "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_MICRO@" -#define QGPGME_VERSION_MAJOR @VERSION_MAJOR@ -#define QGPGME_VERSION_MINOR @VERSION_MINOR@ -#define QGPGME_VERSION_PATCH @VERSION_MICRO@ -#define QGPGME_VERSION ((@VERSION_MAJOR@<<16)|(@VERSION_MINOR@<<8)|(@VERSION_MICRO@)) - -#endif diff --git a/lang/qt/src/qgpgmeaddexistingsubkeyjob.cpp b/lang/qt/src/qgpgmeaddexistingsubkeyjob.cpp deleted file mode 100644 index 7750d36b..00000000 --- a/lang/qt/src/qgpgmeaddexistingsubkeyjob.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - qgpgmeaddexistingsubkeyjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmeaddexistingsubkeyjob.h" - -#include "dataprovider.h" - -#include <QDateTime> - -#include <gpgme++/context.h> -#include <gpgme++/data.h> -#include <gpgme++/gpgaddexistingsubkeyeditinteractor.h> -#include <gpgme++/key.h> - -#include <gpg-error.h> - -using namespace QGpgME; -using namespace GpgME; - -QGpgMEAddExistingSubkeyJob::QGpgMEAddExistingSubkeyJob(Context *context) - : mixin_type{context} -{ - lateInitialization(); -} - -QGpgMEAddExistingSubkeyJob::~QGpgMEAddExistingSubkeyJob() = default; - -static QGpgMEAddExistingSubkeyJob::result_type add_subkey(Context *ctx, const Key &key, const Subkey &subkey) -{ - std::unique_ptr<GpgAddExistingSubkeyEditInteractor> interactor{new GpgAddExistingSubkeyEditInteractor{subkey.keyGrip()}}; - - if (!subkey.neverExpires()) { - const auto expiry = QDateTime::fromSecsSinceEpoch(uint_least32_t(subkey.expirationTime()), - Qt::UTC).toString(u"yyyyMMdd'T'hhmmss").toStdString(); - interactor->setExpiry(expiry); - } - - QGpgME::QByteArrayDataProvider dp; - Data data(&dp); - assert(!data.isNull()); - - ctx->setFlag("extended-edit", "1"); - - const Error err = ctx->edit(key, std::unique_ptr<EditInteractor>(interactor.release()), data); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(err, log, ae); -} - -Error QGpgMEAddExistingSubkeyJob::start(const GpgME::Key &key, const GpgME::Subkey &subkey) -{ - run(std::bind(&add_subkey, std::placeholders::_1, key, subkey)); - return {}; -} - -Error QGpgMEAddExistingSubkeyJob::exec(const GpgME::Key &key, const GpgME::Subkey &subkey) -{ - const result_type r = add_subkey(context(), key, subkey); - return std::get<0>(r); -} - -#include "qgpgmeaddexistingsubkeyjob.moc" diff --git a/lang/qt/src/qgpgmeaddexistingsubkeyjob.h b/lang/qt/src/qgpgmeaddexistingsubkeyjob.h deleted file mode 100644 index 15727552..00000000 --- a/lang/qt/src/qgpgmeaddexistingsubkeyjob.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - qgpgmeaddexistingsubkeyjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEADDEXISTINGSUBKEYJOB_H__ -#define __QGPGME_QGPGMEADDEXISTINGSUBKEYJOB_H__ - -#include "threadedjobmixin.h" -#include "addexistingsubkeyjob.h" - -namespace QGpgME -{ - -class QGpgMEAddExistingSubkeyJob -#ifdef Q_MOC_RUN - : public AddExistingSubkeyJob -#else - : public _detail::ThreadedJobMixin<AddExistingSubkeyJob> -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEAddExistingSubkeyJob(GpgME::Context *context); - ~QGpgMEAddExistingSubkeyJob(); - - /* from AddExistingSubkeyJob */ - GpgME::Error start(const GpgME::Key &key, const GpgME::Subkey &subkey) override; - - /* from AddExistingSubkeyJob */ - GpgME::Error exec(const GpgME::Key &key, const GpgME::Subkey &subkey) override; -}; - -} - -#endif // __QGPGME_QGPGMEADDEXISTINGSUBKEYJOB_H__ diff --git a/lang/qt/src/qgpgmeadduseridjob.cpp b/lang/qt/src/qgpgmeadduseridjob.cpp deleted file mode 100644 index 3dec6581..00000000 --- a/lang/qt/src/qgpgmeadduseridjob.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - qgpgmeadduseridjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmeadduseridjob.h" - -#include "dataprovider.h" - -#include <gpgme++/context.h> -#include <gpgme++/data.h> -#include <gpgme++/gpgadduserideditinteractor.h> -#include <gpgme++/key.h> - -#include <cassert> -#include <memory> - -using namespace QGpgME; -using namespace GpgME; - -QGpgMEAddUserIDJob::QGpgMEAddUserIDJob(Context *context) - : mixin_type(context) -{ - lateInitialization(); -} - -QGpgMEAddUserIDJob::~QGpgMEAddUserIDJob() {} - -static QGpgMEAddUserIDJob::result_type add_user_id(Context *ctx, const Key &key, const QString &name, const QString &email, const QString &comment) -{ - - GpgAddUserIDEditInteractor *gau = new GpgAddUserIDEditInteractor; - - gau->setNameUtf8(name.toUtf8().constData()); - gau->setEmailUtf8(email.toUtf8().constData()); - gau->setCommentUtf8(comment.toUtf8().constData()); - - QGpgME::QByteArrayDataProvider dp; - Data data(&dp); - assert(!data.isNull()); - const Error err = ctx->edit(key, std::unique_ptr<EditInteractor> (gau), data); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(err, log, ae); -} - -Error QGpgMEAddUserIDJob::start(const Key &key, const QString &name, const QString &email, const QString &comment) -{ - run(std::bind(&add_user_id, std::placeholders::_1, key, name, email, comment)); - return Error(); -} -#include "qgpgmeadduseridjob.moc" diff --git a/lang/qt/src/qgpgmeadduseridjob.h b/lang/qt/src/qgpgmeadduseridjob.h deleted file mode 100644 index 26395ba5..00000000 --- a/lang/qt/src/qgpgmeadduseridjob.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - qgpgmeadduseridjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEADDUSERIDJOB_H__ -#define __QGPGME_QGPGMEADDUSERIDJOB_H__ - -#include "adduseridjob.h" - -#include "threadedjobmixin.h" - -namespace QGpgME -{ - -class QGpgMEAddUserIDJob -#ifdef Q_MOC_RUN - : public AddUserIDJob -#else - : public _detail::ThreadedJobMixin<AddUserIDJob> -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -private Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEAddUserIDJob(GpgME::Context *context); - ~QGpgMEAddUserIDJob(); - - /* from AddUserIDJob */ - GpgME::Error start(const GpgME::Key &key, const QString &name, const QString &email, const QString &comment) override; -}; -} - -#endif // __QGPGME_QGPGMEADDUSERIDJOB_H__ diff --git a/lang/qt/src/qgpgmebackend.cpp b/lang/qt/src/qgpgmebackend.cpp deleted file mode 100644 index 9cd34006..00000000 --- a/lang/qt/src/qgpgmebackend.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/* - qgpgmebackend.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2005 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmebackend.h" - -#include "qgpgmegpgcardjob.h" - -#include <gpgme++/error.h> -#include <gpgme++/engineinfo.h> - -#include "protocol_p.h" - -#include <QFile> -#include <QString> - -const char QGpgME::QGpgMEBackend::OpenPGP[] = "OpenPGP"; -const char QGpgME::QGpgMEBackend::SMIME[] = "SMIME"; - - -QGpgME::QGpgMEBackend::QGpgMEBackend() - : mCryptoConfig(nullptr), - mOpenPGPProtocol(nullptr), - mSMIMEProtocol(nullptr) -{ - GpgME::initializeLibrary(); -} - -QGpgME::QGpgMEBackend::~QGpgMEBackend() -{ - delete mCryptoConfig; mCryptoConfig = nullptr; - delete mOpenPGPProtocol; mOpenPGPProtocol = nullptr; - delete mSMIMEProtocol; mSMIMEProtocol = nullptr; -} - -QString QGpgME::QGpgMEBackend::name() const -{ - return QStringLiteral("gpgme"); -} - -QString QGpgME::QGpgMEBackend::displayName() const -{ - return QStringLiteral("GpgME"); -} - -QGpgME::CryptoConfig *QGpgME::QGpgMEBackend::config() const -{ - if (!mCryptoConfig) { - if (GpgME::hasFeature(GpgME::GpgConfEngineFeature, 0)) { - mCryptoConfig = new QGpgMENewCryptoConfig; - } - } - return mCryptoConfig; -} - -QGpgME::GpgCardJob *QGpgME::QGpgMEBackend::gpgCardJob() const -{ - return new QGpgME::QGpgMEGpgCardJob(); -} - -static bool check(GpgME::Protocol proto, QString *reason) -{ - if (!GpgME::checkEngine(proto)) { - return true; - } - if (!reason) { - return false; - } - // error, check why: -#if 0 -Port away from localised string or delete. - const GpgME::EngineInfo ei = GpgME::engineInfo(proto); - if (ei.isNull()) { - *reason = i18n("GPGME was compiled without support for %1.", proto == GpgME::CMS ? QLatin1String("S/MIME") : QLatin1String("OpenPGP")); - } else if (ei.fileName() && !ei.version()) { - *reason = i18n("Engine %1 is not installed properly.", QFile::decodeName(ei.fileName())); - } else if (ei.fileName() && ei.version() && ei.requiredVersion()) - *reason = i18n("Engine %1 version %2 installed, " - "but at least version %3 is required.", - QFile::decodeName(ei.fileName()), QLatin1String(ei.version()), QLatin1String(ei.requiredVersion())); - else { - *reason = i18n("Unknown problem with engine for protocol %1.", proto == GpgME::CMS ? QLatin1String("S/MIME") : QLatin1String("OpenPGP")); - } -#endif - return false; -} - -bool QGpgME::QGpgMEBackend::checkForOpenPGP(QString *reason) const -{ - return check(GpgME::OpenPGP, reason); -} - -bool QGpgME::QGpgMEBackend::checkForSMIME(QString *reason) const -{ - return check(GpgME::CMS, reason); -} - -bool QGpgME::QGpgMEBackend::checkForProtocol(const char *name, QString *reason) const -{ - if (qstricmp(name, OpenPGP) == 0) { - return check(GpgME::OpenPGP, reason); - } - if (qstricmp(name, SMIME) == 0) { - return check(GpgME::CMS, reason); - } - if (reason) { - *reason = QStringLiteral("Unsupported protocol \"%1\"").arg(QLatin1String(name)); - } - return false; -} - -QGpgME::Protocol *QGpgME::QGpgMEBackend::openpgp() const -{ - if (!mOpenPGPProtocol) - if (checkForOpenPGP()) { - mOpenPGPProtocol = new ::Protocol(GpgME::OpenPGP); - } - return mOpenPGPProtocol; -} - -QGpgME::Protocol *QGpgME::QGpgMEBackend::smime() const -{ - if (!mSMIMEProtocol) - if (checkForSMIME()) { - mSMIMEProtocol = new ::Protocol(GpgME::CMS); - } - return mSMIMEProtocol; -} - -QGpgME::Protocol *QGpgME::QGpgMEBackend::protocol(const char *name) const -{ - if (qstricmp(name, OpenPGP) == 0) { - return openpgp(); - } - if (qstricmp(name, SMIME) == 0) { - return smime(); - } - return nullptr; -} - -bool QGpgME::QGpgMEBackend::supportsProtocol(const char *name) const -{ - return qstricmp(name, OpenPGP) == 0 || qstricmp(name, SMIME) == 0; -} - -const char *QGpgME::QGpgMEBackend::enumerateProtocols(int i) const -{ - switch (i) { - case 0: return OpenPGP; - case 1: return SMIME; - default: return nullptr; - } -} - -static QGpgME::QGpgMEBackend *gpgmeBackend; - -QGpgME::CryptoConfig *QGpgME::cryptoConfig() -{ - if (!gpgmeBackend) { - gpgmeBackend = new QGpgME::QGpgMEBackend(); - } - return gpgmeBackend->config(); - -} - -QGpgME::Protocol *QGpgME::openpgp() -{ - if (!gpgmeBackend) { - gpgmeBackend = new QGpgME::QGpgMEBackend(); - } - return gpgmeBackend->openpgp(); -} - -QGpgME::Protocol *QGpgME::smime() -{ - if (!gpgmeBackend) { - gpgmeBackend = new QGpgME::QGpgMEBackend(); - } - return gpgmeBackend->smime(); -} - -QGpgME::GpgCardJob *QGpgME::gpgCardJob () -{ - if (!gpgmeBackend) { - gpgmeBackend = new QGpgME::QGpgMEBackend(); - } - return gpgmeBackend->gpgCardJob(); -} diff --git a/lang/qt/src/qgpgmebackend.h b/lang/qt/src/qgpgmebackend.h deleted file mode 100644 index 2e26d4a3..00000000 --- a/lang/qt/src/qgpgmebackend.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - qgpgmebackend.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2005 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEBACKEND_H__ -#define __QGPGME_QGPGMEBACKEND_H__ - -#include <QString> - -#include "protocol.h" - -class QString; -template <typename T_Key, typename T_Value> class QMap; - -namespace QGpgME -{ -class CryptoConfig; -class Protocol; -class GpgCardJob; - - -class QGpgMEBackend -{ -public: - QGpgMEBackend(); - ~QGpgMEBackend(); - - QString name() const; - QString displayName() const; - - CryptoConfig *config() const; - GpgCardJob *gpgCardJob() const; - - Protocol *openpgp() const; - Protocol *smime() const; - Protocol *protocol(const char *name) const; - - static const char OpenPGP[]; - static const char SMIME[]; - - bool checkForOpenPGP(QString *reason = nullptr) const; - bool checkForSMIME(QString *reason = nullptr) const; - bool checkForProtocol(const char *name, QString *reason) const; - - bool supportsOpenPGP() const - { - return true; - } - bool supportsSMIME() const - { - return true; - } - bool supportsProtocol(const char *name) const; - - const char *enumerateProtocols(int i) const; - -private: - mutable QGpgME::CryptoConfig *mCryptoConfig; - mutable Protocol *mOpenPGPProtocol; - mutable Protocol *mSMIMEProtocol; -}; - -} - -#endif // __QGPGME_QGPGMEBACKEND_H__ diff --git a/lang/qt/src/qgpgmechangeexpiryjob.cpp b/lang/qt/src/qgpgmechangeexpiryjob.cpp deleted file mode 100644 index 7f98a943..00000000 --- a/lang/qt/src/qgpgmechangeexpiryjob.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - qgpgmechangeexpiryjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2021,2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmechangeexpiryjob.h" - -#include "changeexpiryjob_p.h" - -#include <gpgme++/context.h> -#include <gpgme++/key.h> - -#include <QDateTime> - -using namespace QGpgME; -using namespace GpgME; - -namespace -{ - -class QGpgMEChangeExpiryJobPrivate : public ChangeExpiryJobPrivate -{ - QGpgMEChangeExpiryJob *q = nullptr; - -public: - QGpgMEChangeExpiryJobPrivate(QGpgMEChangeExpiryJob *qq) - : q{qq} - { - } - - ~QGpgMEChangeExpiryJobPrivate() override = default; - -private: - GpgME::Error startIt() override - { - Q_ASSERT(!"Not supported by this Job class."); - return Error::fromCode(GPG_ERR_NOT_SUPPORTED); - } - - void startNow() override - { - q->run(); - } -}; - -} - -QGpgMEChangeExpiryJob::QGpgMEChangeExpiryJob(Context *context) - : mixin_type(context) -{ - setJobPrivate(this, std::unique_ptr<QGpgMEChangeExpiryJobPrivate>{new QGpgMEChangeExpiryJobPrivate{this}}); - lateInitialization(); -} - -QGpgMEChangeExpiryJob::~QGpgMEChangeExpiryJob() {} - -static QGpgMEChangeExpiryJob::result_type change_expiry(Context *ctx, const Key &key, const QDateTime &expiry, - const std::vector<Subkey> &subkeys, ChangeExpiryJob::Options options) -{ - // convert expiry to "seconds from now"; use 1 second from now if expiry is before the current datetime - const unsigned long expires = expiry.isValid() - ? std::max<qint64>(QDateTime::currentDateTime().secsTo(expiry), 1) - : 0; - - // updating the expiration date of the primary key and the subkeys needs to be done in two steps - // because --quick-set-expire does not support updating the expiration date of both at the same time - - if (subkeys.empty() || (options & ChangeExpiryJob::UpdatePrimaryKey)) { - // update the expiration date of the primary key - auto err = ctx->setExpire(key, expires); - if (err || err.isCanceled()) { - return std::make_tuple(err, QString(), Error()); - } - } - - GpgME::Error err; - if (!subkeys.empty()) { - // update the expiration date of the specified subkeys - err = ctx->setExpire(key, expires, subkeys); - } else if (options & ChangeExpiryJob::UpdateAllSubkeys) { - // update the expiration date of all subkeys - err = ctx->setExpire(key, expires, {}, Context::SetExpireAllSubkeys); - } - return std::make_tuple(err, QString(), Error()); -} - -Error QGpgMEChangeExpiryJob::start(const Key &key, const QDateTime &expiry) -{ - return start(key, expiry, std::vector<Subkey>()); -} - -Error QGpgMEChangeExpiryJob::start(const Key &key, const QDateTime &expiry, const std::vector<Subkey> &subkeys) -{ - run(std::bind(&change_expiry, std::placeholders::_1, key, expiry, subkeys, options())); - return Error(); -} - -#include "qgpgmechangeexpiryjob.moc" diff --git a/lang/qt/src/qgpgmechangeexpiryjob.h b/lang/qt/src/qgpgmechangeexpiryjob.h deleted file mode 100644 index ac66e4f7..00000000 --- a/lang/qt/src/qgpgmechangeexpiryjob.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - qgpgmechangeexpiryjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMECHANGEEXPIRYJOB_H__ -#define __QGPGME_QGPGMECHANGEEXPIRYJOB_H__ - -#include "changeexpiryjob.h" - -#include "threadedjobmixin.h" - -namespace QGpgME -{ - -class QGpgMEChangeExpiryJob -#ifdef Q_MOC_RUN - : public ChangeExpiryJob -#else - : public _detail::ThreadedJobMixin<ChangeExpiryJob> -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -private Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEChangeExpiryJob(GpgME::Context *context); - ~QGpgMEChangeExpiryJob(); - - /* from ChangeExpiryJob */ - GpgME::Error start(const GpgME::Key &key, const QDateTime &expiry) override; - - /* from ChangeExpiryJob */ - GpgME::Error start(const GpgME::Key &key, const QDateTime &expiry, - const std::vector<GpgME::Subkey> &subkeys) override; - -}; - -} - -#endif // __QGPGME_QGPGMECHANGEEXPIRYJOB_H__ diff --git a/lang/qt/src/qgpgmechangeownertrustjob.cpp b/lang/qt/src/qgpgmechangeownertrustjob.cpp deleted file mode 100644 index 2c8c4e53..00000000 --- a/lang/qt/src/qgpgmechangeownertrustjob.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - qgpgmechangeownertrustjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2024 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmechangeownertrustjob.h" - -#include "dataprovider.h" - -#include <gpgme++/context.h> -#include <gpgme++/data.h> -#include <gpgme++/engineinfo.h> -#include <gpgme++/gpgsetownertrusteditinteractor.h> -#include <gpgme++/key.h> - -#include <cassert> -#include <memory> - -using namespace QGpgME; -using namespace GpgME; - -QGpgMEChangeOwnerTrustJob::QGpgMEChangeOwnerTrustJob(Context *context) - : mixin_type(context) -{ - lateInitialization(); -} - -QGpgMEChangeOwnerTrustJob::~QGpgMEChangeOwnerTrustJob() {} - -static QGpgMEChangeOwnerTrustJob::result_type set_owner_trust(Context *ctx, const Key &key, Key::OwnerTrust trust) -{ - const Error err = ctx->setOwnerTrust(key, trust); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(err, log, ae); -} - -static QGpgMEChangeOwnerTrustJob::result_type change_ownertrust(Context *ctx, const Key &key, Key::OwnerTrust trust) -{ - EditInteractor *ei = new GpgSetOwnerTrustEditInteractor(trust); - - QGpgME::QByteArrayDataProvider dp; - Data data(&dp); - assert(!data.isNull()); - - const Error err = ctx->edit(key, std::unique_ptr<EditInteractor>(ei), data); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(err, log, ae); -} - -Error QGpgMEChangeOwnerTrustJob::start(const Key &key, Key::OwnerTrust trust) -{ - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.4.6") { - run(std::bind(&change_ownertrust, std::placeholders::_1, key, trust)); - } else { - run(std::bind(&set_owner_trust, std::placeholders::_1, key, trust)); - } - return Error(); -} -#include "qgpgmechangeownertrustjob.moc" diff --git a/lang/qt/src/qgpgmechangeownertrustjob.h b/lang/qt/src/qgpgmechangeownertrustjob.h deleted file mode 100644 index 387166e2..00000000 --- a/lang/qt/src/qgpgmechangeownertrustjob.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - qgpgmechangeownertrustjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMECHANGEOWNERTRUSTJOB_H__ -#define __QGPGME_QGPGMECHANGEOWNERTRUSTJOB_H__ - -#include "changeownertrustjob.h" - -#include "threadedjobmixin.h" - -namespace QGpgME -{ - -class QGpgMEChangeOwnerTrustJob -#ifdef Q_MOC_RUN - : public ChangeOwnerTrustJob -#else - : public _detail::ThreadedJobMixin<ChangeOwnerTrustJob> -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -private Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEChangeOwnerTrustJob(GpgME::Context *context); - ~QGpgMEChangeOwnerTrustJob(); - - /* from ChangeOwnerTrustJob */ - GpgME::Error start(const GpgME::Key &key, GpgME::Key::OwnerTrust trust) override; -}; -} - -#endif // __QGPGME_QGPGMECHANGEOWNERTRUSTJOB_H__ diff --git a/lang/qt/src/qgpgmechangepasswdjob.cpp b/lang/qt/src/qgpgmechangepasswdjob.cpp deleted file mode 100644 index 0607b6d3..00000000 --- a/lang/qt/src/qgpgmechangepasswdjob.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - qgpgmechangepasswdjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2010 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmechangepasswdjob.h" - -#include "dataprovider.h" - -#include <gpgme++/context.h> -#include <gpgme++/data.h> -#include <gpgme++/key.h> - -#include <cassert> -#include <memory> - -using namespace QGpgME; -using namespace GpgME; - -QGpgMEChangePasswdJob::QGpgMEChangePasswdJob(Context *context) - : mixin_type(context) -{ - lateInitialization(); -} - -QGpgMEChangePasswdJob::~QGpgMEChangePasswdJob() {} - -static QGpgMEChangePasswdJob::result_type change_passwd(Context *ctx, const Key &key) -{ -#if 0 // in case we want to fall back to edit interactor for gpg... - std::unique_ptr<EditInteractor> ei(new GpgChangePasswdEditInteractor); - - QGpgME::QByteArrayDataProvider dp; - Data data(&dp); - assert(!data.isNull()); - const Error err = ctx->edit(key, ei, data); -#else - const Error err = ctx->passwd(key); -#endif - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(err, log, ae); -} - -Error QGpgMEChangePasswdJob::start(const Key &key) -{ - run(std::bind(&change_passwd, std::placeholders::_1, key)); - return Error(); -} - -#include "qgpgmechangepasswdjob.moc" diff --git a/lang/qt/src/qgpgmechangepasswdjob.h b/lang/qt/src/qgpgmechangepasswdjob.h deleted file mode 100644 index fbd9caa5..00000000 --- a/lang/qt/src/qgpgmechangepasswdjob.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - qgpgmechangepasswdjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2010 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMECHANGEPASSWDJOB_H__ -#define __QGPGME_QGPGMECHANGEPASSWDJOB_H__ - -#include "changepasswdjob.h" - -#include "threadedjobmixin.h" - -namespace QGpgME -{ - -class QGpgMEChangePasswdJob -#ifdef Q_MOC_RUN - : public ChangePasswdJob -#else - : public _detail::ThreadedJobMixin<ChangePasswdJob> -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -private Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEChangePasswdJob(GpgME::Context *context); - ~QGpgMEChangePasswdJob(); - - /* from ChangePasswdJob */ - GpgME::Error start(const GpgME::Key &key) override; -}; - -} - -#endif // __QGPGME_QGPGMECHANGEPASSWDJOB_H__ diff --git a/lang/qt/src/qgpgmedecryptjob.cpp b/lang/qt/src/qgpgmedecryptjob.cpp deleted file mode 100644 index 95240a49..00000000 --- a/lang/qt/src/qgpgmedecryptjob.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - qgpgmedecryptjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmedecryptjob.h" - -#include "dataprovider.h" - -#include <gpgme++/context.h> -#include <gpgme++/decryptionresult.h> -#include <gpgme++/data.h> - -#include <QBuffer> - -#include <cassert> - -using namespace QGpgME; -using namespace GpgME; - -QGpgMEDecryptJob::QGpgMEDecryptJob(Context *context) - : mixin_type(context) -{ - lateInitialization(); -} - -QGpgMEDecryptJob::~QGpgMEDecryptJob() {} - -static QGpgMEDecryptJob::result_type decrypt(Context *ctx, QThread *thread, - const std::weak_ptr<QIODevice> &cipherText_, - const std::weak_ptr<QIODevice> &plainText_) -{ - - const std::shared_ptr<QIODevice> cipherText = cipherText_.lock(); - const std::shared_ptr<QIODevice> plainText = plainText_.lock(); - - const _detail::ToThreadMover ctMover(cipherText, thread); - const _detail::ToThreadMover ptMover(plainText, thread); - - QGpgME::QIODeviceDataProvider in(cipherText); - Data indata(&in); - if (!cipherText->isSequential()) { - indata.setSizeHint(cipherText->size()); - } - - if (!plainText) { - QGpgME::QByteArrayDataProvider out; - Data outdata(&out); - - const DecryptionResult res = ctx->decrypt(indata, outdata); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(res, out.data(), log, ae); - } else { - QGpgME::QIODeviceDataProvider out(plainText); - Data outdata(&out); - - const DecryptionResult res = ctx->decrypt(indata, outdata); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(res, QByteArray(), log, ae); - } - -} - -static QGpgMEDecryptJob::result_type decrypt_qba(Context *ctx, const QByteArray &cipherText) -{ - const std::shared_ptr<QBuffer> buffer(new QBuffer); - buffer->setData(cipherText); - if (!buffer->open(QIODevice::ReadOnly)) { - assert(!"This should never happen: QBuffer::open() failed"); - } - return decrypt(ctx, nullptr, buffer, std::shared_ptr<QIODevice>()); -} - -Error QGpgMEDecryptJob::start(const QByteArray &cipherText) -{ - run(std::bind(&decrypt_qba, std::placeholders::_1, cipherText)); - return Error(); -} - -void QGpgMEDecryptJob::start(const std::shared_ptr<QIODevice> &cipherText, const std::shared_ptr<QIODevice> &plainText) -{ - run(std::bind(&decrypt, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), cipherText, plainText); -} - -GpgME::DecryptionResult QGpgME::QGpgMEDecryptJob::exec(const QByteArray &cipherText, - QByteArray &plainText) -{ - const result_type r = decrypt_qba(context(), cipherText); - plainText = std::get<1>(r); - return std::get<0>(r); -} - -#include "qgpgmedecryptjob.moc" diff --git a/lang/qt/src/qgpgmedecryptjob.h b/lang/qt/src/qgpgmedecryptjob.h deleted file mode 100644 index ae489734..00000000 --- a/lang/qt/src/qgpgmedecryptjob.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - qgpgmedecryptjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEDECRYPTJOB_H__ -#define __QGPGME_QGPGMEDECRYPTJOB_H__ - -#include "decryptjob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/decryptionresult.h> - -namespace QGpgME -{ - -class QGpgMEDecryptJob -#ifdef Q_MOC_RUN - : public DecryptJob -#else - : public _detail::ThreadedJobMixin<DecryptJob, std::tuple<GpgME::DecryptionResult, QByteArray, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -private Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEDecryptJob(GpgME::Context *context); - ~QGpgMEDecryptJob(); - - /* from DecryptJob */ - GpgME::Error start(const QByteArray &cipherText) override; - - /* from DecryptJob */ - void start(const std::shared_ptr<QIODevice> &cipherText, const std::shared_ptr<QIODevice> &plainText) override; - - /* from DecryptJob */ - GpgME::DecryptionResult exec(const QByteArray &cipherText, - QByteArray &plainText) override; -}; - -} -#endif // __QGPGME_QGPGMEDECRYPTJOB_H__ diff --git a/lang/qt/src/qgpgmedecryptverifyarchivejob.cpp b/lang/qt/src/qgpgmedecryptverifyarchivejob.cpp deleted file mode 100644 index 10f07e53..00000000 --- a/lang/qt/src/qgpgmedecryptverifyarchivejob.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - qgpgmedecryptverifyarchivejob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmedecryptverifyarchivejob.h" - -#include "dataprovider.h" -#include "decryptverifyarchivejob_p.h" - -#include <QFile> - -#include <gpgme++/data.h> - -using namespace QGpgME; -using namespace GpgME; - -namespace -{ - -class QGpgMEDecryptVerifyArchiveJobPrivate : public DecryptVerifyArchiveJobPrivate -{ - QGpgMEDecryptVerifyArchiveJob *q = nullptr; - -public: - QGpgMEDecryptVerifyArchiveJobPrivate(QGpgMEDecryptVerifyArchiveJob *qq) - : q{qq} - { - } - - ~QGpgMEDecryptVerifyArchiveJobPrivate() override = default; - -private: - GpgME::Error startIt() override; - - void startNow() override - { - q->run(); - } -}; - -} - -QGpgMEDecryptVerifyArchiveJob::QGpgMEDecryptVerifyArchiveJob(Context *context) - : mixin_type{context} -{ - setJobPrivate(this, std::unique_ptr<QGpgMEDecryptVerifyArchiveJobPrivate>{new QGpgMEDecryptVerifyArchiveJobPrivate{this}}); - lateInitialization(); - connect(this, &Job::rawProgress, this, [this](const QString &what, int type, int current, int total) { - emitArchiveProgressSignals(this, what, type, current, total); - }); -} - -static QGpgMEDecryptVerifyArchiveJob::result_type decrypt_verify(Context *ctx, - const GpgME::Data &indata, - const QString &outputDirectory) -{ - Data outdata; - if (!outputDirectory.isEmpty()) { - outdata.setFileName(outputDirectory.toStdString()); - } - - const auto res = ctx->decryptAndVerify(indata, outdata, Context::DecryptArchive); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(res.first, res.second, log, ae); -} - -static QGpgMEDecryptVerifyArchiveJob::result_type decrypt_verify_from_io_device(Context *ctx, - QThread *thread, - const std::weak_ptr<QIODevice> &cipherText_, - const QString &outputDirectory) -{ - const std::shared_ptr<QIODevice> cipherText = cipherText_.lock(); - const _detail::ToThreadMover ctMover(cipherText, thread); - QGpgME::QIODeviceDataProvider in{cipherText}; - Data indata(&in); - if (!cipherText->isSequential()) { - indata.setSizeHint(cipherText->size()); - } - - return decrypt_verify(ctx, indata, outputDirectory); -} - -static QGpgMEDecryptVerifyArchiveJob::result_type decrypt_verify_from_file_name(Context *ctx, - const QString &inputFile, - const QString &outputDirectory, - bool processAllSignatures) -{ - Data indata; -#ifdef Q_OS_WIN - indata.setFileName(inputFile.toUtf8().constData()); -#else - indata.setFileName(QFile::encodeName(inputFile).constData()); -#endif - - if (processAllSignatures) { - ctx->setFlag("proc-all-sigs", "1"); - } - return decrypt_verify(ctx, indata, outputDirectory); -} - -GpgME::Error QGpgMEDecryptVerifyArchiveJob::start(const std::shared_ptr<QIODevice> &cipherText) -{ - if (!cipherText) { - return Error::fromCode(GPG_ERR_INV_VALUE); - } - - if (processAllSignatures()) { - context()->setFlag("proc-all-sigs", "1"); - } - run(std::bind(&decrypt_verify_from_io_device, - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3, - outputDirectory()), - cipherText); - return {}; -} - -GpgME::Error QGpgMEDecryptVerifyArchiveJobPrivate::startIt() -{ - if (m_inputFilePath.isEmpty()) { - return Error::fromCode(GPG_ERR_INV_VALUE); - } - - q->run([=](Context *ctx) { - return decrypt_verify_from_file_name(ctx, m_inputFilePath, m_outputDirectory, m_processAllSignatures); - }); - - return {}; -} - -#include "qgpgmedecryptverifyarchivejob.moc" diff --git a/lang/qt/src/qgpgmedecryptverifyarchivejob.h b/lang/qt/src/qgpgmedecryptverifyarchivejob.h deleted file mode 100644 index 50ca0839..00000000 --- a/lang/qt/src/qgpgmedecryptverifyarchivejob.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - qgpgmedecryptverifyarchivejob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEDECRYPTVERIFYARCHIVEJOB_H__ -#define __QGPGME_QGPGMEDECRYPTVERIFYARCHIVEJOB_H__ - -#include "decryptverifyarchivejob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/decryptionresult.h> -#include <gpgme++/verificationresult.h> - -namespace QGpgME -{ - -class QGpgMEDecryptVerifyArchiveJob -#ifdef Q_MOC_RUN - : public DecryptVerifyArchiveJob -#else - : public _detail::ThreadedJobMixin<DecryptVerifyArchiveJob, std::tuple<GpgME::DecryptionResult, GpgME::VerificationResult, QString, GpgME::Error>> -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEDecryptVerifyArchiveJob(GpgME::Context *context); - ~QGpgMEDecryptVerifyArchiveJob() = default; - - GpgME::Error start(const std::shared_ptr<QIODevice> &cipherText) override; -}; - -} - -#endif // __QGPGME_QGPGMEDECRYPTVERIFYARCHIVEJOB_H__ diff --git a/lang/qt/src/qgpgmedecryptverifyjob.cpp b/lang/qt/src/qgpgmedecryptverifyjob.cpp deleted file mode 100644 index e8d2ad4e..00000000 --- a/lang/qt/src/qgpgmedecryptverifyjob.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* - qgpgmedecryptverifyjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmedecryptverifyjob.h" - -#include "dataprovider.h" -#include "debug.h" -#include "decryptverifyjob_p.h" -#include "util.h" - -#include <gpgme++/context.h> -#include <gpgme++/decryptionresult.h> -#include <gpgme++/verificationresult.h> -#include <gpgme++/data.h> - -#include <QDebug> -#include "qgpgme_debug.h" - -#include <QBuffer> -#include <QFile> - -#include <cassert> - -using namespace QGpgME; -using namespace GpgME; - -namespace -{ - -class QGpgMEDecryptVerifyJobPrivate : public DecryptVerifyJobPrivate -{ - QGpgMEDecryptVerifyJob *q = nullptr; - -public: - QGpgMEDecryptVerifyJobPrivate(QGpgMEDecryptVerifyJob *qq) - : q{qq} - { - } - - ~QGpgMEDecryptVerifyJobPrivate() override = default; - -private: - GpgME::Error startIt() override; - - void startNow() override - { - q->run(); - } -}; - -} - -QGpgMEDecryptVerifyJob::QGpgMEDecryptVerifyJob(Context *context) - : mixin_type(context) -{ - setJobPrivate(this, std::unique_ptr<QGpgMEDecryptVerifyJobPrivate>{new QGpgMEDecryptVerifyJobPrivate{this}}); - lateInitialization(); -} - -QGpgMEDecryptVerifyJob::~QGpgMEDecryptVerifyJob() {} - -static QGpgMEDecryptVerifyJob::result_type decrypt_verify(Context *ctx, QThread *thread, - const std::weak_ptr<QIODevice> &cipherText_, - const std::weak_ptr<QIODevice> &plainText_) -{ - qCDebug(QGPGME_LOG) << __func__; - - const std::shared_ptr<QIODevice> cipherText = cipherText_.lock(); - const std::shared_ptr<QIODevice> plainText = plainText_.lock(); - - const _detail::ToThreadMover ctMover(cipherText, thread); - const _detail::ToThreadMover ptMover(plainText, thread); - - QGpgME::QIODeviceDataProvider in(cipherText); - Data indata(&in); - if (!cipherText->isSequential()) { - indata.setSizeHint(cipherText->size()); - } - - if (!plainText) { - QGpgME::QByteArrayDataProvider out; - Data outdata(&out); - - const std::pair<DecryptionResult, VerificationResult> res = ctx->decryptAndVerify(indata, outdata); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - qCDebug(QGPGME_LOG) << __func__ << "- End no plainText. Error:" << ae; - return std::make_tuple(res.first, res.second, out.data(), log, ae); - } else { - QGpgME::QIODeviceDataProvider out(plainText); - Data outdata(&out); - - const std::pair<DecryptionResult, VerificationResult> res = ctx->decryptAndVerify(indata, outdata); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - qCDebug(QGPGME_LOG) << __func__ << "- End plainText. Error:" << ae; - return std::make_tuple(res.first, res.second, QByteArray(), log, ae); - } -} - -static QGpgMEDecryptVerifyJob::result_type decrypt_verify_qba(Context *ctx, const QByteArray &cipherText) -{ - const std::shared_ptr<QBuffer> buffer(new QBuffer); - buffer->setData(cipherText); - if (!buffer->open(QIODevice::ReadOnly)) { - assert(!"This should never happen: QBuffer::open() failed"); - } - return decrypt_verify(ctx, nullptr, buffer, std::shared_ptr<QIODevice>()); -} - -static QGpgMEDecryptVerifyJob::result_type decrypt_verify_from_filename(Context *ctx, - const QString &inputFilePath, - const QString &outputFilePath, - bool processAllSignatures) -{ - Data indata; -#ifdef Q_OS_WIN - indata.setFileName(inputFilePath.toUtf8().constData()); -#else - indata.setFileName(QFile::encodeName(inputFilePath).constData()); -#endif - - PartialFileGuard partFileGuard{outputFilePath}; - if (partFileGuard.tempFileName().isEmpty()) { - return std::make_tuple(DecryptionResult{Error::fromCode(GPG_ERR_EEXIST)}, VerificationResult{Error::fromCode(GPG_ERR_EEXIST)}, QByteArray{}, QString{}, Error{}); - } - - Data outdata; -#ifdef Q_OS_WIN - outdata.setFileName(partFileGuard.tempFileName().toUtf8().constData()); -#else - outdata.setFileName(QFile::encodeName(partFileGuard.tempFileName()).constData()); -#endif - - if (processAllSignatures) { - ctx->setFlag("proc-all-sigs", "1"); - } - const auto results = ctx->decryptAndVerify(indata, outdata); - const auto &decryptionResult = results.first; - const auto &verificationResult = results.second; - - if (!decryptionResult.error().code() && !verificationResult.error().code()) { - // the operation succeeded -> save the result under the requested file name - partFileGuard.commit(); - } - - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(decryptionResult, verificationResult, QByteArray{}, log, ae); -} - -Error QGpgMEDecryptVerifyJob::start(const QByteArray &cipherText) -{ - if (processAllSignatures()) { - context()->setFlag("proc-all-sigs", "1"); - } - run(std::bind(&decrypt_verify_qba, std::placeholders::_1, cipherText)); - return Error(); -} - -void QGpgMEDecryptVerifyJob::start(const std::shared_ptr<QIODevice> &cipherText, const std::shared_ptr<QIODevice> &plainText) -{ - if (processAllSignatures()) { - context()->setFlag("proc-all-sigs", "1"); - } - run(std::bind(&decrypt_verify, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), cipherText, plainText); -} - -std::pair<GpgME::DecryptionResult, GpgME::VerificationResult> -QGpgME::QGpgMEDecryptVerifyJob::exec(const QByteArray &cipherText, QByteArray &plainText) -{ - if (processAllSignatures()) { - context()->setFlag("proc-all-sigs", "1"); - } - const result_type r = decrypt_verify_qba(context(), cipherText); - plainText = std::get<2>(r); - return std::make_pair(std::get<0>(r), std::get<1>(r)); -} - -GpgME::Error QGpgMEDecryptVerifyJobPrivate::startIt() -{ - if (m_inputFilePath.isEmpty() || m_outputFilePath.isEmpty()) { - return Error::fromCode(GPG_ERR_INV_VALUE); - } - - q->run([=](Context *ctx) { - return decrypt_verify_from_filename(ctx, m_inputFilePath, m_outputFilePath, m_processAllSignatures); - }); - - return {}; -} - -#include "qgpgmedecryptverifyjob.moc" diff --git a/lang/qt/src/qgpgmedecryptverifyjob.h b/lang/qt/src/qgpgmedecryptverifyjob.h deleted file mode 100644 index 1a1721df..00000000 --- a/lang/qt/src/qgpgmedecryptverifyjob.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - qgpgmedecryptverifyjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEDECRYPTVERIFYJOB_H__ -#define __QGPGME_QGPGMEDECRYPTVERIFYJOB_H__ - -#include "decryptverifyjob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/decryptionresult.h> -#include <gpgme++/verificationresult.h> - -namespace QGpgME -{ - -class QGpgMEDecryptVerifyJob -#ifdef Q_MOC_RUN - : public DecryptVerifyJob -#else - : public _detail::ThreadedJobMixin<DecryptVerifyJob, std::tuple<GpgME::DecryptionResult, GpgME::VerificationResult, QByteArray, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -private Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEDecryptVerifyJob(GpgME::Context *context); - ~QGpgMEDecryptVerifyJob(); - - /* from DecryptVerifyJob */ - GpgME::Error start(const QByteArray &cipherText) override; - - /* from DecryptVerifyJob */ - void start(const std::shared_ptr<QIODevice> &cipherText, const std::shared_ptr<QIODevice> &plainText) override; - - /* from DecryptVerifyJob */ - std::pair<GpgME::DecryptionResult, GpgME::VerificationResult> - exec(const QByteArray &cipherText, QByteArray &plainText) override; -}; - -} -#endif // __QGPGME_QGPGMEDECRYPTVERIFYJOB_H__ diff --git a/lang/qt/src/qgpgmedeletejob.cpp b/lang/qt/src/qgpgmedeletejob.cpp deleted file mode 100644 index 16f822b5..00000000 --- a/lang/qt/src/qgpgmedeletejob.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - qgpgmedeletejob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmedeletejob.h" - -#include <gpgme++/context.h> -#include <gpgme++/key.h> - -#include <cassert> - -using namespace QGpgME; -using namespace GpgME; - -QGpgMEDeleteJob::QGpgMEDeleteJob(Context *context) - : mixin_type(context) -{ - lateInitialization(); -} - -QGpgMEDeleteJob::~QGpgMEDeleteJob() {} - -static QGpgMEDeleteJob::result_type delete_key(Context *ctx, const Key &key, bool allowSecretKeyDeletion) -{ - const Error err = ctx->deleteKey(key, allowSecretKeyDeletion); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(err, log, ae); -} - -Error QGpgMEDeleteJob::start(const Key &key, bool allowSecretKeyDeletion) -{ - run(std::bind(&delete_key, std::placeholders::_1, key, allowSecretKeyDeletion)); - return Error(); -} -#include "qgpgmedeletejob.moc" diff --git a/lang/qt/src/qgpgmedeletejob.h b/lang/qt/src/qgpgmedeletejob.h deleted file mode 100644 index 6228a50c..00000000 --- a/lang/qt/src/qgpgmedeletejob.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - qgpgmedeletejob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEDELETEJOB_H__ -#define __QGPGME_QGPGMEDELETEJOB_H__ - -#include "deletejob.h" - -#include "threadedjobmixin.h" - -namespace GpgME -{ -class Key; -} - -namespace QGpgME -{ - -class QGpgMEDeleteJob -#ifdef Q_MOC_RUN - : public DeleteJob -#else - : public _detail::ThreadedJobMixin<DeleteJob> -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEDeleteJob(GpgME::Context *context); - ~QGpgMEDeleteJob(); - - /* from DeleteJob */ - GpgME::Error start(const GpgME::Key &key, bool allowSecretKeyDeletion) override; -}; - -} - -#endif // __QGPGME_QGPGMEDELETEJOB_H__ diff --git a/lang/qt/src/qgpgmedownloadjob.cpp b/lang/qt/src/qgpgmedownloadjob.cpp deleted file mode 100644 index d7c608f4..00000000 --- a/lang/qt/src/qgpgmedownloadjob.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - qgpgmedownloadjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmedownloadjob.h" - -#include "dataprovider.h" - -#include <gpgme++/context.h> -#include <gpgme++/data.h> - -#include <QStringList> - -#include <cassert> - -using namespace QGpgME; -using namespace GpgME; - -QGpgMEDownloadJob::QGpgMEDownloadJob(Context *context) - : mixin_type(context) -{ - lateInitialization(); -} - -QGpgMEDownloadJob::~QGpgMEDownloadJob() {} - -static QGpgMEDownloadJob::result_type download_qsl(Context *ctx, const QStringList &pats) -{ - QGpgME::QByteArrayDataProvider dp; - Data data(&dp); - - const _detail::PatternConverter pc(pats); - - const Error err = ctx->exportPublicKeys(pc.patterns(), data); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(err, dp.data(), log, ae); -} - -static QGpgMEDownloadJob::result_type download(Context *ctx, QThread *thread, const QByteArray &fpr, const std::weak_ptr<QIODevice> &keyData_) -{ - const std::shared_ptr<QIODevice> keyData = keyData_.lock(); - if (!keyData) { - return download_qsl(ctx, QStringList(QString::fromUtf8(fpr))); - } - - const _detail::ToThreadMover kdMover(keyData, thread); - - QGpgME::QIODeviceDataProvider dp(keyData); - Data data(&dp); - - const _detail::PatternConverter pc(fpr); - - const Error err = ctx->exportPublicKeys(pc.patterns(), data); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(err, QByteArray(), log, ae); -} - -Error QGpgMEDownloadJob::start(const QStringList &pats) -{ - run(std::bind(&download_qsl, std::placeholders::_1, pats)); - return Error(); -} - -Error QGpgMEDownloadJob::start(const QByteArray &fpr, const std::shared_ptr<QIODevice> &keyData) -{ - run(std::bind(&download, std::placeholders::_1, std::placeholders::_2, fpr, std::placeholders::_3), keyData); - return Error(); -} -#include "qgpgmedownloadjob.moc" diff --git a/lang/qt/src/qgpgmedownloadjob.h b/lang/qt/src/qgpgmedownloadjob.h deleted file mode 100644 index 8aab7479..00000000 --- a/lang/qt/src/qgpgmedownloadjob.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - qgpgmedownloadjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEDOWNLOADJOB_H__ -#define __QGPGME_QGPGMEDOWNLOADJOB_H__ - -#include "downloadjob.h" - -#include "threadedjobmixin.h" - -namespace QGpgME -{ - -class QGpgMEDownloadJob -#ifdef Q_MOC_RUN - : public DownloadJob -#else - : public _detail::ThreadedJobMixin<DownloadJob, std::tuple<GpgME::Error, QByteArray, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEDownloadJob(GpgME::Context *context); - ~QGpgMEDownloadJob(); - - /* from DownloadJob */ - GpgME::Error start(const QStringList &fingerprints) override; - - /* from DownloadJob */ - GpgME::Error start(const QByteArray &fingerprint, const std::shared_ptr<QIODevice> &keyData) override; -}; - -} - -#endif // __QGPGME_QGPGMEDOWNLOADJOB_H__ diff --git a/lang/qt/src/qgpgmeencryptarchivejob.cpp b/lang/qt/src/qgpgmeencryptarchivejob.cpp deleted file mode 100644 index 02b9e587..00000000 --- a/lang/qt/src/qgpgmeencryptarchivejob.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - qgpgmeencryptarchivejob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2007,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2022,2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmeencryptarchivejob.h" - -#include "dataprovider.h" -#include "encryptarchivejob_p.h" -#include "filelistdataprovider.h" -#include "qgpgme_debug.h" -#include "util.h" - -#include <QFile> - -#include <gpgme++/data.h> - -using namespace QGpgME; -using namespace GpgME; - -namespace -{ - -class QGpgMEEncryptArchiveJobPrivate : public EncryptArchiveJobPrivate -{ - QGpgMEEncryptArchiveJob *q = nullptr; - -public: - QGpgMEEncryptArchiveJobPrivate(QGpgMEEncryptArchiveJob *qq) - : q{qq} - { - } - - ~QGpgMEEncryptArchiveJobPrivate() override = default; - -private: - GpgME::Error startIt() override; - - void startNow() override - { - q->run(); - } -}; - -} - -QGpgMEEncryptArchiveJob::QGpgMEEncryptArchiveJob(Context *context) - : mixin_type{context} -{ - setJobPrivate(this, std::unique_ptr<QGpgMEEncryptArchiveJobPrivate>{new QGpgMEEncryptArchiveJobPrivate{this}}); - lateInitialization(); - connect(this, &Job::rawProgress, this, [this](const QString &what, int type, int current, int total) { - emitArchiveProgressSignals(this, what, type, current, total); - }); -} - -static QGpgMEEncryptArchiveJob::result_type encrypt(Context *ctx, - const std::vector<Key> &recipients, - const std::vector<QString> &paths, - GpgME::Data &outdata, - Context::EncryptionFlags flags, - const QString &baseDirectory) -{ - QGpgME::FileListDataProvider in{paths}; - Data indata(&in); - if (!baseDirectory.isEmpty()) { - indata.setFileName(baseDirectory.toStdString()); - } - - flags = static_cast<Context::EncryptionFlags>(flags | Context::EncryptArchive); - const auto encryptionResult = ctx->encrypt(recipients, indata, outdata, flags); - - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(encryptionResult, log, ae); -} - -static QGpgMEEncryptArchiveJob::result_type encrypt_to_io_device(Context *ctx, - QThread *thread, - const std::vector<Key> &recipients, - const std::vector<QString> &paths, - const std::weak_ptr<QIODevice> &cipherText_, - Context::EncryptionFlags flags, - const QString &baseDirectory) -{ - const std::shared_ptr<QIODevice> cipherText = cipherText_.lock(); - const _detail::ToThreadMover ctMover(cipherText, thread); - QGpgME::QIODeviceDataProvider out{cipherText}; - Data outdata(&out); - - return encrypt(ctx, recipients, paths, outdata, flags, baseDirectory); -} - -static QGpgMEEncryptArchiveJob::result_type encrypt_to_filename(Context *ctx, - const std::vector<Key> &recipients, - const std::vector<QString> &paths, - const QString &outputFileName, - Context::EncryptionFlags flags, - const QString &baseDirectory) -{ - PartialFileGuard partFileGuard{outputFileName}; - if (partFileGuard.tempFileName().isEmpty()) { - return std::make_tuple(EncryptionResult{Error::fromCode(GPG_ERR_EEXIST)}, QString{}, Error{}); - } - - Data outdata; -#ifdef Q_OS_WIN - outdata.setFileName(partFileGuard.tempFileName().toUtf8().constData()); -#else - outdata.setFileName(QFile::encodeName(partFileGuard.tempFileName()).constData()); -#endif - - const auto result = encrypt(ctx, recipients, paths, outdata, flags, baseDirectory); - const auto &encryptionResult = std::get<0>(result); - if (!encryptionResult.error().code()) { - // the operation succeeded -> save the result under the requested file name - partFileGuard.commit(); - } - - return result; -} - -GpgME::Error QGpgMEEncryptArchiveJob::start(const std::vector<GpgME::Key> &recipients, - const std::vector<QString> &paths, - const std::shared_ptr<QIODevice> &cipherText, - const GpgME::Context::EncryptionFlags flags) -{ - if (!cipherText) { - return Error::fromCode(GPG_ERR_INV_VALUE); - } - - run(std::bind(&encrypt_to_io_device, - std::placeholders::_1, - std::placeholders::_2, - recipients, - paths, - std::placeholders::_3, - flags, - baseDirectory()), - cipherText); - return {}; -} - -GpgME::Error QGpgMEEncryptArchiveJobPrivate::startIt() -{ - if (m_outputFilePath.isEmpty()) { - return Error::fromCode(GPG_ERR_INV_VALUE); - } - - q->run([=](Context *ctx) { - return encrypt_to_filename(ctx, m_recipients, m_inputPaths, m_outputFilePath, m_encryptionFlags, m_baseDirectory); - }); - - return {}; -} - -#include "qgpgmeencryptarchivejob.moc" diff --git a/lang/qt/src/qgpgmeencryptarchivejob.h b/lang/qt/src/qgpgmeencryptarchivejob.h deleted file mode 100644 index 6b818f20..00000000 --- a/lang/qt/src/qgpgmeencryptarchivejob.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - qgpgmeencryptarchivejob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEENCRYPTARCHIVEJOB_H__ -#define __QGPGME_QGPGMEENCRYPTARCHIVEJOB_H__ - -#include "encryptarchivejob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/encryptionresult.h> - -namespace QGpgME -{ - -class QGpgMEEncryptArchiveJob -#ifdef Q_MOC_RUN - : public EncryptArchiveJob -#else - : public _detail::ThreadedJobMixin<EncryptArchiveJob, std::tuple<GpgME::EncryptionResult, QString, GpgME::Error>> -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEEncryptArchiveJob(GpgME::Context *context); - ~QGpgMEEncryptArchiveJob() = default; - - GpgME::Error start(const std::vector<GpgME::Key> &recipients, - const std::vector<QString> &paths, - const std::shared_ptr<QIODevice> &cipherText, - const GpgME::Context::EncryptionFlags flags) override; -}; - -} - -#endif // __QGPGME_QGPGMEENCRYPTARCHIVEJOB_H__ diff --git a/lang/qt/src/qgpgmeencryptjob.cpp b/lang/qt/src/qgpgmeencryptjob.cpp deleted file mode 100644 index c8dd5f1b..00000000 --- a/lang/qt/src/qgpgmeencryptjob.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* - qgpgmeencryptjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2007,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2022,2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmeencryptjob.h" - -#include "dataprovider.h" -#include "encryptjob_p.h" -#include "util.h" - -#include <gpgme++/context.h> -#include <gpgme++/data.h> -#include <gpgme++/encryptionresult.h> - -#include <QBuffer> -#include <QFileInfo> - -#include <cassert> - -using namespace QGpgME; -using namespace GpgME; - -namespace -{ - -class QGpgMEEncryptJobPrivate : public EncryptJobPrivate -{ - QGpgMEEncryptJob *q = nullptr; - -public: - QGpgMEEncryptJobPrivate(QGpgMEEncryptJob *qq) - : q{qq} - { - } - - ~QGpgMEEncryptJobPrivate() override = default; - -private: - GpgME::Error startIt() override; - - void startNow() override - { - q->run(); - } -}; - -} - -QGpgMEEncryptJob::QGpgMEEncryptJob(Context *context) - : mixin_type(context), - mOutputIsBase64Encoded(false) -{ - setJobPrivate(this, std::unique_ptr<QGpgMEEncryptJobPrivate>{new QGpgMEEncryptJobPrivate{this}}); - lateInitialization(); -} - -QGpgMEEncryptJob::~QGpgMEEncryptJob() {} - -void QGpgMEEncryptJob::setOutputIsBase64Encoded(bool on) -{ - mOutputIsBase64Encoded = on; -} - -static QGpgMEEncryptJob::result_type encrypt(Context *ctx, QThread *thread, - const std::vector<Key> &recipients, - const std::weak_ptr<QIODevice> &plainText_, - const std::weak_ptr<QIODevice> &cipherText_, - const Context::EncryptionFlags eflags, - bool outputIsBsse64Encoded, - Data::Encoding inputEncoding, - const QString &fileName) -{ - - const std::shared_ptr<QIODevice> plainText = plainText_.lock(); - const std::shared_ptr<QIODevice> cipherText = cipherText_.lock(); - - const _detail::ToThreadMover ctMover(cipherText, thread); - const _detail::ToThreadMover ptMover(plainText, thread); - - QGpgME::QIODeviceDataProvider in(plainText); - Data indata(&in); - indata.setEncoding(inputEncoding); - - if (!plainText->isSequential()) { - indata.setSizeHint(plainText->size()); - } - - const auto pureFileName = QFileInfo{fileName}.fileName().toStdString(); - if (!pureFileName.empty()) { - indata.setFileName(pureFileName.c_str()); - } - - if (!cipherText) { - QGpgME::QByteArrayDataProvider out; - Data outdata(&out); - - if (outputIsBsse64Encoded) { - outdata.setEncoding(Data::Base64Encoding); - } - - const EncryptionResult res = ctx->encrypt(recipients, indata, outdata, eflags); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(res, out.data(), log, ae); - } else { - QGpgME::QIODeviceDataProvider out(cipherText); - Data outdata(&out); - - if (outputIsBsse64Encoded) { - outdata.setEncoding(Data::Base64Encoding); - } - - const EncryptionResult res = ctx->encrypt(recipients, indata, outdata, eflags); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(res, QByteArray(), log, ae); - } - -} - -static QGpgMEEncryptJob::result_type encrypt_qba(Context *ctx, const std::vector<Key> &recipients, const QByteArray &plainText, const Context::EncryptionFlags eflags, bool outputIsBsse64Encoded, Data::Encoding inputEncoding, const QString &fileName) -{ - const std::shared_ptr<QBuffer> buffer(new QBuffer); - buffer->setData(plainText); - if (!buffer->open(QIODevice::ReadOnly)) { - assert(!"This should never happen: QBuffer::open() failed"); - } - return encrypt(ctx, nullptr, recipients, buffer, std::shared_ptr<QIODevice>(), eflags, outputIsBsse64Encoded, inputEncoding, fileName); -} - -static QGpgMEEncryptJob::result_type encrypt_to_filename(Context *ctx, - const std::vector<Key> &recipients, - const QString &inputFilePath, - const QString &outputFilePath, - Context::EncryptionFlags flags) -{ - Data indata; -#ifdef Q_OS_WIN - indata.setFileName(inputFilePath.toUtf8().constData()); -#else - indata.setFileName(QFile::encodeName(inputFilePath).constData()); -#endif - - PartialFileGuard partFileGuard{outputFilePath}; - if (partFileGuard.tempFileName().isEmpty()) { - return std::make_tuple(EncryptionResult{Error::fromCode(GPG_ERR_EEXIST)}, QByteArray{}, QString{}, Error{}); - } - - Data outdata; -#ifdef Q_OS_WIN - outdata.setFileName(partFileGuard.tempFileName().toUtf8().constData()); -#else - outdata.setFileName(QFile::encodeName(partFileGuard.tempFileName()).constData()); -#endif - - flags = static_cast<Context::EncryptionFlags>(flags | Context::EncryptFile); - const auto encryptionResult = ctx->encrypt(recipients, indata, outdata, flags); - - if (!encryptionResult.error().code()) { - // the operation succeeded -> save the result under the requested file name - partFileGuard.commit(); - } - - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(encryptionResult, QByteArray{}, log, ae); -} - -Error QGpgMEEncryptJob::start(const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust) -{ - run(std::bind(&encrypt_qba, std::placeholders::_1, recipients, plainText, - alwaysTrust ? Context::AlwaysTrust : Context::None, mOutputIsBase64Encoded, inputEncoding(), fileName())); - return Error(); -} - -void QGpgMEEncryptJob::start(const std::vector<Key> &recipients, const std::shared_ptr<QIODevice> &plainText, - const std::shared_ptr<QIODevice> &cipherText, const Context::EncryptionFlags eflags) -{ - run(std::bind(&encrypt, - std::placeholders::_1, std::placeholders::_2, - recipients, - std::placeholders::_3, std::placeholders::_4, - eflags, - mOutputIsBase64Encoded, - inputEncoding(), - fileName()), - plainText, cipherText); -} - -EncryptionResult QGpgMEEncryptJob::exec(const std::vector<Key> &recipients, const QByteArray &plainText, - const Context::EncryptionFlags eflags, QByteArray &cipherText) -{ - const result_type r = encrypt_qba(context(), recipients, plainText, eflags, mOutputIsBase64Encoded, inputEncoding(), fileName()); - cipherText = std::get<1>(r); - return std::get<0>(r); -} - -void QGpgMEEncryptJob::start(const std::vector<Key> &recipients, const std::shared_ptr<QIODevice> &plainText, const std::shared_ptr<QIODevice> &cipherText, bool alwaysTrust) -{ - return start(recipients, plainText, cipherText, alwaysTrust ? Context::AlwaysTrust : Context::None); -} - -EncryptionResult QGpgMEEncryptJob::exec(const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust, QByteArray &cipherText) -{ - return exec(recipients, plainText, alwaysTrust ? Context::AlwaysTrust : Context::None, cipherText); -} - -GpgME::Error QGpgMEEncryptJobPrivate::startIt() -{ - if (m_inputFilePath.isEmpty() || m_outputFilePath.isEmpty()) { - return Error::fromCode(GPG_ERR_INV_VALUE); - } - - q->run([=](Context *ctx) { - return encrypt_to_filename(ctx, m_recipients, m_inputFilePath, m_outputFilePath, m_encryptionFlags); - }); - - return {}; -} - -#include "qgpgmeencryptjob.moc" diff --git a/lang/qt/src/qgpgmeencryptjob.h b/lang/qt/src/qgpgmeencryptjob.h deleted file mode 100644 index 4fcb0c69..00000000 --- a/lang/qt/src/qgpgmeencryptjob.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - qgpgmeencryptjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2007,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEENCRYPTJOB_H__ -#define __QGPGME_QGPGMEENCRYPTJOB_H__ - -#include "encryptjob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/encryptionresult.h> -#include <gpgme++/key.h> - -namespace QGpgME -{ - -class QGpgMEEncryptJob -#ifdef Q_MOC_RUN - : public EncryptJob -#else - : public _detail::ThreadedJobMixin<EncryptJob, std::tuple<GpgME::EncryptionResult, QByteArray, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEEncryptJob(GpgME::Context *context); - ~QGpgMEEncryptJob(); - - /* from EncryptJob */ - GpgME::Error start(const std::vector<GpgME::Key> &recipients, - const QByteArray &plainText, bool alwaysTrust) override; - - /* from EncryptJob */ - void start(const std::vector<GpgME::Key> &recipients, - const std::shared_ptr<QIODevice> &plainText, - const std::shared_ptr<QIODevice> &cipherText, - bool alwaysTrust) override; - - /* from EncryptJob */ - GpgME::EncryptionResult exec(const std::vector<GpgME::Key> &recipients, - const QByteArray &plainText, bool alwaysTrust, - QByteArray &cipherText) override; - /* from EncryptJob */ - void start(const std::vector<GpgME::Key> &recipients, - const std::shared_ptr<QIODevice> &plainText, - const std::shared_ptr<QIODevice> &cipherText, - const GpgME::Context::EncryptionFlags flags) override; - - /* from EncryptJob */ - GpgME::EncryptionResult exec(const std::vector<GpgME::Key> &recipients, - const QByteArray &plainText, const GpgME::Context::EncryptionFlags flags, - QByteArray &cipherText) override; - - /* from EncryptJob */ - void setOutputIsBase64Encoded(bool on) override; - -private: - bool mOutputIsBase64Encoded; -}; - -} - -#endif // __QGPGME_QGPGMEENCRYPTJOB_H__ diff --git a/lang/qt/src/qgpgmeexportjob.cpp b/lang/qt/src/qgpgmeexportjob.cpp deleted file mode 100644 index 239b46b0..00000000 --- a/lang/qt/src/qgpgmeexportjob.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - qgpgmeexportjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2022 by g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmeexportjob.h" - -#include "dataprovider.h" - -#include <gpgme++/context.h> -#include <gpgme++/data.h> -#include <gpgme++/key.h> - -#include <QStringList> - -#include <cassert> - -using namespace QGpgME; -using namespace GpgME; - -QGpgMEExportJob::QGpgMEExportJob(Context *context) - : QGpgMEExportJob{context, 0} -{ -} - -QGpgMEExportJob::QGpgMEExportJob(Context *context, unsigned int forcedMode) - : mixin_type{context} - , m_exportMode{forcedMode} - , m_additionalExportModeFlags{0} -{ - lateInitialization(); -} - -QGpgMEExportJob::~QGpgMEExportJob() = default; - -static QGpgMEExportJob::result_type export_qba(Context *ctx, const QStringList &patterns, unsigned int mode) -{ - const _detail::PatternConverter pc(patterns); - - QGpgME::QByteArrayDataProvider dp; - Data data(&dp); - - const Error err = ctx->exportKeys(pc.patterns(), data, mode); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(err, dp.data(), log, ae); -} - -Error QGpgMEExportJob::start(const QStringList &patterns) -{ - auto mode = m_exportMode | m_additionalExportModeFlags; - run(std::bind(&export_qba, std::placeholders::_1, patterns, mode)); - return Error(); -} - -Error QGpgMEExportJob::exec(const QStringList &patterns, QByteArray &data) -{ - auto mode = m_exportMode | m_additionalExportModeFlags; - const result_type r = export_qba(context(), patterns, mode); - data = std::get<1>(r); - return std::get<0>(r); -} - -void QGpgMEExportJob::setExportFlags(unsigned int flags) -{ - m_additionalExportModeFlags = flags; -} - -/* For ABI compat not pure virtual. */ -void ExportJob::setExportFlags(unsigned int) -{ -} - -/* For ABI compat not pure virtual. */ -GpgME::Error ExportJob::exec(const QStringList &, QByteArray &) -{ - return Error(); -} - -#include "qgpgmeexportjob.moc" diff --git a/lang/qt/src/qgpgmeexportjob.h b/lang/qt/src/qgpgmeexportjob.h deleted file mode 100644 index b60b95f2..00000000 --- a/lang/qt/src/qgpgmeexportjob.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - qgpgmeexportjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2022 by g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEEXPORTJOB_H__ -#define __QGPGME_QGPGMEEXPORTJOB_H__ - -#include "exportjob.h" - -#include "threadedjobmixin.h" - -namespace QGpgME -{ - -class QGpgMEExportJob -#ifdef Q_MOC_RUN - : public ExportJob -#else - : public _detail::ThreadedJobMixin<ExportJob, std::tuple<GpgME::Error, QByteArray, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEExportJob(GpgME::Context *context); - // Creates an export job with forced export mode @p exportMode. The - // export mode flags set with @p exportMode cannot be overridden with - // setExportFlags. - explicit QGpgMEExportJob(GpgME::Context *context, unsigned int exportMode); - ~QGpgMEExportJob() override; - - /* from ExportJob */ - void setExportFlags(unsigned int flags) override; - - /* from ExportJob */ - GpgME::Error start(const QStringList &patterns) override; - GpgME::Error exec(const QStringList &patterns, QByteArray &data) override; - -private: - unsigned int m_exportMode; - unsigned int m_additionalExportModeFlags; -}; - -} - -#endif // __QGPGME_QGPGMEEXPORTJOB_H__ diff --git a/lang/qt/src/qgpgmegpgcardjob.cpp b/lang/qt/src/qgpgmegpgcardjob.cpp deleted file mode 100644 index 2bed23c2..00000000 --- a/lang/qt/src/qgpgmegpgcardjob.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - qgpgmegpgcardjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2020 g10 Code GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmegpgcardjob.h" - -#include <QStringList> -#include <QFileInfo> -#include <QDir> -#include <QProcess> -#include "util.h" -#include "qgpgme_debug.h" - -/* We cannot have a timeout because key generation can - * take ages. Well maybe 10 minutes. */ -#define TIMEOUT_VALUE (600000) - -#include <tuple> - -using namespace GpgME; -using namespace QGpgME; - -QGpgMEGpgCardJob::QGpgMEGpgCardJob() - : mixin_type(/* needed for the mixer */ - Context::createForEngine(GpgME::SpawnEngine).release()) -{ - lateInitialization(); -} - -QGpgMEGpgCardJob::~QGpgMEGpgCardJob() {} - -static QString getGpgCardPath() -{ - auto bindir = QString::fromLocal8Bit(dirInfo("bindir")); - if (bindir.isEmpty()) { - return QString(); - } - - const QFileInfo fi(QDir(bindir).absoluteFilePath(QStringLiteral("gpg-card"))); - if (fi.exists() && fi.isExecutable()) { - return fi.absoluteFilePath(); - } - return QString(); -} - -static QGpgMEGpgCardJob::result_type do_work(const QStringList &cmds, const QString &path) -{ - QStringList args; - args << QStringLiteral("--with-colons"); - args += cmds; - - QProcess proc; - - proc.setProgram(path); - proc.setArguments(args); - - qCDebug(QGPGME_LOG) << "Executing:" << path << args; - proc.start(); - if (!proc.waitForStarted()) { - return std::make_tuple (QString(), QString(), 1, QString(), Error()); - } - - if (!proc.waitForFinished(TIMEOUT_VALUE)) { - return std::make_tuple (QString(), QString(), 1, QString(), Error()); - } - if (proc.exitStatus() == QProcess::NormalExit) { - return std::make_tuple (QString::fromUtf8(proc.readAllStandardOutput()), - QString::fromUtf8(proc.readAllStandardError()), proc.exitCode(), - QString(), Error()); - } - return std::make_tuple (QString::fromUtf8(proc.readAllStandardOutput()), - QString::fromUtf8(proc.readAllStandardError()), 1, - QString(), Error()); -} - -Error QGpgMEGpgCardJob::start(const QStringList &cmds) -{ - const auto cardpath = getGpgCardPath (); - if (cardpath.isEmpty()) { - return Error(make_error(GPG_ERR_NOT_SUPPORTED)); - } - run(std::bind(&do_work, cmds, cardpath)); - return Error(); -} - -Error QGpgMEGpgCardJob::exec(const QStringList &cmds, QString &std_out, QString &std_err, int &exitCode) -{ - const auto cardpath = getGpgCardPath (); - if (cardpath.isEmpty()) { - return Error(make_error(GPG_ERR_NOT_SUPPORTED)); - } - const result_type r = do_work(cmds, cardpath); - std_out = std::get<0>(r); - std_err = std::get<1>(r); - exitCode = std::get<2>(r); - return exitCode == 0 ? Error() : Error(make_error(GPG_ERR_GENERAL)); -} - -#include "qgpgmegpgcardjob.moc" diff --git a/lang/qt/src/qgpgmegpgcardjob.h b/lang/qt/src/qgpgmegpgcardjob.h deleted file mode 100644 index c78c0ee5..00000000 --- a/lang/qt/src/qgpgmegpgcardjob.h +++ /dev/null @@ -1,63 +0,0 @@ -/* qgpgmegpgcardjob.h - - This file is part of libkleopatra, the KDE keymanagement library - Copyright (c) 2020 g10 Code GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEGPGCARDJOB_H__ -#define __QGPGME_QGPGMEGPGCARDJOB_H__ -#include "gpgcardjob.h" - -#include "threadedjobmixin.h" - -namespace QGpgME -{ - -class QGpgMEGpgCardJob -#ifdef Q_MOC_RUN - : public GpgCardJob -#else - : public _detail::ThreadedJobMixin<GpgCardJob, std::tuple<QString, QString, int, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEGpgCardJob(); - ~QGpgMEGpgCardJob(); - - GpgME::Error start(const QStringList &cmds) override; - - GpgME::Error exec(const QStringList &cmds, QString &std_out, QString &std_err, int &exitCode) override; -}; - -} -#endif diff --git a/lang/qt/src/qgpgmeimportfromkeyserverjob.cpp b/lang/qt/src/qgpgmeimportfromkeyserverjob.cpp deleted file mode 100644 index e5e06b23..00000000 --- a/lang/qt/src/qgpgmeimportfromkeyserverjob.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - qgpgmeimportfromkeyserverjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmeimportfromkeyserverjob.h" - -#include "dataprovider.h" - -#include <gpgme++/context.h> -#include <gpgme++/data.h> -#include <gpgme++/key.h> - -#include <cassert> - -using namespace QGpgME; -using namespace GpgME; - -QGpgMEImportFromKeyserverJob::QGpgMEImportFromKeyserverJob(Context *context) - : mixin_type(context) -{ - lateInitialization(); -} - -QGpgMEImportFromKeyserverJob::~QGpgMEImportFromKeyserverJob() {} - -static QGpgMEImportFromKeyserverJob::result_type importfromkeyserver(Context *ctx, const std::vector<Key> &keys) -{ - const ImportResult res = ctx->importKeys(keys); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(res, log, ae); -} - -Error QGpgMEImportFromKeyserverJob::start(const std::vector<Key> &keys) -{ - run(std::bind(&importfromkeyserver, std::placeholders::_1, keys)); - return Error(); -} - -GpgME::ImportResult QGpgME::QGpgMEImportFromKeyserverJob::exec(const std::vector<Key> &keys) -{ - const result_type r = importfromkeyserver(context(), keys); - return std::get<0>(r); -} - -#include "qgpgmeimportfromkeyserverjob.moc" diff --git a/lang/qt/src/qgpgmeimportfromkeyserverjob.h b/lang/qt/src/qgpgmeimportfromkeyserverjob.h deleted file mode 100644 index 917863ed..00000000 --- a/lang/qt/src/qgpgmeimportfromkeyserverjob.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - qgpgmeimportfromkeyserverjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEIMPORTFROMKEYSERVERJOB_H__ -#define __QGPGME_QGPGMEIMPORTFROMKEYSERVERJOB_H__ - -#include "importfromkeyserverjob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/importresult.h> - -namespace QGpgME -{ - -class QGpgMEImportFromKeyserverJob -#ifdef Q_MOC_RUN - : public ImportFromKeyserverJob -#else - : public _detail::ThreadedJobMixin<ImportFromKeyserverJob, std::tuple<GpgME::ImportResult, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEImportFromKeyserverJob(GpgME::Context *context); - ~QGpgMEImportFromKeyserverJob(); - - /* from ImportFromKeyserverJob */ - GpgME::Error start(const std::vector<GpgME::Key> &keys) override; - - /* from ImportFromKeyserverJob */ - GpgME::ImportResult exec(const std::vector<GpgME::Key> &keys) override; -}; - -} - -#endif // __QGPGME_QGPGMEIMPORTFROMKEYSERVERJOB_H__ diff --git a/lang/qt/src/qgpgmeimportjob.cpp b/lang/qt/src/qgpgmeimportjob.cpp deleted file mode 100644 index 7c33288d..00000000 --- a/lang/qt/src/qgpgmeimportjob.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - qgpgmeimportjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmeimportjob.h" - -#include "importjob_p.h" - -#include "dataprovider.h" - -#include <gpgme++/context.h> -#include <gpgme++/data.h> -#include <gpgme++/key.h> - -using namespace QGpgME; -using namespace GpgME; - -namespace -{ - -class QGpgMEImportJobPrivate : public ImportJobPrivate -{ - QGpgMEImportJob *q = nullptr; - -public: - QGpgMEImportJobPrivate(QGpgMEImportJob *qq) - : q{qq} - { - } - - ~QGpgMEImportJobPrivate() override = default; - -private: - GpgME::Error startIt() override - { - Q_ASSERT(!"Not supported by this Job class."); - return Error::fromCode(GPG_ERR_NOT_SUPPORTED); - } - - void startNow() override - { - q->run(); - } -}; - -} - -QGpgMEImportJob::QGpgMEImportJob(Context *context) - : mixin_type(context) -{ - setJobPrivate(this, std::unique_ptr<QGpgMEImportJobPrivate>{new QGpgMEImportJobPrivate{this}}); - lateInitialization(); -} - -QGpgMEImportJob::~QGpgMEImportJob() = default; - -static const char *originToString(Key::Origin origin) -{ - static const std::map<Key::Origin, const char *> mapping = { - { Key::OriginUnknown, "unknown" }, - { Key::OriginKS, "ks" }, - { Key::OriginDane, "dane" }, - { Key::OriginWKD, "wkd" }, - { Key::OriginURL, "url" }, - { Key::OriginFile, "file" }, - { Key::OriginSelf, "self" }, - }; - const auto it = mapping.find(origin); - return (it != std::end(mapping)) ? it->second : nullptr; -} - -static QGpgMEImportJob::result_type import_qba(Context *ctx, const QByteArray &certData, const QString &importFilter, - const QStringList &importOptions, Key::Origin keyOrigin, - const QString &keyOriginUrl) -{ - if (!importFilter.isEmpty()) { - ctx->setFlag("import-filter", importFilter.toStdString().c_str()); - } - if (!importOptions.empty()) { - ctx->setFlag("import-options", importOptions.join(QLatin1Char{','}).toStdString().c_str()); - } - if (keyOrigin != Key::OriginUnknown) { - if (const auto origin = originToString(keyOrigin)) { - std::string value{origin}; - if (!keyOriginUrl.isEmpty()) { - value += ","; - value += keyOriginUrl.toStdString(); - } - ctx->setFlag("key-origin", value.c_str()); - } - } - - QGpgME::QByteArrayDataProvider dp(certData); - Data data(&dp); - - ImportResult res = ctx->importKeys(data); - // HACK: If the import failed with an error, then check if res.imports() - // contains only import statuses with "bad passphrase" error; if yes, this - // means that the user probably entered a wrong password to decrypt an - // encrypted key for import. In this case, return a result with "bad - // passphrase" error instead of the original error. - // We check if all import statuses instead of any import status has a - // "bad passphrase" error to avoid breaking imports that partially worked. - // See https://dev.gnupg.org/T5713. - const auto imports = res.imports(); - if (res.error() && !imports.empty() - && std::all_of(std::begin(imports), std::end(imports), - [](const Import &import) { - return import.error().code() == GPG_ERR_BAD_PASSPHRASE; - })) { - res = ImportResult{Error{GPG_ERR_BAD_PASSPHRASE}}; - } - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(res, log, ae); -} - -Error QGpgMEImportJob::start(const QByteArray &certData) -{ - run(std::bind(&import_qba, std::placeholders::_1, certData, importFilter(), importOptions(), keyOrigin(), keyOriginUrl())); - return Error(); -} - -GpgME::ImportResult QGpgME::QGpgMEImportJob::exec(const QByteArray &keyData) -{ - const result_type r = import_qba(context(), keyData, importFilter(), importOptions(), keyOrigin(), keyOriginUrl()); - return std::get<0>(r); -} - -Error QGpgMEImportJob::startLater(const QByteArray &certData) -{ - setWorkerFunction(std::bind(&import_qba, std::placeholders::_1, certData, importFilter(), importOptions(), keyOrigin(), keyOriginUrl())); - return {}; -} - -#include "qgpgmeimportjob.moc" diff --git a/lang/qt/src/qgpgmeimportjob.h b/lang/qt/src/qgpgmeimportjob.h deleted file mode 100644 index d36fc359..00000000 --- a/lang/qt/src/qgpgmeimportjob.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - qgpgmeimportjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEIMPORTJOB_H__ -#define __QGPGME_QGPGMEIMPORTJOB_H__ - -#include "importjob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/importresult.h> - -namespace QGpgME -{ - -class QGpgMEImportJob -#ifdef Q_MOC_RUN - : public ImportJob -#else - : public _detail::ThreadedJobMixin<ImportJob, std::tuple<GpgME::ImportResult, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEImportJob(GpgME::Context *context); - ~QGpgMEImportJob(); - - /* from ImportJob */ - GpgME::Error start(const QByteArray &keyData) override; - - /* from ImportJob */ - GpgME::ImportResult exec(const QByteArray &keyData) override; - - GpgME::Error startLater(const QByteArray &keyData) override; -}; - -} - -#endif // __QGPGME_QGPGMEIMPORTJOB_H__ diff --git a/lang/qt/src/qgpgmekeyformailboxjob.cpp b/lang/qt/src/qgpgmekeyformailboxjob.cpp deleted file mode 100644 index dca22426..00000000 --- a/lang/qt/src/qgpgmekeyformailboxjob.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - qgpgmekeyformailboxjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmekeyformailboxjob.h" -#include "qgpgmekeylistjob.h" - -#include <QStringList> - -#include <tuple> - -using namespace GpgME; -using namespace QGpgME; - -QGpgMEKeyForMailboxJob::QGpgMEKeyForMailboxJob(Context *context) - : mixin_type(context) -{ - lateInitialization(); -} - -QGpgMEKeyForMailboxJob::~QGpgMEKeyForMailboxJob() {} - -static bool keyIsOk(const Key k) -{ - return !k.isExpired() && !k.isRevoked() && !k.isInvalid() && !k.isDisabled(); -} - -static bool uidIsOk(const UserID uid) -{ - return keyIsOk(uid.parent()) && !uid.isRevoked() && !uid.isInvalid(); -} - -static bool subkeyIsOk(const Subkey s) -{ - return !s.isRevoked() && !s.isInvalid() && !s.isDisabled(); -} - -static QGpgMEKeyForMailboxJob::result_type do_work(Context *ctx, const QString &mailbox, bool canEncrypt) -{ - /* Do a Keylisting. */ - ctx->setKeyListMode(GpgME::Locate | GpgME::Signatures | GpgME::Validate); - std::vector<Key> keys; - QGpgMEKeyListJob *keylist = new QGpgMEKeyListJob(ctx); - - KeyListResult result = keylist->exec(QStringList() << mailbox, false, keys); - - if (result.error()) { - return std::make_tuple(result, Key(), UserID(), QString(), Error()); - } - - // This should ideally be decided by GnuPG and this Job changed - // to just call the according API in GpgME - // See: https://bugs.gnupg.org/gnupg/issue2359 - Key keyC; - UserID uidC; - for (const Key &k : keys) { - if (canEncrypt && !k.canEncrypt()) { - continue; - } - /* First get the uid that matches the mailbox */ - for (const UserID &u : k.userIDs()) { - if (QString::fromUtf8(u.email()).toLower() == mailbox.toLower()) { - if (uidC.isNull()) { - keyC = k; - uidC = u; - } else if ((!uidIsOk(uidC) && uidIsOk(u)) || uidC.validity() < u.validity()) { - /* Validity of the new key is better. */ - uidC = u; - keyC = k; - } else if (uidC.validity() == u.validity() && uidIsOk(u)) { - /* Both are the same check which one is newer. */ - time_t oldTime = 0; - for (const Subkey &s : keyC.subkeys()) { - if ((canEncrypt && s.canEncrypt()) && subkeyIsOk(s)) { - oldTime = s.creationTime(); - } - } - time_t newTime = 0; - for (const Subkey &s : k.subkeys()) { - if ((canEncrypt && s.canEncrypt()) && subkeyIsOk(s)) { - newTime = s.creationTime(); - } - } - if (newTime > oldTime) { - uidC = u; - keyC = k; - } - } - } - } - } - return std::make_tuple(result, keyC, uidC, QString(), Error()); -} - -Error QGpgMEKeyForMailboxJob::start(const QString &mailbox, bool canEncrypt) -{ - run(std::bind(&do_work, std::placeholders::_1, mailbox, canEncrypt)); - return Error(); -} - -KeyListResult QGpgMEKeyForMailboxJob::exec(const QString &mailbox, bool canEncrypt, Key &key, UserID &uid) -{ - const result_type r = do_work(context(), mailbox, canEncrypt); - key = std::get<1>(r); - uid = std::get<2>(r); - return std::get<0>(r); -} - -#include "qgpgmekeyformailboxjob.moc" diff --git a/lang/qt/src/qgpgmekeyformailboxjob.h b/lang/qt/src/qgpgmekeyformailboxjob.h deleted file mode 100644 index 0e8cc1dc..00000000 --- a/lang/qt/src/qgpgmekeyformailboxjob.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - qgpgmekeyformailboxjob.h - - This file is part of libkleopatra, the KDE keymanagement library - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEKEYFORMAILBOXJOB_H__ -#define __QGPGME_QGPGMEKEYFORMAILBOXJOB_H__ -#include "keyformailboxjob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/keylistresult.h> -#include <gpgme++/key.h> - -namespace QGpgME -{ - -class QGpgMEKeyForMailboxJob -#ifdef Q_MOC_RUN - : public KeyForMailboxJob -#else - : public _detail::ThreadedJobMixin<KeyForMailboxJob, std::tuple<GpgME::KeyListResult, GpgME::Key, GpgME::UserID, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEKeyForMailboxJob(GpgME::Context *context); - ~QGpgMEKeyForMailboxJob(); - - /** - Starts the operation. \a mailbox is the mailbox to - look for. - - The result is the same as for the LocateKeysJob. - - If \a canEncrypt is true, only keys that have a subkey for encryption - usage are returned. Use this if you need to select a - key for signing. - */ - GpgME::Error start(const QString &mailbox, bool canEncrypt = true) override; - - GpgME::KeyListResult exec(const QString &mailbox, bool canEncrypt, GpgME::Key &key, GpgME::UserID &uid) override; -}; - -} -#endif diff --git a/lang/qt/src/qgpgmekeygenerationjob.cpp b/lang/qt/src/qgpgmekeygenerationjob.cpp deleted file mode 100644 index ce0b4d40..00000000 --- a/lang/qt/src/qgpgmekeygenerationjob.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - qgpgmekeygenerationjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmekeygenerationjob.h" - -#include "dataprovider.h" - -#include <gpgme++/context.h> -#include <gpgme++/data.h> - -#include <cassert> - -using namespace QGpgME; -using namespace GpgME; - -QGpgMEKeyGenerationJob::QGpgMEKeyGenerationJob(Context *context) - : mixin_type(context) -{ - lateInitialization(); -} - -QGpgMEKeyGenerationJob::~QGpgMEKeyGenerationJob() {} - -static QGpgMEKeyGenerationJob::result_type generate_key(Context *ctx, const QString ¶meters) -{ - QGpgME::QByteArrayDataProvider dp; - Data data = ctx->protocol() == CMS ? Data(&dp) : Data(Data::null); - assert(data.isNull() == (ctx->protocol() != CMS)); - - const KeyGenerationResult res = ctx->generateKey(parameters.toUtf8().constData(), data); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(res, dp.data(), log, ae); -} - -Error QGpgMEKeyGenerationJob::start(const QString ¶meters) -{ - run(std::bind(&generate_key, std::placeholders::_1, parameters)); - return Error(); -} -#include "qgpgmekeygenerationjob.moc" diff --git a/lang/qt/src/qgpgmekeygenerationjob.h b/lang/qt/src/qgpgmekeygenerationjob.h deleted file mode 100644 index 35d5c2f4..00000000 --- a/lang/qt/src/qgpgmekeygenerationjob.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - qgpgmekeygenerationjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEKEYGENERATIONJOB_H__ -#define __QGPGME_QGPGMEKEYGENERATIONJOB_H__ - -#include "keygenerationjob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/keygenerationresult.h> - -namespace QGpgME -{ - -class QGpgMEKeyGenerationJob -#ifdef Q_MOC_RUN - : public KeyGenerationJob -#else - : public _detail::ThreadedJobMixin<KeyGenerationJob, std::tuple<GpgME::KeyGenerationResult, QByteArray, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -private Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEKeyGenerationJob(GpgME::Context *context); - ~QGpgMEKeyGenerationJob(); - - /* from KeygenerationJob */ - GpgME::Error start(const QString ¶meters) override; -}; - -} - -#endif // __QGPGME_QGPGMEKEYGENERATIONJOB_H__ diff --git a/lang/qt/src/qgpgmekeylistjob.cpp b/lang/qt/src/qgpgmekeylistjob.cpp deleted file mode 100644 index 633cff5b..00000000 --- a/lang/qt/src/qgpgmekeylistjob.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - qgpgmekeylistjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmekeylistjob.h" - -#include <gpgme++/key.h> -#include <gpgme++/context.h> -#include <gpgme++/keylistresult.h> -#include <gpg-error.h> - -#include <QStringList> - -#include <algorithm> - -#include <cstdlib> -#include <cstring> -#include <cassert> - -using namespace QGpgME; -using namespace GpgME; - -QGpgMEKeyListJob::QGpgMEKeyListJob(Context *context) - : mixin_type(context) - , mSecretOnly(false) -{ - lateInitialization(); -} - -QGpgMEKeyListJob::~QGpgMEKeyListJob() {} - -static KeyListResult do_list_keys(Context *ctx, const QStringList &pats, std::vector<Key> &keys, bool secretOnly) -{ - - const _detail::PatternConverter pc(pats); - - if (const Error err = ctx->startKeyListing(pc.patterns(), secretOnly)) { - return KeyListResult(nullptr, err); - } - - Error err; - do { - keys.push_back(ctx->nextKey(err)); - } while (!err); - - keys.pop_back(); - - const KeyListResult result = ctx->endKeyListing(); - ctx->cancelPendingOperation(); - return result; -} - -static QGpgMEKeyListJob::result_type list_keys(Context *ctx, QStringList pats, bool secretOnly) -{ - if (pats.size() < 2) { - std::vector<Key> keys; - const KeyListResult r = do_list_keys(ctx, pats, keys, secretOnly); - return std::make_tuple(r, keys, QString(), Error()); - } - - // The communication channel between gpgme and gpgsm is limited in - // the number of patterns that can be transported, but they won't - // say to how much, so we need to find out ourselves if we get a - // LINE_TOO_LONG error back... - - // We could of course just feed them single patterns, and that would - // probably be easier, but the performance penalty would currently - // be noticeable. - - unsigned int chunkSize = pats.size(); -retry: - std::vector<Key> keys; - keys.reserve(pats.size()); - KeyListResult result; - do { - const KeyListResult this_result = do_list_keys(ctx, pats.mid(0, chunkSize), keys, secretOnly); - if (this_result.error().code() == GPG_ERR_LINE_TOO_LONG) { - // got LINE_TOO_LONG, try a smaller chunksize: - chunkSize /= 2; - if (chunkSize < 1) - // chunks smaller than one can't be -> return the error. - { - return std::make_tuple(this_result, keys, QString(), Error()); - } else { - goto retry; - } - } else if (this_result.error().code() == GPG_ERR_EOF) { - // early end of keylisting (can happen when ~/.gnupg doesn't - // exist). Fakeing an empty result: - return std::make_tuple(KeyListResult(), std::vector<Key>(), QString(), Error()); - } - // ok, that seemed to work... - result.mergeWith(this_result); - if (result.error().code()) { - break; - } - pats = pats.mid(chunkSize); - } while (!pats.empty()); - return std::make_tuple(result, keys, QString(), Error()); -} - -Error QGpgMEKeyListJob::start(const QStringList &patterns, bool secretOnly) -{ - mSecretOnly = secretOnly; - run(std::bind(&list_keys, std::placeholders::_1, patterns, secretOnly)); - return Error(); -} - -KeyListResult QGpgMEKeyListJob::exec(const QStringList &patterns, bool secretOnly, std::vector<Key> &keys) -{ - mSecretOnly = secretOnly; - const result_type r = list_keys(context(), patterns, secretOnly); - resultHook(r); - keys = std::get<1>(r); - return std::get<0>(r); -} - -void QGpgMEKeyListJob::resultHook(const result_type &tuple) -{ - for (const Key &key : std::get<1>(tuple)) { - Q_EMIT nextKey(key); - } -} - -void QGpgMEKeyListJob::addMode(KeyListMode mode) -{ - context()->addKeyListMode(mode); -} - -#include "qgpgmekeylistjob.moc" diff --git a/lang/qt/src/qgpgmekeylistjob.h b/lang/qt/src/qgpgmekeylistjob.h deleted file mode 100644 index c1199768..00000000 --- a/lang/qt/src/qgpgmekeylistjob.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - qgpgmekeylistjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEKEYLISTJOB_H__ -#define __QGPGME_QGPGMEKEYLISTJOB_H__ - -#include "keylistjob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/keylistresult.h> -#include <gpgme++/key.h> - -namespace QGpgME -{ - -class QGpgMEKeyListJob -#ifdef Q_MOC_RUN - : public KeyListJob -#else - : public _detail::ThreadedJobMixin<KeyListJob, std::tuple<GpgME::KeyListResult, std::vector<GpgME::Key>, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEKeyListJob(GpgME::Context *context); - ~QGpgMEKeyListJob(); - - /* from KeyListJob */ - GpgME::Error start(const QStringList &patterns, bool secretOnly) override; - - /* from KeyListJob */ - GpgME::KeyListResult exec(const QStringList &patterns, bool secretOnly, std::vector<GpgME::Key> &keys) override; - - void addMode(GpgME::KeyListMode mode) override; - - /* from ThreadedJobMixin */ - void resultHook(const result_type &result) override; -private: - bool mSecretOnly; -}; - -} - -#endif // __QGPGME_QGPGMEKEYLISTJOB_H__ diff --git a/lang/qt/src/qgpgmelistallkeysjob.cpp b/lang/qt/src/qgpgmelistallkeysjob.cpp deleted file mode 100644 index ab9f1f42..00000000 --- a/lang/qt/src/qgpgmelistallkeysjob.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* - qgpgmelistallkeysjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2022,2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmelistallkeysjob.h" - -#include "listallkeysjob_p.h" - -#include "debug.h" -#include <gpgme++/key.h> -#include <gpgme++/context.h> -#include <gpgme++/engineinfo.h> -#include <gpgme++/global.h> -#include <gpgme++/keylistresult.h> -#include "qgpgme_debug.h" - -#include <gpg-error.h> - -#include <algorithm> - -#include <cstdlib> -#include <cstring> -#include <cassert> - -using namespace QGpgME; -using namespace GpgME; - -namespace -{ - -class QGpgMEListAllKeysJobPrivate : public ListAllKeysJobPrivate -{ - QGpgMEListAllKeysJob *q = nullptr; - -public: - QGpgMEListAllKeysJobPrivate(QGpgMEListAllKeysJob *qq) - : q{qq} - { - } - - ~QGpgMEListAllKeysJobPrivate() override = default; - -private: - GpgME::Error startIt() override - { - Q_ASSERT(!"Not supported by this Job class."); - return Error::fromCode(GPG_ERR_NOT_SUPPORTED); - } - - void startNow() override - { - q->run(); - } -}; - -} - -QGpgMEListAllKeysJob::QGpgMEListAllKeysJob(Context *context) - : mixin_type(context) -{ - setJobPrivate(this, std::unique_ptr<QGpgMEListAllKeysJobPrivate>{new QGpgMEListAllKeysJobPrivate{this}}); - lateInitialization(); -} - -QGpgMEListAllKeysJob::~QGpgMEListAllKeysJob() {} - -namespace { - -static KeyListResult do_list_keys_legacy(Context *ctx, std::vector<Key> &keys, bool secretOnly) -{ - - const char **pat = nullptr; - if (const Error err = ctx->startKeyListing(pat, secretOnly)) { - return KeyListResult(nullptr, err); - } - - Error err; - do { - keys.push_back(ctx->nextKey(err)); - } while (!err); - - keys.pop_back(); - - const KeyListResult result = ctx->endKeyListing(); - ctx->cancelPendingOperation(); - return result; -} - -template <typename ForwardIterator, typename BinaryPredicate> -ForwardIterator unique_by_merge(ForwardIterator first, ForwardIterator last, BinaryPredicate pred) -{ - first = std::adjacent_find(first, last, pred); - if (first == last) { - return last; - } - - ForwardIterator dest = first; - dest->mergeWith(*++first); - while (++first != last) - if (pred(*dest, *first)) { - dest->mergeWith(*first); - } else { - *++dest = *first; - } - return ++dest; -} - -static void merge_keys(std::vector<Key> &merged, std::vector<Key> &pub, std::vector<Key> &sec) -{ - merged.reserve(pub.size() + sec.size()); - - std::merge(pub.begin(), pub.end(), - sec.begin(), sec.end(), - std::back_inserter(merged), - ByFingerprint<std::less>()); - - merged.erase(unique_by_merge(merged.begin(), merged.end(), ByFingerprint<std::equal_to>()), - merged.end()); -} - -static QGpgMEListAllKeysJob::result_type list_keys_legacy(Context *ctx, bool mergeKeys) -{ - std::vector<Key> pub, sec, merged; - KeyListResult r; - - r.mergeWith(do_list_keys_legacy(ctx, pub, false)); - std::sort(pub.begin(), pub.end(), ByFingerprint<std::less>()); - - r.mergeWith(do_list_keys_legacy(ctx, sec, true)); - std::sort(sec.begin(), sec.end(), ByFingerprint<std::less>()); - - if (mergeKeys) { - merge_keys(merged, pub, sec); - } else { - merged.swap(pub); - } - return std::make_tuple(r, merged, sec, QString(), Error()); -} - -static KeyListResult do_list_keys(Context *ctx, std::vector<Key> &keys) -{ - const unsigned int keyListMode = ctx->keyListMode(); - ctx->addKeyListMode(KeyListMode::WithSecret); - - const char **pat = nullptr; - if (const Error err = ctx->startKeyListing(pat)) { - ctx->setKeyListMode(keyListMode); - return KeyListResult(nullptr, err); - } - - Error err; - do { - keys.push_back(ctx->nextKey(err)); - } while (!err); - - keys.pop_back(); - - const KeyListResult result = ctx->endKeyListing(); - ctx->setKeyListMode(keyListMode); - - ctx->cancelPendingOperation(); - return result; -} - -static QGpgMEListAllKeysJob::result_type list_keys(Context *ctx, bool mergeKeys, ListAllKeysJob::Options options) -{ - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.0") { - return list_keys_legacy(ctx, mergeKeys); - } - - if (options & ListAllKeysJob::DisableAutomaticTrustDatabaseCheck) { - auto err = ctx->setFlag("no-auto-check-trustdb", "1"); - if (err) { - // ignore error, but log a warning - qCWarning(QGPGME_LOG) << "Setting context flag no-auto-check-trustdb failed:" << err; - } - } - - std::vector<Key> keys; - KeyListResult r = do_list_keys(ctx, keys); - std::sort(keys.begin(), keys.end(), ByFingerprint<std::less>()); - - std::vector<Key> sec; - std::copy_if(keys.begin(), keys.end(), std::back_inserter(sec), [](const Key &key) { return key.hasSecret(); }); - - return std::make_tuple(r, keys, sec, QString(), Error()); -} - -} - -Error QGpgMEListAllKeysJob::start(bool mergeKeys) -{ - run(std::bind(&list_keys, std::placeholders::_1, mergeKeys, options())); - return Error(); -} - -KeyListResult QGpgMEListAllKeysJob::exec(std::vector<Key> &pub, std::vector<Key> &sec, bool mergeKeys) -{ - const result_type r = list_keys(context(), mergeKeys, options()); - pub = std::get<1>(r); - sec = std::get<2>(r); - return std::get<0>(r); -} - -#include "qgpgmelistallkeysjob.moc" diff --git a/lang/qt/src/qgpgmelistallkeysjob.h b/lang/qt/src/qgpgmelistallkeysjob.h deleted file mode 100644 index 93686a4b..00000000 --- a/lang/qt/src/qgpgmelistallkeysjob.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - qgpgmelistallkeysjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMELISTALLKEYSJOB_H__ -#define __QGPGME_QGPGMELISTALLKEYSJOB_H__ - -#include "listallkeysjob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/keylistresult.h> -#include <gpgme++/key.h> - -namespace QGpgME -{ - -class QGpgMEListAllKeysJob -#ifdef Q_MOC_RUN - : public ListAllKeysJob -#else - : public _detail::ThreadedJobMixin<ListAllKeysJob, std::tuple<GpgME::KeyListResult, std::vector<GpgME::Key>, std::vector<GpgME::Key>, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEListAllKeysJob(GpgME::Context *context); - ~QGpgMEListAllKeysJob(); - - /* from ListAllKeysJob */ - GpgME::Error start(bool mergeKeys) override; - - /* from ListAllKeysJob */ - GpgME::KeyListResult exec(std::vector<GpgME::Key> &pub, std::vector<GpgME::Key> &sec, bool mergeKeys) override; -}; - -} - -#endif // __QGPGME_QGPGMELISTALLKEYSJOB_H__ diff --git a/lang/qt/src/qgpgmenewcryptoconfig.cpp b/lang/qt/src/qgpgmenewcryptoconfig.cpp deleted file mode 100644 index a4782d2f..00000000 --- a/lang/qt/src/qgpgmenewcryptoconfig.cpp +++ /dev/null @@ -1,819 +0,0 @@ -/* - qgpgmenewcryptoconfig.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2010 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmenewcryptoconfig.h" - -#include <QDebug> -#include "qgpgme_debug.h" - -#include <QFile> -#include <QDir> -#include <QList> - -#include <gpgme++/global.h> -#include <gpgme++/error.h> -#include "debug.h" - -#include <sstream> -#include <string> -#include <functional> -#include <cassert> -#include <functional> - -using namespace QGpgME; -using namespace GpgME; -using namespace GpgME::Configuration; - -// Just for the Q_ASSERT in the dtor. Not thread-safe, but who would -// have 2 threads talking to gpgconf anyway? :) -static bool s_duringClear = false; - -QGpgMENewCryptoConfig::QGpgMENewCryptoConfig() - : m_parsed(false) -{ -} - -QGpgMENewCryptoConfig::~QGpgMENewCryptoConfig() -{ - clear(); -} - -void QGpgMENewCryptoConfig::reloadConfiguration(bool) -{ - clear(); - - Error error; - const std::vector<Component> components = Component::load(error); -#ifndef NDEBUG - { - std::stringstream ss; - ss << "error: " << error - << "components:\n"; - std::copy(components.begin(), components.end(), - std::ostream_iterator<Component>(ss, "\n")); - qCDebug(QGPGME_CONFIG_LOADING_LOG) << ss.str().c_str(); - } -#endif -#if 0 - TODO port? - if (error && showErrors) { - const QString wmsg = i18n("<qt>Failed to execute gpgconf:<p>%1</p></qt>", QString::fromLocal8Bit(error.asString())); - qCWarning(QGPGME_LOG) << wmsg; // to see it from test_cryptoconfig.cpp - KMessageBox::error(0, wmsg); - } -#endif - for (const Component &c : components) { - const std::shared_ptr<QGpgMENewCryptoConfigComponent> comp(new QGpgMENewCryptoConfigComponent); - comp->setComponent(c); - m_componentsByName[ comp->name() ] = comp; - } - m_parsed = true; -} - -QStringList QGpgMENewCryptoConfig::componentList() const -{ - if (!m_parsed) { - const_cast<QGpgMENewCryptoConfig *>(this)->reloadConfiguration(true); - } - QStringList result; - std::transform(m_componentsByName.begin(), m_componentsByName.end(), - std::back_inserter(result), - mem_fn(&QGpgMENewCryptoConfigComponent::name)); - return result; -} - -QGpgMENewCryptoConfigComponent *QGpgMENewCryptoConfig::component(const QString &name) const -{ - if (!m_parsed) { - const_cast<QGpgMENewCryptoConfig *>(this)->reloadConfiguration(false); - } - return m_componentsByName.value(name).get(); -} - -void QGpgMENewCryptoConfig::sync(bool runtime) -{ - for (const std::shared_ptr<QGpgMENewCryptoConfigComponent> &c : qAsConst(m_componentsByName)) { - c->sync(runtime); - } -} - -void QGpgMENewCryptoConfig::clear() -{ - s_duringClear = true; - m_componentsByName.clear(); - s_duringClear = false; - m_parsed = false; // next call to componentList/component will need to run gpgconf again -} - -//// - -QGpgMENewCryptoConfigComponent::QGpgMENewCryptoConfigComponent() - : CryptoConfigComponent(), - m_component() -{ - -} - -void QGpgMENewCryptoConfigComponent::setComponent(const Component &component) -{ - m_component = component; - m_groupsByName.clear(); - - std::shared_ptr<QGpgMENewCryptoConfigGroup> group; - - const std::vector<Option> options = m_component.options(); - for (const Option &o : options) { - if (o.flags() & Group) { - if (group) { - m_groupsByName[group->name()] = group; - } - group.reset(new QGpgMENewCryptoConfigGroup(shared_from_this(), o)); - } else if (group) { - const std::shared_ptr<QGpgMENewCryptoConfigEntry> entry(new QGpgMENewCryptoConfigEntry(group, o)); - const QString name = entry->name(); - group->m_entryNames.push_back(name); - group->m_entriesByName[name] = entry; - } else { - qCWarning(QGPGME_LOG) << "found no group for entry" << o.name() << "of component" << name(); - } - } - if (group) { - m_groupsByName[group->name()] = group; - } - -} - -QGpgMENewCryptoConfigComponent::~QGpgMENewCryptoConfigComponent() {} - -QString QGpgMENewCryptoConfigComponent::name() const -{ - return QString::fromUtf8(m_component.name()); -} - -QString QGpgMENewCryptoConfigComponent::description() const -{ - return QString::fromUtf8(m_component.description()); -} - -QStringList QGpgMENewCryptoConfigComponent::groupList() const -{ - QStringList result; - result.reserve(m_groupsByName.size()); - std::transform(m_groupsByName.begin(), m_groupsByName.end(), - std::back_inserter(result), - std::mem_fn(&QGpgMENewCryptoConfigGroup::name)); - return result; -} - -QGpgMENewCryptoConfigGroup *QGpgMENewCryptoConfigComponent::group(const QString &name) const -{ - return m_groupsByName.value(name).get(); -} - -void QGpgMENewCryptoConfigComponent::sync(bool runtime) -{ - Q_UNUSED(runtime) // runtime is always set by engine_gpgconf - if (const Error err = m_component.save()) { - qCWarning(QGPGME_LOG) << ":" - << "Error from gpgconf while saving configuration: %1" - << err; - } -} - -//// - -QGpgMENewCryptoConfigGroup::QGpgMENewCryptoConfigGroup(const std::shared_ptr<QGpgMENewCryptoConfigComponent> &comp, const Option &option) - : CryptoConfigGroup(), - m_component(comp), - m_option(option) -{ -} - -QGpgMENewCryptoConfigGroup::~QGpgMENewCryptoConfigGroup() {} - -QString QGpgMENewCryptoConfigGroup::name() const -{ - return QString::fromUtf8(m_option.name()); -} - -QString QGpgMENewCryptoConfigGroup::description() const -{ - return QString::fromUtf8(m_option.description()); -} - -QString QGpgMENewCryptoConfigGroup::path() const -{ - if (const std::shared_ptr<QGpgMENewCryptoConfigComponent> c = m_component.lock()) { - return c->name() + QLatin1Char('/') + name(); - } else { - return QString(); - } -} - -CryptoConfigEntry::Level QGpgMENewCryptoConfigGroup::level() const -{ - // two casts to make SunCC happy: - return static_cast<CryptoConfigEntry::Level>(static_cast<unsigned int>(m_option.level())); -} - -QStringList QGpgMENewCryptoConfigGroup::entryList() const -{ - return m_entryNames; -} - -QGpgMENewCryptoConfigEntry *QGpgMENewCryptoConfigGroup::entry(const QString &name) const -{ - return m_entriesByName.value(name).get(); -} - -static QString urlpart_encode(const QString &str) -{ - QString enc(str); - enc.replace(QLatin1Char('%'), QStringLiteral("%25")); // first! - enc.replace(QLatin1Char(':'), QStringLiteral("%3a")); - //qCDebug(QGPGME_LOG) <<" urlpart_encode:" << str <<" ->" << enc; - return enc; -} - -static QString urlpart_decode(const QString &str) -{ - return QUrl::fromPercentEncoding(str.toLatin1()); -} - -// gpgconf arg type number -> NewCryptoConfigEntry arg type enum mapping -static QGpgME::CryptoConfigEntry::ArgType knownArgType(int argType, bool &ok) -{ - ok = true; - switch (argType) { - case 0: // none - return QGpgME::CryptoConfigEntry::ArgType_None; - case 1: // string - return QGpgME::CryptoConfigEntry::ArgType_String; - case 2: // int32 - return QGpgME::CryptoConfigEntry::ArgType_Int; - case 3: // uint32 - return QGpgME::CryptoConfigEntry::ArgType_UInt; - case 32: // pathname - return QGpgME::CryptoConfigEntry::ArgType_Path; - case 33: // ldap server - return QGpgME::CryptoConfigEntry::ArgType_LDAPURL; - default: - ok = false; - return QGpgME::CryptoConfigEntry::ArgType_None; - } -} - -QGpgMENewCryptoConfigEntry::QGpgMENewCryptoConfigEntry(const std::shared_ptr<QGpgMENewCryptoConfigGroup> &group, const Option &option) - : m_group(group), m_option(option) -{ -} - -#if 0 -QVariant QGpgMENewCryptoConfigEntry::stringToValue(const QString &str, bool unescape) const -{ - const bool isString = isStringType(); - - if (isList()) { - if (argType() == ArgType_None) { - bool ok = true; - const QVariant v = str.isEmpty() ? 0U : str.toUInt(&ok); - if (!ok) { - qCWarning(QGPGME_LOG) << "list-of-none should have an unsigned int as value:" << str; - } - return v; - } - QList<QVariant> lst; - QStringList items = str.split(',', QString::SkipEmptyParts); - for (QStringList::const_iterator valit = items.constBegin(); valit != items.constEnd(); ++valit) { - QString val = *valit; - if (isString) { - if (val.isEmpty()) { - lst << QVariant(QString()); - continue; - } else if (unescape) { - if (val[0] != '"') { // see README.gpgconf - qCWarning(QGPGME_LOG) << "String value should start with '\"' :" << val; - } - val = val.mid(1); - } - } - lst << QVariant(unescape ? gpgconf_unescape(val) : val); - } - return lst; - } else { // not a list - QString val(str); - if (isString) { - if (val.isEmpty()) { - return QVariant(QString()); // not set [ok with lists too?] - } else if (unescape) { - if (val[0] != '"') { // see README.gpgconf - qCWarning(QGPGME_LOG) << "String value should start with '\"' :" << val; - } - val = val.mid(1); - } - } - return QVariant(unescape ? gpgconf_unescape(val) : val); - } -} -#endif - -QGpgMENewCryptoConfigEntry::~QGpgMENewCryptoConfigEntry() -{ -#ifndef NDEBUG - if (!s_duringClear && m_option.dirty()) - qCWarning(QGPGME_LOG) << "Deleting a QGpgMENewCryptoConfigEntry that was modified (" << m_option.description() << ")" - << "You forgot to call sync() (to commit) or clear() (to discard)"; -#endif -} - -QString QGpgMENewCryptoConfigEntry::name() const -{ - return QString::fromUtf8(m_option.name()); -} - -QString QGpgMENewCryptoConfigEntry::description() const -{ - return QString::fromUtf8(m_option.description()); -} - -QString QGpgMENewCryptoConfigEntry::path() const -{ - if (const std::shared_ptr<QGpgMENewCryptoConfigGroup> g = m_group.lock()) { - return g->path() + QLatin1Char('/') + name(); - } else { - return QString(); - } -} - -bool QGpgMENewCryptoConfigEntry::isOptional() const -{ - return m_option.flags() & Optional; -} - -bool QGpgMENewCryptoConfigEntry::isReadOnly() const -{ - return m_option.flags() & NoChange; -} - -bool QGpgMENewCryptoConfigEntry::isList() const -{ - return m_option.flags() & List; -} - -bool QGpgMENewCryptoConfigEntry::isRuntime() const -{ - return m_option.flags() & Runtime; -} - -CryptoConfigEntry::Level QGpgMENewCryptoConfigEntry::level() const -{ - // two casts to make SunCC happy: - return static_cast<Level>(static_cast<unsigned int>(m_option.level())); -} - -CryptoConfigEntry::ArgType QGpgMENewCryptoConfigEntry::argType() const -{ - bool ok = false; - const ArgType type = knownArgType(m_option.type(), ok); - if (ok) { - return type; - } else { - return knownArgType(m_option.alternateType(), ok); - } -} - -bool QGpgMENewCryptoConfigEntry::isSet() const -{ - return m_option.set(); -} - -bool QGpgMENewCryptoConfigEntry::boolValue() const -{ - Q_ASSERT(m_option.alternateType() == NoType); - Q_ASSERT(!isList()); - return m_option.currentValue().boolValue(); -} - -QString QGpgMENewCryptoConfigEntry::stringValue() const -{ - //return toString( false ); - Q_ASSERT(m_option.alternateType() == StringType); - Q_ASSERT(!isList()); - return QString::fromUtf8(m_option.currentValue().stringValue()); -} - -int QGpgMENewCryptoConfigEntry::intValue() const -{ - Q_ASSERT(m_option.alternateType() == IntegerType); - Q_ASSERT(!isList()); - return m_option.currentValue().intValue(); -} - -unsigned int QGpgMENewCryptoConfigEntry::uintValue() const -{ - Q_ASSERT(m_option.alternateType() == UnsignedIntegerType); - Q_ASSERT(!isList()); - return m_option.currentValue().uintValue(); -} - -static QUrl parseURL(int mRealArgType, const QString &str) -{ - if (mRealArgType == 33) { // LDAP server - // The format is HOSTNAME:PORT:USERNAME:PASSWORD:BASE_DN - // or, since gpg 2.2.18, e.g. for dirmngr/ldapserver: [ldap:]hostname:port:username:password:base_dn:flags[:] - const bool isLdapUrl = str.startsWith(QLatin1String("ldap://")) || str.startsWith(QLatin1String("ldaps://")); - if (!isLdapUrl) { - const bool hasOptionalPrefix = str.startsWith(QLatin1String("ldap:")); - const QStringList items = hasOptionalPrefix ? str.mid(5).split(QLatin1Char(':')) : str.split(QLatin1Char(':')); - if (items.size() >= 5) { - QUrl url; - url.setScheme(QStringLiteral("ldap")); - url.setHost(urlpart_decode(items[0]), QUrl::DecodedMode); - - const auto portString = items[1]; - if (!portString.isEmpty()) { - bool ok; - const int port = portString.toInt(&ok); - if (ok) { - url.setPort(port); - } else { - qCWarning(QGPGME_LOG) << "parseURL: malformed LDAP server port, ignoring:" << portString; - } - } - - const QString userName = urlpart_decode(items[2]); - if (!userName.isEmpty()) { - url.setUserName(userName, QUrl::DecodedMode); - } - const QString passWord = urlpart_decode(items[3]); - if (!passWord.isEmpty()) { - url.setPassword(passWord, QUrl::DecodedMode); - } - const auto baseDn = urlpart_decode(items[4]); - if (!baseDn.isEmpty()) { - url.setQuery(baseDn, QUrl::DecodedMode); - } - if (items.size() >= 6) { - const auto flags = urlpart_decode(items[5]); - if (!flags.isEmpty()) { - url.setFragment(flags, QUrl::DecodedMode); - } - } - return url; - } else { - qCWarning(QGPGME_LOG) << "parseURL: malformed LDAP server:" << str; - } - } - } - // other URLs : assume wellformed URL syntax. - return QUrl(str); -} - -static QString portToString(int port) -{ - // -1 is used for default ports => empty string - return port != -1 ? QString::number(port) : QString(); -} - -// The opposite of parseURL -static QString splitURL(int mRealArgType, const QUrl &url) -{ - if (mRealArgType == 33) { // LDAP server - // The format is HOSTNAME:PORT:USERNAME:PASSWORD:BASE_DN - // or, since gpg 2.2.18, e.g. for dirmngr/ldapserver: [ldap:]hostname:port:username:password:base_dn:flags[:] - Q_ASSERT(url.scheme() == QLatin1String("ldap")); - return urlpart_encode(url.host()) + QLatin1Char(':') + - portToString(url.port()) + QLatin1Char(':') + - urlpart_encode(url.userName()) + QLatin1Char(':') + - urlpart_encode(url.password()) + QLatin1Char(':') + - urlpart_encode(url.query()) + QLatin1Char(':') + - urlpart_encode(url.fragment()); - } - return url.path(); -} - -QUrl QGpgMENewCryptoConfigEntry::urlValue() const -{ - const Type type = m_option.type(); - Q_ASSERT(type == FilenameType || type == LdapServerType); - Q_ASSERT(!isList()); - if (type == FilenameType) { - QUrl url = QUrl::fromLocalFile(m_option.currentValue().stringValue()); - return url; - } - return parseURL(type, stringValue()); -} - -unsigned int QGpgMENewCryptoConfigEntry::numberOfTimesSet() const -{ - Q_ASSERT(m_option.alternateType() == NoType); - Q_ASSERT(isList()); - return m_option.currentValue().uintValue(); -} - -std::vector<int> QGpgMENewCryptoConfigEntry::intValueList() const -{ - Q_ASSERT(m_option.alternateType() == IntegerType); - Q_ASSERT(isList()); - return m_option.currentValue().intValues(); -} - -std::vector<unsigned int> QGpgMENewCryptoConfigEntry::uintValueList() const -{ - Q_ASSERT(m_option.alternateType() == UnsignedIntegerType); - Q_ASSERT(isList()); - return m_option.currentValue().uintValues(); -} - -QStringList QGpgMENewCryptoConfigEntry::stringValueList() const -{ - Q_ASSERT(isList()); - const Argument arg = m_option.currentValue(); - const std::vector<const char *> values = arg.stringValues(); - QStringList ret; - for(const char *value: values) { - ret << QString::fromUtf8(value); - } - return ret; -} - -QList<QUrl> QGpgMENewCryptoConfigEntry::urlValueList() const -{ - const Type type = m_option.type(); - Q_ASSERT(type == FilenameType || type == LdapServerType); - Q_ASSERT(isList()); - const Argument arg = m_option.currentValue(); - const std::vector<const char *> values = arg.stringValues(); - QList<QUrl> ret; - for (const char *value : values) { - if (type == FilenameType) { - QUrl url; - url.setPath(QFile::decodeName(value)); - ret << url; - } else { - ret << parseURL(type, QString::fromUtf8(value)); - } - } - return ret; -} - -void QGpgMENewCryptoConfigEntry::resetToDefault() -{ - m_option.resetToDefaultValue(); -} - -void QGpgMENewCryptoConfigEntry::setBoolValue(bool b) -{ - Q_ASSERT(m_option.alternateType() == NoType); - Q_ASSERT(!isList()); - // A "no arg" option is either set or not set. - // Being set means createNoneArgument(), being unset means resetToDefault() - m_option.setNewValue(m_option.createNoneArgument(b)); -} - -void QGpgMENewCryptoConfigEntry::setStringValue(const QString &str) -{ - Q_ASSERT(m_option.alternateType() == StringType); - Q_ASSERT(!isList()); - const Type type = m_option.type(); - // When setting a string to empty (and there's no default), we need to act like resetToDefault - // Otherwise we try e.g. "ocsp-responder:0:" and gpgconf answers: - // "gpgconf: argument required for option ocsp-responder" - if (str.isEmpty() && !isOptional()) { - m_option.resetToDefaultValue(); - } else if (type == FilenameType) { - m_option.setNewValue(m_option.createStringArgument(QFile::encodeName(str).constData())); - } else { - m_option.setNewValue(m_option.createStringArgument(str.toUtf8().constData())); - } -} - -void QGpgMENewCryptoConfigEntry::setIntValue(int i) -{ - Q_ASSERT(m_option.alternateType() == IntegerType); - Q_ASSERT(!isList()); - m_option.setNewValue(m_option.createIntArgument(i)); -} - -void QGpgMENewCryptoConfigEntry::setUIntValue(unsigned int i) -{ - Q_ASSERT(m_option.alternateType() == UnsignedIntegerType); - Q_ASSERT(!isList()); - m_option.setNewValue(m_option.createUIntArgument(i)); -} - -void QGpgMENewCryptoConfigEntry::setURLValue(const QUrl &url) -{ - const Type type = m_option.type(); - Q_ASSERT(type == FilenameType || type == LdapServerType); - Q_ASSERT(!isList()); - const QString str = splitURL(type, url); - // cf. setStringValue() - if (str.isEmpty() && !isOptional()) { - m_option.resetToDefaultValue(); - } else if (type == FilenameType) { - m_option.setNewValue(m_option.createStringArgument(url.toLocalFile().toUtf8().constData())); - } else { - m_option.setNewValue(m_option.createStringArgument(str.toUtf8().constData())); - } -} - -void QGpgMENewCryptoConfigEntry::setNumberOfTimesSet(unsigned int i) -{ - Q_ASSERT(m_option.alternateType() == NoType); - Q_ASSERT(isList()); - m_option.setNewValue(m_option.createNoneListArgument(i)); -} - -void QGpgMENewCryptoConfigEntry::setIntValueList(const std::vector<int> &lst) -{ - Q_ASSERT(m_option.alternateType() == IntegerType); - Q_ASSERT(isList()); - m_option.setNewValue(m_option.createIntListArgument(lst)); -} - -void QGpgMENewCryptoConfigEntry::setUIntValueList(const std::vector<unsigned int> &lst) -{ - Q_ASSERT(m_option.alternateType() == UnsignedIntegerType); - Q_ASSERT(isList()); - m_option.setNewValue(m_option.createUIntListArgument(lst)); -} - -void QGpgMENewCryptoConfigEntry::setURLValueList(const QList<QUrl> &urls) -{ - const Type type = m_option.type(); - Q_ASSERT(m_option.alternateType() == StringType); - Q_ASSERT(isList()); - std::vector<std::string> values; - values.reserve(urls.size()); - for (const QUrl &url : urls) { - if (type == FilenameType) { - values.push_back(QFile::encodeName(url.path()).constData()); - } else { - values.push_back(splitURL(type, url).toUtf8().constData()); - } - } - const auto err = m_option.setNewValue(m_option.createStringListArgument(values)); - if (err) { - qCWarning(QGPGME_LOG) << "setURLValueList: failed to set new value:" << err; - } -} - -bool QGpgMENewCryptoConfigEntry::isDirty() const -{ - return m_option.dirty(); -} - -QVariant QGpgMENewCryptoConfigEntry::defaultValue() const -{ - const auto defaultValue = m_option.defaultValue(); - if (defaultValue.isNull() || defaultValue.numElements() == 0) { - return {}; - } - if (defaultValue.numElements() == 1) { - switch (m_option.alternateType()) { - case NoType: - return QVariant{defaultValue.boolValue()}; - case StringType: - return QVariant{QString::fromUtf8(defaultValue.stringValue())}; - case IntegerType: - return QVariant{defaultValue.intValue()}; - case UnsignedIntegerType: - return QVariant{defaultValue.uintValue()}; - default: - // alternateType should always be one of the above four types - qCWarning(QGPGME_LOG) << __func__ << ": unsupported alternateType" << m_option.alternateType(); - } - } else { - QList<QVariant> list; - switch (m_option.alternateType()) { - case StringType: { - const auto values = defaultValue.stringValues(); - std::transform(std::begin(values), std::end(values), std::back_inserter(list), - [] (const char *value) { return QVariant{QString::fromUtf8(value)}; }); - break; - } - case IntegerType: { - const auto values = defaultValue.intValues(); - std::transform(std::begin(values), std::end(values), std::back_inserter(list), - [] (int value) { return QVariant{value}; }); - break; - } - case UnsignedIntegerType: { - const auto values = defaultValue.uintValues(); - std::transform(std::begin(values), std::end(values), std::back_inserter(list), - [] (unsigned int value) { return QVariant{value}; }); - break; - } - default: - // alternateType should always be one of the above four types - qCWarning(QGPGME_LOG) << __func__ << ": unsupported alternateType" << m_option.alternateType() << "for list"; - } - return QVariant{list}; - } - - return {}; -} - -#if 0 -QString QGpgMENewCryptoConfigEntry::toString(bool escape) const -{ - // Basically the opposite of stringToValue - if (isStringType()) { - if (mValue.isNull()) { - return QString(); - } else if (isList()) { // string list - QStringList lst = mValue.toStringList(); - if (escape) { - for (QStringList::iterator it = lst.begin(); it != lst.end(); ++it) { - if (!(*it).isNull()) { - *it = gpgconf_escape(*it).prepend("\""); - } - } - } - QString res = lst.join(","); - //qCDebug(QGPGME_LOG) <<"toString:" << res; - return res; - } else { // normal string - QString res = mValue.toString(); - if (escape) { - res = gpgconf_escape(res).prepend("\""); - } - return res; - } - } - if (!isList()) { // non-list non-string - if (mArgType == ArgType_None) { - return mValue.toBool() ? QString::fromLatin1("1") : QString(); - } else { // some int - Q_ASSERT(mArgType == ArgType_Int || mArgType == ArgType_UInt); - return mValue.toString(); // int to string conversion - } - } - - // Lists (of other types than strings) - if (mArgType == ArgType_None) { - return QString::number(numberOfTimesSet()); - } - QStringList ret; - QList<QVariant> lst = mValue.toList(); - for (QList<QVariant>::const_iterator it = lst.constBegin(); it != lst.constEnd(); ++it) { - ret << (*it).toString(); // QVariant does the conversion - } - return ret.join(","); -} - -QString QGpgMENewCryptoConfigEntry::outputString() const -{ - Q_ASSERT(mSet); - return toString(true); -} - -bool QGpgMENewCryptoConfigEntry::isStringType() const -{ - return (mArgType == QGpgME::NewCryptoConfigEntry::ArgType_String - || mArgType == QGpgME::NewCryptoConfigEntry::ArgType_Path - || mArgType == QGpgME::NewCryptoConfigEntry::ArgType_URL - || mArgType == QGpgME::NewCryptoConfigEntry::ArgType_LDAPURL); -} - -void QGpgMENewCryptoConfigEntry::setDirty(bool b) -{ - mDirty = b; -} -#endif diff --git a/lang/qt/src/qgpgmenewcryptoconfig.h b/lang/qt/src/qgpgmenewcryptoconfig.h deleted file mode 100644 index 05726e37..00000000 --- a/lang/qt/src/qgpgmenewcryptoconfig.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - qgpgmenewcryptoconfig.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2010 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef QGPGME_QGPGMENEWCRYPTOCONFIG_H -#define QGPGME_QGPGMENEWCRYPTOCONFIG_H - -#include "qgpgme_export.h" -#include "cryptoconfig.h" - -#include <QHash> -#include <QStringList> -#include <QVariant> - -#include <gpgme++/configuration.h> - -#include <vector> -#include <utility> - -class QGpgMENewCryptoConfig; -class QGpgMENewCryptoConfigComponent; -class QGpgMENewCryptoConfigGroup; -class QGpgMENewCryptoConfigEntry; - -class QGpgMENewCryptoConfigEntry : public QGpgME::CryptoConfigEntry -{ -public: - QGpgMENewCryptoConfigEntry(const std::shared_ptr<QGpgMENewCryptoConfigGroup> &group, const GpgME::Configuration::Option &option); - ~QGpgMENewCryptoConfigEntry(); - - QString name() const override; - QString description() const override; - QString path() const override; - bool isOptional() const override; - bool isReadOnly() const override; - bool isList() const override; - bool isRuntime() const override; - Level level() const override; - ArgType argType() const override; - bool isSet() const override; - bool boolValue() const override; - QString stringValue() const override; - int intValue() const override; - unsigned int uintValue() const override; - QUrl urlValue() const override; - unsigned int numberOfTimesSet() const override; - std::vector<int> intValueList() const override; - std::vector<unsigned int> uintValueList() const override; - QList<QUrl> urlValueList() const override; - void resetToDefault() override; - void setBoolValue(bool) override; - void setStringValue(const QString &) override; - void setIntValue(int) override; - void setUIntValue(unsigned int) override; - void setURLValue(const QUrl &) override; - void setNumberOfTimesSet(unsigned int) override; - void setIntValueList(const std::vector<int> &) override; - void setUIntValueList(const std::vector<unsigned int> &) override; - void setURLValueList(const QList<QUrl> &) override; - bool isDirty() const override; - - QStringList stringValueList() const; - QVariant defaultValue() const; - -#if 0 - void setDirty(bool b); - QString outputString() const; - -protected: - bool isStringType() const; - QVariant stringToValue(const QString &value, bool unescape) const; - QString toString(bool escape) const; -#endif -private: - std::weak_ptr<QGpgMENewCryptoConfigGroup> m_group; - GpgME::Configuration::Option m_option; -}; - -class QGpgMENewCryptoConfigGroup : public QGpgME::CryptoConfigGroup -{ -public: - QGpgMENewCryptoConfigGroup(const std::shared_ptr<QGpgMENewCryptoConfigComponent> &parent, const GpgME::Configuration::Option &option); - ~QGpgMENewCryptoConfigGroup(); - - QString name() const override; - QString iconName() const override - { - return QString(); - } - QString description() const override; - QString path() const override; - QGpgME::CryptoConfigEntry::Level level() const override; - QStringList entryList() const override; - QGpgMENewCryptoConfigEntry *entry(const QString &name) const override; - -private: - friend class QGpgMENewCryptoConfigComponent; // it adds the entries - std::weak_ptr<QGpgMENewCryptoConfigComponent> m_component; - GpgME::Configuration::Option m_option; - QStringList m_entryNames; - QHash< QString, std::shared_ptr<QGpgMENewCryptoConfigEntry> > m_entriesByName; -}; - -/// For docu, see kleo/cryptoconfig.h -class QGpgMENewCryptoConfigComponent : public QGpgME::CryptoConfigComponent, public std::enable_shared_from_this<QGpgMENewCryptoConfigComponent> -{ -public: - QGpgMENewCryptoConfigComponent(); - ~QGpgMENewCryptoConfigComponent(); - - void setComponent(const GpgME::Configuration::Component &component); - - QString name() const override; - QString iconName() const override - { - return name(); - } - QString description() const override; - QStringList groupList() const override; - QGpgMENewCryptoConfigGroup *group(const QString &name) const override; - - void sync(bool runtime); - -private: - GpgME::Configuration::Component m_component; - QHash< QString, std::shared_ptr<QGpgMENewCryptoConfigGroup> > m_groupsByName; -}; - -/** - * CryptoConfig implementation around the gpgconf command-line tool - * For method docu, see kleo/cryptoconfig.h - */ -class QGPGME_EXPORT QGpgMENewCryptoConfig : public QGpgME::CryptoConfig -{ -public: - /** - * Constructor - */ - QGpgMENewCryptoConfig(); - ~QGpgMENewCryptoConfig(); - - QStringList componentList() const override; - - QGpgMENewCryptoConfigComponent *component(const QString &name) const override; - - void clear() override; - void sync(bool runtime) override; - -private: - /// @param showErrors if true, a messagebox will be shown if e.g. gpgconf wasn't found - void reloadConfiguration(bool showErrors); - -private: - QHash< QString, std::shared_ptr<QGpgMENewCryptoConfigComponent> > m_componentsByName; - bool m_parsed; -}; - -#endif /* QGPGME_QGPGMENEWCRYPTOCONFIG_H */ diff --git a/lang/qt/src/qgpgmequickjob.cpp b/lang/qt/src/qgpgmequickjob.cpp deleted file mode 100644 index d65afd7d..00000000 --- a/lang/qt/src/qgpgmequickjob.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* qgpgmequickjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2017 Intevation GmbH - Copyright (c) 2020 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmequickjob.h" - -#include "qgpgme_debug.h" -#include "quickjob_p.h" -#include "util.h" - -#include <gpgme++/context.h> -#include <gpgme++/key.h> - - -using namespace QGpgME; -using namespace GpgME; - -namespace -{ - -class QGpgMEQuickJobPrivate : public QuickJobPrivate -{ - QGpgMEQuickJob *q = nullptr; - -public: - QGpgMEQuickJobPrivate(QGpgMEQuickJob *qq) - : q{qq} - { - } - - ~QGpgMEQuickJobPrivate() override = default; - -private: - GpgME::Error startIt() override - { - Q_ASSERT(!"Not supported by this Job class."); - return Error::fromCode(GPG_ERR_NOT_SUPPORTED); - } - - void startNow() override - { - Q_ASSERT(!"Not supported by this Job class."); - q->run(); - } - - GpgME::Error startSetKeyEnabled(const GpgME::Key &key, bool enable) override; -}; - -} - -QGpgMEQuickJob::QGpgMEQuickJob(Context *context) - : mixin_type(context) -{ - setJobPrivate(this, std::unique_ptr<QGpgMEQuickJobPrivate>{new QGpgMEQuickJobPrivate{this}}); - lateInitialization(); -} - -QGpgMEQuickJob::~QGpgMEQuickJob() = default; - -static QGpgMEQuickJob::result_type createWorker(GpgME::Context *ctx, - const QString &uid, - const char *algo, - const QDateTime &expires, - const GpgME::Key &key, - unsigned int flags) -{ - auto err = ctx->createKey(uid.toUtf8().constData(), - algo, - 0, - expires.isValid() ? (unsigned long) (expires.toMSecsSinceEpoch() / 1000 - - QDateTime::currentSecsSinceEpoch()) : 0, - key, - flags); - return std::make_tuple(err, QString(), Error()); -} - -static QGpgMEQuickJob::result_type addSubkeyWorker(GpgME::Context *ctx, - const GpgME::Key &key, - const char *algo, - const QDateTime &expires, - unsigned int flags) -{ - auto err = ctx->createSubkey(key, algo, 0, - expires.isValid() ? (unsigned long) (expires.toMSecsSinceEpoch() / 1000 - - QDateTime::currentSecsSinceEpoch()): 0, - flags); - return std::make_tuple(err, QString(), Error()); -} - -static QGpgMEQuickJob::result_type addUidWorker(GpgME::Context *ctx, - const GpgME::Key &key, - const QString &uid) -{ - auto err = ctx->addUid(key, uid.toUtf8().constData()); - return std::make_tuple(err, QString(), Error()); -} - -static QGpgMEQuickJob::result_type revUidWorker(GpgME::Context *ctx, - const GpgME::Key &key, - const QString &uid) -{ - auto err = ctx->revUid(key, uid.toUtf8().constData()); - return std::make_tuple(err, QString(), Error()); -} - -static QGpgMEQuickJob::result_type revokeSignatureWorker(Context *ctx, - const Key &key, - const Key &signingKey, - const std::vector<UserID> &userIds) -{ - const auto err = ctx->revokeSignature(key, signingKey, userIds); - return std::make_tuple(err, QString(), Error()); -} - -static QGpgMEQuickJob::result_type addAdskWorker(Context *ctx, const Key &key, const char *adsk) -{ - const auto err = ctx->addAdsk(key, adsk); - return std::make_tuple(err, QString(), Error()); -} - -void QGpgMEQuickJob::startCreate(const QString &uid, - const char *algo, - const QDateTime &expires, - const GpgME::Key &key, - unsigned int flags) -{ - run(std::bind(&createWorker, std::placeholders::_1, uid, algo, - expires, key, flags)); -} - -void QGpgMEQuickJob::startAddUid(const GpgME::Key &key, const QString &uid) -{ - run(std::bind(&addUidWorker, std::placeholders::_1, key, uid)); -} - -void QGpgMEQuickJob::startRevUid(const GpgME::Key &key, const QString &uid) -{ - run(std::bind(&revUidWorker, std::placeholders::_1, key, uid)); -} - -void QGpgMEQuickJob::startAddSubkey(const GpgME::Key &key, const char *algo, - const QDateTime &expires, - unsigned int flags) -{ - run(std::bind(&addSubkeyWorker, std::placeholders::_1, key, algo, - expires, flags)); -} - -void QGpgMEQuickJob::startRevokeSignature(const Key &key, const Key &signingKey, const std::vector<UserID> &userIds) -{ - run(std::bind(&revokeSignatureWorker, std::placeholders::_1, key, signingKey, userIds)); -} - -void QGpgMEQuickJob::startAddAdsk(const GpgME::Key &key, const char *adsk) -{ - run(std::bind(&addAdskWorker, std::placeholders::_1, key, adsk)); -} - -static QGpgMEQuickJob::result_type set_key_enabled(Context *ctx, const Key &key, bool enabled) -{ - const auto err = ctx->setKeyEnabled(key, enabled); - return std::make_tuple(err, QString(), Error()); -} - -Error QGpgMEQuickJobPrivate::startSetKeyEnabled(const Key &key, bool enabled) -{ - if (key.isNull()) { - return Error::fromCode(GPG_ERR_INV_VALUE); - } - - q->run([=](Context *ctx) { - return set_key_enabled(ctx, key, enabled); - }); - - return {}; -} - -#include "qgpgmequickjob.moc" diff --git a/lang/qt/src/qgpgmequickjob.h b/lang/qt/src/qgpgmequickjob.h deleted file mode 100644 index 07b89e18..00000000 --- a/lang/qt/src/qgpgmequickjob.h +++ /dev/null @@ -1,78 +0,0 @@ -/* qgpgmequickjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2017 Intevation GmbH - Copyright (c) 2020 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifndef QGPGME_QGPGMEQUICKJOB_H -#define QGPGME_QGPGMEQUICKJOB_H - -#include "quickjob.h" - -#include "threadedjobmixin.h" - -namespace QGpgME -{ - -/** - * Interface to the modern key manipulation functions. - */ -class QGpgMEQuickJob -#ifdef Q_MOC_RUN - : public QuickJob -#else - : public _detail::ThreadedJobMixin<QuickJob> -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEQuickJob(GpgME::Context *context); - ~QGpgMEQuickJob(); - - void startCreate(const QString &uid, - const char *algo, - const QDateTime &expires = QDateTime(), - const GpgME::Key &key = GpgME::Key(), - unsigned int flags = 0) override; - void startAddUid(const GpgME::Key &key, const QString &uid) override; - void startRevUid(const GpgME::Key &key, const QString &uid) override; - void startAddSubkey(const GpgME::Key &key, const char *algo, - const QDateTime &expires = QDateTime(), - unsigned int flags = 0) override; - void startRevokeSignature(const GpgME::Key &key, const GpgME::Key &signingKey, - const std::vector<GpgME::UserID> &userIds = std::vector<GpgME::UserID>()) override; - void startAddAdsk(const GpgME::Key &key, const char *adsk) override; -}; - -} -#endif diff --git a/lang/qt/src/qgpgmereceivekeysjob.cpp b/lang/qt/src/qgpgmereceivekeysjob.cpp deleted file mode 100644 index 6bfc6b56..00000000 --- a/lang/qt/src/qgpgmereceivekeysjob.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - qgpgmereceivekeysjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "qgpgmereceivekeysjob.h" - -#include "util.h" - -using namespace QGpgME; -using namespace GpgME; - -QGpgMEReceiveKeysJob::QGpgMEReceiveKeysJob(Context *context) - : mixin_type{context} -{ - lateInitialization(); -} - -QGpgMEReceiveKeysJob::~QGpgMEReceiveKeysJob() = default; - -static QGpgMEReceiveKeysJob::result_type importfromkeyserver(Context *ctx, const QStringList &keyIds) -{ - const ImportResult res = ctx->importKeys(toStrings(keyIds)); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(res, log, ae); -} - -Error QGpgMEReceiveKeysJob::start(const QStringList &keyIds) -{ - run(std::bind(&importfromkeyserver, std::placeholders::_1, keyIds)); - return Error(); -} - -GpgME::ImportResult QGpgME::QGpgMEReceiveKeysJob::exec(const QStringList &keyIds) -{ - const result_type r = importfromkeyserver(context(), keyIds); - return std::get<0>(r); -} - -#include "qgpgmereceivekeysjob.moc" diff --git a/lang/qt/src/qgpgmereceivekeysjob.h b/lang/qt/src/qgpgmereceivekeysjob.h deleted file mode 100644 index 4c6a24be..00000000 --- a/lang/qt/src/qgpgmereceivekeysjob.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - qgpgmereceivekeysjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMERECEIVEKEYSJOB_H__ -#define __QGPGME_QGPGMERECEIVEKEYSJOB_H__ - -#include "receivekeysjob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/importresult.h> - -namespace QGpgME -{ - -class QGpgMEReceiveKeysJob -#ifdef Q_MOC_RUN - : public ReceiveKeysJob -#else - : public _detail::ThreadedJobMixin<ReceiveKeysJob, std::tuple<GpgME::ImportResult, QString, GpgME::Error>> -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEReceiveKeysJob(GpgME::Context *context); - ~QGpgMEReceiveKeysJob() override; - - GpgME::Error start(const QStringList &keyIds) override; - - GpgME::ImportResult exec(const QStringList &keyIds) override; -}; - -} - -#endif // __QGPGME_QGPGMERECEIVEKEYSJOB_H__ diff --git a/lang/qt/src/qgpgmerefreshsmimekeysjob.cpp b/lang/qt/src/qgpgmerefreshsmimekeysjob.cpp deleted file mode 100644 index 730cef80..00000000 --- a/lang/qt/src/qgpgmerefreshsmimekeysjob.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/* - qgpgmerefreshsmimekeysjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarävdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#define MAX_CMD_LENGTH 32768 - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmerefreshsmimekeysjob.h" -#include "util.h" - -#include <QDebug> -#include "qgpgme_debug.h" - -#include <gpgme++/context.h> -#include <gpgme++/key.h> - -#include <QByteArray> -#include <QMetaObject> -#include <QProcess> -#include <QStringList> - -#include <gpg-error.h> - -#include <assert.h> - -using namespace QGpgME; - -QGpgMERefreshSMIMEKeysJob::QGpgMERefreshSMIMEKeysJob() - : RefreshKeysJob(nullptr), - mProcess(nullptr), - mError(0) -{ - -} - -QGpgMERefreshSMIMEKeysJob::~QGpgMERefreshSMIMEKeysJob() -{ - -} - -GpgME::Error QGpgMERefreshSMIMEKeysJob::start(const QStringList &patterns) -{ - assert(mPatternsToDo.empty()); - - mPatternsToDo = patterns; - if (mPatternsToDo.empty()) { - mPatternsToDo.push_back(QStringLiteral(" ")); // empty list means all -> mae - } - // sure to fail the first - // startAProcess() guard clause - - return startAProcess(); -} - -GpgME::Error QGpgMERefreshSMIMEKeysJob::start(const std::vector<GpgME::Key> &keys) -{ - if (keys.empty()) { - QMetaObject::invokeMethod(this, [this]() { - Q_EMIT slotProcessExited(0, QProcess::NormalExit); - }, Qt::QueuedConnection); - return {}; - } - - const bool gotWrongKeys = std::any_of(std::begin(keys), std::end(keys), [](const GpgME::Key &k) { - return k.protocol() != GpgME::CMS; - }); - if (gotWrongKeys) { - qCDebug(QGPGME_LOG) << "Error: At least one of the keys is not an S/MIME key"; - return GpgME::Error::fromCode(GPG_ERR_INV_VALUE); - } - - return start(toFingerprints(keys)); -} - -#if MAX_CMD_LENGTH < 65 + 128 -#error MAX_CMD_LENGTH is too low -#endif - -GpgME::Error QGpgMERefreshSMIMEKeysJob::startAProcess() -{ - if (mPatternsToDo.empty()) { - return GpgME::Error(); - } - // create and start gpgsm process: - mProcess = new QProcess(this); - mProcess->setObjectName(QStringLiteral("gpgsm -k --with-validation --force-crl-refresh --enable-crl-checks")); - - // FIXME: obbtain the path to gpgsm from gpgme, so we use the same instance. - mProcess->setProgram(QStringLiteral("gpgsm")); - QStringList arguments; - arguments << QStringLiteral("-k") - << QStringLiteral("--with-validation") - << QStringLiteral("--force-crl-refresh") - << QStringLiteral("--enable-crl-checks"); - unsigned int commandLineLength = MAX_CMD_LENGTH; - commandLineLength -= - strlen("gpgsm") + 1 + strlen("-k") + 1 + - strlen("--with-validation") + 1 + strlen("--force-crl-refresh") + 1 + - strlen("--enable-crl-checks") + 1; - while (!mPatternsToDo.empty()) { - const QByteArray pat = mPatternsToDo.front().toUtf8().trimmed(); - const unsigned int patLength = pat.length(); - if (patLength >= commandLineLength) { - break; - } - mPatternsToDo.pop_front(); - if (pat.isEmpty()) { - continue; - } - arguments << QLatin1String(pat); - commandLineLength -= patLength + 1; - } - - mProcess->setArguments(arguments); - - connect(mProcess, SIGNAL(finished(int,QProcess::ExitStatus)), - SLOT(slotProcessExited(int,QProcess::ExitStatus))); - connect(mProcess, &QProcess::readyReadStandardOutput, this, [this]() { - qCDebug(QGPGME_LOG) << "stdout:" << mProcess->readAllStandardOutput(); - }); - connect(mProcess, &QProcess::readyReadStandardError, this, [this]() { - qCDebug(QGPGME_LOG) << "stderr:" << mProcess->readAllStandardError(); - }); - - mProcess->start(); - if (!mProcess->waitForStarted()) { - mError = GpgME::Error::fromCode(GPG_ERR_ENOENT, GPG_ERR_SOURCE_GPGSM); // what else? - deleteLater(); - return mError; - } else { - return GpgME::Error(); - } -} - -void QGpgMERefreshSMIMEKeysJob::slotCancel() -{ - if (mProcess) { - mProcess->kill(); - } - mProcess = nullptr; - mError = GpgME::Error::fromCode(GPG_ERR_CANCELED, GPG_ERR_SOURCE_GPGSM); -} - -void QGpgMERefreshSMIMEKeysJob::slotStatus(QProcess *proc, const QString &type, const QStringList &args) -{ - if (proc != mProcess) { - return; - } - QStringList::const_iterator it = args.begin(); - bool ok = false; - - if (type == QLatin1String("ERROR")) { - - if (args.size() < 2) { - qCDebug(QGPGME_LOG) << "not recognising ERROR with < 2 args!"; - return; - } - const int source = (*++it).toInt(&ok); - if (!ok) { - qCDebug(QGPGME_LOG) << "expected number for first ERROR arg, got something else"; - return; - } - ok = false; - const int code = (*++it).toInt(&ok); - if (!ok) { - qCDebug(QGPGME_LOG) << "expected number for second ERROR arg, got something else"; - return; - } - mError = GpgME::Error::fromCode(code, source); - - } else if (type == QLatin1String("PROGRESS")) { - - if (args.size() < 4) { - qCDebug(QGPGME_LOG) << "not recognising PROGRESS with < 4 args!"; - return; - } - const QString what = *++it; - ok = false; - const int type = (*++it).toInt(&ok); - if (!ok) { - qCDebug(QGPGME_LOG) << "expected number for \"type\", got something else"; - return; - } - ok = false; - const int cur = (*++it).toInt(&ok); - if (!ok) { - qCDebug(QGPGME_LOG) << "expected number for \"cur\", got something else"; - return; - } - ok = false; - const int total = (*++it).toInt(&ok); - if (!ok) { - qCDebug(QGPGME_LOG) << "expected number for \"total\", got something else"; - return; - } - Q_EMIT jobProgress(cur, total); - Q_EMIT rawProgress(what, type, cur, total); - QT_WARNING_PUSH - QT_WARNING_DISABLE_DEPRECATED - Q_EMIT progress(what, cur, total); - QT_WARNING_POP - } -} - -void QGpgMERefreshSMIMEKeysJob::slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus) -{ - if (!mError && !mPatternsToDo.empty()) { - if (const GpgME::Error err = startAProcess()) { - mError = err; - } else { - return; - } - } - - Q_EMIT done(); - if (!mError && - (exitStatus != QProcess::NormalExit || exitCode != 0)) { - mError = GpgME::Error::fromCode(GPG_ERR_GENERAL, GPG_ERR_SOURCE_GPGSM); - } - Q_EMIT result(mError); - deleteLater(); -} -#include "qgpgmerefreshsmimekeysjob.moc" diff --git a/lang/qt/src/qgpgmerefreshsmimekeysjob.h b/lang/qt/src/qgpgmerefreshsmimekeysjob.h deleted file mode 100644 index f2324581..00000000 --- a/lang/qt/src/qgpgmerefreshsmimekeysjob.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - qgpgmerefreshsmimekeysjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEREFRESHSMIMEKEYSJOB_H__ -#define __QGPGME_QGPGMEREFRESHSMIMEKEYSJOB_H__ - -#include "refreshkeysjob.h" - -#include <gpgme++/context.h> - -#include <QStringList> -#include <QProcess> - -namespace QGpgME -{ - -class QGpgMERefreshSMIMEKeysJob : public RefreshKeysJob -{ - Q_OBJECT -public: - QGpgMERefreshSMIMEKeysJob(); - ~QGpgMERefreshSMIMEKeysJob(); - - /* from RefreshKeysJob */ - GpgME::Error start(const QStringList &patterns) override; - - GpgME::Error start(const std::vector<GpgME::Key> &keys) override; - -private Q_SLOTS: - /* from Job */ - void slotCancel() override; - - void slotStatus(QProcess *, const QString &, const QStringList &); - void slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus); - -private: - GpgME::Error startAProcess(); - -private: - QProcess *mProcess; - GpgME::Error mError; - QStringList mPatternsToDo; -}; - -} - -#endif // __QGPGME_QGPGMEREFRESHSMIMEKEYSJOB_H__ diff --git a/lang/qt/src/qgpgmerevokekeyjob.cpp b/lang/qt/src/qgpgmerevokekeyjob.cpp deleted file mode 100644 index bf51144d..00000000 --- a/lang/qt/src/qgpgmerevokekeyjob.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - qgpgmerevokekeyjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmerevokekeyjob.h" - -#include "dataprovider.h" - -#include <gpgme++/context.h> -#include <gpgme++/data.h> -#include <gpgme++/gpgrevokekeyeditinteractor.h> -#include <gpgme++/key.h> - -#include <gpg-error.h> - -#include "qgpgme_debug.h" - -using namespace QGpgME; -using namespace GpgME; - -QGpgMERevokeKeyJob::QGpgMERevokeKeyJob(Context *context) - : mixin_type{context} -{ - lateInitialization(); -} - -QGpgMERevokeKeyJob::~QGpgMERevokeKeyJob() = default; - - -static Error check_arguments(const Key &key, - RevocationReason reason, - const std::vector<std::string> &description) -{ - if (key.isNull()) { - qWarning(QGPGME_LOG) << "Error: Key is null key"; - return Error::fromCode(GPG_ERR_INV_ARG); - } - if (reason < RevocationReason::Unspecified || reason > RevocationReason::NoLongerUsed) { - qWarning(QGPGME_LOG) << "Error: Invalid revocation reason" << static_cast<int>(reason); - return Error::fromCode(GPG_ERR_INV_VALUE); - } - if (std::any_of(std::begin(description), std::end(description), - [](const std::string &line) { - return line.empty() || line.find('\n') != std::string::npos; - })) { - qWarning(QGPGME_LOG) << "Error: Revocation description contains empty lines or lines with endline characters"; - return Error::fromCode(GPG_ERR_INV_VALUE); - } - return {}; -} - -static QGpgMERevokeKeyJob::result_type revoke_key(Context *ctx, const Key &key, - RevocationReason reason, - const std::vector<std::string> &description) -{ - std::unique_ptr<GpgRevokeKeyEditInteractor> interactor{new GpgRevokeKeyEditInteractor}; - interactor->setReason(reason, description); - - QGpgME::QByteArrayDataProvider dp; - Data outData(&dp); - assert(!outData.isNull()); - - ctx->setFlag("extended-edit", "1"); - - const Error err = ctx->edit(key, std::unique_ptr<EditInteractor>(interactor.release()), outData); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(err, log, ae); -} - -Error QGpgMERevokeKeyJob::start(const GpgME::Key &key, - GpgME::RevocationReason reason, - const std::vector<std::string> &description) -{ - Error err = check_arguments(key, reason, description); - if (!err) { - run(std::bind(&revoke_key, std::placeholders::_1, key, reason, description)); - } - return err; -} - -Error QGpgMERevokeKeyJob::exec(const GpgME::Key &key, - GpgME::RevocationReason reason, - const std::vector<std::string> &description) -{ - Error err = check_arguments(key, reason, description); - if (!err) { - const result_type r = revoke_key(context(), key, reason, description); - err = std::get<0>(r); - } - return err; -} - -#include "qgpgmerevokekeyjob.moc" diff --git a/lang/qt/src/qgpgmerevokekeyjob.h b/lang/qt/src/qgpgmerevokekeyjob.h deleted file mode 100644 index 0eba5cb7..00000000 --- a/lang/qt/src/qgpgmerevokekeyjob.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - qgpgmerevokekeyjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEREVOKEKEYJOB_H__ -#define __QGPGME_QGPGMEREVOKEKEYJOB_H__ - -#include "threadedjobmixin.h" -#include "revokekeyjob.h" - -namespace QGpgME -{ - -class QGpgMERevokeKeyJob -#ifdef Q_MOC_RUN - : public RevokeKeyJob -#else - : public _detail::ThreadedJobMixin<RevokeKeyJob> -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMERevokeKeyJob(GpgME::Context *context); - ~QGpgMERevokeKeyJob() override; - - GpgME::Error start(const GpgME::Key &key, - GpgME::RevocationReason reason = GpgME::RevocationReason::Unspecified, - const std::vector<std::string> &description = {}) override; - - GpgME::Error exec(const GpgME::Key &key, - GpgME::RevocationReason reason = GpgME::RevocationReason::Unspecified, - const std::vector<std::string> &description = {}) override; -}; - -} - -#endif // __QGPGME_QGPGMEREVOKEKEYJOB_H__ diff --git a/lang/qt/src/qgpgmesetprimaryuseridjob.cpp b/lang/qt/src/qgpgmesetprimaryuseridjob.cpp deleted file mode 100644 index a7d603d5..00000000 --- a/lang/qt/src/qgpgmesetprimaryuseridjob.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - qgpgmesetprimaryuseridjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmesetprimaryuseridjob.h" - -#include "util.h" - -#include <gpgme++/engineinfo.h> - -using namespace QGpgME; -using namespace GpgME; - -static bool quickSetPrimayUidSupportsUidHash() -{ - return GpgME::engineInfo(GpgME::GpgEngine).engineVersion() >= "2.3.8"; -} - -static QGpgMESetPrimaryUserIDJob::result_type set_primary_userid(Context *ctx, const GpgME::UserID &userId) -{ - auto err = ctx->setPrimaryUid(userId.parent(), quickSetPrimayUidSupportsUidHash() ? userId.uidhash() : userId.id()); - return std::make_tuple(err, QString(), Error()); -} - -QGpgMESetPrimaryUserIDJob::QGpgMESetPrimaryUserIDJob(Context *context) - : mixin_type{context} -{ - lateInitialization(); -} - -QGpgMESetPrimaryUserIDJob::~QGpgMESetPrimaryUserIDJob() = default; - -GpgME::Error QGpgMESetPrimaryUserIDJob::start(const GpgME::UserID &userId) -{ - if (userId.isNull()) { - return Error{make_error(GPG_ERR_INV_ARG)}; - } - run([userId](Context *ctx) { return set_primary_userid(ctx, userId); }); - return {}; -} - -#include "qgpgmesetprimaryuseridjob.moc" diff --git a/lang/qt/src/qgpgmesetprimaryuseridjob.h b/lang/qt/src/qgpgmesetprimaryuseridjob.h deleted file mode 100644 index 4ee967ae..00000000 --- a/lang/qt/src/qgpgmesetprimaryuseridjob.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - qgpgmesetprimaryuseridjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMESETPRIMARYUSERIDJOB_H__ -#define __QGPGME_QGPGMESETPRIMARYUSERIDJOB_H__ - -#include "setprimaryuseridjob.h" -#include "threadedjobmixin.h" - -namespace QGpgME -{ - -class QGpgMESetPrimaryUserIDJob -#ifdef Q_MOC_RUN - : public SetPrimaryUserIDJob -#else - : public _detail::ThreadedJobMixin<SetPrimaryUserIDJob> -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMESetPrimaryUserIDJob(GpgME::Context *context); - ~QGpgMESetPrimaryUserIDJob() override; - - GpgME::Error start(const GpgME::UserID &userId) override; -}; - -} - -#endif // __QGPGME_QGPGMESETPRIMARYUSERIDJOB_H__ diff --git a/lang/qt/src/qgpgmesignarchivejob.cpp b/lang/qt/src/qgpgmesignarchivejob.cpp deleted file mode 100644 index 4d257284..00000000 --- a/lang/qt/src/qgpgmesignarchivejob.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* - qgpgmesignarchivejob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2007,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2022,2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmesignarchivejob.h" - -#include "dataprovider.h" -#include "signarchivejob_p.h" -#include "filelistdataprovider.h" -#include "qgpgme_debug.h" -#include "util.h" - -#include <QFile> - -#include <gpgme++/data.h> - -using namespace QGpgME; -using namespace GpgME; - -namespace -{ - -class QGpgMESignArchiveJobPrivate : public SignArchiveJobPrivate -{ - QGpgMESignArchiveJob *q = nullptr; - -public: - QGpgMESignArchiveJobPrivate(QGpgMESignArchiveJob *qq) - : q{qq} - { - } - - ~QGpgMESignArchiveJobPrivate() override = default; - -private: - GpgME::Error startIt() override; - - void startNow() override - { - q->run(); - } -}; - -} - -QGpgMESignArchiveJob::QGpgMESignArchiveJob(Context *context) - : mixin_type{context} -{ - setJobPrivate(this, std::unique_ptr<QGpgMESignArchiveJobPrivate>{new QGpgMESignArchiveJobPrivate{this}}); - lateInitialization(); - connect(this, &Job::rawProgress, this, [this](const QString &what, int type, int current, int total) { - emitArchiveProgressSignals(this, what, type, current, total); - }); -} - -static QGpgMESignArchiveJob::result_type sign(Context *ctx, - const std::vector<Key> &signers, - const std::vector<QString> &paths, - GpgME::Data &outdata, - const QString &baseDirectory) -{ - QGpgME::FileListDataProvider in{paths}; - Data indata(&in); - if (!baseDirectory.isEmpty()) { - indata.setFileName(baseDirectory.toStdString()); - } - - ctx->clearSigningKeys(); - for (const Key &signer : signers) { - if (!signer.isNull()) { - if (const Error err = ctx->addSigningKey(signer)) { - return std::make_tuple(SigningResult{err}, QString{}, Error{}); - } - } - } - - const auto signingResult = ctx->sign(indata, outdata, GpgME::SignArchive); - - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(signingResult, log, ae); -} - -static QGpgMESignArchiveJob::result_type sign_to_io_device(Context *ctx, - QThread *thread, - const std::vector<Key> &signers, - const std::vector<QString> &paths, - const std::weak_ptr<QIODevice> &output_, - const QString &baseDirectory) -{ - const std::shared_ptr<QIODevice> output = output_.lock(); - const _detail::ToThreadMover ctMover(output, thread); - QGpgME::QIODeviceDataProvider out{output}; - Data outdata(&out); - - return sign(ctx, signers, paths, outdata, baseDirectory); -} - -static QGpgMESignArchiveJob::result_type sign_to_filename(Context *ctx, - const std::vector<Key> &signers, - const std::vector<QString> &paths, - const QString &outputFileName, - const QString &baseDirectory) -{ - PartialFileGuard partFileGuard{outputFileName}; - if (partFileGuard.tempFileName().isEmpty()) { - return std::make_tuple(SigningResult{Error::fromCode(GPG_ERR_EEXIST)}, QString{}, Error{}); - } - - Data outdata; -#ifdef Q_OS_WIN - outdata.setFileName(partFileGuard.tempFileName().toUtf8().constData()); -#else - outdata.setFileName(QFile::encodeName(partFileGuard.tempFileName()).constData()); -#endif - - const auto result = sign(ctx, signers, paths, outdata, baseDirectory); - const auto &signingResult = std::get<0>(result); - if (!signingResult.error().code()) { - // the operation succeeded -> save the result under the requested file name - partFileGuard.commit(); - } - - return result; -} - -GpgME::Error QGpgMESignArchiveJob::start(const std::vector<GpgME::Key> &signers, - const std::vector<QString> &paths, - const std::shared_ptr<QIODevice> &output) -{ - if (!output) { - return Error::fromCode(GPG_ERR_INV_VALUE); - } - - run(std::bind(&sign_to_io_device, - std::placeholders::_1, - std::placeholders::_2, - signers, - paths, - std::placeholders::_3, - baseDirectory()), - output); - return {}; -} - - -GpgME::Error QGpgMESignArchiveJobPrivate::startIt() -{ - if (m_outputFilePath.isEmpty()) { - return Error::fromCode(GPG_ERR_INV_VALUE); - } - - q->run([=](Context *ctx) { - return sign_to_filename(ctx, m_signers, m_inputPaths, m_outputFilePath, m_baseDirectory); - }); - - return {}; -} - -#include "qgpgmesignarchivejob.moc" diff --git a/lang/qt/src/qgpgmesignarchivejob.h b/lang/qt/src/qgpgmesignarchivejob.h deleted file mode 100644 index 5755a91c..00000000 --- a/lang/qt/src/qgpgmesignarchivejob.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - qgpgmesignarchivejob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMESIGNARCHIVEJOB_H__ -#define __QGPGME_QGPGMESIGNARCHIVEJOB_H__ - -#include "signarchivejob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/signingresult.h> - -namespace QGpgME -{ - -class QGpgMESignArchiveJob -#ifdef Q_MOC_RUN - : public SignArchiveJob -#else - : public _detail::ThreadedJobMixin<SignArchiveJob, std::tuple<GpgME::SigningResult, QString, GpgME::Error>> -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMESignArchiveJob(GpgME::Context *context); - ~QGpgMESignArchiveJob() = default; - - GpgME::Error start(const std::vector<GpgME::Key> &signers, - const std::vector<QString> &paths, - const std::shared_ptr<QIODevice> &output) override; -}; - -} - -#endif // __QGPGME_QGPGMESIGNARCHIVEJOB_H__ diff --git a/lang/qt/src/qgpgmesignencryptarchivejob.cpp b/lang/qt/src/qgpgmesignencryptarchivejob.cpp deleted file mode 100644 index c3e23b43..00000000 --- a/lang/qt/src/qgpgmesignencryptarchivejob.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* - qgpgmesignencryptarchivejob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2007,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2022,2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmesignencryptarchivejob.h" - -#include "dataprovider.h" -#include "signencryptarchivejob_p.h" -#include "filelistdataprovider.h" -#include "qgpgme_debug.h" -#include "util.h" - -#include <QFile> - -#include <gpgme++/data.h> - -using namespace QGpgME; -using namespace GpgME; - -namespace -{ - -class QGpgMESignEncryptArchiveJobPrivate : public SignEncryptArchiveJobPrivate -{ - QGpgMESignEncryptArchiveJob *q = nullptr; - -public: - QGpgMESignEncryptArchiveJobPrivate(QGpgMESignEncryptArchiveJob *qq) - : q{qq} - { - } - - ~QGpgMESignEncryptArchiveJobPrivate() override = default; - -private: - GpgME::Error startIt() override; - - void startNow() override - { - q->run(); - } -}; - -} - -QGpgMESignEncryptArchiveJob::QGpgMESignEncryptArchiveJob(Context *context) - : mixin_type{context} -{ - setJobPrivate(this, std::unique_ptr<QGpgMESignEncryptArchiveJobPrivate>{new QGpgMESignEncryptArchiveJobPrivate{this}}); - lateInitialization(); - connect(this, &Job::rawProgress, this, [this](const QString &what, int type, int current, int total) { - emitArchiveProgressSignals(this, what, type, current, total); - }); -} - -static QGpgMESignEncryptArchiveJob::result_type sign_encrypt(Context *ctx, - const std::vector<GpgME::Key> &signers, - const std::vector<Key> &recipients, - const std::vector<QString> &paths, - GpgME::Data &outdata, - Context::EncryptionFlags encryptionFlags, - const QString &baseDirectory) -{ - QGpgME::FileListDataProvider in{paths}; - Data indata(&in); - if (!baseDirectory.isEmpty()) { - indata.setFileName(baseDirectory.toStdString()); - } - - ctx->clearSigningKeys(); - for (const Key &signer : signers) { - if (!signer.isNull()) { - if (const Error err = ctx->addSigningKey(signer)) { - return std::make_tuple(SigningResult{err}, EncryptionResult{}, QString{}, Error{}); - } - } - } - - encryptionFlags = static_cast<Context::EncryptionFlags>(encryptionFlags | Context::EncryptArchive); - const auto res = ctx->signAndEncrypt(recipients, indata, outdata, encryptionFlags); - const auto &signingResult = res.first; - const auto &encryptionResult = res.second; - - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(signingResult, encryptionResult, log, ae); -} - -static QGpgMESignEncryptArchiveJob::result_type sign_encrypt_to_io_device(Context *ctx, - QThread *thread, - const std::vector<GpgME::Key> &signers, - const std::vector<Key> &recipients, - const std::vector<QString> &paths, - const std::weak_ptr<QIODevice> &cipherText_, - Context::EncryptionFlags encryptionFlags, - const QString &baseDirectory) -{ - const std::shared_ptr<QIODevice> cipherText = cipherText_.lock(); - const _detail::ToThreadMover ctMover(cipherText, thread); - QGpgME::QIODeviceDataProvider out{cipherText}; - Data outdata(&out); - - return sign_encrypt(ctx, signers, recipients, paths, outdata, encryptionFlags, baseDirectory); -} - -static QGpgMESignEncryptArchiveJob::result_type sign_encrypt_to_filename(Context *ctx, - const std::vector<GpgME::Key> &signers, - const std::vector<Key> &recipients, - const std::vector<QString> &paths, - const QString &outputFileName, - Context::EncryptionFlags encryptionFlags, - const QString &baseDirectory) -{ - PartialFileGuard partFileGuard{outputFileName}; - if (partFileGuard.tempFileName().isEmpty()) { - return std::make_tuple(SigningResult{Error::fromCode(GPG_ERR_EEXIST)}, - EncryptionResult{Error::fromCode(GPG_ERR_EEXIST)}, - QString{}, - Error{}); - } - - Data outdata; -#ifdef Q_OS_WIN - outdata.setFileName(partFileGuard.tempFileName().toUtf8().constData()); -#else - outdata.setFileName(QFile::encodeName(partFileGuard.tempFileName()).constData()); -#endif - - const auto result = sign_encrypt(ctx, signers, recipients, paths, outdata, encryptionFlags, baseDirectory); - const auto &signingResult = std::get<0>(result); - const auto &encryptionResult = std::get<1>(result); - if (!signingResult.error().code() && !encryptionResult.error().code()) { - // the operation succeeded -> save the result under the requested file name - partFileGuard.commit(); - } - - return result; -} - -GpgME::Error QGpgMESignEncryptArchiveJob::start(const std::vector<GpgME::Key> &signers, - const std::vector<GpgME::Key> &recipients, - const std::vector<QString> &paths, - const std::shared_ptr<QIODevice> &cipherText, - const GpgME::Context::EncryptionFlags encryptionFlags) -{ - if (!cipherText) { - return Error::fromCode(GPG_ERR_INV_VALUE); - } - - run(std::bind(&sign_encrypt_to_io_device, - std::placeholders::_1, - std::placeholders::_2, - signers, - recipients, - paths, - std::placeholders::_3, - encryptionFlags, - baseDirectory()), - cipherText); - return {}; -} - -GpgME::Error QGpgMESignEncryptArchiveJobPrivate::startIt() -{ - if (m_outputFilePath.isEmpty()) { - return Error::fromCode(GPG_ERR_INV_VALUE); - } - - q->run([=](Context *ctx) { - return sign_encrypt_to_filename(ctx, m_signers, m_recipients, m_inputPaths, m_outputFilePath, m_encryptionFlags, m_baseDirectory); - }); - - return {}; -} - -#include "qgpgmesignencryptarchivejob.moc" diff --git a/lang/qt/src/qgpgmesignencryptarchivejob.h b/lang/qt/src/qgpgmesignencryptarchivejob.h deleted file mode 100644 index 2675b28a..00000000 --- a/lang/qt/src/qgpgmesignencryptarchivejob.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - qgpgmesignencryptarchivejob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMESIGNENCRYPTARCHIVEJOB_H__ -#define __QGPGME_QGPGMESIGNENCRYPTARCHIVEJOB_H__ - -#include "signencryptarchivejob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/encryptionresult.h> -#include <gpgme++/signingresult.h> - -namespace QGpgME -{ - -class QGpgMESignEncryptArchiveJob -#ifdef Q_MOC_RUN - : public SignEncryptArchiveJob -#else - : public _detail::ThreadedJobMixin<SignEncryptArchiveJob, std::tuple<GpgME::SigningResult, GpgME::EncryptionResult, QString, GpgME::Error>> -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMESignEncryptArchiveJob(GpgME::Context *context); - ~QGpgMESignEncryptArchiveJob() = default; - - GpgME::Error start(const std::vector<GpgME::Key> &signers, - const std::vector<GpgME::Key> &recipients, - const std::vector<QString> &paths, - const std::shared_ptr<QIODevice> &cipherText, - const GpgME::Context::EncryptionFlags flags) override; -}; - -} - -#endif // __QGPGME_QGPGMESIGNENCRYPTARCHIVEJOB_H__ diff --git a/lang/qt/src/qgpgmesignencryptjob.cpp b/lang/qt/src/qgpgmesignencryptjob.cpp deleted file mode 100644 index 8634d91d..00000000 --- a/lang/qt/src/qgpgmesignencryptjob.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* - qgpgmesignencryptjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004, 2007 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2022,2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmesignencryptjob.h" - -#include "dataprovider.h" -#include "signencryptjob_p.h" -#include "util.h" - -#include <gpgme++/context.h> -#include <gpgme++/data.h> -#include <gpgme++/exception.h> -#include <gpgme++/key.h> - -#include <QBuffer> -#include <QFileInfo> - -#include <cassert> - -using namespace QGpgME; -using namespace GpgME; - -namespace -{ - -class QGpgMESignEncryptJobPrivate : public SignEncryptJobPrivate -{ - QGpgMESignEncryptJob *q = nullptr; - -public: - QGpgMESignEncryptJobPrivate(QGpgMESignEncryptJob *qq) - : q{qq} - { - } - - ~QGpgMESignEncryptJobPrivate() override = default; - -private: - GpgME::Error startIt() override; - - void startNow() override - { - q->run(); - } -}; - -} - -QGpgMESignEncryptJob::QGpgMESignEncryptJob(Context *context) - : mixin_type(context), - mOutputIsBase64Encoded(false) -{ - setJobPrivate(this, std::unique_ptr<QGpgMESignEncryptJobPrivate>{new QGpgMESignEncryptJobPrivate{this}}); - lateInitialization(); -} - -QGpgMESignEncryptJob::~QGpgMESignEncryptJob() {} - -void QGpgMESignEncryptJob::setOutputIsBase64Encoded(bool on) -{ - mOutputIsBase64Encoded = on; -} - -static QGpgMESignEncryptJob::result_type sign_encrypt(Context *ctx, QThread *thread, const std::vector<Key> &signers, - const std::vector<Key> &recipients, const std::weak_ptr<QIODevice> &plainText_, - const std::weak_ptr<QIODevice> &cipherText_, const Context::EncryptionFlags eflags, bool outputIsBsse64Encoded, const QString &fileName) -{ - const std::shared_ptr<QIODevice> &plainText = plainText_.lock(); - const std::shared_ptr<QIODevice> &cipherText = cipherText_.lock(); - - const _detail::ToThreadMover ctMover(cipherText, thread); - const _detail::ToThreadMover ptMover(plainText, thread); - - QGpgME::QIODeviceDataProvider in(plainText); - Data indata(&in); - if (!plainText->isSequential()) { - indata.setSizeHint(plainText->size()); - } - - const auto pureFileName = QFileInfo{fileName}.fileName().toStdString(); - if (!pureFileName.empty()) { - indata.setFileName(pureFileName.c_str()); - } - - ctx->clearSigningKeys(); - for (const Key &signer : signers) { - if (!signer.isNull()) { - if (const Error err = ctx->addSigningKey(signer)) { - return std::make_tuple(SigningResult(err), EncryptionResult(), QByteArray(), QString(), Error()); - } - } - } - - if (!cipherText) { - QGpgME::QByteArrayDataProvider out; - Data outdata(&out); - - if (outputIsBsse64Encoded) { - outdata.setEncoding(Data::Base64Encoding); - } - - const std::pair<SigningResult, EncryptionResult> res = ctx->signAndEncrypt(recipients, indata, outdata, eflags); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(res.first, res.second, out.data(), log, ae); - } else { - QGpgME::QIODeviceDataProvider out(cipherText); - Data outdata(&out); - - if (outputIsBsse64Encoded) { - outdata.setEncoding(Data::Base64Encoding); - } - - const std::pair<SigningResult, EncryptionResult> res = ctx->signAndEncrypt(recipients, indata, outdata, eflags); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(res.first, res.second, QByteArray(), log, ae); - } - -} - -static QGpgMESignEncryptJob::result_type sign_encrypt_qba(Context *ctx, const std::vector<Key> &signers, - const std::vector<Key> &recipients, const QByteArray &plainText, const Context::EncryptionFlags eflags, bool outputIsBsse64Encoded, const QString &fileName) -{ - const std::shared_ptr<QBuffer> buffer(new QBuffer); - buffer->setData(plainText); - if (!buffer->open(QIODevice::ReadOnly)) { - assert(!"This should never happen: QBuffer::open() failed"); - } - return sign_encrypt(ctx, nullptr, signers, recipients, buffer, std::shared_ptr<QIODevice>(), eflags, outputIsBsse64Encoded, fileName); -} - -static QGpgMESignEncryptJob::result_type sign_encrypt_to_filename(Context *ctx, - const std::vector<Key> &signers, - const std::vector<Key> &recipients, - const QString &inputFilePath, - const QString &outputFilePath, - Context::EncryptionFlags flags) -{ - Data indata; -#ifdef Q_OS_WIN - indata.setFileName(inputFilePath.toUtf8().constData()); -#else - indata.setFileName(QFile::encodeName(inputFilePath).constData()); -#endif - - PartialFileGuard partFileGuard{outputFilePath}; - if (partFileGuard.tempFileName().isEmpty()) { - return std::make_tuple(SigningResult{Error::fromCode(GPG_ERR_EEXIST)}, - EncryptionResult{Error::fromCode(GPG_ERR_EEXIST)}, - QByteArray{}, - QString{}, - Error{}); - } - - Data outdata; -#ifdef Q_OS_WIN - outdata.setFileName(partFileGuard.tempFileName().toUtf8().constData()); -#else - outdata.setFileName(QFile::encodeName(partFileGuard.tempFileName()).constData()); -#endif - - ctx->clearSigningKeys(); - for (const Key &signer : signers) { - if (!signer.isNull()) { - if (const Error err = ctx->addSigningKey(signer)) { - return std::make_tuple(SigningResult{err}, EncryptionResult{}, QByteArray{}, QString{}, Error{}); - } - } - } - - flags = static_cast<Context::EncryptionFlags>(flags | Context::EncryptFile); - const auto results = ctx->signAndEncrypt(recipients, indata, outdata, flags); - const auto &signingResult = results.first; - const auto &encryptionResult = results.second; - - if (!signingResult.error().code() && !encryptionResult.error().code()) { - // the operation succeeded -> save the result under the requested file name - partFileGuard.commit(); - } - - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(signingResult, encryptionResult, QByteArray{}, log, ae); -} - -Error QGpgMESignEncryptJob::start(const std::vector<Key> &signers, const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust) -{ - run(std::bind(&sign_encrypt_qba, std::placeholders::_1, signers, recipients, plainText, alwaysTrust ? Context::AlwaysTrust : Context::None, mOutputIsBase64Encoded, fileName())); - return Error(); -} - -void QGpgMESignEncryptJob::start(const std::vector<Key> &signers, const std::vector<Key> &recipients, - const std::shared_ptr<QIODevice> &plainText, const std::shared_ptr<QIODevice> &cipherText, const Context::EncryptionFlags eflags) -{ - run(std::bind(&sign_encrypt, std::placeholders::_1, std::placeholders::_2, signers, recipients, std::placeholders::_3, std::placeholders::_4, eflags, mOutputIsBase64Encoded, fileName()), plainText, cipherText); -} - -void QGpgMESignEncryptJob::start(const std::vector<Key> &signers, const std::vector<Key> &recipients, const std::shared_ptr<QIODevice> &plainText, const std::shared_ptr<QIODevice> &cipherText, bool alwaysTrust) -{ - return start(signers, recipients, plainText, cipherText, alwaysTrust ? Context::AlwaysTrust : Context::None); -} - -std::pair<SigningResult, EncryptionResult> QGpgMESignEncryptJob::exec(const std::vector<Key> &signers, const std::vector<Key> &recipients, const QByteArray &plainText, const Context::EncryptionFlags eflags, QByteArray &cipherText) -{ - const result_type r = sign_encrypt_qba(context(), signers, recipients, plainText, eflags, mOutputIsBase64Encoded, fileName()); - cipherText = std::get<2>(r); - return std::make_pair(std::get<0>(r), std::get<1>(r)); -} - -std::pair<SigningResult, EncryptionResult> QGpgMESignEncryptJob::exec(const std::vector<Key> &signers, const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust, QByteArray &cipherText) -{ - return exec(signers, recipients, plainText, alwaysTrust ? Context::AlwaysTrust : Context::None, cipherText); -} - -GpgME::Error QGpgMESignEncryptJobPrivate::startIt() -{ - if (m_inputFilePath.isEmpty() || m_outputFilePath.isEmpty()) { - return Error::fromCode(GPG_ERR_INV_VALUE); - } - - q->run([=](Context *ctx) { - return sign_encrypt_to_filename(ctx, m_signers, m_recipients, m_inputFilePath, m_outputFilePath, m_encryptionFlags); - }); - - return {}; -} - -#include "qgpgmesignencryptjob.moc" diff --git a/lang/qt/src/qgpgmesignencryptjob.h b/lang/qt/src/qgpgmesignencryptjob.h deleted file mode 100644 index a0014d2b..00000000 --- a/lang/qt/src/qgpgmesignencryptjob.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - qgpgmesignencryptjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2007,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMESIGNENCRYPTJOB_H__ -#define __QGPGME_QGPGMESIGNENCRYPTJOB_H__ - -#include "signencryptjob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/signingresult.h> -#include <gpgme++/encryptionresult.h> -#include <gpgme++/key.h> - -#include <utility> - -namespace QGpgME -{ - -class QGpgMESignEncryptJob -#ifdef Q_MOC_RUN - : public SignEncryptJob -#else - : public _detail::ThreadedJobMixin<SignEncryptJob, std::tuple<GpgME::SigningResult, GpgME::EncryptionResult, QByteArray, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMESignEncryptJob(GpgME::Context *context); - ~QGpgMESignEncryptJob(); - - /* from SignEncryptJob */ - GpgME::Error start(const std::vector<GpgME::Key> &signers, - const std::vector<GpgME::Key> &recipients, - const QByteArray &plainText, bool alwaysTrust) override; - - /* from SignEncryptJob */ - void start(const std::vector<GpgME::Key> &signers, - const std::vector<GpgME::Key> &recipients, - const std::shared_ptr<QIODevice> &plainText, - const std::shared_ptr<QIODevice> &cipherText, - bool alwaysTrust) override; - - void start(const std::vector<GpgME::Key> &signers, - const std::vector<GpgME::Key> &recipients, - const std::shared_ptr<QIODevice> &plainText, - const std::shared_ptr<QIODevice> &cipherText, - const GpgME::Context::EncryptionFlags flags) override; - - std::pair<GpgME::SigningResult, GpgME::EncryptionResult> - exec(const std::vector<GpgME::Key> &signers, - const std::vector<GpgME::Key> &recipients, - const QByteArray &plainText, bool alwaysTrust, - QByteArray &cipherText) override; - - std::pair<GpgME::SigningResult, GpgME::EncryptionResult> - exec(const std::vector<GpgME::Key> &signers, - const std::vector<GpgME::Key> &recipients, - const QByteArray &plainText, const GpgME::Context::EncryptionFlags flags, - QByteArray &cipherText) override; - - /* from SignEncryptJob */ - void setOutputIsBase64Encoded(bool on) override; - -private: - bool mOutputIsBase64Encoded; -}; - -} - -#endif // __QGPGME_QGPGMESIGNENCRYPTJOB_H__ diff --git a/lang/qt/src/qgpgmesignjob.cpp b/lang/qt/src/qgpgmesignjob.cpp deleted file mode 100644 index 79077f4a..00000000 --- a/lang/qt/src/qgpgmesignjob.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/* - qgpgmesignjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2007,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmesignjob.h" - -#include "dataprovider.h" -#include "signjob_p.h" -#include "util.h" - -#include <gpgme++/context.h> -#include <gpgme++/data.h> -#include <gpgme++/signingresult.h> - -#include <QBuffer> -#include <QFile> - -#include <cassert> - -using namespace QGpgME; -using namespace GpgME; - -namespace -{ - -class QGpgMESignJobPrivate : public SignJobPrivate -{ - QGpgMESignJob *q = nullptr; - -public: - QGpgMESignJobPrivate(QGpgMESignJob *qq) - : q{qq} - { - } - - ~QGpgMESignJobPrivate() override = default; - -private: - GpgME::Error startIt() override; - - void startNow() override - { - q->run(); - } -}; - -} - -QGpgMESignJob::QGpgMESignJob(Context *context) - : mixin_type(context), - mOutputIsBase64Encoded(false) -{ - setJobPrivate(this, std::unique_ptr<QGpgMESignJobPrivate>{new QGpgMESignJobPrivate{this}}); - lateInitialization(); -} - -QGpgMESignJob::~QGpgMESignJob() {} - -void QGpgMESignJob::setOutputIsBase64Encoded(bool on) -{ - mOutputIsBase64Encoded = on; -} - -static QGpgMESignJob::result_type sign(Context *ctx, QThread *thread, - const std::vector<Key> &signers, - const std::weak_ptr<QIODevice> &plainText_, - const std::weak_ptr<QIODevice> &signature_, - SignatureMode mode, - bool outputIsBsse64Encoded) -{ - - const std::shared_ptr<QIODevice> plainText = plainText_.lock(); - const std::shared_ptr<QIODevice> signature = signature_.lock(); - - const _detail::ToThreadMover ptMover(plainText, thread); - const _detail::ToThreadMover sgMover(signature, thread); - - QGpgME::QIODeviceDataProvider in(plainText); - Data indata(&in); - if (!plainText->isSequential()) { - indata.setSizeHint(plainText->size()); - } - - ctx->clearSigningKeys(); - for (const Key &signer : signers) { - if (!signer.isNull()) { - if (const Error err = ctx->addSigningKey(signer)) { - return std::make_tuple(SigningResult(err), QByteArray(), QString(), Error()); - } - } - } - - if (!signature) { - QGpgME::QByteArrayDataProvider out; - Data outdata(&out); - - if (outputIsBsse64Encoded) { - outdata.setEncoding(Data::Base64Encoding); - } - - const SigningResult res = ctx->sign(indata, outdata, mode); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(res, out.data(), log, ae); - } else { - QGpgME::QIODeviceDataProvider out(signature); - Data outdata(&out); - - if (outputIsBsse64Encoded) { - outdata.setEncoding(Data::Base64Encoding); - } - - const SigningResult res = ctx->sign(indata, outdata, mode); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(res, QByteArray(), log, ae); - } - -} - -static QGpgMESignJob::result_type sign_qba(Context *ctx, - const std::vector<Key> &signers, - const QByteArray &plainText, - SignatureMode mode, - bool outputIsBsse64Encoded) -{ - const std::shared_ptr<QBuffer> buffer(new QBuffer); - buffer->setData(plainText); - if (!buffer->open(QIODevice::ReadOnly)) { - assert(!"This should never happen: QBuffer::open() failed"); - } - return sign(ctx, nullptr, signers, buffer, std::shared_ptr<QIODevice>(), mode, outputIsBsse64Encoded); -} - -static QGpgMESignJob::result_type sign_to_filename(Context *ctx, - const std::vector<Key> &signers, - const QString &inputFilePath, - const QString &outputFilePath, - SignatureMode flags, - bool appendSignature) -{ - Data indata; -#ifdef Q_OS_WIN - indata.setFileName(inputFilePath.toUtf8().constData()); -#else - indata.setFileName(QFile::encodeName(inputFilePath).constData()); -#endif - - PartialFileGuard partFileGuard{outputFilePath}; - if (partFileGuard.tempFileName().isEmpty()) { - return std::make_tuple(SigningResult{Error::fromCode(GPG_ERR_EEXIST)}, - QByteArray{}, - QString{}, - Error{}); - } - - Data outdata; -#ifdef Q_OS_WIN - outdata.setFileName(partFileGuard.tempFileName().toUtf8().constData()); -#else - outdata.setFileName(QFile::encodeName(partFileGuard.tempFileName()).constData()); -#endif - - ctx->clearSigningKeys(); - for (const Key &signer : signers) { - if (!signer.isNull()) { - if (const Error err = ctx->addSigningKey(signer)) { - return std::make_tuple(SigningResult{err}, QByteArray{}, QString{}, Error{}); - } - } - } - - flags = static_cast<SignatureMode>(flags | SignFile); - const auto signingResult = ctx->sign(indata, outdata, flags); - - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - - if (!signingResult.error().code()) { - // the operation succeeded - const bool appendSignatureToExistingFile = appendSignature && (flags & Detached) && QFile::exists(outputFilePath); - if (appendSignatureToExistingFile) { - // append the result to the existing file - QFile newSignatureFile{partFileGuard.tempFileName()}; - if (!newSignatureFile.open(QIODevice::ReadOnly)) { - qCDebug(QGPGME_LOG) << "Failed to open detached signature file" << newSignatureFile.fileName() << "(" << newSignatureFile.errorString() << ")"; - return std::make_tuple(SigningResult{Error::fromCode(GPG_ERR_GENERAL)}, QByteArray{}, log, ae); - } - const QByteArray newSigData = newSignatureFile.readAll(); - if (newSigData.isEmpty()) { - qCDebug(QGPGME_LOG) << "Failed to read detached signature from file" << newSignatureFile.fileName() << "(" << newSignatureFile.errorString() << ")"; - return std::make_tuple(SigningResult{Error::fromCode(GPG_ERR_GENERAL)}, QByteArray{}, log, ae); - } - newSignatureFile.close(); - - QFile existingSignatureFile{outputFilePath}; - if (!existingSignatureFile.open(QIODevice::WriteOnly | QIODevice::Append)) { - qCDebug(QGPGME_LOG) << "Failed to open existing detached signature file for appending" << existingSignatureFile.fileName() << "(" << existingSignatureFile.errorString() << ")"; - return std::make_tuple(SigningResult{Error::fromCode(GPG_ERR_GENERAL)}, QByteArray{}, log, ae); - } - const auto bytesWritten = existingSignatureFile.write(newSigData); - if (bytesWritten != newSigData.size()) { - qCDebug(QGPGME_LOG) << "Failed to write new signature to existing detached signature file" << existingSignatureFile.fileName() << "(" << existingSignatureFile.errorString() << ")"; - return std::make_tuple(SigningResult{Error::fromCode(GPG_ERR_GENERAL)}, QByteArray{}, log, ae); - } - } else { - // save the result under the requested file name - partFileGuard.commit(); - } - } - - return std::make_tuple(signingResult, QByteArray{}, log, ae); -} - -Error QGpgMESignJob::start(const std::vector<Key> &signers, const QByteArray &plainText, SignatureMode mode) -{ - run(std::bind(&sign_qba, std::placeholders::_1, signers, plainText, mode, mOutputIsBase64Encoded)); - return Error(); -} - -void QGpgMESignJob::start(const std::vector<Key> &signers, const std::shared_ptr<QIODevice> &plainText, const std::shared_ptr<QIODevice> &signature, SignatureMode mode) -{ - run(std::bind(&sign, std::placeholders::_1, std::placeholders::_2, signers, std::placeholders::_3, std::placeholders::_4, mode, mOutputIsBase64Encoded), plainText, signature); -} - -SigningResult QGpgMESignJob::exec(const std::vector<Key> &signers, const QByteArray &plainText, SignatureMode mode, QByteArray &signature) -{ - const result_type r = sign_qba(context(), signers, plainText, mode, mOutputIsBase64Encoded); - signature = std::get<1>(r); - return std::get<0>(r); -} - -GpgME::Error QGpgMESignJobPrivate::startIt() -{ - if (m_inputFilePath.isEmpty() || m_outputFilePath.isEmpty()) { - return Error::fromCode(GPG_ERR_INV_VALUE); - } - - q->run([=](Context *ctx) { - return sign_to_filename(ctx, m_signers, m_inputFilePath, m_outputFilePath, m_signingFlags, m_appendSignature); - }); - - return {}; -} - -#include "qgpgmesignjob.moc" diff --git a/lang/qt/src/qgpgmesignjob.h b/lang/qt/src/qgpgmesignjob.h deleted file mode 100644 index 27d352d0..00000000 --- a/lang/qt/src/qgpgmesignjob.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - qgpgmesignjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2007,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMESIGNJOB_H__ -#define __QGPGME_QGPGMESIGNJOB_H__ - -#include "signjob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/signingresult.h> -#include <gpgme++/key.h> - -namespace QGpgME -{ - -class QGpgMESignJob -#ifdef Q_MOC_RUN - : public SignJob -#else - : public _detail::ThreadedJobMixin<SignJob, std::tuple<GpgME::SigningResult, QByteArray, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMESignJob(GpgME::Context *context); - ~QGpgMESignJob(); - - /* from SignJob */ - GpgME::Error start(const std::vector<GpgME::Key> &signers, - const QByteArray &plainText, - GpgME::SignatureMode mode) override; - - /* from SignJob */ - void start(const std::vector<GpgME::Key> &signers, - const std::shared_ptr<QIODevice> &plainText, - const std::shared_ptr<QIODevice> &signature, - GpgME::SignatureMode mode) override; - - /* from SignJob */ - GpgME::SigningResult exec(const std::vector<GpgME::Key> &signers, - const QByteArray &plainText, - GpgME::SignatureMode mode, - QByteArray &signature) override; - - /* from SignJob */ - void setOutputIsBase64Encoded(bool on) override; - -private: - bool mOutputIsBase64Encoded; -}; - -} - -#endif // __QGPGME_QGPGMESIGNJOB_H__ diff --git a/lang/qt/src/qgpgmesignkeyjob.cpp b/lang/qt/src/qgpgmesignkeyjob.cpp deleted file mode 100644 index 0fdab165..00000000 --- a/lang/qt/src/qgpgmesignkeyjob.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/* - qgpgmesignkeyjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmesignkeyjob.h" - -#include <QDate> -#include <QString> - -#include "dataprovider.h" - -#include <gpgme++/context.h> -#include <gpgme++/data.h> -#include <gpgme++/gpgsignkeyeditinteractor.h> - -#include "qgpgme_debug.h" - -#include <cassert> - -using namespace QGpgME; -using namespace GpgME; - -namespace -{ -struct TrustSignatureProperties { - TrustSignatureProperties() = default; - // needed for C++11 because until C++14 "aggregate initialization requires - // class type, that has no default member initializers" - TrustSignatureProperties(TrustSignatureTrust trust_, unsigned int depth_, const QString &scope_) - : trust{trust_} - , depth{depth_} - , scope{scope_} - {} - - TrustSignatureTrust trust = TrustSignatureTrust::None; - unsigned int depth = 0; - QString scope; -}; -} - -class QGpgMESignKeyJob::Private -{ -public: - Private() = default; - - std::vector<unsigned int> m_userIDsToSign; - GpgME::Key m_signingKey; - unsigned int m_checkLevel = 0; - bool m_exportable = false; - bool m_nonRevocable = false; - bool m_started = false; - bool m_dupeOk = false; - QString m_remark; - TrustSignatureProperties m_trustSignature; - QDate m_expiration; -}; - -QGpgMESignKeyJob::QGpgMESignKeyJob(Context *context) - : mixin_type(context) - , d{std::unique_ptr<Private>(new Private())} -{ - lateInitialization(); -} - -QGpgMESignKeyJob::~QGpgMESignKeyJob() {} - -static QGpgMESignKeyJob::result_type sign_key(Context *ctx, const Key &key, const std::vector<unsigned int> &uids, - unsigned int checkLevel, const Key &signer, unsigned int opts, - bool dupeOk, const QString &remark, - const TrustSignatureProperties &trustSignature, - const QDate &expirationDate) -{ - QGpgME::QByteArrayDataProvider dp; - Data data(&dp); - - GpgSignKeyEditInteractor *skei(new GpgSignKeyEditInteractor); - skei->setUserIDsToSign(uids); - skei->setCheckLevel(checkLevel); - skei->setSigningOptions(opts); - skei->setKey(key); - - if (dupeOk) { - ctx->setFlag("extended-edit", "1"); - skei->setDupeOk(true); - } - - if (!remark.isEmpty()) { - ctx->addSignatureNotation("[email protected]", remark.toUtf8().constData()); - } - - if (opts & GpgSignKeyEditInteractor::Trust) { - skei->setTrustSignatureTrust(trustSignature.trust); - skei->setTrustSignatureDepth(trustSignature.depth); - skei->setTrustSignatureScope(trustSignature.scope.toUtf8().toStdString()); - } - - if (!signer.isNull()) { - if (const Error err = ctx->addSigningKey(signer)) { - return std::make_tuple(err, QString(), Error()); - } - } - - if (expirationDate.isValid()) { - // on 2106-02-07, the Unix time will reach 0xFFFFFFFF; since gpg uses uint32 internally - // for the expiration date clip it at 2106-02-05 to avoid problems with negative time zones - static const QDate maxAllowedDate{2106, 2, 5}; - const auto clippedExpirationDate = expirationDate <= maxAllowedDate ? expirationDate : maxAllowedDate; - if (clippedExpirationDate != expirationDate) { - qCDebug(QGPGME_LOG) << "Expiration of certification has been changed to" << clippedExpirationDate; - } - // use the "days from now" format to specify the expiration date of the certification; - // this format is the most appropriate regardless of the local timezone - const auto daysFromNow = QDate::currentDate().daysTo(clippedExpirationDate); - if (daysFromNow > 0) { - const auto certExpire = std::to_string(daysFromNow) + "d"; - ctx->setFlag("cert-expire", certExpire.c_str()); - } - } else { - // explicitly set "cert-expire" to "0" (no expiration) to override default-cert-expire set in gpg.conf - ctx->setFlag("cert-expire", "0"); - } - - const Error err = ctx->edit(key, std::unique_ptr<EditInteractor> (skei), data); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(err, log, ae); -} - -Error QGpgMESignKeyJob::start(const Key &key) -{ - unsigned int opts = 0; - if (d->m_nonRevocable) { - opts |= GpgSignKeyEditInteractor::NonRevocable; - } - if (d->m_exportable) { - opts |= GpgSignKeyEditInteractor::Exportable; - } - switch (d->m_trustSignature.trust) { - case TrustSignatureTrust::Partial: - case TrustSignatureTrust::Complete: - opts |= GpgSignKeyEditInteractor::Trust; - break; - default: - opts &= ~GpgSignKeyEditInteractor::Trust; - break; - } - run(std::bind(&sign_key, std::placeholders::_1, key, d->m_userIDsToSign, d->m_checkLevel, d->m_signingKey, - opts, d->m_dupeOk, d->m_remark, d->m_trustSignature, d->m_expiration)); - d->m_started = true; - return Error(); -} - -void QGpgMESignKeyJob::setUserIDsToSign(const std::vector<unsigned int> &idsToSign) -{ - assert(!d->m_started); - d->m_userIDsToSign = idsToSign; -} - -void QGpgMESignKeyJob::setCheckLevel(unsigned int checkLevel) -{ - assert(!d->m_started); - d->m_checkLevel = checkLevel; -} - -void QGpgMESignKeyJob::setExportable(bool exportable) -{ - assert(!d->m_started); - d->m_exportable = exportable; -} - -void QGpgMESignKeyJob::setSigningKey(const Key &key) -{ - assert(!d->m_started); - d->m_signingKey = key; -} - -void QGpgMESignKeyJob::setNonRevocable(bool nonRevocable) -{ - assert(!d->m_started); - d->m_nonRevocable = nonRevocable; -} - -void QGpgMESignKeyJob::setRemark(const QString &remark) -{ - assert(!d->m_started); - d->m_remark = remark; -} - -void QGpgMESignKeyJob::setDupeOk(bool value) -{ - assert(!d->m_started); - d->m_dupeOk = value; -} - -void QGpgMESignKeyJob::setTrustSignature(GpgME::TrustSignatureTrust trust, unsigned short depth, const QString &scope) -{ - assert(!d->m_started); - assert(depth <= 255); - d->m_trustSignature = {trust, depth, scope}; -} - -void QGpgMESignKeyJob::setExpirationDate(const QDate &expiration) -{ - assert(!d->m_started); - d->m_expiration = expiration; -} - -#include "qgpgmesignkeyjob.moc" diff --git a/lang/qt/src/qgpgmesignkeyjob.h b/lang/qt/src/qgpgmesignkeyjob.h deleted file mode 100644 index 0316beb6..00000000 --- a/lang/qt/src/qgpgmesignkeyjob.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - qgpgmesignkeyjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMESIGNKEYJOB_H__ -#define __QGPGME_QGPGMESIGNKEYJOB_H__ - -#include "signkeyjob.h" - -#include "threadedjobmixin.h" - -#include <memory> - -namespace QGpgME -{ - -class QGpgMESignKeyJob -#ifdef Q_MOC_RUN - : public SignKeyJob -#else - : public _detail::ThreadedJobMixin<SignKeyJob> -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMESignKeyJob(GpgME::Context *context); - ~QGpgMESignKeyJob(); - - /* from SignKeyJob */ - GpgME::Error start(const GpgME::Key &key) override; - - /* from SignKeyJob */ - void setUserIDsToSign(const std::vector<unsigned int> &idsToSign) override; - - /* from SignKeyJob */ - void setCheckLevel(unsigned int checkLevel) override; - - /* from SignKeyJob */ - void setExportable(bool exportable) override; - - /* from SignKeyJob */ - void setSigningKey(const GpgME::Key &key) override; - - /* from SignKeyJob */ - void setNonRevocable(bool nonRevocable) override; - - /* from SignKeyJob */ - void setRemark(const QString &remark) override; - - /* from SignKeyJob */ - void setDupeOk(bool value) override; - - /* from SignKeyJob */ - void setTrustSignature(GpgME::TrustSignatureTrust trust, unsigned short depth, const QString &scope) override; - - void setExpirationDate(const QDate &expiration) override; - -private: - class Private; - std::unique_ptr<Private> d; -}; -} - -#endif // __QGPGME_QGPGMESIGNKEYJOB_H__ diff --git a/lang/qt/src/qgpgmetofupolicyjob.cpp b/lang/qt/src/qgpgmetofupolicyjob.cpp deleted file mode 100644 index f5d43fa1..00000000 --- a/lang/qt/src/qgpgmetofupolicyjob.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* qgpgmetofupolicyjob.cpp - - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmetofupolicyjob.h" - -#include <gpgme++/context.h> -#include <gpgme++/key.h> -#include <gpgme++/tofuinfo.h> - - -using namespace QGpgME; -using namespace GpgME; - -QGpgMETofuPolicyJob::QGpgMETofuPolicyJob(Context *context) - : mixin_type(context) -{ - lateInitialization(); -} - -QGpgMETofuPolicyJob::~QGpgMETofuPolicyJob() {} - -static QGpgMETofuPolicyJob::result_type policy_worker(Context *ctx, const Key &key, TofuInfo::Policy policy) -{ - return std::make_tuple (ctx->setTofuPolicy(key, policy), - QString(), Error()); -} - -void QGpgMETofuPolicyJob::start(const Key &key, TofuInfo::Policy policy) -{ - run(std::bind(&policy_worker, std::placeholders::_1, key, policy)); -} - -Error QGpgMETofuPolicyJob::exec(const Key &key, TofuInfo::Policy policy) -{ - return std::get<0>(policy_worker(context(), key, policy)); -} - -#include "qgpgmetofupolicyjob.moc" diff --git a/lang/qt/src/qgpgmetofupolicyjob.h b/lang/qt/src/qgpgmetofupolicyjob.h deleted file mode 100644 index ad09045d..00000000 --- a/lang/qt/src/qgpgmetofupolicyjob.h +++ /dev/null @@ -1,66 +0,0 @@ -/* qgpgmetofupolicyjob.h - - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifndef QGPGME_QGPGMETOFUPOLICYJOB_H -#define QGPGME_QGPGMETOFUPOLICYJOB_H - -#include "tofupolicyjob.h" - -#include "threadedjobmixin.h" -namespace GpgME -{ - class Key; -} // namespace GpgME - -namespace QGpgME { - -class QGpgMETofuPolicyJob -#ifdef Q_MOC_RUN - : public TofuPolicyJob -#else - : public _detail::ThreadedJobMixin<TofuPolicyJob, std::tuple<GpgME::Error, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMETofuPolicyJob(GpgME::Context *context); - ~QGpgMETofuPolicyJob(); - - void start(const GpgME::Key &key, GpgME::TofuInfo::Policy policy) override; - GpgME::Error exec(const GpgME::Key &key, GpgME::TofuInfo::Policy policy) override; -}; - -} - -#endif diff --git a/lang/qt/src/qgpgmeverifydetachedjob.cpp b/lang/qt/src/qgpgmeverifydetachedjob.cpp deleted file mode 100644 index 91d89f96..00000000 --- a/lang/qt/src/qgpgmeverifydetachedjob.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* - qgpgmeverifydetachedjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2007,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmeverifydetachedjob.h" - -#include "dataprovider.h" -#include "util.h" -#include "verifydetachedjob_p.h" - -#include <QFile> - -#include <gpgme++/context.h> -#include <gpgme++/data.h> -#include <gpgme++/verificationresult.h> - -#include <cassert> - - -using namespace QGpgME; -using namespace GpgME; - -namespace -{ - -class QGpgMEVerifyDetachedJobPrivate : public VerifyDetachedJobPrivate -{ - QGpgMEVerifyDetachedJob *q = nullptr; - -public: - QGpgMEVerifyDetachedJobPrivate(QGpgMEVerifyDetachedJob *qq) - : q{qq} - { - } - - ~QGpgMEVerifyDetachedJobPrivate() override = default; - -private: - GpgME::Error startIt() override; - - void startNow() override - { - q->run(); - } -}; - -} - -QGpgMEVerifyDetachedJob::QGpgMEVerifyDetachedJob(Context *context) - : mixin_type(context) -{ - setJobPrivate(this, std::unique_ptr<QGpgMEVerifyDetachedJobPrivate>{new QGpgMEVerifyDetachedJobPrivate{this}}); - lateInitialization(); -} - -QGpgMEVerifyDetachedJob::~QGpgMEVerifyDetachedJob() {} - -static QGpgMEVerifyDetachedJob::result_type verify_detached(Context *ctx, QThread *thread, const std::weak_ptr<QIODevice> &signature_, const std::weak_ptr<QIODevice> &signedData_) -{ - const std::shared_ptr<QIODevice> signature = signature_.lock(); - const std::shared_ptr<QIODevice> signedData = signedData_.lock(); - - const _detail::ToThreadMover sgMover(signature, thread); - const _detail::ToThreadMover sdMover(signedData, thread); - - QGpgME::QIODeviceDataProvider sigDP(signature); - Data sig(&sigDP); - - QGpgME::QIODeviceDataProvider dataDP(signedData); - Data data(&dataDP); - if (!signedData->isSequential()) { - data.setSizeHint(signedData->size()); - } - - const VerificationResult res = ctx->verifyDetachedSignature(sig, data); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - - return std::make_tuple(res, log, ae); -} - -static QGpgMEVerifyDetachedJob::result_type verify_detached_qba(Context *ctx, const QByteArray &signature, const QByteArray &signedData) -{ - QGpgME::QByteArrayDataProvider sigDP(signature); - Data sig(&sigDP); - - QGpgME::QByteArrayDataProvider dataDP(signedData); - Data data(&dataDP); - - const VerificationResult res = ctx->verifyDetachedSignature(sig, data); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - - return std::make_tuple(res, log, ae); - -} - -static QGpgMEVerifyDetachedJob::result_type verify_from_filename(Context *ctx, - const QString &signatureFilePath, - const QString &signedFilePath, - bool processAllSignatures) -{ - Data signatureData; -#ifdef Q_OS_WIN - signatureData.setFileName(signatureFilePath.toUtf8().constData()); -#else - signatureData.setFileName(QFile::encodeName(signatureFilePath).constData()); -#endif - - Data signedData; -#ifdef Q_OS_WIN - signedData.setFileName(signedFilePath.toUtf8().constData()); -#else - signedData.setFileName(QFile::encodeName(signedFilePath).constData()); -#endif - - if (processAllSignatures) { - ctx->setFlag("proc-all-sigs", "1"); - } - const auto verificationResult = ctx->verifyDetachedSignature(signatureData, signedData); - - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(verificationResult, log, ae); -} - -Error QGpgMEVerifyDetachedJob::start(const QByteArray &signature, const QByteArray &signedData) -{ - if (processAllSignatures()) { - context()->setFlag("proc-all-sigs", "1"); - } - run(std::bind(&verify_detached_qba, std::placeholders::_1, signature, signedData)); - return Error(); -} - -void QGpgMEVerifyDetachedJob::start(const std::shared_ptr<QIODevice> &signature, const std::shared_ptr<QIODevice> &signedData) -{ - if (processAllSignatures()) { - context()->setFlag("proc-all-sigs", "1"); - } - run(std::bind(&verify_detached, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), signature, signedData); -} - -GpgME::VerificationResult QGpgME::QGpgMEVerifyDetachedJob::exec(const QByteArray &signature, - const QByteArray &signedData) -{ - if (processAllSignatures()) { - context()->setFlag("proc-all-sigs", "1"); - } - const result_type r = verify_detached_qba(context(), signature, signedData); - return std::get<0>(r); -} - -GpgME::Error QGpgMEVerifyDetachedJobPrivate::startIt() -{ - if (m_signatureFilePath.isEmpty() || m_signedFilePath.isEmpty()) { - return Error::fromCode(GPG_ERR_INV_VALUE); - } - - q->run([=](Context *ctx) { - return verify_from_filename(ctx, m_signatureFilePath, m_signedFilePath, m_processAllSignatures); - }); - - return {}; -} - -#include "qgpgmeverifydetachedjob.moc" diff --git a/lang/qt/src/qgpgmeverifydetachedjob.h b/lang/qt/src/qgpgmeverifydetachedjob.h deleted file mode 100644 index 36350254..00000000 --- a/lang/qt/src/qgpgmeverifydetachedjob.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - qgpgmeverifydetachedjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2007,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEVERIFYDETACHEDJOB_H__ -#define __QGPGME_QGPGMEVERIFYDETACHEDJOB_H__ - -#include "verifydetachedjob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/verificationresult.h> - -namespace QGpgME -{ - -class QGpgMEVerifyDetachedJob -#ifdef Q_MOC_RUN - : public VerifyDetachedJob -#else - : public _detail::ThreadedJobMixin<VerifyDetachedJob, std::tuple<GpgME::VerificationResult, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEVerifyDetachedJob(GpgME::Context *context); - ~QGpgMEVerifyDetachedJob(); - - /* from VerifyDetachedJob */ - GpgME::Error start(const QByteArray &signature, const QByteArray &signedData) override; - - /* from VerifyDetachedJob */ - void start(const std::shared_ptr<QIODevice> &signature, const std::shared_ptr<QIODevice> &signedData) override; - - /* from VerifyDetachedJob */ - GpgME::VerificationResult exec(const QByteArray &signature, - const QByteArray &signedData) override; -}; - -} - -#endif // __QGPGME_QGPGMEVERIFYDETACHEDJOB_H__ diff --git a/lang/qt/src/qgpgmeverifyopaquejob.cpp b/lang/qt/src/qgpgmeverifyopaquejob.cpp deleted file mode 100644 index 0cca9f72..00000000 --- a/lang/qt/src/qgpgmeverifyopaquejob.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* - qgpgmeverifyopaquejob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2007,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmeverifyopaquejob.h" - -#include "dataprovider.h" -#include "util.h" -#include "verifyopaquejob_p.h" - -#include <gpgme++/context.h> -#include <gpgme++/data.h> -#include <gpgme++/verificationresult.h> - -#include <QBuffer> -#include <QFile> - -#include <cassert> - -using namespace QGpgME; -using namespace GpgME; - -namespace -{ - -class QGpgMEVerifyOpaqueJobPrivate : public VerifyOpaqueJobPrivate -{ - QGpgMEVerifyOpaqueJob *q = nullptr; - -public: - QGpgMEVerifyOpaqueJobPrivate(QGpgMEVerifyOpaqueJob *qq) - : q{qq} - { - } - - ~QGpgMEVerifyOpaqueJobPrivate() override = default; - -private: - GpgME::Error startIt() override; - - void startNow() override - { - q->run(); - } -}; - -} - -QGpgMEVerifyOpaqueJob::QGpgMEVerifyOpaqueJob(Context *context) - : mixin_type(context) -{ - setJobPrivate(this, std::unique_ptr<QGpgMEVerifyOpaqueJobPrivate>{new QGpgMEVerifyOpaqueJobPrivate{this}}); - lateInitialization(); -} - -QGpgMEVerifyOpaqueJob::~QGpgMEVerifyOpaqueJob() {} - -static QGpgMEVerifyOpaqueJob::result_type verify_opaque(Context *ctx, QThread *thread, const std::weak_ptr<QIODevice> &signedData_, const std::weak_ptr<QIODevice> &plainText_) -{ - - const std::shared_ptr<QIODevice> plainText = plainText_.lock(); - const std::shared_ptr<QIODevice> signedData = signedData_.lock(); - - const _detail::ToThreadMover ptMover(plainText, thread); - const _detail::ToThreadMover sdMover(signedData, thread); - - QGpgME::QIODeviceDataProvider in(signedData); - Data indata(&in); - if (!signedData->isSequential()) { - indata.setSizeHint(signedData->size()); - } - - if (!plainText) { - QGpgME::QByteArrayDataProvider out; - Data outdata(&out); - - const VerificationResult res = ctx->verifyOpaqueSignature(indata, outdata); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(res, out.data(), log, ae); - } else { - QGpgME::QIODeviceDataProvider out(plainText); - Data outdata(&out); - - const VerificationResult res = ctx->verifyOpaqueSignature(indata, outdata); - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(res, QByteArray(), log, ae); - } - -} - -static QGpgMEVerifyOpaqueJob::result_type verify_opaque_qba(Context *ctx, const QByteArray &signedData) -{ - const std::shared_ptr<QBuffer> buffer(new QBuffer); - buffer->setData(signedData); - if (!buffer->open(QIODevice::ReadOnly)) { - assert(!"This should never happen: QBuffer::open() failed"); - } - return verify_opaque(ctx, nullptr, buffer, std::shared_ptr<QIODevice>()); -} - -static QGpgMEVerifyOpaqueJob::result_type verify_from_filename(Context *ctx, - const QString &inputFilePath, - const QString &outputFilePath, - bool processAllSignatures) -{ - Data indata; -#ifdef Q_OS_WIN - indata.setFileName(inputFilePath.toUtf8().constData()); -#else - indata.setFileName(QFile::encodeName(inputFilePath).constData()); -#endif - - PartialFileGuard partFileGuard{outputFilePath}; - if (partFileGuard.tempFileName().isEmpty()) { - return std::make_tuple(VerificationResult{Error::fromCode(GPG_ERR_EEXIST)}, QByteArray{}, QString{}, Error{}); - } - - Data outdata; -#ifdef Q_OS_WIN - outdata.setFileName(partFileGuard.tempFileName().toUtf8().constData()); -#else - outdata.setFileName(QFile::encodeName(partFileGuard.tempFileName()).constData()); -#endif - - if (processAllSignatures) { - ctx->setFlag("proc-all-sigs", "1"); - } - const auto verificationResult = ctx->verifyOpaqueSignature(indata, outdata); - - if (!verificationResult.error().code()) { - // the operation succeeded -> save the result under the requested file name - partFileGuard.commit(); - } - - Error ae; - const QString log = _detail::audit_log_as_html(ctx, ae); - return std::make_tuple(verificationResult, QByteArray{}, log, ae); -} - -Error QGpgMEVerifyOpaqueJob::start(const QByteArray &signedData) -{ - if (processAllSignatures()) { - context()->setFlag("proc-all-sigs", "1"); - } - run(std::bind(&verify_opaque_qba, std::placeholders::_1, signedData)); - return Error(); -} - -void QGpgMEVerifyOpaqueJob::start(const std::shared_ptr<QIODevice> &signedData, const std::shared_ptr<QIODevice> &plainText) -{ - if (processAllSignatures()) { - context()->setFlag("proc-all-sigs", "1"); - } - run(std::bind(&verify_opaque, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), signedData, plainText); -} - -GpgME::VerificationResult QGpgME::QGpgMEVerifyOpaqueJob::exec(const QByteArray &signedData, QByteArray &plainText) -{ - if (processAllSignatures()) { - context()->setFlag("proc-all-sigs", "1"); - } - const result_type r = verify_opaque_qba(context(), signedData); - plainText = std::get<1>(r); - return std::get<0>(r); -} - -GpgME::Error QGpgMEVerifyOpaqueJobPrivate::startIt() -{ - if (m_inputFilePath.isEmpty() || m_outputFilePath.isEmpty()) { - return Error::fromCode(GPG_ERR_INV_VALUE); - } - - q->run([=](Context *ctx) { - return verify_from_filename(ctx, m_inputFilePath, m_outputFilePath, m_processAllSignatures); - }); - - return {}; -} - -#include "qgpgmeverifyopaquejob.moc" diff --git a/lang/qt/src/qgpgmeverifyopaquejob.h b/lang/qt/src/qgpgmeverifyopaquejob.h deleted file mode 100644 index b46de8f8..00000000 --- a/lang/qt/src/qgpgmeverifyopaquejob.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - qgpgmeverifyopaquejob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004,2007,2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEVERIFYOPAQUEJOB_H__ -#define __QGPGME_QGPGMEVERIFYOPAQUEJOB_H__ - -#include "verifyopaquejob.h" - -#include "threadedjobmixin.h" - -#include <gpgme++/verificationresult.h> - -namespace QGpgME -{ - -class QGpgMEVerifyOpaqueJob -#ifdef Q_MOC_RUN - : public VerifyOpaqueJob -#else - : public _detail::ThreadedJobMixin<VerifyOpaqueJob, std::tuple<GpgME::VerificationResult, QByteArray, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEVerifyOpaqueJob(GpgME::Context *context); - ~QGpgMEVerifyOpaqueJob(); - - /* from VerifyOpaqueJob */ - GpgME::Error start(const QByteArray &signedData) override; - - /* from VerifyOpaqueJob */ - void start(const std::shared_ptr<QIODevice> &signedData, const std::shared_ptr<QIODevice> &plainText) override; - - /* form VerifyOpaqueJob */ - GpgME::VerificationResult exec(const QByteArray &signedData, QByteArray &plainData) override; -}; - -} - -#endif // __QGPGME_QGPGMEVERIFYOPAQUEJOB_H__ diff --git a/lang/qt/src/qgpgmewkdlookupjob.cpp b/lang/qt/src/qgpgmewkdlookupjob.cpp deleted file mode 100644 index 76f5b728..00000000 --- a/lang/qt/src/qgpgmewkdlookupjob.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - qgpgmewkdlookupjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2021 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmewkdlookupjob.h" - -#include "debug.h" -#include "qgpgme_debug.h" - -#include <gpgme++/context.h> -#include <gpgme++/data.h> -#include <gpgme++/defaultassuantransaction.h> - -#include <gpg-error.h> - -using namespace QGpgME; -using namespace GpgME; - -QGpgMEWKDLookupJob::QGpgMEWKDLookupJob(Context *context) - : mixin_type{context} -{ - lateInitialization(); -} - -QGpgMEWKDLookupJob::~QGpgMEWKDLookupJob() = default; - -static GpgME::Error startDirmngr(Context *assuanCtx) -{ - Error err; - - auto spawnCtx = std::unique_ptr<Context>{Context::createForEngine(SpawnEngine, &err)}; - if (err) { - qCDebug(QGPGME_LOG) << "Error: Failed to get context for spawn engine (" << err << ")"; - } - const auto gpgconfProgram = GpgME::dirInfo("gpgconf-name"); - // replace backslashes with forward slashes in homedir to work around bug T6833 - std::string homedir{GpgME::dirInfo("homedir")}; - std::replace(homedir.begin(), homedir.end(), '\\', '/'); - const char *argv[] = { - gpgconfProgram, - "--homedir", - homedir.c_str(), - "--launch", - "dirmngr", - NULL - }; - auto ignoreIO = Data{Data::null}; - if (!err) { - qCDebug(QGPGME_LOG) << "Starting dirmngr ..."; - err = spawnCtx->spawn(gpgconfProgram, argv, - ignoreIO, ignoreIO, ignoreIO, - Context::SpawnDetached); - } - - if (!err) { - // wait for socket to become available - int cnt = 0; - do { - ++cnt; - qCDebug(QGPGME_LOG) << "Waiting for dirmngr to start ..."; - QThread::msleep(250 * cnt); - err = assuanCtx->assuanTransact("GETINFO version"); - } while (err.code() == GPG_ERR_ASS_CONNECT_FAILED && cnt < 5); - } - - return err; -} - -static GpgME::Error setUpDirmngrAssuanConnection(Context *ctx) -{ - Error err; - - const std::string dirmngrSocket = GpgME::dirInfo("dirmngr-socket"); - err = ctx->setEngineFileName(dirmngrSocket.c_str()); - - if (!err) { - err = ctx->setEngineHomeDirectory(""); - } - - if (!err) { - // try do connect to dirmngr - err = ctx->assuanTransact("GETINFO version"); - if (err.code() == GPG_ERR_ASS_CONNECT_FAILED) { - err = startDirmngr(ctx); - } - } - - return err; -} - -static GpgME::Error run_wkd_get(Context *ctx, const std::string &email) -{ - Error err; - - const auto cmd = std::string{"WKD_GET "} + email; - err = ctx->assuanTransact(cmd.c_str()); - if (err.code() == GPG_ERR_NO_NAME || err.code() == GPG_ERR_NO_DATA) { - // ignore those benign errors; GPG_ERR_NO_NAME indicates that the domain - // doesn't exist (on first request); GPG_ERR_NO_DATA indicates that - // no key for email is available via WKD or that the domain doesn't - // support WKD or that the domain doesn't exist (on subsequent requests - // using dirmngr's internal cache) - qCDebug(QGPGME_LOG) << "WKD_GET returned" << err << "; ignoring..."; - err = {}; - } - if (err) { - qCDebug(QGPGME_LOG) << "WKD_GET failed with" << err; - } - - return err; -} - -static QGpgMEWKDLookupJob::result_type lookup_keys(Context *ctx, const QString &email) -{ - WKDLookupResult result; - - Error err = setUpDirmngrAssuanConnection(ctx); - - const auto pattern = email.toUtf8().toStdString(); - if (!err) { - err = run_wkd_get(ctx, pattern); - } - - if (!err) { - const auto transaction = std::unique_ptr<DefaultAssuanTransaction>(dynamic_cast<DefaultAssuanTransaction*>(ctx->takeLastAssuanTransaction().release())); - const auto source = transaction->firstStatusLine("SOURCE"); - const auto rawData = transaction->data(); - if (rawData.size() == 0) { - qCDebug(QGPGME_LOG) << "No key found for" << email; - result = WKDLookupResult{pattern, GpgME::Data::null, {}, {}}; - } else { - qCDebug(QGPGME_LOG) << "Found key for" << email << "at" << source.c_str(); - result = WKDLookupResult{pattern, GpgME::Data{rawData.c_str(), rawData.size()}, source, {}}; - } - } - - return std::make_tuple(err ? WKDLookupResult{pattern, err} : result, QString{}, Error{}); -} - -Error QGpgMEWKDLookupJob::start(const QString &email) -{ - run(std::bind(&lookup_keys, std::placeholders::_1, email)); - return Error(); -} - -WKDLookupResult QGpgMEWKDLookupJob::exec(const QString &email) -{ - const result_type r = lookup_keys(context(), email); - return std::get<0>(r); -} - -#include "qgpgmewkdlookupjob.moc" diff --git a/lang/qt/src/qgpgmewkdlookupjob.h b/lang/qt/src/qgpgmewkdlookupjob.h deleted file mode 100644 index 9a206d25..00000000 --- a/lang/qt/src/qgpgmewkdlookupjob.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - qgpgmewkdlookupjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2021 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEWKDLOOKUPJOB_H__ -#define __QGPGME_QGPGMEWKDLOOKUPJOB_H__ - -#include "threadedjobmixin.h" -#include "wkdlookupjob.h" -#include "wkdlookupresult.h" - -namespace QGpgME -{ -class WKDLookupResult; - -class QGpgMEWKDLookupJob -#ifdef Q_MOC_RUN - : public WKDLookupJob -#else - : public _detail::ThreadedJobMixin<WKDLookupJob, std::tuple<WKDLookupResult, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEWKDLookupJob(GpgME::Context *context); - ~QGpgMEWKDLookupJob(); - - /* from WKDLookupJob */ - GpgME::Error start(const QString &email) override; - - /* from WKDLookupJob */ - WKDLookupResult exec(const QString &email) override; -}; - -} - -#endif // __QGPGME_QGPGMEWKDLOOKUPJOB_H__ diff --git a/lang/qt/src/qgpgmewkdrefreshjob.cpp b/lang/qt/src/qgpgmewkdrefreshjob.cpp deleted file mode 100644 index 264d9f21..00000000 --- a/lang/qt/src/qgpgmewkdrefreshjob.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - qgpgmewkdrefreshjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmewkdrefreshjob.h" - -#include "debug.h" -#include "qgpgme_debug.h" -#include "qgpgmekeylistjob.h" -#include "wkdrefreshjob_p.h" - -#include <gpgme++/context.h> - -#include <memory> - -using namespace QGpgME; -using namespace GpgME; - -namespace -{ - -class QGpgMEWKDRefreshJobPrivate : public WKDRefreshJobPrivate -{ - QGpgMEWKDRefreshJob *q = nullptr; - -public: - QGpgMEWKDRefreshJobPrivate(QGpgMEWKDRefreshJob *qq) - : q{qq} - { - } - - ~QGpgMEWKDRefreshJobPrivate() override = default; - -private: - GpgME::Error startIt() override; - - void startNow() override - { - q->run(); - } -}; - -static QStringList toEmailAddressesOriginatingFromWKD(const std::vector<GpgME::Key> &keys) -{ - const QStringList emails = std::accumulate(keys.begin(), keys.end(), QStringList{}, [](QStringList &emails, const Key &key) { - const auto userIDs = key.userIDs(); - emails = std::accumulate(std::begin(userIDs), std::end(userIDs), emails, [](QStringList &emails, const UserID &userID) { - if (!userID.isRevoked() && !userID.addrSpec().empty() && userID.origin() == Key::OriginWKD) { - emails.push_back(QString::fromStdString(userID.addrSpec())); - } - return emails; - }); - return emails; - }); - return emails; -} - -static QStringList toEmailAddresses(const std::vector<GpgME::UserID> &userIds) -{ - const QStringList emails = std::accumulate( - std::begin(userIds), - std::end(userIds), - QStringList{}, - [](QStringList &emails, const UserID &userId) { - if (!userId.isRevoked() && !userId.addrSpec().empty()) { - emails.push_back(QString::fromStdString(userId.addrSpec())); - } - return emails; - }); - return emails; -} - -} - -QGpgMEWKDRefreshJob::QGpgMEWKDRefreshJob(Context *context) - : mixin_type{context} -{ - setJobPrivate(this, std::unique_ptr<QGpgMEWKDRefreshJobPrivate>{new QGpgMEWKDRefreshJobPrivate{this}}); - lateInitialization(); -} - -QGpgMEWKDRefreshJob::~QGpgMEWKDRefreshJob() = default; - -static QGpgMEWKDRefreshJob::result_type locate_external_keys(Context *ctx, const QStringList &emails) -{ - qCDebug(QGPGME_LOG) << __func__ << "locating external keys for" << emails; - if (emails.empty()) { - return std::make_tuple(ImportResult{}, QString{}, Error{}); - } - - Context::KeyListModeSaver saver{ctx}; - ctx->setKeyListMode(GpgME::LocateExternal); - ctx->setFlag("auto-key-locate", "clear,wkd"); - std::vector<Key> dummy; - auto job = std::unique_ptr<KeyListJob>{new QGpgMEKeyListJob{ctx}}; - (void) job->exec(emails, false, dummy); - qCDebug(QGPGME_LOG) << __func__ << "number of keys:" << dummy.size(); - std::for_each(dummy.cbegin(), dummy.cend(), [](const Key &k) { - qCDebug(QGPGME_LOG) << __func__ << toLogString(k).c_str(); - }); - const auto result = ctx->importResult(); - qCDebug(QGPGME_LOG) << __func__ << "result:" << toLogString(result).c_str(); - job.release(); - - return std::make_tuple(result, QString{}, Error{}); -} - -GpgME::Error QGpgMEWKDRefreshJobPrivate::startIt() -{ - QStringList emails; - if (!m_keys.empty()) { - emails = toEmailAddressesOriginatingFromWKD(m_keys); - } else { - emails = toEmailAddresses(m_userIds); - } - std::sort(emails.begin(), emails.end()); - emails.erase(std::unique(emails.begin(), emails.end()), emails.end()); - - q->run([emails](Context *ctx) { - return locate_external_keys(ctx, emails); - }); - - return {}; -} - -#include "qgpgmewkdrefreshjob.moc" diff --git a/lang/qt/src/qgpgmewkdrefreshjob.h b/lang/qt/src/qgpgmewkdrefreshjob.h deleted file mode 100644 index 2a242d65..00000000 --- a/lang/qt/src/qgpgmewkdrefreshjob.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - qgpgmewkdrefreshjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QGPGMEWKDREFRESHJOB_H__ -#define __QGPGME_QGPGMEWKDREFRESHJOB_H__ - -#include "threadedjobmixin.h" -#include "wkdrefreshjob.h" - -#include <gpgme++/importresult.h> - -namespace QGpgME -{ - -class QGpgMEWKDRefreshJob -#ifdef Q_MOC_RUN - : public WKDRefreshJob -#else - : public _detail::ThreadedJobMixin<WKDRefreshJob, std::tuple<GpgME::ImportResult, QString, GpgME::Error>> -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEWKDRefreshJob(GpgME::Context *context); - ~QGpgMEWKDRefreshJob() override; -}; - -} - -#endif // __QGPGME_QGPGMEWKDREFRESHJOB_H__ diff --git a/lang/qt/src/qgpgmewkspublishjob.cpp b/lang/qt/src/qgpgmewkspublishjob.cpp deleted file mode 100644 index 74cf25cc..00000000 --- a/lang/qt/src/qgpgmewkspublishjob.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* wkspublishjob.cpp - - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmewkspublishjob.h" - -#include <gpgme++/context.h> -#include <gpgme++/key.h> - -#include "util.h" - -#include <QFileInfo> -#include <QDir> -#include <QProcess> - -/* Timeout for the WKS Processes will be 5 Minutes as - * they can involve pinentry questions. */ -#define TIMEOUT_VALUE (5*60*1000) - -using namespace QGpgME; -using namespace GpgME; - -QGpgMEWKSPublishJob::QGpgMEWKSPublishJob(Context *context) - : mixin_type(context) -{ - lateInitialization(); -} - -QGpgMEWKSPublishJob::~QGpgMEWKSPublishJob() {} - -static QString getWKSClient() -{ - auto libexecdir = QString::fromLocal8Bit(dirInfo("libexecdir")); - if (libexecdir.isEmpty()) { - return QString(); - } - - const QFileInfo fi(QDir(libexecdir).absoluteFilePath(QStringLiteral("gpg-wks-client"))); - if (fi.exists() && fi.isExecutable()) { - return fi.absoluteFilePath(); - } - return QString(); -} - -static QGpgMEWKSPublishJob::result_type check_worker(const QString &mail) -{ - if (mail.isEmpty()) { - return std::make_tuple (Error(make_error(GPG_ERR_INV_ARG)), - QByteArray(), QByteArray(), QString(), Error()); - } - - const auto wksPath = getWKSClient(); - if (wksPath.isEmpty()) { - return std::make_tuple (Error(make_error(GPG_ERR_NOT_SUPPORTED)), - QByteArray(), QByteArray(), QString(), Error()); - } - - /* QProcess instead of engine_spawn because engine_spawn does not communicate - * the return value of the process and we are in qt anyway. */ - QProcess proc; - proc.setProgram(wksPath); - proc.setArguments(QStringList() << QStringLiteral("--supported") << mail); - proc.start(); - if (!proc.waitForStarted()) { - return std::make_tuple (Error(make_error(GPG_ERR_NOT_SUPPORTED)), - QByteArray(), QByteArray(), QString(), Error()); - } - if (!proc.waitForFinished(TIMEOUT_VALUE)) { - return std::make_tuple (Error(make_error(GPG_ERR_TIMEOUT)), - QByteArray(), QByteArray(), QString(), Error()); - } - if (proc.exitStatus() == QProcess::NormalExit && proc.exitCode() == 0) { - return std::make_tuple (Error(), QByteArray(), QByteArray(), QString(), Error()); - } - return std::make_tuple (Error(make_error(GPG_ERR_NOT_ENABLED)), - QByteArray(), QByteArray(), QString(), Error()); -} - -static QGpgMEWKSPublishJob::result_type create_worker(const char *fpr, const QString &mail) -{ - if (mail.isEmpty() || !fpr) { - return std::make_tuple (Error(make_error(GPG_ERR_INV_ARG)), - QByteArray(), QByteArray(), QString(), Error()); - } - - const auto wksPath = getWKSClient(); - if (wksPath.isEmpty()) { - return std::make_tuple (Error(make_error(GPG_ERR_NOT_SUPPORTED)), - QByteArray(), QByteArray(), QString(), Error()); - } - - QProcess proc; - proc.setProgram(wksPath); - proc.setArguments(QStringList() << QStringLiteral("--create") - << QLatin1String(fpr) - << mail); - proc.start(); - if (!proc.waitForStarted()) { - return std::make_tuple (Error(make_error(GPG_ERR_NOT_SUPPORTED)), - QByteArray(), QByteArray(), QString(), Error()); - } - - if (!proc.waitForFinished(TIMEOUT_VALUE)) { - return std::make_tuple (Error(make_error(GPG_ERR_TIMEOUT)), - QByteArray(), QByteArray(), QString(), Error()); - } - if (proc.exitStatus() == QProcess::NormalExit && proc.exitCode() == 0) { - return std::make_tuple (Error(), proc.readAllStandardOutput(), - proc.readAllStandardError(), QString(), Error()); - } - return std::make_tuple (Error(make_error(GPG_ERR_GENERAL)), - proc.readAllStandardOutput(), proc.readAllStandardError(), QString(), Error()); -} - -static QGpgMEWKSPublishJob::result_type receive_worker(const QByteArray &response) -{ - if (response.isEmpty()) { - return std::make_tuple (Error(make_error(GPG_ERR_INV_ARG)), - QByteArray(), QByteArray(), QString(), Error()); - } - - const auto wksPath = getWKSClient(); - if (wksPath.isEmpty()) { - return std::make_tuple (Error(make_error(GPG_ERR_NOT_SUPPORTED)), - QByteArray(), QByteArray(), QString(), Error()); - } - - QProcess proc; - proc.setProgram(wksPath); - proc.setArguments(QStringList() << QStringLiteral("--receive")); - proc.start(); - if (!proc.waitForStarted()) { - return std::make_tuple (Error(make_error(GPG_ERR_NOT_SUPPORTED)), - QByteArray(), QByteArray(), QString(), Error()); - } - proc.write(response); - proc.closeWriteChannel(); - if (!proc.waitForFinished(TIMEOUT_VALUE)) { - return std::make_tuple (Error(make_error(GPG_ERR_TIMEOUT)), - QByteArray(), QByteArray(), QString(), Error()); - } - if (proc.exitStatus() == QProcess::NormalExit && proc.exitCode() == 0) { - return std::make_tuple (Error(), proc.readAllStandardOutput(), - proc.readAllStandardError(), QString(), Error()); - } - return std::make_tuple (Error(make_error(GPG_ERR_GENERAL)), - proc.readAllStandardOutput(), proc.readAllStandardError(), QString(), Error()); -} - -void QGpgMEWKSPublishJob::startCheck(const QString &mailbox) -{ - run(std::bind(&check_worker, mailbox)); -} - -void QGpgMEWKSPublishJob::startCreate(const char *fpr, const QString &mailbox) { - run(std::bind(&create_worker, fpr, mailbox)); -} - -void QGpgMEWKSPublishJob::startReceive(const QByteArray &response) -{ - run(std::bind(&receive_worker, response)); -} - -#include "qgpgmewkspublishjob.moc" diff --git a/lang/qt/src/qgpgmewkspublishjob.h b/lang/qt/src/qgpgmewkspublishjob.h deleted file mode 100644 index a8635e16..00000000 --- a/lang/qt/src/qgpgmewkspublishjob.h +++ /dev/null @@ -1,71 +0,0 @@ -/* qgpgmewkspublishjob.h - - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifndef QGPGME_QGPGMEWKSPUBLISHJOB_H -#define QGPGME_QGPGMEWKSPUBLISHJOB_H - -#include "wkspublishjob.h" - -#include "threadedjobmixin.h" -namespace GpgME -{ - class Key; -} // namespace GpgME - -namespace QGpgME { - -/** - * Handles Web Key Service Publishing. Needs WKS tools installed and - * server support. - */ -class QGpgMEWKSPublishJob -#ifdef Q_MOC_RUN - : public WKSPublishJob -#else - : public _detail::ThreadedJobMixin<WKSPublishJob, std::tuple<GpgME::Error, QByteArray, QByteArray, QString, GpgME::Error> > -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMEWKSPublishJob(GpgME::Context *context); - ~QGpgMEWKSPublishJob(); - - void startCheck(const QString &mailbox) override; - void startCreate(const char *fpr, const QString &mailbox) override; - void startReceive(const QByteArray &response) override; -}; - -} - -#endif diff --git a/lang/qt/src/quickjob.cpp b/lang/qt/src/quickjob.cpp deleted file mode 100644 index 1c9343da..00000000 --- a/lang/qt/src/quickjob.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - quickjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2024 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#include "quickjob.h" -#include "quickjob_p.h" - -using namespace QGpgME; - -QuickJob::QuickJob(QObject *parent) - : Job{parent} -{ -} - -QuickJob::~QuickJob() = default; - -GpgME::Error QuickJob::startSetKeyEnabled(const GpgME::Key &key, bool enabled) -{ - auto d = jobPrivate<QuickJobPrivate>(this); - return d->startSetKeyEnabled(key, enabled); -} - -#include "quickjob.moc" diff --git a/lang/qt/src/quickjob.h b/lang/qt/src/quickjob.h deleted file mode 100644 index df8ac2b5..00000000 --- a/lang/qt/src/quickjob.h +++ /dev/null @@ -1,101 +0,0 @@ -/* quickjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2017 Intevation GmbH - Copyright (c) 2020 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifndef QGPGME_QUICKJOB_H -#define QGPGME_QUICKJOB_H - -#include "job.h" - -#include "qgpgme_export.h" - -#include <QDateTime> - -#include <gpgme++/key.h> - -class QString; - -namespace QGpgME{ - -/** - * Interface to the modern key manipulation functions. - */ -class QGPGME_EXPORT QuickJob : public Job -{ - Q_OBJECT -public: - explicit QuickJob(QObject *parent = nullptr); - ~QuickJob(); - - /** Start --quick-gen-key */ - virtual void startCreate(const QString &uid, - const char *algo, - const QDateTime &expires = QDateTime(), - const GpgME::Key &key = GpgME::Key(), - unsigned int flags = 0) = 0; - - /** Start --quick-adduid */ - virtual void startAddUid(const GpgME::Key &key, const QString &uid) = 0; - - /** Start --quick-revuid */ - virtual void startRevUid(const GpgME::Key &key, const QString &uid) = 0; - - /** Start --quick-add-key */ - virtual void startAddSubkey(const GpgME::Key &key, const char *algo, - const QDateTime &expires = QDateTime(), - unsigned int flags = 0) = 0; - - /** - Starts the operation to revoke the signatures made with the key \a signingKey on the - user IDs \a userIds of the key \a key. If \a userIds is an empty list, then all - signatures made with \a signingKey on the user IDs of \a key will be revoked. - */ - virtual void startRevokeSignature(const GpgME::Key &key, const GpgME::Key &signingKey, - const std::vector<GpgME::UserID> &userIds = std::vector<GpgME::UserID>()) = 0; - - /** Start --quick-add-adsk */ - virtual void startAddAdsk(const GpgME::Key &key, const char *adsk) = 0; - - /** - * Starts the operation to enable or disable the OpenPGP key \a key. - * If \a enabled is \c true then the key is enabled. Otherwise, the key is disabled. - * - * \note Requires gpg 2.4.6. - */ - GpgME::Error startSetKeyEnabled(const GpgME::Key &key, bool enabled); - -Q_SIGNALS: - void result(const GpgME::Error &error, - const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} -#endif diff --git a/lang/qt/src/quickjob_p.h b/lang/qt/src/quickjob_p.h deleted file mode 100644 index a8c993a2..00000000 --- a/lang/qt/src/quickjob_p.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - quickjob_p.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2024 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_QUICKJOB_P_H__ -#define __QGPGME_QUICKJOB_P_H__ - -#include "job_p.h" - -#include "quickjob.h" - -namespace QGpgME -{ - -struct QuickJobPrivate : public JobPrivate -{ - virtual GpgME::Error startSetKeyEnabled(const GpgME::Key &key, bool enabled) = 0; -}; - -} - -#endif // __QGPGME_QUICKJOB_P_H__ diff --git a/lang/qt/src/receivekeysjob.h b/lang/qt/src/receivekeysjob.h deleted file mode 100644 index 3f85792f..00000000 --- a/lang/qt/src/receivekeysjob.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - receivekeysjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_RECEIVEKEYSJOB_H__ -#define __QGPGME_RECEIVEKEYSJOB_H__ - -#include "abstractimportjob.h" -#include "qgpgme_export.h" - -namespace QGpgME -{ - -class QGPGME_EXPORT ReceiveKeysJob : public AbstractImportJob -{ - Q_OBJECT -protected: - explicit ReceiveKeysJob(QObject *parent); -public: - ~ReceiveKeysJob() override; - - /** - Starts the import of keys from a keyserver. \a keyIds is a list of - key ids and/or fingerprints specifying the keys to import. - */ - virtual GpgME::Error start(const QStringList &keyIds) = 0; - - /** - Runs the import of keys from a keyserver. \a keyIds is a list of - key ids and/or fingerprints specifying the keys to import. - */ - virtual GpgME::ImportResult exec(const QStringList &keyIds) = 0; -}; - -} - -#endif // __QGPGME_RECEIVEKEYSJOB_H__ diff --git a/lang/qt/src/refreshkeysjob.h b/lang/qt/src/refreshkeysjob.h deleted file mode 100644 index 67774c2f..00000000 --- a/lang/qt/src/refreshkeysjob.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - refreshkeysjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_REFRESHKEYSJOB_H__ -#define __KLEO_REFRESHKEYSJOB_H__ - -#include "job.h" -#include "qgpgme_export.h" - -#include <QtCore/QStringList> - -#include <vector> - -namespace GpgME -{ -class Error; -class Key; -} - -namespace QGpgME -{ - -/** - @short An abstract base class for asynchronous key refreshers. - - To use a RefreshKeysJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the key refresh with a - call to start(). This call might fail, in which case the - RefreshKeysJob instance will have scheduled its own destruction - with a call to QObject::deleteLater(). - - After result() is emitted, the job will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT RefreshKeysJob : public Job -{ - Q_OBJECT -protected: - explicit RefreshKeysJob(QObject *parent); -public: - ~RefreshKeysJob(); - - /** - Starts the refresh operation. \a pattern is a list of patterns - used to restrict the list of keys returned. Empty patterns are - ignored. If \a pattern is empty or contains only empty strings, - all keys are refreshed. - - Only implemented for S/MIME. - */ - virtual GpgME::Error start(const QStringList &patterns) = 0; - - /** - Starts a refresh of the \a keys. - */ - virtual GpgME::Error start(const std::vector<GpgME::Key> &keys) = 0; - -Q_SIGNALS: - void result(const GpgME::Error &result); -}; - -} - -#endif // __KLEO_REFRESHKEYSJOB_H__ diff --git a/lang/qt/src/revokekeyjob.h b/lang/qt/src/revokekeyjob.h deleted file mode 100644 index 69aef062..00000000 --- a/lang/qt/src/revokekeyjob.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - revokekeyjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_REVOKEKEYJOB_H__ -#define __QGPGME_REVOKEKEYJOB_H__ - -#include "job.h" -#include "qgpgme_export.h" - -class QString; - -namespace GpgME -{ -class Error; -class Key; -} - -namespace QGpgME -{ - -class QGPGME_EXPORT RevokeKeyJob : public Job -{ - Q_OBJECT -protected: - explicit RevokeKeyJob(QObject *parent); - -public: - ~RevokeKeyJob(); - - /** - Starts the operation. \a key is the key to revoke with reason \a reason and - optional description \a description. The individual elements of \a description - must be non-empty strings and they must not contain any endline characters. - - The job deletes itself after it has completed the operation. - */ - virtual GpgME::Error start(const GpgME::Key &key, - GpgME::RevocationReason reason = GpgME::RevocationReason::Unspecified, - const std::vector<std::string> &description = {}) = 0; - - /** - Runs the operation. \a key is the key to revoke with reason \a reason and - optional description \a description. The individual elements of \a description - must be non-empty strings and they must not contain any endline characters. - */ - virtual GpgME::Error exec(const GpgME::Key &key, - GpgME::RevocationReason reason = GpgME::RevocationReason::Unspecified, - const std::vector<std::string> &description = {}) = 0; - -Q_SIGNALS: - void result(const GpgME::Error &result, const QString &auditLogAsHtml = {}, const GpgME::Error &auditLogError = {}); -}; - -} - -#endif // __QGPGME_REVOKEKEYJOB_H__ diff --git a/lang/qt/src/setprimaryuseridjob.h b/lang/qt/src/setprimaryuseridjob.h deleted file mode 100644 index fa76199c..00000000 --- a/lang/qt/src/setprimaryuseridjob.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - setprimaryuseridjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_SETPRIMARYUSERIDJOB_H__ -#define __QGPGME_SETPRIMARYUSERIDJOB_H__ - -#include "job.h" - -#include "qgpgme_export.h" - -namespace GpgME -{ -class Error; -class UserID; -} - -namespace QGpgME -{ - -class QGPGME_EXPORT SetPrimaryUserIDJob : public Job -{ - Q_OBJECT -public: - explicit SetPrimaryUserIDJob(QObject *parent); - ~SetPrimaryUserIDJob() override; - - /** - * Starts setting user ID \a userId as the primary user ID. - */ - virtual GpgME::Error start(const GpgME::UserID &userId) = 0; - -Q_SIGNALS: - void result(const GpgME::Error &error, - const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __QGPGME_SETPRIMARYUSERIDJOB_H__ diff --git a/lang/qt/src/signarchivejob.cpp b/lang/qt/src/signarchivejob.cpp deleted file mode 100644 index 0d898b25..00000000 --- a/lang/qt/src/signarchivejob.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - signarchivejob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "signarchivejob.h" -#include "signarchivejob_p.h" - -#include <gpgme++/engineinfo.h> - -using namespace QGpgME; - -SignArchiveJob::SignArchiveJob(QObject *parent) - : Job{parent} -{ -} - -SignArchiveJob::~SignArchiveJob() = default; - -// static -bool SignArchiveJob::isSupported() -{ - static const auto gpgVersion = GpgME::engineInfo(GpgME::GpgEngine).engineVersion(); - return (gpgVersion >= "2.4.1") || (gpgVersion >= "2.2.42" && gpgVersion < "2.3.0"); -} - -void SignArchiveJob::setSigners(const std::vector<GpgME::Key> &signers) -{ - auto d = jobPrivate<SignArchiveJobPrivate>(this); - d->m_signers = signers; -} - -std::vector<GpgME::Key> SignArchiveJob::signers() const -{ - auto d = jobPrivate<SignArchiveJobPrivate>(this); - return d->m_signers; -} - -void SignArchiveJob::setInputPaths(const std::vector<QString> &paths) -{ - auto d = jobPrivate<SignArchiveJobPrivate>(this); - d->m_inputPaths = paths; -} - -std::vector<QString> SignArchiveJob::inputPaths() const -{ - auto d = jobPrivate<SignArchiveJobPrivate>(this); - return d->m_inputPaths; -} - -void SignArchiveJob::setOutputFile(const QString &path) -{ - auto d = jobPrivate<SignArchiveJobPrivate>(this); - d->m_outputFilePath = path; -} - -QString SignArchiveJob::outputFile() const -{ - auto d = jobPrivate<SignArchiveJobPrivate>(this); - return d->m_outputFilePath; -} - -void SignArchiveJob::setBaseDirectory(const QString &baseDirectory) -{ - auto d = jobPrivate<SignArchiveJobPrivate>(this); - d->m_baseDirectory = baseDirectory; -} - -QString SignArchiveJob::baseDirectory() const -{ - auto d = jobPrivate<SignArchiveJobPrivate>(this); - return d->m_baseDirectory; -} - -#include "signarchivejob.moc" diff --git a/lang/qt/src/signarchivejob.h b/lang/qt/src/signarchivejob.h deleted file mode 100644 index 0b4cdeb4..00000000 --- a/lang/qt/src/signarchivejob.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - signarchivejob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_SIGNARCHIVEJOB_H__ -#define __QGPGME_SIGNARCHIVEJOB_H__ - -#include "job.h" - -#include <gpgme++/context.h> - -namespace GpgME -{ -class Key; -} - -namespace QGpgME -{ - -/** - * Abstract base class for job for creating signed archives - */ -class QGPGME_EXPORT SignArchiveJob : public Job -{ - Q_OBJECT -protected: - explicit SignArchiveJob(QObject *parent); -public: - ~SignArchiveJob() override; - - static bool isSupported(); - - /** - * Sets the keys to use for signing the archive. - * - * Used if the job is started with startIt(). - */ - void setSigners(const std::vector<GpgME::Key> &signers); - std::vector<GpgME::Key> signers() const; - - /** - * Sets the paths of the files and folders to put into the archive. - * - * If base directory is set, then the paths must be relative to the - * base directory. - * - * Used if the job is started with startIt(). - */ - void setInputPaths(const std::vector<QString> &paths); - std::vector<QString> inputPaths() const; - - /** - * Sets the path of the file to write the created archive to. - * - * If \a path is a relative path and base directory is set, then the - * path is interpreted relative to the base directory. - * - * Used if the job is started with startIt(). - * - * \note If a file with this path exists, then the job will fail, i.e. you - * need to delete an existing file that shall be overwritten before you - * start the job. - */ - void setOutputFile(const QString &path); - QString outputFile() const; - - /** - * Sets the base directory for the relative paths of the input files and - * the output file. - */ - void setBaseDirectory(const QString &baseDirectory); - QString baseDirectory() const; - - /** - * Starts the creation of a signed archive. - * - * Creates a signed archive with the files and directories in \a paths. - * The archive is signed with the keys in \a signers or with the default - * key, if \a signers is empty. The signed archive is written to \a output. - * - * Emits result() when the job has finished. - */ - virtual GpgME::Error start(const std::vector<GpgME::Key> &signers, - const std::vector<QString> &paths, - const std::shared_ptr<QIODevice> &output) = 0; - -Q_SIGNALS: - /** - * This signal is emitted whenever gpgtar sends a progress status update for - * the number of files. In the scanning phase (i.e. while gpgtar checks - * which files to put into the archive), \a current is the current number of - * files and \a total is 0. In the writing phase, \a current is the number - * of processed files and \a total is the total number of files. - */ - void fileProgress(int current, int total); - - /** - * This signal is emitted whenever gpgtar sends a progress status update for - * the amount of processed data. It is only emitted in the writing phase. - * \a current is the processed amount data and \a total is the total amount - * of data to process. Both values never exceed 2^20. - */ - void dataProgress(int current, int total); - - void result(const GpgME::SigningResult &result, - const QString &auditLogAsHtml = {}, - const GpgME::Error &auditLogError = {}); -}; - -} - -#endif // __QGPGME_SIGNARCHIVEJOB_H__ diff --git a/lang/qt/src/signarchivejob_p.h b/lang/qt/src/signarchivejob_p.h deleted file mode 100644 index 9ec921bb..00000000 --- a/lang/qt/src/signarchivejob_p.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - signarchivejob_p.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_SIGNARCHIVEJOB_P_H__ -#define __QGPGME_SIGNARCHIVEJOB_P_H__ - -#include "job_p.h" - -namespace QGpgME -{ - -struct SignArchiveJobPrivate : public JobPrivate -{ - std::vector<GpgME::Key> m_signers; - std::vector<QString> m_inputPaths; - QString m_outputFilePath; - QString m_baseDirectory; -}; - -} - -#endif // __QGPGME_SIGNARCHIVEJOB_P_H__ diff --git a/lang/qt/src/signencryptarchivejob.cpp b/lang/qt/src/signencryptarchivejob.cpp deleted file mode 100644 index 114d6f33..00000000 --- a/lang/qt/src/signencryptarchivejob.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - signencryptarchivejob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "signencryptarchivejob.h" -#include "signencryptarchivejob_p.h" - -#include <gpgme++/engineinfo.h> - -using namespace QGpgME; - -SignEncryptArchiveJob::SignEncryptArchiveJob(QObject *parent) - : Job{parent} -{ -} - -SignEncryptArchiveJob::~SignEncryptArchiveJob() = default; - -// static -bool SignEncryptArchiveJob::isSupported() -{ - static const auto gpgVersion = GpgME::engineInfo(GpgME::GpgEngine).engineVersion(); - return (gpgVersion >= "2.4.1") || (gpgVersion >= "2.2.42" && gpgVersion < "2.3.0"); -} - -void SignEncryptArchiveJob::setSigners(const std::vector<GpgME::Key> &signers) -{ - auto d = jobPrivate<SignEncryptArchiveJobPrivate>(this); - d->m_signers = signers; -} - -std::vector<GpgME::Key> SignEncryptArchiveJob::signers() const -{ - auto d = jobPrivate<SignEncryptArchiveJobPrivate>(this); - return d->m_signers; -} - -void SignEncryptArchiveJob::setRecipients(const std::vector<GpgME::Key> &recipients) -{ - auto d = jobPrivate<SignEncryptArchiveJobPrivate>(this); - d->m_recipients = recipients; -} - -std::vector<GpgME::Key> SignEncryptArchiveJob::recipients() const -{ - auto d = jobPrivate<SignEncryptArchiveJobPrivate>(this); - return d->m_recipients; -} - -void SignEncryptArchiveJob::setInputPaths(const std::vector<QString> &paths) -{ - auto d = jobPrivate<SignEncryptArchiveJobPrivate>(this); - d->m_inputPaths = paths; -} - -std::vector<QString> SignEncryptArchiveJob::inputPaths() const -{ - auto d = jobPrivate<SignEncryptArchiveJobPrivate>(this); - return d->m_inputPaths; -} - -void SignEncryptArchiveJob::setOutputFile(const QString &path) -{ - auto d = jobPrivate<SignEncryptArchiveJobPrivate>(this); - d->m_outputFilePath = path; -} - -QString SignEncryptArchiveJob::outputFile() const -{ - auto d = jobPrivate<SignEncryptArchiveJobPrivate>(this); - return d->m_outputFilePath; -} - -void SignEncryptArchiveJob::setEncryptionFlags(GpgME::Context::EncryptionFlags flags) -{ - auto d = jobPrivate<SignEncryptArchiveJobPrivate>(this); - d->m_encryptionFlags = static_cast<GpgME::Context::EncryptionFlags>(flags | GpgME::Context::EncryptArchive); -} - -GpgME::Context::EncryptionFlags SignEncryptArchiveJob::encryptionFlags() const -{ - auto d = jobPrivate<SignEncryptArchiveJobPrivate>(this); - return d->m_encryptionFlags; -} - -void SignEncryptArchiveJob::setBaseDirectory(const QString &baseDirectory) -{ - auto d = jobPrivate<SignEncryptArchiveJobPrivate>(this); - d->m_baseDirectory = baseDirectory; -} - -QString SignEncryptArchiveJob::baseDirectory() const -{ - auto d = jobPrivate<SignEncryptArchiveJobPrivate>(this); - return d->m_baseDirectory; -} - -#include "signencryptarchivejob.moc" diff --git a/lang/qt/src/signencryptarchivejob.h b/lang/qt/src/signencryptarchivejob.h deleted file mode 100644 index c8742aec..00000000 --- a/lang/qt/src/signencryptarchivejob.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - signencryptarchivejob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_SIGNENCRYPTARCHIVEJOB_H__ -#define __QGPGME_SIGNENCRYPTARCHIVEJOB_H__ - -#include "job.h" - -#include <gpgme++/context.h> - -namespace GpgME -{ -class Key; -} - -namespace QGpgME -{ - -/** - * Abstract base class for job for creating encrypted signed archives - */ -class QGPGME_EXPORT SignEncryptArchiveJob : public Job -{ - Q_OBJECT -protected: - explicit SignEncryptArchiveJob(QObject *parent); -public: - ~SignEncryptArchiveJob() override; - - static bool isSupported(); - - /** - * Sets the keys to use for signing the archive. - * - * Used if the job is started with startIt(). - */ - void setSigners(const std::vector<GpgME::Key> &signers); - std::vector<GpgME::Key> signers() const; - - /** - * Sets the keys to use for encrypting the archive. - * - * Used if the job is started with startIt(). - */ - void setRecipients(const std::vector<GpgME::Key> &recipients); - std::vector<GpgME::Key> recipients() const; - - /** - * Sets the paths of the files and folders to put into the archive. - * - * If base directory is set, then the paths must be relative to the - * base directory. - * - * Used if the job is started with startIt(). - */ - void setInputPaths(const std::vector<QString> &paths); - std::vector<QString> inputPaths() const; - - /** - * Sets the path of the file to write the created archive to. - * - * If \a path is a relative path and base directory is set, then the - * path is interpreted relative to the base directory. - * - * Used if the job is started with startIt(). - * - * \note If a file with this path exists, then the job will fail, i.e. you - * need to delete an existing file that shall be overwritten before you - * start the job. - */ - void setOutputFile(const QString &path); - QString outputFile() const; - - /** - * Sets the flags to use for encryption. Defaults to \c EncryptArchive. - * The \c EncryptArchive flag is always assumed set for this job. - * - * Used if the job is started with startIt(). - */ - void setEncryptionFlags(GpgME::Context::EncryptionFlags flags); - GpgME::Context::EncryptionFlags encryptionFlags() const; - - /** - * Sets the base directory for the relative paths of the input files and - * the output file. - */ - void setBaseDirectory(const QString &baseDirectory); - QString baseDirectory() const; - - /** - * Starts the creation of an encrypted signed archive. - * - * Creates an encrypted signed archive with the files and directories in - * \a paths. - * The archive is signed with the keys in \a signers or with the default - * key, if \a signers is empty. Then the archive is encrypted for the - * keys in \a recipients. If \a recipients is empty, then symmetric - * encryption is performed. The encrypted signed archive is written to - * \a cipherText. - * - * Emits result() when the job has finished. - */ - virtual GpgME::Error start(const std::vector<GpgME::Key> &signers, - const std::vector<GpgME::Key> &recipients, - const std::vector<QString> &paths, - const std::shared_ptr<QIODevice> &cipherText, - const GpgME::Context::EncryptionFlags flags) = 0; - -Q_SIGNALS: - /** - * This signal is emitted whenever gpgtar sends a progress status update for - * the number of files. In the scanning phase (i.e. while gpgtar checks - * which files to put into the archive), \a current is the current number of - * files and \a total is 0. In the writing phase, \a current is the number - * of processed files and \a total is the total number of files. - */ - void fileProgress(int current, int total); - - /** - * This signal is emitted whenever gpgtar sends a progress status update for - * the amount of processed data. It is only emitted in the writing phase. - * \a current is the processed amount data and \a total is the total amount - * of data to process. Both values never exceed 2^20. - */ - void dataProgress(int current, int total); - - void result(const GpgME::SigningResult &signingResult, - const GpgME::EncryptionResult &encryptionResult, - const QString &auditLogAsHtml = {}, - const GpgME::Error &auditLogError = {}); -}; - -} - -#endif // __QGPGME_SIGNENCRYPTARCHIVEJOB_H__ diff --git a/lang/qt/src/signencryptarchivejob_p.h b/lang/qt/src/signencryptarchivejob_p.h deleted file mode 100644 index 3ae7a4c1..00000000 --- a/lang/qt/src/signencryptarchivejob_p.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - signencryptarchivejob_p.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_SIGNENCRYPTARCHIVEJOB_P_H__ -#define __QGPGME_SIGNENCRYPTARCHIVEJOB_P_H__ - -#include "job_p.h" - -namespace QGpgME -{ - -struct SignEncryptArchiveJobPrivate : public JobPrivate -{ - std::vector<GpgME::Key> m_signers; - std::vector<GpgME::Key> m_recipients; - std::vector<QString> m_inputPaths; - QString m_outputFilePath; - QString m_baseDirectory; - GpgME::Context::EncryptionFlags m_encryptionFlags = GpgME::Context::EncryptArchive; -}; - -} - -#endif // __QGPGME_SIGNENCRYPTARCHIVEJOB_P_H__ diff --git a/lang/qt/src/signencryptjob.cpp b/lang/qt/src/signencryptjob.cpp deleted file mode 100644 index e82730e6..00000000 --- a/lang/qt/src/signencryptjob.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - signencryptjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "signencryptjob.h" -#include "signencryptjob_p.h" - -using namespace QGpgME; - -SignEncryptJob::SignEncryptJob(QObject *parent) - : Job{parent} -{ -} - -SignEncryptJob::~SignEncryptJob() = default; - -void SignEncryptJob::setFileName(const QString &fileName) -{ - auto d = jobPrivate<SignEncryptJobPrivate>(this); - d->m_fileName = fileName; -} - -QString SignEncryptJob::fileName() const -{ - auto d = jobPrivate<SignEncryptJobPrivate>(this); - return d->m_fileName; -} - -void SignEncryptJob::setSigners(const std::vector<GpgME::Key> &signers) -{ - auto d = jobPrivate<SignEncryptJobPrivate>(this); - d->m_signers = signers; -} - -std::vector<GpgME::Key> SignEncryptJob::signers() const -{ - auto d = jobPrivate<SignEncryptJobPrivate>(this); - return d->m_signers; -} - -void SignEncryptJob::setRecipients(const std::vector<GpgME::Key> &recipients) -{ - auto d = jobPrivate<SignEncryptJobPrivate>(this); - d->m_recipients = recipients; -} - -std::vector<GpgME::Key> SignEncryptJob::recipients() const -{ - auto d = jobPrivate<SignEncryptJobPrivate>(this); - return d->m_recipients; -} - -void SignEncryptJob::setInputFile(const QString &path) -{ - auto d = jobPrivate<SignEncryptJobPrivate>(this); - d->m_inputFilePath = path; -} - -QString SignEncryptJob::inputFile() const -{ - auto d = jobPrivate<SignEncryptJobPrivate>(this); - return d->m_inputFilePath; -} - -void SignEncryptJob::setOutputFile(const QString &path) -{ - auto d = jobPrivate<SignEncryptJobPrivate>(this); - d->m_outputFilePath = path; -} - -QString SignEncryptJob::outputFile() const -{ - auto d = jobPrivate<SignEncryptJobPrivate>(this); - return d->m_outputFilePath; -} - -void SignEncryptJob::setEncryptionFlags(GpgME::Context::EncryptionFlags flags) -{ - auto d = jobPrivate<SignEncryptJobPrivate>(this); - d->m_encryptionFlags = static_cast<GpgME::Context::EncryptionFlags>(flags | GpgME::Context::EncryptFile); -} - -GpgME::Context::EncryptionFlags SignEncryptJob::encryptionFlags() const -{ - auto d = jobPrivate<SignEncryptJobPrivate>(this); - return d->m_encryptionFlags; -} - -#include "signencryptjob.moc" diff --git a/lang/qt/src/signencryptjob.h b/lang/qt/src/signencryptjob.h deleted file mode 100644 index 73b8c227..00000000 --- a/lang/qt/src/signencryptjob.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - signencryptjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004, 2007 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_SIGNENCRYPTJOB_H__ -#define __KLEO_SIGNENCRYPTJOB_H__ - -#include "job.h" -#include "qgpgme_export.h" - -#include <gpgme++/global.h> -#include <gpgme++/context.h> - -#include <memory> -#include <vector> -#include <utility> - -class QByteArray; -class QIODevice; - -namespace GpgME -{ -class Error; -class Key; -class SigningResult; -class EncryptionResult; -} - -namespace QGpgME -{ - -/** - @short An abstract base class for asynchronous combined signing and encrypting - - To use a SignEncryptJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the operation with a - call to start(). This call might fail, in which case the - SignEncryptJob instance will have scheduled it's own destruction - with a call to QObject::deleteLater(). - - Alternatively, the job can be started with startIt() after setting - an input file and an output file and, optionally, signers, recipients or flags. - If the job is started this way then the backend reads the input and - writes the output directly from/to the specified input file and output - file. In this case the cipherText value of the result signal will always - be empty. This direct IO mode is currently only supported for OpenPGP. - Note that startIt() does not schedule the job's destruction if starting - the job failed. - - After result() is emitted, the SignEncryptJob will schedule it's - own destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT SignEncryptJob : public Job -{ - Q_OBJECT -protected: - explicit SignEncryptJob(QObject *parent); -public: - ~SignEncryptJob() override; - - /** - * Sets the file name to embed in the encryption result. - * - * This is only used if one of the start() functions is used. - */ - void setFileName(const QString &fileName); - QString fileName() const; - - /** - * Sets the keys to use for signing. - * - * Used if the job is started with startIt(). - */ - void setSigners(const std::vector<GpgME::Key> &signers); - std::vector<GpgME::Key> signers() const; - - /** - * Sets the keys to use for encryption. - * - * Used if the job is started with startIt(). - */ - void setRecipients(const std::vector<GpgME::Key> &recipients); - std::vector<GpgME::Key> recipients() const; - - /** - * Sets the path of the file to encrypt. - * - * Used if the job is started with startIt(). - */ - void setInputFile(const QString &path); - QString inputFile() const; - - /** - * Sets the path of the file to write the encryption result to. - * - * Used if the job is started with startIt(). - * - * \note If a file with this path exists, then the job will fail, i.e. you - * need to delete an existing file that shall be overwritten before you - * start the job. - */ - void setOutputFile(const QString &path); - QString outputFile() const; - - /** - * Sets the flags to use for encryption. - * - * Defaults to \c EncryptFile. - * - * Used if the job is started with startIt(). The \c EncryptFile flag is - * always assumed set. - */ - void setEncryptionFlags(GpgME::Context::EncryptionFlags flags); - GpgME::Context::EncryptionFlags encryptionFlags() const; - - /** - Starts the combined signing and encrypting operation. \a signers - is the list of keys to sign \a plainText with. \a recipients is - a list of keys to encrypt the signed \a plainText to. In both - lists, empty (null) keys are ignored. - - If \a alwaysTrust is true, validity checking for the - \em recipient keys will not be performed, but full validity - assumed for all \em recipient keys without further checks. - */ - virtual GpgME::Error start(const std::vector<GpgME::Key> &signers, - const std::vector<GpgME::Key> &recipients, - const QByteArray &plainText, - bool alwaysTrust = false) = 0; - - /*! - \overload - - If \a cipherText is non-null, the ciphertext is written - there. Otherwise, it will be delivered in the third argument of - result(). - */ - virtual void start(const std::vector<GpgME::Key> &signers, - const std::vector<GpgME::Key> &recipients, - const std::shared_ptr<QIODevice> &plainText, - const std::shared_ptr<QIODevice> &cipherText = std::shared_ptr<QIODevice>(), - bool alwaysTrust = false) = 0; - - virtual std::pair<GpgME::SigningResult, GpgME::EncryptionResult> - exec(const std::vector<GpgME::Key> &signers, - const std::vector<GpgME::Key> &recipients, - const QByteArray &plainText, - bool alwaysTrust, QByteArray &cipherText) = 0; - - /*! - This is a hack to request BASE64 output (instead of whatever - comes out normally). - */ - virtual void setOutputIsBase64Encoded(bool) = 0; - - /** Like start but with an additional argument for EncryptionFlags for - * more flexibility. */ - virtual void start(const std::vector<GpgME::Key> &signers, - const std::vector<GpgME::Key> &recipients, - const std::shared_ptr<QIODevice> &plainText, - const std::shared_ptr<QIODevice> &cipherText = std::shared_ptr<QIODevice>(), - const GpgME::Context::EncryptionFlags flags = GpgME::Context::None) = 0; - - /** Like exec but with an additional argument for EncryptionFlags for - * more flexibility. */ - virtual std::pair<GpgME::SigningResult, GpgME::EncryptionResult> - exec(const std::vector<GpgME::Key> &signers, - const std::vector<GpgME::Key> &recipients, - const QByteArray &plainText, - const GpgME::Context::EncryptionFlags flags, QByteArray &cipherText) = 0; -Q_SIGNALS: - void result(const GpgME::SigningResult &signingresult, - const GpgME::EncryptionResult &encryptionresult, - const QByteArray &cipherText, const QString &auditLogAsHtml = QString(), - const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __KLEO_SIGNENCRYPTJOB_H__ diff --git a/lang/qt/src/signencryptjob_p.h b/lang/qt/src/signencryptjob_p.h deleted file mode 100644 index 8f5c91ec..00000000 --- a/lang/qt/src/signencryptjob_p.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - signencryptjob_p.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022,2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_SIGNENCRYPTJOB_P_H__ -#define __QGPGME_SIGNENCRYPTJOB_P_H__ - -#include "job_p.h" - -#include <gpgme++/key.h> - -namespace QGpgME -{ - -struct SignEncryptJobPrivate : public JobPrivate -{ - // used by start() functions - QString m_fileName; - - // used by startIt() - std::vector<GpgME::Key> m_signers; - std::vector<GpgME::Key> m_recipients; - QString m_inputFilePath; - QString m_outputFilePath; - GpgME::Context::EncryptionFlags m_encryptionFlags = GpgME::Context::EncryptFile; -}; - -} - -#endif // __QGPGME_SIGNENCRYPTJOB_P_H__ diff --git a/lang/qt/src/signjob.cpp b/lang/qt/src/signjob.cpp deleted file mode 100644 index be15051b..00000000 --- a/lang/qt/src/signjob.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - signjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "signjob.h" -#include "signjob_p.h" - -using namespace QGpgME; - -SignJob::SignJob(QObject *parent) - : Job{parent} -{ -} - -SignJob::~SignJob() = default; - -void SignJob::setSigners(const std::vector<GpgME::Key> &signers) -{ - auto d = jobPrivate<SignJobPrivate>(this); - d->m_signers = signers; -} - -std::vector<GpgME::Key> SignJob::signers() const -{ - auto d = jobPrivate<SignJobPrivate>(this); - return d->m_signers; -} - -void SignJob::setInputFile(const QString &path) -{ - auto d = jobPrivate<SignJobPrivate>(this); - d->m_inputFilePath = path; -} - -QString SignJob::inputFile() const -{ - auto d = jobPrivate<SignJobPrivate>(this); - return d->m_inputFilePath; -} - -void SignJob::setOutputFile(const QString &path) -{ - auto d = jobPrivate<SignJobPrivate>(this); - d->m_outputFilePath = path; -} - -QString SignJob::outputFile() const -{ - auto d = jobPrivate<SignJobPrivate>(this); - return d->m_outputFilePath; -} - -void SignJob::setSigningFlags(GpgME::SignatureMode flags) -{ - auto d = jobPrivate<SignJobPrivate>(this); - d->m_signingFlags = static_cast<GpgME::SignatureMode>(flags | GpgME::SignFile); -} - -GpgME::SignatureMode SignJob::signingFlags() const -{ - auto d = jobPrivate<SignJobPrivate>(this); - return d->m_signingFlags; -} - -void SignJob::setAppendSignature(bool append) -{ - auto d = jobPrivate<SignJobPrivate>(this); - d->m_appendSignature = append; -} - -bool SignJob::appendSignatureEnabled() const -{ - auto d = jobPrivate<SignJobPrivate>(this); - return d->m_appendSignature; -} - -#include "signjob.moc" diff --git a/lang/qt/src/signjob.h b/lang/qt/src/signjob.h deleted file mode 100644 index be29f4d8..00000000 --- a/lang/qt/src/signjob.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - signjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004, 2007 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_SIGNJOB_H__ -#define __KLEO_SIGNJOB_H__ - -#include "job.h" - -#include <gpgme++/global.h> - -#include <vector> -#include <memory> - -class QByteArray; -class QIODevice; - -namespace GpgME -{ -class Error; -class Key; -class SigningResult; -} - -namespace QGpgME -{ - -/** - @short An abstract base class for asynchronous signing - - To use a SignJob, first obtain an instance from the CryptoBackend - implementation, connect the progress() and result() signals to - suitable slots and then start the signing with a call to - start(). This call might fail, in which case the SignJob instance - will have scheduled it's own destruction with a call to - QObject::deleteLater(). - - Alternatively, the job can be started with startIt() after setting - an input file and an output file and, optionally, signers or flags. - If the job is started this way then the backend reads the input and - writes the output directly from/to the specified input file and output - file. In this case the signature value of the result signal will always - be empty. This direct IO mode is currently only supported for OpenPGP. - Note that startIt() does not schedule the job's destruction if starting - the job failed. - - After result() is emitted, the SignJob will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT SignJob : public Job -{ - Q_OBJECT -protected: - explicit SignJob(QObject *parent); -public: - ~SignJob() override; - - /** - * Sets the keys to use for signing. - * - * Used if the job is started with startIt(). - */ - void setSigners(const std::vector<GpgME::Key> &signers); - std::vector<GpgME::Key> signers() const; - - /** - * Sets the path of the file to sign. - * - * Used if the job is started with startIt(). - */ - void setInputFile(const QString &path); - QString inputFile() const; - - /** - * Sets the path of the file to write the signing result to. - * - * Used if the job is started with startIt(). - * - * \note If a file with this path exists, then the job will fail, i.e. you - * need to delete an existing file that shall be overwritten before you - * start the job. If you create a detached signature then you can tell - * the job to append the new detached signature to an existing file. - */ - void setOutputFile(const QString &path); - QString outputFile() const; - - /** - * Sets the flags to use for signing. - * - * Defaults to \c SignFile. - * - * Used if the job is started with startIt(). The \c SignFile flag is - * always assumed set. - */ - void setSigningFlags(GpgME::SignatureMode flags); - GpgME::SignatureMode signingFlags() const; - - /** - * If @c true then a new detached signature is appended to an already - * existing detached signature. - * - * Defaults to \c false. - * - * Used if the job is started with startIt(). - */ - void setAppendSignature(bool append); - bool appendSignatureEnabled() const; - - /** - Starts the signing operation. \a signers is the list of keys to - sign \a plainText with. Empty (null) keys are ignored. - */ - virtual GpgME::Error start(const std::vector<GpgME::Key> &signers, - const QByteArray &plainText, - GpgME::SignatureMode mode) = 0; - - /*! - \overload - - If \a signature is non-null the signature is written - there. Otherwise, it will be delivered in the second argument of - result(). - */ - virtual void start(const std::vector<GpgME::Key> &signers, - const std::shared_ptr<QIODevice> &plainText, - const std::shared_ptr<QIODevice> &signature, - GpgME::SignatureMode mode) = 0; - - virtual GpgME::SigningResult exec(const std::vector<GpgME::Key> &signers, - const QByteArray &plainText, - GpgME::SignatureMode mode, - QByteArray &signature) = 0; - - /*! - This is a hack to request BASE64 output (instead of whatever - comes out normally). - */ - virtual void setOutputIsBase64Encoded(bool) = 0; - -Q_SIGNALS: - void result(const GpgME::SigningResult &result, const QByteArray &signature, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __KLEO_SIGNJOB_H__ diff --git a/lang/qt/src/signjob_p.h b/lang/qt/src/signjob_p.h deleted file mode 100644 index ec974332..00000000 --- a/lang/qt/src/signjob_p.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - signjob_p.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_SIGNJOB_P_H__ -#define __QGPGME_SIGNJOB_P_H__ - -#include "job_p.h" - -#include <gpgme++/key.h> - -namespace QGpgME -{ - -struct SignJobPrivate : public JobPrivate -{ - // used by startIt() - std::vector<GpgME::Key> m_signers; - QString m_inputFilePath; - QString m_outputFilePath; - GpgME::SignatureMode m_signingFlags = GpgME::SignFile; - bool m_appendSignature = false; -}; - -} - -#endif // __QGPGME_SIGNJOB_P_H__ diff --git a/lang/qt/src/signkeyjob.h b/lang/qt/src/signkeyjob.h deleted file mode 100644 index d0e90c22..00000000 --- a/lang/qt/src/signkeyjob.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - signkeyjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_SIGNKEYJOB_H__ -#define __KLEO_SIGNKEYJOB_H__ - -#include "job.h" - -#include <vector> - -namespace GpgME -{ -class Error; -class Key; -enum class TrustSignatureTrust : char; -} - -class QDate; -class QString; - -namespace QGpgME -{ - -/** - @short An abstract base class to sign keys asynchronously - - To use a SignKeyJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the job with a call - to start(). This call might fail, in which case the ChangeExpiryJob - instance will have scheduled it's own destruction with a call to - QObject::deleteLater(). - - After result() is emitted, the SignKeyJob will schedule it's own - destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT SignKeyJob : public Job -{ - Q_OBJECT -protected: - explicit SignKeyJob(QObject *parent); -public: - ~SignKeyJob(); - - /** - Starts the key signing operation. \a key is the key to sign. - @param keyToSign the key to be signed - */ - virtual GpgME::Error start(const GpgME::Key &keyToSign) = 0; - - /** - * If explicitly specified, only the listed user IDs will be signed. Otherwise all user IDs - * are signed. - * @param idsToSign list of user ID indexes (of the key to be signed). - */ - virtual void setUserIDsToSign(const std::vector<unsigned int> &idsToSign) = 0; - - /** - * sets the check level - * @param checkLevel the check level, ranges from 0 (no claim) and 3 (extensively checked), - * default is 0 - */ - virtual void setCheckLevel(unsigned int checkLevel) = 0; - - /** - * sets whether the signature should be exportable, or local only. - * default is local. - */ - virtual void setExportable(bool exportable) = 0; - - /** - * sets an alternate signing key - */ - virtual void setSigningKey(const GpgME::Key &key) = 0; - - /** - * if set, the created signature won't be revocable. By default signatures - * can be revoked. - */ - virtual void setNonRevocable(bool nonRevocable) = 0; - - /** - * Set this if it is ok to overwrite an existing signature. In that - * case the context has to have the flag "extended-edit" set to 1 through - * Context::setFlag before calling edit. - * - * Not pure virtual for ABI compatibility. - **/ - virtual void setDupeOk(bool) {} - - /** - * Add a remark to the signature. This uses [email protected] as a notation. - * - * Not pure virtual for ABI compatibility. - **/ - virtual void setRemark(const QString &) {} - - /** - * If set, then the created signature will be a trust signature. By default, - * no trust signatures are created. - * - * @a trust is the amount of trust to put into the signed key, either - * @c TrustSignatureTrust::Partial or @c TrustSignatureTrust::Complete. - * @a depth is the level of the trust signature. Values between 0 and 255 are - * allowed. Level 0 has the same meaning as an ordinary validity signature. - * Level 1 means that the signed key is asserted to be a valid trusted - * introducer. Level n >= 2 means that the signed key is asserted to be - * trusted to issue level n-1 trust signatures, i.e., that it is a "meta - * introducer". - * @a scope is a domain name that limits the scope of trust of the signed key - * to user IDs with email addresses matching the domain (or a subdomain). - * - * Not pure virtual for ABI compatibility. - **/ - virtual void setTrustSignature(GpgME::TrustSignatureTrust trust, unsigned short depth, const QString &scope) { Q_UNUSED(trust); Q_UNUSED(depth); Q_UNUSED(scope); } - - /** - * Sets the expiration date of the key signature to @a expiration. By default, - * key signatures do not expire. - * - * Note: Expiration dates after 2106-02-05 will be set to 2106-02-05. - * - * Not pure virtual for ABI compatibility. - **/ - virtual void setExpirationDate(const QDate &expiration) { Q_UNUSED(expiration); } - -Q_SIGNALS: - void result(const GpgME::Error &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __KLEO_SIGNKEYJOB_H__ diff --git a/lang/qt/src/specialjob.h b/lang/qt/src/specialjob.h deleted file mode 100644 index 5690d2e0..00000000 --- a/lang/qt/src/specialjob.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - specialjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_SPECIALJOB_H__ -#define __KLEO_SPECIALJOB_H__ - -#include "job.h" -#include "qgpgme_export.h" - -namespace GpgME -{ -class Error; -} - -namespace QGpgME -{ - -/** - @short An abstract base class for protocol-specific jobs - - To use a SpecialJob, first obtain an instance from the - CryptoBackend implementation, connect progress() and result() - signals to suitable slots and then start the job with a call to - start(). This call might fail, in which case the SpecialJob - instance will have schedules its own destruction with a call to - QObject::deleteLater(). - - After result() is emitted, the SpecialJob will schedule its own - destruction by calling QObject::deleteLater(). - - Parameters are set using the Qt property system. More general, or - constructor parameters are given in the call to - QGpgME::Protocol::specialJob(). - - The result is made available through the result signal, and - through the read-only result property, the latter of which needs - to be defined in each SpecialJob subclass. -*/ -class QGPGME_EXPORT SpecialJob : public Job -{ - Q_OBJECT -protected: - explicit SpecialJob(QObject *parent); - -public: - ~SpecialJob(); - - /** - Starts the special operation. - */ - virtual GpgME::Error start() = 0; - - virtual GpgME::Error exec() = 0; - -Q_SIGNALS: - void result(const GpgME::Error &result, const QVariant &data); -}; - -} - -#endif // __KLEO_SPECIALJOB_H__ diff --git a/lang/qt/src/threadedjobmixin.cpp b/lang/qt/src/threadedjobmixin.cpp deleted file mode 100644 index c0485325..00000000 --- a/lang/qt/src/threadedjobmixin.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* - threadedjobmixin.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "threadedjobmixin.h" - -#include "dataprovider.h" -#include "util.h" - -#include <gpgme++/data.h> - -#include <QString> -#include <QStringList> -#include <QByteArray> - - -#include <algorithm> -#include <iterator> - -using namespace QGpgME; -using namespace GpgME; - -static QString stringFromGpgOutput(const QByteArray &ba) -{ -#ifdef Q_OS_WIN - return QString::fromUtf8(ba); -#else - return QString::fromLocal8Bit(ba); -#endif -} - -static QString markupDiagnostics(const QString &data) -{ - // First ensure that we don't have html in the diag. - QString ret = QStringLiteral("<pre>%1</pre>").arg(data.toHtmlEscaped()); - - return ret; -} - -static const unsigned int CMSAuditLogFlags = Context::AuditLogWithHelp | Context::HtmlAuditLog; -static const unsigned int OpenPGPAuditLogFlags = Context::DiagnosticAuditLog; - -QString _detail::audit_log_as_html(Context *ctx, GpgME::Error &err) -{ - assert(ctx); - QGpgME::QByteArrayDataProvider dp; - Data data(&dp); - assert(!data.isNull()); - - if (ctx->protocol() == OpenPGP) { - if ((err = ctx->getAuditLog(data, OpenPGPAuditLogFlags))) { - return errorAsString(err); - } - const QByteArray ba = dp.data(); - return markupDiagnostics(stringFromGpgOutput(ba)); - } - - if (ctx->protocol() == CMS) { - if ((err = ctx->lastError())) { - if ((err = ctx->getAuditLog(data, Context::DiagnosticAuditLog))) { - return errorAsString(err); - } - const QByteArray ba = dp.data(); - return markupDiagnostics(stringFromGpgOutput(ba)); - } else if ((err = ctx->getAuditLog(data, CMSAuditLogFlags))) { - return errorAsString(err); - } - return QString::fromUtf8(dp.data()); - } - - return QStringLiteral("Unsupported protocol for Audit Log"); -} - -static QList<QByteArray> from_sl(const QStringList &sl) -{ - QList<QByteArray> result; - for (const QString &str : sl) { - result.append(str.toUtf8()); - } - -#if 0 - std::transform(sl.begin(), sl.end(), std::back_inserter(result), - mem_fn(static_cast<QByteArray()const>(&QString::toUtf8))); -#endif - return result; -} - -static QList<QByteArray> single(const QByteArray &ba) -{ - QList<QByteArray> result; - result.push_back(ba); - return result; -} - -_detail::PatternConverter::PatternConverter(const QByteArray &ba) - : m_list(single(ba)), m_patterns(nullptr) {} -_detail::PatternConverter::PatternConverter(const QString &s) - : m_list(single(s.toUtf8())), m_patterns(nullptr) {} -_detail::PatternConverter::PatternConverter(const QList<QByteArray> &lba) - : m_list(lba), m_patterns(nullptr) {} -_detail::PatternConverter::PatternConverter(const QStringList &sl) - : m_list(from_sl(sl)), m_patterns(nullptr) {} - -const char **_detail::PatternConverter::patterns() const -{ - if (!m_patterns) { - m_patterns = new const char *[ m_list.size() + 1 ]; - const char **end = std::transform(m_list.begin(), m_list.end(), m_patterns, - std::mem_fn(&QByteArray::constData)); - *end = nullptr; - } - return m_patterns; -} - -_detail::PatternConverter::~PatternConverter() -{ - delete [] m_patterns; -} diff --git a/lang/qt/src/threadedjobmixin.h b/lang/qt/src/threadedjobmixin.h deleted file mode 100644 index 7a18aa4d..00000000 --- a/lang/qt/src/threadedjobmixin.h +++ /dev/null @@ -1,302 +0,0 @@ -/* - threadedjobmixin.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2008 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_THREADEDJOBMIXING_H__ -#define __QGPGME_THREADEDJOBMIXING_H__ - -#include <QMutex> -#include <QMutexLocker> -#include <QThread> -#include <QString> -#include <QIODevice> - -#include <gpgme++/context.h> -#include <gpgme++/interfaces/progressprovider.h> - -#include "job.h" - -#include <cassert> -#include <functional> - -namespace QGpgME -{ -namespace _detail -{ - -QString audit_log_as_html(GpgME::Context *ctx, GpgME::Error &err); - -class PatternConverter -{ - const QList<QByteArray> m_list; - mutable const char **m_patterns; -public: - explicit PatternConverter(const QByteArray &ba); - explicit PatternConverter(const QString &s); - explicit PatternConverter(const QList<QByteArray> &lba); - explicit PatternConverter(const QStringList &sl); - ~PatternConverter(); - - const char **patterns() const; -}; - -class ToThreadMover -{ - QObject *const m_object; - QThread *const m_thread; -public: - ToThreadMover(QObject *o, QThread *t) : m_object(o), m_thread(t) {} - ToThreadMover(QObject &o, QThread *t) : m_object(&o), m_thread(t) {} - ToThreadMover(const std::shared_ptr<QObject> &o, QThread *t) : m_object(o.get()), m_thread(t) {} - ~ToThreadMover() - { - if (m_object && m_thread) { - m_object->moveToThread(m_thread); - } - } -}; - -template <typename T_result> -class Thread : public QThread -{ -public: - explicit Thread(QObject *parent = nullptr) : QThread(parent) {} - - void setFunction(const std::function<T_result()> &function) - { - const QMutexLocker locker(&m_mutex); - m_function = function; - } - - bool hasFunction() - { - const QMutexLocker locker(&m_mutex); - return static_cast<bool>(m_function); - } - - T_result result() const - { - const QMutexLocker locker(&m_mutex); - return m_result; - } - -private: - void run() override { - const QMutexLocker locker(&m_mutex); - m_result = m_function(); - } -private: - mutable QMutex m_mutex; - std::function<T_result()> m_function; - T_result m_result; -}; - -template <typename T_base, typename T_result = std::tuple<GpgME::Error, QString, GpgME::Error> > -class ThreadedJobMixin : public T_base, public GpgME::ProgressProvider -{ -public: - typedef ThreadedJobMixin<T_base, T_result> mixin_type; - typedef T_result result_type; - - void run() - { - Q_ASSERT(m_thread.hasFunction() && "Call setWorkerFunction() before run()"); - m_thread.start(); - } - -protected: - static_assert(std::tuple_size<T_result>::value > 2, - "Result tuple too small"); - static_assert(std::is_same < - typename std::tuple_element < - std::tuple_size<T_result>::value - 2, - T_result - >::type, - QString - >::value, - "Second to last result type not a QString"); - static_assert(std::is_same < - typename std::tuple_element < - std::tuple_size<T_result>::value - 1, - T_result - >::type, - GpgME::Error - >::value, - "Last result type not a GpgME::Error"); - - explicit ThreadedJobMixin(GpgME::Context *ctx) - : T_base(nullptr), m_ctx(ctx), m_thread(), m_auditLog(), m_auditLogError() - { - } - - void lateInitialization() - { - assert(m_ctx); - QObject::connect(&m_thread, &QThread::finished, this, - &mixin_type::slotFinished); - m_ctx->setProgressProvider(this); - QGpgME::g_context_map.insert(this, m_ctx.get()); - } - - ~ThreadedJobMixin() - { - QGpgME::g_context_map.remove(this); - } - - template <typename T_binder> - void setWorkerFunction(const T_binder &func) - { - m_thread.setFunction([this, func]() { return func(this->context()); }); - } - -public: - template <typename T_binder> - void run(const T_binder &func) - { - m_thread.setFunction(std::bind(func, this->context())); - m_thread.start(); - } - template <typename T_binder> - void run(const T_binder &func, const std::shared_ptr<QIODevice> &io) - { - if (io) { - io->moveToThread(&m_thread); - } - // the arguments passed here to the functor are stored in a QThread, and are not - // necessarily destroyed (living outside the UI thread) at the time the result signal - // is emitted and the signal receiver wants to clean up IO devices. - // To avoid such races, we pass std::weak_ptr's to the functor. - m_thread.setFunction(std::bind(func, this->context(), this->thread(), std::weak_ptr<QIODevice>(io))); - m_thread.start(); - } - template <typename T_binder> - void run(const T_binder &func, const std::shared_ptr<QIODevice> &io1, const std::shared_ptr<QIODevice> &io2) - { - if (io1) { - io1->moveToThread(&m_thread); - } - if (io2) { - io2->moveToThread(&m_thread); - } - // the arguments passed here to the functor are stored in a QThread, and are not - // necessarily destroyed (living outside the UI thread) at the time the result signal - // is emitted and the signal receiver wants to clean up IO devices. - // To avoid such races, we pass std::weak_ptr's to the functor. - m_thread.setFunction(std::bind(func, this->context(), this->thread(), std::weak_ptr<QIODevice>(io1), std::weak_ptr<QIODevice>(io2))); - m_thread.start(); - } - -protected: - GpgME::Context *context() const - { - return m_ctx.get(); - } - - virtual void resultHook(const result_type &) {} - - void slotFinished() - { - const T_result r = m_thread.result(); - m_auditLog = std::get < std::tuple_size<T_result>::value - 2 > (r); - m_auditLogError = std::get < std::tuple_size<T_result>::value - 1 > (r); - resultHook(r); - Q_EMIT this->done(); - doEmitResult(r); - this->deleteLater(); - } - void slotCancel() override { - if (m_ctx) - { - m_ctx->cancelPendingOperation(); - } - } - QString auditLogAsHtml() const override - { - return m_auditLog; - } - GpgME::Error auditLogError() const override - { - return m_auditLogError; - } - void showProgress(const char *what, - int type, int current, int total) override { - QMetaObject::invokeMethod(this, [this, current, total]() { - Q_EMIT this->jobProgress(current, total); - }, Qt::QueuedConnection); - const QString what_ = QString::fromUtf8(what); - QMetaObject::invokeMethod(this, [this, what_, type, current, total]() { - Q_EMIT this->rawProgress(what_, type, current, total); - }, Qt::QueuedConnection); - QMetaObject::invokeMethod(this, [this, what_, current, total]() { - QT_WARNING_PUSH - QT_WARNING_DISABLE_DEPRECATED - Q_EMIT this->progress(what_, current, total); - QT_WARNING_POP - }, Qt::QueuedConnection); - } -private: - template <typename T1, typename T2> - void doEmitResult(const std::tuple<T1, T2> &tuple) - { - Q_EMIT this->result(std::get<0>(tuple), std::get<1>(tuple)); - } - - template <typename T1, typename T2, typename T3> - void doEmitResult(const std::tuple<T1, T2, T3> &tuple) - { - Q_EMIT this->result(std::get<0>(tuple), std::get<1>(tuple), std::get<2>(tuple)); - } - - template <typename T1, typename T2, typename T3, typename T4> - void doEmitResult(const std::tuple<T1, T2, T3, T4> &tuple) - { - Q_EMIT this->result(std::get<0>(tuple), std::get<1>(tuple), std::get<2>(tuple), std::get<3>(tuple)); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5> - void doEmitResult(const std::tuple<T1, T2, T3, T4, T5> &tuple) - { - Q_EMIT this->result(std::get<0>(tuple), std::get<1>(tuple), std::get<2>(tuple), std::get<3>(tuple), std::get<4>(tuple)); - } - -private: - std::shared_ptr<GpgME::Context> m_ctx; - Thread<T_result> m_thread; - QString m_auditLog; - GpgME::Error m_auditLogError; -}; - -} -} - -#endif /* __QGPGME_THREADEDJOBMIXING_H__ */ diff --git a/lang/qt/src/tofupolicyjob.h b/lang/qt/src/tofupolicyjob.h deleted file mode 100644 index 90debaef..00000000 --- a/lang/qt/src/tofupolicyjob.h +++ /dev/null @@ -1,77 +0,0 @@ -/* tofupolicyjob.h - - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifndef QGPGME_TOFUPOLICYJOB_H -#define QGPGME_TOFUPOLICYJOB_H - -#include "job.h" - -#include "qgpgme_export.h" - -#include <gpgme++/tofuinfo.h> - -namespace GpgME -{ - class Key; -} // namespace GpgME - -namespace QGpgME { - -/** - * Set the TOFU Policy for a key - */ -class QGPGME_EXPORT TofuPolicyJob: public Job -{ - Q_OBJECT -protected: - explicit TofuPolicyJob(QObject *parent); -public: - ~TofuPolicyJob(); - - - /* Set the policy to \a policy see the gpgme manual for - * policy explanations. */ - virtual void start(const GpgME::Key &key, GpgME::TofuInfo::Policy policy) = 0; - - virtual GpgME::Error exec(const GpgME::Key &key, GpgME::TofuInfo::Policy policy) = 0; - -Q_SIGNALS: - /* Result of the operation - * - * As usual auditLogAsHtml and auditLogError can be ignored. - **/ - void result(const GpgME::Error &error, - const QString &auditLogAsHtml = QString(), - const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif diff --git a/lang/qt/src/util.cpp b/lang/qt/src/util.cpp deleted file mode 100644 index 51ae9589..00000000 --- a/lang/qt/src/util.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* - util.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "util.h" - -#include "cleaner.h" -#include "qgpgme_debug.h" - -#include <QFile> -#include <QFileInfo> -#include <QRandomGenerator> - -#include <gpgme++/key.h> - -#include <algorithm> -#include <functional> - -std::vector<std::string> toStrings(const QStringList &l) -{ - std::vector<std::string> v; - v.reserve(l.size()); - std::transform(std::begin(l), std::end(l), - std::back_inserter(v), - std::mem_fn(&QString::toStdString)); - return v; -} - -QStringList toFingerprints(const std::vector<GpgME::Key> &keys) -{ - QStringList fprs; - fprs.reserve(keys.size()); - std::transform(std::begin(keys), std::end(keys), std::back_inserter(fprs), [](const GpgME::Key &k) { - return QString::fromLatin1(k.primaryFingerprint()); - }); - return fprs; -} - -/** - * Generates a string of random characters for the file names of temporary files. - * Never use this for generating passwords or similar use cases requiring highly - * secure random data. - */ -static QString getRandomCharacters(const int count) -{ - if (count < 0) { - return {}; - } - - QString randomChars; - randomChars.reserve(count); - - do { - // get a 32-bit random number to generate up to 5 random characters from - // the set {A-Z, a-z, 0-9}; set the highest bit for the break condition - for (quint32 rnd = QRandomGenerator::global()->generate() | (1 << 31); rnd > 3; rnd = rnd >> 6) - { - // take the last 6 bits; ignore 62 and 63 - const char ch = rnd & ((1 << 6) - 1); - if (ch < 26) { - randomChars += QLatin1Char(ch + 'A'); - } else if (ch < 26 + 26) { - randomChars += QLatin1Char(ch - 26 + 'a'); - } else if (ch < 26 + 26 + 10) { - randomChars += QLatin1Char(ch - 26 - 26 + '0'); - } - if (randomChars.size() >= count) { - break; - } - } - } while (randomChars.size() < count); - - return randomChars; -} - -/** - * Creates a temporary file name with extension \c .part for the given file name - * \a fileName. The function makes sure that the created file name is not in use - * at the time the file name is chosen. - * - * Example: For the file name "this.is.an.archive.tar.gpg" the temporary file name - * "this.YHgf2tEl.is.an.archive.tar.gpg.part" could be returned. - */ -static QString createPartFileName(const QString &fileName) -{ - static const int maxAttempts = 10; - - const QFileInfo fi{fileName}; - const QString path = fi.path(); // path without trailing '/' - const QString baseName = fi.baseName(); - const QString suffix = fi.completeSuffix(); - for (int attempt = 0; attempt < maxAttempts; ++attempt) { - const QString candidate = (path + QLatin1Char('/') - + baseName + QLatin1Char('.') - + getRandomCharacters(8) + QLatin1Char('.') - + suffix - + QLatin1String(".part")); - if (!QFile::exists(candidate)) { - return candidate; - } - } - - qCWarning(QGPGME_LOG) << __func__ << "- Failed to create temporary file name for" << fileName; - return {}; -} - -PartialFileGuard::PartialFileGuard(const QString &fileName) - : mFileName{fileName} - , mTempFileName{createPartFileName(fileName)} -{ - qCDebug(QGPGME_LOG) << __func__ << "- Using temporary file name" << mTempFileName; -} - -PartialFileGuard::~PartialFileGuard() -{ - if (!mTempFileName.isEmpty()) { - Cleaner::removeFile(mTempFileName); - } -} - -QString PartialFileGuard::tempFileName() const -{ - return mTempFileName; -} - -bool PartialFileGuard::commit() -{ - if (mTempFileName.isEmpty()) { - qCWarning(QGPGME_LOG) << "PartialFileGuard::commit: Called more than once"; - return false; - } - const bool success = QFile::rename(mTempFileName, mFileName); - if (success) { - qCDebug(QGPGME_LOG) << __func__ << "- Renamed" << mTempFileName << "to" << mFileName; - mTempFileName.clear(); - } else { - qCDebug(QGPGME_LOG) << __func__ << "- Renaming" << mTempFileName << "to" << mFileName << "failed"; - } - return success; -} diff --git a/lang/qt/src/util.h b/lang/qt/src/util.h deleted file mode 100644 index fcd1187e..00000000 --- a/lang/qt/src/util.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - util.h - some internal helpers - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_UTIL_H__ -#define __QGPGME_UTIL_H__ - -#include <QStringList> - -#include <gpgme++/error.h> - -#include <gpgme.h> - -#include <string> -#include <vector> - -namespace GpgME -{ -class Key; -} - -static inline gpgme_error_t make_error(gpgme_err_code_t code) -{ - return gpgme_err_make((gpgme_err_source_t)22, code); -} - -static inline QString errorAsString(const GpgME::Error &error) -{ -#ifdef Q_OS_WIN - return QString::fromStdString(error.asStdString()); -#else - return QString::fromLocal8Bit(error.asStdString().c_str()); -#endif -} - -std::vector<std::string> toStrings(const QStringList &l); - -QStringList toFingerprints(const std::vector<GpgME::Key> &keys); - -/** - * Helper for using a temporary "part" file for writing a result to, similar - * to what browsers do when downloading files. - * On success, you commit() which renames the temporary file to the - * final file name. Otherwise, you do nothing and let the helper remove the - * temporary file on destruction. - */ -class PartialFileGuard -{ -public: - explicit PartialFileGuard(const QString &fileName); - ~PartialFileGuard(); - - QString tempFileName() const; - - bool commit(); - -private: - QString mFileName; - QString mTempFileName; -}; - -#endif // __QGPGME_UTIL_H__ diff --git a/lang/qt/src/verifydetachedjob.cpp b/lang/qt/src/verifydetachedjob.cpp deleted file mode 100644 index 68fe7f21..00000000 --- a/lang/qt/src/verifydetachedjob.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - verifydetachedjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2024 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "verifydetachedjob.h" -#include "verifydetachedjob_p.h" - -using namespace QGpgME; - -VerifyDetachedJob::VerifyDetachedJob(QObject *parent) - : Job{parent} -{ -} - -VerifyDetachedJob::~VerifyDetachedJob() = default; - -void VerifyDetachedJob::setProcessAllSignatures (bool processAll) -{ - auto d = jobPrivate<VerifyDetachedJobPrivate>(this); - d->m_processAllSignatures = processAll; -} - -bool VerifyDetachedJob::processAllSignatures() const -{ - auto d = jobPrivate<VerifyDetachedJobPrivate>(this); - return d->m_processAllSignatures; -} - -void VerifyDetachedJob::setSignatureFile(const QString &path) -{ - auto d = jobPrivate<VerifyDetachedJobPrivate>(this); - d->m_signatureFilePath = path; -} - -QString VerifyDetachedJob::signatureFile() const -{ - auto d = jobPrivate<VerifyDetachedJobPrivate>(this); - return d->m_signatureFilePath; -} - -void VerifyDetachedJob::setSignedFile(const QString &path) -{ - auto d = jobPrivate<VerifyDetachedJobPrivate>(this); - d->m_signedFilePath = path; -} - -QString VerifyDetachedJob::signedFile() const -{ - auto d = jobPrivate<VerifyDetachedJobPrivate>(this); - return d->m_signedFilePath; -} - -#include "verifydetachedjob.moc" diff --git a/lang/qt/src/verifydetachedjob.h b/lang/qt/src/verifydetachedjob.h deleted file mode 100644 index b5b668e3..00000000 --- a/lang/qt/src/verifydetachedjob.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - verifydetachedjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004, 2007 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_VERIFYDETACHEDJOB_H__ -#define __KLEO_VERIFYDETACHEDJOB_H__ - -#include "job.h" - -#include <memory> - -class QByteArray; -class QIODevice; - -namespace GpgME -{ -class Error; -class VerificationResult; -} - -namespace QGpgME -{ - -/** - @short An abstract base class for asynchronous verification of detached signatures - - To use a VerifyDetachedJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the verification with a - call to start(). This call might fail, in which case the - VerifyDetachedJob instance will have scheduled it's own - destruction with a call to QObject::deleteLater(). - - Alternatively, the job can be started with startIt() after setting - the input files. If the job is started this way then the backend reads the - input directly from the specified input files. This direct IO mode is - currently only supported for OpenPGP. Note that startIt() does not schedule - the job's destruction if starting the job failed. - - After result() is emitted, the VerifyDetachedJob will schedule - it's own destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT VerifyDetachedJob : public Job -{ - Q_OBJECT -protected: - explicit VerifyDetachedJob(QObject *parent); -public: - ~VerifyDetachedJob() override; - - /** - * Enables processing of all signatures if \a processAll is true. - * - * By default, gpg (in batch mode used by GpgME) stops the verification of - * data signatures when a bad signature is encountered. This can be changed - * by setting this flag. It's equivalent to setting the context flag - * "proc-all-sigs". - * - * This is only supported for OpenPGP and requires GnuPG 2.2.45, 2.4.6, or - * 2.5.1. - */ - void setProcessAllSignatures(bool processAll); - bool processAllSignatures() const; - - /** - * Sets the path of the file containing the signature to verify. - * - * Used if the job is started with startIt(). - */ - void setSignatureFile(const QString &path); - QString signatureFile() const; - - /** - * Sets the path of the file containing the signed data to verify. - * - * Used if the job is started with startIt(). - */ - void setSignedFile(const QString &path); - QString signedFile() const; - - /** - Starts the verification operation. \a signature contains the - signature data, while \a signedData contains the data over - which the signature was made. - */ - virtual GpgME::Error start(const QByteArray &signature, - const QByteArray &signedData) = 0; - - virtual void start(const std::shared_ptr<QIODevice> &signature, const std::shared_ptr<QIODevice> &signedData) = 0; - - virtual GpgME::VerificationResult exec(const QByteArray &signature, - const QByteArray &signedData) = 0; - -Q_SIGNALS: - void result(const GpgME::VerificationResult &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __KLEO_VERIFYDETACHEDJOB_H__ diff --git a/lang/qt/src/verifydetachedjob_p.h b/lang/qt/src/verifydetachedjob_p.h deleted file mode 100644 index cc594210..00000000 --- a/lang/qt/src/verifydetachedjob_p.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - verifydetachedjob_p.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2024 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_VERIFYDETACHEDJOB_P_H__ -#define __QGPGME_VERIFYDETACHEDJOB_P_H__ - -#include "job_p.h" - -namespace QGpgME -{ - -struct VerifyDetachedJobPrivate : public JobPrivate -{ - QString m_signatureFilePath; - QString m_signedFilePath; - bool m_processAllSignatures = false; -}; - -} - -#endif // __QGPGME_VERIFYDETACHEDJOB_P_H__ diff --git a/lang/qt/src/verifyopaquejob.cpp b/lang/qt/src/verifyopaquejob.cpp deleted file mode 100644 index dced4595..00000000 --- a/lang/qt/src/verifyopaquejob.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - verifyopaquejob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "verifyopaquejob.h" -#include "verifyopaquejob_p.h" - -using namespace QGpgME; - -VerifyOpaqueJob::VerifyOpaqueJob(QObject *parent) - : Job{parent} -{ -} - -VerifyOpaqueJob::~VerifyOpaqueJob() = default; - -void VerifyOpaqueJob::setProcessAllSignatures (bool processAll) -{ - auto d = jobPrivate<VerifyOpaqueJobPrivate>(this); - d->m_processAllSignatures = processAll; -} - -bool VerifyOpaqueJob::processAllSignatures() const -{ - auto d = jobPrivate<VerifyOpaqueJobPrivate>(this); - return d->m_processAllSignatures; -} - -void VerifyOpaqueJob::setInputFile(const QString &path) -{ - auto d = jobPrivate<VerifyOpaqueJobPrivate>(this); - d->m_inputFilePath = path; -} - -QString VerifyOpaqueJob::inputFile() const -{ - auto d = jobPrivate<VerifyOpaqueJobPrivate>(this); - return d->m_inputFilePath; -} - -void VerifyOpaqueJob::setOutputFile(const QString &path) -{ - auto d = jobPrivate<VerifyOpaqueJobPrivate>(this); - d->m_outputFilePath = path; -} - -QString VerifyOpaqueJob::outputFile() const -{ - auto d = jobPrivate<VerifyOpaqueJobPrivate>(this); - return d->m_outputFilePath; -} - -#include "verifyopaquejob.moc" diff --git a/lang/qt/src/verifyopaquejob.h b/lang/qt/src/verifyopaquejob.h deleted file mode 100644 index e006886b..00000000 --- a/lang/qt/src/verifyopaquejob.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - verifyopaquejob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2004, 2007 Klarälvdalens Datakonsult AB - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEO_VERIFYOPAQUEJOB_H__ -#define __KLEO_VERIFYOPAQUEJOB_H__ - -#include "job.h" - -#include <memory> - -class QByteArray; -class QIODevice; - -namespace GpgME -{ -class Error; -class VerificationResult; -} - -namespace QGpgME -{ - -/** - @short An abstract base class for asynchronous verification of opaque signatures - - To use a VerifyOpaqueJob, first obtain an instance from the - CryptoBackend implementation, connect the progress() and result() - signals to suitable slots and then start the verification with a - call to start(). This call might fail, in which case the - VerifyOpaqueJob instance will have scheduled it's own - destruction with a call to QObject::deleteLater(). - - Alternatively, the job can be started with startIt() after setting - an input file and an output file. If the job is started this way then - the backend reads the input and writes the output directly from/to the - specified input file and output file. In this case the plainText value of - the result signal will always be empty. This direct IO mode is currently - only supported for OpenPGP. Note that startIt() does not schedule the job's - destruction if starting the job failed. - - After result() is emitted, the VerifyOpaqueJob will schedule - it's own destruction by calling QObject::deleteLater(). -*/ -class QGPGME_EXPORT VerifyOpaqueJob : public Job -{ - Q_OBJECT -protected: - explicit VerifyOpaqueJob(QObject *parent); -public: - ~VerifyOpaqueJob() override; - - /** - * Enables processing of all signatures if \a processAll is true. - * - * By default, gpg (in batch mode used by GpgME) stops the verification of - * data signatures when a bad signature is encountered. This can be changed - * by setting this flag. It's equivalent to setting the context flag - * "proc-all-sigs". - * - * This is only supported for OpenPGP and requires GnuPG 2.2.45, 2.4.6, or - * 2.5.1. - */ - void setProcessAllSignatures(bool processAll); - bool processAllSignatures() const; - - /** - * Sets the path of the file to verify. - * - * Used if the job is started with startIt(). - */ - void setInputFile(const QString &path); - QString inputFile() const; - - /** - * Sets the path of the file to write the result to. - * - * Used if the job is started with startIt(). - * - * \note If a file with this path exists, then the job will fail, i.e. you - * need to delete an existing file that shall be overwritten before you - * start the job. - */ - void setOutputFile(const QString &path); - QString outputFile() const; - - /** - Starts the verification operation. \a signature contains the - signature data, while \a signedData contains the data over - which the signature was made. - */ - virtual GpgME::Error start(const QByteArray &signedData) = 0; - - /*! - \overload - - If \a plainText is non-null, the plaintext is written - there. Otherwise, it will be delivered in the second argument - of result(). - */ - virtual void start(const std::shared_ptr<QIODevice> &signedData, const std::shared_ptr<QIODevice> &plainText = std::shared_ptr<QIODevice>()) = 0; - - /** Synchronous version of @ref start */ - virtual GpgME::VerificationResult exec(const QByteArray &signedData, QByteArray &plainText) = 0; - -Q_SIGNALS: - void result(const GpgME::VerificationResult &result, const QByteArray &plainText, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif // __KLEO_VERIFYOPAQUEJOB_H__ diff --git a/lang/qt/src/verifyopaquejob_p.h b/lang/qt/src/verifyopaquejob_p.h deleted file mode 100644 index 9686f01c..00000000 --- a/lang/qt/src/verifyopaquejob_p.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - verifyopaquejob_p.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_VERIFYOPAQUEJOB_P_H__ -#define __QGPGME_VERIFYOPAQUEJOB_P_H__ - -#include "job_p.h" - -namespace QGpgME -{ - -struct VerifyOpaqueJobPrivate : public JobPrivate -{ - QString m_inputFilePath; - QString m_outputFilePath; - bool m_processAllSignatures = false; -}; - -} - -#endif // __QGPGME_VERIFYOPAQUEJOB_P_H__ diff --git a/lang/qt/src/wkdlookupjob.h b/lang/qt/src/wkdlookupjob.h deleted file mode 100644 index ae228744..00000000 --- a/lang/qt/src/wkdlookupjob.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - wkdlookupjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2021 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_WKDLOOKUPJOB_H__ -#define __QGPGME_WKDLOOKUPJOB_H__ - -#include "job.h" -#include "qgpgme_export.h" - -class QString; - -namespace GpgME -{ -class Data; -class Error; -} - -namespace QGpgME -{ - -class WKDLookupResult; - -class QGPGME_EXPORT WKDLookupJob : public Job -{ - Q_OBJECT -protected: - explicit WKDLookupJob(QObject *parent); - -public: - ~WKDLookupJob(); - - /** - Starts a key lookup operation for the email address \a email via WKD. - */ - virtual GpgME::Error start(const QString &email) = 0; - - /** - Runs a key lookup operation for the email address \a email via WKD. - */ - virtual WKDLookupResult exec(const QString &email) = 0; - -Q_SIGNALS: - void result(const WKDLookupResult &result, const QString &auditLogAsHtml = {}, const GpgME::Error &auditLogError = {}); -}; - -} - -#endif // __QGPGME_WKDLOOKUPJOB_H__ diff --git a/lang/qt/src/wkdlookupresult.cpp b/lang/qt/src/wkdlookupresult.cpp deleted file mode 100644 index ac1a89e9..00000000 --- a/lang/qt/src/wkdlookupresult.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - wkdlookupresult.cpp - wraps the result of a WKDLookupJob - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2021 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "wkdlookupresult.h" - -#include <gpgme++/data.h> - -using namespace QGpgME; -using namespace GpgME; - -class WKDLookupResult::Private -{ -public: - std::string pattern; - GpgME::Data keyData; - std::string source; -}; - -WKDLookupResult::WKDLookupResult() = default; - -WKDLookupResult::~WKDLookupResult() = default; - -WKDLookupResult::WKDLookupResult(const std::string &pattern, const Error &error) - : Result{error} - , d{new Private{pattern, {}, {}}} -{ -} - -WKDLookupResult::WKDLookupResult(const std::string &pattern, const Data &keyData, const std::string &source, const Error &error) - : Result{error} - , d{new Private{pattern, keyData, source}} -{ -} - -WKDLookupResult::WKDLookupResult(const WKDLookupResult &other) - : Result{other} -{ - if (other.d) { - d.reset(new Private{*other.d}); - } -} - -WKDLookupResult &WKDLookupResult::operator=(const WKDLookupResult &other) -{ - auto tmp = other; - swap(tmp); - return *this; -} - -WKDLookupResult::WKDLookupResult(WKDLookupResult &&other) = default; - -WKDLookupResult &WKDLookupResult::operator=(WKDLookupResult &&other) = default; - -void WKDLookupResult::swap(WKDLookupResult &other) noexcept -{ - Result::swap(other); - std::swap(this->d, other.d); -} - -bool WKDLookupResult::isNull() const -{ - return !d && !bool(error()); -} - -std::string WKDLookupResult::pattern() const -{ - return d ? d->pattern : std::string{}; -} - -Data WKDLookupResult::keyData() const -{ - return d ? d->keyData : Data{}; -} - -std::string WKDLookupResult::source() const -{ - return d ? d->source : std::string{}; -} - -void QGpgME::swap(WKDLookupResult &a, WKDLookupResult &b) -{ - a.swap(b); -} diff --git a/lang/qt/src/wkdlookupresult.h b/lang/qt/src/wkdlookupresult.h deleted file mode 100644 index 5696fb6d..00000000 --- a/lang/qt/src/wkdlookupresult.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - wkdlookupresult.h - wraps the result of a WKDLookupJob - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2021 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_WKDLOOKUPRESULT_H__ -#define __QGPGME_WKDLOOKUPRESULT_H__ - -#include "qgpgme_export.h" - -#include <gpgme++/result.h> - -#include <memory> - -namespace GpgME -{ -class Data; -class Error; -} - -namespace QGpgME -{ - -class QGPGME_EXPORT WKDLookupResult : public GpgME::Result -{ -public: - WKDLookupResult(); - ~WKDLookupResult(); - - explicit WKDLookupResult(const std::string &pattern, const GpgME::Error &err); - explicit WKDLookupResult(const std::string &pattern, const GpgME::Data &keyData, const std::string &source, const GpgME::Error &err); - - WKDLookupResult(const WKDLookupResult &other); - WKDLookupResult &operator=(const WKDLookupResult &other); - - WKDLookupResult(WKDLookupResult &&other); - WKDLookupResult &operator=(WKDLookupResult &&other); - - void swap(WKDLookupResult &other) noexcept; - - bool isNull() const; - - std::string pattern() const; - GpgME::Data keyData() const; - std::string source() const; - -private: - class Private; - std::unique_ptr<Private> d; -}; - -QGPGME_EXPORT void swap(WKDLookupResult &a, WKDLookupResult &b); - -} - -#endif // __QGPGME_WKDLOOKUPRESULT_H__ diff --git a/lang/qt/src/wkdrefreshjob.cpp b/lang/qt/src/wkdrefreshjob.cpp deleted file mode 100644 index f79df2c5..00000000 --- a/lang/qt/src/wkdrefreshjob.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - wkdrefreshjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "wkdrefreshjob.h" -#include "wkdrefreshjob_p.h" - -using namespace QGpgME; - -WKDRefreshJob::WKDRefreshJob(QObject *parent) - : AbstractImportJob{parent} -{ -} - -WKDRefreshJob::~WKDRefreshJob() = default; - -GpgME::Error WKDRefreshJob::start(const std::vector<GpgME::Key> &keys) -{ - auto d = jobPrivate<WKDRefreshJobPrivate>(this); - d->m_keys = keys; - return d->startIt(); -} - -GpgME::Error WKDRefreshJob::start(const std::vector<GpgME::UserID> &userIDs) -{ - auto d = jobPrivate<WKDRefreshJobPrivate>(this); - d->m_userIds = userIDs; - return d->startIt(); -} - -#include "wkdrefreshjob.moc" diff --git a/lang/qt/src/wkdrefreshjob.h b/lang/qt/src/wkdrefreshjob.h deleted file mode 100644 index cbaaf6b0..00000000 --- a/lang/qt/src/wkdrefreshjob.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - wkdrefreshjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_WKDREFRESHJOB_H__ -#define __QGPGME_WKDREFRESHJOB_H__ - -#include "abstractimportjob.h" -#include "qgpgme_export.h" - -#include <vector> - -namespace GpgME -{ -class Error; -class Key; -class UserID; -} - -namespace QGpgME -{ - -/** - * This job refreshes OpenPGP keys via WKD. - */ -class QGPGME_EXPORT WKDRefreshJob : public AbstractImportJob -{ - Q_OBJECT -protected: - explicit WKDRefreshJob(QObject *parent); -public: - ~WKDRefreshJob() override; - - /** - * Starts a refresh of the \a keys. Only user IDs that have WKD set as - * origin are used for the WKD lookup. Revoked user IDs are ignored. - * - * Use the other start overload to use all user IDs for the WKD lookup. - */ - GpgME::Error start(const std::vector<GpgME::Key> &keys); - - /** - * Starts a refresh of the keys belonging to the user IDs \a userIDs. - * All user IDs are used for the WKD lookup. Revoked user IDs are ignored. - */ - GpgME::Error start(const std::vector<GpgME::UserID> &userIDs); -}; - -} - -#endif // __QGPGME_WKDREFRESHJOB_H__ diff --git a/lang/qt/src/wkdrefreshjob_p.h b/lang/qt/src/wkdrefreshjob_p.h deleted file mode 100644 index 8e729936..00000000 --- a/lang/qt/src/wkdrefreshjob_p.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - wkdrefreshjob_p.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __QGPGME_WKDREFRESHJOB_P_H__ -#define __QGPGME_WKDREFRESHJOB_P_H__ - -#include "job_p.h" - -#include <gpgme++/key.h> - -namespace QGpgME -{ - -struct WKDRefreshJobPrivate : public JobPrivate -{ - std::vector<GpgME::Key> m_keys; - std::vector<GpgME::UserID> m_userIds; -}; - -} - -#endif // __QGPGME_WKDREFRESHJOB_P_H__ diff --git a/lang/qt/src/wkspublishjob.h b/lang/qt/src/wkspublishjob.h deleted file mode 100644 index 2b4daf51..00000000 --- a/lang/qt/src/wkspublishjob.h +++ /dev/null @@ -1,108 +0,0 @@ -/* wkspublishjob.h - - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifndef QGPGME_WKSPUBLISHJOB_H -#define QGPGME_WKSPUBLISHJOB_H - -#include "job.h" - -#include "qgpgme_export.h" - -namespace GpgME -{ - class Key; -} // namespace GpgME - -namespace QGpgME { - -/** - * Handles Web Key Service Publishing. Needs WKS tools installed and - * server support. - * - * Remember that after a result is emitted the job is auto deleted - * so you can only use it for a single action. - * - * The workflow is to call startCreate, check for errors and then - * send the RFC822 mail returned in returnedData. - * - * When the response is received call startReceive with the - * RFC822 mail received as parameter response. Check for errors - * and then send the result from returnedData back to the server. - */ -class QGPGME_EXPORT WKSPublishJob: public Job -{ - Q_OBJECT -protected: - explicit WKSPublishJob(QObject *parent); -public: - ~WKSPublishJob(); - - /** Start a check if WKS Publishing is supported. As this involves - * an HTTP Query it might take a while. Returns GPG_ERR_NOT_SUPPORED - * result if GnuPG is too old or the required tools are not installed. - * - * The error GPG_ERR_NOT_ENABLED indicates that wks-tools failed to - * detect a working wks service for this. - * - * @param the mailbox to check for. - **/ - virtual void startCheck(const QString &mailbox) = 0; - - /** Create a publish request. - * The returnedData from the result signal will contain - * the full Request as returned by gpg-wks-client --create - * - * @param fpr the fingerprint of the key to create the request for. - * @param mailbox A simple mail address without a Name. - */ - virtual void startCreate(const char *fpr, const QString &mailbox) = 0; - - /** Handle a submission response. The returnedData in the result singnal - * will contain the confirmation response as returned by gpg-wks-client --receive - * - * @param response The response of the server. - **/ - virtual void startReceive(const QByteArray &response) = 0; - -Q_SIGNALS: - /* Result of the operation returned Data and returned Error are - * the results from gpg-wks-client's stdout or stderr respectively. - * - * As usual auditLogAsHtml and auditLogError can be ignored. - **/ - void result(const GpgME::Error &error, const QByteArray &returnedData, - const QByteArray &returnedError, - const QString &auditLogAsHtml = QString(), - const GpgME::Error &auditLogError = GpgME::Error()); -}; - -} - -#endif diff --git a/lang/qt/tests/Makefile.am b/lang/qt/tests/Makefile.am deleted file mode 100644 index ee168b75..00000000 --- a/lang/qt/tests/Makefile.am +++ /dev/null @@ -1,424 +0,0 @@ -# Makefile.am - Makefile for QGpgME tests. -# Copyright (C) 2016 Bundesamt für Sicherheit in der Informationstechnik -# Software engineering by Intevation GmbH -# -# This file is part of QGpgME. -# -# QGpgME 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 2 of the License, or -# (at your option) any later version. -# -# QGpgME is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see <https://gnu.org/licenses/>. -# SPDX-License-Identifier: GPL-2.0-or-later - -## Process this file with automake to produce Makefile.in - -GPG = gpg - -GNUPGHOME=$(abs_builddir) -TESTS_ENVIRONMENT = GNUPGHOME=$(GNUPGHOME) - -EXTRA_DIST = initial.test final.test - -if WANT_QT5 -the_tests5 = \ - t-addexistingsubkey5 \ - t-changeexpiryjob5 \ - t-config5 \ - t-decryptverify5 \ - t-disablekey5 \ - t-encrypt5 \ - t-import5 \ - t-keylist5 \ - t-keylocate5 \ - t-ownertrust5 \ - t-remarks5 \ - t-revokekey5 \ - t-setprimaryuserid5 \ - t-tofuinfo5 \ - t-trustsignatures5 \ - t-various5 \ - t-verify5 \ - t-wkdlookup5 -# disabled test: t-wkspublish5 -the_runners5 = \ - run-decryptverifyarchivejob5 \ - run-decryptverifyjob5 \ - run-encryptarchivejob5 \ - run-encryptjob5 \ - run-exportjob5 \ - run-importjob5 \ - run-keyformailboxjob5 \ - run-receivekeysjob5 \ - run-refreshkeysjob5 \ - run-signarchivejob5 \ - run-signjob5 \ - run-verifydetachedjob5 \ - run-verifyopaquejob5 \ - run-wkdrefreshjob5 -endif -if WANT_QT6 -the_tests6 = \ - t-addexistingsubkey6 \ - t-changeexpiryjob6 \ - t-config6 \ - t-decryptverify6 \ - t-disablekey6 \ - t-encrypt6 \ - t-import6 \ - t-keylist6 \ - t-keylocate6 \ - t-ownertrust6 \ - t-remarks6 \ - t-revokekey6 \ - t-setprimaryuserid6 \ - t-tofuinfo6 \ - t-trustsignatures6 \ - t-various6 \ - t-verify6 \ - t-wkdlookup6 -# disabled test: t-wkspublish6 -the_runners6 = \ - run-decryptverifyarchivejob6 \ - run-decryptverifyjob6 \ - run-encryptarchivejob6 \ - run-encryptjob6 \ - run-exportjob6 \ - run-importjob6 \ - run-keyformailboxjob6 \ - run-receivekeysjob6 \ - run-refreshkeysjob6 \ - run-signarchivejob6 \ - run-signjob6 \ - run-verifydetachedjob6 \ - run-verifyopaquejob6 \ - run-wkdrefreshjob6 -endif - -TESTS = initial.test $(the_tests5) $(the_tests6) final.test - -# define .moc files for all tests; we'll moc their .cpp files -# the only header that needs to be moc'd (t-support.h) is handled individually -# moc_files = $(the_tests:%=%.moc) - -# generate the moc files in two steps: -# 1. generate Qt 5/6-specific moc files in builddir with extension .moc5/.moc6; -# this ensures correct dependencies on the source files -# 2. generate forwarding headers in subfolders moc5/moc6 with extension .moc; -# this ensures that the "foo.moc" includes in the source files work and -# include the correct version of the generated moc files for Qt 5/6 -# GNU make's pattern rules would make this easier, but we don't want to use them -if WANT_QT5 -moc5_dir = moc5 -moc5_files = $(moc5_dir)/t-support.hmoc $(the_tests5:%5=%.moc5) -moc5_forward_headers = $(the_tests5:%5=$(moc5_dir)/%.moc) - -$(moc5_dir)/t-support.hmoc: t-support.h | $(moc5_dir) - $(MOC5) `test -f '$<' || echo '$(srcdir)/'`$< -o $@ - -.cpp.moc5: - $(MOC5) `test -f '$<' || echo '$(srcdir)/'`$< -o $@ - -$(moc5_dir): - mkdir $(moc5_dir) - -$(moc5_forward_headers): Makefile.am | $(moc5_dir) - echo "#include \"../$(notdir $@)5\"" > "$@" -endif -if WANT_QT6 -moc6_dir = moc6 -moc6_files = $(moc6_dir)/t-support.hmoc $(the_tests6:%6=%.moc6) -moc6_forward_headers = $(the_tests6:%6=$(moc6_dir)/%.moc) - -$(moc6_dir)/t-support.hmoc: t-support.h | $(moc6_dir) - $(MOC6) `test -f '$<' || echo '$(srcdir)/'`$< -o $@ - -.cpp.moc6: - $(MOC6) `test -f '$<' || echo '$(srcdir)/'`$< -o $@ - -$(moc6_dir): - mkdir $(moc6_dir) - -$(moc6_forward_headers): Makefile.am | $(moc6_dir) - echo "#include \"../$(notdir $@)6\"" > "$@" -endif - -AM_LDFLAGS = -no-install - -if WANT_QT5 -ldadd_qt5 = ../../cpp/src/libgpgmepp.la ../src/libqgpgme.la \ - ../../../src/libgpgme.la @GPGME_QT5_LIBS@ @GPG_ERROR_LIBS@ \ - @GPGME_QT5TEST_LIBS@ @LDADD_FOR_TESTS_KLUDGE@ -lstdc++ - -cppflags_qt5 = -I$(moc5_dir) -I$(top_srcdir)/lang/qt/src -I$(top_builddir)/lang/cpp/src \ - -I$(top_builddir)/src \ - @GPG_ERROR_CFLAGS@ @GPGME_QT5_CFLAGS@ @GPG_ERROR_CFLAGS@ \ - @LIBASSUAN_CFLAGS@ @GPGME_QT5TEST_CFLAGS@ -DBUILDING_QGPGME \ - -DTOP_SRCDIR="$(top_srcdir)" -endif -if WANT_QT6 -ldadd_qt6 = ../../cpp/src/libgpgmepp.la ../src/libqgpgmeqt6.la \ - ../../../src/libgpgme.la @GPGME_QT6_LIBS@ @GPG_ERROR_LIBS@ \ - @GPGME_QT6TEST_LIBS@ @LDADD_FOR_TESTS_KLUDGE@ -lstdc++ - -cppflags_qt6 = -I$(moc6_dir) -I$(top_srcdir)/lang/qt/src -I$(top_builddir)/lang/cpp/src \ - -I$(top_builddir)/src \ - @GPG_ERROR_CFLAGS@ @GPGME_QT6_CFLAGS@ @GPG_ERROR_CFLAGS@ \ - @LIBASSUAN_CFLAGS@ @GPGME_QT6TEST_CFLAGS@ -DBUILDING_QGPGME \ - -DTOP_SRCDIR="$(top_srcdir)" -endif - -support_src = t-support.h t-support.cpp - -if WANT_QT5 -t_addexistingsubkey5_SOURCES = t-addexistingsubkey.cpp $(support_src) -t_addexistingsubkey5_LDADD = $(ldadd_qt5) -t_addexistingsubkey5_CPPFLAGS = $(cppflags_qt5) -t_changeexpiryjob5_SOURCES = t-changeexpiryjob.cpp $(support_src) -t_changeexpiryjob5_LDADD = $(ldadd_qt5) -t_changeexpiryjob5_CPPFLAGS = $(cppflags_qt5) -t_config5_SOURCES = t-config.cpp $(support_src) -t_config5_LDADD = $(ldadd_qt5) -t_config5_CPPFLAGS = $(cppflags_qt5) -t_decryptverify5_SOURCES = t-decryptverify.cpp $(support_src) -t_decryptverify5_LDADD = $(ldadd_qt5) -t_decryptverify5_CPPFLAGS = $(cppflags_qt5) -t_disablekey5_SOURCES = t-disablekey.cpp $(support_src) -t_disablekey5_LDADD = $(ldadd_qt5) -t_disablekey5_CPPFLAGS = $(cppflags_qt5) -t_encrypt5_SOURCES = t-encrypt.cpp $(support_src) -t_encrypt5_LDADD = $(ldadd_qt5) -t_encrypt5_CPPFLAGS = $(cppflags_qt5) -t_import5_SOURCES = t-import.cpp $(support_src) -t_import5_LDADD = $(ldadd_qt5) -t_import5_CPPFLAGS = $(cppflags_qt5) -t_keylist5_SOURCES = t-keylist.cpp $(support_src) -t_keylist5_LDADD = $(ldadd_qt5) -t_keylist5_CPPFLAGS = $(cppflags_qt5) -t_keylocate5_SOURCES = t-keylocate.cpp $(support_src) -t_keylocate5_LDADD = $(ldadd_qt5) -t_keylocate5_CPPFLAGS = $(cppflags_qt5) -t_ownertrust5_SOURCES = t-ownertrust.cpp $(support_src) -t_ownertrust5_LDADD = $(ldadd_qt5) -t_ownertrust5_CPPFLAGS = $(cppflags_qt5) -t_remarks5_SOURCES = t-remarks.cpp $(support_src) -t_remarks5_LDADD = $(ldadd_qt5) -t_remarks5_CPPFLAGS = $(cppflags_qt5) -t_revokekey5_SOURCES = t-revokekey.cpp $(support_src) -t_revokekey5_LDADD = $(ldadd_qt5) -t_revokekey5_CPPFLAGS = $(cppflags_qt5) -t_setprimaryuserid5_SOURCES = t-setprimaryuserid.cpp $(support_src) -t_setprimaryuserid5_LDADD = $(ldadd_qt5) -t_setprimaryuserid5_CPPFLAGS = $(cppflags_qt5) -t_tofuinfo5_SOURCES = t-tofuinfo.cpp $(support_src) -t_tofuinfo5_LDADD = $(ldadd_qt5) -t_tofuinfo5_CPPFLAGS = $(cppflags_qt5) -t_trustsignatures5_SOURCES = t-trustsignatures.cpp $(support_src) -t_trustsignatures5_LDADD = $(ldadd_qt5) -t_trustsignatures5_CPPFLAGS = $(cppflags_qt5) -t_various5_SOURCES = t-various.cpp $(support_src) -t_various5_LDADD = $(ldadd_qt5) -t_various5_CPPFLAGS = $(cppflags_qt5) -t_verify5_SOURCES = t-verify.cpp $(support_src) -t_verify5_LDADD = $(ldadd_qt5) -t_verify5_CPPFLAGS = $(cppflags_qt5) -t_wkdlookup5_SOURCES = t-wkdlookup.cpp $(support_src) -t_wkdlookup5_LDADD = $(ldadd_qt5) -t_wkdlookup5_CPPFLAGS = $(cppflags_qt5) -# t_wkspublish5_SOURCES = t-wkspublish.cpp $(support_src) -# t_wkspublish5_LDADD = $(ldadd_qt5) -# t_wkspublish5_CPPFLAGS = $(cppflags_qt5) -run_decryptverifyarchivejob5_SOURCES = run-decryptverifyarchivejob.cpp -run_decryptverifyarchivejob5_LDADD = $(ldadd_qt5) -run_decryptverifyarchivejob5_CPPFLAGS = $(cppflags_qt5) -run_decryptverifyjob5_SOURCES = run-decryptverifyjob.cpp -run_decryptverifyjob5_LDADD = $(ldadd_qt5) -run_decryptverifyjob5_CPPFLAGS = $(cppflags_qt5) -run_encryptarchivejob5_SOURCES = run-encryptarchivejob.cpp -run_encryptarchivejob5_LDADD = $(ldadd_qt5) -run_encryptarchivejob5_CPPFLAGS = $(cppflags_qt5) -run_encryptjob5_SOURCES = run-encryptjob.cpp -run_encryptjob5_LDADD = $(ldadd_qt5) -run_encryptjob5_CPPFLAGS = $(cppflags_qt5) -run_exportjob5_SOURCES = run-exportjob.cpp -run_exportjob5_LDADD = $(ldadd_qt5) -run_exportjob5_CPPFLAGS = $(cppflags_qt5) -run_importjob5_SOURCES = run-importjob.cpp -run_importjob5_LDADD = $(ldadd_qt5) -run_importjob5_CPPFLAGS = $(cppflags_qt5) -run_keyformailboxjob5_SOURCES = run-keyformailboxjob.cpp -run_keyformailboxjob5_LDADD = $(ldadd_qt5) -run_keyformailboxjob5_CPPFLAGS = $(cppflags_qt5) -run_receivekeysjob5_SOURCES = run-receivekeysjob.cpp -run_receivekeysjob5_LDADD = $(ldadd_qt5) -run_receivekeysjob5_CPPFLAGS = $(cppflags_qt5) -run_refreshkeysjob5_SOURCES = run-refreshkeysjob.cpp -run_refreshkeysjob5_LDADD = $(ldadd_qt5) -run_refreshkeysjob5_CPPFLAGS = $(cppflags_qt5) -run_signarchivejob5_SOURCES = run-signarchivejob.cpp -run_signarchivejob5_LDADD = $(ldadd_qt5) -run_signarchivejob5_CPPFLAGS = $(cppflags_qt5) -run_signjob5_SOURCES = run-signjob.cpp -run_signjob5_LDADD = $(ldadd_qt5) -run_signjob5_CPPFLAGS = $(cppflags_qt5) -run_verifydetachedjob5_SOURCES = run-verifydetachedjob.cpp -run_verifydetachedjob5_LDADD = $(ldadd_qt5) -run_verifydetachedjob5_CPPFLAGS = $(cppflags_qt5) -run_verifyopaquejob5_SOURCES = run-verifyopaquejob.cpp -run_verifyopaquejob5_LDADD = $(ldadd_qt5) -run_verifyopaquejob5_CPPFLAGS = $(cppflags_qt5) -run_wkdrefreshjob5_SOURCES = run-wkdrefreshjob.cpp -run_wkdrefreshjob5_LDADD = $(ldadd_qt5) -run_wkdrefreshjob5_CPPFLAGS = $(cppflags_qt5) - -#nodist_t_keylist5_SOURCES = $(moc5_files) $(moc5_forward_headers) -endif -if WANT_QT6 -t_addexistingsubkey6_SOURCES = t-addexistingsubkey.cpp $(support_src) -t_addexistingsubkey6_LDADD = $(ldadd_qt6) -t_addexistingsubkey6_CPPFLAGS = $(cppflags_qt6) -t_changeexpiryjob6_SOURCES = t-changeexpiryjob.cpp $(support_src) -t_changeexpiryjob6_LDADD = $(ldadd_qt6) -t_changeexpiryjob6_CPPFLAGS = $(cppflags_qt6) -t_config6_SOURCES = t-config.cpp $(support_src) -t_config6_LDADD = $(ldadd_qt6) -t_config6_CPPFLAGS = $(cppflags_qt6) -t_decryptverify6_SOURCES = t-decryptverify.cpp $(support_src) -t_decryptverify6_LDADD = $(ldadd_qt6) -t_decryptverify6_CPPFLAGS = $(cppflags_qt6) -t_disablekey6_SOURCES = t-disablekey.cpp $(support_src) -t_disablekey6_LDADD = $(ldadd_qt6) -t_disablekey6_CPPFLAGS = $(cppflags_qt6) -t_encrypt6_SOURCES = t-encrypt.cpp $(support_src) -t_encrypt6_LDADD = $(ldadd_qt6) -t_encrypt6_CPPFLAGS = $(cppflags_qt6) -t_import6_SOURCES = t-import.cpp $(support_src) -t_import6_LDADD = $(ldadd_qt6) -t_import6_CPPFLAGS = $(cppflags_qt6) -t_keylist6_SOURCES = t-keylist.cpp $(support_src) -t_keylist6_LDADD = $(ldadd_qt6) -t_keylist6_CPPFLAGS = $(cppflags_qt6) -t_keylocate6_SOURCES = t-keylocate.cpp $(support_src) -t_keylocate6_LDADD = $(ldadd_qt6) -t_keylocate6_CPPFLAGS = $(cppflags_qt6) -t_ownertrust6_SOURCES = t-ownertrust.cpp $(support_src) -t_ownertrust6_LDADD = $(ldadd_qt6) -t_ownertrust6_CPPFLAGS = $(cppflags_qt6) -t_remarks6_SOURCES = t-remarks.cpp $(support_src) -t_remarks6_LDADD = $(ldadd_qt6) -t_remarks6_CPPFLAGS = $(cppflags_qt6) -t_revokekey6_SOURCES = t-revokekey.cpp $(support_src) -t_revokekey6_LDADD = $(ldadd_qt6) -t_revokekey6_CPPFLAGS = $(cppflags_qt6) -t_setprimaryuserid6_SOURCES = t-setprimaryuserid.cpp $(support_src) -t_setprimaryuserid6_LDADD = $(ldadd_qt6) -t_setprimaryuserid6_CPPFLAGS = $(cppflags_qt6) -t_tofuinfo6_SOURCES = t-tofuinfo.cpp $(support_src) -t_tofuinfo6_LDADD = $(ldadd_qt6) -t_tofuinfo6_CPPFLAGS = $(cppflags_qt6) -t_trustsignatures6_SOURCES = t-trustsignatures.cpp $(support_src) -t_trustsignatures6_LDADD = $(ldadd_qt6) -t_trustsignatures6_CPPFLAGS = $(cppflags_qt6) -t_various6_SOURCES = t-various.cpp $(support_src) -t_various6_LDADD = $(ldadd_qt6) -t_various6_CPPFLAGS = $(cppflags_qt6) -t_verify6_SOURCES = t-verify.cpp $(support_src) -t_verify6_LDADD = $(ldadd_qt6) -t_verify6_CPPFLAGS = $(cppflags_qt6) -t_wkdlookup6_SOURCES = t-wkdlookup.cpp $(support_src) -t_wkdlookup6_LDADD = $(ldadd_qt6) -t_wkdlookup6_CPPFLAGS = $(cppflags_qt6) -# t_wkspublish6_SOURCES = t-wkspublish.cpp $(support_src) -# t_wkspublish6_LDADD = $(ldadd_qt6) -# t_wkspublish6_CPPFLAGS = $(cppflags_qt6) -run_decryptverifyarchivejob6_SOURCES = run-decryptverifyarchivejob.cpp -run_decryptverifyarchivejob6_LDADD = $(ldadd_qt6) -run_decryptverifyarchivejob6_CPPFLAGS = $(cppflags_qt6) -run_decryptverifyjob6_SOURCES = run-decryptverifyjob.cpp -run_decryptverifyjob6_LDADD = $(ldadd_qt6) -run_decryptverifyjob6_CPPFLAGS = $(cppflags_qt6) -run_encryptarchivejob6_SOURCES = run-encryptarchivejob.cpp -run_encryptarchivejob6_LDADD = $(ldadd_qt6) -run_encryptarchivejob6_CPPFLAGS = $(cppflags_qt6) -run_encryptjob6_SOURCES = run-encryptjob.cpp -run_encryptjob6_LDADD = $(ldadd_qt6) -run_encryptjob6_CPPFLAGS = $(cppflags_qt6) -run_exportjob6_SOURCES = run-exportjob.cpp -run_exportjob6_LDADD = $(ldadd_qt6) -run_exportjob6_CPPFLAGS = $(cppflags_qt6) -run_importjob6_SOURCES = run-importjob.cpp -run_importjob6_LDADD = $(ldadd_qt6) -run_importjob6_CPPFLAGS = $(cppflags_qt6) -run_keyformailboxjob6_SOURCES = run-keyformailboxjob.cpp -run_keyformailboxjob6_LDADD = $(ldadd_qt6) -run_keyformailboxjob6_CPPFLAGS = $(cppflags_qt6) -run_receivekeysjob6_SOURCES = run-receivekeysjob.cpp -run_receivekeysjob6_LDADD = $(ldadd_qt6) -run_receivekeysjob6_CPPFLAGS = $(cppflags_qt6) -run_refreshkeysjob6_SOURCES = run-refreshkeysjob.cpp -run_refreshkeysjob6_LDADD = $(ldadd_qt6) -run_refreshkeysjob6_CPPFLAGS = $(cppflags_qt6) -run_signarchivejob6_SOURCES = run-signarchivejob.cpp -run_signarchivejob6_LDADD = $(ldadd_qt6) -run_signarchivejob6_CPPFLAGS = $(cppflags_qt6) -run_signjob6_SOURCES = run-signjob.cpp -run_signjob6_LDADD = $(ldadd_qt6) -run_signjob6_CPPFLAGS = $(cppflags_qt6) -run_verifydetachedjob6_SOURCES = run-verifydetachedjob.cpp -run_verifydetachedjob6_LDADD = $(ldadd_qt6) -run_verifydetachedjob6_CPPFLAGS = $(cppflags_qt6) -run_verifyopaquejob6_SOURCES = run-verifyopaquejob.cpp -run_verifyopaquejob6_LDADD = $(ldadd_qt6) -run_verifyopaquejob6_CPPFLAGS = $(cppflags_qt6) -run_wkdrefreshjob6_SOURCES = run-wkdrefreshjob.cpp -run_wkdrefreshjob6_LDADD = $(ldadd_qt6) -run_wkdrefreshjob6_CPPFLAGS = $(cppflags_qt6) - -# nodist_t_keylist6_SOURCES = $(moc6_files) $(moc6_forward_headers) -endif - -BUILT_SOURCES = $(moc5_files) $(moc5_forward_headers) \ - $(moc6_files) $(moc6_forward_headers) \ - pubring-stamp - -noinst_PROGRAMS = $(the_tests5) $(the_runners5) $(the_tests6) $(the_runners6) - -CLEANFILES = secring.gpg pubring.gpg pubring.kbx trustdb.gpg dirmngr.conf \ - gpg-agent.conf pubring.kbx~ S.gpg-agent gpg.conf pubring.gpg~ \ - random_seed S.gpg-agent .gpg-v21-migrated pubring-stamp \ - $(moc5_files) $(moc5_forward_headers) \ - $(moc6_files) $(moc6_forward_headers) \ - gpg.conf tofu.db reader_0.status reader_1.status - -clean-local: - -test -z "$(moc5_dir)" || rm -rf $(moc5_dir) - -test -z "$(moc6_dir)" || rm -rf $(moc6_dir) - -$(TESTS_ENVIRONMENT) $(top_srcdir)/tests/start-stop-agent --stop - -rm -fR private-keys-v1.d crls.d - -clean-keyring: - -$(TESTS_ENVIRONMENT) $(top_srcdir)/tests/start-stop-agent --stop - -rm -fR private-keys-v1.d crls.d pubring.gpg pubring.kbx secring.gpg \ - trustdb.gpg pubring-stamp - -pubring-stamp: $(top_srcdir)/tests/gpg/pubdemo.asc \ - $(top_srcdir)/tests/gpg/secdemo.asc - -$(TESTS_ENVIRONMENT) gpgconf --kill all - echo "ignore-invalid-option allow-loopback-pinentry" > $(abs_builddir)/gpg-agent.conf - echo "allow-loopback-pinentry" >> gpg-agent.conf - echo "ignore-invalid-option pinentry-mode" > gpg.conf - echo "pinentry-mode loopback" >> gpg.conf - $(TESTS_ENVIRONMENT) $(GPG) --no-permission-warning \ - --import $(top_srcdir)/tests/gpg/pubdemo.asc - $(TESTS_ENVIRONMENT) $(GPG) --no-permission-warning \ - --passphrase "abc" \ - --import $(top_srcdir)/tests/gpg/secdemo.asc - -$(TESTS_ENVIRONMENT) gpgconf --kill all - touch pubring-stamp diff --git a/lang/qt/tests/final.test b/lang/qt/tests/final.test deleted file mode 100755 index f28aaa4c..00000000 --- a/lang/qt/tests/final.test +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -# stop the dirmngr that may have been started -gpgconf --kill dirmngr - -exit 0 diff --git a/lang/qt/tests/initial.test b/lang/qt/tests/initial.test deleted file mode 100755 index 039e4d00..00000000 --- a/lang/qt/tests/initial.test +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exit 0 diff --git a/lang/qt/tests/run-decryptverifyarchivejob.cpp b/lang/qt/tests/run-decryptverifyarchivejob.cpp deleted file mode 100644 index 6d5615c0..00000000 --- a/lang/qt/tests/run-decryptverifyarchivejob.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - run-decryptverifyarchivejob.cpp - - This file is part of QGpgME's test suite. - Copyright (c) 2023 by g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License, - version 2, as published by the Free Software Foundation. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <debug.h> -#include <decryptverifyarchivejob.h> -#include <protocol.h> - -#include <QCommandLineParser> -#include <QCoreApplication> -#include <QDebug> - -#include <gpgme++/context.h> -#include <gpgme++/decryptionresult.h> -#include <gpgme++/verificationresult.h> - -#include <iostream> - -using namespace GpgME; - -std::ostream &operator<<(std::ostream &os, const QString &s) -{ - return os << s.toLocal8Bit().constData(); -} - -struct CommandLineOptions { - bool processAllSignatures = false; - QString outputDirectory; - QString archiveName; -}; - -CommandLineOptions parseCommandLine(const QStringList &arguments) -{ - CommandLineOptions options; - - QCommandLineParser parser; - parser.setApplicationDescription("Test program for DecryptVerifyArchiveJob"); - parser.addHelpOption(); - parser.addOptions({ - {{"C", "directory"}, "Extract the files into the directory DIRECTORY.", "DIRECTORY"}, - {"process-all-signatures", "Don't stop signature checking after bad signature."}, - }); - parser.addPositionalArgument("archive", "The archive to decrypt and extract"); - - parser.process(arguments); - - const auto args = parser.positionalArguments(); - if (args.size() != 1) { - parser.showHelp(1); - } - - options.processAllSignatures = parser.isSet("process-all-signatures"); - options.outputDirectory = parser.value("directory"); - options.archiveName = args.first(); - - return options; -} - -int main(int argc, char **argv) -{ - GpgME::initializeLibrary(); - - QCoreApplication app{argc, argv}; - app.setApplicationName("run-decryptverifyarchivejob"); - - const auto options = parseCommandLine(app.arguments()); - - if (!QGpgME::DecryptVerifyArchiveJob::isSupported()) { - std::cerr << "Error: Decrypting and extracting archives is not supported by your version of gpg." << std::endl; - return 1; - } - - auto job = QGpgME::openpgp()->decryptVerifyArchiveJob(); - if (!job) { - std::cerr << "Error: Could not create job" << std::endl; - return 1; - } - job->setProcessAllSignatures(options.processAllSignatures); - job->setInputFile(options.archiveName); - job->setOutputDirectory(options.outputDirectory); - QObject::connect(job, &QGpgME::DecryptVerifyArchiveJob::result, &app, [](const GpgME::DecryptionResult &decryptionResult, const GpgME::VerificationResult &verificationResult, const QString &auditLog, const GpgME::Error &) { - std::cerr << "Diagnostics: " << auditLog << std::endl; - std::cerr << "Decryption Result: " << decryptionResult << std::endl; - std::cerr << "Verification Result: " << verificationResult << std::endl; - qApp->quit(); - }); - - const auto err = job->startIt(); - if (err) { - std::cerr << "Error: Starting the job failed: " << err << std::endl; - return 1; - } - - return app.exec(); -} diff --git a/lang/qt/tests/run-decryptverifyjob.cpp b/lang/qt/tests/run-decryptverifyjob.cpp deleted file mode 100644 index 805bad68..00000000 --- a/lang/qt/tests/run-decryptverifyjob.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - run-decryptverifyjob.cpp - - This file is part of QGpgME's test suite. - Copyright (c) 2023 by g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License, - version 2, as published by the Free Software Foundation. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <debug.h> -#include <protocol.h> -#include <decryptverifyjob.h> - -#include <QCommandLineParser> -#include <QCoreApplication> -#include <QDebug> -#include <QFile> -#include <QTimer> - -#include <gpgme++/context.h> -#include <gpgme++/decryptionresult.h> -#include <gpgme++/verificationresult.h> - -#include <iostream> - -using namespace GpgME; - -std::ostream &operator<<(std::ostream &os, const QString &s) -{ - return os << s.toLocal8Bit().constData(); -} - -struct CommandLineOptions { - bool processAllSignatures = false; - QString inputFile; - QString outputFile; - std::chrono::seconds cancelTimeout{0}; -}; - -CommandLineOptions parseCommandLine(const QStringList &arguments) -{ - CommandLineOptions options; - - QCommandLineParser parser; - parser.setApplicationDescription("Test program for DecryptVerifyJob"); - parser.addHelpOption(); - parser.addOptions({ - {{"o", "output"}, "Write output to FILE.", "FILE"}, - {"cancel-after", "Cancel the running job after SECONDS seconds.", "SECONDS"}, - {"process-all-signatures", "Don't stop signature checking after bad signature."}, - }); - parser.addPositionalArgument("file", "File to decrypt", "FILE"); - - parser.process(arguments); - - const auto args = parser.positionalArguments(); - if (args.size() != 1) { - parser.showHelp(1); - } - - options.processAllSignatures = parser.isSet("process-all-signatures"); - options.inputFile = args.front(); - options.outputFile = parser.value("output"); - if (parser.isSet("cancel-after")) { - bool ok; - options.cancelTimeout = std::chrono::seconds{parser.value("cancel-after").toInt(&ok)}; - if (!ok) { - options.cancelTimeout = std::chrono::seconds{-1}; - } - } - - return options; -} - -int main(int argc, char **argv) -{ - GpgME::initializeLibrary(); - - QCoreApplication app{argc, argv}; - app.setApplicationName("run-decryptverifyjob"); - - const auto options = parseCommandLine(app.arguments()); - if (options.cancelTimeout.count() < 0) { - std::cerr << "Ignoring invalid timeout for cancel." << std::endl; - } - - std::shared_ptr<QFile> output; - if (options.outputFile.isEmpty() || options.outputFile == QLatin1String{"-"}) { - output.reset(new QFile); - output->open(stdout, QIODevice::WriteOnly); - } else { - if (QFile::exists(options.outputFile)) { - qCritical() << "File" << options.outputFile << "exists. Bailing out."; - return 1; - } - } - - auto job = QGpgME::openpgp()->decryptVerifyJob(); - if (!job) { - std::cerr << "Error: Could not create job" << std::endl; - return 1; - } - QObject::connect(job, - &QGpgME::DecryptVerifyJob::result, - &app, - [](const GpgME::DecryptionResult &decryptionResult, - const GpgME::VerificationResult &verificationResult, - const QByteArray &, - const QString &auditLog, - const GpgME::Error &) { - std::cerr << "Diagnostics: " << auditLog << std::endl; - std::cerr << "Decryption Result: " << decryptionResult << std::endl; - std::cerr << "Verification Result: " << verificationResult << std::endl; - qApp->quit(); - }); - if (options.cancelTimeout.count() > 0) { - QTimer::singleShot(options.cancelTimeout, job, [job]() { - std::cerr << "Canceling job" << std::endl; - job->slotCancel(); - }); - } - - std::shared_ptr<QFile> input; - GpgME::Error err; - job->setProcessAllSignatures(options.processAllSignatures); - if (output) { - input.reset(new QFile{options.inputFile}); - input->open(QIODevice::ReadOnly); - job->start(input, output); - } else { - job->setInputFile(options.inputFile); - job->setOutputFile(options.outputFile); - err = job->startIt(); - } - if (err) { - std::cerr << "Error: Starting the job failed: " << err << std::endl; - return 1; - } - - return app.exec(); -} diff --git a/lang/qt/tests/run-encryptarchivejob.cpp b/lang/qt/tests/run-encryptarchivejob.cpp deleted file mode 100644 index 87781fd9..00000000 --- a/lang/qt/tests/run-encryptarchivejob.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/* - run-encryptarchivejob.cpp - - This file is part of QGpgME's test suite. - Copyright (c) 2023 by g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License, - version 2, as published by the Free Software Foundation. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <debug.h> -#include <protocol.h> -#include <encryptarchivejob.h> -#include <signencryptarchivejob.h> - -#include <QCommandLineParser> -#include <QCoreApplication> -#include <QDebug> -#include <QDir> -#include <QFile> -#include <QFileInfo> -#include <QTimer> - -#include <gpgme++/context.h> -#include <gpgme++/encryptionresult.h> -#include <gpgme++/signingresult.h> - -#include <iostream> - -using namespace GpgME; - -std::ostream &operator<<(std::ostream &os, const QString &s) -{ - return os << s.toLocal8Bit().constData(); -} - -struct CommandLineOptions { - bool armor = false; - bool sign = false; - QString archiveName; - QString baseDirectory; - std::chrono::seconds cancelTimeout{0}; - std::vector<QString> filesAndDirectories; -}; - -CommandLineOptions parseCommandLine(const QStringList &arguments) -{ - CommandLineOptions options; - - QCommandLineParser parser; - parser.setApplicationDescription("Test program for EncryptArchiveJob and SignEncryptArchiveJob"); - parser.addHelpOption(); - parser.addOptions({ - {{"s", "sign"}, "Sign archive before encryption."}, - {{"o", "output"}, "Write output to FILE.", "FILE"}, - {{"a", "armor"}, "Create ASCII armored output."}, - {{"C", "directory"}, "Change to DIRECTORY before creating the archive.", "DIRECTORY"}, - {"cancel-after", "Cancel the running job after SECONDS seconds.", "SECONDS"}, - }); - parser.addPositionalArgument("files", "Files and directories to add to the archive", "[files] [directories]"); - - parser.process(arguments); - - const auto args = parser.positionalArguments(); - if (args.empty()) { - parser.showHelp(1); - } - - options.armor = parser.isSet("armor"); - options.sign = parser.isSet("sign"); - options.archiveName = parser.value("output"); - options.baseDirectory = parser.value("directory"); - if (parser.isSet("cancel-after")) { - bool ok; - options.cancelTimeout = std::chrono::seconds{parser.value("cancel-after").toInt(&ok)}; - if (!ok) { - options.cancelTimeout = std::chrono::seconds{-1}; - } - } - std::copy(args.begin(), args.end(), std::back_inserter(options.filesAndDirectories)); - - return options; -} - -QString checkOutputFilePath(const QString &fileName, const QString &baseDirectory) -{ - const QFileInfo fi{QDir{baseDirectory}, fileName}; - if (fi.exists()) { - qCritical() << "File" << fi.filePath() << "exists. Bailing out."; - return {}; - } - return fileName; -} - -int main(int argc, char **argv) -{ - GpgME::initializeLibrary(); - - QCoreApplication app{argc, argv}; - app.setApplicationName("run-encryptarchivejob"); - - const auto options = parseCommandLine(app.arguments()); - if (options.cancelTimeout.count() < 0) { - std::cerr << "Ignoring invalid timeout for cancel." << std::endl; - } - - if ((options.sign && !QGpgME::SignEncryptArchiveJob::isSupported()) - || (!options.sign && !QGpgME::EncryptArchiveJob::isSupported())) { - std::cerr << "Error: Encrypting archives is not supported by your version of gpg." << std::endl; - return 1; - } - - std::shared_ptr<QFile> output; - QString outputFilePath; - if (options.archiveName.isEmpty() || options.archiveName == QLatin1String{"-"}) { - output.reset(new QFile); - output->open(stdout, QIODevice::WriteOnly); - } else { - outputFilePath = checkOutputFilePath(options.archiveName, options.baseDirectory); - if (outputFilePath.isEmpty()) { - return 1; - } - } - - if (options.sign) { - auto job = QGpgME::openpgp()->signEncryptArchiveJob(options.armor); - if (!job) { - std::cerr << "Error: Could not create job" << std::endl; - return 1; - } - job->setBaseDirectory(options.baseDirectory); - QObject::connect(job, &QGpgME::SignEncryptArchiveJob::result, &app, [](const GpgME::SigningResult &signingResult, const GpgME::EncryptionResult &encryptionResult, const QString &auditLog, const GpgME::Error &) { - std::cerr << "Diagnostics: " << auditLog << std::endl; - std::cerr << "Signing Result: " << signingResult << std::endl; - std::cerr << "Encryption Result: " << encryptionResult << std::endl; - qApp->quit(); - }); - if (options.cancelTimeout.count() > 0) { - QTimer::singleShot(options.cancelTimeout, job, [job]() { - std::cerr << "Canceling job" << std::endl; - job->slotCancel(); - }); - } - - GpgME::Error err; - if (output) { - err = job->start({}, {}, options.filesAndDirectories, output, GpgME::Context::None); - } else { - job->setInputPaths(options.filesAndDirectories); - job->setOutputFile(outputFilePath); - err = job->startIt(); - } - if (err) { - std::cerr << "Error: Starting the job failed: " << err << std::endl; - return 1; - } - } else { - auto job = QGpgME::openpgp()->encryptArchiveJob(options.armor); - if (!job) { - std::cerr << "Error: Could not create job" << std::endl; - return 1; - } - job->setBaseDirectory(options.baseDirectory); - QObject::connect(job, &QGpgME::EncryptArchiveJob::result, &app, [](const GpgME::EncryptionResult &result, const QString &auditLog, const GpgME::Error &) { - std::cerr << "Diagnostics: " << auditLog << std::endl; - std::cerr << "Result: " << result << std::endl; - qApp->quit(); - }); - if (options.cancelTimeout.count() > 0) { - QTimer::singleShot(options.cancelTimeout, job, [job]() { - std::cerr << "Canceling job" << std::endl; - job->slotCancel(); - }); - } - - GpgME::Error err; - if (output) { - err = job->start({}, options.filesAndDirectories, output, GpgME::Context::None); - } else { - job->setInputPaths(options.filesAndDirectories); - job->setOutputFile(outputFilePath); - err = job->startIt(); - } - if (err) { - std::cerr << "Error: Starting the job failed: " << err << std::endl; - return 1; - } - } - - return app.exec(); -} diff --git a/lang/qt/tests/run-encryptjob.cpp b/lang/qt/tests/run-encryptjob.cpp deleted file mode 100644 index 14c8ea44..00000000 --- a/lang/qt/tests/run-encryptjob.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/* - run-encryptjob.cpp - - This file is part of QGpgME's test suite. - Copyright (c) 2023 by g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License, - version 2, as published by the Free Software Foundation. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <debug.h> -#include <protocol.h> -#include <encryptjob.h> -#include <signencryptjob.h> - -#include <QCommandLineParser> -#include <QCoreApplication> -#include <QDebug> -#include <QFile> -#include <QTimer> - -#include <gpgme++/context.h> -#include <gpgme++/encryptionresult.h> -#include <gpgme++/signingresult.h> - -#include <iostream> - -using namespace GpgME; - -std::ostream &operator<<(std::ostream &os, const QString &s) -{ - return os << s.toLocal8Bit().constData(); -} - -struct CommandLineOptions { - bool armor = false; - bool sign = false; - QString inputFile; - QString outputFile; - std::chrono::seconds cancelTimeout{0}; -}; - -CommandLineOptions parseCommandLine(const QStringList &arguments) -{ - CommandLineOptions options; - - QCommandLineParser parser; - parser.setApplicationDescription("Test program for EncryptJob and SignEncryptJob"); - parser.addHelpOption(); - parser.addOptions({ - {{"s", "sign"}, "Sign file before encryption."}, - {{"o", "output"}, "Write output to FILE.", "FILE"}, - {{"a", "armor"}, "Create ASCII armored output."}, - {"cancel-after", "Cancel the running job after SECONDS seconds.", "SECONDS"}, - }); - parser.addPositionalArgument("file", "File to encrypt", "FILE"); - - parser.process(arguments); - - const auto args = parser.positionalArguments(); - if (args.size() != 1) { - parser.showHelp(1); - } - - options.armor = parser.isSet("armor"); - options.sign = parser.isSet("sign"); - options.inputFile = args.front(); - options.outputFile = parser.value("output"); - if (parser.isSet("cancel-after")) { - bool ok; - options.cancelTimeout = std::chrono::seconds{parser.value("cancel-after").toInt(&ok)}; - if (!ok) { - options.cancelTimeout = std::chrono::seconds{-1}; - } - } - - return options; -} - -int main(int argc, char **argv) -{ - GpgME::initializeLibrary(); - - QCoreApplication app{argc, argv}; - app.setApplicationName("run-encryptjob"); - - const auto options = parseCommandLine(app.arguments()); - if (options.cancelTimeout.count() < 0) { - std::cerr << "Ignoring invalid timeout for cancel." << std::endl; - } - - std::shared_ptr<QFile> output; - if (options.outputFile.isEmpty() || options.outputFile == QLatin1String{"-"}) { - output.reset(new QFile); - output->open(stdout, QIODevice::WriteOnly); - } else { - if (QFile::exists(options.outputFile)) { - qCritical() << "File" << options.outputFile << "exists. Bailing out."; - return 1; - } - } - - std::shared_ptr<QFile> input; - - if (options.sign) { - auto job = QGpgME::openpgp()->signEncryptJob(options.armor); - if (!job) { - std::cerr << "Error: Could not create job" << std::endl; - return 1; - } - QObject::connect(job, &QGpgME::SignEncryptJob::result, &app, [](const GpgME::SigningResult &signingResult, const GpgME::EncryptionResult &encryptionResult, const QByteArray &, const QString &auditLog, const GpgME::Error &) { - std::cerr << "Diagnostics: " << auditLog << std::endl; - std::cerr << "Signing Result: " << signingResult << std::endl; - std::cerr << "Encryption Result: " << encryptionResult << std::endl; - qApp->quit(); - }); - if (options.cancelTimeout.count() > 0) { - QTimer::singleShot(options.cancelTimeout, job, [job]() { - std::cerr << "Canceling job" << std::endl; - job->slotCancel(); - }); - } - - GpgME::Error err; - if (output) { - input.reset(new QFile{options.inputFile}); - input->open(QIODevice::ReadOnly); - job->start({}, {}, input, output, GpgME::Context::None); - } else { - job->setInputFile(options.inputFile); - job->setOutputFile(options.outputFile); - err = job->startIt(); - } - if (err) { - std::cerr << "Error: Starting the job failed: " << err << std::endl; - return 1; - } - } else { - auto job = QGpgME::openpgp()->encryptJob(options.armor); - if (!job) { - std::cerr << "Error: Could not create job" << std::endl; - return 1; - } - QObject::connect(job, &QGpgME::EncryptJob::result, &app, [](const GpgME::EncryptionResult &result, const QByteArray &, const QString &auditLog, const GpgME::Error &) { - std::cerr << "Diagnostics: " << auditLog << std::endl; - std::cerr << "Result: " << result << std::endl; - qApp->quit(); - }); - if (options.cancelTimeout.count() > 0) { - QTimer::singleShot(options.cancelTimeout, job, [job]() { - std::cerr << "Canceling job" << std::endl; - job->slotCancel(); - }); - } - - GpgME::Error err; - if (output) { - input.reset(new QFile{options.inputFile}); - input->open(QIODevice::ReadOnly); - job->start({}, input, output, GpgME::Context::None); - } else { - job->setInputFile(options.inputFile); - job->setOutputFile(options.outputFile); - err = job->startIt(); - } - if (err) { - std::cerr << "Error: Starting the job failed: " << err << std::endl; - return 1; - } - } - - return app.exec(); -} diff --git a/lang/qt/tests/run-exportjob.cpp b/lang/qt/tests/run-exportjob.cpp deleted file mode 100644 index ed6f8912..00000000 --- a/lang/qt/tests/run-exportjob.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - run-exportjob.cpp - - This file is part of QGpgME's test suite. - Copyright (c) 2022 by g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License, - version 2, as published by the Free Software Foundation. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <debug.h> -#include <exportjob.h> -#include <protocol.h> - -#include <gpgme++/context.h> - -#include <QCoreApplication> - -#include <iostream> - -using namespace GpgME; -using std::cout; -using std::cerr; - -static void showUsageAndExitWithCode(int exitCode) -{ - cerr << "Usage: run-exportjob [OPTION]... [PATTERN]...\n" - "Options:\n" - " --secret export secret keys instead of public keys\n" - " --secret-subkey export secret subkeys instead of public keys\n"; - - exit(exitCode); -} - -static QGpgME::ExportJob *createExportJob(unsigned int mode) -{ - if (mode & Context::ExportSecretSubkey) { - return QGpgME::openpgp()->secretSubkeyExportJob(/*armor=*/true); - } else if (mode & Context::ExportSecret) { - return QGpgME::openpgp()->secretKeyExportJob(/*armor=*/true); - } - return QGpgME::openpgp()->publicKeyExportJob(/*armor=*/true); -} - -int main(int argc, char *argv[]) -{ - GpgME::initializeLibrary(); - - QCoreApplication app{argc, argv}; - - unsigned int exportMode = 0; - - auto arguments = app.arguments(); - if (!arguments.isEmpty()) { - arguments.pop_front(); // remove program name - } - while (!arguments.isEmpty()) { - const auto &arg = arguments.front(); - if (!arg.startsWith(QLatin1String{"--"})) { - break; - } - if (arg == QLatin1String{"--"}) { - arguments.pop_front(); - break; - } - if (arg == QLatin1String{"--help"}) { - showUsageAndExitWithCode(0); - } else if (arg == QLatin1String{"--secret"}) { - exportMode = Context::ExportSecret; - arguments.pop_front(); - } else if (arg == QLatin1String{"--secret-subkey"}) { - exportMode = Context::ExportSecretSubkey; - arguments.pop_front(); - } else { - cerr << "Error: Invalid option " << arg.toStdString() << std::endl; - showUsageAndExitWithCode(1); - } - } - - auto job = createExportJob(exportMode); - QObject::connect(job, &QGpgME::ExportJob::result, - &app, [&app] (const GpgME::Error &err, const QByteArray &keyData, const QString &, const GpgME::Error &) { - if (err) { - cerr << "The ChangeExpiryJob failed with" << err << "."; - app.exit(1); - return; - } - cout << "Begin Result:\n" << keyData.toStdString() << "End Result:\n"; - app.exit(); - }); - job->start(arguments); - - return app.exec(); -} diff --git a/lang/qt/tests/run-importjob.cpp b/lang/qt/tests/run-importjob.cpp deleted file mode 100644 index 67ee73f3..00000000 --- a/lang/qt/tests/run-importjob.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - run-importjob.cpp - - This file is part of QGpgME's test suite. - Copyright (c) 2021 by g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License, - version 2, as published by the Free Software Foundation. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <debug.h> -#include <importjob.h> -#include <gpgme++/importresult.h> -#include <protocol.h> - -#include <QFile> -#include <QFileInfo> - -#include <QDebug> - -#include <set> - -GpgME::Protocol guessProtocol(const QString &filename) -{ - static const std::set<QString> cmsExtensions = {"cer", "crt", "der", "p12", "p7c", "pem", "pfx"}; - static const std::set<QString> pgpExtensions = {"asc", "gpg", "pgp"}; - - const auto extension = QFileInfo{filename}.suffix(); - if (cmsExtensions.find(extension) != cmsExtensions.end()) { - return GpgME::CMS; - } else if (pgpExtensions.find(extension) != pgpExtensions.end()) { - return GpgME::OpenPGP; - } - qDebug() << "Unknown file name extension" << extension; - return GpgME::UnknownProtocol; -} - -int main(int argc, char **argv) -{ - GpgME::initializeLibrary(); - - if (argc != 2) { - qInfo().noquote() << "Usage:" << argv[0] << "<certificate file>"; - return 1; - } - const auto filename = QString::fromLocal8Bit(argv[1]); - - QFile f{filename}; - if (!f.exists()) { - qWarning() << "Error: File not found" << filename; - return 1; - } - const auto protocol = guessProtocol(filename); - if (protocol == GpgME::UnknownProtocol) { - qWarning() << "Error: Unknown file type"; - return 1; - } - if (!f.open(QIODevice::ReadOnly)) { - qWarning() << "Error: Failed to open file" << filename << "for reading."; - return 1; - } - - const auto keyData = f.readAll(); - auto job = (protocol == GpgME::CMS ? QGpgME::smime() : QGpgME::openpgp())->importJob(); - const auto result = job->exec(keyData); - qDebug() << "Result error:" << result.error(); - for (const auto &line : QString::fromStdString(QGpgME::toLogString(result)).split('\n')) { - qDebug().noquote() << line; - } - return 0; -} diff --git a/lang/qt/tests/run-keyformailboxjob.cpp b/lang/qt/tests/run-keyformailboxjob.cpp deleted file mode 100644 index 8ec0c5b3..00000000 --- a/lang/qt/tests/run-keyformailboxjob.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - run-keyformailbox.cpp - - This file is part of QGpgME's test suite. - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License, - version 2, as published by the Free Software Foundation. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "keyformailboxjob.h" -#include "keylistjob.h" -#include "protocol.h" - -#include <gpgme++/key.h> -#include <gpgme++/keylistresult.h> - -#include <QDebug> - - -int main(int argc, char **argv) -{ - QString mailbox; - if (argc == 2) { - mailbox = QString::fromLocal8Bit(argv[1]); - } - - auto job = QGpgME::openpgp()->keyForMailboxJob(); - GpgME::Key k; - GpgME::UserID uid; - job->exec(mailbox, true, k, uid); - qDebug() << "UID Name: " << uid.name() << " Mail: " << uid.email() << " id: " << uid.id(); - qDebug() << "Key fpr: " << k.primaryFingerprint(); - return 0; -} diff --git a/lang/qt/tests/run-receivekeysjob.cpp b/lang/qt/tests/run-receivekeysjob.cpp deleted file mode 100644 index 44553218..00000000 --- a/lang/qt/tests/run-receivekeysjob.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - run-receivekeysjob.cpp - - This file is part of QGpgME's test suite. - Copyright (c) 2022 by g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License, - version 2, as published by the Free Software Foundation. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <debug.h> -#include <gpgme++/importresult.h> -#include <protocol.h> -#include <receivekeysjob.h> - -#include <QCoreApplication> -#include <QDebug> - -#include <iostream> - -int main(int argc, char **argv) -{ - GpgME::initializeLibrary(); - - if (argc < 2) { - std::cerr << "Usage: " << argv[0] << " KEYID..." << std::endl; - return 1; - } - - QCoreApplication app(argc, argv); - const QStringList keyIds = qApp->arguments().mid(1); - - auto job = QGpgME::openpgp()->receiveKeysJob(); - const auto result = job->exec(keyIds); - - std::cout << "Result: " << result.error() << std::endl; - std::cout << "Details:\n" << result << std::endl; - - return 0; -} diff --git a/lang/qt/tests/run-refreshkeysjob.cpp b/lang/qt/tests/run-refreshkeysjob.cpp deleted file mode 100644 index ad653a54..00000000 --- a/lang/qt/tests/run-refreshkeysjob.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* - run-refreshkeysjob.cpp - - This file is part of QGpgME's test suite. - Copyright (c) 2022 by g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License, - version 2, as published by the Free Software Foundation. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <debug.h> -#include <protocol.h> -#include <refreshkeysjob.h> -#include <receivekeysjob.h> - -#include <QCoreApplication> -#include <QDebug> - -#include <gpgme++/context.h> -#include <gpgme++/importresult.h> - -#include <iostream> - -using namespace GpgME; - -std::ostream &operator<<(std::ostream &os, const QString &s) -{ - return os << s.toLocal8Bit().constData(); -} - -const char *displayName(Protocol protocol) -{ - switch (protocol) { - case GpgME::OpenPGP: - return "OpenPGP"; - case GpgME::CMS: - return "S/MIME"; - default: - return "Unknown protocol"; - } -} - -struct KeyAndError { - Key key; - Error error; -}; - -KeyAndError getKey(const QString &keyId, Protocol protocol) -{ - KeyAndError result; - - auto ctx = Context::create(protocol); - if (!ctx) { - result.error = Error::fromCode(GPG_ERR_GENERAL); - return result; - } - - result.key = ctx->key(keyId.toLatin1().constData(), result.error); - if (result.error.code() == GPG_ERR_EOF) { - result.error = Error{}; - } - return result; -} - -int main(int argc, char **argv) -{ - GpgME::initializeLibrary(); - - if (argc != 2) { - std::cerr << "Usage: " << argv[0] << " KEYID" << std::endl; - return 1; - } - - QCoreApplication app{argc, argv}; - const auto keyId = qApp->arguments().last(); - - auto openPGPKey = getKey(keyId, GpgME::OpenPGP); - auto smimeKey = getKey(keyId, GpgME::CMS); - if ((!openPGPKey.key.isNull() && !smimeKey.key.isNull()) - || (openPGPKey.error.code() == GPG_ERR_AMBIGUOUS_NAME) - || (smimeKey.error.code() == GPG_ERR_AMBIGUOUS_NAME)) { - std::cerr << "Error: Multiple keys matching '" << keyId << "' found" << std::endl; - return 1; - } else if (openPGPKey.key.isNull() && smimeKey.key.isNull()) { - std::cerr << "Error: No key matching '" << keyId << "' found" << std::endl; - return 1; - } - if (openPGPKey.error) { - std::cerr << "Warning: Error while getting OpenPGP key: " << openPGPKey.error << std::endl; - } - if (smimeKey.error) { - std::cerr << "Warning: Error while getting S/MIME key: " << openPGPKey.error << std::endl; - } - auto key = openPGPKey.key.isNull() ? smimeKey.key : openPGPKey.key; - std::cout << "Refreshing " << displayName(key.protocol()) << " key " << key.userID(0).id() << std::endl; - - if (key.protocol() == GpgME::OpenPGP) { - auto job = QGpgME::openpgp()->receiveKeysJob(); - if (!job) { - std::cerr << "Error: Could not create job to refresh OpenPGP key" << std::endl; - return 1; - } - QObject::connect(job, &QGpgME::ReceiveKeysJob::result, &app, [](const GpgME::ImportResult &result, const QString &, const GpgME::Error &) { - std::cout << "Result: " << result << std::endl; - qApp->quit(); - }); - const auto err = job->start({QString::fromLatin1(key.primaryFingerprint())}); - if (err) { - std::cerr << "Error: " << err << std::endl; - return 1; - } - } else { - auto job = QGpgME::smime()->refreshKeysJob(); - if (!job) { - std::cerr << "Error: Could not create job to refresh S/MIME key" << std::endl; - return 1; - } - QObject::connect(job, &QGpgME::RefreshKeysJob::result, &app, [](const GpgME::Error &err) { - std::cout << "Result: " << err << std::endl; - qApp->quit(); - }); - const auto err = job->start({key}); - if (err) { - std::cerr << "Error: " << err << std::endl; - return 1; - } - } - - return app.exec(); -} diff --git a/lang/qt/tests/run-signarchivejob.cpp b/lang/qt/tests/run-signarchivejob.cpp deleted file mode 100644 index 3152507e..00000000 --- a/lang/qt/tests/run-signarchivejob.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - run-signarchivejob.cpp - - This file is part of QGpgME's test suite. - Copyright (c) 2023 by g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License, - version 2, as published by the Free Software Foundation. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <debug.h> -#include <protocol.h> -#include <signarchivejob.h> - -#include <QCommandLineParser> -#include <QCoreApplication> -#include <QDebug> -#include <QDir> -#include <QFile> -#include <QFileInfo> -#include <QTimer> - -#include <gpgme++/context.h> -#include <gpgme++/signingresult.h> - -#include <iostream> - -using namespace GpgME; - -std::ostream &operator<<(std::ostream &os, const QString &s) -{ - return os << s.toLocal8Bit().constData(); -} - -struct CommandLineOptions { - bool armor; - QString archiveName; - QString baseDirectory; - std::chrono::seconds cancelTimeout{0}; - std::vector<QString> filesAndDirectories; -}; - -CommandLineOptions parseCommandLine(const QStringList &arguments) -{ - CommandLineOptions options; - - QCommandLineParser parser; - parser.setApplicationDescription("Test program for SignArchiveJob"); - parser.addHelpOption(); - parser.addOptions({ - {{"o", "output"}, "Write output to FILE.", "FILE"}, - {{"a", "armor"}, "Create ASCII armored output."}, - {{"C", "directory"}, "Change to DIRECTORY before creating the archive.", "DIRECTORY"}, - {"cancel-after", "Cancel the running job after SECONDS seconds.", "SECONDS"}, - }); - parser.addPositionalArgument("files", "Files and directories to add to the archive", "[files] [directories]"); - - parser.process(arguments); - - const auto args = parser.positionalArguments(); - if (args.empty()) { - parser.showHelp(1); - } - - options.armor = parser.isSet("armor"); - options.archiveName = parser.value("output"); - options.baseDirectory = parser.value("directory"); - if (parser.isSet("cancel-after")) { - bool ok; - options.cancelTimeout = std::chrono::seconds{parser.value("cancel-after").toInt(&ok)}; - if (!ok) { - options.cancelTimeout = std::chrono::seconds{-1}; - } - } - std::copy(args.begin(), args.end(), std::back_inserter(options.filesAndDirectories)); - - return options; -} - -QString checkOutputFilePath(const QString &fileName, const QString &baseDirectory) -{ - const QFileInfo fi{QDir{baseDirectory}, fileName}; - if (fi.exists()) { - qCritical() << "File" << fi.filePath() << "exists. Bailing out."; - return {}; - } - return fileName; -} - -int main(int argc, char **argv) -{ - GpgME::initializeLibrary(); - - QCoreApplication app{argc, argv}; - app.setApplicationName("run-signarchivejob"); - - const auto options = parseCommandLine(app.arguments()); - if (options.cancelTimeout.count() < 0) { - std::cerr << "Ignoring invalid timeout for cancel." << std::endl; - } - - if (!QGpgME::SignArchiveJob::isSupported()) { - std::cerr << "Error: Signing archives is not supported by your version of gpg." << std::endl; - return 1; - } - - std::shared_ptr<QFile> output; - QString outputFilePath; - if (options.archiveName.isEmpty() || options.archiveName == QLatin1String{"-"}) { - output.reset(new QFile); - output->open(stdout, QIODevice::WriteOnly); - } else { - outputFilePath = checkOutputFilePath(options.archiveName, options.baseDirectory); - if (outputFilePath.isEmpty()) { - return 1; - } - } - - auto job = QGpgME::openpgp()->signArchiveJob(options.armor); - if (!job) { - std::cerr << "Error: Could not create job" << std::endl; - return 1; - } - job->setBaseDirectory(options.baseDirectory); - QObject::connect(job, &QGpgME::SignArchiveJob::result, &app, [](const GpgME::SigningResult &result, const QString &auditLog, const GpgME::Error &) { - std::cerr << "Diagnostics: " << auditLog << std::endl; - std::cerr << "Result: " << result << std::endl; - qApp->quit(); - }); - if (options.cancelTimeout.count() > 0) { - QTimer::singleShot(options.cancelTimeout, job, [job]() { - std::cerr << "Canceling job" << std::endl; - job->slotCancel(); - }); - } - - GpgME::Error err; - if (output) { - err = job->start({}, options.filesAndDirectories, output); - } else { - job->setInputPaths(options.filesAndDirectories); - job->setOutputFile(outputFilePath); - err = job->startIt(); - } - if (err) { - std::cerr << "Error: Starting the job failed: " << err << std::endl; - return 1; - } - - return app.exec(); -} diff --git a/lang/qt/tests/run-signjob.cpp b/lang/qt/tests/run-signjob.cpp deleted file mode 100644 index 9c2ebcc2..00000000 --- a/lang/qt/tests/run-signjob.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - run-signjob.cpp - - This file is part of QGpgME's test suite. - Copyright (c) 2023 by g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License, - version 2, as published by the Free Software Foundation. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <debug.h> -#include <protocol.h> -#include <signjob.h> - -#include <QCommandLineParser> -#include <QCoreApplication> -#include <QDebug> -#include <QFile> -#include <QTimer> - -#include <gpgme++/context.h> -#include <gpgme++/signingresult.h> - -#include <iostream> - -using namespace GpgME; - -std::ostream &operator<<(std::ostream &os, const QString &s) -{ - return os << s.toLocal8Bit().constData(); -} - -struct CommandLineOptions { - GpgME::SignatureMode signingFlags = GpgME::NormalSignatureMode; - bool armor = false; - bool appendSignature = false; - QString inputFile; - QString outputFile; - std::chrono::seconds cancelTimeout{0}; -}; - -CommandLineOptions parseCommandLine(const QStringList &arguments) -{ - CommandLineOptions options; - - QCommandLineParser parser; - parser.setApplicationDescription("Test program for SignJob"); - parser.addHelpOption(); - parser.addOptions({ - {{"o", "output"}, "Write output to FILE.", "FILE"}, - {{"a", "armor"}, "Create ASCII armored output."}, - {{"b", "detach-sign"}, "Create a detached signature."}, - {"append", "Append new (detached) signature to existing file."}, - {"cancel-after", "Cancel the running job after SECONDS seconds.", "SECONDS"}, - }); - parser.addPositionalArgument("file", "File to sign", "FILE"); - - parser.process(arguments); - - const auto args = parser.positionalArguments(); - if (args.size() != 1) { - parser.showHelp(1); - } - - options.armor = parser.isSet("armor"); - if (parser.isSet("detach-sign")) { - options.signingFlags = GpgME::Detached; - options.appendSignature = parser.isSet("append"); - } - options.inputFile = args.front(); - options.outputFile = parser.value("output"); - if (parser.isSet("cancel-after")) { - bool ok; - options.cancelTimeout = std::chrono::seconds{parser.value("cancel-after").toInt(&ok)}; - if (!ok) { - options.cancelTimeout = std::chrono::seconds{-1}; - } - } - - return options; -} - -int main(int argc, char **argv) -{ - GpgME::initializeLibrary(); - - QCoreApplication app{argc, argv}; - app.setApplicationName("run-signjob"); - - const auto options = parseCommandLine(app.arguments()); - if (options.cancelTimeout.count() < 0) { - std::cerr << "Ignoring invalid timeout for cancel." << std::endl; - } - - std::shared_ptr<QFile> output; - if (options.outputFile.isEmpty() || options.outputFile == QLatin1String{"-"}) { - output.reset(new QFile); - output->open(stdout, QIODevice::WriteOnly); - } else { - if (QFile::exists(options.outputFile) && !options.appendSignature) { - qCritical() << "File" << options.outputFile << "exists. Bailing out."; - return 1; - } - } - - auto job = QGpgME::openpgp()->signJob(options.armor); - if (!job) { - std::cerr << "Error: Could not create job" << std::endl; - return 1; - } - QObject::connect(job, &QGpgME::SignJob::result, &app, [](const GpgME::SigningResult &result, const QByteArray &, const QString &auditLog, const GpgME::Error &) { - std::cerr << "Diagnostics: " << auditLog << std::endl; - std::cerr << "Result: " << result << std::endl; - qApp->quit(); - }); - if (options.cancelTimeout.count() > 0) { - QTimer::singleShot(options.cancelTimeout, job, [job]() { - std::cerr << "Canceling job" << std::endl; - job->slotCancel(); - }); - } - - std::shared_ptr<QFile> input; - GpgME::Error err; - if (output) { - input.reset(new QFile{options.inputFile}); - input->open(QIODevice::ReadOnly); - job->start({}, input, output, GpgME::NormalSignatureMode); - } else { - job->setInputFile(options.inputFile); - job->setOutputFile(options.outputFile); - job->setSigningFlags(options.signingFlags); - job->setAppendSignature(options.appendSignature); - err = job->startIt(); - } - if (err) { - std::cerr << "Error: Starting the job failed: " << err << std::endl; - return 1; - } - - return app.exec(); -} diff --git a/lang/qt/tests/run-verifydetachedjob.cpp b/lang/qt/tests/run-verifydetachedjob.cpp deleted file mode 100644 index 17a719e9..00000000 --- a/lang/qt/tests/run-verifydetachedjob.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - run-verifydetachedjob.cpp - - This file is part of QGpgME's test suite. - Copyright (c) 2024 by g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License, - version 2, as published by the Free Software Foundation. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <debug.h> -#include <protocol.h> -#include <verifydetachedjob.h> - -#include <QCommandLineParser> -#include <QCoreApplication> -#include <QDebug> -#include <QFile> - -#include <gpgme++/context.h> -#include <gpgme++/verificationresult.h> - -#include <iostream> - -using namespace GpgME; - -std::ostream &operator<<(std::ostream &os, const QString &s) -{ - return os << s.toLocal8Bit().constData(); -} - -struct CommandLineOptions { - bool processAllSignatures = false; - QString signatureFile; - QString signedFile; -}; - -CommandLineOptions parseCommandLine(const QStringList &arguments) -{ - CommandLineOptions options; - - QCommandLineParser parser; - parser.setApplicationDescription("Test program for VerifyDetachedJob"); - parser.addHelpOption(); - parser.addOptions({ - {"process-all-signatures", "Don't stop signature checking after bad signature."}, - }); - parser.addPositionalArgument("signature", "Detached SIGNATURE to verify", "SIGNATURE"); - parser.addPositionalArgument("signed file", "FILE containing the signed data", "FILE"); - - parser.process(arguments); - - const auto args = parser.positionalArguments(); - if (args.size() != 2) { - parser.showHelp(1); - } - - options.processAllSignatures = parser.isSet("process-all-signatures"); - options.signatureFile = args[0]; - options.signedFile = args[1]; - - return options; -} - -int main(int argc, char **argv) -{ - GpgME::initializeLibrary(); - - QCoreApplication app{argc, argv}; - app.setApplicationName("run-verifydetachedjob"); - - const auto options = parseCommandLine(app.arguments()); - - auto job = QGpgME::openpgp()->verifyDetachedJob(); - if (!job) { - std::cerr << "Error: Could not create job" << std::endl; - return 1; - } - QObject::connect(job, - &QGpgME::VerifyDetachedJob::result, - &app, - [](const GpgME::VerificationResult &verificationResult, - const QString &auditLog, - const GpgME::Error &) { - std::cerr << "Diagnostics: " << auditLog << std::endl; - std::cerr << "Verification Result: " << verificationResult << std::endl; - qApp->quit(); - }); - - std::shared_ptr<QFile> input; - GpgME::Error err; - job->setProcessAllSignatures(options.processAllSignatures); - job->setSignatureFile(options.signatureFile); - job->setSignedFile(options.signedFile); - err = job->startIt(); - if (err) { - std::cerr << "Error: Starting the job failed: " << err << std::endl; - return 1; - } - - return app.exec(); -} diff --git a/lang/qt/tests/run-verifyopaquejob.cpp b/lang/qt/tests/run-verifyopaquejob.cpp deleted file mode 100644 index a3245b4f..00000000 --- a/lang/qt/tests/run-verifyopaquejob.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - run-verifyopaquejob.cpp - - This file is part of QGpgME's test suite. - Copyright (c) 2023 by g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License, - version 2, as published by the Free Software Foundation. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <debug.h> -#include <protocol.h> -#include <verifyopaquejob.h> - -#include <QCommandLineParser> -#include <QCoreApplication> -#include <QDebug> -#include <QFile> -#include <QTimer> - -#include <gpgme++/context.h> -#include <gpgme++/verificationresult.h> - -#include <iostream> - -using namespace GpgME; - -std::ostream &operator<<(std::ostream &os, const QString &s) -{ - return os << s.toLocal8Bit().constData(); -} - -struct CommandLineOptions { - bool processAllSignatures = false; - QString inputFile; - QString outputFile; - std::chrono::seconds cancelTimeout{0}; -}; - -CommandLineOptions parseCommandLine(const QStringList &arguments) -{ - CommandLineOptions options; - - QCommandLineParser parser; - parser.setApplicationDescription("Test program for VerifyOpaqueJob"); - parser.addHelpOption(); - parser.addOptions({ - {{"o", "output"}, "Write output to FILE.", "FILE"}, - {"cancel-after", "Cancel the running job after SECONDS seconds.", "SECONDS"}, - {"process-all-signatures", "Don't stop signature checking after bad signature."}, - }); - parser.addPositionalArgument("file", "File to verify", "FILE"); - - parser.process(arguments); - - const auto args = parser.positionalArguments(); - if (args.size() != 1) { - parser.showHelp(1); - } - - options.processAllSignatures = parser.isSet("process-all-signatures"); - options.inputFile = args.front(); - options.outputFile = parser.value("output"); - if (parser.isSet("cancel-after")) { - bool ok; - options.cancelTimeout = std::chrono::seconds{parser.value("cancel-after").toInt(&ok)}; - if (!ok) { - options.cancelTimeout = std::chrono::seconds{-1}; - } - } - - return options; -} - -int main(int argc, char **argv) -{ - GpgME::initializeLibrary(); - - QCoreApplication app{argc, argv}; - app.setApplicationName("run-verifyopaquejob"); - - const auto options = parseCommandLine(app.arguments()); - if (options.cancelTimeout.count() < 0) { - std::cerr << "Ignoring invalid timeout for cancel." << std::endl; - } - - std::shared_ptr<QFile> output; - if (options.outputFile.isEmpty() || options.outputFile == QLatin1String{"-"}) { - output.reset(new QFile); - output->open(stdout, QIODevice::WriteOnly); - } else { - if (QFile::exists(options.outputFile)) { - qCritical() << "File" << options.outputFile << "exists. Bailing out."; - return 1; - } - } - - auto job = QGpgME::openpgp()->verifyOpaqueJob(); - if (!job) { - std::cerr << "Error: Could not create job" << std::endl; - return 1; - } - QObject::connect(job, - &QGpgME::VerifyOpaqueJob::result, - &app, - [](const GpgME::VerificationResult &verificationResult, - const QByteArray &, - const QString &auditLog, - const GpgME::Error &) { - std::cerr << "Diagnostics: " << auditLog << std::endl; - std::cerr << "Verification Result: " << verificationResult << std::endl; - qApp->quit(); - }); - if (options.cancelTimeout.count() > 0) { - QTimer::singleShot(options.cancelTimeout, job, [job]() { - std::cerr << "Canceling job" << std::endl; - job->slotCancel(); - }); - } - - std::shared_ptr<QFile> input; - GpgME::Error err; - job->setProcessAllSignatures(options.processAllSignatures); - if (output) { - input.reset(new QFile{options.inputFile}); - input->open(QIODevice::ReadOnly); - job->start(input, output); - } else { - job->setInputFile(options.inputFile); - job->setOutputFile(options.outputFile); - err = job->startIt(); - } - if (err) { - std::cerr << "Error: Starting the job failed: " << err << std::endl; - return 1; - } - - return app.exec(); -} diff --git a/lang/qt/tests/run-wkdrefreshjob.cpp b/lang/qt/tests/run-wkdrefreshjob.cpp deleted file mode 100644 index 17bad83d..00000000 --- a/lang/qt/tests/run-wkdrefreshjob.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - run-wkdrefreshjob.cpp - - This file is part of QGpgME's test suite. - Copyright (c) 2023 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <debug.h> -#include <protocol.h> -#include <wkdrefreshjob.h> - -#include <QCommandLineParser> -#include <QCoreApplication> -#include <QDebug> - -#include <gpgme++/context.h> -#include <gpgme++/importresult.h> - -#include <iostream> - -using namespace GpgME; - -std::ostream &operator<<(std::ostream &os, const QString &s) -{ - return os << s.toLocal8Bit().constData(); -} - -struct CommandLineOptions { - bool allUserIds; - QString keyId; -}; - -CommandLineOptions parseCommandLine(const QStringList &arguments) -{ - CommandLineOptions options; - - QCommandLineParser parser; - parser.setApplicationDescription("Test program for WKDRefreshJob"); - parser.addHelpOption(); - parser.addOptions({ - {"all-userids", "Query WKD for all user IDs."}, - }); - parser.addPositionalArgument("key ID", "Key to refresh"); - - parser.process(arguments); - - const auto args = parser.positionalArguments(); - if (args.size() != 1) { - parser.showHelp(1); - } - - options.allUserIds = parser.isSet("all-userids"); - options.keyId = args[0]; - - return options; -} - -Key getOpenPGPKey(const QString &keyId, Error &err) -{ - Key key; - - auto ctx = Context::create(GpgME::OpenPGP); - if (!ctx) { - err = Error::fromCode(GPG_ERR_GENERAL); - return key; - } - - key = ctx->key(keyId.toLatin1().constData(), err); - if (err.code() == GPG_ERR_EOF) { - err = Error{}; - } - return key; -} - -int main(int argc, char **argv) -{ - GpgME::initializeLibrary(); - - QCoreApplication app{argc, argv}; - app.setApplicationName("run-wkdrefreshjob"); - - const auto options = parseCommandLine(app.arguments()); - - Error err; - const auto key = getOpenPGPKey(options.keyId, err); - if (err.code() == GPG_ERR_AMBIGUOUS_NAME) { - std::cerr << "Error: Multiple OpenPGP keys matching '" << options.keyId << "' found" << std::endl; - return 1; - } - if (key.isNull()) { - std::cerr << "Error: No OpenPGP key matching '" << options.keyId << "' found" << std::endl; - return 1; - } - if (err) { - std::cerr << "Error while getting OpenPGP key: " << err << std::endl; - return 1; - } - std::cout << "Refreshing OpenPGP key " << key.userID(0).id() << std::endl; - - auto job = QGpgME::openpgp()->wkdRefreshJob(); - if (!job) { - std::cerr << "Error: Could not create job to refresh OpenPGP key" << std::endl; - return 1; - } - QObject::connect(job, &QGpgME::WKDRefreshJob::result, &app, [](const GpgME::ImportResult &result, const QString &, const GpgME::Error &) { - if (result.isNull()) { - std::cout << "Empty result. Lookup via WKD failed or no user ID was originally retrieved via WKD." << std::endl; - } else { - std::cout << "Result: " << result << std::endl; - } - qApp->quit(); - }); - if (options.allUserIds) { - err = job->start(key.userIDs()); - } else { - err = job->start({key}); - } - if (err) { - std::cerr << "Error: " << err << std::endl; - return 1; - } - - return app.exec(); -} diff --git a/lang/qt/tests/t-addexistingsubkey.cpp b/lang/qt/tests/t-addexistingsubkey.cpp deleted file mode 100644 index df620ddb..00000000 --- a/lang/qt/tests/t-addexistingsubkey.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* t-addexistingsubkey.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "t-support.h" - -#include "addexistingsubkeyjob.h" -#include "protocol.h" - -#include <QSignalSpy> -#include <QTest> - -#include <gpgme++/context.h> -#include <gpgme++/data.h> -#include <gpgme++/engineinfo.h> - -#include <algorithm> - -using namespace QGpgME; -using namespace GpgME; - -static const char *requiredVersion = "2.3.5"; - -/* Test keys - sec# ed25519 2022-01-13 [SC] - 1CB8C6A0317AA83F44FE009932392C82B814C8E0 - uid [ unknown] [email protected] - ssb cv25519 2022-01-13 [E] - ssb cv25519 2022-01-13 [E] [expires: 2100-01-01] - - sec ed25519 2022-01-13 [SC] - C3C87F0A3920B01F9E4450EA2B79F21D4DD10BFC - uid [ unknown] [email protected] - ssb cv25519 2022-01-13 [E] - * generated with -export GNUPGHOME=$(mktemp -d) -gpg -K -gpg --batch --pinentry-mode loopback --passphrase abc --quick-gen-key [email protected] default default never -fpr=$(gpg -k --with-colons [email protected] | grep ^fpr | head -1 | cut -d ':' -f 10) -gpg --batch --pinentry-mode loopback --passphrase abc --quick-add-key ${fpr} default default 21000101T120000 -gpg --batch --pinentry-mode loopback --passphrase abc --quick-gen-key [email protected] default default never -gpg -K -gpg --export-secret-subkeys --armor --batch --pinentry-mode loopback --passphrase abc --comment [email protected] [email protected] | sed 's/\(.*\)/ "\1\\n"/' -gpg --export-secret-keys --armor --batch --pinentry-mode loopback --passphrase abc --comment [email protected] [email protected] | sed 's/\(.*\)/ "\1\\n"/' -#rm -rf ${GNUPGHOME} -unset GNUPGHOME -*/ -static const char *testKeyData = - "-----BEGIN PGP PRIVATE KEY BLOCK-----\n" - "Comment: [email protected]\n" - "\n" - "lDsEYd/ujBYJKwYBBAHaRw8BAQdAwiZPINTcrpgmu6ZWSaPZlcRSd4nDuofVMhe7\n" - "c2XrFyT/AGUAR05VAbQWc291cmNlLWtleUBleGFtcGxlLm5ldIiUBBMWCgA8FiEE\n" - "HLjGoDF6qD9E/gCZMjksgrgUyOAFAmHf7owCGwMFCwkIBwIDIgIBBhUKCQgLAgQW\n" - "AgMBAh4HAheAAAoJEDI5LIK4FMjgupIA/Au2YEAT9dYdJd0eJCJerG5YAeoB+uBs\n" - "mBkgr6xXE0bIAP43b6u1Jtvf/Wm3BhRbLd5Tg67Ba4CIZ8ZLGng73FBoBpyLBGHf\n" - "7owSCisGAQQBl1UBBQEBB0Cpg8Qof/WShxROZZtmPnw24vTk0R8nIAF1CZJ0bG/C\n" - "SwMBCAf+BwMCtzxziVxQEor8w/VVzHp4/hVSCUyrpiX7Djf04cIMs2bFPduZLgxb\n" - "c1SXhlgiqU0YBNntbGGNdKjTP6FMbYWq1+NwQm6ZXtC76LPG7syM94h4BBgWCgAg\n" - "FiEEHLjGoDF6qD9E/gCZMjksgrgUyOAFAmHf7owCGwwACgkQMjksgrgUyOCI0wEA\n" - "+f56fkvDDUwMOMw7n4+GKpfJXpWhVL08ttccbBOa/9IA/2HYA/78ZaD8E5EyqAEK\n" - "Aj9Au+2oJu9V5qo92QEoqwYHnIsEYd/vgxIKKwYBBAGXVQEFAQEHQBa9FxJkm/9D\n" - "xABildkaYMrbJbu8BPk6uv9V8aLmv9FnAwEIB/4HAwIPhcbN8s6OzPz8/g78TrCh\n" - "xqQb2kygCEj+OQ4/XXU3lus2b5xS5h44LGt99Wisqx+wVPDXmPDJOaxjhHXDmJxd\n" - "/LplIEhykojSm3uUDxERiH4EGBYKACYWIQQcuMagMXqoP0T+AJkyOSyCuBTI4AUC\n" - "Yd/vgwIbDAUJkqcQPQAKCRAyOSyCuBTI4IUjAP9BTfOD+jy6lLmzNO9pquRSAxi/\n" - "PQuglGtpS0LQEJMEOwD+PFnsMe2EtQ+WVSDBeB7O0m61EXeY+RhpuhNtsNXVuwc=\n" - "=wIPU\n" - "-----END PGP PRIVATE KEY BLOCK-----\n" - "-----BEGIN PGP PRIVATE KEY BLOCK-----\n" - "Comment: [email protected]\n" - "\n" - "lIYEYd/v/RYJKwYBBAHaRw8BAQdAKoILWXG3yaLb2EniNKQLUjwsrvy5vgAN299J\n" - "W5cFbrz+BwMC/uKbCq3sK5H8QVtEQ/IxGmjWNBpy6c8EDlOG4APi4o4VE+bEYD8w\n" - "J3Kk/lzSm6ZT5vC6DDASks797omjXD+J7zZ0vtTPvheYi/nsVz2UebQWdGFyZ2V0\n" - "LWtleUBleGFtcGxlLm5ldIiUBBMWCgA8FiEEw8h/CjkgsB+eRFDqK3nyHU3RC/wF\n" - "AmHf7/0CGwMFCwkIBwIDIgIBBhUKCQgLAgQWAgMBAh4HAheAAAoJECt58h1N0Qv8\n" - "rXcBAPxnkXqpp4IY3iTKV5XAdo7Uys7U/joUD73rj2XEvgI1AQDhKK4PLxPhf3ki\n" - "FKU0RA7itxzOH+F8bQ5BdYS49jDPCpyLBGHf7/0SCisGAQQBl1UBBQEBB0Dq9rwA\n" - "hAA2UFJShFsLFp7+g4uhWDfuDa3VjeIQRM+9QgMBCAf+BwMCMfCTl0LNqsn836t5\n" - "f2ZHBuMcNs4JWYmdLAIVaewEHq7zhOsX3iB+/yxwu9g2mXc4XUJ1iQzXLOYwgGov\n" - "8jIovrr01hDkSg4rvM9JKMWdd4h4BBgWCgAgFiEEw8h/CjkgsB+eRFDqK3nyHU3R\n" - "C/wFAmHf7/0CGwwACgkQK3nyHU3RC/xyfAEAqnMdSv6FTAwAWrYvJqJtSVoEhjMn\n" - "3c2qMsu34Bk86/MBAKHbLFmdyePvHaxKeO8CkQDoJzK8rYzw3RAmq/5JsQkL\n" - "=rOVf\n" - "-----END PGP PRIVATE KEY BLOCK-----\n"; - -class AddExistingSubkeyJobTest : public QGpgMETest -{ - Q_OBJECT - -private Q_SLOTS: - - void initTestCase() - { - QGpgMETest::initTestCase(); - - // set up the test fixture for this test - qputenv("GNUPGHOME", mGnupgHomeTestFixture.path().toUtf8()); - QVERIFY(importSecretKeys(testKeyData, 2)); - } - - void init() - { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < requiredVersion) { - QSKIP("gpg does not yet support adding an existing subkey to another key via the command API"); - } - - // set up a copy of the test fixture for each test function - mGnupgHomeTestCopy.reset(new QTemporaryDir{}); - QVERIFY(copyKeyrings(mGnupgHomeTestFixture.path(), mGnupgHomeTestCopy->path())); - qputenv("GNUPGHOME", mGnupgHomeTestCopy->path().toUtf8()); - } - - void testAddExistingSubkeyAsync() - { - // Get the key the subkey should be added to - auto key = getTestKey("[email protected]"); - QVERIFY(!key.isNull()); - - // Get the key with the subkey to add - auto sourceKey = getTestKey("[email protected]", 3); - QVERIFY(!sourceKey.isNull()); - - auto job = std::unique_ptr<AddExistingSubkeyJob>{openpgp()->addExistingSubkeyJob()}; - hookUpPassphraseProvider(job.get()); - - Error result; - connect(job.get(), &AddExistingSubkeyJob::result, - job.get(), [this, &result](const Error &result_) { - result = result_; - Q_EMIT asyncDone(); - }); - QVERIFY(!job->start(key, sourceKey.subkey(1))); - job.release(); // after the job has been started it's on its own - - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - QCOMPARE(result.code(), static_cast<int>(GPG_ERR_NO_ERROR)); - key.update(); - QCOMPARE(key.numSubkeys(), 3u); - } - - void testAddExistingSubkeySync() - { - // Get the key the subkey should be added to - auto key = getTestKey("[email protected]"); - QVERIFY(!key.isNull()); - - // Get the key with the subkey to add - auto sourceKey = getTestKey("[email protected]", 3); - QVERIFY(!sourceKey.isNull()); - auto sourceSubkey = sourceKey.subkey(1); - QVERIFY(sourceSubkey.expirationTime() == 0); - - auto job = std::unique_ptr<AddExistingSubkeyJob>{openpgp()->addExistingSubkeyJob()}; - hookUpPassphraseProvider(job.get()); - - const auto result = job->exec(key, sourceSubkey); - - QCOMPARE(result.code(), static_cast<int>(GPG_ERR_NO_ERROR)); - key.update(); - QCOMPARE(key.numSubkeys(), 3u); - QCOMPARE(key.subkey(2).expirationTime(), 0); - } - - void testAddExistingSubkeyWithExpiration() - { - // Get the key the subkey should be added to - auto key = getTestKey("[email protected]"); - QVERIFY(!key.isNull()); - - // Get the key with the subkey to add - auto sourceKey = getTestKey("[email protected]", 3); - QVERIFY(!sourceKey.isNull()); - auto sourceSubkey = sourceKey.subkey(2); - QVERIFY(sourceSubkey.expirationTime() != 0); - - auto job = std::unique_ptr<AddExistingSubkeyJob>{openpgp()->addExistingSubkeyJob()}; - hookUpPassphraseProvider(job.get()); - - const auto result = job->exec(key, sourceSubkey); - - if (sourceSubkey.expirationTime() > 0) { - QCOMPARE(result.code(), static_cast<int>(GPG_ERR_NO_ERROR)); - key.update(); - QCOMPARE(key.numSubkeys(), 3u); - - // allow 1 second different expiration because gpg calculates with - // expiration as difference to current time and takes current time - // several times - const auto allowedDeltaTSeconds = 1; - const auto expectedExpirationRange = std::make_pair( - uint_least32_t(sourceSubkey.expirationTime()) - allowedDeltaTSeconds, - uint_least32_t(sourceSubkey.expirationTime()) + allowedDeltaTSeconds); - const auto actualExpiration = uint_least32_t(key.subkey(2).expirationTime()); - QVERIFY2(actualExpiration >= expectedExpirationRange.first, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.first)).c_str()); - QVERIFY2(actualExpiration <= expectedExpirationRange.second, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.second)).c_str()); - } else { - // on 32-bit systems the expiration date of the test key overflows; - // in this case we expect an appropriate error code - QCOMPARE(result.code(), static_cast<int>(GPG_ERR_INV_TIME)); - } - } - -private: - Key getTestKey(const char *pattern, unsigned int expectedSubkeys = 2) - { - auto ctx = Context::create(OpenPGP); - VERIFY_OR_OBJECT(ctx); - - Error err; - auto key = ctx->key(pattern, err, /*secret=*/true); - VERIFY_OR_OBJECT(!err); - VERIFY_OR_OBJECT(!key.isNull()); - COMPARE_OR_OBJECT(key.numSubkeys(), expectedSubkeys); - for (unsigned int i = 0; i < key.numSubkeys(); ++i) { - VERIFY_OR_OBJECT(!key.subkey(i).isNull()); - } - return key; - } - -private: - QTemporaryDir mGnupgHomeTestFixture; - std::unique_ptr<QTemporaryDir> mGnupgHomeTestCopy; -}; - -QTEST_MAIN(AddExistingSubkeyJobTest) - -#include "t-addexistingsubkey.moc" diff --git a/lang/qt/tests/t-changeexpiryjob.cpp b/lang/qt/tests/t-changeexpiryjob.cpp deleted file mode 100644 index b64bf798..00000000 --- a/lang/qt/tests/t-changeexpiryjob.cpp +++ /dev/null @@ -1,397 +0,0 @@ -/* t-changeexpiryjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2021 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "t-support.h" - -#include "changeexpiryjob.h" -#include <gpgme++/context.h> -#include <gpgme++/engineinfo.h> -#include "protocol.h" -#include "util.h" - -#include <QSignalSpy> -#include <QTemporaryDir> -#include <QTest> - -using namespace QGpgME; -using namespace GpgME; - -class TestChangeExpiryJob: public QGpgMETest -{ - Q_OBJECT - -private Q_SLOTS: - void test_change_expiration_default_without_subkeys() - { - Error err; - - if (!loopbackSupported()) { - return; - } - - auto ctx = Context::create(OpenPGP); - QVERIFY(ctx); - - // Get the key ([email protected]) - auto key = ctx->key("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, true); - QVERIFY(!err); - QVERIFY(!key.isNull()); - QVERIFY(!key.subkey(0).isNull()); - QVERIFY(!key.subkey(1).isNull()); - const auto subkeyExpiration = uint_least32_t(key.subkey(1).expirationTime()); - - { - // Create the job - auto job = std::unique_ptr<ChangeExpiryJob>{openpgp()->changeExpiryJob()}; - QVERIFY(job); - hookUpPassphraseProvider(job.get()); - - // Use defaults of job - - connect(job.get(), &ChangeExpiryJob::result, - this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { - Q_EMIT asyncDone(); - if (err2) { - QFAIL(qPrintable(QString("The ChangeExpiryJob failed with '%1'.").arg(errorAsString(err2)))); - } - }); - - const auto newExpirationDate = QDateTime::currentDateTime().addDays(1); - job->start(key, newExpirationDate); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the expiration date should have been changed. - key.update(); - - // allow a few seconds earlier expiration because job calculates "seconds from now" passed to gpg after it was started - const auto expectedExpirationRange = std::make_pair( - newExpirationDate.toSecsSinceEpoch() - 10, - QDateTime::currentDateTime().addDays(1).toSecsSinceEpoch()); - { - const auto actualExpiration = uint_least32_t(key.subkey(0).expirationTime()); - QVERIFY2(actualExpiration >= expectedExpirationRange.first, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.first)).c_str()); - QVERIFY2(actualExpiration <= expectedExpirationRange.second, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.second)).c_str()); - } - { - const auto actualExpiration = uint_least32_t(key.subkey(1).expirationTime()); - QCOMPARE(actualExpiration, subkeyExpiration); // unchanged - } - } - } - - void test_change_expiration_default_with_subkeys() - { - Error err; - - if (!loopbackSupported()) { - return; - } - - auto ctx = Context::create(OpenPGP); - QVERIFY(ctx); - - // Get the key ([email protected]) - auto key = ctx->key("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, true); - QVERIFY(!err); - QVERIFY(!key.isNull()); - QVERIFY(!key.subkey(0).isNull()); - QVERIFY(!key.subkey(1).isNull()); - const auto primaryKeyExpiration = uint_least32_t(key.subkey(0).expirationTime()); - - { - // Create the job - auto job = std::unique_ptr<ChangeExpiryJob>{openpgp()->changeExpiryJob()}; - QVERIFY(job); - hookUpPassphraseProvider(job.get()); - - // Use defaults of job - - connect(job.get(), &ChangeExpiryJob::result, - this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { - Q_EMIT asyncDone(); - if (err2) { - QFAIL(qPrintable(QString("The ChangeExpiryJob failed with '%1'.").arg(errorAsString(err2)))); - } - }); - - const auto newExpirationDate = QDateTime::currentDateTime().addDays(2); - job->start(key, newExpirationDate, {key.subkey(1)}); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the expiration date should have been changed. - key.update(); - - // allow a few seconds earlier expiration because job calculates "seconds from now" passed to gpg after it was started - const auto expectedExpirationRange = std::make_pair( - newExpirationDate.toSecsSinceEpoch() - 10, - QDateTime::currentDateTime().addDays(2).toSecsSinceEpoch()); - { - const auto actualExpiration = uint_least32_t(key.subkey(0).expirationTime()); - QCOMPARE(actualExpiration, primaryKeyExpiration); // unchanged - } - { - const auto actualExpiration = uint_least32_t(key.subkey(1).expirationTime()); - QVERIFY2(actualExpiration >= expectedExpirationRange.first, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.first)).c_str()); - QVERIFY2(actualExpiration <= expectedExpirationRange.second, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.second)).c_str()); - } - } - } - - void test_change_expiration_update_primary_key_without_subkeys() - { - Error err; - - if (!loopbackSupported()) { - return; - } - - auto ctx = Context::create(OpenPGP); - QVERIFY(ctx); - - // Get the key ([email protected]) - auto key = ctx->key("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, true); - QVERIFY(!err); - QVERIFY(!key.isNull()); - QVERIFY(!key.subkey(0).isNull()); - QVERIFY(!key.subkey(1).isNull()); - const auto subkeyExpiration = uint_least32_t(key.subkey(1).expirationTime()); - - { - // Create the job - auto job = std::unique_ptr<ChangeExpiryJob>{openpgp()->changeExpiryJob()}; - QVERIFY(job); - hookUpPassphraseProvider(job.get()); - - // Set up the job - job->setOptions(ChangeExpiryJob::UpdatePrimaryKey); - - connect(job.get(), &ChangeExpiryJob::result, - this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { - Q_EMIT asyncDone(); - if (err2) { - QFAIL(qPrintable(QString("The ChangeExpiryJob failed with '%1'.").arg(errorAsString(err2)))); - } - }); - - const auto newExpirationDate = QDateTime::currentDateTime().addDays(3); - job->start(key, newExpirationDate, {}); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the expiration date should have been changed. - key.update(); - - // allow a few seconds earlier expiration because job calculates "seconds from now" passed to gpg after it was started - const auto expectedExpirationRange = std::make_pair( - newExpirationDate.toSecsSinceEpoch() - 10, - QDateTime::currentDateTime().addDays(3).toSecsSinceEpoch()); - { - const auto actualExpiration = uint_least32_t(key.subkey(0).expirationTime()); - QVERIFY2(actualExpiration >= expectedExpirationRange.first, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.first)).c_str()); - QVERIFY2(actualExpiration <= expectedExpirationRange.second, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.second)).c_str()); - } - { - const auto actualExpiration = uint_least32_t(key.subkey(1).expirationTime()); - QCOMPARE(actualExpiration, subkeyExpiration); // unchanged - } - } - } - - void test_change_expiration_update_primary_key_with_subkeys() - { - Error err; - - if (!loopbackSupported()) { - return; - } - - auto ctx = Context::create(OpenPGP); - QVERIFY(ctx); - - // Get the key ([email protected]) - auto key = ctx->key("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, true); - QVERIFY(!err); - QVERIFY(!key.isNull()); - QVERIFY(!key.subkey(0).isNull()); - QVERIFY(!key.subkey(1).isNull()); - - { - // Create the job - auto job = std::unique_ptr<ChangeExpiryJob>{openpgp()->changeExpiryJob()}; - QVERIFY(job); - hookUpPassphraseProvider(job.get()); - - // Set up the job - job->setOptions(ChangeExpiryJob::UpdatePrimaryKey); - - connect(job.get(), &ChangeExpiryJob::result, - this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { - Q_EMIT asyncDone(); - if (err2) { - QFAIL(qPrintable(QString("The ChangeExpiryJob failed with '%1'.").arg(errorAsString(err2)))); - } - }); - - const auto newExpirationDate = QDateTime::currentDateTime().addDays(4); - job->start(key, newExpirationDate, {key.subkey(1)}); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the expiration date should have been changed. - key.update(); - - // allow a few seconds earlier expiration because job calculates "seconds from now" passed to gpg after it was started - const auto expectedExpirationRange = std::make_pair( - newExpirationDate.toSecsSinceEpoch() - 10, - QDateTime::currentDateTime().addDays(4).toSecsSinceEpoch()); - { - const auto actualExpiration = uint_least32_t(key.subkey(0).expirationTime()); - QVERIFY2(actualExpiration >= expectedExpirationRange.first, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.first)).c_str()); - QVERIFY2(actualExpiration <= expectedExpirationRange.second, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.second)).c_str()); - } - { - const auto actualExpiration = uint_least32_t(key.subkey(1).expirationTime()); - QVERIFY2(actualExpiration >= expectedExpirationRange.first, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.first)).c_str()); - QVERIFY2(actualExpiration <= expectedExpirationRange.second, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.second)).c_str()); - } - } - } - - void test_change_expiration_update_primary_key_and_all_subkeys() - { - Error err; - - if (!loopbackSupported()) { - return; - } - - auto ctx = Context::create(OpenPGP); - QVERIFY(ctx); - - // Get the key ([email protected]) - auto key = ctx->key("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, true); - QVERIFY(!err); - QVERIFY(!key.isNull()); - QVERIFY(!key.subkey(0).isNull()); - QVERIFY(!key.subkey(1).isNull()); - - { - // Create the job - auto job = std::unique_ptr<ChangeExpiryJob>{openpgp()->changeExpiryJob()}; - QVERIFY(job); - hookUpPassphraseProvider(job.get()); - - // Set up the job - job->setOptions(ChangeExpiryJob::UpdatePrimaryKey | ChangeExpiryJob::UpdateAllSubkeys); - - connect(job.get(), &ChangeExpiryJob::result, - this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { - Q_EMIT asyncDone(); - if (err2) { - QFAIL(qPrintable(QString("The ChangeExpiryJob failed with '%1'.").arg(errorAsString(err2)))); - } - }); - - const auto newExpirationDate = QDateTime::currentDateTime().addDays(5); - job->start(key, newExpirationDate); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the expiration date should have been changed. - key.update(); - - // allow a few seconds earlier expiration because job calculates "seconds from now" passed to gpg after it was started - const auto expectedExpirationRange = std::make_pair( - newExpirationDate.toSecsSinceEpoch() - 10, - QDateTime::currentDateTime().addDays(5).toSecsSinceEpoch()); - { - const auto actualExpiration = uint_least32_t(key.subkey(0).expirationTime()); - QVERIFY2(actualExpiration >= expectedExpirationRange.first, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.first)).c_str()); - QVERIFY2(actualExpiration <= expectedExpirationRange.second, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.second)).c_str()); - } - { - const auto actualExpiration = uint_least32_t(key.subkey(1).expirationTime()); - QVERIFY2(actualExpiration >= expectedExpirationRange.first, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.first)).c_str()); - QVERIFY2(actualExpiration <= expectedExpirationRange.second, - ("actual: " + std::to_string(actualExpiration) + - "; expected: " + std::to_string(expectedExpirationRange.second)).c_str()); - } - } - } - - void initTestCase() - { - QGpgMETest::initTestCase(); - const QString gpgHome = qgetenv("GNUPGHOME"); - QVERIFY(copyKeyrings(gpgHome, mDir.path())); - qputenv("GNUPGHOME", mDir.path().toUtf8()); - } - -private: - QTemporaryDir mDir; -}; - -QTEST_MAIN(TestChangeExpiryJob) - -#include "t-changeexpiryjob.moc" diff --git a/lang/qt/tests/t-config.cpp b/lang/qt/tests/t-config.cpp deleted file mode 100644 index 2f73b9a6..00000000 --- a/lang/qt/tests/t-config.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* t-config.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <QDebug> -#include <QTest> -#include <QTemporaryDir> -#include "t-support.h" -#include "protocol.h" -#include "cryptoconfig.h" -#include <gpgme++/engineinfo.h> - -#include <unistd.h> - -using namespace QGpgME; - -class CryptoConfigTest: public QGpgMETest -{ - Q_OBJECT - -private Q_SLOTS: - void testDefault() - { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.2.0") { - // We are using compliance here and other options might also - // be unsupported in older versions. - return; - } - auto conf = cryptoConfig(); - QVERIFY(conf); - auto entry = conf->entry(QStringLiteral("gpg"), QStringLiteral("compliance")); - QVERIFY(entry); - const auto defaultValue = entry->defaultValue().toString(); - QCOMPARE(defaultValue, QStringLiteral("gnupg")); - - entry->setStringValue("de-vs"); - conf->sync(true); - conf->clear(); - entry = conf->entry(QStringLiteral("gpg"), QStringLiteral("compliance")); - QCOMPARE(entry->stringValue(), QStringLiteral("de-vs")); - - entry->resetToDefault(); - conf->sync(true); - conf->clear(); - entry = conf->entry(QStringLiteral("gpg"), QStringLiteral("compliance")); - QCOMPARE(entry->stringValue(), defaultValue); - } - - void initTestCase() - { - QGpgMETest::initTestCase(); - const QString gpgHome = qgetenv("GNUPGHOME"); - qputenv("GNUPGHOME", mDir.path().toUtf8()); - QVERIFY(mDir.isValid()); - } -private: - QTemporaryDir mDir; - -}; - -QTEST_MAIN(CryptoConfigTest) - -#include "t-config.moc" diff --git a/lang/qt/tests/t-decryptverify.cpp b/lang/qt/tests/t-decryptverify.cpp deleted file mode 100644 index 9df10933..00000000 --- a/lang/qt/tests/t-decryptverify.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* t-verifiy.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - Copyright (c) 2023 by g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "t-support.h" - -#include <protocol.h> -#include <decryptverifyjob.h> - -#include <QDebug> -#include <QTest> - -#include <gpgme++/decryptionresult.h> -#include <gpgme++/key.h> -#include <gpgme++/verificationresult.h> - -using namespace QGpgME; -using namespace GpgME; - -static const char encryptedText[] = -"-----BEGIN PGP MESSAGE-----\n" -"\n" -"jA0ECQMCnJt+DX+RJJH90kIBCYlu/LYn57TCNO+O8kYwe4jcyEIaHqSZuvO50nFE\n" -"hQy9p33Y5VwP6uDOYOKxr1W6iE4GvbX+5UNKYdjjPL0m1ak=\n" -"=hgKY\n" -"-----END PGP MESSAGE-----\n"; - -static const char signedText[] = -"-----BEGIN PGP MESSAGE-----\n" -"\n" -"owGbwMvMwCSoW1RzPCOz3IRxjXQSR0lqcYleSUWJTZOvjVdpcYmCu1+oQmaJIleH\n" -"GwuDIBMDGysTSIqBi1MApi+nlGGuwDeHao53HBr+FoVGP3xX+kvuu9fCMJvl6IOf\n" -"y1kvP4y+8D5a11ang0udywsA\n" -"=Crq6\n" -"-----END PGP MESSAGE-----\n"; - -static const char storedText[] = -"-----BEGIN PGP MESSAGE-----\n" -"\n" -"owE7LZzEkHy7X86rtLhEwd0vVCGzRJELAA==\n" -"=VwL6\n" -"-----END PGP MESSAGE-----\n"; - -class DecryptVerifyTest: public QGpgMETest -{ - Q_OBJECT - -private Q_SLOTS: - - void testEncryptedOnlyData() - { - const QByteArray encryptedData{encryptedText}; - std::unique_ptr<DecryptVerifyJob> job{openpgp()->decryptVerifyJob(true)}; - hookUpPassphraseProvider(job.get()); - - QByteArray verified; - const auto result = job->exec(encryptedData, verified); - - const auto decryptionResult = result.first; - QCOMPARE(decryptionResult.error().code(), int{GPG_ERR_NO_ERROR}); - const auto verificationResult = result.second; - QCOMPARE(verificationResult.error().code(), int{GPG_ERR_NO_ERROR}); - QCOMPARE(verificationResult.numSignatures(), 0u); - } - - void testSignedOnlyData() - { - const QByteArray signedData{signedText}; - std::unique_ptr<DecryptVerifyJob> job{openpgp()->decryptVerifyJob(true)}; - - QByteArray verified; - const auto result = job->exec(signedData, verified); - - const auto decryptionResult = result.first; - QCOMPARE(decryptionResult.error().code(), int{GPG_ERR_NO_DATA}); - const auto verificationResult = result.second; - QCOMPARE(verificationResult.error().code(), int{GPG_ERR_NO_ERROR}); - QCOMPARE(verificationResult.numSignatures(), 1u); - } - - void testStoredData() - { - const QByteArray storedData{storedText}; - std::unique_ptr<DecryptVerifyJob> job{openpgp()->decryptVerifyJob(true)}; - - QByteArray verified; - const auto result = job->exec(storedData, verified); - - const auto decryptionResult = result.first; - QCOMPARE(decryptionResult.error().code(), int{GPG_ERR_NO_DATA}); - const auto verificationResult = result.second; - QCOMPARE(verificationResult.error().code(), int{GPG_ERR_NO_DATA}); - QCOMPARE(verificationResult.numSignatures(), 0u); - } -}; - -QTEST_MAIN(DecryptVerifyTest) -#include "t-decryptverify.moc" diff --git a/lang/qt/tests/t-disablekey.cpp b/lang/qt/tests/t-disablekey.cpp deleted file mode 100644 index 40581719..00000000 --- a/lang/qt/tests/t-disablekey.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* t-disablekey.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2024 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "t-support.h" - -#include "quickjob.h" -#include "debug.h" -#include "keylistjob.h" -#include "protocol.h" - -#include <gpgme++/engineinfo.h> -#include <gpgme++/keylistresult.h> - -#include <QDebug> -#include <QSignalSpy> -#include <QTest> - -using namespace QGpgME; -using namespace GpgME; - -class DisableKeyTest: public QGpgMETest -{ - Q_OBJECT - - Key getTestKey() - { - const std::unique_ptr<KeyListJob> job{openpgp()->keyListJob(false, true, true)}; - std::vector<GpgME::Key> keys; - KeyListResult result = job->exec({QStringLiteral("[email protected]")}, false, keys); - VERIFY_OR_OBJECT(!result.error()); - VERIFY_OR_OBJECT(keys.size() == 1); - return keys.front(); - } - -private Q_SLOTS: - - void testDisableAndEnableKey() - { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.4.6") { - QSKIP("gpg does not yet support the --quick-set-ownertrust command"); - } - - Key key = getTestKey(); - QVERIFY(!key.isNull()); - QVERIFY(!key.isDisabled()); - - { - const std::unique_ptr<QuickJob> job{openpgp()->quickJob()}; - connect(job.get(), &QuickJob::result, this, [this](Error e) { - if (e) { - qDebug() << "Error in result:" << e; - } - QVERIFY(!e); - Q_EMIT asyncDone(); - }); - job->startSetKeyEnabled(key, false); - QSignalSpy spy{this, SIGNAL(asyncDone())}; - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - } - key = getTestKey(); - QVERIFY(!key.isNull()); - QVERIFY(key.isDisabled()); - - { - const std::unique_ptr<QuickJob> job{openpgp()->quickJob()}; - connect(job.get(), &QuickJob::result, this, [this](Error e) { - if (e) { - qDebug() << "Error in result:" << e; - } - QVERIFY(!e); - Q_EMIT asyncDone(); - }); - job->startSetKeyEnabled(key, true); - QSignalSpy spy{this, SIGNAL(asyncDone())}; - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - } - key = getTestKey(); - QVERIFY(!key.isNull()); - QVERIFY(!key.isDisabled()); - } -}; - -QTEST_MAIN(DisableKeyTest) - -#include "t-disablekey.moc" diff --git a/lang/qt/tests/t-encrypt.cpp b/lang/qt/tests/t-encrypt.cpp deleted file mode 100644 index aac49a4b..00000000 --- a/lang/qt/tests/t-encrypt.cpp +++ /dev/null @@ -1,333 +0,0 @@ -/* t-encrypt.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <QDebug> -#include <QTest> -#include <QTemporaryDir> -#include <QSignalSpy> -#include <QBuffer> -#include "keylistjob.h" -#include "encryptjob.h" -#include "signencryptjob.h" -#include <gpgme++/signingresult.h> -#include "encryptjob.h" -#include <gpgme++/encryptionresult.h> -#include <gpgme++/decryptionresult.h> -#include "decryptjob.h" -#include "qgpgmebackend.h" -#include <gpgme++/keylistresult.h> -#include <gpgme++/engineinfo.h> -#include "verifyopaquejob.h" -#include "t-support.h" - -#define PROGRESS_TEST_SIZE 1 * 1024 * 1024 - -using namespace QGpgME; -using namespace GpgME; - - - -class EncryptionTest : public QGpgMETest -{ - Q_OBJECT - -private Q_SLOTS: - - void testSimpleEncryptDecrypt() - { - auto listjob = openpgp()->keyListJob(false, false, false); - std::vector<Key> keys; - auto keylistresult = listjob->exec(QStringList() << QStringLiteral("[email protected]"), - false, keys); - QVERIFY(!keylistresult.error()); - QVERIFY(keys.size() == 1); - delete listjob; - - auto job = openpgp()->encryptJob(/*ASCII Armor */true, /* Textmode */ true); - QVERIFY(job); - QByteArray cipherText; - auto result = job->exec(keys, QStringLiteral("Hello World").toUtf8(), Context::AlwaysTrust, cipherText); - delete job; - QVERIFY(!result.error()); - const auto cipherString = QString::fromUtf8(cipherText); - QVERIFY(cipherString.startsWith("-----BEGIN PGP MESSAGE-----")); - - /* Now decrypt */ - if (!loopbackSupported()) { - return; - } - auto decJob = openpgp()->decryptJob(); - hookUpPassphraseProvider(decJob); - QByteArray plainText; - auto decResult = decJob->exec(cipherText, plainText); - QVERIFY(!decResult.error()); - QVERIFY(QString::fromUtf8(plainText) == QStringLiteral("Hello World")); - delete decJob; - } - - void testProgress() - { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.15") { - // We can only test the progress with 2.1.15 as this started to - // have total progress for memory callbacks - return; - } - auto listjob = openpgp()->keyListJob(false, false, false); - std::vector<Key> keys; - auto keylistresult = listjob->exec(QStringList() << QStringLiteral("[email protected]"), - false, keys); - QVERIFY(!keylistresult.error()); - QVERIFY(keys.size() == 1); - delete listjob; - - auto job = openpgp()->encryptJob(/*ASCII Armor */false, /* Textmode */ false); - QVERIFY(job); - QByteArray plainBa; - plainBa.fill('X', PROGRESS_TEST_SIZE); - QByteArray cipherText; - - bool initSeen = false; - bool finishSeen = false; - connect(job, &Job::jobProgress, this, [&initSeen, &finishSeen] (int current, int total) { - // We only check for progress 0 and max progress as the other progress - // lines depend on the system speed and are as such unreliable to test. - QVERIFY(total == PROGRESS_TEST_SIZE); - if (current == 0) { - initSeen = true; - } - if (current == total) { - finishSeen = true; - } - QVERIFY(current >= 0 && current <= total); - }); - connect(job, &Job::rawProgress, this, [&initSeen, &finishSeen] (const QString &what, int type, int current, int total) { - // `what` is something like "-&12", i.e. a special fd passed to gpg; we only check that it's not empty - QVERIFY(!what.isEmpty()); - QCOMPARE(type, '?'); - // We only check for progress 0 and max progress as the other progress - // lines depend on the system speed and are as such unreliable to test. - QVERIFY(total == PROGRESS_TEST_SIZE); - if (current == 0) { - initSeen = true; - } - if (current == total) { - finishSeen = true; - } - QVERIFY(current >= 0 && current <= total); - }); - connect(job, &EncryptJob::result, this, [this, &initSeen, &finishSeen] (const GpgME::EncryptionResult &, - const QByteArray &, - const QString, - const GpgME::Error) { - QVERIFY(initSeen); - QVERIFY(finishSeen); - Q_EMIT asyncDone(); - }); - - auto inptr = std::shared_ptr<QIODevice>(new QBuffer(&plainBa)); - inptr->open(QIODevice::ReadOnly); - auto outptr = std::shared_ptr<QIODevice>(new QBuffer(&cipherText)); - outptr->open(QIODevice::WriteOnly); - - job->start(keys, inptr, outptr, Context::AlwaysTrust); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - } - - void testSymmetricEncryptDecrypt() - { - if (!loopbackSupported()) { - return; - } - auto job = openpgp()->encryptJob(); - hookUpPassphraseProvider(job); - auto ctx = Job::context(job); - ctx->setArmor(true); - ctx->setTextMode(true); - QByteArray cipherText; - auto result = job->exec(std::vector<Key>(), QStringLiteral("Hello symmetric World").toUtf8(), Context::AlwaysTrust, cipherText); - delete job; - QVERIFY(!result.error()); - const auto cipherString = QString::fromUtf8(cipherText); - QVERIFY(cipherString.startsWith("-----BEGIN PGP MESSAGE-----")); - - killAgent(mDir.path()); - - auto decJob = openpgp()->decryptJob(); - hookUpPassphraseProvider(decJob); - QByteArray plainText; - auto decResult = decJob->exec(cipherText, plainText); - QVERIFY(!result.error()); - QVERIFY(QString::fromUtf8(plainText) == QStringLiteral("Hello symmetric World")); - delete decJob; - } - - void testEncryptDecryptNowrap() - { - /* Now decrypt */ - if (!loopbackSupported()) { - return; - } - auto listjob = openpgp()->keyListJob(false, false, false); - std::vector<Key> keys; - auto keylistresult = listjob->exec(QStringList() << QStringLiteral("[email protected]"), - false, keys); - QVERIFY(!keylistresult.error()); - QVERIFY(keys.size() == 1); - delete listjob; - - auto job = openpgp()->signEncryptJob(/*ASCII Armor */true, /* Textmode */ true); - QVERIFY(job); - hookUpPassphraseProvider(job); - - QByteArray cipherText; - auto result = job->exec(keys, keys, QStringLiteral("Hello World").toUtf8(), Context::AlwaysTrust, cipherText); - delete job; - QVERIFY(!result.first.error()); - QVERIFY(!result.second.error()); - const auto cipherString = QString::fromUtf8(cipherText); - QVERIFY(cipherString.startsWith("-----BEGIN PGP MESSAGE-----")); - - /* Now decrypt */ - if (!loopbackSupported()) { - return; - } - - auto decJob = openpgp()->decryptJob(); - hookUpPassphraseProvider(decJob); - auto ctx = Job::context(decJob); - ctx->setDecryptionFlags(Context::DecryptUnwrap); - - QByteArray plainText; - auto decResult = decJob->exec(cipherText, plainText); - - QVERIFY(!decResult.error()); - - delete decJob; - - // Now verify the unwrapeped data. - auto verifyJob = openpgp()->verifyOpaqueJob(true); - QByteArray verified; - - auto verResult = verifyJob->exec(plainText, verified); - QVERIFY(!verResult.error()); - delete verifyJob; - - QVERIFY(verResult.numSignatures() == 1); - auto sig = verResult.signatures()[0]; - - QVERIFY(verified == QStringLiteral("Hello World")); - } - -private: - /* Loopback and passphrase provider don't work for mixed encryption. - * So this test is disabled until gnupg(?) is fixed for this. */ - void testMixedEncryptDecrypt() - { - if (!loopbackSupported()) { - return; - } - auto listjob = openpgp()->keyListJob(false, false, false); - std::vector<Key> keys; - auto keylistresult = listjob->exec(QStringList() << QStringLiteral("[email protected]"), - false, keys); - QVERIFY(!keylistresult.error()); - QVERIFY(keys.size() == 1); - delete listjob; - - auto job = openpgp()->encryptJob(); - hookUpPassphraseProvider(job); - auto ctx = Job::context(job); - ctx->setArmor(true); - ctx->setTextMode(true); - QByteArray cipherText; - printf("Before exec, flags: %x\n", Context::Symmetric | Context::AlwaysTrust); - auto result = job->exec(keys, QStringLiteral("Hello symmetric World").toUtf8(), - static_cast<Context::EncryptionFlags>(Context::Symmetric | Context::AlwaysTrust), - cipherText); - printf("After exec\n"); - delete job; - QVERIFY(!result.error()); - printf("Cipher:\n%s\n", cipherText.constData()); - const auto cipherString = QString::fromUtf8(cipherText); - QVERIFY(cipherString.startsWith("-----BEGIN PGP MESSAGE-----")); - - killAgent(mDir.path()); - - /* Now create a new homedir which with we test symmetric decrypt. */ - QTemporaryDir tmp; - qputenv("GNUPGHOME", tmp.path().toUtf8()); - QFile agentConf(tmp.path() + QStringLiteral("/gpg-agent.conf")); - QVERIFY(agentConf.open(QIODevice::WriteOnly)); - agentConf.write("allow-loopback-pinentry"); - agentConf.close(); - - auto decJob = openpgp()->decryptJob(); - hookUpPassphraseProvider(decJob); - auto ctx2 = Job::context(decJob); - ctx2->setTextMode(true); - QByteArray plainText; - auto decResult = decJob->exec(cipherText, plainText); - QVERIFY(!decResult.error()); - qDebug() << "Plain: " << plainText; - QVERIFY(QString::fromUtf8(plainText) == QStringLiteral("Hello symmetric World")); - delete decJob; - - killAgent(tmp.path()); - qputenv("GNUPGHOME", mDir.path().toUtf8()); - } - -public Q_SLOT: - - void initTestCase() - { - QGpgMETest::initTestCase(); - const QString gpgHome = qgetenv("GNUPGHOME"); - qputenv("GNUPGHOME", mDir.path().toUtf8()); - QVERIFY(mDir.isValid()); - QFile agentConf(mDir.path() + QStringLiteral("/gpg-agent.conf")); - QVERIFY(agentConf.open(QIODevice::WriteOnly)); - agentConf.write("allow-loopback-pinentry"); - agentConf.close(); - QVERIFY(copyKeyrings(gpgHome, mDir.path())); - } - -private: - QTemporaryDir mDir; -}; - -QTEST_MAIN(EncryptionTest) - -#include "t-encrypt.moc" diff --git a/lang/qt/tests/t-import.cpp b/lang/qt/tests/t-import.cpp deleted file mode 100644 index be17a03c..00000000 --- a/lang/qt/tests/t-import.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/* t-import.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2021 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "t-support.h" - -#include <gpgme++/context.h> -#include <gpgme++/engineinfo.h> -#include "protocol.h" -#include "importjob.h" - -#include <gpgme++/importresult.h> - -#include <QDebug> -#include <QSignalSpy> -#include <QTemporaryDir> -#include <QTest> - -#include <memory> - -using namespace QGpgME; -using namespace GpgME; - -class ImportTest : public QGpgMETest -{ - Q_OBJECT - -private: - QTemporaryDir tempGpgHome; - -private Q_SLOTS: - void initTestCase() - { - QGpgMETest::initTestCase(); - QVERIFY2(tempGpgHome.isValid(), "Failed to create temporary GNUPGHOME"); - qputenv("GNUPGHOME", tempGpgHome.path().toLocal8Bit()); - } - - void testImportWithImportFilter() - { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.14") { - QSKIP("gpg does not yet support the --import-filter option"); - } - - // pub ed25519 2021-12-15 [SC] - // E7A0841292ACC9465D3142652FB3A6F51FBF28A2 - // uid [ultimate] [email protected] - // uid [ultimate] [email protected] - // sub cv25519 2021-12-15 [E] - static const char keyFpr[] = "E7A0841292ACC9465D3142652FB3A6F51FBF28A2"; - static const char keyData[] = - "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" - "\n" - "mDMEYbm2PhYJKwYBBAHaRw8BAQdACzxBWtNNsmJ6rzpZkjh1yBe+Ajsk9NR8umEu\n" - "Da3HLgG0ImltcG9ydFdpdGhJbXBvcnRGaWx0ZXJAZXhhbXBsZS5uZXSIlAQTFgoA\n" - "PBYhBOeghBKSrMlGXTFCZS+zpvUfvyiiBQJhubY+AhsDBQsJCAcCAyICAQYVCgkI\n" - "CwIEFgIDAQIeBwIXgAAKCRAvs6b1H78oosRgAQCc/ke6q076nvzIE2UzT83JK/B6\n" - "lxSV7Fb8bKltOMpvsAD+Phap3EzA8jdMyKoO0FM926bw5lX7QROfeZ/JBYqyPwC0\n" - "ImltcG9ydFdpdGhJbXBvcnRGaWx0ZXJAZXhhbXBsZS5jb22IlAQTFgoAPBYhBOeg\n" - "hBKSrMlGXTFCZS+zpvUfvyiiBQJhubZlAhsDBQsJCAcCAyICAQYVCgkICwIEFgID\n" - "AQIeBwIXgAAKCRAvs6b1H78oohPWAQC/u9UXzkxRkrB2huaTZCsyimWEGZIMmxWd\n" - "tE+vN9/IvQD/Yzia+xRS6yca3Yz6iW8xS844ZqRxvkUEHjtJXSOzagm4OARhubY+\n" - "EgorBgEEAZdVAQUBAQdANQFjmDctY3N0/ELPZtj9tapwFs4vrmTVpx/SCfZmihkD\n" - "AQgHiHgEGBYKACAWIQTnoIQSkqzJRl0xQmUvs6b1H78oogUCYbm2PgIbDAAKCRAv\n" - "s6b1H78oovGyAP41ySzvvDpV7XDJBOAFxvWLmywa5IcO7Lrg7y1efoWj0AD+Kk/B\n" - "s7jGLdoG51h670h50MMoYCANB6MwAdSP+qZUlQg=\n" - "=/3O0\n" - "-----END PGP PUBLIC KEY BLOCK-----\n"; - - auto *job = openpgp()->importJob(); - job->setImportFilter(QLatin1String{"keep-uid=mbox = [email protected]"}); - connect(job, &ImportJob::result, this, - [this](ImportResult result, QString, Error) - { - QVERIFY(!result.error()); - QVERIFY(!result.imports().empty()); - QVERIFY(result.numImported()); - Q_EMIT asyncDone(); - }); - job->start(QByteArray{keyData}); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait()); - - auto ctx = std::unique_ptr<GpgME::Context>(Context::createForProtocol(GpgME::OpenPGP)); - GpgME::Error err; - const auto key = ctx->key(keyFpr, err, false); - QVERIFY(!key.isNull()); - QCOMPARE(key.numUserIDs(), 1u); - QCOMPARE(key.userID(0).id(), "[email protected]"); - } - - void testImportWithImportOptions() - { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.23") { - QSKIP("gpg does not yet support --import-options show-only"); - } - - // pub ed25519 2024-06-12 [SC] - // A52F4947AF1506F3A7572EFC140278B773CA7C16 - // uid [email protected] - static const char keyFpr[] = "A52F4947AF1506F3A7572EFC140278B773CA7C16"; - static const char keyData[] = - "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" - "\n" - "mDMEZmlpmBYJKwYBBAHaRw8BAQdAZaSopKwccTwnMlJBVCWMT6et1T1WF9EkXdJi\n" - "gzI74xW0GWltcG9ydE9wdGlvbnNAZXhhbXBsZS5uZXSIkwQTFgoAOxYhBKUvSUev\n" - "FQbzp1cu/BQCeLdzynwWBQJmaWmYAhsDBQsJCAcCAiICBhUKCQgLAgQWAgMBAh4H\n" - "AheAAAoJEBQCeLdzynwWjmQBAP4dQEN/M4/dKIAlxNAbWzIkV+eSoUFLJszOJ/xx\n" - "FwJzAP43gkdXkUsHZt/U3mLZqtiHJFd7JxVm7hKRoAVBhZZYDw==\n" - "=7Z1j\n" - "-----END PGP PUBLIC KEY BLOCK-----\n"; - - auto *job = openpgp()->importJob(); - job->setImportOptions({QStringLiteral("show-only")}); - connect(job, &ImportJob::result, this, - [this](ImportResult result, QString, Error) - { - QVERIFY(!result.error()); - QCOMPARE(result.numConsidered(), 0); - QCOMPARE(result.numImported(), 0); - QVERIFY(result.imports().empty()); - Q_EMIT asyncDone(); - }); - job->start(QByteArray{keyData}); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait()); - - auto ctx = std::unique_ptr<GpgME::Context>(Context::createForProtocol(GpgME::OpenPGP)); - GpgME::Error err; - const auto key = ctx->key(keyFpr, err, false); - QVERIFY(key.isNull()); - } - - void testImportWithKeyOrigin() - { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.22") { - QSKIP("gpg does not yet support the --key-origin option"); - } - - static const char keyFpr[] = "5C5C428FABCC20F6913464BCCA6FB442887289B3"; - static const char keyData[] = - "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" - "\n" - "mDMEYbhuixYJKwYBBAHaRw8BAQdAulOM3IksCjdOJluEVlwalD8oZ5oa6wCw3EgW\n" - "NswXXb60H2ltcG9ydFdpdGhLZXlPcmlnaW5AZXhhbXBsZS5uZXSIlAQTFgoAPBYh\n" - "BFxcQo+rzCD2kTRkvMpvtEKIcomzBQJhuG6LAhsDBQsJCAcCAyICAQYVCgkICwIE\n" - "FgIDAQIeBwIXgAAKCRDKb7RCiHKJs+cIAQDaeoOw1OCAGpZQb8xJmLJHul5dLLzU\n" - "RBdHauMx9NROmQEA23QUVedc7walQjNKFzyIJA/YqRdbAKPiLonRBmxk9Ay4OARh\n" - "uG6LEgorBgEEAZdVAQUBAQdAMVdO9mNWIP/q8PtNOnBGlPyhx/vs07sF5sXk50A+\n" - "61QDAQgHiHgEGBYKACAWIQRcXEKPq8wg9pE0ZLzKb7RCiHKJswUCYbhuiwIbDAAK\n" - "CRDKb7RCiHKJs/x6AP0SEbZqW4iLCz2i1JntQghK5qpSZOVqsBTcARd6pcJ/cwEA\n" - "mrwskWazuS9+GVbHT5RATWOXnGaj+AICSDPE6qHtGgA=\n" - "=putz\n" - "-----END PGP PUBLIC KEY BLOCK-----\n"; - - auto *job = openpgp()->importJob(); - job->setKeyOrigin(GpgME::Key::OriginWKD, "https://example.net"); - connect(job, &ImportJob::result, this, - [this](ImportResult result, QString, Error) - { - QVERIFY(!result.error()); - QVERIFY(!result.imports().empty()); - QVERIFY(result.numImported()); - Q_EMIT asyncDone(); - }); - job->start(QByteArray{keyData}); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait()); - - auto ctx = std::unique_ptr<GpgME::Context>(Context::createForProtocol(GpgME::OpenPGP)); - GpgME::Error err; - const auto key = ctx->key(keyFpr, err, false); - QVERIFY(!key.isNull()); - QVERIFY(key.origin() == Key::OriginWKD); - // the origin URL is currently not available in GpgME - } - - void testDeferredStart() - { - // pub ed25519 2023-01-05 [SC] - // 4D1367FE9AF6334D8A55BA635A817A94C7B37E5D - // uid [email protected] - static const char keyFpr[] = "4D1367FE9AF6334D8A55BA635A817A94C7B37E5D"; - static const char keyData[] = - "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" - "\n" - "mDMEY7bNSxYJKwYBBAHaRw8BAQdAazIWyd/xEMeObDSUnh2+AXQuo0oM+TDBG49z\n" - "KHvTAYG0GmltcG9ydERlZmVycmVkQGV4YW1wbGUubmV0iJMEExYKADsWIQRNE2f+\n" - "mvYzTYpVumNagXqUx7N+XQUCY7bNSwIbAwULCQgHAgIiAgYVCgkICwIEFgIDAQIe\n" - "BwIXgAAKCRBagXqUx7N+XasrAP4qPzLzPd6tWDZvP29ZYPTSrjrTb0U5MOJeIPKX\n" - "73jZswEAwWRvgH+GmhTOigw0UVtinAFvUEFVyvcW/GR19mw5XA0=\n" - "=JnpA\n" - "-----END PGP PUBLIC KEY BLOCK-----\n"; - - auto *job = openpgp()->importJob(); - job->startLater(QByteArray{keyData}); - connect(job, &ImportJob::result, this, - [this](ImportResult result, QString, Error) - { - QVERIFY(!result.error()); - QVERIFY(!result.imports().empty()); - QVERIFY(result.numImported()); - Q_EMIT asyncDone(); - }); - job->startNow(); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait()); - - auto ctx = std::unique_ptr<GpgME::Context>(Context::createForProtocol(GpgME::OpenPGP)); - GpgME::Error err; - const auto key = ctx->key(keyFpr, err, false); - QVERIFY(!key.isNull()); - } -}; - -QTEST_MAIN(ImportTest) - -#include "t-import.moc" diff --git a/lang/qt/tests/t-keylist.cpp b/lang/qt/tests/t-keylist.cpp deleted file mode 100644 index 75bc4120..00000000 --- a/lang/qt/tests/t-keylist.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* t-keylist.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <QDebug> -#include <QTest> -#include <QSignalSpy> -#include <QMap> -#include "keylistjob.h" -#include "listallkeysjob.h" -#include "qgpgmebackend.h" -#include <gpgme++/keylistresult.h> - -#include <gpgme++/context.h> -#include <gpgme++/engineinfo.h> - -#include <memory> - -#include "t-support.h" - -using namespace QGpgME; -using namespace GpgME; - -class KeyListTest : public QGpgMETest -{ - Q_OBJECT - -private Q_SLOTS: - void testSingleKeyListSync() - { - KeyListJob *job = openpgp()->keyListJob(false, false, false); - std::vector<GpgME::Key> keys; - GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("[email protected]"), - false, keys); - delete job; - QVERIFY (!result.error()); - QVERIFY (keys.size() == 1); - const QString kId = QLatin1String(keys.front().keyID()); - QVERIFY (kId == QStringLiteral("2D727CC768697734")); - - QVERIFY (keys[0].subkeys().size() == 2); - QVERIFY (keys[0].subkeys()[0].publicKeyAlgorithm() == Subkey::AlgoDSA); - QVERIFY (keys[0].subkeys()[1].publicKeyAlgorithm() == Subkey::AlgoELG_E); - } - - // This test can help with valgrind to check for memleaks when handling - // keys - void testGetKey() - { - GpgME::Key key; - { - auto ctx = std::unique_ptr<GpgME::Context> (GpgME::Context::createForProtocol(GpgME::OpenPGP)); - ctx->setKeyListMode (GpgME::KeyListMode::Local | - GpgME::KeyListMode::Signatures | - GpgME::KeyListMode::Validate | - GpgME::KeyListMode::WithTofu); - GpgME::Error err; - key = ctx->key ("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, false); - } - QVERIFY(key.primaryFingerprint()); - QVERIFY(!strcmp(key.primaryFingerprint(), "A0FF4590BB6122EDEF6E3C542D727CC768697734")); - { - auto ctx = std::unique_ptr<GpgME::Context> (GpgME::Context::createForProtocol(GpgME::OpenPGP)); - ctx->setKeyListMode (GpgME::KeyListMode::Local | - GpgME::KeyListMode::Signatures | - GpgME::KeyListMode::Validate | - GpgME::KeyListMode::WithTofu); - GpgME::Error err; - key = ctx->key ("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, false); - } - QVERIFY(key.primaryFingerprint()); - QVERIFY(!strcmp(key.primaryFingerprint(), "A0FF4590BB6122EDEF6E3C542D727CC768697734")); - } - - void testPubkeyAlgoAsString() - { - static const QMap<Subkey::PubkeyAlgo, QString> expected { - { Subkey::AlgoRSA, QStringLiteral("RSA") }, - { Subkey::AlgoRSA_E, QStringLiteral("RSA-E") }, - { Subkey::AlgoRSA_S, QStringLiteral("RSA-S") }, - { Subkey::AlgoELG_E, QStringLiteral("ELG-E") }, - { Subkey::AlgoDSA, QStringLiteral("DSA") }, - { Subkey::AlgoECC, QStringLiteral("ECC") }, - { Subkey::AlgoELG, QStringLiteral("ELG") }, - { Subkey::AlgoECDSA, QStringLiteral("ECDSA") }, - { Subkey::AlgoECDH, QStringLiteral("ECDH") }, - { Subkey::AlgoEDDSA, QStringLiteral("EdDSA") }, - { Subkey::AlgoUnknown, QString() } - }; - for (Subkey::PubkeyAlgo algo : expected.keys()) { - QVERIFY(QString::fromUtf8(Subkey::publicKeyAlgorithmAsString(algo)) == - expected.value(algo)); - } - } - - void testKeyListAsync() - { - KeyListJob *job = openpgp()->keyListJob(); - connect(job, &KeyListJob::result, job, [this, job](KeyListResult, std::vector<Key> keys, QString, Error) - { - QVERIFY(keys.size() == 1); - Q_EMIT asyncDone(); - }); - job->start(QStringList() << "[email protected]"); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - } - - void testListAllKeysSync() - { - const auto accumulateFingerprints = [](std::vector<std::string> &v, const Key &key) { v.push_back(std::string(key.primaryFingerprint())); return v; }; - - ListAllKeysJob *job = openpgp()->listAllKeysJob(/* includeSigs= */false, /* validate= */false); - std::vector<GpgME::Key> pubKeys, secKeys; - GpgME::KeyListResult result = job->exec(pubKeys, secKeys, /* mergeKeys= */false); // mergeKeys is unused for GnuPG >= 2.1 - delete job; - QVERIFY(!result.error()); - - QCOMPARE(secKeys.size(), static_cast<decltype(secKeys.size())>(2)); - std::vector<std::string> secKeyFingerprints = std::accumulate(secKeys.begin(), secKeys.end(), std::vector<std::string>(), accumulateFingerprints); - QCOMPARE(secKeyFingerprints, std::vector<std::string>({ - "23FD347A419429BACCD5E72D6BC4778054ACD246", - "A0FF4590BB6122EDEF6E3C542D727CC768697734" - })); - QVERIFY(secKeys[0].hasSecret()); - if (!(GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.0")) { - QVERIFY(secKeys[0].subkeys()[0].keyGrip()); - } - - QCOMPARE(pubKeys.size(), static_cast<decltype(pubKeys.size())>(26)); - std::vector<std::string> pubKeyFingerprints = std::accumulate(pubKeys.begin(), pubKeys.end(), std::vector<std::string>(), accumulateFingerprints); - QCOMPARE(pubKeyFingerprints, std::vector<std::string>({ - "045B2334ADD69FC221076841A5E67F7FA3AE3EA1", - "04C1DF62EFA0EBB00519B06A8979A6C5567FB34A", - "0DBCAD3F08843B9557C6C4D4A94C0F75653244D6", - "1DDD28CEF714F5B03B8C246937CAB51FB79103F8", - "23FD347A419429BACCD5E72D6BC4778054ACD246", - "2686AA191A278013992C72EBBE794852BE5CF886", - "3531152DE293E26A07F504BC318C1FAEFAEF6D1B", - "38FBE1E4BF6A5E1242C8F6A13BDBEDB1777FBED3", - "3FD11083779196C2ECDD9594AD1B0FAD43C2D0C7", - "43929E89F8F79381678CAE515F6356BA6D9732AC", - "56D33268F7FE693FBB594762D4BF57F37372E243", - "5AB9D6D7BAA1C95B3BAA3D9425B00FD430CEC684", - "61EE841A2A27EB983B3B3C26413F4AF31AFDAB6C", - "6560C59C43D031C54D7C588EEBA9F240EB9DC9E6", - "6FAA9C201E5E26DCBAEC39FD5D15E01D3FF13206", - "9E91CBB11E4D4135583EF90513DB965534C6E3F1", - "A0FF4590BB6122EDEF6E3C542D727CC768697734", - "A7969DA1C3297AA96D49843F1C67EC133C661C84", - "C9C07DCC6621B9FB8D071B1D168410A48FC282E6", - "CD538D6CC9FB3D745ECDA5201FE8FC6F04259677", - "D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2", - "E8143C489C8D41124DC40D0B47AF4B6961F04784", - "E8D6C90B683B0982BD557A99DEF0F7B8EC67DBDE", - "ECAC774F4EEEB0620767044A58CB9A4C85A81F38", - "ED9B316F78644A58D042655A9EEF34CD4B11B25F", - "F8F1EDC73995AB739AD54B380C820C71D2699313" - })); - if (!(GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.0")) { - // with GnuPG >= 2.1 the job always lists keys with --with-keygrip and --with-secret, - // i.e. the key grips and information about secret keys are always available - QVERIFY(!pubKeys[0].hasSecret()); - QVERIFY(pubKeys[0].subkeys()[0].keyGrip()); - - QVERIFY(pubKeys[4].hasSecret()); - QVERIFY(pubKeys[4].subkeys()[0].keyGrip()); - } - } -}; - -QTEST_MAIN(KeyListTest) - -#include "t-keylist.moc" diff --git a/lang/qt/tests/t-keylocate.cpp b/lang/qt/tests/t-keylocate.cpp deleted file mode 100644 index 88062f50..00000000 --- a/lang/qt/tests/t-keylocate.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* t-keylocate.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <QDebug> -#include <QTest> -#include <QSignalSpy> -#include <QTemporaryDir> -#include "keylistjob.h" -#include "protocol.h" -#include <gpgme++/keylistresult.h> -#include <gpgme++/engineinfo.h> - -#include "t-support.h" - -using namespace QGpgME; -using namespace GpgME; - -class KeyLocateTest : public QGpgMETest -{ - Q_OBJECT - -private Q_SLOTS: - -#ifdef DO_ONLINE_TESTS - void testDaneKeyLocate() - { - QTemporaryDir dir; - const QString oldHome = qgetenv("GNUPGHOME"); - qputenv("GNUPGHOME", dir.path().toUtf8()); - /* Could do this with gpgconf but this is not a gpgconf test ;-) */ - QFile conf(dir.path() + QStringLiteral("/gpg.conf")); - QVERIFY(conf.open(QIODevice::WriteOnly)); - conf.write("auto-key-locate dane"); - conf.close(); - - auto *job = openpgp()->locateKeysJob(); - mTestpattern = QStringLiteral("[email protected]"); - connect(job, &KeyListJob::result, job, [this, job](KeyListResult result, std::vector<Key> keys, QString, Error) - { - QVERIFY(!result.error()); - QVERIFY(keys.size() == 1); - - Key k = keys.front(); - QVERIFY(k.numUserIDs()); - bool found = false; - for (const UserID &uid : k.userIDs()) { - const QString mailBox = QString::fromUtf8(uid.email()); - if (mTestpattern.toLower() == mailBox.toLower()) { - found = true; - } - } - QVERIFY(found); - Q_EMIT asyncDone(); - }); - job->start(QStringList() << mTestpattern); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - qputenv("GNUPGHOME", oldHome.toUtf8()); - } -#endif - - void testKeyLocateSingle() - { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.0.10") { - return; - } - auto *job = openpgp()->locateKeysJob(); - mTestpattern = QStringLiteral("[email protected]"); - - connect(job, &KeyListJob::result, job, [this, job](KeyListResult result, std::vector<Key> keys, QString, Error) - { - QVERIFY(!result.isNull()); - QVERIFY(!result.isTruncated()); - QVERIFY(!result.error()); - QVERIFY(keys.size() == 1); - - Key k = keys.front(); - QVERIFY(k.numUserIDs()); - bool found = false; - for (const UserID &uid : k.userIDs()) { - const QString mailBox = QString::fromUtf8(uid.email()); - if (mTestpattern.toLower() == mailBox.toLower()) { - found = true; - } - } - QVERIFY(found); - Q_EMIT asyncDone(); - }); - job->start(QStringList() << mTestpattern); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - } - -private: - QString mTestpattern; -}; - -QTEST_MAIN(KeyLocateTest) - -#include "t-keylocate.moc" diff --git a/lang/qt/tests/t-ownertrust.cpp b/lang/qt/tests/t-ownertrust.cpp deleted file mode 100644 index a032dfbd..00000000 --- a/lang/qt/tests/t-ownertrust.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* t-ownertrust.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <QDebug> -#include <QTest> -#include <QSignalSpy> -#include "debug.h" -#include "keylistjob.h" -#include "protocol.h" -#include <gpgme++/keylistresult.h> -#include "changeownertrustjob.h" - -#include "t-support.h" - -using namespace QGpgME; -using namespace GpgME; - -class ChangeOwnerTrustTest: public QGpgMETest -{ - Q_OBJECT - -private Q_SLOTS: - - void testChangeOwnerTrust() - { - KeyListJob *job = openpgp()->keyListJob(false, true, true); - std::vector<GpgME::Key> keys; - GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("[email protected]"), - false, keys); - delete job; - QVERIFY (!result.error()); - QVERIFY (keys.size() == 1); - Key key = keys.front(); - QVERIFY (key.ownerTrust() == Key::Unknown); - - ChangeOwnerTrustJob *job2 = openpgp()->changeOwnerTrustJob(); - connect(job2, &ChangeOwnerTrustJob::result, this, [this](Error e) - { - if (e) { - qDebug() << "Error in result: " << e; - } - QVERIFY(!e); - Q_EMIT asyncDone(); - }); - job2->start(key, Key::Ultimate); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - job = openpgp()->keyListJob(false, true, true); - result = job->exec(QStringList() << QStringLiteral("[email protected]"), - false, keys); - delete job; - key = keys.front(); - QVERIFY (key.ownerTrust() == Key::Ultimate); - - ChangeOwnerTrustJob *job3 = openpgp()->changeOwnerTrustJob(); - connect(job3, &ChangeOwnerTrustJob::result, this, [this](Error e) - { - if (e) { - qDebug() << "Error in result: " << e; - } - QVERIFY(!e); - Q_EMIT asyncDone(); - }); - job3->start(key, Key::Unknown); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - job = openpgp()->keyListJob(false, true, true); - result = job->exec(QStringList() << QStringLiteral("[email protected]"), - false, keys); - delete job; - - key = keys.front(); - QVERIFY (key.ownerTrust() == Key::Unknown); - } -}; - -QTEST_MAIN(ChangeOwnerTrustTest) - -#include "t-ownertrust.moc" diff --git a/lang/qt/tests/t-remarks.cpp b/lang/qt/tests/t-remarks.cpp deleted file mode 100644 index b7de4ac4..00000000 --- a/lang/qt/tests/t-remarks.cpp +++ /dev/null @@ -1,472 +0,0 @@ -/* t-remarks.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2017 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <QDebug> -#include <QTest> -#include <QSignalSpy> -#include <QTemporaryDir> -#include "debug.h" -#include "keylistjob.h" -#include "protocol.h" -#include "signkeyjob.h" -#include <gpgme++/context.h> -#include <gpgme++/engineinfo.h> - -#include "t-support.h" - -using namespace QGpgME; -using namespace GpgME; - -class TestRemarks: public QGpgMETest -{ - Q_OBJECT - -public: - // This test is disabled (no slot) because the behavior - // is not clearly defined. Better to prevent that - // case in the UI - void testRemarkOwnKey() - { - if (!loopbackSupported()) { - return; - } - // Get the signing key (alfa) - auto ctx = Context::create(OpenPGP); - QVERIFY (ctx); - Error err; - auto seckey = ctx->key("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, true); - QVERIFY (!seckey.isNull()); - QVERIFY (!err); - - // Create the job - auto job = openpgp()->signKeyJob(); - QVERIFY (job); - hookUpPassphraseProvider(job); - - // Set up the job - job->setExportable(false); - std::vector<unsigned int> uids; - uids.push_back(0); - job->setUserIDsToSign(uids); - job->setSigningKey(seckey); - job->setRemark(QStringLiteral("Just GNU it!")); - job->setDupeOk(true); - - connect(job, &SignKeyJob::result, this, [this] (const GpgME::Error &err2, - const QString, - const GpgME::Error) { - Q_EMIT asyncDone(); - if (err2) { - qDebug() << "Error: " << err2; - } - QVERIFY(err2); - }); - - job->start(seckey); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - } - - -private Q_SLOTS: - - void testRemarkReplaceSingleUIDExportable() - { - if (!loopbackSupported()) { - return; - } - // Get the signing key (alfa) - auto ctx = Context::create(OpenPGP); - QVERIFY (ctx); - Error err; - auto seckey = ctx->key("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, true); - QVERIFY (!seckey.isNull()); - QVERIFY (!err); - - // Get the target key (tango) - auto target = ctx->key("ECAC774F4EEEB0620767044A58CB9A4C85A81F38", err, false); - QVERIFY (!target.isNull()); - QVERIFY (!err); - QVERIFY (target.numUserIDs()); - - // Create the job - auto job = openpgp()->signKeyJob(); - QVERIFY (job); - hookUpPassphraseProvider(job); - - // Set up the job - job->setExportable(true); - std::vector<unsigned int> uids; - uids.push_back(0); - job->setUserIDsToSign(uids); - job->setSigningKey(seckey); - job->setRemark(QStringLiteral("The quick brown fox jumps over the lazy dog")); - - connect(job, &SignKeyJob::result, this, [this] (const GpgME::Error &err2, - const QString, - const GpgME::Error) { - Q_EMIT asyncDone(); - QVERIFY(!err2); - }); - - job->start(target); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the remark should have been added. - target.update(); - const char *remark = target.userID(0).remark(seckey, err); - QVERIFY(!err); - QVERIFY(remark); - QCOMPARE(QString::fromUtf8(remark), QStringLiteral("The quick brown fox " - "jumps over the lazy dog")); - - // Now replace the remark - auto job3 = openpgp()->signKeyJob(); - QVERIFY (job3); - hookUpPassphraseProvider(job3); - - // Set up the job - job3->setExportable(false); - job3->setUserIDsToSign(uids); - job3->setSigningKey(seckey); - job3->setDupeOk(true); - job3->setRemark(QStringLiteral("The quick brown fox fails to jump over Frodo")); - - connect(job3, &SignKeyJob::result, this, [this] (const GpgME::Error &err2, - const QString, - const GpgME::Error) { - Q_EMIT asyncDone(); - QVERIFY(!err2); - }); - - job3->start(target); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - target.update(); - remark = target.userID(0).remark(seckey, err); - QVERIFY(!err); - QVERIFY(remark); - QCOMPARE(QString::fromUtf8(remark), QStringLiteral("The quick brown fox fails " - "to jump over Frodo")); - } - - - void testMultipleRemarks() - { - if (!loopbackSupported()) { - return; - } - // Get the signing key1 (alfa) - auto ctx = Context::create(OpenPGP); - QVERIFY (ctx); - Error err; - auto alpha = ctx->key("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, true); - QVERIFY (!alpha.isNull()); - QVERIFY (!err); - - // Get the signing key2 (zulu) - auto zulu = ctx->key("23FD347A419429BACCD5E72D6BC4778054ACD246", err, true); - QVERIFY (!zulu.isNull()); - QVERIFY (!err); - - // Get the target key (victor) - auto target = ctx->key("E8143C489C8D41124DC40D0B47AF4B6961F04784", err, false); - QVERIFY (!target.isNull()); - QVERIFY (!err); - QVERIFY (target.numUserIDs()); - - // Create the job - auto job = openpgp()->signKeyJob(); - QVERIFY (job); - hookUpPassphraseProvider(job); - - // Setup the first job - job->setExportable(false); - std::vector<unsigned int> uids; - uids.push_back(0); - job->setUserIDsToSign(uids); - job->setSigningKey(alpha); - job->setRemark(QStringLiteral("String one")); - - connect(job, &SignKeyJob::result, this, [this] (const GpgME::Error &err2, - const QString, - const GpgME::Error) { - Q_EMIT asyncDone(); - QVERIFY(!err2); - }); - job->start(target); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // Now another remark from zulu - auto job3 = openpgp()->signKeyJob(); - QVERIFY (job3); - hookUpPassphraseProvider(job3); - - // Set up the job - job3->setExportable(false); - job3->setUserIDsToSign(uids); - job3->setSigningKey(zulu); - job3->setDupeOk(true); - job3->setRemark(QStringLiteral("String two")); - - connect(job3, &SignKeyJob::result, this, [this] (const GpgME::Error &err2, - const QString, - const GpgME::Error) { - Q_EMIT asyncDone(); - QVERIFY(!err2); - }); - - job3->start(target); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - target.update(); - std::vector<GpgME::Key> keys; - keys.push_back(alpha); - keys.push_back(zulu); - - const auto remarks = target.userID(0).remarks(keys, err); - - QVERIFY(!err); - QVERIFY(remarks.size() == 2); - QCOMPARE(remarks[0], std::string("String one")); - QCOMPARE(remarks[1], std::string("String two")); - } - - void testRemarkReplaceSingleUID() - { - if (!loopbackSupported()) { - return; - } - // Get the signing key (alfa) - auto ctx = Context::create(OpenPGP); - QVERIFY (ctx); - Error err; - auto seckey = ctx->key("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, true); - QVERIFY (!seckey.isNull()); - QVERIFY (!err); - - // Get the target key (xray) - auto target = ctx->key("04C1DF62EFA0EBB00519B06A8979A6C5567FB34A", err, false); - QVERIFY (!target.isNull()); - QVERIFY (!err); - QVERIFY (target.numUserIDs()); - - // Create the job - auto job = openpgp()->signKeyJob(); - QVERIFY (job); - hookUpPassphraseProvider(job); - - // Set up the job - job->setExportable(false); - std::vector<unsigned int> uids; - uids.push_back(0); - job->setUserIDsToSign(uids); - job->setSigningKey(seckey); - job->setRemark(QStringLiteral("The quick brown fox jumps over the lazy dog")); - - connect(job, &SignKeyJob::result, this, [this] (const GpgME::Error &err2, - const QString, - const GpgME::Error) { - Q_EMIT asyncDone(); - QVERIFY(!err2); - }); - - job->start(target); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the remark should have been added. - target.update(); - const char *remark = target.userID(0).remark(seckey, err); - QVERIFY(!err); - QVERIFY(remark); - QCOMPARE(QString::fromUtf8(remark), QStringLiteral("The quick brown fox " - "jumps over the lazy dog")); - - // Now replace the remark - auto job3 = openpgp()->signKeyJob(); - QVERIFY (job3); - hookUpPassphraseProvider(job3); - - // Set up the job - job3->setExportable(false); - job3->setUserIDsToSign(uids); - job3->setSigningKey(seckey); - job3->setDupeOk(true); - job3->setRemark(QStringLiteral("The quick brown fox jumps over Frodo")); - - connect(job3, &SignKeyJob::result, this, [this] (const GpgME::Error &err2, - const QString, - const GpgME::Error) { - Q_EMIT asyncDone(); - QVERIFY(!err2); - }); - - job3->start(target); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - target.update(); - remark = target.userID(0).remark(seckey, err); - QVERIFY(!err); - QVERIFY(remark); - QCOMPARE(QString::fromUtf8(remark), QStringLiteral("The quick brown fox " - "jumps over Frodo")); - } - - void testRemarkReplaceMultiUID() - { - if (!loopbackSupported()) { - return; - } - // Get the signing key (alfa) - auto ctx = Context::create(OpenPGP); - QVERIFY (ctx); - Error err; - auto seckey = ctx->key("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, true); - QVERIFY (!seckey.isNull()); - QVERIFY (!err); - - // Get the target key (mallory / mike) - auto target = ctx->key("2686AA191A278013992C72EBBE794852BE5CF886", err, false); - QVERIFY (!target.isNull()); - QVERIFY (!err); - QVERIFY (target.numUserIDs()); - - // Create the job - auto job = openpgp()->signKeyJob(); - QVERIFY (job); - hookUpPassphraseProvider(job); - - // Set up the job - job->setExportable(false); - std::vector<unsigned int> uids; - uids.push_back(0); - job->setUserIDsToSign(uids); - job->setSigningKey(seckey); - job->setRemark(QStringLiteral("Mallory is evil 😠")); - - connect(job, &SignKeyJob::result, this, [this] (const GpgME::Error &err2, - const QString, - const GpgME::Error) { - Q_EMIT asyncDone(); - QVERIFY(!err2); - }); - - job->start(target); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the remark should have been added. - target.update(); - const char *remark = target.userID(0).remark(seckey, err); - QVERIFY(!err); - QVERIFY(remark); - QCOMPARE(QString::fromUtf8(remark), QStringLiteral("Mallory is evil 😠")); - - // Try to replace it without dupeOK - auto job2 = openpgp()->signKeyJob(); - QVERIFY (job2); - hookUpPassphraseProvider(job2); - - // Set up the job - job2->setExportable(false); - job2->setUserIDsToSign(uids); - job2->setSigningKey(seckey); - job2->setRemark(QStringLiteral("Mallory is nice")); - - connect(job2, &SignKeyJob::result, this, [this] (const GpgME::Error &err2, - const QString, - const GpgME::Error) { - Q_EMIT asyncDone(); - QVERIFY(err2); - }); - - job2->start(target); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // Now replace the remark - auto job3 = openpgp()->signKeyJob(); - QVERIFY (job3); - hookUpPassphraseProvider(job3); - - // Set up the job - job3->setExportable(false); - job3->setUserIDsToSign(uids); - job3->setSigningKey(seckey); - job3->setDupeOk(true); - job3->setRemark(QStringLiteral("Mallory is nice")); - - connect(job3, &SignKeyJob::result, this, [this] (const GpgME::Error &err2, - const QString, - const GpgME::Error) { - Q_EMIT asyncDone(); - QVERIFY(!err2); - }); - - job3->start(target); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - target.update(); - remark = target.userID(0).remark(seckey, err); - QVERIFY(!err); - QVERIFY(remark); - QCOMPARE(QString::fromUtf8(remark), QStringLiteral("Mallory is nice")); - } - - void initTestCase() - { - QGpgMETest::initTestCase(); - const QString gpgHome = qgetenv("GNUPGHOME"); - QVERIFY(copyKeyrings(gpgHome, mDir.path())); - qputenv("GNUPGHOME", mDir.path().toUtf8()); - QFile conf(mDir.path() + QStringLiteral("/gpg.conf")); - QVERIFY(conf.open(QIODevice::WriteOnly)); - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() >= "2.2.18") { - conf.write("allow-weak-key-signatures"); - } - conf.close(); - } - -private: - QTemporaryDir mDir; -}; - -QTEST_MAIN(TestRemarks) - -#include "t-remarks.moc" diff --git a/lang/qt/tests/t-revokekey.cpp b/lang/qt/tests/t-revokekey.cpp deleted file mode 100644 index 4d8b0ca5..00000000 --- a/lang/qt/tests/t-revokekey.cpp +++ /dev/null @@ -1,338 +0,0 @@ -/* t-revokekey.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "t-support.h" - -#include <protocol.h> -#include <revokekeyjob.h> - -#include <QDebug> -#include <QProcess> -#include <QRegularExpression> -#include <QSignalSpy> -#include <QTest> - -#include <gpgme++/context.h> -#include <gpgme++/data.h> - -#include <algorithm> - -using namespace QGpgME; -using namespace GpgME; - -/* Test keys - sec ed25519 2022-03-29 [SC] - 604122B94C86BE846EAFE637FC2BCFB1B19A1CF4 - uid [ultimate] [email protected] - ssb cv25519 2022-03-29 [E] - * generated with -export GNUPGHOME=$(mktemp -d) -gpg -K -gpg --batch --pinentry-mode loopback --passphrase abc --quick-gen-key [email protected] default default never -gpg -K -gpg --export-secret-keys --armor --batch --pinentry-mode loopback --passphrase abc --comment [email protected] [email protected] | sed 's/\(.*\)/ "\1\\n"/' -#rm -rf ${GNUPGHOME} -unset GNUPGHOME -*/ -static const char *testKeyData = - "-----BEGIN PGP PRIVATE KEY BLOCK-----\n" - "Comment: [email protected]\n" - "\n" - "lIYEYkLSGhYJKwYBBAHaRw8BAQdAWKBjYOZIW33CjwlHKKGIgqXDOGhmbPCStkj1\n" - "+2/cVFL+BwMCXJpRHkD8EcT8DMWdVo84Lx4w7RNDCQx5xnm6rO5kvtmh+PjgM3qt\n" - "CQVGy8H7Dq35yzi0Hihm5zvHxVGYdAu96ShAI2ZqqVL7is0CdAmAibQVcmV2b2tl\n" - "LW1lQGV4YW1wbGUubmV0iJQEExYKADwWIQRgQSK5TIa+hG6v5jf8K8+xsZoc9AUC\n" - "YkLSGgIbAwULCQgHAgMiAgEGFQoJCAsCBBYCAwECHgcCF4AACgkQ/CvPsbGaHPSH\n" - "LAD/RNFgm1Bp6ltDXLS6oS0S5Bgjjg3CBpbdxWTvLjPpaagBAIU2pTLrsGNDKIZq\n" - "EAY7hY50tdcvOfT4OSAySJACJzMFnIsEYkLSGhIKKwYBBAGXVQEFAQEHQIOTbPEz\n" - "hUtL72BHfetUWESlEbh2IF/NEUWASUtQJDghAwEIB/4HAwJGE5naBnwwcfyPC+Nq\n" - "DwY5FO28hQVAzgNu9KAncmPtpST1J8sEPAtJGhtq/9fki9eSvBMbAa64VVpFHKHK\n" - "ravZxr2uCrK6J/u4rTvnR8HgiHgEGBYKACAWIQRgQSK5TIa+hG6v5jf8K8+xsZoc\n" - "9AUCYkLSGgIbDAAKCRD8K8+xsZoc9ANAAP9rX/xanm7YvcGFIxPclmy4h33lLaG8\n" - "dE5RA6zeSg7DqQD8Dae82iKaqKfTpe2+2vIEyxBVy8+WttoElUoXiwr0AQg=\n" - "=/5re\n" - "-----END PGP PRIVATE KEY BLOCK-----\n"; - -class RevokeKeyJobTest : public QGpgMETest -{ - Q_OBJECT - -private Q_SLOTS: - - void initTestCase() - { - QGpgMETest::initTestCase(); - - // set up the test fixture for this test - qputenv("GNUPGHOME", mGnupgHomeTestFixture.path().toUtf8()); - QVERIFY(importSecretKeys(testKeyData, 1)); - } - - void init() - { - // set up a copy of the test fixture for each test function - mGnupgHomeTestCopy.reset(new QTemporaryDir{}); - QVERIFY(copyKeyrings(mGnupgHomeTestFixture.path(), mGnupgHomeTestCopy->path())); - qputenv("GNUPGHOME", mGnupgHomeTestCopy->path().toUtf8()); - } - - void testAsync() - { - // Get the key that shall be revoked - auto key = getTestKey("[email protected]"); - QVERIFY(!key.isNull()); - QVERIFY(!key.isRevoked()); - - auto job = std::unique_ptr<RevokeKeyJob>{openpgp()->revokeKeyJob()}; - hookUpPassphraseProvider(job.get()); - - Error result; - connect(job.get(), &RevokeKeyJob::result, - job.get(), [this, &result](const Error &result_) { - result = result_; - Q_EMIT asyncDone(); - }); - QVERIFY(!job->start(key, RevocationReason::NoLongerUsed, - {"This key is not used anymore."})); - job.release(); // after the job has been started it's on its own - - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - QVERIFY(result.code() == GPG_ERR_NO_ERROR); - key.update(); - QVERIFY(key.isRevoked()); - verifyReason(key, RevocationReason::NoLongerUsed, - {"This key is not used anymore."}); - } - - void testSync_noReasonDescription() - { - // Get the key that shall be revoked - auto key = getTestKey("[email protected]"); - QVERIFY(!key.isNull()); - QVERIFY(!key.isRevoked()); - - auto job = std::unique_ptr<RevokeKeyJob>{openpgp()->revokeKeyJob()}; - hookUpPassphraseProvider(job.get()); - - const auto result = job->exec(key); - - QVERIFY(result.code() == GPG_ERR_NO_ERROR); - key.update(); - QVERIFY(key.isRevoked()); - verifyReason(key, RevocationReason::Unspecified, {}); - } - - void testSync_oneLineReasonDescription() - { - // Get the key that shall be revoked - auto key = getTestKey("[email protected]"); - QVERIFY(!key.isNull()); - QVERIFY(!key.isRevoked()); - - auto job = std::unique_ptr<RevokeKeyJob>{openpgp()->revokeKeyJob()}; - hookUpPassphraseProvider(job.get()); - - const auto result = job->exec(key, RevocationReason::Compromised, - {"The secret key was stolen."}); - - QVERIFY(result.code() == GPG_ERR_NO_ERROR); - key.update(); - QVERIFY(key.isRevoked()); - verifyReason(key, RevocationReason::Compromised, - {"The secret key was stolen."}); - } - - void testSync_twoLinesReasonDescription() - { - // Get the key that shall be revoked - auto key = getTestKey("[email protected]"); - QVERIFY(!key.isNull()); - QVERIFY(!key.isRevoked()); - - auto job = std::unique_ptr<RevokeKeyJob>{openpgp()->revokeKeyJob()}; - hookUpPassphraseProvider(job.get()); - - const auto result = job->exec(key, RevocationReason::Superseded, - {"This key has been superseded by key", - "0000 1111 2222 3333 4444 5555 6666 7777 8888 9999."}); - - QVERIFY(result.code() == GPG_ERR_NO_ERROR); - key.update(); - QVERIFY(key.isRevoked()); - verifyReason(key, RevocationReason::Superseded, - {"This key has been superseded by key", - "0000 1111 2222 3333 4444 5555 6666 7777 8888 9999."}); - } - - void testErrorHandling_nullKey() - { - { - auto job = std::unique_ptr<RevokeKeyJob>{openpgp()->revokeKeyJob()}; - QTest::ignoreMessage(QtWarningMsg, "Error: Key is null key"); - const auto result = job->exec(Key{}); - QVERIFY(result.code() == GPG_ERR_INV_ARG); - } - { - auto job = std::unique_ptr<RevokeKeyJob>{openpgp()->revokeKeyJob()}; - QTest::ignoreMessage(QtWarningMsg, "Error: Key is null key"); - const auto result = job->start(Key{}); - QVERIFY(result.code() == GPG_ERR_INV_ARG); - } - } - - void testErrorHandling_invalidReason() - { - // Get the key that shall be revoked - auto key = getTestKey("[email protected]"); - QVERIFY(!key.isNull()); - QVERIFY(!key.isRevoked()); - - { - auto job = std::unique_ptr<RevokeKeyJob>{openpgp()->revokeKeyJob()}; - QTest::ignoreMessage(QtWarningMsg, QRegularExpression{"^Error: Invalid revocation reason"}); - const auto result = job->exec(key, static_cast<RevocationReason>(-1)); - QVERIFY(result.code() == GPG_ERR_INV_VALUE); - } - { - auto job = std::unique_ptr<RevokeKeyJob>{openpgp()->revokeKeyJob()}; - QTest::ignoreMessage(QtWarningMsg, QRegularExpression{"^Error: Invalid revocation reason"}); - const auto result = job->start(key, static_cast<RevocationReason>(4)); - QVERIFY(result.code() == GPG_ERR_INV_VALUE); - } - } - - void testErrorHandling_invalidDescription() - { - // Get the key that shall be revoked - auto key = getTestKey("[email protected]"); - QVERIFY(!key.isNull()); - QVERIFY(!key.isRevoked()); - - { - auto job = std::unique_ptr<RevokeKeyJob>{openpgp()->revokeKeyJob()}; - QTest::ignoreMessage(QtWarningMsg, "Error: Revocation description contains empty lines or lines with endline characters"); - const auto result = job->exec(key, RevocationReason::Unspecified, - {"line1", "", "line3"}); - QVERIFY(result.code() == GPG_ERR_INV_VALUE); - } - { - auto job = std::unique_ptr<RevokeKeyJob>{openpgp()->revokeKeyJob()}; - QTest::ignoreMessage(QtWarningMsg, "Error: Revocation description contains empty lines or lines with endline characters"); - const auto result = job->start(key, RevocationReason::Unspecified, - {"line1\nline2"}); - QVERIFY(result.code() == GPG_ERR_INV_VALUE); - } - } - -private: - Key getTestKey(const char *pattern) - { - auto ctx = Context::create(OpenPGP); - VERIFY_OR_OBJECT(ctx); - - Error err; - auto key = ctx->key(pattern, err, /*secret=*/true); - VERIFY_OR_OBJECT(!err); - VERIFY_OR_OBJECT(!key.isNull()); - return key; - } - - bool verifyReason(const Key &key, RevocationReason reason, const QStringList &description) - { - static const auto startTimeout = std::chrono::milliseconds{1000}; - static const auto finishTimeout = std::chrono::milliseconds{2000}; - static const QStringList hexCodeForReason = { - QStringLiteral("00"), /* no particular reason */ - QStringLiteral("02"), /* key has been compromised */ - QStringLiteral("01"), /* key is superseded */ - QStringLiteral("03") /* key is no longer used */ - }; - - QProcess p; - p.setProgram(dirInfo("gpg-name")); - p.setArguments({QStringLiteral("-K"), - QStringLiteral("--with-colon"), - QStringLiteral("--with-sig-list"), - QLatin1String{key.primaryFingerprint()} - }); - - p.start(); - - if (!p.waitForStarted(startTimeout.count())) { - qWarning() << "Timeout while waiting for start of" << p.program() << p.arguments().join(u' '); - return false; - } - if (!p.waitForFinished(finishTimeout.count())) { - qWarning() << "Timeout while waiting for completion of" << p.program() << p.arguments().join(u' '); - return false; - } - if (p.exitStatus() != QProcess::NormalExit) { - qWarning() << p.program() << "terminated abnormally with exit status" << p.exitStatus(); - return false; - } - - const auto lines = QString::fromUtf8(p.readAllStandardOutput()).split(u'\n'); - for (const auto &l : lines) { - const auto fields = l.split(u':'); - if (fields[0] == QLatin1String{"rev"}) { - // or "rev" the signature class may be followed by a comma - // and a 2 digit hexnumber with the revocation reason - const auto sigClass = fields.value(10); - const auto revReason = sigClass.split(u',').value(1); - COMPARE_OR_FALSE(revReason, hexCodeForReason.value(static_cast<int>(reason))); - - // decode the \n in the C-style quoted comment field - const auto comment = fields.value(20).replace(QStringLiteral("\\n"), QStringLiteral("\n")); - COMPARE_OR_FALSE(comment, description.join(u'\n')); - return true; - } - if (fields[0] == QLatin1String{"uid"}) { - qWarning() << "Found uid before rev in key listing:\n" << stdout; - return false; - } - } - return false; - } - -private: - QTemporaryDir mGnupgHomeTestFixture; - std::unique_ptr<QTemporaryDir> mGnupgHomeTestCopy; -}; - -QTEST_MAIN(RevokeKeyJobTest) - -#include "t-revokekey.moc" diff --git a/lang/qt/tests/t-setprimaryuserid.cpp b/lang/qt/tests/t-setprimaryuserid.cpp deleted file mode 100644 index e57d1c6e..00000000 --- a/lang/qt/tests/t-setprimaryuserid.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* t-setprimaryuserid.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "t-support.h" - -#include <keylistjob.h> -#include <protocol.h> - -#include <gpgme++/context.h> -#include <gpgme++/engineinfo.h> -#include <gpgme++/keylistresult.h> - -using namespace QGpgME; -using namespace GpgME; - -class TestSetPrimaryUserID: public QGpgMETest -{ - Q_OBJECT - -private Q_SLOTS: - void testSetPrimaryUserID() - { - Key key; - { - std::unique_ptr<KeyListJob> job{openpgp()->keyListJob()}; - std::vector<GpgME::Key> keys; - GpgME::KeyListResult result = job->exec({QStringLiteral("[email protected]")}, true, keys); - QVERIFY(!result.error()); - QVERIFY(keys.size() == 1); - key = keys.front(); - } - - QCOMPARE(key.numUserIDs(), 3u); - const std::string oldPrimaryUserId = key.userID(0).id(); - const std::string newPrimaryUserId = key.userID(1).id(); - const std::string newPrimaryUserIdHash = key.userID(1).uidhash(); - - { - std::unique_ptr<Context> ctx{Context::createForProtocol(key.protocol())}; - QVERIFY(ctx); - hookUpPassphraseProvider(ctx.get()); - - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() >= "2.3.8") { - QVERIFY(!ctx->setPrimaryUid(key, newPrimaryUserIdHash.c_str())); - } else { - QVERIFY(!ctx->setPrimaryUid(key, newPrimaryUserId.c_str())); - } - } - key.update(); - - QCOMPARE(key.userID(0).id(), newPrimaryUserId); - - { - std::unique_ptr<Context> ctx{Context::createForProtocol(key.protocol())}; - QVERIFY(ctx); - hookUpPassphraseProvider(ctx.get()); - - QVERIFY(!ctx->setPrimaryUid(key, oldPrimaryUserId.c_str())); - } - key.update(); - - QCOMPARE(key.userID(0).id(), oldPrimaryUserId); - } - - void testErrorHandling_noSecretKey() - { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.3.8") { - QSKIP("gpg < 2.3.8 does not report status error"); - } - Key key; - { - std::unique_ptr<KeyListJob> job{openpgp()->keyListJob()}; - std::vector<GpgME::Key> keys; - GpgME::KeyListResult result = job->exec({QStringLiteral("[email protected]")}, false, keys); - QVERIFY(!result.error()); - QVERIFY(keys.size() == 1); - key = keys.front(); - } - - QCOMPARE(key.numUserIDs(), 2u); - const std::string newPrimaryUserId = key.userID(1).id(); - - { - std::unique_ptr<Context> ctx{Context::createForProtocol(key.protocol())}; - QVERIFY(ctx); - auto err = ctx->setPrimaryUid(key, newPrimaryUserId.c_str()); - QCOMPARE(err.code(), static_cast<int>(GPG_ERR_NO_SECKEY)); - } - } - - void testErrorHandling_noUserID() - { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.3.8") { - QSKIP("gpg < 2.3.8 does not report status error"); - } - Key key; - { - std::unique_ptr<KeyListJob> job{openpgp()->keyListJob()}; - std::vector<GpgME::Key> keys; - GpgME::KeyListResult result = job->exec({QStringLiteral("[email protected]")}, true, keys); - QVERIFY(!result.error()); - QVERIFY(keys.size() == 1); - key = keys.front(); - } - { - std::unique_ptr<Context> ctx{Context::createForProtocol(key.protocol())}; - QVERIFY(ctx); - auto err = ctx->setPrimaryUid(key, "bravo"); - QCOMPARE(err.code(), static_cast<int>(GPG_ERR_NO_USER_ID)); - } - } - - void initTestCase() - { - QGpgMETest::initTestCase(); - const QString gpgHome = qgetenv("GNUPGHOME"); - QVERIFY(copyKeyrings(gpgHome, mDir.path())); - qputenv("GNUPGHOME", mDir.path().toUtf8()); - QFile conf(mDir.path() + QStringLiteral("/gpg.conf")); - QVERIFY(conf.open(QIODevice::WriteOnly)); - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() >= "2.2.18") { - conf.write("allow-weak-key-signatures\n"); - } - conf.close(); - } - -private: - QTemporaryDir mDir; -}; - -QTEST_MAIN(TestSetPrimaryUserID) - -#include "t-setprimaryuserid.moc" diff --git a/lang/qt/tests/t-support.cpp b/lang/qt/tests/t-support.cpp deleted file mode 100644 index 48ad0cd9..00000000 --- a/lang/qt/tests/t-support.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* t-support.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "t-support.h" - -#include "importjob.h" -#include "job.h" -#include "protocol.h" - -#include <QTest> - -#include <QProcess> -#include <QCoreApplication> -#include <QObject> -#include <QDir> -#include <QSignalSpy> - -#include <gpgme++/context.h> -#include <gpgme++/engineinfo.h> -#include <gpgme++/importresult.h> - -using namespace GpgME; -using namespace QGpgME; - -void QGpgMETest::initTestCase() -{ - GpgME::initializeLibrary(); - const QString gpgHome = qgetenv("GNUPGHOME"); - QVERIFY2(!gpgHome.isEmpty(), "GNUPGHOME environment variable is not set."); -} - -void QGpgMETest::cleanupTestCase() -{ - QCoreApplication::sendPostedEvents(); - killAgent(); -} - -// static -bool QGpgMETest::doOnlineTests() -{ - return !qgetenv("DO_ONLINE_TESTS").isEmpty(); -} - -bool QGpgMETest::copyKeyrings(const QString &src, const QString &dest) -{ - bool is21dir = QFileInfo(src + QDir::separator() + QStringLiteral("pubring.kbx")).exists(); - const QString name = is21dir ? QStringLiteral("pubring.kbx") : - QStringLiteral("pubring.gpg"); - if (!QFile::copy(src + QDir::separator() + name, dest + QDir::separator() + name)) { - return false; - } - if (!is21dir) { - return (QFile::copy(src + QDir::separator() + QStringLiteral("secring.gpg"), - dest + QDir::separator() + QStringLiteral("secring.gpg"))); - } - QDir dir (src + QDir::separator() + QStringLiteral("private-keys-v1.d")); - QDir target(dest); - if (!target.mkdir("private-keys-v1.d")) { - return false; - } - foreach (QString f, dir.entryList(QDir::Files)) { - if (!QFile::copy(dir.path() + QDir::separator() + f, - dest + QDir::separator() + - QStringLiteral("private-keys-v1.d") + QDir::separator() + f)) { - return false; - } - } - return true; -} - -bool QGpgMETest::importSecretKeys(const char *keyData, int expectedKeys) -{ - auto job = std::unique_ptr<ImportJob>{openpgp()->importJob()}; - VERIFY_OR_FALSE(job); - hookUpPassphraseProvider(job.get()); - - ImportResult result; - connect(job.get(), &ImportJob::result, - this, [this, &result](const ImportResult &result_) { - result = result_; - Q_EMIT asyncDone(); - }); - VERIFY_OR_FALSE(!job->start(keyData)); - job.release(); // after the job has been started it's on its own - - QSignalSpy spy (this, SIGNAL(asyncDone())); - VERIFY_OR_FALSE(spy.wait(QSIGNALSPY_TIMEOUT)); - VERIFY_OR_FALSE(!result.error()); - VERIFY_OR_FALSE(!result.imports().empty()); - COMPARE_OR_FALSE(result.numSecretKeysImported(), expectedKeys); - - return true; -} - -void QGpgMETest::hookUpPassphraseProvider(GpgME::Context *context) -{ - context->setPassphraseProvider(&mPassphraseProvider); - context->setPinentryMode(Context::PinentryLoopback); -} - -void QGpgMETest::hookUpPassphraseProvider(QGpgME::Job *job) -{ - hookUpPassphraseProvider(Job::context(job)); -} - -void killAgent(const QString& dir) -{ - QProcess proc; - proc.setProgram(QStringLiteral("gpg-connect-agent")); - QStringList arguments; - arguments << "-S " << dir + "/S.gpg-agent"; - proc.start(); - proc.waitForStarted(); - proc.write("KILLAGENT\n"); - proc.write("BYE\n"); - proc.closeWriteChannel(); - proc.waitForFinished(); -} - -bool loopbackSupported() -{ - /* With GnuPG 2.0.x (at least 2.0.26 by default on jessie) - * the passphrase_cb does not work. So the test popped up - * a pinentry. So tests requiring decryption don't work. */ - static auto version = GpgME::engineInfo(GpgME::GpgEngine).engineVersion(); - if (version < "2.0.0") { - /* With 1.4 it just works */ - return true; - } - if (version < "2.1.0") { - /* With 2.1 it works with loopback mode */ - return false; - } - return true; -} - -#include "t-support.hmoc" diff --git a/lang/qt/tests/t-support.h b/lang/qt/tests/t-support.h deleted file mode 100644 index eb4ba57d..00000000 --- a/lang/qt/tests/t-support.h +++ /dev/null @@ -1,134 +0,0 @@ -/* t-support.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifndef T_SUPPORT_H -#define T_SUPPORT_H - -#include <gpgme++/interfaces/passphraseprovider.h> -#include <QObject> -#include <QTest> - -#include <gpg-error.h> - -namespace GpgME -{ -class Context; -} - -namespace QGpgME -{ -class Job; -} - -/// generic variant of QVERIFY returning \a returnValue on failure -#define VERIFY_OR_RETURN_VALUE(statement, returnValue) \ -do {\ - if (!QTest::qVerify(static_cast<bool>(statement), #statement, "", __FILE__, __LINE__))\ - return returnValue;\ -} while (false) - -/// generic variant of QCOMPARE returning \a returnValue on failure -#define COMPARE_OR_RETURN_VALUE(actual, expected, returnValue) \ -do {\ - if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\ - return returnValue;\ -} while (false) - -/// variant of QVERIFY returning a default constructed object on failure -#define VERIFY_OR_OBJECT(statement) VERIFY_OR_RETURN_VALUE(statement, {}) - -/// variant of QCOMPARE returning a default constructed object on failure -#define COMPARE_OR_OBJECT(actual, expected) COMPARE_OR_RETURN_VALUE(actual, expected, {}) - -/// variant of QVERIFY returning \c false on failure -#define VERIFY_OR_FALSE(statement) VERIFY_OR_RETURN_VALUE(statement, false) - -/// variant of QCOMPARE returning \c false on failure -#define COMPARE_OR_FALSE(actual, expected) COMPARE_OR_RETURN_VALUE(actual, expected, false) - -namespace QTest -{ -template <> -inline char *toString(const std::string &s) -{ - return QTest::toString(s.c_str()); -} -} - -namespace GpgME -{ -class TestPassphraseProvider : public PassphraseProvider -{ -public: - char *getPassphrase(const char * /*useridHint*/, const char * /*description*/, - bool /*previousWasBad*/, bool &/*canceled*/) override - { - char *ret; - gpgrt_asprintf(&ret, "abc"); - return ret; - } -}; -} // namespace GpgME - -void killAgent(const QString &dir = qgetenv("GNUPGHOME")); -/* Is the passphrase Provider / loopback Supported */ -bool loopbackSupported(); - -class QGpgMETest : public QObject -{ - Q_OBJECT - -Q_SIGNALS: - void asyncDone(); - -protected: - static bool doOnlineTests(); - - bool copyKeyrings(const QString &from, const QString& to); - - bool importSecretKeys(const char *keyData, int expectedKeys = 1); - - void hookUpPassphraseProvider(GpgME::Context *context); - void hookUpPassphraseProvider(QGpgME::Job *job); - -public Q_SLOTS: - void initTestCase(); - void cleanupTestCase(); - -private: - GpgME::TestPassphraseProvider mPassphraseProvider; -}; - -/* Timeout, in milliseconds, for use with QSignalSpy to wait on - signals. */ -#define QSIGNALSPY_TIMEOUT 60000 - -#endif // T_SUPPORT_H diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp deleted file mode 100644 index 852142cf..00000000 --- a/lang/qt/tests/t-tofuinfo.cpp +++ /dev/null @@ -1,530 +0,0 @@ -/* t-tofuinfo.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <QDebug> -#include <QTest> -#include <QTemporaryDir> -#include <QSignalSpy> - -#include "debug.h" -#include "protocol.h" -#include <gpgme++/tofuinfo.h> -#include "tofupolicyjob.h" -#include "verifyopaquejob.h" -#include <gpgme++/verificationresult.h> -#include <gpgme++/signingresult.h> -#include "importjob.h" -#include <gpgme++/importresult.h> -#include "keylistjob.h" -#include <gpgme++/keylistresult.h> -#include "signjob.h" -#include <gpgme++/key.h> - -#include "t-support.h" -#include <gpgme++/engineinfo.h> -#include <gpgme++/context.h> -#include <iostream> - -using namespace QGpgME; -using namespace GpgME; - -static const char testMsg1[] = -"-----BEGIN PGP MESSAGE-----\n" -"\n" -"owGbwMvMwCSoW1RzPCOz3IRxjXQSR0lqcYleSUWJTZOvjVdpcYmCu1+oQmaJIleH\n" -"GwuDIBMDGysTSIqBi1MApi+nlGGuwDeHao53HBr+FoVGP3xX+kvuu9fCMJvl6IOf\n" -"y1kvP4y+8D5a11ang0udywsA\n" -"=Crq6\n" -"-----END PGP MESSAGE-----\n"; - -static const char conflictKey1[] = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" -"\n" -"mDMEXDWgpxYJKwYBBAHaRw8BAQdAguVu4qkx8iw4eU+TQ4vvcKG7IdcZvbMhw3Zc\n" -"npGf0+u0GXRvZnVfY29uZmxpY3RAZXhhbXBsZS5jb22IkAQTFggAOBYhBO6ovNDG\n" -"nLzbR1TlMJYJ0fjlWbUrBQJcNaCnAhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheA\n" -"AAoJEJYJ0fjlWbUrLaMBALegwkv2+sEcmKZqxt8JscYvFiEuycv2+rKHaZA0eDoN\n" -"AP97W4XrJb5x49J5jDDdeko8k00uGqiiuAXJo27/i/phA7g4BFw1oKcSCisGAQQB\n" -"l1UBBQEBB0Crhw24E2lPBhd/y+ZFotQ/2TrYqkUQqGPmff8ofLziNgMBCAeIeAQY\n" -"FggAIBYhBO6ovNDGnLzbR1TlMJYJ0fjlWbUrBQJcNaCnAhsMAAoJEJYJ0fjlWbUr\n" -"/K8BAJWsa+tOZsJw7w5fz6O0We6Xx4Rt17jHf563G6wMcz9+AQDRsedJ7w4zYzS9\n" -"MFiJQ5aN0NDHMRtDFWAgCunVnJ3OBw==\n" -"=fZa5\n" -"-----END PGP PUBLIC KEY BLOCK-----\n"; - -static const char conflictKey2[] = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" -"\n" -"mDMEXDWgixYJKwYBBAHaRw8BAQdAMWOhumYspcvEOTuesOSN4rvnJVOj/6qOWFTu\n" -"x+wPRra0GXRvZnVfY29uZmxpY3RAZXhhbXBsZS5jb22IkAQTFggAOBYhBA64G88Q\n" -"NPXztj8ID/FhC7tiGbeRBQJcNaCLAhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheA\n" -"AAoJEPFhC7tiGbeRUt4A/2hf4Zgz+TYyfeH/4/ZtyL1JuZggqR1s5UopEx2Aiw10\n" -"AP405KiTd31TJQN8Ru+7bskPu0/mzLZMNkRvBNEdc5kbDLg4BFw1oIsSCisGAQQB\n" -"l1UBBQEBB0B5NtSrx7wDDKgwUe5Rxz0vRkaWLtyE0KbfE77oPy5DGAMBCAeIeAQY\n" -"FggAIBYhBA64G88QNPXztj8ID/FhC7tiGbeRBQJcNaCLAhsMAAoJEPFhC7tiGbeR\n" -"km0BAP8TQwraipqb1pJlLsEgDXeM5Jocz4fuePD78BsOBtORAP9gpCyKXdyJYGlA\n" -"qjmG356yG6pCK9aPckTZ9IViPiHWCw==\n" -"=tn3Q\n" -"-----END PGP PUBLIC KEY BLOCK-----\n"; - -static const char conflictMsg1[] = "-----BEGIN PGP MESSAGE-----\n" -"\n" -"owGbwMvMwCE2jfPij6eRW7UZTwsnMcSYLnT0Ki0uUXD3C1XILFHk6ihlYRDjYJAV\n" -"U2R5t2LPhWNz9tx2D3lqANPEygTSwcDFKQAT+RjG8M9of873hQrMpinBVwKYv+rq\n" -"XGmYW+ZcZJ+133KDq+itzlxGhg3L2X/6Khj+2Hd+He+KnXtunF2wNWxl7849e/Sy\n" -"v6tc+8MBAA==\n" -"=fZLe\n" -"-----END PGP MESSAGE-----\n"; - -static const char conflictMsg2[] = "-----BEGIN PGP MESSAGE-----\n" -"\n" -"owGbwMvMwCH2MZF7d5Lk9omMp4WTGGJMFwZ4lRaXKLj7hSpklihydZSyMIhxMMiK\n" -"KbLw7ZA+L2Dy9fM2ew5+mCZWJpAOBi5OAZhIUhIjw7bV+xS+cR0quqhmcY2Dl3WW\n" -"8Ufr+rRNufOPyIdoO6nEXGH47/B+E1+oxS6e5f5n7MJ3aHBO+s345sipGV/4f665\n" -"9mmiGjsA\n" -"=8oJA\n" -"-----END PGP MESSAGE-----\n"; - -class TofuInfoTest: public QGpgMETest -{ - Q_OBJECT - -private: - bool testSupported() - { - static bool initialized, supported; - if (initialized) { - return supported; - } - initialized = true; - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.16") { - return false; - } - // If the keylist fails here this means that gnupg does not - // support tofu at all. It can be disabled at compile time. So no - // tests. - auto *job = openpgp()->keyListJob(false, false, false); - job->addMode(GpgME::WithTofu); - std::vector<GpgME::Key> keys; - job->exec(QStringList() << QStringLiteral("[email protected]"), true, keys); - delete job; - supported = !keys.empty(); - return supported; - } - - void testTofuCopy(TofuInfo other, const TofuInfo &orig) - { - QVERIFY(!orig.isNull()); - QVERIFY(!other.isNull()); - QVERIFY(orig.signLast() == other.signLast()); - QVERIFY(orig.signCount() == other.signCount()); - QVERIFY(orig.validity() == other.validity()); - QVERIFY(orig.policy() == other.policy()); - } - - void signAndVerify(const QString &what, const GpgME::Key &key, int expected) - { - auto job = openpgp()->signJob(); - hookUpPassphraseProvider(job); - - std::vector<Key> keys; - keys.push_back(key); - QByteArray signedData; - auto sigResult = job->exec(keys, what.toUtf8(), NormalSignatureMode, signedData); - delete job; - - QVERIFY(!sigResult.error()); - for (const auto &uid : keys[0].userIDs()) { - auto info = uid.tofuInfo(); - QVERIFY(info.signCount() == expected - 1); - } - - auto verifyJob = openpgp()->verifyOpaqueJob(); - QByteArray verified; - - auto result = verifyJob->exec(signedData, verified); - delete verifyJob; - - QVERIFY(!result.error()); - QVERIFY(verified == what.toUtf8()); - - QVERIFY(result.numSignatures() == 1); - auto sig = result.signatures()[0]; - - auto key2 = sig.key(); - QVERIFY(!key.isNull()); - QVERIFY(!strcmp (key2.primaryFingerprint(), key.primaryFingerprint())); - QVERIFY(!strcmp (key.primaryFingerprint(), sig.fingerprint())); - auto stats = key2.userID(0).tofuInfo(); - QVERIFY(!stats.isNull()); - if (stats.signCount() != expected) { - std::cout << "################ Key before verify: " - << key - << "################ Key after verify: " - << key2; - } - QVERIFY(stats.signCount() == expected); - } - -private Q_SLOTS: - void testTofuNull() - { - if (!testSupported()) { - return; - } - TofuInfo tofu; - QVERIFY(tofu.isNull()); - QVERIFY(!tofu.description()); - QVERIFY(!tofu.signCount()); - QVERIFY(!tofu.signLast()); - QVERIFY(!tofu.signFirst()); - QVERIFY(tofu.validity() == TofuInfo::ValidityUnknown); - QVERIFY(tofu.policy() == TofuInfo::PolicyUnknown); - } - - void testTofuInfo() - { - if (!testSupported()) { - return; - } - auto *job = openpgp()->verifyOpaqueJob(true); - const QByteArray data1(testMsg1); - QByteArray plaintext; - - auto ctx = Job::context(job); - QVERIFY(ctx); - ctx->setSender("[email protected]"); - - auto result = job->exec(data1, plaintext); - delete job; - - QVERIFY(!result.isNull()); - QVERIFY(!result.error()); - QVERIFY(!strcmp(plaintext.constData(), "Just GNU it!\n")); - - QVERIFY(result.numSignatures() == 1); - Signature sig = result.signatures()[0]; - /* TOFU is always marginal */ - QVERIFY(sig.validity() == Signature::Marginal); - - auto stats = sig.key().userID(0).tofuInfo(); - QVERIFY(!stats.isNull()); - QVERIFY(sig.key().primaryFingerprint()); - QVERIFY(sig.fingerprint()); - QVERIFY(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint())); - QVERIFY(stats.signFirst() == stats.signLast()); - QVERIFY(stats.signCount() == 1); - QVERIFY(stats.policy() == TofuInfo::PolicyAuto); - QVERIFY(stats.validity() == TofuInfo::LittleHistory); - - testTofuCopy(stats, stats); - - /* Another verify */ - - job = openpgp()->verifyOpaqueJob(true); - result = job->exec(data1, plaintext); - delete job; - - QVERIFY(!result.isNull()); - QVERIFY(!result.error()); - - QVERIFY(result.numSignatures() == 1); - sig = result.signatures()[0]; - /* TOFU is always marginal */ - QVERIFY(sig.validity() == Signature::Marginal); - - stats = sig.key().userID(0).tofuInfo(); - QVERIFY(!stats.isNull()); - QVERIFY(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint())); - QVERIFY(stats.signFirst() == stats.signLast()); - QVERIFY(stats.signCount() == 1); - QVERIFY(stats.policy() == TofuInfo::PolicyAuto); - QVERIFY(stats.validity() == TofuInfo::LittleHistory); - - /* Verify that another call yields the same result */ - job = openpgp()->verifyOpaqueJob(true); - result = job->exec(data1, plaintext); - delete job; - - QVERIFY(!result.isNull()); - QVERIFY(!result.error()); - - QVERIFY(result.numSignatures() == 1); - sig = result.signatures()[0]; - /* TOFU is always marginal */ - QVERIFY(sig.validity() == Signature::Marginal); - - stats = sig.key().userID(0).tofuInfo(); - QVERIFY(!stats.isNull()); - QVERIFY(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint())); - QVERIFY(stats.signFirst() == stats.signLast()); - QVERIFY(stats.signCount() == 1); - QVERIFY(stats.policy() == TofuInfo::PolicyAuto); - QVERIFY(stats.validity() == TofuInfo::LittleHistory); - } - - void testTofuSignCount() - { - if (!testSupported()) { - return; - } - auto *job = openpgp()->keyListJob(false, false, false); - job->addMode(GpgME::WithTofu); - std::vector<GpgME::Key> keys; - GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("[email protected]"), - true, keys); - delete job; - QVERIFY(!keys.empty()); - Key key = keys[0]; - QVERIFY(!key.isNull()); - - /* As we sign & verify quickly here we need different - * messages to avoid having them treated as the same - * message if they were created within the same second. - * Alternatively we could use the same message and wait - * a second between each call. But this would slow down - * the testsuite. */ - signAndVerify(QStringLiteral("Hello"), key, 1); - key.update(); - signAndVerify(QStringLiteral("Hello2"), key, 2); - key.update(); - signAndVerify(QStringLiteral("Hello3"), key, 3); - key.update(); - signAndVerify(QStringLiteral("Hello4"), key, 4); - } - - void testTofuKeyList() - { - if (!testSupported()) { - return; - } - - /* First check that the key has no tofu info. */ - auto *job = openpgp()->keyListJob(false, false, false); - std::vector<GpgME::Key> keys; - auto result = job->exec(QStringList() << QStringLiteral("[email protected]"), - true, keys); - delete job; - QVERIFY(!keys.empty()); - auto key = keys[0]; - QVERIFY(!key.isNull()); - QVERIFY(key.userID(0).tofuInfo().isNull()); - auto keyCopy = key; - keyCopy.update(); - auto sigCnt = keyCopy.userID(0).tofuInfo().signCount(); - signAndVerify(QStringLiteral("Hello5"), keyCopy, - sigCnt + 1); - keyCopy.update(); - signAndVerify(QStringLiteral("Hello6"), keyCopy, - sigCnt + 2); - - /* Now another one but with tofu */ - job = openpgp()->keyListJob(false, false, false); - job->addMode(GpgME::WithTofu); - result = job->exec(QStringList() << QStringLiteral("[email protected]"), - true, keys); - delete job; - QVERIFY(!result.error()); - QVERIFY(!keys.empty()); - auto key2 = keys[0]; - QVERIFY(!key2.isNull()); - auto info = key2.userID(0).tofuInfo(); - QVERIFY(!info.isNull()); - QVERIFY(info.signCount()); - } - - void testTofuPolicy() - { - if (!testSupported()) { - return; - } - - /* First check that the key has no tofu info. */ - auto *job = openpgp()->keyListJob(false, false, false); - std::vector<GpgME::Key> keys; - job->addMode(GpgME::WithTofu); - auto result = job->exec(QStringList() << QStringLiteral("[email protected]"), - false, keys); - - if (keys.empty()) { - qDebug() << "[email protected] not found"; - qDebug() << "Error: " << result.error(); - const auto homedir = QString::fromLocal8Bit(qgetenv("GNUPGHOME")); - qDebug() << "Homedir is: " << homedir; - QFileInfo fi(homedir + "/pubring.gpg"); - qDebug () << "pubring exists: " << fi.exists() << " readable? " - << fi.isReadable() << " size: " << fi.size(); - QFileInfo fi2(homedir + "/pubring.kbx"); - qDebug () << "keybox exists: " << fi2.exists() << " readable? " - << fi2.isReadable() << " size: " << fi2.size(); - - result = job->exec(QStringList(), false, keys); - for (const auto &key : keys) { - qDebug() << "Key: " << key.userID(0).name() << " <" - << key.userID(0).email() - << ">\n fpr: " << key.primaryFingerprint(); - } - } - QVERIFY(!result.error()); - QVERIFY(!keys.empty()); - auto key = keys[0]; - QVERIFY(!key.isNull()); - QVERIFY(key.userID(0).tofuInfo().policy() != TofuInfo::PolicyBad); - auto *tofuJob = openpgp()->tofuPolicyJob(); - auto err = tofuJob->exec(key, TofuInfo::PolicyBad); - QVERIFY(!err); - result = job->exec(QStringList() << QStringLiteral("[email protected]"), - false, keys); - QVERIFY(!keys.empty()); - key = keys[0]; - QVERIFY(key.userID(0).tofuInfo().policy() == TofuInfo::PolicyBad); - err = tofuJob->exec(key, TofuInfo::PolicyGood); - - result = job->exec(QStringList() << QStringLiteral("[email protected]"), - false, keys); - key = keys[0]; - QVERIFY(key.userID(0).tofuInfo().policy() == TofuInfo::PolicyGood); - delete tofuJob; - delete job; - } - - void testTofuConflict() - { - if (!testSupported()) { - return; - } - - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.19") { - return; - } - - // Import key 1 - auto importjob = openpgp()->importJob(); - connect(importjob, &ImportJob::result, this, - [this](ImportResult result, QString, Error) - { - QVERIFY(!result.error()); - QVERIFY(!result.imports().empty()); - QVERIFY(result.numImported()); - Q_EMIT asyncDone(); - }); - importjob->start(QByteArray(conflictKey1)); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait()); - - // Verify Message 1 - const QByteArray signedData(conflictMsg1); - auto verifyJob = openpgp()->verifyOpaqueJob(true); - QByteArray verified; - auto result = verifyJob->exec(signedData, verified); - delete verifyJob; - - QVERIFY(!result.isNull()); - QVERIFY(!result.error()); - - QVERIFY(result.numSignatures() == 1); - auto sig = result.signatures()[0]; - QVERIFY(sig.validity() == Signature::Marginal); - - auto stats = sig.key().userID(0).tofuInfo(); - QVERIFY(!stats.isNull()); - QVERIFY(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint())); - QVERIFY(stats.signFirst() == stats.signLast()); - QVERIFY(stats.signCount() == 1); - QVERIFY(stats.policy() == TofuInfo::PolicyAuto); - QVERIFY(stats.validity() == TofuInfo::LittleHistory); - - // Import key 2 - importjob = openpgp()->importJob(); - connect(importjob, &ImportJob::result, this, - [this](ImportResult result, QString, Error) - { - QVERIFY(!result.error()); - QVERIFY(!result.imports().empty()); - QVERIFY(result.numImported()); - Q_EMIT asyncDone(); - }); - importjob->start(QByteArray(conflictKey2)); - QSignalSpy spy2 (this, SIGNAL(asyncDone())); - QVERIFY(spy2.wait()); - - // Verify Message 2 - const QByteArray signedData2(conflictMsg2); - QByteArray verified2; - verifyJob = openpgp()->verifyOpaqueJob(true); - result = verifyJob->exec(signedData2, verified2); - delete verifyJob; - - QVERIFY(!result.isNull()); - QVERIFY(!result.error()); - - QVERIFY(result.numSignatures() == 1); - sig = result.signatures()[0]; - QVERIFY(sig.validity() == Signature::Unknown); - // TODO activate when implemented - // QVERIFY(sig.summary() == Signature::TofuConflict); - - stats = sig.key().userID(0).tofuInfo(); - QVERIFY(!stats.isNull()); - QVERIFY(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint())); - QVERIFY(stats.signFirst() == stats.signLast()); - QVERIFY(stats.signCount() == 1); - QVERIFY(stats.policy() == TofuInfo::PolicyAsk); - QVERIFY(stats.validity() == TofuInfo::Conflict); - } - - - void initTestCase() - { - QGpgMETest::initTestCase(); - const QString gpgHome = qgetenv("GNUPGHOME"); - qputenv("GNUPGHOME", mDir.path().toUtf8()); - QVERIFY(mDir.isValid()); - QFile conf(mDir.path() + QStringLiteral("/gpg.conf")); - QVERIFY(conf.open(QIODevice::WriteOnly)); - conf.write("trust-model tofu+pgp"); - conf.close(); - QFile agentConf(mDir.path() + QStringLiteral("/gpg-agent.conf")); - QVERIFY(agentConf.open(QIODevice::WriteOnly)); - agentConf.write("allow-loopback-pinentry"); - agentConf.close(); - QVERIFY(copyKeyrings(gpgHome, mDir.path())); - } -private: - QTemporaryDir mDir; - -}; - -QTEST_MAIN(TofuInfoTest) - -#include "t-tofuinfo.moc" diff --git a/lang/qt/tests/t-trustsignatures.cpp b/lang/qt/tests/t-trustsignatures.cpp deleted file mode 100644 index 6d575dff..00000000 --- a/lang/qt/tests/t-trustsignatures.cpp +++ /dev/null @@ -1,524 +0,0 @@ -/* t-trustsignatures.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2021 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "t-support.h" - -#include <gpgme++/context.h> -#include <gpgme++/engineinfo.h> -#include "protocol.h" -#include "signkeyjob.h" -#include "util.h" - -#include <QRegularExpression> -#include <QSignalSpy> -#include <QTemporaryDir> -#include <QTest> - -using namespace QGpgME; -using namespace GpgME; - -class TestTrustSignatures: public QGpgMETest -{ - Q_OBJECT - -private Q_SLOTS: - void test_tsign_single_uid_key_and_then_tsign_it_again() - { - Error err; - - if (!loopbackSupported()) { - return; - } - - auto ctx = Context::create(OpenPGP); - QVERIFY(ctx); - - // Get the signing key ([email protected]) - auto seckey = ctx->key("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, true); - QVERIFY(!err); - QVERIFY(!seckey.isNull()); - - // Get the target key ([email protected]) - auto target = ctx->key("E8143C489C8D41124DC40D0B47AF4B6961F04784", err, false); - QVERIFY(!err); - QVERIFY(!target.isNull()); - QVERIFY(target.numUserIDs() > 0); - - // Create first trust signature - { - // Create the job - auto job = std::unique_ptr<SignKeyJob>{openpgp()->signKeyJob()}; - QVERIFY(job); - hookUpPassphraseProvider(job.get()); - - // Set up the job - job->setExportable(true); - job->setSigningKey(seckey); - job->setTrustSignature(TrustSignatureTrust::Complete, 1, QStringLiteral("example.org")); - - connect(job.get(), &SignKeyJob::result, - this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { - Q_EMIT asyncDone(); - if (err2) { - if (err2.code() == GPG_ERR_GENERAL) { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" - "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2)))); - } else { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2)))); - } - } - }); - - job->start(target); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the trust signature should have been added. - target.update(); - const auto trustSignature = target.userID(0).signature(target.userID(0).numSignatures() - 1); - QVERIFY(trustSignature.isTrustSignature()); - QCOMPARE(trustSignature.trustDepth(), 1u); - QCOMPARE(trustSignature.trustValue(), TrustSignatureTrust::Complete); - QVERIFY(trustSignature.trustScope()); - const auto trustScope = QString::fromUtf8(trustSignature.trustScope()); - QVERIFY(!trustScope.isEmpty()); - const QRegularExpression regex{trustScope}; - QVERIFY(regex.isValid()); - QVERIFY(regex.match(QStringLiteral("Foo <[email protected]>")).hasMatch()); - } - - // Create second trust signature - { - // Create the job - auto job = std::unique_ptr<SignKeyJob>{openpgp()->signKeyJob()}; - QVERIFY(job); - hookUpPassphraseProvider(job.get()); - - // Set up the job - job->setExportable(true); - job->setSigningKey(seckey); - job->setDupeOk(true); - job->setTrustSignature(TrustSignatureTrust::Partial, 2, QStringLiteral("example.net")); - - connect(job.get(), &SignKeyJob::result, - this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { - Q_EMIT asyncDone(); - if (err2) { - if (err2.code() == GPG_ERR_GENERAL) { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" - "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2)))); - } else { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2)))); - } - } - }); - - err = job->start(target); - QVERIFY(!err); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the trust signature should have been added. - target.update(); - const auto trustSignature = target.userID(0).signature(target.userID(0).numSignatures() - 1); - QVERIFY(trustSignature.isTrustSignature()); - QCOMPARE(trustSignature.trustDepth(), 2u); - QCOMPARE(trustSignature.trustValue(), TrustSignatureTrust::Partial); - QVERIFY(trustSignature.trustScope()); - const auto trustScope = QString::fromUtf8(trustSignature.trustScope()); - QVERIFY(!trustScope.isEmpty()); - const QRegularExpression regex{trustScope}; - QVERIFY(regex.isValid()); - QVERIFY(regex.match(QStringLiteral("Foo <[email protected]>")).hasMatch()); - } - } - - void test_tsign_multi_uid_key_and_then_tsign_it_again() - { - Error err; - - if (!loopbackSupported()) { - return; - } - - auto ctx = Context::create(OpenPGP); - QVERIFY(ctx); - - // Get the signing key ([email protected]) - auto seckey = ctx->key("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, true); - QVERIFY(!err); - QVERIFY(!seckey.isNull()); - - // Get the target key (Bob / Bravo Test) - auto target = ctx->key("D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2", err, false); - QVERIFY(!err); - QVERIFY(!target.isNull()); - QVERIFY(target.numUserIDs() > 0); - - // Create first trust signature - { - // Create the job - auto job = openpgp()->signKeyJob();//std::unique_ptr<SignKeyJob>{openpgp()->signKeyJob()}; - QVERIFY(job); - hookUpPassphraseProvider(job); - - // Set up the job - job->setExportable(true); - job->setSigningKey(seckey); - job->setTrustSignature(TrustSignatureTrust::Complete, 1, QStringLiteral("example.org")); - - connect(job, &SignKeyJob::result, - this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { - Q_EMIT asyncDone(); - if (err2) { - if (err2.code() == GPG_ERR_GENERAL) { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" - "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2)))); - } else { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2)))); - } - } - }); - - job->start(target); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the trust signature should have been added. - target.update(); - const auto trustSignature = target.userID(0).signature(target.userID(0).numSignatures() - 1); - QVERIFY(trustSignature.isTrustSignature()); - QCOMPARE(trustSignature.trustDepth(), 1u); - QCOMPARE(trustSignature.trustValue(), TrustSignatureTrust::Complete); - QVERIFY(trustSignature.trustScope()); - const auto trustScope = QString::fromUtf8(trustSignature.trustScope()); - QVERIFY(!trustScope.isEmpty()); - const QRegularExpression regex{trustScope}; - QVERIFY(regex.isValid()); - QVERIFY(regex.match(QStringLiteral("Foo <[email protected]>")).hasMatch()); - } - - // Create second trust signature - { - // Create the job - auto job = openpgp()->signKeyJob();//std::unique_ptr<SignKeyJob>{openpgp()->signKeyJob()}; - QVERIFY(job); - hookUpPassphraseProvider(job); - - // Set up the job - job->setExportable(true); - job->setSigningKey(seckey); - job->setDupeOk(true); - job->setTrustSignature(TrustSignatureTrust::Partial, 2, QStringLiteral("example.net")); - - connect(job, &SignKeyJob::result, - this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { - Q_EMIT asyncDone(); - if (err2) { - if (err2.code() == GPG_ERR_GENERAL) { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" - "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2)))); - } else { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2)))); - } - } - }); - - err = job->start(target); - QVERIFY(!err); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the trust signature should have been added. - target.update(); - const auto trustSignature = target.userID(0).signature(target.userID(0).numSignatures() - 1); - QVERIFY(trustSignature.isTrustSignature()); - QCOMPARE(trustSignature.trustDepth(), 2u); - QCOMPARE(trustSignature.trustValue(), TrustSignatureTrust::Partial); - QVERIFY(trustSignature.trustScope()); - const auto trustScope = QString::fromUtf8(trustSignature.trustScope()); - QVERIFY(!trustScope.isEmpty()); - const QRegularExpression regex{trustScope}; - QVERIFY(regex.isValid()); - QVERIFY(regex.match(QStringLiteral("Foo <[email protected]>")).hasMatch()); - } - } - - void test_tsign_first_uid_and_then_tsign_both_uids() - { - Error err; - - if (!loopbackSupported()) { - return; - } - - auto ctx = Context::create(OpenPGP); - QVERIFY(ctx); - - // Get the signing key ([email protected]) - auto seckey = ctx->key("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, true); - QVERIFY(!err); - QVERIFY(!seckey.isNull()); - - // Get the target key (Mallory / Mike Test) - auto target = ctx->key("2686AA191A278013992C72EBBE794852BE5CF886", err, false); - QVERIFY(!err); - QVERIFY(!target.isNull()); - QVERIFY(target.numUserIDs() > 0); - - // Create first trust signature - { - // Create the job - auto job = openpgp()->signKeyJob();//std::unique_ptr<SignKeyJob>{openpgp()->signKeyJob()}; - QVERIFY(job); - hookUpPassphraseProvider(job); - - // Set up the job - job->setExportable(true); - job->setSigningKey(seckey); - job->setUserIDsToSign({0}); - job->setTrustSignature(TrustSignatureTrust::Complete, 1, QStringLiteral("example.org")); - - connect(job, &SignKeyJob::result, - this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { - Q_EMIT asyncDone(); - if (err2) { - if (err2.code() == GPG_ERR_GENERAL) { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" - "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2)))); - } else { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2)))); - } - } - }); - - job->start(target); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the trust signature should have been added. - target.update(); - const auto trustSignature = target.userID(0).signature(target.userID(0).numSignatures() - 1); - QVERIFY(trustSignature.isTrustSignature()); - QCOMPARE(trustSignature.trustDepth(), 1u); - QCOMPARE(trustSignature.trustValue(), TrustSignatureTrust::Complete); - QVERIFY(trustSignature.trustScope()); - const auto trustScope = QString::fromUtf8(trustSignature.trustScope()); - QVERIFY(!trustScope.isEmpty()); - const QRegularExpression regex{trustScope}; - QVERIFY(regex.isValid()); - QVERIFY(regex.match(QStringLiteral("Foo <[email protected]>")).hasMatch()); - } - - // Create second trust signature - { - // Create the job - auto job = openpgp()->signKeyJob();//std::unique_ptr<SignKeyJob>{openpgp()->signKeyJob()}; - QVERIFY(job); - hookUpPassphraseProvider(job); - - // Set up the job - job->setExportable(true); - job->setSigningKey(seckey); - job->setDupeOk(true); - job->setTrustSignature(TrustSignatureTrust::Partial, 2, QStringLiteral("example.net")); - - connect(job, &SignKeyJob::result, - this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { - Q_EMIT asyncDone(); - if (err2) { - if (err2.code() == GPG_ERR_GENERAL) { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" - "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2)))); - } else { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2)))); - } - } - }); - - err = job->start(target); - QVERIFY(!err); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the trust signature should have been added. - target.update(); - const auto trustSignature = target.userID(0).signature(target.userID(0).numSignatures() - 1); - QVERIFY(trustSignature.isTrustSignature()); - QCOMPARE(trustSignature.trustDepth(), 2u); - QCOMPARE(trustSignature.trustValue(), TrustSignatureTrust::Partial); - QVERIFY(trustSignature.trustScope()); - const auto trustScope = QString::fromUtf8(trustSignature.trustScope()); - QVERIFY(!trustScope.isEmpty()); - const QRegularExpression regex{trustScope}; - QVERIFY(regex.isValid()); - QVERIFY(regex.match(QStringLiteral("Foo <[email protected]>")).hasMatch()); - } - } - - void test_tsign_all_uids_and_then_tsign_first_uid() - { - Error err; - - if (!loopbackSupported()) { - return; - } - - auto ctx = Context::create(OpenPGP); - QVERIFY(ctx); - - // Get the signing key ([email protected]) - auto seckey = ctx->key("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, true); - QVERIFY(!err); - QVERIFY(!seckey.isNull()); - - // Get the target key (Echelon / Echo Test / Eve) - auto target = ctx->key("3531152DE293E26A07F504BC318C1FAEFAEF6D1B", err, false); - QVERIFY(!err); - QVERIFY(!target.isNull()); - QVERIFY(target.numUserIDs() > 0); - - // Create first trust signature - { - // Create the job - auto job = openpgp()->signKeyJob();//std::unique_ptr<SignKeyJob>{openpgp()->signKeyJob()}; - QVERIFY(job); - hookUpPassphraseProvider(job); - - // Set up the job - job->setExportable(true); - job->setSigningKey(seckey); - job->setTrustSignature(TrustSignatureTrust::Complete, 1, QStringLiteral("example.org")); - - connect(job, &SignKeyJob::result, - this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { - Q_EMIT asyncDone(); - if (err2) { - if (err2.code() == GPG_ERR_GENERAL) { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" - "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2)))); - } else { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2)))); - } - } - }); - - job->start(target); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the trust signature should have been added. - target.update(); - const auto trustSignature = target.userID(0).signature(target.userID(0).numSignatures() - 1); - QVERIFY(trustSignature.isTrustSignature()); - QCOMPARE(trustSignature.trustDepth(), 1u); - QCOMPARE(trustSignature.trustValue(), TrustSignatureTrust::Complete); - QVERIFY(trustSignature.trustScope()); - const auto trustScope = QString::fromUtf8(trustSignature.trustScope()); - QVERIFY(!trustScope.isEmpty()); - const QRegularExpression regex{trustScope}; - QVERIFY(regex.isValid()); - QVERIFY(regex.match(QStringLiteral("Foo <[email protected]>")).hasMatch()); - } - - // Create second trust signature - { - // Create the job - auto job = openpgp()->signKeyJob();//std::unique_ptr<SignKeyJob>{openpgp()->signKeyJob()}; - QVERIFY(job); - hookUpPassphraseProvider(job); - - // Set up the job - job->setExportable(true); - job->setSigningKey(seckey); - job->setUserIDsToSign({0}); - job->setDupeOk(true); - job->setTrustSignature(TrustSignatureTrust::Partial, 2, QStringLiteral("example.net")); - - connect(job, &SignKeyJob::result, - this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { - Q_EMIT asyncDone(); - if (err2) { - if (err2.code() == GPG_ERR_GENERAL) { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" - "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2)))); - } else { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2)))); - } - } - }); - - err = job->start(target); - QVERIFY(!err); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the trust signature should have been added. - target.update(); - const auto trustSignature = target.userID(0).signature(target.userID(0).numSignatures() - 1); - QVERIFY(trustSignature.isTrustSignature()); - QCOMPARE(trustSignature.trustDepth(), 2u); - QCOMPARE(trustSignature.trustValue(), TrustSignatureTrust::Partial); - QVERIFY(trustSignature.trustScope()); - const auto trustScope = QString::fromUtf8(trustSignature.trustScope()); - QVERIFY(!trustScope.isEmpty()); - const QRegularExpression regex{trustScope}; - QVERIFY(regex.isValid()); - QVERIFY(regex.match(QStringLiteral("Foo <[email protected]>")).hasMatch()); - } - } - - void initTestCase() - { - QGpgMETest::initTestCase(); - const QString gpgHome = qgetenv("GNUPGHOME"); - QVERIFY(copyKeyrings(gpgHome, mDir.path())); - qputenv("GNUPGHOME", mDir.path().toUtf8()); - QFile conf(mDir.path() + QStringLiteral("/gpg.conf")); - QVERIFY(conf.open(QIODevice::WriteOnly)); - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() >= "2.2.18") { - conf.write("allow-weak-key-signatures"); - } - conf.close(); - } - -private: - QTemporaryDir mDir; -}; - -QTEST_MAIN(TestTrustSignatures) - -#include "t-trustsignatures.moc" diff --git a/lang/qt/tests/t-various.cpp b/lang/qt/tests/t-various.cpp deleted file mode 100644 index 282fffc2..00000000 --- a/lang/qt/tests/t-various.cpp +++ /dev/null @@ -1,418 +0,0 @@ -/* t-various.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2017 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <QDebug> -#include <QTest> -#include <QSignalSpy> -#include <QTemporaryDir> -#include "keylistjob.h" -#include "protocol.h" -#include "util.h" -#include <gpgme++/keylistresult.h> -#include <gpgme++/context.h> -#include <gpgme++/engineinfo.h> -#include "dn.h" -#include <gpgme++/data.h> -#include "dataprovider.h" -#include "signkeyjob.h" - -#include "t-support.h" - -using namespace QGpgME; -using namespace GpgME; - -static const char aKey[] = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" -"\n" -"mDMEWG+w/hYJKwYBBAHaRw8BAQdAiq1oStvDYg8ZfFs5DgisYJo8dJxD+C/AA21O\n" -"K/aif0O0GXRvZnVfY29uZmxpY3RAZXhhbXBsZS5jb22IlgQTFggAPhYhBHoJBLaV\n" -"DamYAgoa1L5BwMOl/x88BQJYb7D+AhsDBQkDwmcABQsJCAcCBhUICQoLAgQWAgMB\n" -"Ah4BAheAAAoJEL5BwMOl/x88GvwA/0SxkbLyAcshGm2PRrPsFQsSVAfwaSYFVmS2\n" -"cMVIw1PfAQDclRH1Z4MpufK07ju4qI33o4s0UFpVRBuSxt7A4P2ZD7g4BFhvsP4S\n" -"CisGAQQBl1UBBQEBB0AmVrgaDNJ7K2BSalsRo2EkRJjHGqnp5bBB0tapnF81CQMB\n" -"CAeIeAQYFggAIBYhBHoJBLaVDamYAgoa1L5BwMOl/x88BQJYb7D+AhsMAAoJEL5B\n" -"wMOl/x88OR0BAMq4/vmJUORRTmzjHcv/DDrQB030DSq666rlckGIKTShAPoDXM9N\n" -"0gZK+YzvrinSKZXHmn0aSwmC1/hyPybJPEljBw==\n" -"=p2Oj\n" -"-----END PGP PUBLIC KEY BLOCK-----\n"; - -class TestVarious: public QGpgMETest -{ - Q_OBJECT - -private Q_SLOTS: - void testDN() - { - DN dn(QStringLiteral("CN=Before\\0DAfter,OU=Test,DC=North America,DC=Fabrikam,DC=COM")); - QVERIFY(dn.dn() == QStringLiteral("CN=Before\rAfter,OU=Test,DC=North America,DC=Fabrikam,DC=COM")); - QStringList attrOrder; - attrOrder << QStringLiteral("DC") << QStringLiteral("OU") << QStringLiteral("CN"); - dn.setAttributeOrder(attrOrder); - QVERIFY(dn.prettyDN() == QStringLiteral("DC=North America,DC=Fabrikam,DC=COM,OU=Test,CN=Before\rAfter")); - } - - void testKeyFromFile() - { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.14") { - return; - } - QGpgME::QByteArrayDataProvider dp(aKey); - Data data(&dp); - const auto keys = data.toKeys(); - QVERIFY(keys.size() == 1); - const auto key = keys[0]; - QVERIFY(!key.isNull()); - QVERIFY(key.primaryFingerprint() == QStringLiteral("7A0904B6950DA998020A1AD4BE41C0C3A5FF1F3C")); - } - - void testDataRewind() - { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.14") { - return; - } - QGpgME::QByteArrayDataProvider dp(aKey); - Data data(&dp); - char buf[20]; - data.read(buf, 20); - - auto keys = data.toKeys(); - QVERIFY(keys.size() == 0); - - data.rewind(); - - keys = data.toKeys(); - QVERIFY(keys.size() == 1); - } - - void testQuickUid() - { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.13") { - return; - } - KeyListJob *job = openpgp()->keyListJob(false, true, true); - std::vector<GpgME::Key> keys; - GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("[email protected]"), - false, keys); - delete job; - QVERIFY (!result.error()); - QVERIFY (keys.size() == 1); - Key key = keys.front(); - - QVERIFY (key.numUserIDs() == 3); - const char uid[] = "Foo Bar (with comment) <[email protected]>"; - - auto ctx = Context::createForProtocol(key.protocol()); - QVERIFY (ctx); - hookUpPassphraseProvider(ctx); - - QVERIFY(!ctx->addUid(key, uid)); - delete ctx; - key.update(); - - QVERIFY (key.numUserIDs() == 4); - bool id_found = false;; - for (const auto &u: key.userIDs()) { - if (!strcmp (u.id(), uid)) { - QVERIFY (!u.isRevoked()); - id_found = true; - break; - } - } - QVERIFY (id_found); - - ctx = Context::createForProtocol(key.protocol()); - QVERIFY (!ctx->revUid(key, uid)); - delete ctx; - key.update(); - - bool id_revoked = false;; - for (const auto &u: key.userIDs()) { - if (!strcmp (u.id(), uid)) { - id_revoked = true; - break; - } - } - QVERIFY(id_revoked); - } - - void testSetExpire() - { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.22") { - return; - } - KeyListJob *job = openpgp()->keyListJob(false, true, true); - std::vector<GpgME::Key> keys; - GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("[email protected]"), - false, keys); - delete job; - QVERIFY (!result.error()); - QVERIFY (keys.size() == 1); - Key key = keys.front(); - - QVERIFY (key.subkey(0).expirationTime() == time_t(0)); - QVERIFY (key.subkey(1).expirationTime() == time_t(0)); - - auto ctx = Context::createForProtocol(key.protocol()); - QVERIFY (ctx); - hookUpPassphraseProvider(ctx); - - // change expiration of the main key - QVERIFY(!ctx->setExpire(key, 1000)); - delete ctx; - key.update(); - - QVERIFY (key.subkey(0).expirationTime() != time_t(0)); - QVERIFY (key.subkey(1).expirationTime() == time_t(0)); - time_t keyExpiration = key.subkey(0).expirationTime(); - - // change expiration of all subkeys - ctx = Context::createForProtocol(key.protocol()); - QVERIFY(!ctx->setExpire(key, 2000, std::vector<Subkey>(), Context::SetExpireAllSubkeys)); - delete ctx; - key.update(); - - QVERIFY (key.subkey(0).expirationTime() == keyExpiration); - QVERIFY (key.subkey(1).expirationTime() != time_t(0)); - time_t subkeyExpiration = key.subkey(1).expirationTime(); - - // change expiration of specific subkey(s) - ctx = Context::createForProtocol(key.protocol()); - std::vector<Subkey> specificSubkeys; - specificSubkeys.push_back(key.subkey(1)); - QVERIFY(!ctx->setExpire(key, 3000, specificSubkeys)); - delete ctx; - key.update(); - - QVERIFY (key.subkey(0).expirationTime() == keyExpiration); - QVERIFY (key.subkey(1).expirationTime() != subkeyExpiration); - - // test error handling: calling setExpire() with the primary key as - // subkey should fail with "subkey <primary key fpr> not found" - ctx = Context::createForProtocol(key.protocol()); - std::vector<Subkey> primaryKey; - primaryKey.push_back(key.subkey(0)); - const auto err = ctx->setExpire(key, 3000, primaryKey); - QCOMPARE(err.code(), static_cast<int>(GPG_ERR_NOT_FOUND)); - delete ctx; - } - - void testSignKeyWithoutExpiration() - { - Error err; - - if (!loopbackSupported()) { - return; - } - - auto ctx = Context::create(OpenPGP); - QVERIFY(ctx); - - // Get the signing key ([email protected]) - auto seckey = ctx->key("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, true); - QVERIFY(!err); - QVERIFY(!seckey.isNull()); - - // Get the target key (Bob / Bravo Test) - auto target = ctx->key("D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2", err, false); - QVERIFY(!err); - QVERIFY(!target.isNull()); - QVERIFY(target.numUserIDs() > 0); - - // Create the job - auto job = std::unique_ptr<SignKeyJob>{openpgp()->signKeyJob()}; - QVERIFY(job); - hookUpPassphraseProvider(job.get()); - - // Set up the job - job->setExportable(true); - job->setSigningKey(seckey); - job->setDupeOk(true); - - connect(job.get(), &SignKeyJob::result, - this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { - Q_EMIT asyncDone(); - if (err2) { - if (err2.code() == GPG_ERR_GENERAL) { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" - "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2)))); - } else { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2)))); - } - } - }); - - job->start(target); - QSignalSpy spy{this, &TestVarious::asyncDone}; - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the signature should have been added. - target.update(); - const auto keySignature = target.userID(0).signature(target.userID(0).numSignatures() - 1); - QVERIFY(keySignature.neverExpires()); - } - - void testSignKeyWithExpiration() - { - Error err; - - if (!loopbackSupported()) { - return; - } - - auto ctx = Context::create(OpenPGP); - QVERIFY(ctx); - - // Get the signing key ([email protected]) - auto seckey = ctx->key("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, true); - QVERIFY(!err); - QVERIFY(!seckey.isNull()); - - // Get the target key (Bob / Bravo Test) - auto target = ctx->key("D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2", err, false); - QVERIFY(!err); - QVERIFY(!target.isNull()); - QVERIFY(target.numUserIDs() > 0); - - // Create the job - auto job = std::unique_ptr<SignKeyJob>{openpgp()->signKeyJob()}; - QVERIFY(job); - hookUpPassphraseProvider(job.get()); - - // Set up the job - job->setExportable(true); - job->setSigningKey(seckey); - job->setDupeOk(true); - job->setExpirationDate(QDate{2222, 2, 22}); - - connect(job.get(), &SignKeyJob::result, - this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { - Q_EMIT asyncDone(); - if (err2) { - if (err2.code() == GPG_ERR_GENERAL) { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" - "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2)))); - } else { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2)))); - } - } - }); - - job->start(target); - QSignalSpy spy{this, &TestVarious::asyncDone}; - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - // At this point the signature should have been added. - target.update(); - const auto keySignature = target.userID(0).signature(target.userID(0).numSignatures() - 1); - QVERIFY(!keySignature.neverExpires()); - const auto expirationDate = QDateTime::fromSecsSinceEpoch(uint_least32_t(keySignature.expirationTime())).date(); - // expiration date is capped at 2106-02-05; we also allow 2106-02-04 as expiration date because for locations that use DST - // the expiration date may be 2106-02-04-23:xx:xx (in local non-DST time) if the current time is 00:xx::xx (in local DST time) - const auto expectedExpirationRange = std::make_pair(QDate{2106, 2, 4}, QDate{2106, 2, 5}); - QVERIFY2(expirationDate >= expectedExpirationRange.first, - ("\n Actual : " + expirationDate.toString(Qt::ISODate).toLatin1() + - "\n Expected: " + expectedExpirationRange.first.toString(Qt::ISODate).toLatin1()).constData()); - QVERIFY2(expirationDate <= expectedExpirationRange.second, - ("\n Actual : " + expirationDate.toString(Qt::ISODate).toLatin1() + - "\n Expected: " + expectedExpirationRange.second.toString(Qt::ISODate).toLatin1()).constData()); - } - - void testVersion() - { - QVERIFY(EngineInfo::Version("2.1.0") < EngineInfo::Version("2.1.1")); - QVERIFY(EngineInfo::Version("2.1.10") < EngineInfo::Version("2.1.11")); - QVERIFY(EngineInfo::Version("2.2.0") > EngineInfo::Version("2.1.19")); - QVERIFY(EngineInfo::Version("1.0.0") < EngineInfo::Version("2.0.0")); - QVERIFY(EngineInfo::Version("0.1.0") < EngineInfo::Version("1.0.0")); - QVERIFY(!(EngineInfo::Version("2.0.0") < EngineInfo::Version("2.0.0"))); - QVERIFY(!(EngineInfo::Version("2.0.0") > EngineInfo::Version("2.0.0"))); - QVERIFY(EngineInfo::Version("3.0.0") > EngineInfo::Version("2.3.20")); - QVERIFY(EngineInfo::Version("3.0.1") > EngineInfo::Version("3.0.0")); - QVERIFY(EngineInfo::Version("3.1.0") > EngineInfo::Version("3.0.20")); - - QVERIFY(EngineInfo::Version("1.1.1") <= "2.0.0"); - QVERIFY(EngineInfo::Version("1.1.1") <= "1.2.0"); - QVERIFY(EngineInfo::Version("1.1.1") <= "1.1.2"); - QVERIFY(EngineInfo::Version("1.1.1") <= "1.1.1"); - QVERIFY(!(EngineInfo::Version("1.1.1") <= "1.1.0")); - QVERIFY(!(EngineInfo::Version("1.1.1") <= "1.0.9")); - QVERIFY(!(EngineInfo::Version("1.1.1") <= "0.9.9")); - - QVERIFY(!(EngineInfo::Version("1.1.1") == "2.0.0")); - QVERIFY(!(EngineInfo::Version("1.1.1") == "1.2.0")); - QVERIFY(!(EngineInfo::Version("1.1.1") == "1.1.2")); - QVERIFY(EngineInfo::Version("1.1.1") == "1.1.1"); - QVERIFY(!(EngineInfo::Version("1.1.1") == "1.1.0")); - QVERIFY(!(EngineInfo::Version("1.1.1") == "1.0.9")); - QVERIFY(!(EngineInfo::Version("1.1.1") == "0.9.9")); - - QVERIFY(EngineInfo::Version("1.1.1") != "2.0.0"); - QVERIFY(EngineInfo::Version("1.1.1") != "1.2.0"); - QVERIFY(EngineInfo::Version("1.1.1") != "1.1.2"); - QVERIFY(!(EngineInfo::Version("1.1.1") != "1.1.1")); - QVERIFY(EngineInfo::Version("1.1.1") != "1.1.0"); - QVERIFY(EngineInfo::Version("1.1.1") != "1.0.9"); - QVERIFY(EngineInfo::Version("1.1.1") != "0.9.9"); - - QVERIFY(!(EngineInfo::Version("1.1.1") >= "2.0.0")); - QVERIFY(!(EngineInfo::Version("1.1.1") >= "1.2.0")); - QVERIFY(!(EngineInfo::Version("1.1.1") >= "1.1.2")); - QVERIFY(EngineInfo::Version("1.1.1") >= "1.1.1"); - QVERIFY(EngineInfo::Version("1.1.1") >= "1.1.0"); - QVERIFY(EngineInfo::Version("1.1.1") >= "1.0.9"); - QVERIFY(EngineInfo::Version("1.1.1") >= "0.9.9"); - } - - void initTestCase() - { - QGpgMETest::initTestCase(); - const QString gpgHome = qgetenv("GNUPGHOME"); - QVERIFY(copyKeyrings(gpgHome, mDir.path())); - qputenv("GNUPGHOME", mDir.path().toUtf8()); - QFile conf(mDir.path() + QStringLiteral("/gpg.conf")); - QVERIFY(conf.open(QIODevice::WriteOnly)); - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() >= "2.2.18") { - conf.write("allow-weak-key-signatures"); - } - conf.close(); - } - -private: - QTemporaryDir mDir; -}; - -QTEST_MAIN(TestVarious) - -#include "t-various.moc" diff --git a/lang/qt/tests/t-verify.cpp b/lang/qt/tests/t-verify.cpp deleted file mode 100644 index f1bba08f..00000000 --- a/lang/qt/tests/t-verify.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* t-verifiy.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <QDebug> -#include <QTest> - - -#include "protocol.h" - -#include "verifyopaquejob.h" -#include <gpgme++/verificationresult.h> -#include <gpgme++/key.h> - -#include "t-support.h" - -using namespace QGpgME; -using namespace GpgME; - -static const char testMsg1[] = -"-----BEGIN PGP MESSAGE-----\n" -"\n" -"owGbwMvMwCSoW1RzPCOz3IRxjXQSR0lqcYleSUWJTZOvjVdpcYmCu1+oQmaJIleH\n" -"GwuDIBMDGysTSIqBi1MApi+nlGGuwDeHao53HBr+FoVGP3xX+kvuu9fCMJvl6IOf\n" -"y1kvP4y+8D5a11ang0udywsA\n" -"=Crq6\n" -"-----END PGP MESSAGE-----\n"; - - -class VerifyTest: public QGpgMETest -{ - Q_OBJECT - -private Q_SLOTS: - - /* Check that a signature always has a key. */ - void testSignatureKey() - { - const QByteArray signedData(testMsg1); - auto verifyJob = openpgp()->verifyOpaqueJob(true); - QByteArray verified; - - auto result = verifyJob->exec(signedData, verified); - QVERIFY(!result.error()); - delete verifyJob; - - QVERIFY(result.numSignatures() == 1); - auto sig = result.signatures()[0]; - - const auto key = sig.key(true, false); - QVERIFY(!key.isNull()); - - bool found = false; - for (const auto &subkey: key.subkeys()) { - if (!strcmp (subkey.fingerprint(), sig.fingerprint())) { - found = true; - } - } - QVERIFY(found); - } -}; - -QTEST_MAIN(VerifyTest) -#include "t-verify.moc" diff --git a/lang/qt/tests/t-wkdlookup.cpp b/lang/qt/tests/t-wkdlookup.cpp deleted file mode 100644 index 03b7823a..00000000 --- a/lang/qt/tests/t-wkdlookup.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* t-wkdlookup.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2021 g10 Code GmbH - Software engineering by Ingo Klöcker <[email protected]> - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "t-support.h" - -#include <gpgme++/data.h> -#include <gpgme++/engineinfo.h> -#include "protocol.h" -#include "wkdlookupjob.h" -#include "wkdlookupresult.h" - -#include <QDebug> -#include <QSignalSpy> -#include <QTest> - -#include <algorithm> - -using namespace QGpgME; -using namespace GpgME; - -static const char *requiredVersion = "2.1.12"; - -namespace -{ -bool keyHasUserIDWithMatchingEmailAddress(const Key &key, const QString &expectedEmailAddress) -{ - const auto email = expectedEmailAddress.toLower(); - const auto userIds = key.userIDs(); - return std::any_of( - std::begin(userIds), std::end(userIds), - [email](const UserID &uid) { - return email == QString::fromUtf8(uid.email()).toLower(); - }); -} -} - -class WKDLookupTest : public QGpgMETest -{ - Q_OBJECT - -private Q_SLOTS: - - void testWKDLookupAsync() - { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < requiredVersion) { - QSKIP("dirmngr does not yet support WKD lookup"); - } - if (!doOnlineTests()) { - QSKIP("Set DO_ONLINE_TESTS environment variable to run this test."); - } - const QString email = QLatin1String{"[email protected]"}; - - WKDLookupResult result; - auto *job = openpgp()->wkdLookupJob(); - connect(job, &WKDLookupJob::result, job, [this, &result](const WKDLookupResult &result_, const QString &, const Error &) - { - result = result_; - Q_EMIT asyncDone(); - }); - job->start(email); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - QVERIFY(result.error().code() == GPG_ERR_NO_ERROR); - QCOMPARE(result.pattern(), "[email protected]"); - QCOMPARE(result.source(), "https://openpgpkey.gnupg.org"); - const auto keys = result.keyData().toKeys(GpgME::OpenPGP); - QVERIFY(keys.size() == 1); - QVERIFY(keyHasUserIDWithMatchingEmailAddress(keys.front(), email)); - } - - void testWKDLookupSync() - { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < requiredVersion) { - QSKIP("dirmngr does not yet support WKD lookup"); - } - if (!doOnlineTests()) { - QSKIP("Set DO_ONLINE_TESTS environment variable to run this test."); - } - const QString email = QLatin1String{"[email protected]"}; - - auto *job = openpgp()->wkdLookupJob(); - const auto result = job->exec(email); - - QVERIFY(result.error().code() == GPG_ERR_NO_ERROR); - QCOMPARE(result.pattern(), "[email protected]"); - QCOMPARE(result.source(), "https://openpgpkey.gnupg.org"); - const auto keys = result.keyData().toKeys(GpgME::OpenPGP); - QVERIFY(keys.size() == 1); - QVERIFY(keyHasUserIDWithMatchingEmailAddress(keys.front(), email)); - } - - void testLookupWithNoResultAsync() - { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < requiredVersion) { - QSKIP("dirmngr does not yet support WKD lookup"); - } - if (!doOnlineTests()) { - QSKIP("Set DO_ONLINE_TESTS environment variable to run this test."); - } - const QString email = QLatin1String{"[email protected]"}; - - WKDLookupResult result; - auto *job = openpgp()->wkdLookupJob(); - connect(job, &WKDLookupJob::result, job, [this, &result](const WKDLookupResult &result_, const QString &, const Error &) - { - result = result_; - Q_EMIT asyncDone(); - }); - job->start(email); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - QVERIFY(result.error().code() == GPG_ERR_NO_ERROR); - QCOMPARE(result.pattern(), "[email protected]"); - QCOMPARE(result.source(), ""); - QVERIFY(result.keyData().isNull()); - } -}; - -QTEST_MAIN(WKDLookupTest) - -#include "t-wkdlookup.moc" diff --git a/lang/qt/tests/t-wkspublish.cpp b/lang/qt/tests/t-wkspublish.cpp deleted file mode 100644 index cb75d149..00000000 --- a/lang/qt/tests/t-wkspublish.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/* t-wkspublish.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik - Software engineering by Intevation GmbH - - QGpgME 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 2 of the - License, or (at your option) any later version. - - QGpgME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <QDebug> -#include <QTest> -#include <QSignalSpy> -#include <QTemporaryDir> -#include "wkspublishjob.h" -#include "keygenerationjob.h" -#include <gpgme++/keygenerationresult.h> -#include "importjob.h" -#include <gpgme++/importresult.h> -#include "protocol.h" -#include <gpgme++/engineinfo.h> - -#include "t-support.h" - -using namespace QGpgME; -using namespace GpgME; - -//#define DO_ONLINE_TESTS - -#define TEST_ADDRESS "[email protected]" - -static const char *testSecKey = -"-----BEGIN PGP PRIVATE KEY BLOCK-----\n" -"\n" -"lHgEV77hVhMJKyQDAwIIAQEHAgMEN3qKqBr9EecnfUnpw8RS8DHAjJqhwm2HAoEE\n" -"3yfQQ9w8uB/bKm5dqW4HML3JWRH8YoJaKSVrJY2D1FZUY+vHlgABAKDwEAB0HND8\n" -"5kbxiJmqKIuuNqCJ2jHgs9G0xk4GdKvZEdq0JlRlc3QgVXNlciAyIDx0ZXN0dXNl\n" -"cjJAdGVzdC5nbnVwZy5vcmc+iHkEExMIACEFAle+4VYCGwMFCwkIBwIGFQgJCgsC\n" -"BBYCAwECHgECF4AACgkQRVRoUEJO+6zgFQD7BF3pnS3w3A7J9y+Y3kyGfmscXFWJ\n" -"Kme1PAsAlVSm1y4A+weReMvWFYHJH257v94yhStmV8egGoybsNDttNAW53cbnHwE\n" -"V77hVhIJKyQDAwIIAQEHAgMEX+6cF0HEn4g3ztFvwHyr7uwXMVYUGL3lE3mjhnV3\n" -"SbY6Dmy3OeFVnEVkawHqSv+HobpQTeEqNoQHAoIiXFCRlgMBCAcAAP9FykiyDspm\n" -"T33XWRPD+LAOmaIU7CIhfv9+lVkeExlU1w+qiGEEGBMIAAkFAle+4VYCGwwACgkQ\n" -"RVRoUEJO+6xjhgD/ZJ/MwYZJPk/xPYhTP8+wF+tErVNA8w3pP9D69dgUPdcA/izZ\n" -"Pji6YetVhgsyaHc4PrKynsk5G6nM3KkAOehUQsX8\n" -"=S/Wa\n" -"-----END PGP PRIVATE KEY BLOCK-----\n"; - -static const char *testResponse = -"From [email protected] Thu Aug 25 12:15:54 2016\n" -"Return-Path: <[email protected]>\n" -"From: [email protected]\n" -"To: [email protected]\n" -"Subject: Confirm your key publication\n" -"X-Wks-Loop: webkey.g10code.com\n" -"MIME-Version: 1.0\n" -"Content-Type: multipart/encrypted; protocol=\"application/pgp-encrypted\";\n" -" boundary=\"=-=01-wbu5fr9nu6fix5tcojjo=-=\"\n" -"Date: Thu, 25 Aug 2016 12:15:54 +0000\n" -"Message-Id: <[email protected]>\n" -"Sender: <[email protected]>\n" -"X-Kolab-Scheduling-Message: FALSE\n" -"\n" -" \n" -"\n" -"--=-=01-wbu5fr9nu6fix5tcojjo=-=\n" -"Content-Type: application/pgp-encrypted\n" -"\n" -"Version: 1\n" -"\n" -"--=-=01-wbu5fr9nu6fix5tcojjo=-=\n" -"Content-Type: application/octet-stream\n" -"\n" -"-----BEGIN PGP MESSAGE-----\n" -"Version: GnuPG v2\n" -"\n" -"hH4D8pSp7hUsFUASAgMEg0w39E6d0TkFYxLbT6n3YcoKTT+Ur/c7Sn1ECyL7Rnuk\n" -"cmPO0adt3JxueK7Oz5COlk32SECFODdF3cQuDhkGxzC6Sfc4SfisdILmNhaT/MeW\n" -"8a+yE4skSK70absif4kw5XkvxXNxHeIHfAteP50jPJLSwEsBTEceb9cRMoP7s8w0\n" -"lYyi+RWQ7UKlKKywtcRCL4ow2H7spjx+a+3FzNOAoy7K0/thhLVRk8z+iuPi0/4n\n" -"Z2Ql60USLLUlfV2ZIpXdCd+5GjTJsnGhDos1pas5TZcOOAxO12Cg5TcqHISOaqa8\n" -"6BqxcKCU3NypIynOKHj375KArSs0WsEH8HWHyBBHB+NYtNpnTAuHNKxM+JtNxf+U\n" -"NfD2zptS6kyiHLw+4zjL5pEV7RHS2PBwWBDS6vhnyybNwckleya96U04iYiGRYGE\n" -"lUUR6Fl8H6x04dItFH1/jJA6Ppcu4FoYou04HADWCqJXPTgztjiW1/9QoCeXl5lm\n" -"CcOCcuw7lXp+qTejuns=\n" -"=SsWX\n" -"-----END PGP MESSAGE-----\n" -"\n" -"--=-=01-wbu5fr9nu6fix5tcojjo=-=--\n"; - - -class WKSPublishTest : public QGpgMETest -{ - Q_OBJECT - -private Q_SLOTS: - void testUnsupported() - { - // First check if it is supported - auto job = openpgp()->wksPublishJob(); - connect(job, &WKSPublishJob::result, this, - [this] (Error err, QByteArray, QByteArray, QString, Error) { - QVERIFY(err); - Q_EMIT asyncDone(); - }); - job->startCheck ("testuser1@localhost"); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - } -#ifdef DO_ONLINE_TESTS -private Q_SLOTS: -#else -private: -#endif - void testWSKPublishSupport() - { - // First check if it is supported - auto job = openpgp()->wksPublishJob(); - connect(job, &WKSPublishJob::result, this, - [this] (Error err, QByteArray, QByteArray, QString, Error) { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.0.16") { - std::cout << err; - QVERIFY(err); - } else { - QVERIFY(!err); - } - Q_EMIT asyncDone(); - }); - job->startCheck ("[email protected]"); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - } - - void testWKSPublishErrors() { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.0.16") { - /* Not supported */ - return; - } - auto job = openpgp()->wksPublishJob(); - connect(job, &WKSPublishJob::result, this, - [this] (Error err, QByteArray, QByteArray, QString, Error) { - QVERIFY(err); - Q_EMIT asyncDone(); - }); - job->startCreate("AB874F24E98EBB8487EE7B170F8E3D97FE7011B7", - QStringLiteral("[email protected]")); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - } - - void testWKSPublishCreate() { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.0.16") { - /* Not supported */ - return; - } - /* First generate a test key */ - const QString args = QStringLiteral("<GnupgKeyParms format=\"internal\">\n" - "%no-protection\n" - "%transient-key\n" - "key-type: ECDSA\n" - "key-curve: brainpoolP256r1\n" - "key-usage: sign\n" - "subkey-type: ECDH\n" - "subkey-curve: brainpoolP256r1\n" - "subkey-usage: encrypt\n" - "name-email: %1\n" - "name-real: Test User\n" - "</GnupgKeyParms>").arg(TEST_ADDRESS); - - auto keygenjob = openpgp()->keyGenerationJob(); - QByteArray fpr; - connect(keygenjob, &KeyGenerationJob::result, this, - [this, &fpr](KeyGenerationResult result, QByteArray, QString, Error) - { - QVERIFY(!result.error()); - fpr = QByteArray(result.fingerprint()); - QVERIFY(!fpr.isEmpty()); - Q_EMIT asyncDone(); - }); - keygenjob->start(args); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - /* Then try to create a request. */ - auto job = openpgp()->wksPublishJob(); - connect(job, &WKSPublishJob::result, this, - [this] (Error err, QByteArray out, QByteArray, QString, Error) { - QVERIFY(!err); - Q_EMIT asyncDone(); - const QString outstr = QString(out); - QVERIFY(outstr.contains( - QStringLiteral("-----BEGIN PGP PUBLIC KEY BLOCK-----"))); - QVERIFY(outstr.contains( - QStringLiteral("Content-Type: application/pgp-keys"))); - QVERIFY(outstr.contains( - QStringLiteral("From: " TEST_ADDRESS))); - }); - job->startCreate(fpr.constData(), QLatin1String(TEST_ADDRESS)); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - } - - void testWKSPublishReceive() { - if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.0.16") { - /* Not supported */ - return; - } - auto importjob = openpgp()->importJob(); - connect(importjob, &ImportJob::result, this, - [this](ImportResult result, QString, Error) - { - QVERIFY(!result.error()); - QVERIFY(!result.imports().empty()); - QVERIFY(result.numSecretKeysImported()); - Q_EMIT asyncDone(); - }); - importjob->start(QByteArray(testSecKey)); - QSignalSpy spy (this, SIGNAL(asyncDone())); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - - /* Get a response. */ - auto job = openpgp()->wksPublishJob(); - connect(job, &WKSPublishJob::result, this, - [this] (Error err, QByteArray out, QByteArray, QString, Error) { - QVERIFY(!err); - Q_EMIT asyncDone(); - const QString outstr = QString(out); - QVERIFY(outstr.contains( - QStringLiteral("-----BEGIN PGP MESSAGE-----"))); - QVERIFY(outstr.contains( - QStringLiteral("Content-Type: multipart/encrypted;"))); - QVERIFY(outstr.contains( - QStringLiteral("From: " TEST_ADDRESS))); - }); - job->startReceive(QByteArray(testResponse)); - QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); - } - - void initTestCase() - { - QGpgMETest::initTestCase(); - const QString gpgHome = qgetenv("GNUPGHOME"); - qputenv("GNUPGHOME", mDir.path().toUtf8()); - QVERIFY(mDir.isValid()); - QFile agentConf(mDir.path() + QStringLiteral("/gpg-agent.conf")); - QVERIFY(agentConf.open(QIODevice::WriteOnly)); - agentConf.write("allow-loopback-pinentry"); - agentConf.close(); - } -private: - QTemporaryDir mDir; -}; - -QTEST_MAIN(WKSPublishTest) - -#include "t-wkspublish.moc" |