Commit Graph

229 Commits

Author SHA1 Message Date
Andre Heinecke
f311b92cea cpp: Add WithTofu Keylist Mode
* lang/cpp/src/context.cpp: Handle WithTofu.
* lang/cpp/src/global.h (KeyListMode): Add WithTofu.
* lang/cpp/src/util.h (add_to_gpgme_keylist_mode_t): Handle WithTofu.
2016-08-25 16:17:46 +02:00
Andre Heinecke
053e6e0a7b qt: Fix tofuinfo test when gpg is gpg2
* lang/qt/tests/t-support.cpp (QGpgMETest::copyKeyrings): New helper.
* lang/qt/tests/t-support.h: Declare.
* lang/qt/tests/t-encrypt.cpp: use it
* lang/qt/tests/t-tofuinbo.cpp: ditto.

--
New helper takes care of copying the correct files for either
keybox or keyring.
2016-08-25 15:20:02 +02:00
Andre Heinecke
f08904b810 qt: Remove unused variable in test
* t-wkspublish.cpp (testWKSPublishCreate): Remove context.
2016-08-25 15:02:11 +02:00
Andre Heinecke
df04b232b8 qt: Add test for wkspublishjob
* lang/qt/tests/t-wkspublish.cpp: New.
* lang/qt/tests/Makefile.am: Update accordingly.

--
Most tests are disabled by default as tey require
an online connection.
Define DO_ONLINE_TESTS to enable the tests.
2016-08-25 14:40:26 +02:00
Andre Heinecke
94420b0577 qt: Add WKSPublishJob
* lang/qt/src/Makefile.am: Add new files.
* lang/qt/src/job.cpp: Include moc / subclass stub.
* lang/qt/src/protocol.h: Add virtual for new job.
* lang/qt/src/protocol_p.h: Add job.
* lang/qt/src/wkspublishjob.h: Interface for WKSPublishJob.
* lang/qt/src/qgpgmewkspublishjob.cpp,
lang/qt/src/qgpgmewkspublishjob.h: New.

--
The Job was originally intended to be used with a SpawnEngine
Context but QProcess was a better fit for the job.

Usage is similar to the client tool. check, create, recieve.
2016-08-25 14:29:41 +02:00
Andre Heinecke
de7b67f9b2 Cpp: Change firstSeen / lastSeen return values
* lang/cpp/src/tofuinfo.cpp,
lang/cpp/src/tofuinfo.h (TofuInfo::firstSeen, TofuInfo::lastSeen):
Change return values to unsigned long and update doc.
2016-08-25 11:41:57 +02:00
Andre Heinecke
abcd9a283e Cpp: Add wrapper for gpgme_get_dirinfo
* lang/cpp/src/context.cpp (dirInfo): New.
* lang/cpp/src/global.h (dirInfo): New.
2016-08-25 11:41:57 +02:00
Andre Heinecke
ece8b02a83 Cpp: Add support for spawn engine
* lang/cpp/src/context.cpp (Context::spawn, Context::spawnAsync): New.
* lang/cpp/src/context.h: Add prototypes.
(SpawnFlags): New.
* lang/cpp/src/global.h (SpawnEngine): Added.
2016-08-25 11:41:57 +02:00
Werner Koch
e20b0f0201 cpp: Get rid of AssuanResult due to its deprecation.
* lang/cpp/src/assuanresult.cpp: Remove.
* lang/cpp/src/assuanresult.h: Remove.
* lang/cpp/src/Makefile.am: Remove these files.
* lang/cpp/src/context.cpp: Remove header assuanresult.h
(assuanTransact): Change return type to Error.  Use
gpgme_op_assuan_transact_ext.
(startAssuanTransaction): Change return type to Error.
(assuanResult): Remove
* lang/cpp/src/context.h (assuanResult): Adjust for changes.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-24 14:15:58 +02:00
Andre Heinecke
d2e40fb7ad Qt: Adapt (disabled) tofuinfo test to new API
* lang/qt/tests/t-tofuinfo.cpp: Switch to UID based API.

--
Test is still disabled as GnuPG still returns unexpected
results.
2016-08-24 14:00:41 +02:00
Andre Heinecke
7c5a4974b7 Cpp: Add Key to signature
* lang/cpp/src/verificationresult.cpp,
lang/cpp/src/verificationresult.h (Signature::key): New.
2016-08-24 13:59:37 +02:00
Andre Heinecke
40ea1c8577 Cpp: Use fpr field for primaryFingerprint
* lang/cpp/src/key.cpp (Key::primaryFingerprint): Return
fpr value if available.

--
Should not be necessary but we might have an incomplete
key without subkeys but the fingerprint already set in
gpgme's data type.
2016-08-24 13:57:49 +02:00
Andre Heinecke
799b168243 Cpp: Move tofuinfo from signature to userid
* lang/cpp/src/key.cpp (UserID::tofuInfo): New.
* lang/cpp/src/key.h: Update accordingly.
* lang/cpp/src/tofuinfo.cpp: Remove dropped fields.
* lang/cpp/src/tofuinfo.h: Update accordingly.
* lang/cpp/src/verificationresult.cpp,
lang/cpp/src/verificationresult.h: Remove tofu info.
* lang/qt/tests/t-tofuinfo.cpp: Disable for now.

