Commit Graph

3501 Commits

Author SHA1 Message Date
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
f3ca57dfd7 core: Handle import status lines during keylist operation
* src/import.c (import_status_handler): Rename to ...
(_gpgme_import_status_handler): this. Make non-static.
(_gpgme_op_import_init_result): New.
(_gpgme_op_import_start, _gpgme_op_import_keys_start,
_gpgme_op_receive_keys_start): Call _gpgme_op_import_init_result.
* src/keylist.c (keylist_status_handler): Call
_gpgme_import_status_handler to handle import status lines.
(gpgme_op_keylist_start, gpgme_op_keylist_ext_start): Call
_gpgme_op_import_init_result.
* src/ops.h (_gpgme_op_import_init_result,
_gpgme_import_status_handler): New prototypes.
--

If a keylist operation with keylist mode GPGME_KEYLIST_MODE_LOCATE is
run, then gpg emits import status lines. Handling those status lines
allows users to retrieve the result of a --locate-(external)-keys
command.

GnuPG-bug-id: 5951
2022-05-04 14:23:42 +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
aff9aaac68 core: Support --locate-external-keys command of gpg
* src/gpgme.h.in (GPGME_KEYLIST_MODE_FORCE_EXTERN): New.
(GPGME_KEYLIST_MODE_LOCATE_EXTERNAL): New.
* src/gpgme.c (gpgme_set_keylist_mode): Check for invalid mode.
* src/engine-gpg.c (gpg_keylist_build_options): Use
"--locate-external-keys" instead of "--locate-keys" if flag is set.
* src/gpgme-json.c (op_keylist): New flag "force-extern".
* src/gpgme-tool.c (gt_get_keylist_mode, cmd_keylist_mode): Handle
new mode.
--

GnuPG-bug-id: 5951
2022-04-27 16:57:17 +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
e21c3b559d core: Return BAD_PASSPHRASE error code on symmetric decryption.
* src/decrypt.c (op_data_t): Add field symdecrypt_failed.
(parse_status_error): Handle BAD_PASSPHRASE error code.
(_gpgme_decrypt_status_handler): Consult new field.
--

Return a bad passphrase error if the failure during symmetric decryption
is likely caused by the user entering a wrong passphrase. The special
error code of a failed public key decryption takes precedence.

GnuPG-bug-id: 5939
2022-04-25 12:14:42 +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
NIIBE Yutaka
b10791b055 doc: Remove explanation about AM_PATH_GPGME_PTH for GNU Pth.
--

The commit 3ddf4c3d40 in 2011 removed
the support.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-04-08 09:19:19 +09: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
NIIBE Yutaka
a36d71a8e3 core: Don't use internal __assuan functions.
* configure.ac (nanosleep): Detect.
* src/assuan-support.c: Don't use __assuan_usleep.
(my_socketpair): Don't use __assuan_socketpair.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-04-05 14:42:59 +09:00
NIIBE Yutaka
110a375401 core: Don't keep using deprecated ath_ API.
* src/posix-io.c: Don't include ath.h.
(_gpgme_io_read): Call read directly.
(_gpgme_io_write): Call write directly.
(_gpgme_io_waitpid): Call waitpid directly.
(_gpgme_io_select_select): Call select directly.
(_gpgme_io_recvmsg): Call recvmsg directly.
(_gpgme_io_sendmsg): Call sendmsg directly.
(_gpgme_io_connect): Call connect directly.
* src/assuan-support.c: Don't include ath.h.
(my_waitpid): Call waitpid directly.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-04-05 14:25:00 +09: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
7317139ef9 doc: Update NEWS
--

GnuPG-bug-id: 5906
2022-03-29 15:14:12 +02:00
Ingo Klöcker
3b3b36a607 qt: Set default visibility of all symbols to hidden
* configure.ac: Add -fvisibility=hidden to GPGME_QT_CFLAGS if gcc
supports the flag.
--

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.

GnuPG-bug-id: 5906
2022-03-28 17:22:48 +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
ff3c93881a doc: Remove bogus documentation
--

These lines were accidentally added with the documentation for
gpgme_op_setexpire. The actual documentation for gpgme_op_revuid_start
is a bit further down.
2022-03-28 17:22:48 +02:00
NIIBE Yutaka
b2a2158384 core: Support keylist mode for op_keylist_from_data.
* src/engine-backend.h (keylist_data): Add MODE argument.
* src/engine-gpg.c (gpg_keylist_data): Add MODE argument.
* src/engine.c (_gpgme_engine_op_keylist_data): Likewise.
* src/engine.h (_gpgme_engine_op_keylist_data): Declaration.
* src/keylist.c (gpgme_op_keylist_from_data_start): Call
_gpgme_engine_op_keylist_data with ctx->keylist_mode.

--

GnuPG-bug-id: 5438
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-16 16:19:50 +09: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
71d4c9f452 doc: Update NEWS
--

Add a few more changes in version 1.17.0.
2022-03-07 09:28:09 +01:00
Werner Koch
f61a14f189
Post release updates 2022-03-06 18:02:42 +01:00
Werner Koch
ee50a38823
Release 1.17.1
* configure.ac: Bump QT LT version to C15/A0/R0.
2022-03-06 17:48:47 +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
fb5369161f
Post release updates
--
2022-02-07 18:09:06 +01:00
Werner Koch
72bb46b34f
Release 1.17.0 2022-02-07 15:02:49 +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