[Gpa-commits] r993 - in trunk: . src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed May 13 12:37:57 CEST 2009


Author: werner
Date: 2009-05-13 12:37:57 +0200 (Wed, 13 May 2009)
New Revision: 993

Added:
   trunk/src/gpadatebox.c
   trunk/src/gpadatebox.h
   trunk/src/gpadatebutton.c
   trunk/src/gpadatebutton.h
Modified:
   trunk/NEWS
   trunk/src/ChangeLog
   trunk/src/Makefile.am
   trunk/src/convert.c
   trunk/src/gpa.c
   trunk/src/gpagenkeyadvop.c
   trunk/src/gpagenkeycardop.c
   trunk/src/gpagenkeysimpleop.c
   trunk/src/gpaprogressdlg.c
   trunk/src/gpawidgets.c
   trunk/src/gpgmeedit.c
   trunk/src/gpgmeedit.h
   trunk/src/gpgmetools.c
   trunk/src/gpgmetools.h
   trunk/src/keygendlg.c
   trunk/src/keygendlg.h
   trunk/src/keygenwizard.c
   trunk/src/keygenwizard.h
Log:
Reworked parts of the key generation.


Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/NEWS	2009-05-13 10:37:57 UTC (rev 993)
@@ -3,7 +3,11 @@
  
  * Add a basic smartcard manager and the option --card.
 
+ * GPA now requires gpg2.
 
+ * X.509 support is now always enabled.
+
+
 Noteworthy changes in version 0.8.0 (2008-09-04)
 ------------------------------------------------
 

Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/ChangeLog	2009-05-13 10:37:57 UTC (rev 993)
@@ -1,3 +1,42 @@
+2009-05-13  Werner Koch  <wk at g10code.com>
+
+	* gpa.c (cms_hack): Always enable CMS support.
+
+	* convert.c (gpa_expiry_date_string, gpa_creation_date_string):
+	Change to use ISO date format.
+
+	* keygenwizard.c (gpa_keygen_wizard_generate_action): Use
+	gpa_keygen_para functions.  Change default algo to RSA-2048.
+	(STANDARD_KEY_LENGTH): New.
+	(gpa_keygen_wizard_final_page): Adjust for changed key length.
+
+	* gpgmetools.h (GPAKeyGenParameters): Rename to
+	gpa_keygen_para_t.  Change all users.
+	(gpa_keygen_para_t): Remove EXPIRYDATE, INTERVAL
+	and UNIT.  Add EXPIRE.  Rename USERID to NAME.
+	* gpgmetools.c (key_gen_params_new): Rename to ...
+	(gpa_keygen_para_new): .. this.  Adjust for changed EXPIRE.
+	(gpa_key_gen_free_parameters): Rename to ...
+	(gpa_keygen_para_free): .. this.  Rewrite
+	* gpgmeedit.c (calculate_expiration_day): Remove.
+	(card_edit_genkey_parms_new): Use new EXPIRE parameter.
+
+2009-05-12  Werner Koch  <wk at g10code.com>
+
+	* keygendlg.c: Rewritten.
+	* gpgmetools.c (gpa_algorithm_string, gpa_algorithm_from_string)
+	(algorithm_strings): Remove.
+	* gpgmetools.h (GPA_KEYGEN_ALGO_FIRST, GPA_KEYGEN_ALGO_LAST): Remove.
+
+	* gpadatebutton.c, gpadatebutton.h: New.
+	* gpadatebox.c, gpadatebox.h: New.
+
+2009-05-11  Werner Koch  <wk at g10code.com>
+
+	* gpgmetools.h (GPA_KEYGEN_ALGO_RSA_RSA): New.
+
+	* keygendlg.c (gpa_key_gen_run_dialog): Remove the 768 bit key size.
+
 2009-05-07  Werner Koch  <wk at g10code.com>
 
 	* cm-openpgp.c (update_entry_key_attr): New.

Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/Makefile.am	2009-05-13 10:37:57 UTC (rev 993)
@@ -137,6 +137,8 @@
 	      gpabackupop.h gpabackupop.c \
 	      gpakeyselector.h gpakeyselector.c \
 	      gpapinchange.h gpapinchange.c \
+	      gpadatebutton.c gpadatebutton.h \
+	      gpadatebox.c gpadatebox.h \
 	      server.c \
 	      filewatch.c \
 	      options.c \

Modified: trunk/src/convert.c
===================================================================
--- trunk/src/convert.c	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/convert.c	2009-05-13 10:37:57 UTC (rev 993)
@@ -74,15 +74,16 @@
 char *
 gpa_expiry_date_string (unsigned long expiry_time)
 {
-  gchar date_buffer[256];
   gchar *result;
   GDate expiry_date;
 
   if( expiry_time > 0 )
     {
       g_date_set_time_t (&expiry_date, (time_t) expiry_time);
-      g_date_strftime (date_buffer, 256, "%x", &expiry_date);
-      result = g_strdup (date_buffer);
+      result = g_strdup_printf ("%04d-%02d-%02d", 
+                                g_date_get_year (&expiry_date),
+                                g_date_get_month (&expiry_date),
+                                g_date_get_day (&expiry_date));
     }
   else
     result = g_strdup (_("never expires"));
@@ -93,15 +94,16 @@
 char *
 gpa_creation_date_string (unsigned long creation_time)
 {
-  gchar date_buffer[256];
   gchar *result;
   GDate creation_date;
 
   if( creation_time > 0 )
     {
       g_date_set_time_t (&creation_date, (time_t) creation_time);
-      g_date_strftime (date_buffer, 256, "%x", &creation_date);
-      result = g_strdup (date_buffer);
+      result = g_strdup_printf ("%04d-%02d-%02d", 
+                                g_date_get_year (&creation_date),
+                                g_date_get_month (&creation_date),
+                                g_date_get_day (&creation_date));
     }
   else
     result = g_strdup (_("unknown"));

Modified: trunk/src/gpa.c
===================================================================
--- trunk/src/gpa.c	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/gpa.c	2009-05-13 10:37:57 UTC (rev 993)
@@ -105,11 +105,12 @@
     { "settings", 's', 0, G_OPTION_ARG_NONE, &args.start_settings,
       N_("Open the settings dialog"), NULL },
     { "daemon", 'd', 0, G_OPTION_ARG_NONE, &args.start_only_server,
-      N_("Enable the UI server (implies --cms)"), NULL },
+      N_("Enable the UI server"), NULL },
     { "options", 'o', 0, G_OPTION_ARG_FILENAME, &args.options_filename,
       N_("Read options from file"), "FILE" },
-    { "cms", 'x', 0, G_OPTION_ARG_NONE, &cms_hack,
-      "Enable CMS/X.509 support", NULL },
+    /* Note:  the cms option will eventually be removed.  */
+    { "cms", 'x', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE,
+      &cms_hack, NULL, NULL },
     { "disable-ticker", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE,
       &disable_ticker, NULL, NULL },
     { NULL }
@@ -397,10 +398,8 @@
 
 
   /* Handle command line options.  */
+  cms_hack = 1; /* CMS is now always enabled.  */
 
-  if (args.start_only_server)
-    cms_hack = 1; 
-
   /* Start the key manger by default.  */
   if (!args.start_key_manager
       && !args.start_file_manager

Added: trunk/src/gpadatebox.c
===================================================================
--- trunk/src/gpadatebox.c	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/gpadatebox.c	2009-05-13 10:37:57 UTC (rev 993)
@@ -0,0 +1,217 @@
+/* gpadatebox.c  -  A box to show an optional date.
+ * Copyright (C) 2009 g10 Code GmbH
+ *
+ * This file is part of GPA.
+ *
+ * GPA is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GPA is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>. 
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "gpadatebutton.h"
+#include "gpadatebox.h"
+
+
+
+/* Object's class definition.  */
+struct _GpaDateBoxClass 
+{
+  GtkHBoxClass parent_class;
+
+};
+
+
+/* Object definition.  */
+struct _GpaDateBox
+{
+  GtkHBox parent_instance;
+
+  GtkWidget *checkbox;   /* The check box.  */
+  GtkWidget *datebtn;    /* The date button.  */
+};
+
+
+/* The parent class.  */
+static GObjectClass *parent_class;
+
+
+/* Local prototypes */
+static void gpa_date_box_finalize (GObject *object);
+
+
+
+/************************************************************ 
+ *******************   Implementation   *********************
+ ************************************************************/
+
+static void
+update_widgets (GpaDateBox *self)
+{
+  gboolean state;
+
+  state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->checkbox));
+  if (state && !self->datebtn)
+    {
+      self->datebtn = gpa_date_button_new ();
+      gtk_box_pack_start (GTK_BOX (self), self->datebtn, FALSE, FALSE, 0);
+      gtk_widget_show_all (GTK_WIDGET (self));
+      gtk_button_clicked (GTK_BUTTON (self->datebtn));
+    }
+  else if (!state && self->datebtn)
+    {
+      gtk_widget_destroy (GTK_WIDGET (self->datebtn));
+      self->datebtn = NULL;
+      gtk_widget_show_all (GTK_WIDGET (self));
+    }
+
+}
+
+
+static void
+checkbox_toggled_cb (GtkToggleButton *button, gpointer user_data)
+{
+  GpaDateBox *self = GPA_DATE_BOX (user_data);
+  (void)button;
+
+  update_widgets (self);
+}
+
+
+/* Create the widgets.  */
+static void
+create_widgets (GpaDateBox *self)
+{
+  self->checkbox = gtk_check_button_new ();
+  gtk_box_pack_start (GTK_BOX (self), self->checkbox, FALSE, FALSE, 0);
+  g_signal_connect (self->checkbox, "toggled",
+                    G_CALLBACK (checkbox_toggled_cb), self);
+
+  update_widgets (self);
+  gtk_widget_show_all (GTK_WIDGET (self));
+} 
+
+
+
+/************************************************************ 
+ ******************   Object Management  ********************
+ ************************************************************/
+
+static void
+gpa_date_box_class_init (void *class_ptr, void *class_data)
+{
+  GpaDateBoxClass *klass = class_ptr;
+  (void)class_data;
+
+  parent_class = g_type_class_peek_parent (klass);
+  
+  G_OBJECT_CLASS (klass)->finalize = gpa_date_box_finalize;
+}
+
+
+static void
+gpa_date_box_init (GTypeInstance *instance, void *class_ptr)
+{
+  GpaDateBox *self = GPA_DATE_BOX (instance);
+  (void)class_ptr;
+
+  create_widgets (self);
+}
+
+
+static void
+gpa_date_box_finalize (GObject *object)
+{  
+  GpaDateBox *self = GPA_DATE_BOX (object);
+  (void)self;
+
+  parent_class->finalize (object);
+}
+
+
+/* Construct the class.  */
+GType
+gpa_date_box_get_type (void)
+{
+  static GType this_type = 0;
+  
+  if (!this_type)
+    {
+      static const GTypeInfo this_info =
+	{
+	  sizeof (GpaDateBoxClass),
+	  (GBaseInitFunc) NULL,
+	  (GBaseFinalizeFunc) NULL,
+	  gpa_date_box_class_init,
+	  (GClassFinalizeFunc) NULL,
+	  NULL, /* class_data */
+	  sizeof (GpaDateBox),
+	  0,    /* n_preallocs */
+	  gpa_date_box_init
+	};
+      
+      this_type = g_type_register_static (GTK_TYPE_HBOX,
+                                          "GpaDateBox",
+                                          &this_info, 0);
+    }
+  
+  return this_type;
+}
+
+
+/************************************************************ 
+ **********************  Public API  ************************
+ ************************************************************/
+GtkWidget *
+gpa_date_box_new (void)
+{
+  GtkWidget *obj;
+
+  obj = GTK_WIDGET (g_object_new (GPA_DATE_BOX_TYPE, NULL));
+
+  return obj;
+}
+
+
+void
+gpa_date_box_set_date (GpaDateBox *self, GDate *date)
+{
+  g_return_if_fail (IS_GPA_DATE_BOX (self));
+
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->checkbox), !!date);
+  gpa_date_button_set_date (GPA_DATE_BUTTON (self->datebtn), date);
+
+  update_widgets (self);
+}
+
+
+/* Store the current date at R_DATE.  Returns true if the date is
+   valid and the check box is checked.  */
+gboolean
+gpa_date_box_get_date (GpaDateBox *self, GDate *r_date)
+{
+  g_return_val_if_fail (IS_GPA_DATE_BOX (self), FALSE);
+
+  g_date_clear (r_date, 1);
+  if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->checkbox)))
+    return FALSE;
+  return gpa_date_button_get_date (GPA_DATE_BUTTON (self->datebtn), r_date);
+}

