summaryrefslogtreecommitdiff
path: root/lang/cpp
diff options
context:
space:
mode:
authorJinWang An <jinwang.an@samsung.com>2021-12-01 16:54:37 +0900
committerJinWang An <jinwang.an@samsung.com>2021-12-01 16:54:37 +0900
commitfd4d11c14daa6a54c81202dffc02cc419fa67568 (patch)
treee14910ad034ec7b4d10552a13e219174ccd4946d /lang/cpp
parent442a1386c9708114c2b721afea60d5593e36c423 (diff)
downloadgpgme-fd4d11c14daa6a54c81202dffc02cc419fa67568.tar.gz
gpgme-fd4d11c14daa6a54c81202dffc02cc419fa67568.tar.bz2
gpgme-fd4d11c14daa6a54c81202dffc02cc419fa67568.zip
Imported Upstream version 1.11.0upstream/1.11.0
Diffstat (limited to 'lang/cpp')
-rw-r--r--lang/cpp/src/context.h3
-rw-r--r--lang/cpp/src/data.cpp14
-rw-r--r--lang/cpp/src/data.h3
-rw-r--r--lang/cpp/src/importresult.cpp5
-rw-r--r--lang/cpp/src/importresult.h1
-rw-r--r--lang/cpp/src/key.cpp21
-rw-r--r--lang/cpp/src/key.h14
7 files changed, 60 insertions, 1 deletions
diff --git a/lang/cpp/src/context.h b/lang/cpp/src/context.h
index 4cd5b30..aff8e49 100644
--- a/lang/cpp/src/context.h
+++ b/lang/cpp/src/context.h
@@ -408,7 +408,8 @@ public:
enum SpawnFlags {
SpawnNone = 0,
SpawnDetached = 1,
- SpawnAllowSetFg = 2
+ SpawnAllowSetFg = 2,
+ SpawnShowWindow = 4
};
/** Spwan the process \a file with arguments \a argv.
*
diff --git a/lang/cpp/src/data.cpp b/lang/cpp/src/data.cpp
index 32ca561..52b8da2 100644
--- a/lang/cpp/src/data.cpp
+++ b/lang/cpp/src/data.cpp
@@ -254,3 +254,17 @@ std::vector<GpgME::Key> GpgME::Data::toKeys(Protocol proto) const
delete ctx;
return ret;
}
+
+std::string GpgME::Data::toString()
+{
+ std::string ret;
+ char buf[4096];
+ size_t nread;
+ seek (0, SEEK_SET);
+ while ((nread = read (buf, 4096)) > 0)
+ {
+ ret += std::string (buf, nread);
+ }
+ seek (0, SEEK_SET);
+ return ret;
+}
diff --git a/lang/cpp/src/data.h b/lang/cpp/src/data.h
index cc7906f..446f6fa 100644
--- a/lang/cpp/src/data.h
+++ b/lang/cpp/src/data.h
@@ -114,6 +114,9 @@ public:
* Protocol proto. Returns an empty list on error.*/
std::vector<Key> toKeys(const Protocol proto = Protocol::OpenPGP) const;
+ /** Return a copy of the data as std::string. Sets seek pos to 0 */
+ std::string toString();
+
class Private;
Private *impl()
{
diff --git a/lang/cpp/src/importresult.cpp b/lang/cpp/src/importresult.cpp
index 8c35f9c..dbb31d0 100644
--- a/lang/cpp/src/importresult.cpp
+++ b/lang/cpp/src/importresult.cpp
@@ -154,6 +154,11 @@ int GpgME::ImportResult::notImported() const
return d ? d->res.not_imported : 0 ;
}
+int GpgME::ImportResult::numV3KeysSkipped() const
+{
+ return d ? d->res.skipped_v3_keys : 0 ;
+}
+
GpgME::Import GpgME::ImportResult::import(unsigned int idx) const
{
return Import(d, idx);
diff --git a/lang/cpp/src/importresult.h b/lang/cpp/src/importresult.h
index 2f0e7f2..0547679 100644
--- a/lang/cpp/src/importresult.h
+++ b/lang/cpp/src/importresult.h
@@ -78,6 +78,7 @@ public:
int numSecretKeysUnchanged() const;
int notImported() const;
+ int numV3KeysSkipped() const;
Import import(unsigned int idx) const;
std::vector<Import> imports() const;
diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index 66fdea9..0e86a19 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 829bd26..c3c711c 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
{