Commit Graph

1100 Commits

Author SHA1 Message Date
Ingo Klöcker
bc10169724 qt: Allow setting the file name of encrypted data
* lang/qt/src/Makefile.am (qgpgme_sources): Add encryptjob.cpp.
* lang/qt/src/encryptjob.cpp: New.
* lang/qt/src/encryptjob.h (class EncryptJob): Add member functions
setFileName, fileName.
* lang/qt/src/qgpgmeencryptjob.cpp (encrypt): Set file name of input.
(encrypt_qba, QGpgMEEncryptJob::exec, QGpgMEEncryptJob::start): Pass
file name to encrypt resp. encrypt_qba.
--

This makes it possible to store the original name of an encrypted file
in the encryption result.

GnuPG-bug-id: 6056
2022-07-05 18:10:08 +02:00
Ingo Klöcker
31423945d2 qt: Fix filename of cmake config files for w32
* lang/qt/src/Makefile.am (EXTRA_DIST): Add
QGpgmeConfig-w32.cmake.in.in.
--
2022-07-04 17:10:31 +02:00
Laurent Montel
d42323f902 qt: Add #include <QStringList> needed for building against qt6
* lang/qt/src/downloadjob.h, lang/qt/src/exportjob.h,
lang/qt/src/keylistjob.h lang/qt/src/refreshkeysjob.h: in qt6 we need
to use #include <QStringList>
--

It fixes some compile qt6 compile error.

Signed-off-by: Laurent Montel <montel@kde.org>
2022-07-04 16:58:59 +02:00
Ingo Klöcker
6e45da30ae cpp: Remove obsolete compatibility with KF5 variants
* lang/cpp/src/GpgmeppConfig-w32.cmake.in.in,
lang/cpp/src/GpgmeppConfig.cmake.in.in: Remove find_package() call.
--

The KF5 variants have been removed years ago with revision
a3cf30f894.
2022-06-30 12:30:15 +02:00
Ingo Klöcker
fd813f5c39 qt,tests: Allow 1-day-offset for expiration date
* lang/qt/tests/t-various.cpp (TestVarious::testSignKeyWithExpiration):
Assert that the expiration date is either 2106-02-05 or 2106-02-04.

--

This avoids a test failure if the test is run at 00:xx:xx in a location
that uses DST.

GnuPG-bug-id: 5991
2022-06-10 12:03:39 +02:00
Ingo Klöcker
7870fdbfef qt: Prevent u32 overflow when calculating expiration date
* lang/qt/src/qgpgmesignkeyjob.cpp (sign_key): Change maxAllowedDate to
2106-02-05. Change log-level from warning to debug.
* lang/qt/tests/t-various.cpp (TestVarious::testSignKeyWithExpiration):
Remove check for warning. Adapt assertion.
--

Capping the expiration date at 2106-02-05 prevents a u32 overflow when
adding the number of days until the maximal date to the current time.

GnuPG-bug-id: 5991
2022-06-10 11:54:03 +02:00
Ingo Klöcker
918afc809d Revert "tests: Avoid problems with local time across a day boundary."
This reverts commit 5ba0e454a3.
2022-06-09 15:43:24 +02:00
Werner Koch
5ba0e454a3
tests: Avoid problems with local time across a day boundary.
--

GnuPG-bug-id: 5991
2022-05-23 08:20:04 +02:00
Andre Heinecke
f3011b5a19
cpp: Export KeyListModeSaver
* lang/cpp/src/context.h (Context::KeyListModeSaver): Add Export.

--
This is required for Windows.
2022-05-12 09:34:15 +02:00
Ingo Klöcker
306fd9c915 cpp: Output more properties of a subkey
* lang/cpp/src/key.cpp (ostream operator<< for Subkey): Fix wrong output
of isInvalid and isDisabled flags. Add output of key grip, card serial
number and the flags isSecret, isQualified, isDeVs, and isCardKey.
--

This makes it easier to check those properties for different keys, e.g.
with the run-keylist test program.