Added: trunk/src/gpadatebox.h
===================================================================
--- trunk/src/gpadatebox.h	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/gpadatebox.h	2009-05-13 10:37:57 UTC (rev 993)
@@ -0,0 +1,60 @@
+/* gpadatebox.h  -  A box to show an optional date.
+ * Copyright (C) 2009 g10 Code GmbH
+ *
+ * This file is part of GPA.
+ *
+ * GPA is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GPA is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>. 
+ */
+
+#ifndef GPADATEBOX_H
+#define GPADATEBOX_H
+
+#include <gtk/gtkbox.h>
+
+
+/* Declare the Object. */
+typedef struct _GpaDateBox      GpaDateBox;
+typedef struct _GpaDateBoxClass GpaDateBoxClass;
+
+GType gpa_date_box_get_type (void) G_GNUC_CONST;
+
+#define GPA_DATE_BOX_TYPE   (gpa_date_box_get_type ())
+
+#define GPA_DATE_BOX(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GPA_DATE_BOX_TYPE, GpaDateBox))
+
+#define GPA_DATE_BOX_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass),  \
+                            GPA_DATE_BOX_TYPE, GpaDateBoxClass))
+
+#define IS_GPA_DATE_BOX(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GPA_DATE_BOX_TYPE))
+
+#define IS_GPA_DATE_BOX_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), GPA_DATE_BOX_TYPE))
+
+#define GPA_DATE_BOX_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj),    \
+                              GPA_DATE_BOX_TYPE, GpaDateBoxClass))
+
+
+/* The public functions.  */
+GtkWidget *gpa_date_box_new (void);
+
+void gpa_date_box_set_date (GpaDateBox *self, GDate *date);
+
+gboolean gpa_date_box_get_date (GpaDateBox *self, GDate *r_date);
+
+
+#endif /*GPADATEBOX_H*/

