gpgme.git
17 months agoMerge branch 'master' into ben-minor-fixes ben/minor-docs-fixes
Ben McGinnes [Wed, 17 Aug 2016 03:14:44 +0000 (13:14 +1000)]
Merge branch 'master' into ben-minor-fixes

17 months agocore: New global flag "require-gnupg".
Werner Koch [Tue, 16 Aug 2016 16:53:42 +0000 (18:53 +0200)]
core: New global flag "require-gnupg".

* src/gpgme.c (gpgme_set_global_flag): Add flag.
* src/engine.c (engine_minimal_version): New variable.
(_gpgme_set_engine_minimal_version): New function.
(gpgme_get_engine_info): Check that flag.

* tests/run-keylist.c (main): New option --require-gnupg.

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agocore: Simplify setting of dummy versions.
Werner Koch [Tue, 16 Aug 2016 16:49:11 +0000 (18:49 +0200)]
core: Simplify setting of dummy versions.

* src/engine.c (_gpgme_engine_info_release): Do not assert but free
FILE_NAME.
(gpgme_get_engine_info): Provide default for VERSION and REQ_VERSION.
Use calloc instead of malloc.
(_gpgme_set_engine_info): Ditto.
* src/engine-assuan.c (llass_get_version): Return NULL.
(llass_get_req_version): Ditto.
* src/engine-spawn.c (engspawn_get_version): Ditto.
(engspawn_get_req_version): Ditto.
* src/engine-uiserver.c (uiserver_get_version): Ditto.
(uiserver_get_req_version): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agoTODO stuff
Ben McGinnes [Tue, 16 Aug 2016 16:16:41 +0000 (02:16 +1000)]
TODO stuff

* Expanded the documentation section to reflect the quandary with
  quality documentation.

17 months agoHistorical Record
Ben McGinnes [Tue, 16 Aug 2016 16:11:12 +0000 (02:11 +1000)]
Historical Record

* Minor grammatical fixes.
* Added paragraph on Justus' updates.
* Rewrote PyPI section as it is now available there (as pyme3).

17 months agoSpelling fix
Ben McGinnes [Tue, 16 Aug 2016 15:27:07 +0000 (01:27 +1000)]
Spelling fix

* Changed binginds to bindings.  :)

17 months agoQt: Add test for progress signal of encryptjob
Andre Heinecke [Fri, 12 Aug 2016 14:55:51 +0000 (16:55 +0200)]
Qt: Add test for progress signal of encryptjob

* lang/qt/tests/t-encrypt.cpp (testProgress): New.

--
This tests that a ByteArray IODevice now gives proper progress
signals.

17 months agoCpp: Provide size-hint for seekable and mem data
Andre Heinecke [Fri, 12 Aug 2016 14:51:13 +0000 (16:51 +0200)]
Cpp: Provide size-hint for seekable and mem data

* lang/cpp/src/data.cpp (GpgME::Data::Data): Set size-hint for
mem and DataProvider based Data.

--
This fixes the case that QGpgME did not have a total value for
progress as the size was unknown.

17 months agocore: Make use of the "size-hint" in engine-gpg.
Werner Koch [Fri, 12 Aug 2016 13:24:46 +0000 (15:24 +0200)]
core: Make use of the "size-hint" in engine-gpg.

* src/engine-gpg.c: Include data.h.
(add_input_size_hint): New.
(gpg_decrypt, gpg_encrypt, gpg_encrypt_sign, gpg_sign)
(gpg_verify): Call new function,

* tests/run-encrypt.c (status_cb): Print to stderr.
(progress_cb): New.o
(main): Add option --progress.  Print full-status lines.  Provide a
size for the input data.

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agocore: Add gpgme_data_set_flag to add more meta data to data objects.
Werner Koch [Fri, 12 Aug 2016 13:21:16 +0000 (15:21 +0200)]
core: Add gpgme_data_set_flag to add more meta data to data objects.

* src/gpgme.h.in (gpgme_data_set_flag): New public function.
* src/data.c (gpgme_data_set_flag): New.
(_gpgme_data_get_size_hint): New.
* src/data.h (strucy gpgme_data): Add field 'size_hint'.
* src/gpgme.def, src/libgpgme.vers: Add new function.
* src/conversion.c (_gpgme_string_to_off): New.

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agoAdd Python bindings to NEWS.
Justus Winter [Fri, 12 Aug 2016 10:28:03 +0000 (12:28 +0200)]
Add Python bindings to NEWS.

--
Signed-off-by: Justus Winter <justus@g10code.com>
17 months agoQt: Fix defaultkeygenerationjob build
Andre Heinecke [Fri, 12 Aug 2016 06:17:18 +0000 (08:17 +0200)]
Qt: Fix defaultkeygenerationjob build