GnuPG-bug-id: 5965
2022-05-05 17:25:47 +02:00
Ingo Klöcker
e029fd2735 cpp,tests: Actually parse the --with-secret option
* lang/cpp/tests/run-keylist.cpp (main): Handle --with-secret option.
Print error for unknown option.
--

The --with-secret option was already listed in the help. Now it also
works.

GnuPG-bug-id: 5965
2022-05-05 17:24:59 +02:00
Ingo Klöcker
9e8c8e448e qt: Revert change of result signal of RefreshKeysJob
* lang/qt/src/refreshkeysjob.h (RefreshKeysJob::result): Remove optional
parameters auditLogAsHtml and auditLogError.
* lang/qt/tests/run-refreshkeysjob.cpp (main): Update accordingly.
--

This reverts f4c3560925. The reason for
the previous change does no longer apply.

GnuPG-bug-id: 5951
2022-05-05 10:39:26 +02:00
Ingo Klöcker
15a4940aa7 qt: Use lambda instead of std::bind
* lang/qt/src/qgpgmerefreshopenpgpkeysjob.cpp
(QGpgMERefreshOpenPGPKeysJob::start): Replace std::bind call with a
lambda.
--

GnuPG-bug-id: 5951
2022-05-05 10:32:34 +02:00
Ingo Klöcker
c64a8daf50 qt: Emit import result when refreshing OpenPGP keys
* lang/qt/src/refreshopenpgpkeysjob.h: New.
* lang/qt/src/Makefile.am, lang/qt/src/job.cpp: Update accordingly.
* lang/qt/src/qgpgmerefreshopenpgpkeysjob.h (class
QGpgMERefreshOpenPGPKeysJob): Derive from RefreshOpenPGPKeysJob with
result ImportResult. Remove unused start overload.
* lang/qt/src/qgpgmerefreshopenpgpkeysjob.cpp (locate_external_keys):
Ignore result of KeyListJob. Return import result.
(receive_keys): Return import result.
(refresh_keys): Merge the two import results and return the result.
* lang/qt/src/protocol.h (class Protocol): Add pure virtual member
function refreshOpenPGPKeysJob.
* lang/qt/src/protocol_p.h (Protocol::refreshKeysJob): Return nullptr
for OpenPGP protocol.
(Protocol::refreshOpenPGPKeysJob): New.

* lang/qt/tests/run-refreshkeysjob.cpp (main): Use appropriate job
for the protocol of the key to refresh.
--

This adds RefreshOpenPGPKeysJob complementing RefreshKeysJob (for S/MIME
keys). Changing the result type of RefreshKeysJob would break the ABI.
Therefore we have to introduce a new base class for the refresh job for
OpenPGP. We derive this base class from AbstractImportJob because we
want to return an import result.

GnuPG-bug-id: 5951
2022-05-04 14:51:50 +02:00
Ingo Klöcker
3519d61173 cpp: Allow retrieving import result of key listing with locate mode
* lang/cpp/src/context_p.h (enum Context::Private::Operation): Add
value KeyListWithImport.
* lang/cpp/src/context.cpp (Context::startKeyListing, Context::nextKey):
Set lastop to KeyListWithImport if keylist mode includes Locate.
--

Adding Import to lastop for keylist operations that perform a locate
allows retrieving the import result with Context::importResult.

GnuPG-bug-id: 5951
2022-05-04 14:31:03 +02:00
Ingo Klöcker
d911a15364 cpp: Allow merging the results of two imports
* lang/cpp/src/importresult.h, lang/cpp/src/importresult.cpp (class
ImportResult): Add member function mergeWith.
--

This allows creating a consolidated result of several independent
imports. If the import results to merge considered the same keys, then
not all counts can be consolidated correctly, but the important numbers
like the number of considered keys, the number of imported keys, the
number of unchanged keys and the numbers of new user IDs, subkeys,
signatures and revocations should be correct.

