[seahorse/feature/seahorse-pgp-key-api: 1/8] pgp-key: Add API to get whether key is private




commit 1e2e7ea35a4dc80bb8faf1951fb75d564ef09b93
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Sun Aug 15 10:47:23 2021 +0200

    pgp-key: Add API to get whether key is private

 pgp/seahorse-pgp-key.c | 11 +++++++++++
 pgp/seahorse-pgp-key.h |  2 ++
 2 files changed, 13 insertions(+)
---
diff --git a/pgp/seahorse-pgp-key.c b/pgp/seahorse-pgp-key.c
index df7920ff..a0ee0658 100644
--- a/pgp/seahorse-pgp-key.c
+++ b/pgp/seahorse-pgp-key.c
@@ -573,6 +573,17 @@ seahorse_pgp_key_has_keyid (SeahorsePgpKey *self, const char *match)
     return FALSE;
 }
 
+gboolean
+seahorse_pgp_key_is_private_key (SeahorsePgpKey *self)
+{
+    SeahorseUsage usage;
+
+    g_return_val_if_fail (SEAHORSE_PGP_IS_KEY (self), FALSE);
+
+    usage = seahorse_object_get_usage (SEAHORSE_OBJECT (self));
+    return usage == SEAHORSE_USAGE_PRIVATE_KEY;
+}
+
 static void
 seahorse_pgp_key_init (SeahorsePgpKey *self)
 {
diff --git a/pgp/seahorse-pgp-key.h b/pgp/seahorse-pgp-key.h
index d73e152b..c435e255 100644
--- a/pgp/seahorse-pgp-key.h
+++ b/pgp/seahorse-pgp-key.h
@@ -83,6 +83,8 @@ const char*       seahorse_pgp_key_get_keyid            (SeahorsePgpKey *self);
 gboolean          seahorse_pgp_key_has_keyid            (SeahorsePgpKey *self,
                                                          const char     *keyid);
 
+gboolean          seahorse_pgp_key_is_private_key       (SeahorsePgpKey *self);
+
 const char*       seahorse_pgp_key_calc_identifier      (const char *keyid);
 
 guint             seahorse_pgp_keyid_hash               (gconstpointer v);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]