Commit Graph

33 Commits

Author SHA1 Message Date
Werner Koch
c8048bf8eb
core: New keylist mode GPGME_KEYLIST_MODE_WITH_KEYGRIP.
* src/gpgme.h.in (GPGME_KEYLIST_MODE_WITH_KEYGRIP): New.
* src/gpgme-json.c (op_keylist): New flag "keygrip".
* src/engine-gpg.c (gpg_keylist_build_options): Pass the options.

* lang/cpp/src/global.h (WithKeygrip): New.
* lang/cpp/src/context.cpp: Add check.
* lang/cpp/src/key.cpp (Key::update): Handle WithKeygrip.
* lang/cpp/src/verificationresult.cpp: Ditto.
* lang/cpp/src/util.h (add_to_gpgme_keylist_mode_t): Ditto.
--

GnuPG-bug-id: 4939
Signed-off-by: Werner Koch <wk@gnupg.org>
2020-07-15 14:11:17 +02:00
Andre Heinecke
7981ec4147
cpp: Add wrapper for gpgme_set_global_flag
* lang/cpp/src/context.cpp (setGlobalFlag): New.
* lang/cpp/src/global.h (setGlobalFlag): Export it.

--
GnuPG-Bug-Id: T4471
2019-04-24 12:36:14 +02:00
Andre Heinecke
c4cc47ee8f
cpp: Fix Error::hasSystemError
* lang/cpp/src/context.cpp (Error::hasSystemError): Invert logic to
do what it says.

--
This is safe because according to codesearch it is only used
in QGpgME
2019-03-13 12:02:05 +01:00
Andre Heinecke
1d31420650
qt,cpp: Consistently use nullptr and override
* lang/cpp/src/Makefile.am, lang/qt/src/Makefile.am (AM_CPPFLAGS):
Add suggest-override and zero-as-null-pointer-constant warnings.