* lang/qt/src/defaultkeygenerationjob.cpp: Include moc.

17 months agoQt: Add DefaultKeyGenerationJob
Andre Heinecke [Thu, 11 Aug 2016 15:57:14 +0000 (17:57 +0200)]
Qt: Add DefaultKeyGenerationJob

* lang/qt/src/defaultkeygenerationjob.cpp,
lang/qt/src/defaultkeygenerationjob.h: New.
* lang/qt/src/Makefile.am: Update accordingly.

--
The defaultkeygenerationjob makes it easier to just generate a key
in the future this should probably use quick-gen key but since this
is not exposed in gpgme we hardcode the defaults and do it with
the params file.

This is also the first job that uses a new and better architecture
without backend abstraction and the pimpl pattern instead of
a specialized subclass.

This is an adoption of kde's libkleo commit f49b7157
Thanks dvratil@kde.org

17 months agoQt: Ensure all public classes are exported
Andre Heinecke [Thu, 11 Aug 2016 15:38:36 +0000 (17:38 +0200)]
Qt: Ensure all public classes are exported

* src/abstractimportjob.h,
src/cryptoconfig.h,
src/deletejob.h,
src/exportjob.h,
src/importfromkeyserverjob.h,
src/importjob.h,
src/keygenerationjob.h,
src/keylistjob.h,
src/listallkeysjob.h,
src/refreshkeysjob.h,
src/signencryptjob.h,
src/specialjob.h,
src/verifydetachedjob.h: Export classes.

--
This is an adoption of kde's libkleo commit: d6a71a4e
Thanks dvratil@kde.org

17 months agoQt: Add KeyForMailboxJob
Andre Heinecke [Thu, 11 Aug 2016 15:22:35 +0000 (17:22 +0200)]
Qt: Add KeyForMailboxJob

* lang/qt/src/job.cpp: Include moc and make subclass.
* lang/qt/src/keyformailboxjob.h,
lang/qt/src/qgpgmekeyformailboxjob.cpp,
lang/qt/src/qgpgmekeyformailboxjob.h: New.
* lang/qt/tests/run-keyformailboxjob.cpp: New manual test.
* lang/qt/tests/Makefile.am: Add run-keyformailboxjob.
* lang/qt/src/Makefile.am: Update accordingly.
* lang/qt/src/protocol.h, lang/qt/src/protocol_p.h: Add
keyformailboxjob.

--
The KeyForMailboxjob can be used to determine the best key to
use to encrypt something to a given mail address.

17 months agodoc: Get rid of version.texi
Werner Koch [Wed, 10 Aug 2016 14:33:20 +0000 (16:33 +0200)]
doc: Get rid of version.texi

* configure.ac (CC_FOR_BUILD): New.
* doc/mkdefsinc.c: New.  Taken from GnuPG and modified for gpgme.
* doc/Makefile.am (EXTRA_DIST): Add defsincdate and mkdefsinc.c
(BUILT_SOURCES): new.
(gpgme.texi): New dependency.
(mkdefsinc, defsincdate, defs.inc): New rules.
(dist-hook): New.
* doc/gpgme.texi: Include defs.inc.  Remove version.texi.
--

GnuPG-bug-id: 2352

That new system should also yield more approriate date infos for the
manual.

17 months agobuild: Declare all languages for make dist.
Werner Koch [Wed, 10 Aug 2016 14:28:36 +0000 (16:28 +0200)]
build: Declare all languages for make dist.

* lang/Makefile.am (DIST_SUBDIRS): New.

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agocore: Do not identify PNG files as PGP signatures.
Werner Koch [Wed, 10 Aug 2016 13:31:25 +0000 (15:31 +0200)]
core: Do not identify PNG files as PGP signatures.

* src/data-identify.c (next_openpgp_packet): Blacklist PNG files.
--

GnuPG-bug-id: 2314
Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agoCpp: Handle empty recipients consistently
Andre Heinecke [Wed, 10 Aug 2016 12:12:33 +0000 (14:12 +0200)]
Cpp: Handle empty recipients consistently

* lang/cpp/src/context.cpp (Context::getKeysFromRecipients):
New helper.
(Context::encrypt, Context::startEncryption, Context::signAndEncrypt)
(Context::startCombinedSigningAndEncryption): Use new helper.
* lang/cpp/src/context.h (Context::getKeysFromRecipients): Add
as private helper.

--
bf776ce was incomplete as the code to handle recpients
was duplicated four times. This is now unified and constently
uses a nullptr instead of an empty array.

17 months agocore: Handle ENCRYPT_SYMMETRIC also for sig & enc
Andre Heinecke [Wed, 10 Aug 2016 12:01:38 +0000 (14:01 +0200)]
core: Handle ENCRYPT_SYMMETRIC also for sig & enc

