Commit Graph

265 Commits

Author SHA1 Message Date
Andre Heinecke
a8ff34fc30 qt: Add test for setting tofu policy
* lang/qt/tests/t-tofuinfo.cpp (testTofuPolicy): New.
2016-09-16 16:58:39 +02:00
Andre Heinecke
77aecfb5c9 qt: Add job for tofupolicy
* lang/qt/src/job.cpp, lang/qt/src/protocol.h,
lang/qt/src/protocol_p.h: Register job.
* lang/qt/src/qgpgmetofupolicyjob.cpp,
lang/qt/src/qgpgmetofupolicyjob.h,
lang/qt/src/tofupolicyjob.h: New.
* lang/qt/src/Makefile.am: Update accordingly.
2016-09-16 16:58:39 +02:00
Andre Heinecke
4d384d7bfe cpp: Add support for gpgme_op_tofu_policy
* src/context.cpp, src/context.h (setTofuPolicy, setTofuPolicyStart):
New.
2016-09-16 16:58:39 +02:00
Andre Heinecke
32baac8cde cpp: Declare sizes of tofu-info enums
* lang/cpp/src/tofuinfo.h (Policy, Validity): Declare sizes.

--
This is a quick ABI break before the release so that we can
easier extend them in the future. All new enums in public API
should be declared with a size from now on.
2016-09-16 16:58:38 +02:00
Werner Koch
bd24db313d
cpp: Silence use of deprecated function warning.
* lang/cpp/src/context.cpp (GpgME): Use pragma to silence wardning.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-16 16:00:57 +02:00
Werner Koch
b615316168
core: Document the version a function has been deprecated.
* src/gpgme.h.in (_GPGME_DEPRECATED): Change to take versio numbers
for documentation.  Change all places.
(_GPGME_DEPRECATED_OUTSIDE_GPGME): Ditto.
* lang/python/gpgme-h-clean.py: Adjust RE.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-16 16:00:27 +02:00
Justus Winter
6af7bee076 python: Release the GIL during calls into GPGME.
* lang/python/helpers.c (pyme_raise_callback_exception): Re-acquire
the Global Interpreter Lock.
(pyPassphraseCb, pyme_set_passphrase_cb, pyProgressCb,
pyme_set_progress_cb, pyStatusCb, pyme_set_status_cb,
_pyme_interact_cb, pyDataReadCb, pyDataWriteCb, pyDataSeekCb,
pyDataReleaseCb, pyme_data_new_from_cbs, _pyme_assuan_data_cb,
_pyme_assuan_inquire_cb, _pyme_assuan_status_cb): Likewise.
* lang/python/setup.py.in: Make 'gpgme-config' emit the correct
cflags, and SWIG generate code to release the GIL before calling us.

