[seahorse] pgp-key-properties: Show whether subkeys can be used for signing/encryption



commit 23d1f7e575e12919577ea7428898e1f34c6bb150
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon May 12 21:00:58 2014 -0500

    pgp-key-properties: Show whether subkeys can be used for signing/encryption
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730044
    Signed-off-by: Federico Mena Quintero <federico gnome org>
    Signed-off-by: Stef Walter <stefw gnome org>
     * Fixed whitespace

 pgp/seahorse-pgp-key-properties.c |   38 +++++++++++++++++++++++-------------
 pgp/seahorse-pgp-subkey.c         |   27 ++++++++++++++++++++++++++
 pgp/seahorse-pgp-subkey.h         |    2 +
 3 files changed, 53 insertions(+), 14 deletions(-)
---
diff --git a/pgp/seahorse-pgp-key-properties.c b/pgp/seahorse-pgp-key-properties.c
index c0e1616..49c773b 100644
--- a/pgp/seahorse-pgp-key-properties.c
+++ b/pgp/seahorse-pgp-key-properties.c
@@ -1001,6 +1001,7 @@ enum {
        SUBKEY_OBJECT,
        SUBKEY_ID,
        SUBKEY_TYPE,
+       SUBKEY_USAGE,
        SUBKEY_CREATED,
        SUBKEY_EXPIRES,
        SUBKEY_STATUS,
@@ -1009,13 +1010,14 @@ enum {
 };
 
 const GType subkey_columns[] = {
-    G_TYPE_OBJECT,  /* index */
-    G_TYPE_STRING,  /* id */
-    G_TYPE_STRING,  /* created */
-    G_TYPE_STRING,  /* expires */
-    G_TYPE_STRING,  /* status  */
-    G_TYPE_STRING,  /* type */
-    G_TYPE_UINT     /* length*/
+    G_TYPE_OBJECT,  /* SUBKEY_OBJECT */
+    G_TYPE_STRING,  /* SUBKEY_ID */
+    G_TYPE_STRING,  /* SUBKEY_TYPE */
+    G_TYPE_STRING,  /* SUBKEY_USAGE */
+    G_TYPE_STRING,  /* SUBKEY_CREATED */
+    G_TYPE_STRING,  /* SUBKEY_EXPIRES  */
+    G_TYPE_STRING,  /* SUBKEY_STATUS */
+    G_TYPE_UINT     /* SUBKEY_LENGTH */
 };
 
 /* trust combo box list */
@@ -1433,6 +1435,9 @@ do_details (SeahorseWidget *swidget)
                                                      -1, _("Type"), gtk_cell_renderer_text_new (), 
                                                      "text", SUBKEY_TYPE, NULL);
         gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (widget),
+                                                     -1, _("Usage"), gtk_cell_renderer_text_new (),
+                                                     "text", SUBKEY_USAGE, NULL);
+        gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (widget),
                                                      -1, _("Created"), gtk_cell_renderer_text_new (), 
                                                      "text", SUBKEY_CREATED, NULL);
         gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (widget),
@@ -1451,6 +1456,7 @@ do_details (SeahorseWidget *swidget)
                const gchar *status = NULL;
                gchar *expiration_date;
                gchar *created_date;
+               gchar *usage;
                gulong expires;
                guint flags;
                
@@ -1474,20 +1480,24 @@ do_details (SeahorseWidget *swidget)
                        expiration_date = seahorse_util_get_display_date_string (expires);
 
                created_date = seahorse_util_get_display_date_string (seahorse_pgp_subkey_get_created 
(subkey));
-        
+
+               usage = seahorse_pgp_subkey_get_usage (subkey);
+
                gtk_list_store_append (store, &iter);
-               gtk_list_store_set (store, &iter,  
-                                   SUBKEY_OBJECT, l->data,
-                                   SUBKEY_ID, seahorse_pgp_subkey_get_keyid (l->data),
-                                   SUBKEY_TYPE, seahorse_pgp_subkey_get_algorithm (l->data),
+               gtk_list_store_set (store, &iter,
+                                   SUBKEY_OBJECT, subkey,
+                                   SUBKEY_ID, seahorse_pgp_subkey_get_keyid (subkey),
+                                   SUBKEY_TYPE, seahorse_pgp_subkey_get_algorithm (subkey),
+                                   SUBKEY_USAGE, usage,
                                    SUBKEY_CREATED, created_date,
                                    SUBKEY_EXPIRES, expiration_date,
-                                   SUBKEY_STATUS,  status, 
+                                   SUBKEY_STATUS, status,
                                    SUBKEY_LENGTH, seahorse_pgp_subkey_get_length (subkey),
                                    -1);
-        
+
                g_free (expiration_date);
                g_free (created_date);
+               g_free (usage);
        } 
 }
 
diff --git a/pgp/seahorse-pgp-subkey.c b/pgp/seahorse-pgp-subkey.c
index 826723e..3fd78fc 100644
--- a/pgp/seahorse-pgp-subkey.c
+++ b/pgp/seahorse-pgp-subkey.c
@@ -279,6 +279,33 @@ seahorse_pgp_subkey_set_length (SeahorsePgpSubkey *self, guint length)
        g_object_notify (G_OBJECT (self), "length");
 }
 
+gchar *
+seahorse_pgp_subkey_get_usage (SeahorsePgpSubkey *self)
+{
+       GString *str;
+       gboolean previous;
+
+       g_return_val_if_fail (SEAHORSE_IS_PGP_SUBKEY (self), NULL);
+
+       str = g_string_new (NULL);
+
+       previous = FALSE;
+
+       if (self->pv->flags & SEAHORSE_FLAG_CAN_ENCRYPT) {
+               previous = TRUE;
+               g_string_append (str, _("Encrypt"));
+       }
+
+       if (self->pv->flags & SEAHORSE_FLAG_CAN_SIGN) {
+               if (previous)
+                       g_string_append (str, ", ");
+
+               g_string_append (str, _("Sign"));
+       }
+
+       return g_string_free (str, FALSE);
+}
+
 const gchar*
 seahorse_pgp_subkey_get_algorithm (SeahorsePgpSubkey *self)
 {
diff --git a/pgp/seahorse-pgp-subkey.h b/pgp/seahorse-pgp-subkey.h
index c3c3b7a..eb6c855 100644
--- a/pgp/seahorse-pgp-subkey.h
+++ b/pgp/seahorse-pgp-subkey.h
@@ -74,6 +74,8 @@ guint               seahorse_pgp_subkey_get_length        (SeahorsePgpSubkey *se
 void                seahorse_pgp_subkey_set_length        (SeahorsePgpSubkey *self,
                                                            guint index);
 
+gchar *             seahorse_pgp_subkey_get_usage         (SeahorsePgpSubkey *self);
+
 gulong              seahorse_pgp_subkey_get_created       (SeahorsePgpSubkey *self);
 
 void                seahorse_pgp_subkey_set_created       (SeahorsePgpSubkey *self,


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