[Gpa-commits] r931 - trunk/src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Jan 13 14:14:59 CET 2009


Author: werner
Date: 2009-01-13 14:14:58 +0100 (Tue, 13 Jan 2009)
New Revision: 931

Modified:
   trunk/src/ChangeLog
   trunk/src/cardman.c
Log:
Detect card type (requires gnupg > 2.0.10)


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2009-01-11 16:15:55 UTC (rev 930)
+++ trunk/src/ChangeLog	2009-01-13 13:14:58 UTC (rev 931)
@@ -1,3 +1,11 @@
+2009-01-13  Werner Koch  <wk at g10code.com>
+
+	* cardman.c (_GpaCardManager): Add field CARDTYPE.
+	(card_reload_cb): Detect the card type.
+	(update_info_visibility): Put card type into the status line.
+	(cardman_statusbar_new): Rename to statusbar_new.
+	(cardman_statusbar_update): Rename to statusbar_update.
+
 2009-01-11  Moritz  <moritz at gnu.org>
 
 	* gpgmeedit.c (card_edit_genkey_fnc_transit): Add default-case in

Modified: trunk/src/cardman.c
===================================================================
--- trunk/src/cardman.c	2009-01-11 16:15:55 UTC (rev 930)
+++ trunk/src/cardman.c	2009-01-13 13:14:58 UTC (rev 931)
@@ -80,6 +80,9 @@
 #endif
 
   int have_card;             /* True, if a supported card is in the reader.  */
+  const char *cardtype;      /* String with the card type.  */
+  int is_openpgp;            /* True if the card is an OpenPGP card.  */
+
   gpa_filewatch_id_t watch;  /* For watching the reader status file.  */
   int in_card_reload;        /* Sentinel for card_reload.  */
 };
@@ -115,7 +118,7 @@
 /* Status bar handling.  */
 
 static GtkWidget *
-cardman_statusbar_new (GpaCardManager *cardman)
+statusbar_new (GpaCardManager *cardman)
 {
   GtkWidget *align;
   GtkWidget *hbox;
@@ -139,7 +142,7 @@
 
 
 static void
-cardman_statusbar_update (GpaCardManager *cardman, const char *text)
+statusbar_update (GpaCardManager *cardman, const char *text)
 {
   gtk_label_set_text (GTK_LABEL (cardman->status_text), text);
 }
@@ -167,12 +170,18 @@
 {
   if (cardman->have_card)
     {
-      cardman_statusbar_update (cardman, _("Smart card detected."));
-      gtk_widget_show_all (cardman->card_widget);
+      char *tmp = g_strdup_printf (_("%s card detected."), cardman->cardtype);
+      
+      statusbar_update (cardman, tmp);
+      xfree (tmp);
+      if (cardman->is_openpgp)
+        gtk_widget_show_all (cardman->card_widget);
+      else
+        gtk_widget_hide_all (cardman->card_widget);
     }
   else
     {
-      cardman_statusbar_update (cardman, _("Checking for smart card..."));
+      statusbar_update (cardman, _("Checking for card..."));
       gtk_widget_hide_all (cardman->card_widget);
     }
 }
@@ -193,6 +202,23 @@
       if (idx == 0)
         {
           cardman->have_card = !!*string;
+          cardman->cardtype = "Unknown";
+          cardman->is_openpgp = 0;
+        }
+      else if (idx == 1)
+        {
+          if (!strcmp (string, "openpgp-card"))
+            {
+              cardman->cardtype = "OpenPGP";
+              cardman->is_openpgp = 1;
+            }
+          else if (!strcmp (string, "netkey-card"))
+            cardman->cardtype = "NetKey";
+          else if (!strcmp (string, "dinsig-card"))
+            cardman->cardtype = "DINSIG";
+          else if (!strcmp (string, "pkcs15-card"))
+            cardman->cardtype = "PKCS#15";
+
           update_info_visibility (cardman);
           update_title (cardman);
         }
@@ -616,7 +642,9 @@
 				      construct_properties);
   cardman = GPA_CARD_MANAGER (object);
 
-  cardman->have_card = 1;
+  cardman->have_card = 0;
+  cardman->cardtype = "Unknown";
+  cardman->is_openpgp = 0;
 
   cardman->entryLogin = NULL;
 
@@ -666,7 +694,7 @@
   cardman->card_widget = construct_card_widget (cardman);
   gtk_box_pack_start (GTK_BOX (vbox), cardman->card_widget, TRUE, TRUE, 0);
 
-  statusbar = cardman_statusbar_new (cardman);
+  statusbar = statusbar_new (cardman);
   gtk_box_pack_start (GTK_BOX (vbox), statusbar, TRUE, TRUE, 0);
 
   gtk_container_add (GTK_CONTAINER (cardman), vbox);



More information about the Gpa-commits mailing list