gpgme.git
23 months agopython: idiomatic interface prototype justus/idiomatic-py-0
Justus Winter [Wed, 8 Jun 2016 16:58:57 +0000 (18:58 +0200)]
python: idiomatic interface prototype

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agopython: Port more tests.
Justus Winter [Mon, 6 Jun 2016 10:49:11 +0000 (12:49 +0200)]
python: Port more tests.

* lang/python/tests/Makefile.am (pytests): Add new file.
* lang/python/tests/t-import.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agosrc: Fix error handling.
Justus Winter [Fri, 8 Jul 2016 16:00:01 +0000 (18:00 +0200)]
src: Fix error handling.

* src/encrypt.c (encrypt_status_handler): Fix error handling, ||
conflates errors.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agopython: Fix raising stashed exceptions.
Justus Winter [Fri, 8 Jul 2016 09:45:08 +0000 (11:45 +0200)]
python: Fix raising stashed exceptions.

Fixes an issue with newer versions of Python.

* lang/python/helpers.c (pygpgme_raise_callback_exception): Be more
careful when restoring the exception.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agopython: Fix distcheck.
Justus Winter [Wed, 6 Jul 2016 08:59:18 +0000 (10:59 +0200)]
python: Fix distcheck.

* lang/python/INSTALL: Drop obsolete file.
* lang/python/Makefile.am (EXTRA_DIST): Add missing files.
(CLEANFILES): Remove generated files.
(clean-local): Fix permissions of copied files.
* lang/python/tests/Makefile.am (TESTS): Use our own setup and
teardown scripts.
(EXTRA_DIST): Add missing files.
* lang/python/tests/final.py: New file.
* lang/python/tests/initial.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agoqt: Fix distcheck.
Justus Winter [Wed, 6 Jul 2016 09:01:55 +0000 (11:01 +0200)]
qt: Fix distcheck.

* lang/qt/src/Makefile.am (qgpgme_headers): Add missing file.
(CLEANFILES): Add generated file.
* lang/qt/tests/Makefile.am (clean-local): Remove private keys.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agocpp: Fix distcheck.
Justus Winter [Thu, 7 Jul 2016 11:23:05 +0000 (13:23 +0200)]
cpp: Fix distcheck.

* lang/cpp/src/Makefile.am (CLEANFILES): Remove generated file.

Signed-off-by: Justus Winter <justus@g10code.com>
23 months agoQt: Add test for publicKeyAlgorithmAsString
Andre Heinecke [Wed, 6 Jul 2016 13:09:16 +0000 (15:09 +0200)]
Qt: Add test for publicKeyAlgorithmAsString

* lang/qt/tests/t-keylist.cpp (testPubkeyAlgoAsString): New.

23 months agoCpp: Expose gpgme_pubkey_algo_name
Andre Heinecke [Wed, 6 Jul 2016 13:07:34 +0000 (15:07 +0200)]
Cpp: Expose gpgme_pubkey_algo_name

* lang/cpp/src/key.cpp (Subkey::publicKeyAlgorithmAsString): New
static variant.
* lang/cpp/src/key.h: Declare function. Clarify comment about name
mismatch.

23 months agoQt: Add check for pubkeyAlgo in t-keylist
Andre Heinecke [Wed, 6 Jul 2016 11:39:43 +0000 (13:39 +0200)]
Qt: Add check for pubkeyAlgo in t-keylist

* lang/qt/tests/t-keylist.cpp (testSingleKeyListSync): Check
pubkeyAlgo.

23 months agoCpp: Add PubkeyAlgo enum
Andre Heinecke [Wed, 6 Jul 2016 11:38:20 +0000 (13:38 +0200)]
Cpp: Add PubkeyAlgo enum

* lang/cpp/src/key.h (Subkey::PubkeyAlgo): New enum.
(Subkey::publicKeyAlgorithm): Change return type.
* lang/cpp/src/key.cpp (Subkey::publicKeyAlgorithm): Use enum.

23 months agoQt: Fix include order when buildin test
Andre Heinecke [Wed, 6 Jul 2016 09:28:11 +0000 (11:28 +0200)]
Qt: Fix include order when buildin test

* lang/qt/tests/Makefile.am (AM_CPPFLAGS): Include cpp before
gpgme src directory.

--
This fixes a problem where context.h would be picked up from gpgme/src
instead of including the context.h from gpgme++.

23 months agoRevert "Qt: More robust lookup of Cpp's context.h"
Andre Heinecke [Wed, 6 Jul 2016 09:22:10 +0000 (11:22 +0200)]
Revert "Qt: More robust lookup of Cpp's context.h"

* lang/qt/src/threadedjobmixin.h: Revert using full path
for context.h

--
This reverts commit 47bfbc9026b49b9918359af5fcc1621aab0d1065 as
it causes problems depending on the include path. The proper
fix will be to ensure that cpp/src is included before gpgme/src.

23 months agoQt: Fix test build with Qt < 5.4.0
Andre Heinecke [Tue, 5 Jul 2016 20:11:42 +0000 (22:11 +0200)]
Qt: Fix test build with Qt < 5.4.0

* lang/qt/tests/t-keylist.cpp,
lang/qt/tests/t-keylocate.cpp,
lang/qt/tests/t-ownertrust.cpp: Use old style SIGNAl syntax for
QSignalSpy

23 months agoQt: More robust lookup of Cpp's context.h
Andre Heinecke [Tue, 5 Jul 2016 20:10:18 +0000 (22:10 +0200)]
Qt: More robust lookup of Cpp's context.h

* lang/qt/src/threadedjobmixin.h: When building qgpgme look for
context.h in the full cpp subdirectory.