* src/engine-gpg.c (gpg_encrypt_sign): Handle ENCRYPT_SYMMETRIC
flag.

17 months agoQt: Remove unused variable
Andre Heinecke [Wed, 10 Aug 2016 10:06:39 +0000 (12:06 +0200)]
Qt: Remove unused variable

* lang/qt/src/qgpgmerefreshkeysjob.cpp (slotStatus): Remove
unused variable typ.

17 months agoQt: Create TestPassphraseProvider on stack
Andre Heinecke [Wed, 10 Aug 2016 10:05:32 +0000 (12:05 +0200)]
Qt: Create TestPassphraseProvider on stack

* lang/qt/tests/t-encrypt.cpp, lang/qt/tests/t-tofuinfo.cpp: Create
TestPassphraseProvider on stack.

--
Context does not delete the provider. This fixes ASAN errors.

17 months agoCpp: Clarify ownership of provider classes
Andre Heinecke [Wed, 10 Aug 2016 10:04:16 +0000 (12:04 +0200)]
Cpp: Clarify ownership of provider classes

* lang/cpp/src/context.h: Note that the context does not take
ownership of providers.

17 months agotests: Fix memory leak.
Justus Winter [Wed, 10 Aug 2016 08:37:31 +0000 (10:37 +0200)]
tests: Fix memory leak.

* tests/gpg/t-encrypt-mixed.c (main): Free 'text2'.

Signed-off-by: Justus Winter <justus@g10code.com>
17 months agocore: Ensure err is initalized in gpg_encrypt
Andre Heinecke [Wed, 10 Aug 2016 08:27:05 +0000 (10:27 +0200)]
core: Ensure err is initalized in gpg_encrypt

* src/engine-gpg.c (gpg_encrypt): Initialize err.

17 months agoQt: Fix t-keylist moc include
Andre Heinecke [Wed, 10 Aug 2016 07:50:26 +0000 (09:50 +0200)]
Qt: Fix t-keylist moc include

* lang/qt/tests/t-keylist.cpp: Don't include t-support.moc

--
Accidental leftover from trying to generate t-support moc from
another cpp file. This was solved instead by a new rule to generate
moc files from the header.

17 months agoQt: Clean up debug output in tests
Andre Heinecke [Tue, 9 Aug 2016 16:39:56 +0000 (18:39 +0200)]
Qt: Clean up debug output in tests

* lang/qt/tests/t-support.cpp: Remove accidentally commited
debug output.

17 months agoQt: Add encryption test and refactor testsuite
Andre Heinecke [Tue, 9 Aug 2016 12:10:15 +0000 (14:10 +0200)]
Qt: Add encryption test and refactor testsuite

* lang/qt/tests/Makefile.am: Add t-encrypt and t-support.
* lang/qt/tests/t-support.cpp, lang/qt/tests/t-support.c (QGpgMETest):
New. Class to handle common cleanup / init.
* lang/qt/tests/t-keylist.cpp,
lang/qt/tests/t-keylocate.cpp,
lang/qt/tests/t-ownertrust.cpp,
lang/qt/tests/t-tofuinfo.cpp: Inherit QGpgMETest.
* lang/qt/tests/t-encrypt.cpp: New. Test Symetric and Asymectric
encryption. Mixed encryption test is disabled.

17 months agoQt: Add support for EncryptJobs with generic flags
Andre Heinecke [Tue, 9 Aug 2016 11:10:08 +0000 (13:10 +0200)]
Qt: Add support for EncryptJobs with generic flags

* lang/qt/src/encryptjob.h, lang/qt/src/signencryptjob.h,
lang/qt/src/qgpgmeencryptjob.h, lang/qt/src/qgpgmeencryptjob.cpp,
lang/qt/src/qgpgmesignencryptjob.cpp,
lang/qt/src/qgpgmeencryptjob.cpp: Add start and exec overloads
that accept generic EncryptFlags.

--
While this technically is an ABI break (vtable change) there
are no known classes outside qgpgme that inherit encryptjob
or signencryptjob. And the new functions should be added
to the bottom of the vtable.

17 months agoCpp: Add support for all EncryptionFlags
Andre Heinecke [Tue, 9 Aug 2016 11:07:30 +0000 (13:07 +0200)]
Cpp: Add support for all EncryptionFlags

* lang/cpp/src/context.h (EncryptionFlags): Extend.
* lang/cpp/src/context.cpp (encryptflags2encryptflags): Ditto.

17 months agoCpp: Fix simple symmetric encryption
Andre Heinecke [Tue, 9 Aug 2016 10:56:01 +0000 (12:56 +0200)]
Cpp: Fix simple symmetric encryption