GnuPG-bug-id: 5951
2022-05-04 12:37:47 +02:00
Ingo Klöcker
f1a354fd57 qt: Apply compiler hint
* lang/qt/tests/t-verify.cpp (VerifyTest::testSignatureKey): Use
reference type to prevent copying.
--
2022-05-02 16:04:28 +02:00
Ingo Klöcker
540e7bf3d4 qt: Use GpgME::Locate alias
* lang/qt/src/protocol_p.h (Protocol::locateKeysJob): Use Locate alias
instead of Extern|Local.
* lang/qt/src/qgpgmekeyformailboxjob.cpp (do_work): Ditto.
--
2022-05-02 16:00:43 +02:00
Ingo Klöcker
e12861f18c qt: Add job for refreshing OpenPGP keys
* lang/qt/src/qgpgmerefreshopenpgpkeysjob.h,
lang/qt/src/qgpgmerefreshopenpgpkeysjob.cpp: New.
* lang/qt/src/Makefile.am: Add new files.
* lang/qt/src/protocol_p.h (Protocol::refreshKeysJob): Add support for
OpenPGP protocol.
--

The new job performs a --locate-external-keys for the email addresses
of all not revoked user IDs of the given keys, and it performs a
--recv-keys for the fingerprints of the given keys. The former may
import new keys from WKD or an LDAP server or via some other
(hopefully trusted) auto-key-locate mechanism.

GnuPG-bug-id: 5951
2022-05-02 15:51:44 +02:00
Ingo Klöcker
34786132fe cpp: Add RAII class for saving/restoring the key list mode
* lang/cpp/src/context.h, lang/cpp/src/context.cpp (class Context):
Add nested class KeyListModeSaver.
--

This RAII-style class can be used to save the currently used key list
mode in case it needs to be changed temporarily. On destruction, it
will restore the key list mode that was active at construction time.

GnuPG-bug-id: 5951
2022-05-02 15:51:44 +02:00
Ingo Klöcker
99fd565889 qt: Add debug helper for Result classes with output stream operator
* lang/qt/src/util.h (toLogString): New.
--

GnuPG-bug-id: 5951
2022-05-02 15:06:56 +02:00
Ingo Klöcker
0c304beeaa qt: Factor out helper for getting the fingerprints of some keys
* lang/qt/src/util.h, lang/qt/src/util.cpp (toFingerprints): New.
* lang/qt/src/qgpgmerefreshsmimekeysjob.cpp: Use the helper.
--

GnuPG-bug-id: 5951
2022-05-02 15:04:37 +02:00
Ingo Klöcker
97e09fb964 qt,doc: Fix some API documentation
--

Fix or remove API documentation that has been copied and pasted from
other jobs.
2022-05-02 14:58:21 +02:00
Ingo Klöcker
54c4fd16d1 qt: Fix connection to readyReadStandardOutput signal
* lang/qt/src/qgpgmerefreshsmimekeysjob.h,
lang/qt/src/qgpgmerefreshsmimekeysjob.cpp
(QGpgMERefreshSMIMEKeysJob::slotStderr): Remove.
* lang/qt/src/qgpgmerefreshsmimekeysjob.cpp
(QGpgMERefreshSMIMEKeysJob::startAProcess): Handle
readyReadStandardOutput and readyReadStandardError signals with lambdas.
--

For now output stdout and stderr of gpgsm process as debug log. In
particular, this "adds" the missing slot slotStdout.

GnuPG-bug-id: 5951
2022-04-29 11:55:47 +02:00
Ingo Klöcker
9686258bd1 qt: Add test runner for refresh job
* lang/qt/tests/run-refreshkeysjob.cpp: New.
* lang/qt/tests/Makefile.am (run_refreshkeysjob_SOURCES): New.
(noinst_PROGRAMS): Add new build artifact.
--

GnuPG-bug-id: 5951
2022-04-29 11:44:30 +02:00
Ingo Klöcker
f4c3560925 qt: Make RefreshKeysJob result compatible with standard job result
* lang/qt/src/refreshkeysjob.h (RefreshKeysJob::result): Add optional
parameters auditLogAsHtml and auditLogError.
--