Added: trunk/src/gpadatebutton.c
===================================================================
--- trunk/src/gpadatebutton.c	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/gpadatebutton.c	2009-05-13 10:37:57 UTC (rev 993)
@@ -0,0 +1,317 @@
+/* gpadatebutton.c  -  A button to show and select a date.
+ * Copyright (C) 2009 g10 Code GmbH
+ *
+ * This file is part of GPA.
+ *
+ * GPA is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GPA is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>. 
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "gpadatebutton.h"
+
+
+
+/* Object's class definition.  */
+struct _GpaDateButtonClass 
+{
+  GtkButtonClass parent_class;
+
+  /* The signal function for "date-set". */
+  void (*date_set)(GpaDateButton *self);
+};
+
+
+/* Object definition.  */
+struct _GpaDateButton
+{
+  GtkButton parent_instance;
+
+  GtkWidget *dialog;    /* NULL or the dialog popup window.  */
+  GtkWidget *calendar;  /* The calendar object.  */
+
+  GtkWidget *label;
+
+  guint current_year;
+  guint current_month;
+  guint current_day;
+
+  int ignore_next_selection;
+};
+
+
+/* The parent class.  */
+static GObjectClass *parent_class;
+
+
+/* Local prototypes */
+static void gpa_date_button_finalize (GObject *object);
+
+
+
+/************************************************************ 
+ *******************   Implementation   *********************
+ ************************************************************/
+
+static void
+update_widgets (GpaDateButton *self)
+{
+  char buf[20];
+
+  if (!self->current_day && !self->current_month && !self->current_year)
+    *buf = 0;
+  else
+    snprintf (buf, sizeof buf, "%04d-%02d-%02d", 
+              self->current_year, self->current_month+1, self->current_day);
+  
+  gtk_label_set_text (GTK_LABEL (self->label), 
+                      *buf? buf : "(not set)");
+  if (self->calendar && *buf)
+    {
+      gtk_calendar_select_month (GTK_CALENDAR (self->calendar),
+                                 self->current_month, self->current_year);
+      gtk_calendar_select_day (GTK_CALENDAR (self->calendar),
+                               self->current_day);
+    }
+}
+
+
+
+/* Signal handler for "destroy" to the dialog window.  */
+static void
+destroy_cb (GtkWidget *widget, gpointer user_data)
+{
+  GpaDateButton *self = GPA_DATE_BUTTON (user_data);
+
+  self->dialog = NULL;
+} 
+
+
+static void
+day_selected_cb (GtkWidget *widget, gpointer user_data)
+{
+  GpaDateButton *self = GPA_DATE_BUTTON (user_data);
+
+  if (self->ignore_next_selection)
+    {
+      self->ignore_next_selection = 0;
+      return;
+    }
+
+  gtk_calendar_get_date (GTK_CALENDAR (self->calendar),
+                         &self->current_year,
+                         &self->current_month,
+                         &self->current_day);
+  update_widgets (self);
+
+  g_signal_emit_by_name (self, "date-set");
+
+  gtk_widget_destroy (self->dialog);
+}
+
+static void
+month_changed_cb (GtkWidget *widget, gpointer user_data)
+{
+  GpaDateButton *self = GPA_DATE_BUTTON (user_data);
+
+  self->ignore_next_selection = 1;
+}
+
+
+/* Create the widgets.  */
+static void
+create_widgets (GpaDateButton *self)
+{
+  self->label = gtk_label_new (NULL);
+  gtk_label_set_justify (GTK_LABEL (self->label), GTK_JUSTIFY_LEFT);
+
+  update_widgets (self);
+  gtk_widget_show (self->label);
+  gtk_container_add (GTK_CONTAINER (self), self->label);
+} 
+
+
+
+/************************************************************ 
+ ******************   Object Management  ********************
+ ************************************************************/
+
+/* Overloaded method for clicked.  */
+static void
+gpa_date_button_clicked (GtkButton *button)
+{
+  GpaDateButton *self = GPA_DATE_BUTTON (button);
+
+  if (!self->dialog) 
+    {
+      self->dialog = gtk_dialog_new ();
+      gtk_window_set_decorated (GTK_WINDOW (self->dialog), FALSE);
+      gtk_window_set_modal (GTK_WINDOW (self->dialog), TRUE);
+      
+      g_signal_connect (self->dialog, "destroy",
+                        G_CALLBACK (destroy_cb), self);
+      g_signal_connect_swapped (self->dialog, "response",
+                                G_CALLBACK (gtk_widget_destroy), self->dialog);
+
+      self->calendar = gtk_calendar_new ();
+      gtk_container_add (GTK_CONTAINER (GTK_DIALOG (self->dialog)->vbox),
+                         self->calendar);
+
+      g_signal_connect (self->calendar, "day-selected",
+                        G_CALLBACK (day_selected_cb), self);
+      g_signal_connect (self->calendar, "month-changed",
+                        G_CALLBACK (month_changed_cb), self);
+
+      gtk_widget_show_all (self->dialog);
+
+    }
+  
+  update_widgets (self);
+  gtk_window_present (GTK_WINDOW (self->dialog));
+}
+
+
+static void
+gpa_date_button_class_init (void *class_ptr, void *class_data)
+{
+  GpaDateButtonClass *klass = class_ptr;
+  
+  (void)class_data;
+
+  parent_class = g_type_class_peek_parent (klass);
+  
+  G_OBJECT_CLASS (klass)->finalize = gpa_date_button_finalize;
+  GTK_BUTTON_CLASS (klass)->clicked = gpa_date_button_clicked;
+
+  g_signal_new ("date-set",
+                G_TYPE_FROM_CLASS (G_OBJECT_CLASS (klass)),
+                G_SIGNAL_RUN_FIRST,
+                G_STRUCT_OFFSET (GpaDateButtonClass, date_set),
+                NULL, NULL,
+                g_cclosure_marshal_VOID__VOID,
+                G_TYPE_NONE, 0);
+}
+
+
+static void
+gpa_date_button_init (GTypeInstance *instance, void *class_ptr)
+{
+  GpaDateButton *self = GPA_DATE_BUTTON (instance);
+
+  (void)class_ptr;
+
+  create_widgets (self);
+}
+
+
+static void
+gpa_date_button_finalize (GObject *object)
+{  
+  GpaDateButton *self = GPA_DATE_BUTTON (object);
+  (void)self;
+
+  parent_class->finalize (object);
+}
+
+
+/* Construct the class.  */
+GType
+gpa_date_button_get_type (void)
+{
+  static GType this_type = 0;
+  
+  if (!this_type)
+    {
+      static const GTypeInfo this_info =
+	{
+	  sizeof (GpaDateButtonClass),
+	  (GBaseInitFunc) NULL,
+	  (GBaseFinalizeFunc) NULL,
+	  gpa_date_button_class_init,
+	  (GClassFinalizeFunc) NULL,
+	  NULL, /* class_data */
+	  sizeof (GpaDateButton),
+	  0,    /* n_preallocs */
+	  gpa_date_button_init
+	};
+      
+      this_type = g_type_register_static (GTK_TYPE_BUTTON,
+                                          "GpaDateButton",
+                                          &this_info, 0);
+    }
+  
+  return this_type;
+}
+
+
+/************************************************************ 
+ **********************  Public API  ************************
+ ************************************************************/
+GtkWidget *
+gpa_date_button_new (void)
+{
+  GtkWidget *obj;
+
+  obj = GTK_WIDGET (g_object_new (GPA_DATE_BUTTON_TYPE, NULL));
+
+  return obj;
+}
+
+
+void
+gpa_date_button_set_date (GpaDateButton *self, GDate *date)
+{
+  g_return_if_fail (IS_GPA_DATE_BUTTON (self));
+
+  if (!date)
+    {
+      self->current_day = 0;
+      self->current_month = 0;
+      self->current_year = 0;
+    }
+  else
+    {
+      self->current_day = g_date_get_day (date);
+      self->current_month = g_date_get_month (date);
+      self->current_year = g_date_get_year (date);
+    }
+
+  update_widgets (self);
+}
+
+
+/* Store the current date at R_DATE.  Returns true if the date is
+   valid.  */
+gboolean
+gpa_date_button_get_date (GpaDateButton *self, GDate *r_date)
+{
+  g_return_val_if_fail (IS_GPA_DATE_BUTTON (self), FALSE);
+
+  g_date_clear (r_date, 1);
+  if (!g_date_valid_dmy (self->current_day,
+                         self->current_month, self->current_year))
+    return FALSE;
+
+  g_date_set_dmy (r_date, self->current_day,
+                  self->current_month, self->current_year);
+  return TRUE;
+}

Added: trunk/src/gpadatebutton.h
===================================================================
--- trunk/src/gpadatebutton.h	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/gpadatebutton.h	2009-05-13 10:37:57 UTC (rev 993)
@@ -0,0 +1,60 @@
+/* gpadatebutton.h  -  A button to show and select a date.
+ * Copyright (C) 2009 g10 Code GmbH
+ *
+ * This file is part of GPA.
+ *
+ * GPA is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GPA is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>. 
+ */
+
+#ifndef GPADATEBUTTON_H
+#define GPADATEBUTTON_H
+
+#include <gtk/gtkbutton.h>
+
+
+/* Declare the Object. */
+typedef struct _GpaDateButton      GpaDateButton;
+typedef struct _GpaDateButtonClass GpaDateButtonClass;
+
+GType gpa_date_button_get_type (void) G_GNUC_CONST;
+
+#define GPA_DATE_BUTTON_TYPE   (gpa_date_button_get_type ())
+
+#define GPA_DATE_BUTTON(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GPA_DATE_BUTTON_TYPE, GpaDateButton))
+
+#define GPA_DATE_BUTTON_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass),  \
+                            GPA_DATE_BUTTON_TYPE, GpaDateButtonClass))
+
+#define IS_GPA_DATE_BUTTON(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GPA_DATE_BUTTON_TYPE))
+
+#define IS_ACCOUNTLIST_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), GPA_DATE_BUTTON_TYPE))
+
+#define GPA_DATE_BUTTON_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj),    \
+                              GPA_DATE_BUTTON_TYPE, GpaDateButtonClass))
+
+
+/* The public functions.  */
+GtkWidget *gpa_date_button_new (void);
+
+void gpa_date_button_set_date (GpaDateButton *self, GDate *date);
+
+gboolean gpa_date_button_get_date (GpaDateButton *self, GDate *r_date);
+
+
+#endif /*GPADATEBUTTON_H*/

Modified: trunk/src/gpagenkeyadvop.c
===================================================================
--- trunk/src/gpagenkeyadvop.c	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/gpagenkeyadvop.c	2009-05-13 10:37:57 UTC (rev 993)
@@ -150,7 +150,7 @@
 {
   GpaGenKeyAdvancedOperation *op = data;
   gpg_error_t err;
-  GPAKeyGenParameters *parms;
+  gpa_keygen_para_t *parms;
   
   parms = gpa_key_gen_run_dialog (GPA_OPERATION (op)->window, 0);
   if (!parms)

Modified: trunk/src/gpagenkeycardop.c
===================================================================
--- trunk/src/gpagenkeycardop.c	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/gpagenkeycardop.c	2009-05-13 10:37:57 UTC (rev 993)
@@ -153,7 +153,7 @@
 {
   GpaGenKeyCardOperation *op = data;
   gpg_error_t err;
-  GPAKeyGenParameters *parms;
+  gpa_keygen_para_t *parms;
   
   parms = gpa_key_gen_run_dialog (GPA_OPERATION (op)->window, 1);
   if (!parms)

Modified: trunk/src/gpagenkeysimpleop.c
===================================================================
--- trunk/src/gpagenkeysimpleop.c	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/gpagenkeysimpleop.c	2009-05-13 10:37:57 UTC (rev 993)
@@ -38,7 +38,7 @@
 							  GpaGenKeySimpleOperation *op);
 
 static gboolean 
-gpa_gen_key_simple_operation_generate (GPAKeyGenParameters *params,
+gpa_gen_key_simple_operation_generate (gpa_keygen_para_t *params,
 				       gboolean do_backup, gpointer data);
 
 /* GObject boilerplate */
@@ -145,7 +145,7 @@
 /* Internal */
 
 static gboolean 
-gpa_gen_key_simple_operation_generate (GPAKeyGenParameters *params,
+gpa_gen_key_simple_operation_generate (gpa_keygen_para_t *params,
 				       gboolean do_backup, gpointer data)
 {
   GpaGenKeySimpleOperation *op = data;

Modified: trunk/src/gpaprogressdlg.c
===================================================================
--- trunk/src/gpaprogressdlg.c	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/gpaprogressdlg.c	2009-05-13 10:37:57 UTC (rev 993)
@@ -130,7 +130,7 @@
   dialog->label = gtk_label_new (NULL);
   gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG (dialog)->vbox),
 			       dialog->label);
-  dialog->pbar = gpa_progress_bar_new ();
+  dialog->pbar = GPA_PROGRESS_BAR (gpa_progress_bar_new ());
   gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG (dialog)->vbox),
 			       GTK_WIDGET (dialog->pbar));
   /* Set up the dialog.  */

Modified: trunk/src/gpawidgets.c
===================================================================
--- trunk/src/gpawidgets.c	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/gpawidgets.c	2009-05-13 10:37:57 UTC (rev 993)
@@ -157,6 +157,7 @@
                             gtk_toggle_button_get_active (togglebutton));
 }
 
