[Gpa-commits] r844 - in trunk: . src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Mar 11 16:45:53 CET 2008
Author: werner
Date: 2008-03-11 16:45:52 +0100 (Tue, 11 Mar 2008)
New Revision: 844
Modified:
trunk/NEWS
trunk/src/ChangeLog
trunk/src/gpgmetools.c
trunk/src/keylist.c
trunk/src/keylist.h
trunk/src/keyring.c
trunk/src/recipientdlg.c
trunk/src/selectkeydlg.c
Log:
Add more support for X.509.
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2008-03-11 14:28:06 UTC (rev 843)
+++ trunk/NEWS 2008-03-11 15:45:52 UTC (rev 844)
@@ -9,6 +9,10 @@
* GPA supports manipulating the backend configuration through
gpg-conf.
+ * GPA has now basic support for X.509; use the command line switch
+ --cms to enable this.
+
+
Noteworthy changes in version 0.7.6 (2007-05-24)
------------------------------------------------
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2008-03-11 14:28:06 UTC (rev 843)
+++ trunk/src/ChangeLog 2008-03-11 15:45:52 UTC (rev 844)
@@ -1,3 +1,27 @@
+2008-03-11 Werner Koch <wk at g10code.com>
+
+ * selectkeydlg.c (select_key_dlg_constructor): List only encrypt keys.
+ * keylist.h (KEY_USAGE_SIGN): Add key usage flags.
+ (_GpaKeyList): Add field REQUESTED_USAGE.
+ * keylist.c (gpa_keylist_new_with_keys): Add arg REQUESTED_USAGE.
+ (PROP_REQUESTED_USAGE): New.
+ (gpa_keylist_get_property, gpa_keylist_set_property)
+ (gpa_keylist_class_init): Install property.
+ (gpa_keylist_next): Filetr on usage and account.
+ * recipientdlg.c (parse_one_recipient): List only keys with
+ encrypt capability.
+
+ * keylist.c (gpa_keylist_constructor): Add a new column.
+ (GpaKeyListColumn): Add GPA_KEYLIST_COLUMN_KEYTYPE.
+ (gpa_keylist_next, setup_columns): Fill this column.
+
+ * gpgmetools.c (gpa_key_ownertrust_string): No ownertrust for X.509.
+ * keyring.c (keyring_editor_selection_changed): Set the protocol
+ before doing a key list.
+ (keyring_editor_has_single_selection_OpenPGP): New.
+ (keyring_editor_menubar_new): Use it for ownertrust.
+ (keyring_editor_popup_menu_new): Ditto.
+
2008-03-11 Marcus Brinkmann <marcus at g10code.de>
* settingsdlg.c: Include settingsdlg.h. Beautify code.
@@ -4973,7 +4997,7 @@
* gpa.c (gpa_file_toolbar_new): Use this new function here.
* gtktools.c (gpa_xpm_label_box): Ditto
* keysmenu.c (getIconNameForOwnertrust): Replaces
- getIconForOwnertrust. Chnaged all callers to provide a string now.
+ getIconForOwnertrust. Changed all callers to provide a string now.
2000-08-17 Werner Koch <wk at gnupg.org>
Modified: trunk/src/gpgmetools.c
===================================================================
--- trunk/src/gpgmetools.c 2008-03-11 14:28:06 UTC (rev 843)
+++ trunk/src/gpgmetools.c 2008-03-11 15:45:52 UTC (rev 844)
@@ -539,6 +539,9 @@
const gchar *
gpa_key_ownertrust_string (gpgme_key_t key)
{
+ if (key->protocol == GPGME_PROTOCOL_CMS)
+ return "";
+
switch (key->owner_trust)
{
case GPGME_VALIDITY_UNKNOWN:
Modified: trunk/src/keylist.c
===================================================================
--- trunk/src/keylist.c 2008-03-11 14:28:06 UTC (rev 843)
+++ trunk/src/keylist.c 2008-03-11 15:45:52 UTC (rev 844)
@@ -39,7 +39,8 @@
PROP_PUBLIC_ONLY,
PROP_PROTOCOL,
PROP_INITIAL_KEYS,
- PROP_INITIAL_PATTERN
+ PROP_INITIAL_PATTERN,
+ PROP_REQUESTED_USAGE
};
/* GObject */
@@ -51,6 +52,7 @@
{
/* These are the displayed columns */
GPA_KEYLIST_COLUMN_IMAGE,
+ GPA_KEYLIST_COLUMN_KEYTYPE,
GPA_KEYLIST_COLUMN_KEYID,
GPA_KEYLIST_COLUMN_EXPIRY,
GPA_KEYLIST_COLUMN_OWNERTRUST,
@@ -103,6 +105,9 @@
case PROP_INITIAL_PATTERN:
g_value_set_string (value, list->initial_pattern);
break;
+ case PROP_REQUESTED_USAGE:
+ g_value_set_int (value, list->requested_usage);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -134,6 +139,9 @@
case PROP_INITIAL_PATTERN:
list->initial_pattern = g_value_get_string (value);
break;
+ case PROP_REQUESTED_USAGE:
+ list->requested_usage = g_value_get_int (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -184,6 +192,7 @@
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
+ G_TYPE_STRING,
G_TYPE_POINTER,
G_TYPE_INT,
G_TYPE_ULONG,
@@ -263,6 +272,15 @@
"A string with pattern to be used for a key search or NULL.",
NULL,
G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (object_class, PROP_REQUESTED_USAGE,
+ g_param_spec_int
+ ("requested-usage", "Requested-Key-Usage",
+ "A bit vector describing the requested key usage (capabilities).",
+ 0, 65535, 0,
+ G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
+
}
@@ -399,14 +417,41 @@
gchar *userid, *expiry;
gboolean has_secret;
long int val_value;
+ const char *keytype;
/* Remove the dialog if it is being displayed */
remove_trustdb_dialog (list);
-
+
+ /* Filter out keys we don't want. */
+ if (key && list->protocol != GPGME_PROTOCOL_UNKNOWN
+ && key->protocol != list->protocol)
+ {
+ gpgme_key_unref (key);
+ return;
+ }
+
+ if (key && list->requested_usage)
+ {
+ if ((key->can_sign && list->requested_usage & KEY_USAGE_SIGN))
+ ;
+ else if ((key->can_encrypt && list->requested_usage & KEY_USAGE_ENCR))
+ ;
+ else if ((key->can_certify && list->requested_usage & KEY_USAGE_CERT))
+ ;
+ else
+ {
+ gpgme_key_unref (key);
+ return;
+ }
+ }
+
+ /* Append the key to the list. */
list->keys = g_list_append (list->keys, key);
store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (list)));
/* Get the column values */
keyid = gpa_gpgme_key_get_short_keyid (key);
+ keytype = (key->protocol == GPGME_PROTOCOL_OpenPGP? "P" :
+ key->protocol == GPGME_PROTOCOL_CMS? "X" : "?");
expiry = gpa_expiry_date_string (key->subkeys->expires);
ownertrust = gpa_key_ownertrust_string (key);
validity = gpa_key_validity_string (key);
@@ -434,6 +479,7 @@
val_value = GPGME_VALIDITY_UNKNOWN;
gtk_list_store_set (store, &iter,
+ GPA_KEYLIST_COLUMN_KEYTYPE, keytype,
GPA_KEYLIST_COLUMN_KEYID, keyid,
GPA_KEYLIST_COLUMN_EXPIRY, expiry,
GPA_KEYLIST_COLUMN_OWNERTRUST, ownertrust,
@@ -507,6 +553,15 @@
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes
+ (NULL, renderer, "text", GPA_KEYLIST_COLUMN_KEYTYPE, NULL);
+ gpa_set_column_title
+ (column, " ",
+ _("This columns lists the type of the certificate."
+ " A 'P' denotes OpenPGP and a 'X' denotes X.509 (S/MIME)."));
+ gtk_tree_view_append_column (GTK_TREE_VIEW (keylist), column);
+
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes
(NULL, renderer, "text", GPA_KEYLIST_COLUMN_KEYID, NULL);
gpa_set_column_title
(column, _("Key ID"),
@@ -515,6 +570,7 @@
gtk_tree_view_column_set_sort_column_id (column, GPA_KEYLIST_COLUMN_KEYID);
gtk_tree_view_column_set_sort_indicator (column, TRUE);
+
if (detailed)
{
renderer = gtk_cell_renderer_text_new ();
@@ -587,12 +643,14 @@
will be created in public_only mode. PROTOCOL may be used to
resctrict the list to keys of a certain protocol. If KEYS is not
NULL, those keys will be displayed instead of listing all. If
- PATTERN is not NULL, the serach box will be filled with that
- pattern */
+ PATTERN is not NULL, the search box will be filled with that
+ pattern. If REQUESTED_USAGE is not 0 only keys with the given
+ usages are listed. */
GpaKeyList *
gpa_keylist_new_with_keys (GtkWidget *window, gboolean public_only,
gpgme_protocol_t protocol,
- gpgme_key_t *keys, const char *pattern)
+ gpgme_key_t *keys, const char *pattern,
+ int requested_usage)
{
GpaKeyList *list;
@@ -601,6 +659,7 @@
"protocol", (int)protocol,
"initial-keys", gpa_gpgme_copy_keyarray (keys),
"initial-pattern", pattern,
+ "requested-usage", requested_usage,
NULL);
return list;
Modified: trunk/src/keylist.h
===================================================================
--- trunk/src/keylist.h 2008-03-11 14:28:06 UTC (rev 843)
+++ trunk/src/keylist.h 2008-03-11 15:45:52 UTC (rev 844)
@@ -53,6 +53,7 @@
gpgme_protocol_t protocol;
gpgme_key_t *initial_keys;
const char *initial_pattern;
+ int requested_usage;
};
struct _GpaKeyListClass {
@@ -66,6 +67,14 @@
/* API */
+
+/* Usage flags. */
+#define KEY_USAGE_SIGN 1 /* Good for signatures. */
+#define KEY_USAGE_ENCR 2 /* Good for encryption. */
+#define KEY_USAGE_CERT 4 /* Good to certify other keys. */
+#define KEY_USAGE_AUTH 8 /* Good for authentication. */
+
+
/* Create a new key list widget. */
GtkWidget *gpa_keylist_new (GtkWidget * window);
@@ -74,7 +83,8 @@
gboolean public_only,
gpgme_protocol_t protocol,
gpgme_key_t *keys,
- const char *pattern);
+ const char *pattern,
+ int requested_usage);
/* Set the key list in "brief" mode. */
void gpa_keylist_set_brief (GpaKeyList * keylist);
Modified: trunk/src/keyring.c
===================================================================
--- trunk/src/keyring.c 2008-03-11 14:28:06 UTC (rev 843)
+++ trunk/src/keyring.c 2008-03-11 15:45:52 UTC (rev 844)
@@ -255,6 +255,26 @@
}
/* Return TRUE if the key list widget of the keyring editor has
+ exactly one selected OpenPGP item. Usable as a sensitivity
+ callback. */
+static gboolean
+keyring_editor_has_single_selection_OpenPGP (gpointer param)
+{
+ GPAKeyringEditor *editor = param;
+ int result = 0;
+
+ if (gpa_keylist_has_single_selection (editor->keylist))
+ {
+ gpgme_key_t key = gpa_keylist_get_selected_key (editor->keylist);
+ if (key && key->protocol == GPGME_PROTOCOL_OpenPGP)
+ result = 1;
+ gpgme_key_unref (key);
+ }
+
+ return result;
+}
+
+/* Return TRUE if the key list widget of the keyring editor has
exactly one selected item and it is a private key. Usable as a
sensitivity callback. */
static gboolean
@@ -654,20 +674,20 @@
GList *selection;
gpgme_key_t key;
int old_mode;
- gpgme_protocol_t oldproto; /* Just to be save. */
selection = gpa_keylist_get_selected_keys (editor->keylist);
key = (gpgme_key_t) selection->data;
old_mode = gpgme_get_keylist_mode (editor->ctx->ctx);
- /* With all the signatures. */
+ /* With all the signatures. Note that we should not save and
+ restore the old protocol because the protocol should not be
+ changed before the gpgme_op_keylist_end. Saving and
+ restoring the keylist mode is okay. */
gpgme_set_keylist_mode (editor->ctx->ctx,
old_mode | GPGME_KEYLIST_MODE_SIGS);
- oldproto = gpgme_get_protocol (editor->ctx->ctx);
gpgme_set_protocol (editor->ctx->ctx, key->protocol);
err = gpgme_op_keylist_start (editor->ctx->ctx, key->subkeys->fpr,
FALSE);
- gpgme_set_protocol (editor->ctx->ctx, oldproto);
if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
gpa_gpgme_warning (err);
@@ -938,8 +958,8 @@
item = gtk_item_factory_get_widget (GTK_ITEM_FACTORY(factory),
_("/Keys/Set Owner Trust..."));
if (item)
- add_selection_sensitive_widget (editor, item,
- keyring_editor_has_single_selection);
+ add_selection_sensitive_widget
+ (editor, item, keyring_editor_has_single_selection_OpenPGP);
/* If the keys can be signed. */
item = gtk_item_factory_get_widget (GTK_ITEM_FACTORY(factory),
@@ -997,8 +1017,8 @@
item = gtk_item_factory_get_widget (GTK_ITEM_FACTORY(factory),
_("/Set Owner Trust..."));
if (item)
- add_selection_sensitive_widget (editor, item,
- keyring_editor_has_single_selection);
+ add_selection_sensitive_widget
+ (editor, item, keyring_editor_has_single_selection_OpenPGP);
/* If the keys can be signed. */
item = gtk_item_factory_get_widget (GTK_ITEM_FACTORY(factory),
Modified: trunk/src/recipientdlg.c
===================================================================
--- trunk/src/recipientdlg.c 2008-03-11 14:28:06 UTC (rev 843)
+++ trunk/src/recipientdlg.c 2008-03-11 15:45:52 UTC (rev 844)
@@ -473,7 +473,8 @@
{
while (!gpgme_op_keylist_next (ctx, &key))
{
- if (key->revoked || key->disabled || key->expired)
+ if (key->revoked || key->disabled || key->expired
+ || !key->can_encrypt)
gpgme_key_unref (key);
else if (append_key_to_keyinfo (&info->pgp, key)
>= TRUNCATE_KEYSEARCH_AT)
@@ -494,7 +495,8 @@
{
while (!gpgme_op_keylist_next (ctx, &key))
{
- if (key->revoked || key->disabled || key->expired)
+ if (key->revoked || key->disabled || key->expired
+ || !key->can_encrypt)
gpgme_key_unref (key);
else if (append_key_to_keyinfo (&info->x509,key)
>= TRUNCATE_KEYSEARCH_AT)
Modified: trunk/src/selectkeydlg.c
===================================================================
--- trunk/src/selectkeydlg.c 2008-03-11 14:28:06 UTC (rev 843)
+++ trunk/src/selectkeydlg.c 2008-03-11 15:45:52 UTC (rev 844)
@@ -208,7 +208,8 @@
TRUE,
dialog->protocol,
dialog->initial_keys,
- dialog->initial_pattern);
+ dialog->initial_pattern,
+ KEY_USAGE_ENCR);
gpa_gpgme_release_keyarray (dialog->initial_keys);
dialog->initial_keys = NULL;
gtk_container_add (GTK_CONTAINER (scroller), GTK_WIDGET(dialog->keylist));
More information about the Gpa-commits
mailing list