--- camel-gpg-context.c.orig	2005-09-02 16:37:43.000000000 +0200
+++ camel-gpg-context.c	2006-04-29 10:58:19.580018429 +0200
@@ -775,6 +775,20 @@
 		
 		g_free (gpg->need_id);
 		gpg->need_id = userid;
+	} else if (!strncmp (status, "NEED_PASSPHRASE_PIN ", 20)) {
+		char *userid;
+		
+		status += 20;
+		
+		status = next_token (status, &userid);
+		if (!userid) {
+			camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
+					     _("Failed to parse gpg passphrase request."));
+			return -1;
+		}
+		
+		g_free (gpg->need_id);
+		gpg->need_id = userid;
 	} else if (!strncmp (status, "GET_HIDDEN passphrase.enter", 27)) {
 		char *prompt, *passwd;
 		const char *name;
@@ -809,6 +823,40 @@
 		g_free (passwd);
 		
 		gpg->send_passwd = TRUE;
+	} else if (!strncmp (status, "GET_HIDDEN passphrase.pin.ask", 29)) {
+		char *prompt, *passwd;
+		const char *name;
+		
+		name = g_hash_table_lookup (gpg->userid_hint, gpg->need_id);
+		if (!name)
+			name = gpg->need_id;
+		
+		prompt = g_strdup_printf (_("You need a PIN to unlock the key on\n"
+					    "SmartCard: \"%s\""), name);
+		
+		if ((passwd = camel_session_get_password (gpg->session, NULL, NULL, prompt,  gpg->need_id, CAMEL_SESSION_PASSWORD_SECRET, ex)) && !gpg->utf8) {
+			char *opasswd = passwd;
+			
+			if ((passwd = g_locale_to_utf8 (passwd, -1, &nread, &nwritten, NULL))) {
+				memset (opasswd, 0, strlen (opasswd));
+				g_free (opasswd);
+			} else {
+				passwd = opasswd;
+			}
+		}
+		g_free (prompt);
+		
+		if (passwd == NULL) {
+			if (!camel_exception_is_set (ex))
+				camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled."));
+			return -1;
+		}
+		
+		gpg->passwd = g_strdup_printf ("%s\n", passwd);
+		memset (passwd, 0, strlen (passwd));
+		g_free (passwd);
+		
+		gpg->send_passwd = TRUE;
 	} else if (!strncmp (status, "GOOD_PASSPHRASE", 15)) {
 		gpg->bad_passwds = 0;
 	} else if (!strncmp (status, "BAD_PASSPHRASE", 14)) {