--
Gpgme core also contains a context.h that can lead to confusion
otherwise.

23 months agow32: Fallback to 2.1 reg key for gpgconf search
Andre Heinecke [Tue, 1 Mar 2016 12:11:13 +0000 (13:11 +0100)]
w32: Fallback to 2.1 reg key for gpgconf search

* src/w32-util.c (_gpgme_get_gpgconf_path): Fallback to 2.1 installer
 registry key.

--
Finding gpgconf is utterly important so we should be as compatible
as possible.

23 months agoDoc: Document pinentry mode
Andre Heinecke [Mon, 4 Jul 2016 09:23:12 +0000 (11:23 +0200)]
Doc: Document pinentry mode

* doc/gpgme.texi (Passphrase Callback): Document as context
attribute.
(gpgme_set_passphrase_cb): Note that this requires LOOPBACK mode
with GnuPG 2.1.

23 months agoQt: Add testTofuSignCount
Andre Heinecke [Mon, 4 Jul 2016 09:42:30 +0000 (11:42 +0200)]
Qt: Add testTofuSignCount

* src/lang/qt/tests/t-tofuinfo.cpp(testTofuSignCount): New.
(initTestCase): Set gpg-agent loopback pinentry config.
(signAndVerify): Helper for tofuTestSignCount.

--
Also needs the wait code because of GnuPG-Bug-Id: 2405

23 months agoQt: Add test passphrase provider
Andre Heinecke [Mon, 4 Jul 2016 09:40:03 +0000 (11:40 +0200)]
Qt: Add test passphrase provider

* lang/qt/tests/t-support.h (TestPassphraseProvider): New.
* lang/qt/tests/Makefile.am (t_tofuinfo_SOURCES): Add t-support.h

23 months agoCpp: Add support for TOFU_CONFLICT sigsum
Andre Heinecke [Mon, 4 Jul 2016 09:31:01 +0000 (11:31 +0200)]
Cpp: Add support for TOFU_CONFLICT sigsum

* lang/cpp/src/verificationresult.cpp (GpgME::Signature::Summary):
Handle TOFU_CONFLICT.
* lang/cpp/src/verificationresult.h (Summary): Add TofuConflict.

23 months agoCpp: Add support for pinentry_mode
Andre Heinecke [Mon, 4 Jul 2016 09:25:40 +0000 (11:25 +0200)]
Cpp: Add support for pinentry_mode

* lang/cpp/src/context.cpp (Context::pinentryMode): Return mode.
(Context::setPinentryMode): Set mode.
* lang/cpp/src/context.h (PinentryMode): Add enum.

23 months agoQt: Add test for TofuInfo
Andre Heinecke [Fri, 1 Jul 2016 14:55:14 +0000 (16:55 +0200)]
Qt: Add test for TofuInfo

* lang/qt/tests/t-tofuinfo.cpp: New.
* lang/qt/tests/Makefile.am: Update accordingly.

--
The test currently contains a workaround for GnuPG-Bug-Id 2405

23 months agoCpp: Add TofuInfo to signatures
Andre Heinecke [Fri, 1 Jul 2016 14:49:06 +0000 (16:49 +0200)]
Cpp: Add TofuInfo to signatures

* lang/cpp/src/tofuinfo.cpp, lang/cpp/src/tofuinfo.h: New class.
* lang/cpp/src/verificationresult.cpp (Signature::tofuInfo): New.
(VerificationResult::Private): Handle tofu info.
(GpgME::operator<<(std::ostream &os, const Signature &sig)): Include
TofuInfo in dump.
* lang/cpp/src/verificationresult.h (Signature::tofuInfo): New.
* lang/cpp/src/Makefile.am (main_sources, gpgmepp_headers): Add
new files.
* configure.ac (LIBGPGMEPP_LT_REVISION): Bump for new API.

23 months agocore: Clarify documentation of tofu_stats address
Andre Heinecke [Fri, 1 Jul 2016 14:47:04 +0000 (16:47 +0200)]
core: Clarify documentation of tofu_stats address

* src/gpgme.h.in: Mention that Address is not always in addr-spec.

--
The old comment made it look like you could always expect the
address to be parsable as a mailbox address.

23 months agocore: Fix identify for armored detached sigs
Andre Heinecke [Fri, 1 Jul 2016 08:56:57 +0000 (10:56 +0200)]
core: Fix identify for armored detached sigs

* src/data-identify.c (basic_detection): Return signature for
signature.

--
This causes identify to return signature for both binary and
ascii armored detached signatures where previously it would
have returned signed for armored signatures and signature for
binary signatures.

GnuPG-Bug-Id: 2314

23 months agotests: Fix trivial memory leaks.
Justus Winter [Mon, 27 Jun 2016 15:56:18 +0000 (17:56 +0200)]
tests: Fix trivial memory leaks.

--
Signed-off-by: Justus Winter <justus@g10code.com>
23 months agoCpp: Expose new data_identify values
Andre Heinecke [Mon, 27 Jun 2016 13:50:01 +0000 (15:50 +0200)]
Cpp: Expose new data_identify values

* lang/cpp/src/data.cpp (GpgME::Data::type): Handle PGP Encrypted
 and Signature.
* lang/cpp/src/data.h: Add values accordingly.

23 months agoCpp: Do not treat KEYEXPIRED as error
Andre Heinecke [Mon, 27 Jun 2016 12:47:44 +0000 (14:47 +0200)]
Cpp: Do not treat KEYEXPIRED as error

* lang/cpp/src/editinteractor.cpp (status_to_error): No error
for KEYEXPIRED.

--
As keyexpired status is sent even if a subkey is expired
we can not treat it as a global error.