Co-authored-by: Kai Michaelis <kai@gnupg.org>
Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-16 15:56:47 +02:00
Justus Winter
a458e7fe20 python: Adapt to 'gpgme_op_interact'.
* lang/python/examples/inter-edit.py: Update example.
* lang/python/gpgme.i (gpgme_edit_cb_t): Turn into
'gpgme_interact_cb_t'.
* lang/python/helpers.c (_pyme_edit_cb): Turn into
'_pyme_interact_cb_t'.
* lang/python/private.h (_pyme_edit_cb): Likewise.
* lang/python/pyme/constants/__init__.py: Replace numeric status codes
with the keywords.
* lang/python/pyme/constants/status.py: Likewise.
* lang/python/pyme/core.py (Context.interact): New method.
(Context.op_edit): Deprecate, update docstring, implement using
Context.interact.
* lang/python/tests/t-edit.py: Test both interfaces.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-16 14:56:29 +02:00
Justus Winter
594c3b8b05 python: Clarify that we support Python 2.7 too.
* lang/python/README: Use 'Python' instead of 'Python 3'.
* lang/python/pyme/version.py.in: Likewise.
* lang/python/setup.py.in: Add classifier for 2.7, drop 3 only.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-14 14:36:29 +02:00
Justus Winter
4011b2b2a1 python: Trim imports.
* lang/python/examples/encrypt-to-all.py: Drop unused import of 'os'.
* lang/python/examples/signverify.py: Likewise.
* lang/python/examples/simple.py: Likewise.
* lang/python/examples/verifydetails.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-14 14:35:00 +02:00
Justus Winter
44d18200d5 python: Improve error handling.
* lang/python/gpgme.i (gpgme_engine_info_t): Improve error handling.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-14 14:34:14 +02:00
Justus Winter
f6cd560ca7 python: Adapt to TOFU changes.
* lang/python/pyme/results.py (TofuInfo): Drop.
(Signature): The TOFU information moved to the key.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-14 14:32:48 +02:00
Justus Winter
24b4162d90 python: Build for both Python2 and Python3.
* NEWS: Update.
* configure.ac: Check for multiple Python versions.
* lang/python/Makefile.am: Build and install for both Python versions.
* lang/python/tests/Makefile.am: Test both versions.
* lang/python/tests/run-tests.py: New test runner.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-14 12:18:15 +02:00
Justus Winter
dc23fdf555 python: Import from __future__ to align behavior of Python 2.7.
--
Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-14 12:15:57 +02:00
Justus Winter
3b37c4efcf python: Use more generic shebang.
--
Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-14 12:15:57 +02:00
Justus Winter
70a3be27a5 python: Handle slight differences between Python 2 and 3.
* lang/python/helpers.c (pyDataWriteCb): Handle Python integers being
returned on Python 2.
(pyDataSeekCb): Likewise.
* lang/python/pyme/core.py (Data.__init__): Fix testing for string
argument.
(Data.new_from_filepart): Likewise.
* lang/python/pyme/util.py (is_a_string): New function.
* lang/python/tests/t-encrypt-large.py (read_cb): Force evaluation of
generator.
* lang/python/tests/t-idiomatic.py: Partly skip test on Python 2.
* lang/python/tests/t-verify.py (check_result): Here, the difference
between 2 and 3 really matters.  We cannot change the char *
conversion in Python 2 without breaking all existing applications, and
using bytestrings in Python 3 would be very inconvenient.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-13 13:29:43 +02:00
Justus Winter
4abff7d750 python: Fix types and error handling.
* lang/python/helpers.c (_pyme_edit_cb): Drop the const.
(_pyme_assuan_{data,inquire,status}_cb): Fix error handling.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-13 13:29:43 +02:00
Justus Winter
c0c50318bd python: Avoid Python3-only form of super().
* lang/python/pyme/core.py (GpgmeWrapper.__repr__): Use more
compatible form of super.
(GpgmeWrapper.__setattr__): Likewise.
(Context.__init__): Likewise.
(Data.__init__): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-12 17:24:18 +02:00
Justus Winter
1d5bbbf118 python: Make type translation compatible with Python 2.7.
* lang/python/gpgme.i: Avoid functions not available in Python 2.7.
* lang/python/helpers.c: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-12 17:11:19 +02:00
Justus Winter
70999d8161 python: Avoid hardcoding the interpreter.
* lang/python/setup.py.in: Avoid hardcoding the interpreter.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-12 16:19:07 +02:00
Justus Winter
b48b852a84 python: Do not rely on subprocess.DEVNULL.
* lang/python/setup.py.in: Do not rely on subprocess.DEVNULL.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-12 16:18:31 +02:00
Justus Winter
a0263ad282 tests: Make signature notation test compatible with older GnuPGs.
* lang/python/tests/t-sig-notation.py: Only check the critical flag
when GnuPG >= 2.1.13 is used.
* tests/gpg/t-sig-notation.c: Likewise.

Fixes-commit: c88c9ef3
Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-12 14:56:07 +02:00
Andre Heinecke
d480f6b701 qt: Fix some includes
* lang/qt/src/qgpgmekeyformailboxjob.cpp: Explicitly include
QStringList.
* lang/qt/tests/t-support.h, lang/qt/tests/t-support.cpp: Move
includes into impl. Explicitly include QDir.

--
This fixes build against Qt versions where the includes are less
implicit.
2016-09-12 10:52:10 +02:00
Justus Winter
7b9e6ea376 qt: Fix tofu test.
* lang/qt/tests/t-tofuinfo.cpp: Adjust member names.