This is necessary for the OpenPGP-implementation of this job.

GnuPG-bug-id: 5951
2022-04-29 11:24:36 +02:00
Ingo Klöcker
fd97cbaa44 qt: Allow refreshing a list of keys
* lang/qt/src/refreshkeysjob.h (class RefreshKeysJob): Add pure virtual
member function start taking a list of keys.
* lang/qt/src/qgpgmerefreshsmimekeysjob.h,
lang/qt/src/qgpgmerefreshsmimekeysjob.cpp (class
QGpgMERefreshSMIMEKeysJob): Implement new member function.
--

The new overload makes it easier to refresh some keys if one does
already have Keys.

GnuPG-bug-id: 5951
2022-04-29 10:50:31 +02:00
Ingo Klöcker
62e7709717 qt: Minor refactoring
* lang/qt/src/qgpgmerefreshsmimekeysjob.cpp: Use namespace QGpgME.
--

GnuPG-bug-id: 5951
2022-04-29 10:46:23 +02:00
Ingo Klöcker
f47bc992ae qt: Rename QGpgMERefreshKeysJob to QGpgMERefreshSMIMEKeysJob
* lang/qt/src/qgpgmerefreshkeysjob.h,
lang/qt/src/qgpgmerefreshkeysjob.cpp: Change name to
* lang/qt/src/qgpgmerefreshsmimekeysjob.h,
lang/qt/src/qgpgmerefreshsmimekeysjob.cpp: ... this, and adapt the
include guard.
(class QGpgMERefreshKeysJob): Rename to QGpgMERefreshSMIMEKeysJob.
* lang/qt/src/Makefile.am: Adapt mentioned file names accordingly.
* lang/qt/src/protocol_p.h (Protocol::refreshKeysJob): Use renamed
class.
--

To avoid confusion with a similar job for OpenPGP keys with a completely
different implementation, we rename this class to make clear that it is
specific for S/MIME keys.

GnuPG-bug-id: 5951
2022-04-29 10:39:38 +02:00
Ingo Klöcker
359906c8bc cpp,tests: Verify that requested keylist mode is used
* lang/cpp/tests/run-getkey.cpp, lang/cpp/tests/run-keylist.cpp (main):
Check used keylist mode.
--

Since Context::setKeyListMode() does not return the error returned by
gpgme, we need to verify explicitly that the keylist mode was set
successfully.

GnuPG-bug-id: 5951
2022-04-28 10:33:23 +02:00
Ingo Klöcker
dea872f21f cpp: Support new keylist modes
* lang/cpp/src/global.h (ForceExtern, LocateExternal, KeyListModeMask):
New.
* lang/cpp/src/context.cpp (operator<<): Add check.
* lang/cpp/src/util.h (gpgme_keylist_mode_t,
convert_from_gpgme_keylist_mode_t): Handle ForceExtern.
* lang/cpp/tests/run-getkey.cpp (show_usage, main): Add arguments
--force-extern and --locate-external.
* lang/cpp/tests/run-keylist.cpp (show_usage, main): Ditto.
--

GnuPG-bug-id: 5951
2022-04-27 17:21:04 +02:00
Ingo Klöcker
512f11b458 qt: Rely on the bad passphrase error reported by gpg
* lang/qt/src/qgpgmedecryptverifyjob.cpp (patch_decryption_result):
Removed.
(decrypt_verify): Remove usage of patch_decryption_result.
--

This reverts most of revision d8e5871dca.

GnuPG-bug-id: 5939
2022-04-25 12:18:17 +02:00
Ingo Klöcker
d8e5871dca qt: Report better error if decryption failed because of bad passphrase
* lang/qt/src/qgpgmedecryptverifyjob.cpp (patch_decryption_result): New.
(decrypt_verify): Call patch_decryption_result.
--