+
 GtkWidget *
 gpa_expiry_frame_new (GDate * expiryDate)
 {

Modified: trunk/src/gpgmeedit.c
===================================================================
--- trunk/src/gpgmeedit.c	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/gpgmeedit.c	2009-05-13 10:37:57 UTC (rev 993)
@@ -1153,7 +1153,7 @@
 struct genkey_parms_s
 {
   int  post_default_state;
-  char expiration_day[11];	/* "YYYY-MM-DD". */
+  char expiration_day[11];	/* "YYYY-MM-DD" or "0". */
   char *name;
   char *email;
   char *comment;
@@ -1168,7 +1168,7 @@
   switch (state)
     {
     case CARD_DEFAULT:
-      /* Return an empty line toindicate that the default is to be used.  */
+      /* Return an empty line to indicate that the default is to be used.  */
       *result = "";
       break;
 
@@ -1403,47 +1403,6 @@
 
 
 static void
-calculate_expiration_day (GPAKeyGenParameters *parms,
-                          char *expiration_day, size_t length)
-{
-  assert (length >= 11);
-
-  if (parms->expiryDate)
-    g_date_strftime (expiration_day, length, "%Y-%m-%d", parms->expiryDate);
-  else if (parms->interval)
-    {
-      GDate *date = g_date_new ();
-      g_date_set_time_t (date, time (NULL));
-
-      assert ((parms->unit == 'd') || (parms->unit == 'w')
-	      || (parms->unit == 'm') || (parms->unit == 'y'));
-
-      switch (parms->unit)
-	{
-	case 'd':
-	  g_date_add_days (date, parms->interval);
-	  break;
-	case 'w':
-	  g_date_add_days (date, parms->interval * 7);
-	  break;
-	case 'm':
-	  g_date_add_months (date, parms->interval);
-	  break;
-	case 'y':
-	  g_date_add_years (date, parms->interval);
-	  break;
-	}
-
-      g_date_strftime (expiration_day, length, "%Y-%m-%d", date);
-      g_date_free (date);
-    }
-  else
-    /* Never expire.  */
-    strcpy (expiration_day, "0");
-}
-
-
-static void
 card_edit_genkey_parms_release (GpaContext *ctx, gpg_error_t err,
 				struct edit_parms_s *parms)
 {
@@ -1461,7 +1420,7 @@
 /* Generate the edit parameters needed for setting owner trust.  */
 static struct edit_parms_s *
 card_edit_genkey_parms_new (GpaContext *ctx,
-                            GPAKeyGenParameters *parms, gpgme_data_t out)
+                            gpa_keygen_para_t *parms, gpgme_data_t out)
 {
   struct edit_parms_s *edit_parms;
   struct genkey_parms_s *genkey_parms;
@@ -1475,9 +1434,18 @@
   edit_parms->out = out;
   edit_parms->opaque = genkey_parms;
 
-  calculate_expiration_day (parms, genkey_parms->expiration_day,
-			    sizeof (genkey_parms->expiration_day));
-  genkey_parms->name = parms->userID;
+  assert (sizeof (genkey_parms->expiration_day) > 10);
+  if (g_date_valid (&parms->expire))
+    snprintf (genkey_parms->expiration_day, 
+              sizeof genkey_parms->expiration_day,
+              "%04d-%02d-%02d", 
+              g_date_get_year (&parms->expire),
+              g_date_get_month (&parms->expire),
+              g_date_get_day (&parms->expire));
+  else /* Never expire.  */
+    strcpy (genkey_parms->expiration_day, "0");
+
+  genkey_parms->name = parms->name;
   genkey_parms->email = parms->email;
   genkey_parms->comment = parms->comment;
 
@@ -1493,7 +1461,7 @@
 
 gpg_error_t
 gpa_gpgme_card_edit_genkey_start (GpaContext *ctx,
-                                  GPAKeyGenParameters *genkey_parms)
+                                  gpa_keygen_para_t *genkey_parms)
 {
   struct edit_parms_s *edit_parms;
   gpgme_data_t out = NULL;

Modified: trunk/src/gpgmeedit.h
===================================================================
--- trunk/src/gpgmeedit.h	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/gpgmeedit.h	2009-05-13 10:37:57 UTC (rev 993)
@@ -47,7 +47,7 @@
  */
 gpg_error_t gpa_gpgme_edit_passwd_start (GpaContext *ctx, gpgme_key_t key);
 
-gpg_error_t gpa_gpgme_card_edit_genkey_start (GpaContext *ctx, GPAKeyGenParameters *parms);
+gpg_error_t gpa_gpgme_card_edit_genkey_start (GpaContext *ctx, gpa_keygen_para_t *parms);
 
 #if 0
 gpg_error_t gpa_gpgme_card_edit_modify_start (GpaContext *ctx, const gchar *login);

Modified: trunk/src/gpgmetools.c
===================================================================
--- trunk/src/gpgmetools.c	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/gpgmetools.c	2009-05-13 10:37:57 UTC (rev 993)
@@ -340,80 +340,89 @@
    don't need worry about the user ID being UTF-8 as long as we are
    using GTK+2, because all user input is UTF-8 in it.  */
 static gchar *
-build_genkey_parms (GPAKeyGenParameters *params)
+build_genkey_parms (gpa_keygen_para_t *params)
 {
   gchar *string;
-  gchar *key_algo;
-  gchar *subkeys, *email, *comment, *expire;
+  const char *key_algo;
+  gchar *subkeys = NULL;
+  gchar *name = NULL;
+  gchar *email = NULL;
+  gchar *comment = NULL;
+  gchar *expire = NULL;
 
   /* Choose which keys and subkeys to generate.  */
   switch (params->algo)
     {
+    case GPA_KEYGEN_ALGO_RSA_RSA:
+      key_algo = "RSA";
+      subkeys = g_strdup_printf ("Subkey-Type: RSA\n"
+                                 "Subkey-Length: %d\n"
+                                 "Subkey-Usage: encrypt\n", params->keysize);
+      break;
+    case GPA_KEYGEN_ALGO_RSA_ELGAMAL:
+      key_algo = "RSA";
+      subkeys = g_strdup_printf ("Subkey-Type: ELG-E\n"
+                                 "Subkey-Length: %d\n"
+                                 "Subkey-Usage: encrypt\n", params->keysize);
+      break;
+    case GPA_KEYGEN_ALGO_RSA:
+      key_algo = "RSA";
+      break;
     case GPA_KEYGEN_ALGO_DSA_ELGAMAL:
       key_algo = "DSA";
-      subkeys = g_strdup_printf ("SubKey-Type: ELG-E\n"
-                                 "Subkey-Length: %i\n", params->keysize);
+      subkeys = g_strdup_printf ("Subkey-Type: ELG-E\n"
+                                 "Subkey-Length: %i\n"
+                                 "Subkey-Usage: encrypt\n", params->keysize);
       break;
     case GPA_KEYGEN_ALGO_DSA:
       key_algo = "DSA";
-      subkeys = "";
       break;
-    case GPA_KEYGEN_ALGO_RSA:
-      key_algo = "RSA";
-      subkeys = "";
-      break;
     default:
       /* Can't happen */
       return NULL;
     }
 
-  /* Build the extra fields of the user ID if supplied by the user.  */
+  /* Construct the user ID.  */
+  if (params->name && params->name[0])
+    name = g_strdup_printf ("Name-Real: %s\n", params->name);
   if (params->email && params->email[0])
     email = g_strdup_printf ("Name-Email: %s\n", params->email);
-  else
-    email = "";
-
   if (params->comment && params->comment[0])
     comment = g_strdup_printf ("Name-Comment: %s\n", params->comment);
-  else
-    comment = "";
 
   /* Build the expiration date string if needed */
-  if (params->expiryDate)
-    {
-      expire = g_strdup_printf ("Expire-Date: %i-%02i-%02i\n", 
-                                g_date_get_year(params->expiryDate),
-                                g_date_get_month(params->expiryDate),
-                                g_date_get_day(params->expiryDate));
-    }
-  else if (params->interval)
-    expire = g_strdup_printf ("Expire-Date: %i%c\n", params->interval,
-			      params->unit);
-  else
-    expire = "";
+  if (g_date_valid (&params->expire))
+    expire = g_strdup_printf ("Expire-Date: %04d-%02d-%02d\n", 
+                              g_date_get_year (&params->expire),
+                              g_date_get_month (&params->expire),
+                              g_date_get_day (&params->expire));
+
   /* Assemble the final parameter string */
   string = g_strdup_printf ("<GnupgKeyParms format=\"internal\">\n"
                             "Key-Type: %s\n"
                             "Key-Length: %i\n"
+                            "Key-Usage: sign\n"
                             "%s" /* Subkeys */
-                            "Name-Real: %s\n"
-                            "%s" /* Email Address */
+                            "%s" /* Name */
+                            "%s" /* Email */
                             "%s" /* Comment */
                             "%s" /* Expiration date */
-                            "Passphrase: %s\n"
-                            "</GnupgKeyParms>\n", key_algo, params->keysize,
-                            subkeys, params->userID, email, comment, expire,
-                            params->password);
+                            "%%ask-passphrase\n"
+                            "</GnupgKeyParms>\n",
+                            key_algo,
+                            params->keysize, 
+                            subkeys? subkeys : "",
+                            name? name:"",
+                            email? email : "",
+                            comment? comment : "",
+                            expire? expire : "");
 
   /* Free auxiliary strings if they are not empty */
-  if (subkeys[0])
-    g_free (subkeys);
-  if (email[0])
-    g_free (email);
-  if (comment[0])
-    g_free (comment);
-  if (expire[0])
-    g_free (expire);
+  g_free (subkeys);
+  g_free (name);
+  g_free (email);
+  g_free (comment);
+  g_free (expire);
 
   return string;
 }
@@ -422,7 +431,7 @@
    the parameters required by GPGME and returns whatever
    gpgme_op_genkey_start returns.  */
 gpg_error_t
-gpa_generate_key_start (gpgme_ctx_t ctx, GPAKeyGenParameters *params)
+gpa_generate_key_start (gpgme_ctx_t ctx, gpa_keygen_para_t *params)
 {
   gchar *parm_string;
   gpg_error_t err;
@@ -558,57 +567,25 @@
 
 
 void
-gpa_key_gen_free_parameters(GPAKeyGenParameters * params)
+gpa_keygen_para_free (gpa_keygen_para_t *params)
 {
-  g_free (params->userID);
+  g_free (params->name);
   g_free (params->email);
   g_free (params->comment);
-  if (params->expiryDate)
-    g_date_free (params->expiryDate);
   g_free (params);
 }
 
 
-GPAKeyGenParameters *
-key_gen_params_new(void)
+gpa_keygen_para_t *
+gpa_keygen_para_new (void)
 {
-  GPAKeyGenParameters * params = g_malloc (sizeof (*params));
-  params->userID = NULL;
-  params->email = NULL;
-  params->comment = NULL;
-  params->expiryDate = NULL;
-  params->interval = 0;
+  gpa_keygen_para_t *params = xcalloc (1, sizeof *params);
+  g_date_clear (&params->expire, 1);
   return params;
 }
 
 
-static gchar *algorithm_strings[] = {
-  N_("DSA and ElGamal (default)"),
-  N_("DSA (sign only)"),
-  N_("RSA (sign only)"),
-};
 
-
-const gchar *
-gpa_algorithm_string (GPAKeyGenAlgo algo)
-{
-  return _(algorithm_strings[algo]);
-}
-
-
-GPAKeyGenAlgo
-gpa_algorithm_from_string (const gchar * string)
-{
-  GPAKeyGenAlgo result;
-
-  result = GPA_KEYGEN_ALGO_FIRST;
-  while (result <= GPA_KEYGEN_ALGO_LAST &&
-	 strcmp (string, _(algorithm_strings[result])) != 0)
-    result++;
-  return result;
-}
-
-
 /* Ownertrust strings.  */
 const gchar *
 gpa_key_ownertrust_string (gpgme_key_t key)

Modified: trunk/src/gpgmetools.h
===================================================================
--- trunk/src/gpgmetools.h	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/gpgmetools.h	2009-05-13 10:37:57 UTC (rev 993)
@@ -26,25 +26,29 @@
 #include <gtk/gtk.h>
 #include <gpgme.h>
 
+/* Internal algorithm identifiers, describing which keys to
+   create.  */
 typedef enum
   {
+    GPA_KEYGEN_ALGO_RSA_RSA,
+    GPA_KEYGEN_ALGO_RSA_ELGAMAL,
+    GPA_KEYGEN_ALGO_RSA,
     GPA_KEYGEN_ALGO_DSA_ELGAMAL,
     GPA_KEYGEN_ALGO_DSA,
-    GPA_KEYGEN_ALGO_RSA
-  } GPAKeyGenAlgo;
+    GPA_KEYGEN_ALGO_VIA_CARD
+  } gpa_keygen_algo_t;
 
-#define GPA_KEYGEN_ALGO_FIRST GPA_KEYGEN_ALGO_DSA_ELGAMAL
-#define GPA_KEYGEN_ALGO_LAST GPA_KEYGEN_ALGO_RSA
 
+
 typedef struct
- {
+{
   /* User ID.  */
-  gchar *userID;
+  gchar *name;
   gchar *email;
   gchar *comment;
-
+  
   /* Algorithm.  */
-  GPAKeyGenAlgo algo;
+  gpa_keygen_algo_t algo;
 
   /* Key size.  */
   gint keysize;
@@ -52,15 +56,12 @@
   /* The password to use.  */
   gchar *password;
 
-  /* The expiry date.  If expiryDate is not NULL it holds the expiry
-     date, otherwise if interval is not zero, it defines the period of
-     time until expiration together with unit (which is one of d, w,
-     m, y), otherwise the user chose "never expire".  */
-  GDate *expiryDate;
-  gint interval;
-  gchar unit;
-} GPAKeyGenParameters;
+  /* Epiration date.  It is only used if it is valid.  */
+  GDate expire;
 
+} gpa_keygen_para_t;
+
+
 /* Report an unexpected error in GPGME and quit the application.
    Better to use the macro instead of the function.  */
 #define gpa_gpgme_error(err) \
@@ -116,21 +117,17 @@
    the parameters required by Gpgme and returns whatever
    gpgme_op_genkey_start returns.  */
 gpg_error_t gpa_generate_key_start (gpgme_ctx_t ctx, 
-				    GPAKeyGenParameters *params);
+				    gpa_keygen_para_t *params);
 
 /* Backup a key.  It exports both the public and secret keys to a
    file.  Returns TRUE on success and FALSE on error.  It displays
    errors to the user.  */
 gboolean gpa_backup_key (const gchar *fpr, const char *filename);
 
-GPAKeyGenParameters *key_gen_params_new (void);
+gpa_keygen_para_t *gpa_keygen_para_new (void);
 
-void gpa_key_gen_free_parameters (GPAKeyGenParameters *params);
+void gpa_keygen_para_free (gpa_keygen_para_t *params);
 
-const gchar * gpa_algorithm_string (GPAKeyGenAlgo algo);
-
-GPAKeyGenAlgo gpa_algorithm_from_string (const gchar * string);
-
 /* Ownertrust strings.  */
 const gchar *gpa_key_ownertrust_string (gpgme_key_t key);
 

Modified: trunk/src/keygendlg.c
===================================================================
--- trunk/src/keygendlg.c	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/keygendlg.c	2009-05-13 10:37:57 UTC (rev 993)
@@ -1,6 +1,5 @@
 /* keygendlg.c - The GNU Privacy Assistant
-   Copyright (C) 2000, 2001 G-N-U GmbH.
-   Copyright (C) 2008 g10 Code GmbH
+   Copyright (C) 2009 g10 Code GmbH
 
    This file is part of GPA.
 
@@ -26,332 +25,318 @@
 #include "gpa.h"
 #include "gpawidgets.h"
 #include "gtktools.h"
+#include "gpadatebox.h"
 #include "keygendlg.h"
-#include "qdchkpwd.h"
 
-#define	XSTRDUP_OR_NULL(s)	((s != NULL) ? g_strdup (s) : NULL)
 
-struct _GPAKeyGenDialog
+
+/* A table of algorithm combinations we offer to create.  */
+static struct 
 {
-  gboolean forcard;		/* Specifies if this is a dialog for
-				   on-card key generation or not. */
-  GtkWidget *window;
-  GtkWidget *entryUserID;
-  GtkWidget *entryPasswd;
-  GtkWidget *entryRepeat;
-  GtkWidget *frameExpire;
-  GtkWidget *comboKeysize;
+  gpa_keygen_algo_t algo;
+  const char *name;
+} algorithm_table[] = 
+  {
+    { GPA_KEYGEN_ALGO_RSA_RSA,     N_("RSA")},
+    { GPA_KEYGEN_ALGO_RSA,         N_("RSA (sign only)")},
+    { GPA_KEYGEN_ALGO_DSA_ELGAMAL, N_("DSA")},
+    { GPA_KEYGEN_ALGO_DSA,         N_("DSA (sign only)")},
+    { 0, NULL}
+  };
+
+
+
+struct _GpaKeyGenDlg
+{
+  gboolean forcard;	    /* Specifies if this is a dialog for
+			       on-card key generation or not. */
+  GtkWidget *dialog;        /* The dialog object.  */
+
+  GtkWidget *entry_algo;    /* Maybe NULL.  */
+  GtkWidget *entry_keysize; /* Maybe NULL.  */
+  GtkWidget *entry_name;
+  GtkWidget *entry_email;
+  GtkWidget *entry_comment;
+  GtkWidget *entry_expire;
+
+  GtkWidget *label_userid;
 };
-typedef struct _GPAKeyGenDialog GPAKeyGenDialog;
+typedef struct _GpaKeyGenDlg GpaKeyGenDlg;
 
 
 /* This callback gets called each time the user clicks on the [OK] or
    [Cancel] buttons.  If the button was [OK], it verifies that the
    input makes sense.  */
 static void
-response_cb (GtkDialog *dlg, gint response, gpointer param)
+response_cb (GtkDialog *dlg, gint response, gpointer user_data)
 {
-  GPAKeyGenDialog *dialog = param;
-  gchar *expiry_error;
-  const gchar *userid;
-  const gchar *passwd;
-  const gchar *repeat;
-  const gchar *keysize;
+  GpaKeyGenDlg *self = user_data;
+  const gchar *name;
+  const char *temp;
+  int   keysize;
 
   if (response != GTK_RESPONSE_OK)
     return;
 
-  userid = gtk_entry_get_text (GTK_ENTRY (dialog->entryUserID));
-  passwd = (dialog->entryPasswd
-            ? gtk_entry_get_text (GTK_ENTRY (dialog->entryPasswd)) 
-            : NULL);
-  repeat = (dialog->entryRepeat
-            ? gtk_entry_get_text (GTK_ENTRY (dialog->entryRepeat))
-            : NULL);
-  keysize = gtk_combo_box_get_active_text (GTK_COMBO_BOX 
-                                           (dialog->comboKeysize));
-
-  if (keysize == NULL || *keysize == '\0')
+  name = gtk_entry_get_text (GTK_ENTRY (self->entry_name));
+  temp = (self->entry_keysize
+          ? gtk_combo_box_get_active_text (GTK_COMBO_BOX 
+                                           (self->entry_keysize))
+          :  NULL);
+  keysize = temp? atoi (temp):0; 
+             
+  if (!name || !*name)
     {
-      /* FIXME: We should check it is a valid number.  */
-      gpa_window_error (_("You must enter a key size."), dialog->window);
+      gpa_window_error (_("You must enter a User ID."), self->dialog);
       g_signal_stop_emission_by_name (dlg, "response");
-    }      
-  else if (! *userid)
-    {
-      gpa_window_error (_("You must enter a User ID."), dialog->window);
-      g_signal_stop_emission_by_name (dlg, "response");
     }
-  else if ((!dialog->forcard) && (!g_str_equal (passwd, repeat)))
+  else if (self->forcard)
+    ;
+  else if (keysize < 1024)
     {
-      gpa_window_error (_("In \"Passphrase\" and \"Repeat passphrase\",\n"
-			  "you must enter the same passphrase."),
-			dialog->window);
+      gpa_window_error (_("You must enter a key size."), self->dialog);
       g_signal_stop_emission_by_name (dlg, "response");
-    }
-  else if ((!dialog->forcard) && strlen (passwd) == 0)
-    {
-      gpa_window_error (_("You did not enter a passphrase.\n"
-			  "It is needed to protect your private key."),
-			dialog->window);
-      g_signal_stop_emission_by_name (dlg, "response");
-    }
-  else if ((!dialog->forcard) && (strlen (passwd) < 10 || qdchkpwd (passwd) < 0.6))
-    {
-      GtkWidget *msgbox;
-      
-      msgbox = gtk_message_dialog_new (GTK_WINDOW (dialog->window),
-				       GTK_DIALOG_MODAL,
-				       GTK_MESSAGE_WARNING,
-				       GTK_BUTTONS_NONE,
-				       _("Warning: You have entered a "
-					 "passphrase\n"
-					 "that is obviously not secure.\n\n"
-					 "Please enter a new passphrase."));
-      gtk_dialog_add_buttons (GTK_DIALOG (msgbox), 
-			      _("_Enter new passphrase"),
-			      GTK_RESPONSE_CANCEL,
-			      _("Take this one _anyway"), GTK_RESPONSE_OK,
-			      NULL);
-      if (gtk_dialog_run (GTK_DIALOG (msgbox)) == GTK_RESPONSE_CANCEL)
-	g_signal_stop_emission_by_name (dlg, "response");
-      gtk_widget_destroy (msgbox);
-    }
-  else if ((expiry_error = gpa_expiry_frame_validate (dialog->frameExpire)))
-    {
-      g_signal_stop_emission_by_name (dlg, "response");
-      gpa_window_error (expiry_error, dialog->window);
-    }
+    }      
+
+  /* FIXME: check that the expire date is not in the past.  */
 }
 
 
-/* Run the "Generate Key" dialog and if the user presses OK, return
-   the values from the dialog in a newly allocated GPAKeyGenParameters
-   struct.  If FORCARD is true, display the dialog suitable for
-   generation keys on the OpenPGP smartcard. If the user pressed
-   "Cancel", return NULL.  The returned struct has to be deleted with
-   gpa_key_gen_free_parameters.  */
-GPAKeyGenParameters *
-gpa_key_gen_run_dialog (GtkWidget *parent, gboolean forcard)
+static void
+update_preview_cb (void *widget, void *user_data)
 {
-  GtkWidget *windowGenerate;
-  GtkWidget *vboxGenerate;
+  GpaKeyGenDlg *self = user_data;
+  const char *name, *email, *comment;
+  char *uid;
+  (void)widget;
+
+  name = gtk_entry_get_text (GTK_ENTRY (self->entry_name));
+  if (!name)
+    name = "";
+  email = gtk_entry_get_text (GTK_ENTRY (self->entry_email));
+  if (!email)
+    email = "";
+  comment = gtk_entry_get_text (GTK_ENTRY (self->entry_comment));
+  if (!comment)
+    comment = "";
+
+  uid = g_strdup_printf ("%s%s%s%s%s%s%s",
+                         name, 
+                         *comment? " (":"", comment, *comment? ")":"",
+                         *email? " <":"", email, *email? ">":"");
+  gtk_label_set_text (GTK_LABEL (self->label_userid), uid);
+  g_free (uid);
+}
+
+
+
+/* Helper to create the dialog.  PARENT is the parent window.  */
+static void
+create_dialog (GpaKeyGenDlg *self, GtkWidget *parent)
+{
+  GtkWidget *dialog;
+  GtkWidget *vbox;
   GtkWidget *table;
-  GtkWidget *labelAlgorithm;
-  GtkWidget *comboAlgorithm;
-  GtkWidget *labelKeysize;
-  GtkWidget *comboKeysize;
-  GtkWidget *frameExpire;
-  GtkWidget *labelUserID;
-  GtkWidget *entryUserID;
-  GtkWidget *labelEmail;
-  GtkWidget *entryEmail;
-  GtkWidget *labelComment;
-  GtkWidget *entryComment;
-  GtkWidget *labelPasswd;
-  GtkWidget *entryPasswd;
-  GtkWidget *labelRepeat;
-  GtkWidget *entryRepeat;
 
-  GPAKeyGenDialog dialog;
-  GPAKeyGenParameters * params = NULL;
+  GtkWidget *label;
+  GtkWidget *combo;
+  GtkWidget *entry;
+  GtkWidget *button;
 
-  GPAKeyGenAlgo algo;
+  int rowidx, idx;
 
-  dialog.forcard = forcard;
 
-  windowGenerate = gtk_dialog_new_with_buttons
-    (forcard ? _("Generate new keys on card") : _("Generate key"), GTK_WINDOW (parent),
+  dialog = gtk_dialog_new_with_buttons
+    (self->forcard ? _("Generate new keys on card") : _("Generate key"),
+     GTK_WINDOW (parent),
      GTK_DIALOG_MODAL,
      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
      GTK_STOCK_OK, GTK_RESPONSE_OK,
      NULL);
-  gtk_dialog_set_alternative_button_order (GTK_DIALOG (windowGenerate),
+  self->dialog = dialog;
+  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
                                            GTK_RESPONSE_OK,
                                            GTK_RESPONSE_CANCEL,
                                            -1);
-  gtk_dialog_set_default_response (GTK_DIALOG (windowGenerate),
-                                   GTK_RESPONSE_OK);
-  dialog.window = windowGenerate;
+  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
 
-  /* Use g_signal_connect_object here to make the dialog pointer the
-     first parameter of the handler.  */
-  //  g_signal_connect (G_OBJECT (windowGenerate), "delete-event",
-  //  		    G_CALLBACK (gtk_widget_destroy), dialog.window);
-  g_signal_connect (G_OBJECT (windowGenerate), "response",
-                    G_CALLBACK (response_cb), &dialog);
+  vbox = GTK_DIALOG (dialog)->vbox;
+  gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
 
-  vboxGenerate = GTK_DIALOG(dialog.window)->vbox;
-  gtk_container_set_border_width (GTK_CONTAINER (vboxGenerate), 5);
-
   table = gtk_table_new (7, 2, FALSE);
   gtk_container_set_border_width (GTK_CONTAINER (table), 5);
-  gtk_box_pack_start (GTK_BOX (vboxGenerate), table, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
+  rowidx = 0;
 
-  labelAlgorithm = gtk_label_new_with_mnemonic (_("_Algorithm: "));
-  gtk_misc_set_alignment (GTK_MISC (labelAlgorithm), 1.0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), labelAlgorithm, 0, 1, 0, 1,
-		    GTK_FILL, GTK_SHRINK, 0, 0);
-  comboAlgorithm = gtk_combo_box_new_text ();
 
-  if (forcard)
-    /* The OpenPGP smartcard does only support RSA. */
-    gtk_combo_box_append_text (GTK_COMBO_BOX (comboAlgorithm), "RSA");
-  else
+  if (!self->forcard)
     {
-      for (algo = GPA_KEYGEN_ALGO_FIRST; algo <= GPA_KEYGEN_ALGO_LAST; algo++)
-	gtk_combo_box_append_text (GTK_COMBO_BOX (comboAlgorithm), 
-				   gpa_algorithm_string (algo));
+      label = gtk_label_new_with_mnemonic (_("_Algorithm: "));
+      gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+      gtk_table_attach (GTK_TABLE (table), label, 0, 1, rowidx, rowidx+1,
+                        GTK_FILL, GTK_SHRINK, 0, 0);
+      
+      combo = gtk_combo_box_new_text ();
+      for (idx=0; algorithm_table[idx].name; idx++)
+	gtk_combo_box_append_text (GTK_COMBO_BOX (combo), 
+				   algorithm_table[idx].name);
+      gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
+      gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
+      gtk_table_attach (GTK_TABLE (table), combo, 1, 2, rowidx, rowidx+1,
+                        GTK_FILL, GTK_SHRINK, 0, 0);
+      self->entry_algo = combo;
+      rowidx++;
+      
+      label = gtk_label_new_with_mnemonic (_("_Key size (bits): "));
+      gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+      gtk_table_attach (GTK_TABLE (table), label, 0, 1, rowidx, rowidx+1,
+                        GTK_FILL, GTK_SHRINK, 0, 0);
+      combo = gtk_combo_box_new_text ();
+      gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "1024");
+      gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "1536");
+      gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "2048");
+      gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "3072");
+      gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 2);
+      gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
+      
+      gtk_table_attach (GTK_TABLE (table), combo, 1, 2, rowidx, rowidx+1,
+                        GTK_FILL, GTK_SHRINK, 0, 0);
+      self->entry_keysize = combo;
+      rowidx++;
     }