* lang/cpp/src/context.cpp (Context::encrypt): If no recipients
are provided encrypt with NULL and not an empty array.

--
Sending an empty array leads to an invalid argument error.

17 months agocore: Add support for mixed symmetric and asym enc
Andre Heinecke [Tue, 9 Aug 2016 09:40:29 +0000 (11:40 +0200)]
core: Add support for mixed symmetric and asym enc

* src/gpgme.h.in (gpgme_encrypt_flags_t): New flag
GPGME_ENCRYPT_SYMMETRIC.
* src/engine-gpg.c (gpg_encrypt): Also add --symmetric if the flag
is given.
* NEWS: Mention new flag.
* tests/run-encrypt.c (show_usage): Extend for --symmetric.
(main): Handle --symmetric.
(main): Set passphrase_cb in loopback mode.
(main): Fix encrypt call if no recipients are given.
* tests/gpg/t-encrypt-mixed.c: New.
* tests/gpg/Makefile.am (c_tests): Add new test.
* doc/gpgme.texi: Document new flag.

17 months agocore: Let GPGME_PROTOCOL_ASSUAN pass Assuan comments through.
Werner Koch [Mon, 8 Aug 2016 15:02:54 +0000 (17:02 +0200)]
core: Let GPGME_PROTOCOL_ASSUAN pass Assuan comments through.

* src/engine-assuan.c (llass_new): Set ASSUAN_CONVEY_COMMENTS,
--

GnuPG-bug-id: 2429
Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agoPrepend LD_LIBRARY_PATH for python tests
Andre Heinecke [Mon, 8 Aug 2016 13:04:01 +0000 (15:04 +0200)]
Prepend LD_LIBRARY_PATH for python tests

* lang/python/tests/Makefile.am (TESTS_ENVIRONMENT): Prepend path
instead of setting the value.

--
This fixes the case where tools / libararies are needed for
a working GnuPG system that are pointed to by LD_LIBRARY_PATH.
E.g. GnuPG itself is installed in a custom prefix and PATH /
LD_LIBRARY_PATH is set accordingly.

17 months agopython: Clean up and modernize examples.
Justus Winter [Fri, 5 Aug 2016 12:03:15 +0000 (14:03 +0200)]
python: Clean up and modernize examples.

* lang/python/examples/Examples.rst: Delete file.
* lang/python/examples/t-edit.py: Likewise.  This is actually a test
case and has been moved to 'tests'.
* lang/python/examples/assuan.py: New file.
* lang/python/examples/decryption-filter.py: Likewise.
* lang/python/examples/delkey.py: Modernize.
* lang/python/examples/encrypt-to-all.py: Likewise.
* lang/python/examples/exportimport.py: Likewise.
* lang/python/examples/genkey.py: Likewise.
* lang/python/examples/inter-edit.py: Likewise.
* lang/python/examples/sign.py: Likewise.
* lang/python/examples/signverify.py: Likewise.
* lang/python/examples/simple.py: Likewise.
* lang/python/examples/testCMSgetkey.py: Likewise.
* lang/python/examples/verifydetails.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
17 months agocore: Extend gpgme_subkey_t to carry the keygrip.
Werner Koch [Thu, 4 Aug 2016 14:17:01 +0000 (16:17 +0200)]
core: Extend gpgme_subkey_t to carry the keygrip.

* src/gpgme.h.in (struct _gpgme_subkey): Add file 'keygrip'.
* src/key.c (gpgme_key_unref): Free KEYGRIP.
* src/keylist.c (keylist_colon_handler): Parse GRP records.
* src/engine-gpg.c (gpg_keylist_build_options): Do not use
--with-fingerprint options for gpg versions >= 2.1.15.

* tests/run-keylist.c (main): Print subkeys and keygrips.

Signed-off-by: Werner Koch <wk@gnupg.org>
17 months agopython: Add a nicer interface to list keys.
Justus Winter [Wed, 3 Aug 2016 14:32:30 +0000 (16:32 +0200)]
python: Add a nicer interface to list keys.

* lang/python/pyme/core.py (Context.keylist): New method.
* lang/python/tests/t-keylist.py: Test new method.

Signed-off-by: Justus Winter <justus@g10code.com>
17 months agopython: Add a flag identifying in-tree builds.
Justus Winter [Tue, 2 Aug 2016 16:45:10 +0000 (18:45 +0200)]
python: Add a flag identifying in-tree builds.

* lang/python/helpers.c (pyme_in_tree_build): New variable.
* lang/python/helpers.h (pyme_in_tree_build): New declaration.
* lang/python/pyme/version.py.in (in_tree_build): New variable.
* lang/python/setup.py.in: Rework macro handling, set 'IN_TREE_BUILD'
as appropriate.