Replace the generic "decryption failed" error with the more specific
"bad passphrase" error if the audit log indicates that a wrong symmetric
password caused the decryption to fail.

GnuPG-bug-id: 5939
2022-04-22 17:34:41 +02:00
Ingo Klöcker
321c8a0254 cpp: Allow changing the error of a result
* lang/cpp/src/result.h (class Result): Add member function setError.
--

This can be used to replace the error of a result with a more suitable
error.

GnuPG-bug-id: 5939
2022-04-22 17:30:59 +02:00
Ingo Klöcker
102024f7e6 qt,doc: Fix typo and grammar in API documentation
--
2022-04-05 10:17:39 +02:00
Ingo Klöcker
28cdbfdccb cpp: Handle canceling of an edit operation
* lang/cpp/src/editinteractor.cpp
(CallbackHelper::edit_interactor_callback_impl): Check for error _or_
canceled state.
--

Without this canceling an edit operation resulted in a "General error".

GnuPG-bug-id: 5904
2022-04-05 10:17:39 +02:00
Ingo Klöcker
db532eca8e cpp: Return actual error if revocation fails
* lang/cpp/src/editinteractor.cpp, lang/cpp/src/editinteractor.h
(EditInteractor::parseStatusError): New.
* lang/cpp/src/gpgrevokekeyeditinteractor.cpp
(GpgRevokeKeyEditInteractor::Private::nextState): Handle status
error.
--

With this change the interactor returns a proper error like "Bad
Passphrase" or "Empty Passphrase" instead of an unspecific "General
Error" if a status error occurred.

GnuPG-bug-id: 5904
2022-04-05 10:15:07 +02:00
Ingo Klöcker
c965b45bcd cpp: Add internal utility function for splitting strings
* lang/cpp/src/util.h (split): New.
--

This function splits a given string using the given delimiter into
several strings.

GnuPG-bug-id: 5904
2022-04-05 10:05:43 +02:00
Ingo Klöcker
4beb6f4199 cpp: Do not export symbols of the Private class
* lang/cpp/src/gpgrevokekeyeditinteractor.h (class
GpgRevokeKeyEditInteractor): Mark nested class Private as hidden.
--

GnuPG-bug-id: 5904
2022-04-05 10:05:43 +02:00
Ingo Klöcker
7f089165e3 qt: Check arguments passed to the revoke key job
* lang/qt/src/qgpgmerevokekeyjob.cpp (check_arguments): New.
(QGpgMERevokeKeyJob::start, QGpgMERevokeKeyJob::exec): Call
check_arguments.
* lang/qt/tests/t-revokekey.cpp (RevokeKeyJobTest): Add member functions
testErrorHandling_nullKey, testErrorHandling_invalidReason,
testErrorHandling_invalidDescription.
--

Check that the key is not a null key, that the reason has a valid
value, and that the description lines do not contain endline characters
and are not empty.

GnuPG-bug-id: 5904
2022-03-31 18:39:19 +02:00
Ingo Klöcker
3856ae8621 qt,tests: Verify reason code and description of revocation
* lang/qt/tests/t-revokekey.cpp (RevokeKeyJobTest::testRevokeKeyAsync,
RevokeKeyJobTest::testRevokeKeySync_noReasonDescription,
RevokeKeyJobTest::testRevokeKeySync_oneLineReasonDescription,
RevokeKeyJobTest::testRevokeKeySync_twoLinesReasonDescription): Call
verifyReason.
(class RevokeKeyJobTest): Add private member function verifyReason.
--

gpgme doesn't parse the information, so we run gpg manually to verify
the revocation reason and the description.

GnuPG-bug-id: 5904
2022-03-30 12:29:28 +02:00
Ingo Klöcker
41297520da qt: Add job to revoke own OpenPGP keys
* lang/qt/src/revokekeyjob.h, lang/qt/src/qgpgmerevokekeyjob.h,
lang/qt/src/qgpgmerevokekeyjob.cpp: New.
* lang/qt/src/protocol.h (class Protocol): Add pure virtual member
function revokeKeyJob.
* lang/qt/src/protocol_p.h (Protocol::revokeKeyJob): New.
* lang/qt/src/job.cpp, lang/qt/src/Makefile.am: Update accordingly.

