Commit Graph

174 Commits

Author SHA1 Message Date
Andre Heinecke
537cb871fd Cpp: Add feature enum for new identify
* lang/cpp/src/context.cpp (supported_features2): Add
BinaryAndFineGrainedIdentify
* lang/cpp/src/global.h (Feature2): ditto.

--
This is mostly for compatible code with KF5::Gpgmepp where there
is no hard requirement against gpgme 1.7. With 1.7 a version
check would also suffice.
2016-07-13 11:56:18 +02:00
Justus Winter
1bff47ee58 python: Port more tests.
* lang/python/pyme/core.py (Context.op_keylist_all): Add missing
'op_keylist_end'.
(Context.op_trustlist_all): Fix function. Add missing
'op_trustlist_end'.
* lang/python/tests/Makefile.am (pytests): Add new files.
* lang/python/tests/t-import.py: New file.
* lang/python/tests/t-keylist.py: Likewise.
* lang/python/tests/t-trustlist.py: Check alternate interface.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-12 18:34:12 +02:00
Justus Winter
57b5168552 python: Improve python packaging.
* lang/python/Makefile.am: Sign source releases, and upload them.
* lang/python/setup.py.in: Add categories.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-12 18:34:12 +02:00
Andre Heinecke
fd87c4679c Qt: Install CamelCase forward includes
* lang/qt/src/Makefile.am (camelcase_headers): New. Create and install
CamelCase headers.

--
For Qt Libraries it is a common pattern that headers are installed
additionally under their Namespace / Class Name so that automated
inclusion works once a class is used in code. This was also
done for QGpgME headers when they lived in Libkleo so this increases
compatibility.
2016-07-12 11:47:33 +02:00
Andre Heinecke
86ab2ee2d6 Qt: Export VerifyDetachedJob
* lang/qt/src/verifydetachedjob.h (VerifyDetachedJob): Export it.
2016-07-12 11:47:04 +02:00
Andre Heinecke
b03c48cfb0 Qt/Cpp: Add version headers
* lang/cpp/src/gpgmepp_version.h.in,
lang/qt/src/qgpgme_version.h.in: New. Version information.
* lang/qt/src/Makefile.am, lang/cpp/src/Makefile.am: Add them.
* configure.ac: Configure them.

--
The version headers are common practice in KDE Frameworks and
were installed for KF5Gpgmepp and Libkleo respectively.
2016-07-12 11:35:39 +02:00
Andre Heinecke
362b8cdf4e Qt/Cpp: Add license blurb to export headers
* lang/cpp/src/gpgmepp_export.h,
lang/qt/src/qgpgme_export.h: Add license blurb.
2016-07-12 11:35:39 +02:00
Justus Winter
ce66289137 python: Fix distcheck.
* lang/python/Makefile.am (EXTRA_DIST): Add missing files.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-11 19:42:56 +02:00
Justus Winter
007382ce94 python: Enable out-of-tree build of pyme bindings.
* lang/python/MANIFEST.in: Update manifest template.
* lang/python/Makefile.am: Copy more files, move generation of files
to Python build script, add 'sdist' target to build a Python source
distribution.
* lang/python/gpgme-h-clean.py: Add code to build 'errors.i'.
* lang/python/setup.py.in: Generate files, enable out-of-tree builds.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-11 18:09:54 +02:00
Justus Winter
98cba522c9 python: Do not depend on access to internal data structures.
* lang/python/gpgme.i (gpgme_data_t): Rework so that it works without
access to the definition of 'struct gpgme_data'.
* lang/python/helpers.c (object_to_gpgme_data_t): Add assertion.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-11 17:50:58 +02:00
Justus Winter
c53f87c5f9 python: Make result wrapping backwards compatible.
* lang/python/pyme/results.py (Result.__init__): Skip missing fields.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-11 17:50:58 +02:00
Andre Heinecke
bfa8ac7e02 Qt: Fix memleaks in tests
* lang/qt/tests/t-keylist.cpp(cleanupTestCase): Ensure that
posted events are handled for autodeletion.
(testSingleKeylistSync): delete job.
* lang/qt/tests/t-ownertrust.cpp(cleanupTestCase): Ditto
* lang/qt/tests/t-ownertrust.cpp(testChangeOwnerTrust): Delete
keylistjobs.
* lang/qt/tests/t-keylocate.cpp(cleanupTestCase): Ditto
2016-07-11 16:51:58 +02:00
Andre Heinecke
b1f42e8f25 Qt: Add some general Protocol documentation
* lang/qt/src/protocol.h (Protocol): Add doc.