-  gtk_combo_box_set_active (GTK_COMBO_BOX (comboAlgorithm), 0);
-  gtk_label_set_mnemonic_widget (GTK_LABEL (labelAlgorithm), comboAlgorithm);
-			      
-  gtk_table_attach (GTK_TABLE (table), comboAlgorithm, 1, 2, 0, 1,
-		    GTK_FILL, GTK_SHRINK, 0, 0);
 
-  labelKeysize = gtk_label_new_with_mnemonic (_("_Key size (bits): "));
-  gtk_misc_set_alignment (GTK_MISC (labelKeysize), 1.0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), labelKeysize, 0, 1, 1, 2,
-		    GTK_FILL, GTK_SHRINK, 0, 0);
-  comboKeysize = gtk_combo_box_new_text ();
-  dialog.comboKeysize = comboKeysize;
+  
+  label = gtk_label_new (NULL);  /* Dummy label.  */
+  gtk_table_attach (GTK_TABLE (table), label, 0, 2, rowidx, rowidx+1,
+                    GTK_FILL, GTK_FILL, 0, 0);
+  rowidx++;
 
-  if (forcard)
-    {
-      /* The OpenPGP smartcard does only support 1024bit RSA
-	 keys. FIXME: should we really hardcode this? -mo */
-      gtk_combo_box_append_text (GTK_COMBO_BOX (comboKeysize), _("1024"));
-      gtk_combo_box_set_active (GTK_COMBO_BOX (comboKeysize), 0);
-    }
-  else
-    {
-      gtk_combo_box_append_text (GTK_COMBO_BOX (comboKeysize), _("768"));
-      gtk_combo_box_append_text (GTK_COMBO_BOX (comboKeysize), _("1024"));
-      gtk_combo_box_append_text (GTK_COMBO_BOX (comboKeysize), _("2048"));
-      gtk_combo_box_set_active (GTK_COMBO_BOX (comboKeysize), 1 /* 1024 */);
-    }
-  gtk_label_set_mnemonic_widget (GTK_LABEL (labelKeysize), comboKeysize);
-  gtk_table_attach (GTK_TABLE (table), comboKeysize, 1, 2, 1, 2,
-		    GTK_FILL, GTK_SHRINK, 0, 0);
 