Fixes-commit: 120b1478
Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-12 10:11:44 +02:00
Werner Koch
120b14783c
core,cpp: Extend the TOFU information.
* src/gpgme.h.in (struct _gpeme_tofu_info): Rename FIRSTSEEN to
SIGNFIRST and LASTSEEN to SIGNLAST.  Add ENCRFIST and ENCRLAST.
* src/keylist.c (parse_tfs_record): Parse to ENCRFIRST and ENCRLAST.
* src/verify.c (parse_tofu_stats): Ditto.
* tests/run-keylist.c (main): Adjust and print encrypt stats.
* tests/run-verify.c (print_result): Ditto.

* lang/cpp/src/tofuinfo.h (TofuInfo): Rename firstSeen to signFirst
and lastSeen to signLast.  Add encrCount, encrFirst and encrLast.
* lang/cpp/src/tofuinfo.cpp (encrCount, encrFirst, encrLast): New.
--

The latest GnuPG commits have the needed changes but we also allow the
use of currently released GnuPG version.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-07 09:26:11 +02:00
Andre Heinecke
ab3fbdbd05 qt: Clarify comment and strings in tofuinfo test
* lang/qt/tests/t-tofuinfo.cpp (testTofuSignCount)
(testTofuKeyList): Ensure distinct messages. Clarify comment.
2016-09-05 16:54:50 +02:00
Andre Heinecke
965b842fad qt: Enable signcount checks in tofuinfo test
* lang/qt/tests/t-tofuinfo.cpp: Enable checks for signcount.

--
Signcount for userIDs works now as expected with gnupg 2.1.16.
2016-09-05 12:58:35 +02:00
Andre Heinecke
79439e76cc cpp: Add convenience update function to a key
* lang/cpp/src/key.cpp (Key::update): New.
* lang/cpp/src/key.h: Update accordingly.

--
This function helps if you have an incomplete key or want
to make sure all info in a key is complete (e.g. validity / tofuinfo)
2016-09-05 12:53:02 +02:00
Andre Heinecke
444d85ace0 cpp: Add ostream operators for key and uid
* lang/cpp/src/key.cpp (Key, UserID): Add ostream operator.
* lang/cpp/src/key.h: Update accordingly.

--
This is helpful debugging / showing the state of a key / uid and
tofuinfo.
2016-09-05 11:57:09 +02:00
Andre Heinecke
8a39a595eb qt: Add missing header redirection
* lang/qt/src/keyformailboxjob.h,
lang/qt/src/qgpgmekeyformailboxjob.h: Fix includes.

--
This ensures that when building qgpgme you do not need an installed
gpgme++.
2016-09-05 10:44:41 +02:00
Andre Heinecke
e3a4697894 qt: Include cpp before core directory
* lang/qt/src/Makefile.am (AM_CPPFLAGS): Include cpp before core.

--
Both core and cpp have headers that have the same names, this
can lead to the wrong headers beeing included when qt bindings
are built.
2016-09-05 10:42:02 +02:00
Andre Heinecke
05570bd3d0 qt: Fix 2.1 t-support copy
* lang/qt/src/t-support.cpp (copyKeyring): Fix seckey copy.
2016-08-25 17:16:25 +02:00
Andre Heinecke
9fc72e928b qt: Fix and extend TofuInfo test.
* lang/qt/tests/t-tofuinfo.cpp: Delete executed jobs.
(testTofuKeyList): New.
(testSupported): Activate for 2.1.16
(signAndVerify): Disable sigcount tests.
2016-08-25 16:25:49 +02:00
Andre Heinecke
c875f07e55 qt: Fix keyring copy in tests
* lang/qt/test/t-encrypt.cpp,
lang/qt/test/t-tofuinfo.cpp: Assert on copy failure.
* lang/qt/test/t-support.cpp (copyKeyrings): Fix path.
2016-08-25 16:23:58 +02:00
Andre Heinecke
4e37d0bb12 qt: Add generic flag support for keylistjobs
* lang/qt/src/keylistjob.h (addMode): New.
* lang/qt/src/qgpgmekeylistjob.h (addMode): New.
* lang/qt/src/qgpgmekeylistjob.cpp (addMode: New.

--
Instead of new API for each new thing lets be a bit more
generic / open.
2016-08-25 16:22:12 +02:00
Andre Heinecke
5a92cc96da qt: Ensure that current src dir is included first
* lang/qt/src/Makefile.am: Reorder include directives.

--
This fixes the problem that QGpgME would pick up gpgme or
gpgme++ headers from an installed version.
2016-08-25 16:20:42 +02:00
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