23 months agotests: Add new test tool run-decrypt
Andre Heinecke [Fri, 24 Jun 2016 09:30:55 +0000 (11:30 +0200)]
tests: Add new test tool run-decrypt

* tests/run-decrypt.c: New.
* tests/Makefile.am (noinst_PROGRAMS): Add run-decrypt.

23 months agocore: Add closer inspection of "PGP MESSAGE".
Werner Koch [Thu, 23 Jun 2016 08:14:57 +0000 (10:14 +0200)]
core: Add closer inspection of "PGP MESSAGE".

* src/data-identify.c (inspect_pgp_message): New.
(basic_detection): Un-const arg DATA. Call inspect_pgp_message.

Signed-off-by: Werner Koch <wk@gnupg.org>
23 months agocore: Add a base 64 decoder.
Werner Koch [Thu, 23 Jun 2016 07:48:54 +0000 (09:48 +0200)]
core: Add a base 64 decoder.

* src/b64dec.c: New. Taken from gnupg.  Prefix function names with
_gpgme_ and change to use standard C malloc functions.
* src/util.h.h (struct b64state): New.
* src/Makefile.am (main_sources): Add file.

--

The file b64dec.c has been taken from gnupg commit
e430ff6ad0b7dcfcebd92b825dd5168205447ff3

Signed-off-by: Werner Koch <wk@gnupg.org>
23 months agocore: Detect compressed signed OpenPGP data.
Werner Koch [Wed, 22 Jun 2016 16:43:26 +0000 (18:43 +0200)]
core: Detect compressed signed OpenPGP data.

* src/data-identify.c (next_openpgp_packet): Allow partial encoding.
(pgp_binary_detection): Handle compressed packets.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
23 months agotests: Add new test tool run-identify.
Werner Koch [Tue, 21 Jun 2016 14:17:26 +0000 (16:17 +0200)]
tests: Add new test tool run-identify.

* src/gpgme-tool.c (gt_identify): Add new strings.
* tests/run-identify.c: New.
* tests/Makefile.am (noinst_PROGRAMS): Add run-identify.

Signed-off-by: Werner Koch <wk@gnupg.org>
23 months agocore: Enhance gpgme_data_identify to detect binary PGP messages.
Werner Koch [Tue, 21 Jun 2016 14:14:02 +0000 (16:14 +0200)]
core: Enhance gpgme_data_identify to detect binary PGP messages.

* src/gpgme.h.in (GPGME_DATA_TYPE_PGP_ENCRYPTED): New.
(GPGME_DATA_TYPE_PGP_SIGNATURE): New.
* src/data-identify.c: Add enum for OpenPGP packet types.
(buf32_to_ulong): New.
(next_openpgp_packet): New.  Based on the gnupg/kbx/keybox-openpgp.c
implementation and relicensed to LGPL by g10 Code.
(pgp_binary_detection): New.
(basic_detection): Call pgp_binary_detection instead of returning
unknown.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agopython: Improve autmatically generated docstrings.
Justus Winter [Tue, 14 Jun 2016 11:28:37 +0000 (13:28 +0200)]
python: Improve autmatically generated docstrings.

* lang/python/gpgme.i: Add comment.
* lang/python/pyme/core.py (__getattr__): Rewrite automatically
generated doctrings for the wrapper methods.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Make result objects more robust.
Justus Winter [Tue, 14 Jun 2016 15:33:12 +0000 (17:33 +0200)]
python: Make result objects more robust.

Results returned by the GPGME are fragile, i.e. they are only valid
until the next operation is performed in the context.

We cannot arbitrarily constrain the lifetime of Python objects, we
therefore create deep copies of the results.

* lang/python/gpgme.i (gpgme_tofu_info_t): Turn these into a list.
(gpgme_*_result_t): Create deep copies of these objects.
* lang/python/helpers.c (pygpgme_wrap_fragile_result): New function.
* lang/python/helpers.h (pygpgme_wrap_fragile_result): New prototype.
* lang/python/pyme/results.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Avoid creating SWIG proxy classes.
Justus Winter [Tue, 14 Jun 2016 11:48:33 +0000 (13:48 +0200)]
python: Avoid creating SWIG proxy classes.

* lang/python/Makefile.am (gpgme_wrap.c): Use '-builtin' to make SWIG
generate builtin types for c types.
* lang/python/gpgme.i (pygpgme_wrap_gpgme_data_t): Adapt slightly.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Simplify wrapping glue.
Justus Winter [Tue, 14 Jun 2016 10:37:26 +0000 (12:37 +0200)]
python: Simplify wrapping glue.

* lang/python/pyme/core.py: Rename '_getctype' to '_ctype' and turn it
  into a string.  Likewise rename '_getnameprepend' to '_cprefix'.
* lang/python/helpers.c: Adapt accordingly.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Rework callbacks.
Justus Winter [Mon, 13 Jun 2016 17:16:30 +0000 (19:16 +0200)]
python: Rework callbacks.

Simplify how the lifetime of callback arguments is managed.