-  labelUserID = gtk_label_new_with_mnemonic (_("_User ID: "));
-  gtk_misc_set_alignment (GTK_MISC (labelUserID), 1.0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), labelUserID, 0, 1, 2, 3,
-		    GTK_FILL, GTK_SHRINK, 0, 0);
-  entryUserID = gtk_entry_new ();
-  dialog.entryUserID = entryUserID;
-  gtk_label_set_mnemonic_widget (GTK_LABEL (labelUserID), entryUserID);
+  label = gtk_label_new (NULL);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 2, rowidx, rowidx+1,
+                    GTK_FILL, GTK_FILL, 0, 0);
+  self->label_userid = label;
+  rowidx++;
 
-  gtk_table_attach (GTK_TABLE (table), entryUserID, 1, 2, 2, 3, GTK_FILL,
-		    GTK_SHRINK, 0, 0);
+  label = gtk_label_new (NULL);  /* Dummy label.  */
+  gtk_table_attach (GTK_TABLE (table), label, 0, 2, rowidx, rowidx+1,
+                    GTK_FILL, GTK_FILL, 0, 0);
+  rowidx++;
 
-  labelEmail = gtk_label_new_with_mnemonic (_("_Email: "));
-  gtk_misc_set_alignment (GTK_MISC (labelEmail), 1.0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), labelEmail, 0, 1, 3, 4,
+  label = gtk_label_new_with_mnemonic (_("_User ID: "));
+  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, rowidx, rowidx+1,
 		    GTK_FILL, GTK_SHRINK, 0, 0);