Signed-off-by: Justus Winter <justus@g10code.com>
17 months agopython: Fix build system integration.
Justus Winter [Tue, 2 Aug 2016 16:42:26 +0000 (18:42 +0200)]
python: Fix build system integration.

* lang/python/Makefile.am: Be more careful when cleaning the build
directory, we must not delete the generated file 'pyme/version.py'.

Signed-off-by: Justus Winter <justus@g10code.com>
17 months agodoc: Document the Assuan protocol.
Justus Winter [Tue, 2 Aug 2016 14:51:08 +0000 (16:51 +0200)]
doc: Document the Assuan protocol.

* doc/gpgme.texi: Document the Assuan protocol.

GnuPG-bug-id: 2407
Signed-off-by: Justus Winter <justus@g10code.com>
17 months agodoc: Fix formatting.
Justus Winter [Tue, 2 Aug 2016 14:50:54 +0000 (16:50 +0200)]
doc: Fix formatting.

--
Signed-off-by: Justus Winter <justus@g10code.com>
17 months agopython: Fix out-of-tree build.
Justus Winter [Thu, 28 Jul 2016 16:14:08 +0000 (18:14 +0200)]
python: Fix out-of-tree build.

* lang/python/MANIFEST.in: Add 'private.h'.

Fixes-commit: 3d4dc3f0
Signed-off-by: Justus Winter <justus@g10code.com>
17 months agopython: Improve error handling.
Justus Winter [Thu, 28 Jul 2016 15:44:18 +0000 (17:44 +0200)]
python: Improve error handling.

* lang/python/pyme/core.py (Context.protocol): Check that the engine
is usable before setting the protocol.
(Context._errorcheck): Add missing functions.

Signed-off-by: Justus Winter <justus@g10code.com>
17 months agosrc: Fix dummy engine versions.
Justus Winter [Thu, 28 Jul 2016 15:45:53 +0000 (17:45 +0200)]
src: Fix dummy engine versions.

Previously, 'gpgme_engine_check_version' failed for these protocols
because the version parser failed to parse the dummy versions.

* src/engine-assuan.c (llass_get_version): Use a version triple that
the parser can understand.
(llass_get_req_version): Likewise.
* src/engine-spawn.c (engspawn_get_version): Likewise.
(engspawn_get_req_version): Likewise.
* src/engine-uiserver.c (uiserver_get_version): Likewise.
(uiserver_get_req_version): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
17 months agopython: Drop superfluous imports and trim public interface.
Justus Winter [Thu, 28 Jul 2016 14:29:05 +0000 (16:29 +0200)]
python: Drop superfluous imports and trim public interface.

* lang/python/pyme/__init__.py: Avoid leaking low-level 'gpgme', make
sure the main module looks nice and tidy, appease pyflakes.
* lang/python/pyme/errors.py: Appease pyflakes.
* lang/python/pyme/util.py: Avoid leaking low-level 'gpgme' into the
module namespace.
* lang/python/pyme/version.py.in: Likewise.
* lang/python/tests/t-keylist.py: Drop superfluous imports.
* lang/python/tests/t-sig-notation.py: Likewise.
* lang/python/tests/t-sign.py: Likewise.
* lang/python/tests/t-signers.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
17 months agopython: Rename compiled SWIG module.
Justus Winter [Thu, 28 Jul 2016 13:44:38 +0000 (15:44 +0200)]
python: Rename compiled SWIG module.

Avoid the name pygpgme, as this is the name of another popular Python
binding for GPGME.

This commit renames the compiled Python module produced by SWIG.

* lang/python/Makefile.am: Rename the compiled Python module.
* lang/python/gpgme.i: Likewise.
* lang/python/pyme/core.py: Likewise.
* lang/python/pyme/errors.py: Likewise.
* lang/python/pyme/util.py: Likewise.
* lang/python/pyme/version.py.in: Likewise.
* lang/python/setup.py.in: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
17 months agopython: Rename exported functions.
Justus Winter [Thu, 28 Jul 2016 13:24:05 +0000 (15:24 +0200)]
python: Rename exported functions.

Avoid the name pygpgme, as this is the name of another popular Python
binding for GPGME.

This commit renames all functions that are exported to the Python
world.

* lang/python/helpers.c: Rename all exported functions.
* lang/python/helpers.h: Likewise.
* lang/python/pyme/core.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
17 months agopython: Rename private functions.
Justus Winter [Thu, 28 Jul 2016 12:51:20 +0000 (14:51 +0200)]
python: Rename private functions.

Avoid the name pygpgme, as this is the name of another popular Python
binding for GPGME.