* lang/python/gpgme.i (gpgme_edit_cb_t): Check arguments.
(PyObject_p_p, void_p_p): Drop rather dangerous interface.
(pygpgme_unwrap_gpgme_ctx_t): New function.
* lang/python/helpers.c (pygpgme_clear_generic_cb): Drop dangerous
function.
(pyPassphraseCb): Assert contract.
(pygpgme_set_passphrase_cb): Use Python's calling convention so that
we can raise exceptions.  Hand in 'self', get the wrapped object, and
simply store the hook data as attribute of the wrapper object.
(pyProgressCb, pygpgme_set_progress_cb): Likewise.
(pygpgme_set_status_cb): Likewise.
(pygpgme_data_new_from_cbs): Likewise.
* lang/python/helpers.h (pygpgme_clear_generic_cb): Drop prototype.
(pygpgme_set_passphrase_cb): Update prototype.
(pygpgme_set_progress_cb): Likewise.
(pygpgme_set_status_cb): Likewise.
(pygpgme_data_new_from_cbs): Likewise.
(pygpgme_unwrap_gpgme_ctx_t): New prottotype.
* lang/python/pyme/core.py (Context, Data): Update callsites.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Wrap objects implementing the buffer protocol.
Justus Winter [Wed, 8 Jun 2016 15:56:33 +0000 (17:56 +0200)]
python: Wrap objects implementing the buffer protocol.

* lang/python/Makefile.am: Add the toplevel source directory to CFLAGS
when compiling the bindings so that we can use private header files.
* lang/python/gpgme.i (gpgme_data_t): Rework the object wrapping.  Do
not create a Python wrapper object, merely a gpgme_data_t object, and
keep references to buffer objects, if any.  If necessary, update the
buffer after the function call.
(pygpgme_wrap_gpgme_data_t): New function.
* lang/python/helpers.c (object_to_gpgme_data_t): Rework object
wrapping.  Also wrap objects implementing the buffer protocol.
* lang/python/helpers.h (object_to_gpgme_data_t): Update prototype.
(pygpgme_wrap_gpgme_data_t): New prototype.
* lang/python/tests/t-idiomatic.py: Demonstrate this.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Add properties to wrapped object.
Justus Winter [Fri, 10 Jun 2016 11:00:33 +0000 (13:00 +0200)]
python: Add properties to wrapped object.

* lang/python/pyme/core.py (GpgmeWrapper.__repr__): Saner
representation.
(GpgmeWrapper.__str__): Construct a nicer human readable string.
(GpgmeWrapper._boolean_properties): New field.
(GpgmeWrapper.__wrap_boolean_property): New function.
(GpgmeWrapper.__getattr__): Wrap functions using properties.
(GpgmeWrapper.__setattr__): New method.  Likewise wrap functions.
(Context.signers): New property.
(Context.pinentry_mode): Likewise.
(Context._boolean_properties): List boolean properties.
(Context.__init__): Add keyword arguments for properties and apply
them.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Improve the documentation.
Justus Winter [Mon, 6 Jun 2016 12:08:59 +0000 (14:08 +0200)]
python: Improve the documentation.

* lang/python/Makefile.am: Copy the README file.
* lang/python/README: Rename, convert to org, and update.
* lang/python/pyme/__init__.py: Move license out of the docstring,
update docstring.
* lang/python/pyme/core.py: Add and update docstrings.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Get version information from the build system.
Justus Winter [Thu, 9 Jun 2016 10:38:50 +0000 (12:38 +0200)]
python: Get version information from the build system.

* configure.ac: Generate 'setup.py' and 'version.py'.
* lang/python/Makefile.am: Use generated setup script.
* lang/python/pyme/version.py: Turn it into a template, and get
version information from the build system.  Also drop some variables.
* lang/python/setup.py: Likewise.  This way we can avoid importing the
version module, which is frowned upon and actually caused a problem.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Fix exception leak.
Justus Winter [Mon, 13 Jun 2016 16:35:47 +0000 (18:35 +0200)]
python: Fix exception leak.

* lang/python/helpers.c (pygpgme_stash_callback_exception): Fix leak.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Fix license.
Justus Winter [Tue, 14 Jun 2016 14:54:26 +0000 (16:54 +0200)]
python: Fix license.

Other parts of the build system are also LGPLed.

* lang/python/Makefile.am: Fix license.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agocore: Make sure FD_SET is not used with an out of range fd.
Werner Koch [Tue, 14 Jun 2016 06:35:12 +0000 (08:35 +0200)]
core: Make sure FD_SET is not used with an out of range fd.

* src/posix-io.c (_gpgme_io_select): Check for FD out of range.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agopython: Improve error handling.
Justus Winter [Wed, 8 Jun 2016 16:06:24 +0000 (18:06 +0200)]
python: Improve error handling.

* lang/python/helpers.c (pyPassphraseCb): Handle write errors.
(pyEditCb): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Add function to raise exceptions from c.
Justus Winter [Wed, 8 Jun 2016 15:54:45 +0000 (17:54 +0200)]
python: Add function to raise exceptions from c.

* lang/python/helpers.c (pygpgme_raise_exception): New function.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Fix stripping deprecated functionality.
Justus Winter [Wed, 8 Jun 2016 14:51:35 +0000 (16:51 +0200)]
python: Fix stripping deprecated functionality.

* lang/python/Makefile.am (gpgme.h): Add script as input.
* lang/python/gpgme-h-clean.py (deprec_func): Also match struct
members.
(line_break): Fix matching on struct members.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Fix type.
Justus Winter [Wed, 8 Jun 2016 15:04:02 +0000 (17:04 +0200)]
python: Fix type.

* lang/python/gpgme.i: Use correct Python type for size.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Implement the context manager protocol.
Justus Winter [Tue, 7 Jun 2016 17:31:10 +0000 (19:31 +0200)]
python: Implement the context manager protocol.

* lang/python/pyme/core.py (Context.__del__): Make function
idemptotent.
(Context.{__enter__,__exit__}): Implement the context manager
protocol.
(Data.__del__): Make function idemptotent, drop debug print.
(Data.{__enter__,__exit__}): Implement the context manager
protocol.
* lang/python/tests/t-idiomatic.py: Demonstrate this.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Fix error handling.
Justus Winter [Tue, 7 Jun 2016 14:07:33 +0000 (16:07 +0200)]
python: Fix error handling.