-  entryEmail = gtk_entry_new ();
-  gtk_label_set_mnemonic_widget (GTK_LABEL (labelEmail), entryEmail);
-  gtk_table_attach (GTK_TABLE (table), entryEmail, 1, 2, 3, 4, GTK_FILL,
-		    GTK_SHRINK, 0, 0);
+  entry = gtk_entry_new ();
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+  gtk_table_attach (GTK_TABLE (table), entry, 1, 2, rowidx, rowidx+1,
+                    GTK_FILL, GTK_SHRINK, 0, 0);
+  self->entry_name = entry;
+  g_signal_connect (G_OBJECT (entry), "changed",
+                    G_CALLBACK (update_preview_cb), self);
+  rowidx++;
 
-  labelComment = gtk_label_new_with_mnemonic (_("_Comment: "));
-  gtk_misc_set_alignment (GTK_MISC (labelComment), 1.0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), labelComment, 0, 1, 4, 5,
+  label = gtk_label_new_with_mnemonic (_("_Email: "));
+  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, rowidx, rowidx+1,
 		    GTK_FILL, GTK_SHRINK, 0, 0);
-  entryComment = gtk_entry_new ();
-  gtk_label_set_mnemonic_widget (GTK_LABEL (labelComment), entryComment);
-  gtk_table_attach (GTK_TABLE (table), entryComment, 1, 2, 4, 5, GTK_FILL,
-		    GTK_SHRINK, 0, 0);
+  entry = gtk_entry_new ();
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+  gtk_table_attach (GTK_TABLE (table), entry, 1, 2, rowidx, rowidx+1,
+                    GTK_FILL, GTK_SHRINK, 0, 0);
+  self->entry_email = entry;
+  g_signal_connect (G_OBJECT (entry), "changed",
+                    G_CALLBACK (update_preview_cb), self);
+  rowidx++;
 
-  entryPasswd = NULL;		/* Silence compiler warning. */
+  label = gtk_label_new_with_mnemonic (_("_Comment: "));
+  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, rowidx, rowidx+1,
+		    GTK_FILL, GTK_SHRINK, 0, 0);
+  entry = gtk_entry_new ();
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+  gtk_table_attach (GTK_TABLE (table), entry, 1, 2, rowidx, rowidx+1,
+                    GTK_FILL, GTK_SHRINK, 0, 0);
+  self->entry_comment = entry;
+  g_signal_connect (G_OBJECT (entry), "changed",
+                    G_CALLBACK (update_preview_cb), self);
+  rowidx++;
 
-  if (forcard)
-    {
-      /* This doesn't make sense for the smartcard. */
-      dialog.entryPasswd = NULL;
-      dialog.entryRepeat = NULL;
-    }
-  else
-    {
-      labelPasswd = gtk_label_new_with_mnemonic (_("_Passphrase: "));
-      gtk_misc_set_alignment (GTK_MISC (labelPasswd), 1.0, 0.5);
-      gtk_table_attach (GTK_TABLE (table), labelPasswd, 0, 1, 5, 6,
-			GTK_FILL, GTK_SHRINK, 0, 0);
-      entryPasswd = gtk_entry_new ();
-      dialog.entryPasswd = entryPasswd;
-      gtk_entry_set_visibility (GTK_ENTRY (entryPasswd), FALSE);
-      gtk_label_set_mnemonic_widget (GTK_LABEL (labelPasswd), entryPasswd);
-      gtk_table_attach (GTK_TABLE (table), entryPasswd, 1, 2, 5, 6, GTK_FILL,
-			GTK_SHRINK, 0, 0);
+  label = gtk_label_new_with_mnemonic (_("_Expires: "));
+  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, rowidx, rowidx+1,
+                    GTK_FILL, GTK_SHRINK, 0, 0);
+  button = gpa_date_box_new ();
+  gtk_table_attach (GTK_TABLE (table), button, 1, 2, rowidx, rowidx+1,
+                    GTK_FILL, GTK_SHRINK, 0, 0);
+  self->entry_expire = button;
 
-      labelRepeat = gtk_label_new_with_mnemonic (_("_Repeat passphrase: "));
-      gtk_misc_set_alignment (GTK_MISC (labelRepeat), 1.0, 0.5);
-      gtk_table_attach (GTK_TABLE (table), labelRepeat, 0, 1, 6, 7,
-			GTK_FILL, GTK_SHRINK, 0, 0);
-      entryRepeat = gtk_entry_new ();
-      dialog.entryRepeat = entryRepeat;
-      gtk_entry_set_visibility (GTK_ENTRY (entryRepeat), FALSE);
-      gtk_label_set_mnemonic_widget (GTK_LABEL (labelRepeat), entryRepeat);
+}
 