This commit renames all functions that are not exported to the Python
world.

* lang/python/gpgme.i: Rename all private functions.
* lang/python/helpers.c: Likewise.
* lang/python/helpers.h: Likewise.
* lang/python/private.h: Likewise.  Also move the SWIG runtime helper
prototypes here.

Signed-off-by: Justus Winter <justus@g10code.com>
17 months agopython: Support the Assuan engine.
Justus Winter [Thu, 28 Jul 2016 10:40:54 +0000 (12:40 +0200)]
python: Support the Assuan engine.

* lang/python/gpgme.i: Add typemaps for the Assuan protocol callbacks.
* lang/python/helpers.c (_pyme_assuan_{data,inquire,status}_cb): New
functions.
* lang/python/private.h (_pyme_assuan_{data,inquire,status}_cb): New
prototypes.
* lang/python/pyme/core.py (Context.assuan_transact): New method.
* lang/python/pyme/util.py (percent_escape): New function.
* lang/python/tests/Makefile.am (py_tests): Add new test.
* lang/python/tests/t-protocol-assuan.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
17 months agopython: Improve engine information handling.
Justus Winter [Thu, 28 Jul 2016 09:16:35 +0000 (11:16 +0200)]
python: Improve engine information handling.

* lang/python/gpgme.i (gpgme_engine_info_t): Wrap engine infos.
* lang/python/pyme/core.py (Context.engine_info): New property.
(Context.{g,s}et_engine_info): Improve docstrings.
* lang/python/pyme/results.py (EngineInfo): New class.

Signed-off-by: Justus Winter <justus@g10code.com>
17 months agopython: Add accessors for the protocol.
Justus Winter [Thu, 28 Jul 2016 08:59:46 +0000 (10:59 +0200)]
python: Add accessors for the protocol.

* lang/python/pyme/core.py (Context.__init__): Add 'protocol'
parameter.
(Context.protocol): New accessors.

Signed-off-by: Justus Winter <justus@g10code.com>
17 months agopython: Expose less functions to the Python world.
Justus Winter [Thu, 28 Jul 2016 08:20:20 +0000 (10:20 +0200)]
python: Expose less functions to the Python world.

* lang/python/Makefile.am (EXTRA_DIST, COPY_FILES): Add new file.
* lang/python/gpgme.i: Include new file and add comments.
* lang/python/helpers.c: Include new file.
* lang/python/helpers.h: Move functions we do not need to expose...
* lang/python/private.h: ... here.

Signed-off-by: Justus Winter <justus@g10code.com>
18 months agoFix including nil bytes in keylist output.
Ben Kibbey [Tue, 19 Jul 2016 00:16:46 +0000 (20:16 -0400)]
Fix including nil bytes in keylist output.

* src/gpgme-tool.c (cmd_keylist,gt_result): use strlen().

Signed-off-by: Ben Kibbey <bjk@luxsci.net>
18 months agopython: Make GPGME's version easily accessible.
Justus Winter [Fri, 15 Jul 2016 16:27:04 +0000 (18:27 +0200)]
python: Make GPGME's version easily accessible.

* lang/python/pyme/version.py.in (gpgme_versionstr): New variable.

Signed-off-by: Justus Winter <justus@g10code.com>
18 months agopython: Add an idiomatic interface.
Justus Winter [Wed, 8 Jun 2016 16:58:57 +0000 (18:58 +0200)]
python: Add an idiomatic interface.

* configure.ac: Bump required Python version.
* lang/python/pyme/__init__.py: Update docstring.  Import Context and
Data.
* lang/python/pyme/core.py (Context.encrypt): New function.
(Context.decrypt): Likewise.
(Context.sign): Likewise.
(Context.verify): Likewise.
* lang/python/pyme/errors.py: Add new errors.
* lang/python/pyme/util.py (process_constants): Rework and return the
inserted keys.
* lang/python/tests/Makefile.am (EXTRA_DIST): Add new keys.
* lang/python/tests/encrypt-only.asc: New file.
* lang/python/tests/sign-only.asc: Likewise.
* lang/python/tests/initial.py: Mark key 'Alpha' as trusted, import
new keys.
* lang/python/tests/support.py: Add fingerprints of known keys.
(in_srcdir): New function.
(print_data): Handle bytes too.
(mark_key_trusted): New function.
* lang/python/tests/t-decrypt-verify.py: Adjust test.  Test idiomatic
interface.
* lang/python/tests/t-decrypt.py: Test idiomatic interface.
* lang/python/tests/t-encrypt-sign.py: Likewise.
* lang/python/tests/t-encrypt-sym.py: Likewise.
* lang/python/tests/t-encrypt.py: Likewise.
* lang/python/tests/t-idiomatic.py: Simplify.
* lang/python/tests/t-keylist.py: Adjust to newly trusted key.
* lang/python/tests/t-sign.py: Likewise.  Test idiomatic interface.
* lang/python/tests/t-signers.py: Likewise.
* lang/python/tests/t-verify.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
18 months agoQt: Disable keylocate test for gnupg < 2.0.10
Andre Heinecke [Thu, 14 Jul 2016 15:03:05 +0000 (17:03 +0200)]
Qt: Disable keylocate test for gnupg < 2.0.10