--
This explicitly documents that syncs run with exec need deletion.
2016-07-11 16:47:07 +02:00
Andre Heinecke
02babb2961 Qt: Disable t-tofuinfo tests
* lang/qt/tests/t-tofuinfo.cpp: Disable tests.

--
Even with the wait this test could fail and anyway the delay
was not nice. So we remove the wait hack and just wait for
the bug (2405) to be fixed in GnuPG or GpgME core.
2016-07-11 12:03:16 +02:00
Justus Winter
8a93f345b7 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>
2016-07-08 11:45:08 +02:00
Justus Winter
52efcf1ee9 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>
2016-07-07 14:10:36 +02:00
Justus Winter
38c408560c 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>
2016-07-07 13:56:37 +02:00
Justus Winter
49286ac1c8 cpp: Fix distcheck.
* lang/cpp/src/Makefile.am (CLEANFILES): Remove generated file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-07 13:56:37 +02:00
Andre Heinecke
fc02672332 Qt: Add test for publicKeyAlgorithmAsString
* lang/qt/tests/t-keylist.cpp (testPubkeyAlgoAsString): New.
2016-07-06 15:09:16 +02:00
Andre Heinecke
e41ae4db9e 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.
2016-07-06 15:07:34 +02:00
Andre Heinecke
9f93346d21 Qt: Add check for pubkeyAlgo in t-keylist
* lang/qt/tests/t-keylist.cpp (testSingleKeyListSync): Check
pubkeyAlgo.
2016-07-06 13:39:43 +02:00
Andre Heinecke
c28007d040 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.
2016-07-06 13:38:20 +02:00
Andre Heinecke
4934893e27 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++.
2016-07-06 11:28:11 +02:00
Andre Heinecke
7a8c04f66d 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 47bfbc9026 as
it causes problems depending on the include path. The proper
fix will be to ensure that cpp/src is included before gpgme/src.
2016-07-06 11:22:10 +02:00
Andre Heinecke
49a6ee5058 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
2016-07-05 22:11:42 +02:00
Andre Heinecke
47bfbc9026 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.
2016-07-05 22:10:18 +02:00
Andre Heinecke
8fa9b5696c 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
2016-07-04 11:44:39 +02:00
Andre Heinecke
efb5059b9b 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
2016-07-04 11:44:39 +02:00
Andre Heinecke
80498ab662 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.
2016-07-04 11:44:39 +02:00
Andre Heinecke
d75c118aae 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.
2016-07-04 11:44:38 +02:00
Andre Heinecke
fbd6ac4655 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
2016-07-01 16:55:14 +02:00
Andre Heinecke
93c5d420fc 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.
2016-07-01 16:52:34 +02:00
Andre Heinecke
15fc5c34c8 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.
2016-06-27 15:50:01 +02:00
Andre Heinecke
82d484c852 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.
2016-06-27 14:47:44 +02:00
Justus Winter
8997d88bf9 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>
2016-06-16 14:19:17 +02:00
Justus Winter
a324d0cffe 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>
2016-06-16 14:19:17 +02:00
Justus Winter
856bcfe293 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>
2016-06-16 14:19:17 +02:00
Justus Winter
6641c7814b 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>
2016-06-16 14:19:17 +02:00
Justus Winter
f3618bc615 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>
2016-06-16 14:19:17 +02:00
Justus Winter
616929b6ed 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>
2016-06-16 14:19:17 +02:00
Justus Winter
5464060bae 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>
2016-06-16 14:19:17 +02:00
Justus Winter
5492853d7b 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>
2016-06-16 14:07:41 +02:00
Justus Winter
7eef399d89 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>
2016-06-16 14:07:41 +02:00
Justus Winter
a852f99a0a python: Fix exception leak.
* lang/python/helpers.c (pygpgme_stash_callback_exception): Fix leak.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-16 14:07:41 +02:00
Justus Winter
3bacce03e6 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>
2016-06-16 14:07:41 +02:00
Justus Winter
77d149e861 python: Improve error handling.
* lang/python/helpers.c (pyPassphraseCb): Handle write errors.
(pyEditCb): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-08 18:12:35 +02:00
Justus Winter
5ebc205439 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>
2016-06-08 17:54:45 +02:00
Justus Winter
8426304b67 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>
2016-06-08 17:12:00 +02:00
Justus Winter
990492ea4f python: Fix type.
* lang/python/gpgme.i: Use correct Python type for size.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-08 17:12:00 +02:00
Justus Winter
e3c5913a33 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>
2016-06-08 13:44:09 +02:00