* lang/cpp/src/*, lang/qt/src/*: Consistenly use nullptr and override.

--
This was especially important for the headers so that downstream
users of GpgME++ or QGpgME do not get flooded by warnings if
they have these warnings enabled.

It also improves compiler errors/warnings in case of accidental
mistakes.
2018-12-03 12:25:00 +01:00
Andre Heinecke
05a0e97f5c
cpp: Add some convenience functions
* lang/cpp/src/context.cpp (Context::create): New.
* lang/cpp/src/context.h: Update accordingly.
* lang/cpp/src/key.cpp, lang/cpp/src/key.h:
(Key::isBad, Subkey::isBad, UserID::isBad)
(UserID::Signature::isBad): Add shorthand for the isX checks.
* NEWS: Mention it.

--
I don't know how often I wrote:
if (key.isNull() || key.isExpired() || key.isRevoked() ...

And for the context it is good practice to use a unique ptr
so the API should make it easy.
2018-10-25 14:13:39 +02:00
Andre Heinecke
7a1e6dbfb1
cpp: Initialize all gpgme_key_t's in context
* lang/cpp/src/context.cpp (Context::startKeyListing),
(Context::keyListResult, Context::signingKeys): Initialize key.

--
"Should" not be neccessary but it's cleaner and would have
covered the case of the previous commit.
2018-10-09 10:47:16 +02:00
Andre Heinecke
629afebe50
cpp: Add enum mapping for GPGME_AUDIT_LOG_DIAG
* src/context.cpp (to_auditlog_flags): Map DIAG value.
* src/context.h (AuditLogFlags): Add it.
2018-07-05 11:29:36 +02:00
Andre Heinecke
8dff414e17
cpp: Add proper gpgme_op_createkey
* lang/cpp/src/context.cpp, lang/cpp/src/context.h
(Context::createKeyEx): New.

--
The createKeyEx function follows the usual pattern that the
synchronous call returns a result directly while for the
async an extra call is neccessary.
2018-06-08 16:19:47 +02:00
Andre Heinecke
00b027af86
cpp: Add gpgme_(get)set_ctx_flag
* NEWS: Mention API extensions.
* lang/cpp/src/context.cpp, lang/cpp/src/context.h
(Context::setFlag, Context::getFlag): New.
2018-06-01 11:10:45 +02:00
Andre Heinecke
8e2d6c28a5
cpp: Wrap create_key and create_subkey
* lang/cpp/src/context.cpp,
lang/cpp/src/context.h (Context::startCreateKey)
(Context::createKey, Context::createSubkey)
(Context::startCreateSubkey): New.
2017-12-01 13:21:34 +01:00
Andre Heinecke
18b7906078
cpp: Respect decrypt flags in new functions
* lang/cpp/src/context.cpp: Respect directly provided flags
in the new decrypt functions.

--
Overlooked in the initial commit. Also fixed the according
unused variable warnings.
2017-03-24 17:24:04 +01:00
Andre Heinecke
8ad37ecc29
cpp: Use gpgme_op_decrypt_ex and add new flags.
* lang/cpp/src/context.cpp: New decrypt and decryptVerify functions
that take flags as arguments. Use new variants in old functions.
(Context::setDecryptionFlags): New helper.
(Context::Private::Private): Initialize new member.
* lang/cpp/src/context_p.h (Context::Private::decryptFlags): New.
* lang/cpp/src/context.h (Context::DecryptFlags): New enum.
(Context::EncryptionFlags): Extend for EncryptWrap.

--
The setDecryptionFlags provides a generic way to set decryption
flags for the whole context. This allows existing code to just
keep using the old functions and modify the decryption behavior
in a central place.
2017-03-24 16:51:26 +01:00
Andre Heinecke
e416f99618 cpp: Add revuid and adduid support
* lang/cpp/src/context.cpp
(Context::revUid, Context::startRevUid),
(Context::addUid, Context::startAddUid): New.
* lang/cpp/src/context.h: Declare new functions.
* lang/cpp/src/key.cpp (Key::UserID::revoke)
(Key::addUid): Idomatic helpers.
lang/cpp/src/key.h: Declare new functions.
* NEWS: Update accordingly.
2017-01-11 16:14:45 +01:00
Andre Heinecke
d09a84eaf1 cpp: Add get / set Sender API
* cpp/src/context.cpp, cpp/src/context.h (Context::setSender),
(Context::getSender): Add simple wrappers.
2016-11-14 20:47:17 +01:00
Andre Heinecke
39dd7585f5 cpp: Fix gcc diagnostic push / pop
* lang/cpp/src/context.cpp: Fix pragmas.

--
This fixes an error with -Werror=unknown-pragmas
2016-10-05 16:27:18 +02:00
Andre Heinecke
a142f187b7 cpp, qt: Include config.h
lang/cpp/src/callbacks.cpp,
lang/cpp/src/configuration.cpp,
lang/cpp/src/context.cpp,
lang/cpp/src/context_glib.cpp,
lang/cpp/src/context_qt.cpp,
lang/cpp/src/context_vanilla.cpp,
lang/cpp/src/data.cpp,
lang/cpp/src/decryptionresult.cpp,
lang/cpp/src/defaultassuantransaction.cpp,
lang/cpp/src/editinteractor.cpp,
lang/cpp/src/encryptionresult.cpp,
lang/cpp/src/engineinfo.cpp,
lang/cpp/src/eventloopinteractor.cpp,
lang/cpp/src/exception.cpp,
lang/cpp/src/gpgadduserideditinteractor.cpp,
lang/cpp/src/gpgagentgetinfoassuantransaction.cpp,
lang/cpp/src/gpgsetexpirytimeeditinteractor.cpp,
lang/cpp/src/gpgsetownertrusteditinteractor.cpp,
lang/cpp/src/gpgsignkeyeditinteractor.cpp,
lang/cpp/src/importresult.cpp,
lang/cpp/src/key.cpp,
lang/cpp/src/keygenerationresult.cpp,
lang/cpp/src/keylistresult.cpp,
lang/cpp/src/scdgetinfoassuantransaction.cpp,
lang/cpp/src/signingresult.cpp,
lang/cpp/src/tofuinfo.cpp,
lang/cpp/src/trustitem.cpp,
lang/cpp/src/verificationresult.cpp,
lang/cpp/src/vfsmountresult.cpp,
lang/qt/src/dataprovider.cpp,
lang/qt/src/defaultkeygenerationjob.cpp,
lang/qt/src/gpgme_backend_debug.cpp,
lang/qt/src/job.cpp,
lang/qt/src/qgpgmeadduseridjob.cpp,
lang/qt/src/qgpgmebackend.cpp,
lang/qt/src/qgpgmechangeexpiryjob.cpp,
lang/qt/src/qgpgmechangeownertrustjob.cpp,
lang/qt/src/qgpgmechangepasswdjob.cpp,
lang/qt/src/qgpgmedecryptjob.cpp,
lang/qt/src/qgpgmedecryptverifyjob.cpp,
lang/qt/src/qgpgmedeletejob.cpp,
lang/qt/src/qgpgmedownloadjob.cpp,
lang/qt/src/qgpgmeencryptjob.cpp,
lang/qt/src/qgpgmeexportjob.cpp,
lang/qt/src/qgpgmeimportfromkeyserverjob.cpp,
lang/qt/src/qgpgmeimportjob.cpp,
lang/qt/src/qgpgmekeyformailboxjob.cpp,
lang/qt/src/qgpgmekeygenerationjob.cpp,
lang/qt/src/qgpgmekeylistjob.cpp,
lang/qt/src/qgpgmelistallkeysjob.cpp,
lang/qt/src/qgpgmenewcryptoconfig.cpp,
lang/qt/src/qgpgmerefreshkeysjob.cpp,
lang/qt/src/qgpgmesecretkeyexportjob.cpp,
lang/qt/src/qgpgmesignencryptjob.cpp,
lang/qt/src/qgpgmesignjob.cpp,
lang/qt/src/qgpgmesignkeyjob.cpp,
lang/qt/src/qgpgmetofupolicyjob.cpp,
lang/qt/src/qgpgmeverifydetachedjob.cpp,
lang/qt/src/qgpgmeverifyopaquejob.cpp,
lang/qt/src/qgpgmewkspublishjob.cpp,
lang/qt/src/threadedjobmixin.cpp,
lang/qt/tests/run-keyformailboxjob.cpp,
lang/qt/tests/t-encrypt.cpp,
lang/qt/tests/t-keylist.cpp,
lang/qt/tests/t-keylocate.cpp,
lang/qt/tests/t-ownertrust.cpp,
lang/qt/tests/t-support.cpp,
lang/qt/tests/t-tofuinfo.cpp,
lang/qt/tests/t-wkspublish.cpp: Include config.h

--
This fixes problems with mismatching definitions. Most
notably _FILE_OFFSET_BITS is now always set correctly.
2016-09-23 15:25:51 +02:00
Andreas Stieger
ae324b51ff cpp: Avoid missing returns in non-void functions
* lang/cpp/src/context.cpp
  (Context::signaturePolicyURL): return nullptr on default
  (to_tofu_policy_t): add default case for unknown
* lang/cpp/src/key.cpp
  (Key::primaryFingerprint): return nullptr on default
* lang/cpp/src/tofuinfo.cpp
  (GpgME::TofuInfo::policy): add default case for unknown

Signed-off-by: Andreas Stieger <astieger@suse.com>
Signed-off-by: Andre Heinecke <aheinecke@intevation.de>
2016-09-21 16:46:06 +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
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
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
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
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
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
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
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
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
9b36ebf37a Qt / Cpp: Port auto_ptr to unique_ptr
* lang/cpp/src/context.cpp,
lang/cpp/src/context.h,
lang/cpp/src/context_p.h (Context::createForEngine),
(Context::edit, Context::startEditing),
(Context::takeLastEditInteractor, Context::cardEdit),
(Context::startCardEditing, Context::takeLastCardEditInteractor),
(Context::assuanTransact, Context::startAssuanTransaction),
(Context::takeLastAssuanTransaction): Port to unique_ptr.
* lang/qt/src/qgpgmeadduseridjob.cpp,
lang/qt/src/qgpgmechangeexpiryjob.cpp,
lang/qt/src/qgpgmechangeownertrustjob.cpp,
lang/qt/src/qgpgmechangepasswdjob.cpp,
lang/qt/src/qgpgmesignkeyjob.cpp: Update accordingly.

--
This is another API break but as we already broke API with GpgME++
and QGpgME from KDE Frameworks this is a good time to do this
to avoid using a deprected C++ class in the API.
2016-05-17 17:54:53 +02:00
Andre Heinecke
691950e18c Cpp: Remove last usages of boost
* lang/cpp/src/configuration.cpp: Use std::remove_pointer.
  (Configuration::operator<<): std::for_each.
* lang/cpp/src/context.cpp: Delete manually instead of scoped ptr.
* lang/cpp/src/scdgetinfoassuantransaction.cpp: Use static_assert.
  (to_reader_list): Tokenize with getline.
2016-04-11 17:00:59 +02:00
Andre Heinecke
433bb8e84b Remove feature check ifdefs
* lang/cpp/src/assuanresult.cpp,
 lang/cpp/src/callbacks.cpp,
 lang/cpp/src/configuration.cpp,
 lang/cpp/src/context.cpp,
 lang/cpp/src/context_glib.cpp,
 lang/cpp/src/context_qt.cpp,
 lang/cpp/src/context_vanilla.cpp,
 lang/cpp/src/data.cpp,
 lang/cpp/src/decryptionresult.cpp,
 lang/cpp/src/defaultassuantransaction.cpp,
 lang/cpp/src/editinteractor.cpp,
 lang/cpp/src/encryptionresult.cpp,
 lang/cpp/src/engineinfo.cpp,
 lang/cpp/src/eventloopinteractor.cpp,
 lang/cpp/src/global.h,
 lang/cpp/src/gpgagentgetinfoassuantransaction.cpp,
 lang/cpp/src/importresult.cpp,
 lang/cpp/src/interfaces/assuantransaction.h,
 lang/cpp/src/key.cpp,
 lang/cpp/src/keygenerationresult.cpp,
 lang/cpp/src/keylistresult.cpp,
 lang/cpp/src/scdgetinfoassuantransaction.cpp,
 lang/cpp/src/signingresult.cpp,
 lang/cpp/src/trustitem.cpp,
 lang/cpp/src/util.h,
 lang/cpp/src/verificationresult.cpp,
 lang/cpp/src/vfsmountresult.cpp: Remove feature checks.
2016-02-22 19:07:41 +01:00
Andre Heinecke
0855a1296a Initial checkin of gpgmepp sources
Based on git.kde.org/pim/gpgmepp rev. 0e3ebc02

* lang/cpp/src/assuanresult.cpp,
 lang/cpp/src/assuanresult.h,
 lang/cpp/src/callbacks.cpp,
 lang/cpp/src/callbacks.h,
 lang/cpp/src/configuration.cpp,
 lang/cpp/src/configuration.h,
 lang/cpp/src/context.cpp,
 lang/cpp/src/context.h,
 lang/cpp/src/context_glib.cpp,
 lang/cpp/src/context_p.h,
 lang/cpp/src/context_qt.cpp,
 lang/cpp/src/context_vanilla.cpp,
 lang/cpp/src/data.cpp,
 lang/cpp/src/data.h,
 lang/cpp/src/data_p.h,
 lang/cpp/src/decryptionresult.cpp,
 lang/cpp/src/decryptionresult.h,
 lang/cpp/src/defaultassuantransaction.cpp,
 lang/cpp/src/defaultassuantransaction.h,
 lang/cpp/src/editinteractor.cpp,
 lang/cpp/src/editinteractor.h,
 lang/cpp/src/encryptionresult.cpp,
 lang/cpp/src/encryptionresult.h,
 lang/cpp/src/engineinfo.cpp,
 lang/cpp/src/engineinfo.h,
 lang/cpp/src/error.h,
 lang/cpp/src/eventloopinteractor.cpp,
 lang/cpp/src/eventloopinteractor.h,
 lang/cpp/src/exception.cpp,
 lang/cpp/src/exception.h,
 lang/cpp/src/global.h,
 lang/cpp/src/gpgadduserideditinteractor.cpp,
 lang/cpp/src/gpgadduserideditinteractor.h,
 lang/cpp/src/gpgagentgetinfoassuantransaction.cpp,
 lang/cpp/src/gpgagentgetinfoassuantransaction.h,
 lang/cpp/src/gpgmefw.h,
 lang/cpp/src/gpgmepp_export.h,
 lang/cpp/src/gpgsetexpirytimeeditinteractor.cpp,
 lang/cpp/src/gpgsetexpirytimeeditinteractor.h,
 lang/cpp/src/gpgsetownertrusteditinteractor.cpp,
 lang/cpp/src/gpgsetownertrusteditinteractor.h,
 lang/cpp/src/gpgsignkeyeditinteractor.cpp,
 lang/cpp/src/gpgsignkeyeditinteractor.h,
 lang/cpp/src/importresult.cpp,
 lang/cpp/src/importresult.h,
 lang/cpp/src/key.cpp,
 lang/cpp/src/key.h,
 lang/cpp/src/keygenerationresult.cpp,
 lang/cpp/src/keygenerationresult.h,
 lang/cpp/src/keylistresult.cpp,
 lang/cpp/src/keylistresult.h,
 lang/cpp/src/notation.h,
 lang/cpp/src/result.h,
 lang/cpp/src/result_p.h,
 lang/cpp/src/scdgetinfoassuantransaction.cpp,
 lang/cpp/src/scdgetinfoassuantransaction.h,
 lang/cpp/src/signingresult.cpp,
 lang/cpp/src/signingresult.h,
 lang/cpp/src/trustitem.cpp,
 lang/cpp/src/trustitem.h,
 lang/cpp/src/util.h,
 lang/cpp/src/verificationresult.cpp,
 lang/cpp/src/verificationresult.h,
 lang/cpp/src/vfsmountresult.cpp,
 lang/cpp/src/vfsmountresult.h,
 lang/cpp/src/interfaces/assuantransaction.h,
 lang/cpp/src/interfaces/dataprovider.h,
 lang/cpp/src/interfaces/passphraseprovider.h,
 lang/cpp/src/interfaces/progressprovider.h: New.
2016-02-22 19:01:37 +01:00