* lang/qt/tests/t-keylocate.cpp: Disable test for gnupg < 2.0.10

18 months agoCpp: Add EngineInfo::Version class
Andre Heinecke [Thu, 14 Jul 2016 15:01:33 +0000 (17:01 +0200)]
Cpp: Add EngineInfo::Version class

* lang/cpp/src/engineinfo.cpp (EngineInfo::engineVersion): New.
* lang/cpp/src/engineinfo.h (EngineInfo::engineVersion): Declare.
(EngineInfo::Version): Small helper to work with versions.

18 months agoQt: Fix usage of ignore-invalid-option in tests
Andre Heinecke [Thu, 14 Jul 2016 14:32:56 +0000 (16:32 +0200)]
Qt: Fix usage of ignore-invalid-option in tests

* Makefile.am (pubring-stamp): Fix config.

18 months agoQt: Fix tests if gpg2 is gpg
Andre Heinecke [Thu, 14 Jul 2016 13:31:50 +0000 (15:31 +0200)]
Qt: Fix tests if gpg2 is gpg

* lang/qt/tests/Makefile.am (pubring-stamp): Loopback and provide
passphrase on command line when importing.

18 months agopython: Fix test.
Justus Winter [Thu, 14 Jul 2016 11:22:59 +0000 (13:22 +0200)]
python: Fix test.

* lang/python/tests/t-keylist.py: Do not assume key alpha is trusted
yet.

Signed-off-by: Justus Winter <justus@g10code.com>
18 months agopython: Drop bad category.
Justus Winter [Thu, 14 Jul 2016 10:34:56 +0000 (12:34 +0200)]
python: Drop bad category.

--
Signed-off-by: Justus Winter <justus@g10code.com>
18 months agobuild: Update config.{guess,sub} to {2016-05-15,2016-06-20}.
Werner Koch [Wed, 13 Jul 2016 17:07:47 +0000 (19:07 +0200)]
build: Update config.{guess,sub} to {2016-05-15,2016-06-20}.

* build-aux/config.guess: Update.
* build-aux/config.sub: Update.

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agocore: New GPGME_DATA_ENCODING_MIME.
Werner Koch [Wed, 13 Jul 2016 12:45:02 +0000 (14:45 +0200)]
core: New GPGME_DATA_ENCODING_MIME.

* src/gpgme.h.in (GPGME_DATA_ENCODING_MIME): New.
* src/data.c (gpgme_data_set_encoding): Adjust check.
* src/engine-gpg.c (have_gpg_version): New.
(gpg_encrypt, gpg_encrypt_sign): Pass flag '--mimemode'.
(gpg_sign): Ditto.

* lang/cpp/src/data.h (GpgME): Add MimeEncoding.
* lang/cpp/src/data.cpp (encoding, setEncoding): Support MimeEncoding.

* src/gpgme-tool.c (server_data_encoding): Add flag --mime.
--

This feature allows an application to declare that the encrypted or
signed data is a valid MIME part.

What is missing is a way to return that information to the application
after decryption/verification.  This can be done by setting the
encoding of the output data object; however this requires some
internal additions to our processing model.

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agocore: Pass the engine's version string to the engine's new function.
Werner Koch [Wed, 13 Jul 2016 11:57:14 +0000 (13:57 +0200)]
core: Pass the engine's version string to the engine's new function.

* src/engine-backend.h (engine_ops): Add arg 'version' to NEW.
* src/engine-assuan.c (llass_new): Add dummy arg 'version'.
* src/engine-g13.c (g13_new): Ditto.
* src/engine-gpgconf.c (gpgconf_new): Ditto.
* src/engine-gpgsm.c (gpgsm_new): Ditto.
* src/engine-spawn.c (engspawn_new): Ditto.
* src/engine-uiserver.c (uiserver_new): Ditto.
* src/engine.c (_gpgme_engine_new): Pass version string to the new
function.
* src/engine-gpg.c (struct engine_gpg): Add field 'version'.
(gpg_new): Add arg 'version'.
(gpg_release): Free VERSION.

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agoCpp: Add feature enum for new identify
Andre Heinecke [Wed, 13 Jul 2016 09:56:18 +0000 (11:56 +0200)]
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.