* lang/python/gpgme.i: Fix freeing an uninitialized pointer in the
error handling of generated wrapper functions by explicitly storing
the pointer in a local variable which can be initialized.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Wrap file-like objects on demand.
Justus Winter [Mon, 6 Jun 2016 11:11:15 +0000 (13:11 +0200)]
python: Wrap file-like objects on demand.

* lang/python/gpgme.i (gpgme_data_t): Use new function to create
wrapper objects if necessary, and deallocate them after the function
call.
* lang/python/helpers.c (object_to_gpgme_data_t): New function.
* lang/python/helpers.h (object_to_gpgme_data_t): New prototype.
* lang/python/tests/Makefile.am (pytests): Add new test.
* lang/python/tests/t-idiomatic.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Move helper function.
Justus Winter [Thu, 2 Jun 2016 15:14:53 +0000 (17:14 +0200)]
python: Move helper function.

* lang/python/gpgme.i (object_to_gpgme_t): Move...
* lang/python/helpers.c: ... here.
* lang/python/helpers.h (object_to_gpgme_t): New prototype.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Fix error handling.
Justus Winter [Thu, 2 Jun 2016 13:32:35 +0000 (15:32 +0200)]
python: Fix error handling.

* lang/python/gpgme.i (object_to_gpgme_t): Properly propagate
exceptions.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Initialize GPGME for the user.
Justus Winter [Thu, 2 Jun 2016 13:18:40 +0000 (15:18 +0200)]
python: Initialize GPGME for the user.

* lang/python/pyme/core.py: Call 'check_version' and explain why.
* lang/python/tests/support.py (init_gpgme): Drop call here.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Drop obsolete VCS keywords.
Justus Winter [Mon, 6 Jun 2016 12:12:09 +0000 (14:12 +0200)]
python: Drop obsolete VCS keywords.

--
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Fix test suite with GnuPG prior to 2.1.12.
Justus Winter [Wed, 1 Jun 2016 13:40:49 +0000 (15:40 +0200)]
python: Fix test suite with GnuPG prior to 2.1.12.

* lang/python/tests/Makefile.am (gpg-agent.conf): Use
'allow-loopback-pinentry'.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Make Python detection more robust.
Justus Winter [Wed, 1 Jun 2016 13:33:52 +0000 (15:33 +0200)]
python: Make Python detection more robust.

Previously, missing Python development packages made configure fail
instead of merely disabling the bindings.

* configure.ac: Check for 'PYTHON_VERSION'.
* m4/ax_python_devel.m4: Make test non-fatal.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopython: Improve build system integration, fix warnings.
Justus Winter [Wed, 1 Jun 2016 12:16:27 +0000 (14:16 +0200)]
python: Improve build system integration, fix warnings.

* lang/python/Makefile.am: Pass CFLAGS to python build system.
* lang/python/helpers.c (pyPassphraseCb): Use correct type for length.
(pygpgme_data_new_from_cbs): Drop unused variable.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoCpp: Use whitelist for status messages
Andre Heinecke [Wed, 1 Jun 2016 11:46:27 +0000 (13:46 +0200)]
Cpp: Use whitelist for status messages

* lang/cpp/src/editinteractor.cpp (EditInteractor::needsNoResponse):
Use whitelist instead of blacklist.

--
This should be more robust when new status messages are added.
The whitelist is the same GPA uses. Fixes Qt's t-ownertrust.

2 years agoQt: Fix debug output in t-ownertrust
Andre Heinecke [Wed, 1 Jun 2016 08:01:43 +0000 (10:01 +0200)]
Qt: Fix debug output in t-ownertrust

* lang/qt/tests/t-ownertrust.cpp (testChangeOwnerTrust): Remove
general debug of trust level. Add debug output for error.

2 years agotests: Fix notation tests.
Justus Winter [Wed, 1 Jun 2016 10:50:32 +0000 (12:50 +0200)]
tests: Fix notation tests.

* lang/python/tests/t-sig-notation.py (check_result): Check critical
flag.
* tests/gpg/t-sig-notation.c (check_result): Likewise.

Fixes-commit: 1cacd7d0
Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agocore: Set notation flags for verify.
Werner Koch [Wed, 1 Jun 2016 09:10:30 +0000 (11:10 +0200)]
core: Set notation flags for verify.

* src/gpgme.h.in (GPGME_STATUS_NOTATION_FLAGS): New.
* src/status-table.c (status_table): Add new status.
* src/verify.c (parse_notation): Handle flags.  Also fix NOTATION_DATA
in case gpg would not percent-escape spaces.
(_gpgme_verify_status_handler): Handle flags.
* tests/run-verify.c (print_result): Print notaion data.
--

Note that this does only work with the soon to be released GnuPG
2.1.13.

2 years agopython: use GPG_ERROR_CONFIG variable
Tobias Mueller [Tue, 31 May 2016 12:41:12 +0000 (14:41 +0200)]
python: use GPG_ERROR_CONFIG variable

instead of calling gpg-error-config.
This is useful when configuring with --with-gpgerror-prefix
because then GPG_ERROR_CONFIG contains the correct
/path/to/bin/gpg-error-config whereas calling gpg-error-config
directly would look in the user's PATH (and not in the prefix
where gpg-error-config was installed).

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agopython: Port more tests.
Justus Winter [Tue, 31 May 2016 14:21:06 +0000 (16:21 +0200)]
python: Port more tests.