--
With be4ff75d7 Tofu info now lives with a UserID
Object. While this breaks API it was not yet released.
2016-08-23 16:44:17 +02:00
Andre Heinecke
64194b0f8d Cpp: Fix some pedantic warnings
* lang/cpp/src/context.cpp,
lang/cpp/src/context.h (Context::getKeysFromRecipients): Remove
ignored / invalid const qualifier.
* lang/cpp/src/result.h: Don't shadow error function in ctor.
2016-08-17 07:23:05 +02:00
Andre Heinecke
391e55411c 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.
2016-08-12 16:55:51 +02:00
Andre Heinecke
df7bbf5a66 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.
2016-08-12 16:51:13 +02:00
Andre Heinecke
75c974c4e0 Qt: Fix defaultkeygenerationjob build
* lang/qt/src/defaultkeygenerationjob.cpp: Include moc.
2016-08-12 08:17:18 +02:00
Andre Heinecke
105f5446e6 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
2016-08-11 18:00:14 +02:00
Andre Heinecke
59e2251a08 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
2016-08-11 18:00:14 +02:00
Andre Heinecke
8c5abc8d93 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.
2016-08-11 18:00:14 +02:00
Werner Koch
48691db97b
build: Declare all languages for make dist.
* lang/Makefile.am (DIST_SUBDIRS): New.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-10 16:28:36 +02:00
Andre Heinecke
09667a6006 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.
2016-08-10 14:12:33 +02:00
Andre Heinecke
d467018ce3 Qt: Remove unused variable
* lang/qt/src/qgpgmerefreshkeysjob.cpp (slotStatus): Remove
unused variable typ.
2016-08-10 12:07:56 +02:00
Andre Heinecke
a27d7755d0 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.
2016-08-10 12:07:56 +02:00
Andre Heinecke
21d5e71d48 Cpp: Clarify ownership of provider classes
* lang/cpp/src/context.h: Note that the context does not take
ownership of providers.
2016-08-10 12:07:56 +02:00
Andre Heinecke
0c222e1b3c 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.
2016-08-10 09:50:26 +02:00
Andre Heinecke
969f223d8d Qt: Clean up debug output in tests
* lang/qt/tests/t-support.cpp: Remove accidentally commited
debug output.
2016-08-09 18:39:56 +02:00
Andre Heinecke
f209ec8f58 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.
2016-08-09 14:23:51 +02:00
Andre Heinecke
34b456c3fb 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.
2016-08-09 14:23:51 +02:00
Andre Heinecke
1737239379 Cpp: Add support for all EncryptionFlags
* lang/cpp/src/context.h (EncryptionFlags): Extend.
* lang/cpp/src/context.cpp (encryptflags2encryptflags): Ditto.
2016-08-09 14:23:51 +02:00
Andre Heinecke
bf776ce94c 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.
2016-08-09 14:23:51 +02:00
Andre Heinecke
ab6f66d676 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.
2016-08-08 15:04:01 +02:00
Justus Winter
2a613e8715 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>
2016-08-05 14:05:49 +02:00
Justus Winter
56e26b54da 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>
2016-08-03 16:32:30 +02:00
Justus Winter
4c8265d32d 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>
2016-08-02 18:45:10 +02:00
Justus Winter
0bd7d8c197 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>
2016-08-02 18:42:26 +02:00
Justus Winter
4e728de842 python: Fix out-of-tree build.
* lang/python/MANIFEST.in: Add 'private.h'.

Fixes-commit: 3d4dc3f0
Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-28 18:14:08 +02:00
Justus Winter
5a7c7a86f7 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>
2016-07-28 17:50:07 +02:00
Justus Winter
2ff58fcbd5 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>
2016-07-28 16:50:02 +02:00
Justus Winter
2f754440f2 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>
2016-07-28 16:49:50 +02:00
Justus Winter
b5aa05c3b2 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>
2016-07-28 15:26:43 +02:00
Justus Winter
1d2f22aae6 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>
2016-07-28 15:26:43 +02:00
Justus Winter
de69fa496c 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>
2016-07-28 14:23:07 +02:00
Justus Winter
355d707286 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>
2016-07-28 11:16:35 +02:00
Justus Winter
78f7bf4dcf 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>
2016-07-28 10:59:46 +02:00
Justus Winter
3d4dc3f021 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>
2016-07-28 10:23:32 +02:00
Justus Winter
e545ca3f68 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>
2016-07-15 18:28:19 +02:00
Justus Winter
1f318b7aaa 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>
2016-07-15 18:28:09 +02:00
Andre Heinecke
d2f2cbd297 Qt: Disable keylocate test for gnupg < 2.0.10
* lang/qt/tests/t-keylocate.cpp: Disable test for gnupg < 2.0.10
2016-07-14 17:03:05 +02:00
Andre Heinecke
41de1ab904 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.
2016-07-14 17:02:38 +02:00