18 months agopython: Port more tests.
Justus Winter [Mon, 6 Jun 2016 10:49:11 +0000 (12:49 +0200)]
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>
18 months agopython: Improve python packaging.
Justus Winter [Tue, 12 Jul 2016 14:20:35 +0000 (16:20 +0200)]
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>
18 months agom4: Don't set fpic for qt on windows
Andre Heinecke [Tue, 12 Jul 2016 13:26:14 +0000 (15:26 +0200)]
m4: Don't set fpic for qt on windows

* m4/qt.m4 (FIND_QT): Do not set fpic for windows.

--
Otherwise each compile call will result in a warning that
fpic is ignored for windows.

18 months agom4: Use LIBS instead of LDFLAGS for Qt libs
Andre Heinecke [Tue, 12 Jul 2016 13:10:16 +0000 (15:10 +0200)]
m4: Use LIBS instead of LDFLAGS for Qt libs

* m4/qt.m4: Modify LIBS instead of LDFLAGS for link test.

--
The test would otherwise fail when building for windows because the
link order was wrong.

18 months agoBump version to 1.7.0
Andre Heinecke [Tue, 12 Jul 2016 10:28:41 +0000 (12:28 +0200)]
Bump version to 1.7.0

* configure.ac(mym4_version_minor),
(mym4_version_micro): Next release will be 1.7.0

--
This was already mentioned in NEWS but acidentally not changed
in configure.ac

18 months agoQt: Install CamelCase forward includes
Andre Heinecke [Tue, 12 Jul 2016 09:47:33 +0000 (11:47 +0200)]
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.

18 months agoQt: Export VerifyDetachedJob
Andre Heinecke [Tue, 12 Jul 2016 09:47:04 +0000 (11:47 +0200)]
Qt: Export VerifyDetachedJob

* lang/qt/src/verifydetachedjob.h (VerifyDetachedJob): Export it.

18 months agoQt/Cpp: Add version headers
Andre Heinecke [Tue, 12 Jul 2016 09:09:44 +0000 (11:09 +0200)]
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.

18 months agoQt/Cpp: Add license blurb to export headers
Andre Heinecke [Tue, 12 Jul 2016 09:08:42 +0000 (11:08 +0200)]
Qt/Cpp: Add license blurb to export headers

* lang/cpp/src/gpgmepp_export.h,
lang/qt/src/qgpgme_export.h: Add license blurb.

18 months agopython: Fix distcheck.
Justus Winter [Mon, 11 Jul 2016 17:42:56 +0000 (19:42 +0200)]
python: Fix distcheck.

* lang/python/Makefile.am (EXTRA_DIST): Add missing files.

Signed-off-by: Justus Winter <justus@g10code.com>
18 months agom4: Add compile / link check for qt
Andre Heinecke [Mon, 11 Jul 2016 16:47:11 +0000 (18:47 +0200)]
m4: Add compile / link check for qt

* m4/qt.m4 (FIND_QT): Check if a qt application can be compiled and
linked.

--
In case gpgme is cross compiled pkg-config may pick up qt
for the build system and not for the host system. To avoid that
we check that we can compile a qt program for host.

18 months agopython: Enable out-of-tree build of pyme bindings.
Justus Winter [Mon, 11 Jul 2016 14:38:37 +0000 (16:38 +0200)]
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>
18 months agopython: Do not depend on access to internal data structures.
Justus Winter [Mon, 11 Jul 2016 14:34:15 +0000 (16:34 +0200)]
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>
18 months agopython: Make result wrapping backwards compatible.
Justus Winter [Mon, 11 Jul 2016 10:29:17 +0000 (12:29 +0200)]
python: Make result wrapping backwards compatible.

* lang/python/pyme/results.py (Result.__init__): Skip missing fields.

Signed-off-by: Justus Winter <justus@g10code.com>
18 months agoQt: Fix memleaks in tests
Andre Heinecke [Mon, 11 Jul 2016 14:47:30 +0000 (16:47 +0200)]
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

18 months agoQt: Add some general Protocol documentation
Andre Heinecke [Mon, 11 Jul 2016 14:41:09 +0000 (16:41 +0200)]
Qt: Add some general Protocol documentation

* lang/qt/src/protocol.h (Protocol): Add doc.

--
This explicitly documents that syncs run with exec need deletion.

18 months agoQt: Disable t-tofuinfo tests
Andre Heinecke [Mon, 11 Jul 2016 10:01:35 +0000 (12:01 +0200)]
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.

18 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>
18 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>
18 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>
18 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>
18 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>
18 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.

18 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.

18 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.

18 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.

18 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++.

18 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.

18 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

18 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.

18 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.

18 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.

18 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

18 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

18 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.