* lang/qt/tests/Makefile.am (the_tests, moc_files, noinst_PROGRAMS):
Add new test.
(t_revokekey_SOURCES): New.
* lang/qt/tests/t-revokekey.cpp: New.
--

The new job allows revoking own OpenPGP keys as with the "revkey"
edit-key command of gpg.

GnuPG-bug-id: 5904
2022-03-30 12:29:28 +02:00
Ingo Klöcker
d96e8a7a6b cpp: Add interactor to revoke a key
* lang/cpp/src/global.h (enum class RevocationReason): New.
* lang/cpp/src/gpgrevokekeyeditinteractor.cpp,
lang/cpp/src/gpgrevokekeyeditinteractor.h: New.
* lang/cpp/src/Makefile.am: Add new files.
--

GnuPG-bug-id: 5904
2022-03-30 12:05:26 +02:00
Ingo Klöcker
fe588fef09 cpp: Set default visibility of all symbols to hidden
* configure.ac: Add -fvisibility=hidden to GPGME_CPP_CFLAGS if gcc
supports the flag.
* lang/cpp/src/Makefile.am (AM_CPPFLAGS): Add GPGME_CPP_CFLAGS.
* m4/ax_gcc_func_attribute.m4: New.
--

With this change all defined symbols are hidden by default, so that they
are not exported anymore. All symbols that are part of the ABI and that
shall still be exported are already marked as having default visibility.

The m4 macro was taken from the website mentioned in the License header
of the file.

GnuPG-bug-id: 5906
2022-03-28 17:22:48 +02:00
Ingo Klöcker
92139e7b6b cpp: Put local helper function into unnamed namespace
lang/cpp/src/context.cpp (to_auditlog_flags): Wrap in unnamed namespace.
--

GnuPG-bug-id: 5906
2022-03-28 17:22:48 +02:00
Ingo Klöcker
55861ba9cc qt: Add missing include of config.h
* lang/qt/src/util.cpp: Include config.h.
--

GnuPG-bug-id: 5871
2022-03-07 09:28:09 +01:00
Ingo Klöcker
5a5a748e23 qt,doc: Remove comments about throwing exceptions
--

The jobs do not throw GpgME::Exception anymore since a long time.
2022-03-07 09:28:09 +01:00
Ingo Klöcker
ad3aabdd8a qt: Fix ABI compatibility with 1.16.0
* lang/qt/src/protocol.h (class Protocol): Move new virtual methods to
the end of the class.
--

This makes the vtable offsets of the old virtual methods match those
in 1.16.0 again.

GnuPG-bug-id: 5834
2022-02-17 09:54:45 +01:00
Werner Koch
451a42f0d2
qt: Fix build for older Qt versions.
* lang/qt/src/util.cpp: Include <functional>.
2022-02-07 13:10:13 +01:00
Ingo Klöcker
ca1c30b6fa qt: Add job to import keys given by key ids
* lang/qt/src/receivekeysjob.h, lang/qt/src/qgpgmereceivekeysjob.h,
lang/qt/src/qgpgmereceivekeysjob.cpp: New.
* lang/qt/src/protocol.h (class Protocol): Add pure virtual member
function receiveKeysJob.
* lang/qt/src/protocol_p.h (Protocol::receiveKeysJob): Implement it.
* lang/qt/src/job.cpp, lang/qt/src/Makefile.am: Update accordingly.

* lang/qt/tests/run-receivekeysjob.cpp: New.
* lang/qt/tests/Makefile.am: Add new test runner.
--

This job allows importing keys that are given by their key ids (or
fingerprints) from keyservers as with gpg's recv-keys command.

GnuPG-bug-id: 5808
2022-02-03 15:56:30 +01:00