* lang/python/gpgme.i: Hide length fields of notations.
* lang/python/tests/Makefile.am (pytests): Add new tests.
* lang/python/tests/t-decrypt-verify.py: New file.
* lang/python/tests/t-sig-notation.py: Likewise.
* lang/python/tests/t-verify.py: Likewise.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agobuild: Fix URL.
Justus Winter [Tue, 31 May 2016 09:01:36 +0000 (11:01 +0200)]
build: Fix URL.

--
Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agoSpeedup closing of fds before exec.
Werner Koch [Fri, 27 May 2016 20:19:35 +0000 (22:19 +0200)]
Speedup closing of fds before exec.

* src/posix-io.c [__linux__]: Include dirent.h.
(get_max_fds) [__linux__]: Try to figure out the highest used fd.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agopython: Port more tests.
Justus Winter [Fri, 27 May 2016 13:58:23 +0000 (15:58 +0200)]
python: Port more tests.

* lang/python/pyme/core.py (Data._error_check): Add
'gpgme_data_get_file_name' to the list of functions not returning an
error code.
* lang/python/tests/Makefile.am (pytests): Add new tests.
* lang/python/tests/support.py (verbose): New variable.
* lang/python/tests/t-data.py: Test setting and getting the filename.
* lang/python/tests/t-encrypt-large.py: New file.
* lang/python/tests/t-file-name.py: Likewise.
* lang/python/tests/t-trustlist.py: Likewise.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agosrc: Fix typo.
Justus Winter [Fri, 27 May 2016 13:46:17 +0000 (15:46 +0200)]
src: Fix typo.

--
Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agotests: Fix test.
Justus Winter [Fri, 27 May 2016 13:27:55 +0000 (15:27 +0200)]
tests: Fix test.

--
Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agopython: Implement data callbacks.
Justus Winter [Fri, 27 May 2016 12:04:28 +0000 (14:04 +0200)]
python: Implement data callbacks.

* lang/python/gpgme.i (object_to_gpgme_t): Set exception on error.
* lang/python/helpers.c (pyDataReadCb): New function.
(pyDataWriteCb): Likewise.
(pyDataSeekCb): Likewise.
(pyDataReleaseCb): Likewise.
(pygpgme_data_new_from_cbs): Likewise.
* lang/python/helpers.h (pygpgme_data_new_from_cbs): New prototype.
* lang/python/pyme/core.py (Data.__init__): Fix docstring, fix read
callbacks.
(Data.__del__): Fix read callbacks.
(Data._free_readcb): Drop function.
(Data._free_datacbs): New function.
(Data.new_from_cbs): Fix setting the callbacks.
(Data.write): Raise stashed exceptions.
(Data.read): Likewise.
* lang/python/tests/t-callbacks.py: Test new functionality.
* lang/python/tests/t-data.py: Likewise.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agopython: Fix object deallocation.
Justus Winter [Fri, 27 May 2016 10:25:59 +0000 (12:25 +0200)]
python: Fix object deallocation.

Handing a reference to the wrapper object created a non-trivial
circular reference that Pythons garbage collector is unable to break.
Explicitly break it by using a weak reference.

* lang/python/helpers.c (pygpgme_stash_callback_exception): Retrieve
object from weak reference.
* lang/python/pyme/core.py (Context.__del__): Free status callback.
(Context.set_passphrase_cb): Use a weak reference.
(Context.set_progress_cb): Likewise.
(Context.set_status_cb): Likewise.
(Context.op_edit): Likewise.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agoImprove comments.
Justus Winter [Fri, 27 May 2016 10:19:52 +0000 (12:19 +0200)]
Improve comments.

* src/gpgme.h.in (gpgme_data_seek_cb_t, gpgme_data_seek): Clarify that
these functions return the new offset.
(gpgme_data_release_cb_t): Fix name of parameter.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agopython: Fix reading data from existing files.
Justus Winter [Wed, 25 May 2016 10:47:28 +0000 (12:47 +0200)]
python: Fix reading data from existing files.

* lang/python/pyme/core.py (Data.__init__): Add 'copy' kwargument, and
pass it to functions supporting it.  PEP8 fix.
(Data.new_from_fd): PEP8 fix.
(Data.new_from_file): Give a more helpful error message if copy is
False.  PEP8 fix.
(Data.new_from_fd): Hand the file descriptor to
'gpgme_data_new_from_fd', not a stream.  Fix docstring.
* lang/python/tests/t-data.py: Add tests for this.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agosrc: Fix trace string.
Justus Winter [Wed, 25 May 2016 10:45:25 +0000 (12:45 +0200)]
src: Fix trace string.

* src/data-compat.c (gpgme_data_new_from_file): Fix trace string.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agopython: Improve and test Context.wait.
Justus Winter [Tue, 24 May 2016 15:57:10 +0000 (17:57 +0200)]
python: Improve and test Context.wait.

* lang/python/pyme/core.py (Context.wait): Improve docstring.  As the
context passed to 'gpgme_wait' is never NULL, it is pointless to look
at the returned context.  Always raise exceptions.
* lang/python/tests/Makefile.am (pytests): Add new test.
* lang/python/tests/t-wait.py: New file.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agopython: Make all GnuPG errors available.
Justus Winter [Tue, 24 May 2016 15:22:08 +0000 (17:22 +0200)]
python: Make all GnuPG errors available.

* lang/python/Makefile.am (errors.i): Generate file.
* lang/python/gpgme.i: Include generated file.
* lang/python/pyme/errors.py: Pull in all errors and error sources.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agopython: Move the base wrapper class.
Justus Winter [Tue, 24 May 2016 14:45:39 +0000 (16:45 +0200)]
python: Move the base wrapper class.