-      gtk_table_attach (GTK_TABLE (table), entryRepeat, 1, 2, 6, 7,
-			GTK_FILL, GTK_SHRINK, 0, 0);
-    }
 
-  frameExpire = gpa_expiry_frame_new (NULL);
-  dialog.frameExpire = frameExpire;
-  gtk_container_set_border_width (GTK_CONTAINER (frameExpire), 5);
-  gtk_box_pack_start (GTK_BOX (vboxGenerate), frameExpire, FALSE, FALSE, 0);
+/* Run the "Generate Key" dialog and if the user presses OK, return
+   the values from the dialog in a newly allocated gpa_keygen_para_t
+   struct.  If FORCARD is true, display the dialog suitable for
+   generation keys on the OpenPGP smartcard. If the user pressed
+   "Cancel", return NULL.  The returned struct has to be freed with
+   gpa_keygen_para_free.  */
+gpa_keygen_para_t *
+gpa_key_gen_run_dialog (GtkWidget *parent, gboolean forcard)
+{
+  GpaKeyGenDlg *self;
+  gpa_keygen_para_t *params;
 
-  gtk_widget_show_all (windowGenerate);
-  if (gtk_dialog_run (GTK_DIALOG (windowGenerate)) == GTK_RESPONSE_OK)
-    {
-      /* The user pressed OK, so create a GPAKeyGenParameters struct
-	 and fill it with the values from the dialog.  */
-      gchar *temp;
+  self = xcalloc (1, sizeof *self);
+  self->forcard = forcard;
+  create_dialog (self, parent);
+  g_signal_connect (G_OBJECT (self->dialog), "response",
+                    G_CALLBACK (response_cb), self);
 
-      params = key_gen_params_new ();
-      params->userID
-	= XSTRDUP_OR_NULL (gtk_entry_get_text (GTK_ENTRY (entryUserID)));
-      params->email
-	= XSTRDUP_OR_NULL(gtk_entry_get_text (GTK_ENTRY (entryEmail)));
-      params->comment
-	= XSTRDUP_OR_NULL (gtk_entry_get_text (GTK_ENTRY(entryComment)));
 
-      if (forcard)
-	params->password = NULL;
-      else
-	params->password
-	  = XSTRDUP_OR_NULL (gtk_entry_get_text (GTK_ENTRY(entryPasswd)));
+  gtk_widget_show_all (self->dialog);
+  if (gtk_dialog_run (GTK_DIALOG (self->dialog)) != GTK_RESPONSE_OK)
+    {
+      gtk_widget_destroy (self->dialog);
+      g_free (self);
+      return NULL;
+    }
 
-      if (forcard)
-	/* Although this values isn't used... */
-	params->algo = GPA_KEYGEN_ALGO_RSA;
-      else
-	{
-	  temp = gtk_combo_box_get_active_text (GTK_COMBO_BOX (comboAlgorithm));
-	  params->algo = gpa_algorithm_from_string (temp);
-	}
+  /* The user pressed OK: Populate gpa_keygen_para_t struct and
+     return it.  */
+  params = gpa_keygen_para_new ();
+  params->name   = g_strdup (gtk_entry_get_text
+                             (GTK_ENTRY (self->entry_name)));
+  params->email  = g_strdup (gtk_entry_get_text
+                             (GTK_ENTRY (self->entry_email)));
+  params->comment= g_strdup (gtk_entry_get_text 
+                             (GTK_ENTRY (self->entry_comment)));
 
-      temp = gtk_combo_box_get_active_text (GTK_COMBO_BOX (comboKeysize));
-      params->keysize = atoi (temp);
+  if (forcard)
+    params->algo = GPA_KEYGEN_ALGO_VIA_CARD;
+  else
+    {
+      char *temp;
+      int idx;
 
-      params->expiryDate = NULL;
-      params->interval = 0;
-      if (! gpa_expiry_frame_get_expiration (frameExpire, &(params->expiryDate),
-					     &(params->interval),
-					     &(params->unit)))
-	{
-	  gpa_window_error (_("!FATAL ERROR!\n"
-			      "Invalid insert mode for expiry date."),
-			    parent);
-	  gpa_key_gen_free_parameters(params);
-	  params = NULL;
-	}
+      idx = gtk_combo_box_get_active (GTK_COMBO_BOX (self->entry_algo));
+      if (idx < 0 || idx >= DIM (algorithm_table) 
+          || !algorithm_table[idx].name)
+        {
+	  gpa_keygen_para_free (params);
+          gtk_widget_destroy (self->dialog);
+          g_free (self);
+          g_return_val_if_reached (NULL);
+        }
+      params->algo = algorithm_table[idx].algo;
+      temp = gtk_combo_box_get_active_text 
+        (GTK_COMBO_BOX (self->entry_keysize));
+      params->keysize = temp? atoi (temp) : 0;
     }
-  else
-    params = NULL;
+      
+  gpa_date_box_get_date (GPA_DATE_BOX (self->entry_expire), &params->expire);
 
-  gtk_widget_destroy (windowGenerate);
+  gtk_widget_destroy (self->dialog);
+  g_free (self);
 
   return params;
 }

Modified: trunk/src/keygendlg.h
===================================================================
--- trunk/src/keygendlg.h	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/keygendlg.h	2009-05-13 10:37:57 UTC (rev 993)
@@ -25,7 +25,7 @@
 #include <gtk/gtk.h>
 #include "gpgmetools.h"
 
-GPAKeyGenParameters * gpa_key_gen_run_dialog (GtkWidget *parent, 
+gpa_keygen_para_t * gpa_key_gen_run_dialog (GtkWidget *parent, 
                                               gboolean forcard);
 
 

Modified: trunk/src/keygenwizard.c
===================================================================
--- trunk/src/keygenwizard.c	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/keygenwizard.c	2009-05-13 10:37:57 UTC (rev 993)
@@ -35,6 +35,10 @@
 #include "gpgmetools.h"
 #include "keygenwizard.h"
 
+
+#define STANDARD_KEY_LENGTH 2048
+
+
 /* The key generation wizard.
  
    New users should not be overwhelmed by too many options most of which
@@ -458,10 +462,17 @@
 static GtkWidget *
 gpa_keygen_wizard_final_page (GPAKeyGenWizard * keygen_wizard)
 {
-  return gpa_keygen_wizard_message_page
+  GtkWidget *widget;
+  char *desc;
+
+  desc = g_strdup_printf 
     (_("Congratulations!\n\n"
        "You have successfully generated a key."
-       " The key is indefinitely valid and has a length of 1024 bits."));
+       " The key is indefinitely valid and has a length of %d bits."), 
+     STANDARD_KEY_LENGTH);
+  widget = gpa_keygen_wizard_message_page (desc);
+  g_free (desc);
+  return widget;
 }
 
 
@@ -472,11 +483,11 @@
 //GtkAssistant *assistant, GtkWidget *page, gpointer data)
 {
   GPAKeyGenWizard *wizard = data;
-  GPAKeyGenParameters params;
+  gpa_keygen_para_t *para;
   gboolean do_backup;
   GtkWidget *radio;
 
-  memset (&params, 0, sizeof params);
+  para = gpa_keygen_para_new ();
 
   /* Shall we make backups?  */
   radio = g_object_get_data (G_OBJECT (wizard->backup_page),
@@ -484,21 +495,18 @@
   do_backup = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio));
 
   /* The User ID.  */
-  params.userID = gpa_keygen_wizard_simple_get_text (wizard->name_page);
-  params.email = gpa_keygen_wizard_simple_get_text (wizard->email_page);
-  params.password
+  para->name = gpa_keygen_wizard_simple_get_text (wizard->name_page);
+  para->email = gpa_keygen_wizard_simple_get_text (wizard->email_page);
+  para->password
     = gpa_keygen_wizard_password_get_password (wizard->passwd_page);
 
   /* Default values for newbie mode.  */
-  params.algo = GPA_KEYGEN_ALGO_DSA_ELGAMAL;
-  params.keysize = 1024;
-  params.expiryDate = NULL;
-  params.interval = 0;
+  para->algo = GPA_KEYGEN_ALGO_RSA_RSA;
+  para->keysize = STANDARD_KEY_LENGTH;
 
-  wizard->generate (&params, do_backup, wizard->generate_data);
+  wizard->generate (para, do_backup, wizard->generate_data);
 
-  g_free (params.userID);
-  g_free (params.email);
+  gpa_keygen_para_free (para);
 
   return FALSE;
 }

Modified: trunk/src/keygenwizard.h
===================================================================
--- trunk/src/keygenwizard.h	2009-05-07 18:49:43 UTC (rev 992)
+++ trunk/src/keygenwizard.h	2009-05-13 10:37:57 UTC (rev 993)
@@ -23,7 +23,7 @@
 
 #include <gtk/gtk.h>
 
-typedef gboolean (*GpaKeyGenWizardGenerateCb) (GPAKeyGenParameters *params,
+typedef gboolean (*GpaKeyGenWizardGenerateCb) (gpa_keygen_para_t *params,
 					       gboolean do_backup,
 					       gpointer data);
 



More information about the Gpa-commits mailing list