aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore42
-rw-r--r--NEWS6
-rw-r--r--lang/cpp/src/key.cpp21
-rw-r--r--lang/cpp/src/key.h14
4 files changed, 83 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 4c37222c..de173b8f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+# GnuPG exclusions
/aclocal.m4
/autom4te.cache
/config.h.in
@@ -11,3 +12,44 @@ Makefile
stamp-h1
*.o
*.lo
+
+# Hidden files
+*~
+
+# Byte compiled Python
+*.py[cod]
+__pycache__
+
+# C extensions
+*.so
+
+# Packages
+*.egg
+*.egg-info
+build
+eggs
+parts
+develop-eggs
+.installed.cfg
+
+# Installer logs
+pip-log.txt
+
+# Unit test / coverage reports
+.coverage
+.tox
+nosetests.xml
+
+# Translations
+*.mo
+
+# Mr Developer
+.mr.developer.cfg
+.project
+.pydevproject
+
+# Assorted Apple crap
+default.profraw
+.DS_Store
+._.DS_Store
+default.profraw \ No newline at end of file
diff --git a/NEWS b/NEWS
index 40d5b539..1a342b18 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,12 @@
Noteworthy changes in version 1.10.1 (unreleased)
-------------------------------------------------
+ * Interface changes relative to the 1.10.0 release:
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ cpp: Key::locate NEW.
+ cpp: Data::toString NEW.
+
+
Noteworthy changes in version 1.10.0 (2017-12-12)
-------------------------------------------------
diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index 66fdea96..0e86a19e 100644
--- a/lang/cpp/src/key.cpp
+++ b/lang/cpp/src/key.cpp
@@ -371,6 +371,27 @@ void Key::update()
return;
}
+// static
+Key Key::locate(const char *mbox)
+{
+ if (!mbox) {
+ return Key();
+ }
+
+ auto ctx = Context::createForProtocol(OpenPGP);
+ if (!ctx) {
+ return Key();
+ }
+
+ ctx->setKeyListMode (Extern | Local);
+
+ Error e = ctx->startKeyListing (mbox);
+ auto ret = ctx->nextKey (e);
+ delete ctx;
+
+ return ret;
+}
+
//
//
// class Subkey
diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h
index 829bd266..c3c711c1 100644
--- a/lang/cpp/src/key.h
+++ b/lang/cpp/src/key.h
@@ -164,6 +164,20 @@ public:
* @returns a possible error.
**/
Error addUid(const char *uid);
+
+ /**
+ * @brief try to locate the best pgp key for a given mailbox.
+ *
+ * Boils down to gpg --locate-key <mbox>
+ * This may take some time if remote sources are also
+ * used.
+ *
+ * @param mbox should be a mail address does not need to be normalized.
+ *
+ * @returns The best key for a mailbox or a null key.
+ */
+ static Key locate(const char *mbox);
+
private:
gpgme_key_t impl() const
{