* python/lang/pyme/util.py (GpgmeWrapper): Move...
* python/lang/pyme/core.py: ... here.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agopython: Support status callbacks.
Justus Winter [Tue, 24 May 2016 13:14:53 +0000 (15:14 +0200)]
python: Support status callbacks.

* lang/python/helpers.c (pyStatusCb): New function.
(pygpgme_set_status_cb): Likewise.
* lang/python/helpers.h (pygpgme_set_status_cb): New prototype.
* lang/python/pyme/core.py (Context.__init__): Initialize
'last_statuscb'.
(Context._free_statuscb): New function.
(Context.set_status_cb): Likewise.
* lang/python/tests/t-callbacks.py: Test status callbacks.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agopython: Improve docstring.
Justus Winter [Tue, 24 May 2016 13:12:40 +0000 (15:12 +0200)]
python: Improve docstring.

* lang/python/pyme/core.py (Context.set_progress_cb): Improve
docstring.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agoQt: Fix test build with clang
Andre Heinecke [Tue, 24 May 2016 14:00:42 +0000 (16:00 +0200)]
Qt: Fix test build with clang

* lang/qt/tests/Makefile.am (LDADD): Explicitly add -lstdc++

--
g++ does not need that but clang does need it explicitly

2 years agoCpp: Set -std=c++11 also if CXXCPP is already set
Andre Heinecke [Tue, 24 May 2016 12:10:16 +0000 (14:10 +0200)]
Cpp: Set -std=c++11 also if CXXCPP is already set

* m4/ax_cxx_compile_stdxx.m4 (AX_CXX_COMPILE_STDCXX): Set CXXCPP if
neccessary.

--
This fixes the build with scan-build where CXXCPP is already set but
does not include stdc++11. While this deviates from the
autotools-archive version of the script it does not make sense
to me first to check if stdc++11 needs to be set and then not
set it.

2 years agopython: Improve support for edit callbacks.
Justus Winter [Tue, 24 May 2016 10:29:32 +0000 (12:29 +0200)]
python: Improve support for edit callbacks.

* lang/python/helpers.c (pyEditCb): Stash exceptions.
* lang/python/pyme/core.py (Context.op_edit): Hand in 'self'.
* lang/python/tests/Makefile.am (py_tests): Add new test.
* lang/python/tests/t-callbacks.py: Test edit callbacks.
* lang/python/tests/t-edit.py: New file.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agopython: Fix hook.
Justus Winter [Mon, 23 May 2016 16:23:34 +0000 (18:23 +0200)]
python: Fix hook.

* lang/python/helpers.c (pyProgressCb): Fix getting hook data.
* lang/python/tests/t-callbacks.py: Show that this works.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agopython: Move edit callback function.
Justus Winter [Mon, 23 May 2016 16:09:22 +0000 (18:09 +0200)]
python: Move edit callback function.

* lang/python/gpgme.i (pyEditCb): Move...
* lang/python/helpers.c: ... here.
* lang/python/helpers.h (pyEditCb): New prototype.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agopython: Port more tests.
Justus Winter [Mon, 23 May 2016 13:42:14 +0000 (15:42 +0200)]
python: Port more tests.

* lang/python/tests/Makefile.am (TESTS_ENVIRONMENT): Set
LD_LIBRARY_PATH.
(pytests): Add new tests.
* lang/python/tests/t-callbacks.py: Trim imports.
* lang/python/tests/t-encrypt-sign.py: New file.
* lang/python/tests/t-export.py: Likewise.
* lang/python/tests/t-signers.py: Likewise.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agopython: Translate list of strings.
Justus Winter [Mon, 23 May 2016 13:41:06 +0000 (15:41 +0200)]
python: Translate list of strings.

* lang/python/gpgme.i: Add typemap translating list of strings.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agoapi: Return Tofu info for signatures.
Werner Koch [Sat, 21 May 2016 08:29:49 +0000 (10:29 +0200)]
api: Return Tofu info for signatures.

* src/gpgme.h.in (gpgme_tofu_policy_t): New.
(gpgme_status_code_t): Add status codes for TOFU.
(struct _gpgme_tofu_info, gpgme_tofu_info_t): New.
(struct _gpgme_signature): Add field 'tofu'.
* src/status-table.c (status_table): Add new codes.
* src/verify.c: Include limits.h.
(release_tofu_info): New.
(release_op_data): Call that.
(parse_tofu_user): New.
(parse_tofu_stats): New.
(parse_tofu_stats_long): New.
(_gpgme_verify_status_handler): Handle TOFU status lines.

* tests/run-verify.c (print_description): New.
(print_result): print tofu info.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agoapi: Add new context flag "raw-description".
Werner Koch [Sat, 21 May 2016 08:22:57 +0000 (10:22 +0200)]
api: Add new context flag "raw-description".

* src/context.h (struct gpgme_context): Add field raw_description.
* src/gpgme.c (gpgme_set_ctx_flag): New flag.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agocore: New functions to help parsing of status lines.
Werner Koch [Sat, 21 May 2016 08:21:06 +0000 (10:21 +0200)]
core: New functions to help parsing of status lines.

* src/conversion.c (_gpgme_split_fields): New.
(_gpgme_strtoul_field): New.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agoQt: Add test for changeownertrust
Andre Heinecke [Fri, 20 May 2016 14:04:50 +0000 (16:04 +0200)]
Qt: Add test for changeownertrust

* lang/qt/tests/t-ownertrust.cpp: New test.
* lang/qt/tests/Makefile.am: Add test.

--
This test would have catched the issue created by not handling
GPGME_STATUS_KEY_CONSIDERED.

2 years agoCpp: Ignore STATUS_KEY_CONSIDERED when editing
Andre Heinecke [Fri, 20 May 2016 14:03:08 +0000 (16:03 +0200)]
Cpp: Ignore STATUS_KEY_CONSIDERED when editing

* lang/cpp/src/editinteractor.cpp (EditInteractor::needsNoResponse):
Handle GPGME_STATUS_KEY_CONSIDERED.

2 years agoapi: Add new function gpgme_set_ctx_flag.
Werner Koch [Thu, 19 May 2016 15:01:07 +0000 (17:01 +0200)]
api: Add new function gpgme_set_ctx_flag.

* src/gpgme.h.in (gpgme_set_ctx_flag): New prototype.
* src/gpgme.c (gpgme_set_ctx_flag): New.
* src/gpgme.def, src/libgpgme.vers: Add new function.
* src/context.h (struct gpgme_context): Add FULL_STATUS.
* src/decrypt.c (_gpgme_decrypt_status_handler): Do not call the
  status callback if FULL_STATUS is set.
* src/genkey.c (genkey_status_handler): Ditto.
* src/passphrase.c (_gpgme_passphrase_status_handler): Ditto.
* src/sign.c (_gpgme_sign_status_handler): Ditto.

* src/engine-backend.h (struct engine_ops): Add SET_STATUS_CB and add
adjust all definitions of that variable.
* src/engine.c (_gpgme_engine_set_status_cb): New.
* src/op-support.c (_gpgme_op_reset): Call this function.

* src/engine-gpg.c (struct engine_gpg): Add fields MON_CB and
MON_CB_VALUE.
(gpg_set_status_cb): New.
(_gpgme_engine_ops_gpg): Register that function.
(read_status): Call the monitor callback.

* src/engine-gpgsm.c (struct engine_gpgsm): Add fields MON_CB and
MON_CB_VALUE.
(_gpgme_engine_ops_gpgsm): Register that function.
(gpgsm_assuan_simple_command): Change first arg to be an engine
context and adjust call callers.  Call the monitor callback.

* src/engine-uiserver.c (struct engine_uiserver): Add fields MON_CB
and MON_CB_VALUE.
(_gpgme_engine_ops_uiserver): Register that function.
(uiserver_assuan_simple_command): Change first arg to be an engine
context and adjust call callers.  Call the monitor callback.

* tests/run-verify.c (status_cb): New.
(print_result): Print algo names.
(main): Add option --status.
--

This new feature is mainly intended for bug tracking.  Having access
to the raw status lines might also be useful for applications, though.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agoapi: Remove arbitrary restriction from gpgme_op_verify.
Werner Koch [Thu, 19 May 2016 12:26:22 +0000 (14:26 +0200)]
api: Remove arbitrary restriction from gpgme_op_verify.

* src/verify.c (verify_start): Do not return GPG_ERR_INV_VALUES when
when SIGNED_TEXT is not given.
--

The original idea behind this restriction probably was that it is
useless to verify a non-detached signatures without also returning the
signed text.  However, it is sometimes useful to just check the
signature, for example to see who signed it.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agopython: Improve progress callbacks.
Justus Winter [Thu, 19 May 2016 13:53:19 +0000 (15:53 +0200)]
python: Improve progress callbacks.

* lang/python/helpers.c (pyProgressCb): Stash python errors, convert
'what' to Unicode object.
* lang/python/pyme/core.py (Context.set_progress_cb): Hand in 'self'.
* lang/python/tests/t-callbacks.py: Test progress callbacks.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agopython: Robust exception handling in callbacks.
Justus Winter [Thu, 19 May 2016 09:03:27 +0000 (11:03 +0200)]
python: Robust exception handling in callbacks.

* lang/python/helpers.c (pygpgme_stash_callback_exception): New
function.
(pygpgme_raise_callback_exception): Likewise.
(pyPassphraseCb): Stash python errors.
* lang/python/helpers.h (pygpgme_raise_callback_exception): New
prototype.
* lang/python/pyme/core.py ({Context,Data}.__init__): Move common
initialization to superclass.
(Context.set_progress_cb): Hand in 'self'.
* lang/python/pyme/util.py (GpgmeWrapper.__init__): New function.
(GpgmeWrapper.__getattr__): Raise stashed exceptions.
* lang/python/tests/Makefile.am (py_tests): Add new test.
* lang/python/tests/t-callbacks.py: New file.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agoQt: Check for graphviz and set HAVE_DOT correctly
Andre Heinecke [Thu, 19 May 2016 09:14:24 +0000 (11:14 +0200)]
Qt: Check for graphviz and set HAVE_DOT correctly

* configure.ac: Check for graphviz and define HAVE_DOT.
* lang/qt/doc/Doxyfile.in (HAVE_DOT): Use variable.

2 years agopython: Add more tests.
Justus Winter [Wed, 18 May 2016 13:33:36 +0000 (15:33 +0200)]
python: Add more tests.

* lang/python/tests/Makefile.am (py_tests): Add new tests.
* lang/python/tests/support.py (print_data): New function.
* lang/python/tests/t-decrypt.py: Use new function.
* lang/python/tests/t-encrypt.py: Likewise.
* lang/python/tests/t-sign.py: New file.
* lang/python/tests/t-encrypt-sym.py: Likewise.

Signed-off-by: Justus Winter <justus@gnupg.org>
2 years agopython: More type conversion fixes.
Justus Winter [Thu, 19 May 2016 08:55:34 +0000 (10:55 +0200)]
python: More type conversion fixes.

* lang/python/helpers.c (pyPassphraseCb): Cope with 'uid_hint' being
NULL, convert it to an Unicode object, and cope with the callback
returning both Unicode and bytes objects.

Signed-off-by: Justus Winter <justus@gnupg.org>