[Winpt-commits] r207 - trunk/Src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Apr 28 12:28:37 CEST 2006


Author: twoaday
Date: 2006-04-28 12:28:24 +0200 (Fri, 28 Apr 2006)
New Revision: 207

Modified:
   trunk/Src/ChangeLog
   trunk/Src/WinPT-en.rc
   trunk/Src/resource.h
   trunk/Src/wptKeyCache.cpp
   trunk/Src/wptKeyEdit.cpp
   trunk/Src/wptKeyEditCB.cpp
   trunk/Src/wptKeyEditDlgs.cpp
   trunk/Src/wptKeyManager.cpp
   trunk/Src/wptKeyManagerDlg.cpp
   trunk/Src/wptKeylist.cpp
   trunk/Src/wptKeysigDlg.cpp
   trunk/Src/wptListView.cpp
   trunk/Src/wptMAPI.cpp
Log:
Bug fixes and cleanups.



Modified: trunk/Src/ChangeLog
===================================================================
--- trunk/Src/ChangeLog	2006-04-28 10:28:06 UTC (rev 206)
+++ trunk/Src/ChangeLog	2006-04-28 10:28:24 UTC (rev 207)
@@ -1,3 +1,14 @@
+2006-04-28  Timo Schulz  <ts at g10code.de>
+
+	* wptMAPI.cpp (mapi_send_pubkey): Use new key struct.
+	* wptKeysigDlg.cpp (sigprops_dlg_proc): Prepare dialog
+	for handling policy URLs.
+	* wptKeyManagerDlg.cpp (save_column_info, restore_column_info):
+	New option KMSortBy.
+	* wptKeylist.cpp (get_key_algo): Lower priority for revoked keys.
+	* wptKeyEdit.cpp (minimizeKey): New.
+	* wptKeyCache.cpp (gpg_keycache_update_key): Reload utf8 uid list.
+	
 2006-04-27  Timo Schulz  <ts at g10code.de>
 
 	* wptKeyManager.cpp (km_get_key_ptr): New.

Modified: trunk/Src/WinPT-en.rc
===================================================================
--- trunk/Src/WinPT-en.rc	2006-04-28 10:28:06 UTC (rev 206)
+++ trunk/Src/WinPT-en.rc	2006-04-28 10:28:24 UTC (rev 207)
@@ -120,36 +120,39 @@
     PUSHBUTTON      "&Cancel",IDCANCEL,130,129,50,14
 END
 
-IDD_WINPT_SIGPROPS DIALOG DISCARDABLE  0, 0, 242, 130
+IDD_WINPT_SIGPROPS DIALOG DISCARDABLE  0, 0, 242, 159
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Signature Properties"
 FONT 8, "MS Sans Serif"
 BEGIN
-    GROUPBOX        "Signature Info",IDC_STATIC,2,3,235,102
-    EDITTEXT        IDC_SIGPROPS_INFO,8,18,219,13,ES_AUTOHSCROLL | 
+    GROUPBOX        "Signature Info",IDC_STATIC,2,3,235,128
+    EDITTEXT        IDC_SIGPROPS_INFO,9,18,219,13,ES_AUTOHSCROLL | 
                     ES_READONLY
-    LTEXT           "Issuer key",IDC_SIGPROPS_KEYINF,8,36,111,8
-    EDITTEXT        IDC_SIGPROPS_ISSUER,8,49,146,12,ES_AUTOHSCROLL | 
+    LTEXT           "Issuer key",IDC_SIGPROPS_KEYINF,9,36,111,8
+    EDITTEXT        IDC_SIGPROPS_ISSUER,9,49,146,12,ES_AUTOHSCROLL | 
                     ES_READONLY
-    LTEXT           "Expire date",IDC_SIGPROPS_EXPSTR,8,70,40,8
+    LTEXT           "Issuer key ID",IDC_SIGPROPS_KEYIDINF,155,36,73,8
+    EDITTEXT        IDC_SIGPROPS_KEYID,155,49,73,12,ES_AUTOHSCROLL | 
+                    ES_READONLY
+    LTEXT           "Policy URL",IDC_SIGPROPS_POLICINF,9,68,64,8
+    EDITTEXT        IDC_SIGPROPS_POLIC,9,80,219,12,ES_AUTOHSCROLL | 
+                    ES_READONLY
+    LTEXT           "Expire date",IDC_SIGPROPS_EXPSTR,9,100,40,8
     CONTROL         "DateTimePicker1",IDC_SIGPROPS_EXPDATE,"SysDateTimePick32",
-                    DTS_RIGHTALIGN | WS_DISABLED | WS_TABSTOP,49,68,60,12
+                    DTS_RIGHTALIGN | WS_DISABLED | WS_TABSTOP,54,99,60,12
+    LTEXT           "Class",IDC_SIGPROPS_CLASSINF,161,100,25,8
+    EDITTEXT        IDC_SIGPROPS_CLASS,188,99,40,12,ES_AUTOHSCROLL | 
+                    ES_READONLY
     CONTROL         "Exportable",IDC_SIGPROPS_EXP,"Button",BS_AUTOCHECKBOX | 
-                    BS_FLAT | WS_DISABLED | WS_TABSTOP,5,91,53,10
+                    BS_FLAT | WS_DISABLED | WS_TABSTOP,9,118,53,10
     CONTROL         "Non-revocably",IDC_SIGPROPS_NREV,"Button",
-                    BS_AUTOCHECKBOX | BS_FLAT | WS_DISABLED | WS_TABSTOP,60,
-                    91,67,10
+                    BS_AUTOCHECKBOX | BS_FLAT | WS_DISABLED | WS_TABSTOP,64,
+                    118,67,10
     CONTROL         "Revoked",IDC_SIGPROPS_REV,"Button",BS_AUTOCHECKBOX | 
-                    BS_FLAT | WS_DISABLED | WS_TABSTOP,129,91,50,10
+                    BS_FLAT | WS_DISABLED | WS_TABSTOP,133,118,50,10
     CONTROL         "Expired",IDC_SIGPROPS_EXPIRED,"Button",BS_AUTOCHECKBOX | 
-                    BS_FLAT | WS_DISABLED | WS_TABSTOP,183,91,50,10
-    DEFPUSHBUTTON   "OK",IDOK,187,107,50,14
-    LTEXT           "Class",IDC_SIGPROPS_CLASSINF,161,70,25,8
-    EDITTEXT        IDC_SIGPROPS_CLASS,188,69,40,12,ES_AUTOHSCROLL | 
-                    ES_READONLY
-    LTEXT           "Issuer key ID",IDC_SIGPROPS_KEYIDINF,155,36,73,8
-    EDITTEXT        IDC_SIGPROPS_KEYID,155,49,73,12,ES_AUTOHSCROLL | 
-                    ES_READONLY
+                    BS_FLAT | WS_DISABLED | WS_TABSTOP,187,118,50,10
+    DEFPUSHBUTTON   "OK",IDOK,187,135,50,14
 END
 
 IDD_WINPT_KEYEDIT_SHOWPREF DIALOG DISCARDABLE  0, 0, 144, 154
@@ -216,7 +219,7 @@
         LEFTMARGIN, 2
         RIGHTMARGIN, 237
         TOPMARGIN, 3
-        BOTTOMMARGIN, 123
+        BOTTOMMARGIN, 152
     END
 
     IDD_WINPT_KEYEDIT_SHOWPREF, DIALOG

Modified: trunk/Src/resource.h
===================================================================
--- trunk/Src/resource.h	2006-04-28 10:28:06 UTC (rev 206)
+++ trunk/Src/resource.h	2006-04-28 10:28:24 UTC (rev 207)
@@ -647,6 +647,8 @@
 #define IDC_LANGUAGE_INFO               1523
 #define IDC_LANGUAGE_LIST               1524
 #define IDC_SHOWPREF_UIDHINT            1525
+#define IDC_SIGPROPS_POLICINF           1526
+#define IDC_SIGPROPS_POLIC              1527
 #define ID_GPG_ENCRYPT                  40003
 #define ID_GPG_DECRYPT                  40004
 #define ID_GPG_SIGN                     40005
@@ -827,7 +829,7 @@
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        246
 #define _APS_NEXT_COMMAND_VALUE         40186
-#define _APS_NEXT_CONTROL_VALUE         1526
+#define _APS_NEXT_CONTROL_VALUE         1528
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif

Modified: trunk/Src/wptKeyCache.cpp
===================================================================
--- trunk/Src/wptKeyCache.cpp	2006-04-28 10:28:06 UTC (rev 206)
+++ trunk/Src/wptKeyCache.cpp	2006-04-28 10:28:24 UTC (rev 207)
@@ -251,53 +251,62 @@
 }
 
 
+static void
+keycache_decode_uid (struct keycache_s *ctx)
+{
+    gpgme_user_id_t u;
+    struct native_uid_s *n, *t;
+
+    for (u = ctx->key->uids; u; u = u->next) {
+	n = (struct native_uid_s*)calloc (1, sizeof *n);
+	if (!n)
+	    BUG (0);
+	if (is_8bit_string (u->uid)) {
+	    n->malloced = 1;
+	    n->uid = utf8_to_native (u->uid);
+	    if (u->name != NULL)
+		n->name = utf8_to_native (u->name);
+	    if (u->email != NULL)
+		n->email = strdup (u->email);
+	    if (u->comment != NULL)
+		n->comment = utf8_to_native (u->comment);
+	}
+	else {
+	    n->malloced = 0;
+	    n->uid = u->uid;
+	    n->name = u->name;
+	    n->comment = u->comment;
+	    n->email = u->email;
+	}
+	n->validity = u->validity;
+	n->revoked = u->revoked;
+	if (!ctx->uids)	
+	    ctx->uids = n;
+	else {
+	    for (t = ctx->uids; t->next; t=t->next)
+		;
+	    t->next = n;	   
+	}
+    }
+}
+
+
 /* Store utf8 decoded user IDs in the code to avoid in-place decoding. */
-static gpgme_error_t
+static void
 keycache_decode_uids (gpg_keycache_t ctx)
 {
-    struct native_uid_s *n, *t;
     struct keycache_s *c;
-    gpgme_user_id_t u;
 
-    for (c = ctx->item; c; c = c->next) {
-	for (u = c->key->uids; u; u = u->next) {
-	    n = (struct native_uid_s*)calloc (1, sizeof *n);
-	    if (!n)
-		BUG (0);
-	    if (is_8bit_string (u->uid)) {
-		n->malloced = 1;
-		n->uid = utf8_to_native (u->uid);
-		if (u->name != NULL)
-		    n->name = utf8_to_native (u->name);
-		if (u->email != NULL)
-    		    n->email = strdup (u->email);
-		if (u->comment != NULL)
-		    n->comment = utf8_to_native (u->comment);
-	    }
-	    else {
-		n->malloced = 0;
-		n->uid = u->uid;
-		n->name = u->name;
-		n->comment = u->comment;
-		n->email = u->email;
-	    }
-	    if (!c->uids)
-		c->uids = n;
-	    else {
-		for (t = c->uids; t->next; t=t->next)
-		    ;
-		t->next = n;
-	    }
-	}
-    }	
-    return 0;
+    for (c = ctx->item; c; c = c->next)
+	keycache_decode_uid (c);
 }
 
 
 static void
-free_native_uids (struct native_uid_s *n)
+free_native_uids (struct native_uid_s **r_n)
 {
     struct native_uid_s *t;
+    struct native_uid_s *n = *r_n;
 
     while (n != NULL) {
 	t = n->next;
@@ -311,6 +320,7 @@
 	safe_free (n);
 	n = t;
     }
+    *r_n = NULL;
 }
 
 
@@ -445,7 +455,7 @@
 	safe_free (c->sym_prefs);
 	safe_free (c->attrib.d);
 	safe_free (c->card_type);
-	free_native_uids (c->uids);
+	free_native_uids (&c->uids);
 	safe_free (c);
     }
     safe_free (ctx);
@@ -636,6 +646,10 @@
 	}
 	/* XXX: this is also called for keys without a photo-id. */
 	keycache_reload_photo (ctx, keyid);
+
+	/* refresh utf8 user ID list. */
+	free_native_uids (&c->uids);
+	keycache_decode_uid (c);
     }
     else {
 	log_debug ("keycache add: sync public part\r\n");

Modified: trunk/Src/wptKeyEdit.cpp
===================================================================
--- trunk/Src/wptKeyEdit.cpp	2006-04-28 10:28:06 UTC (rev 206)
+++ trunk/Src/wptKeyEdit.cpp	2006-04-28 10:28:24 UTC (rev 207)
@@ -798,6 +798,17 @@
 }
 
 
+/* Remove unusable parts and all signatures from a key. */
+gpgme_error_t 
+GpgKeyEdit::minimizeKey (void)
+{
+    if (!this->key)
+	return gpg_error (GPG_ERR_INV_OBJ);
+    type = GPG_EDITKEY_MINIMIZE;
+    return gpg_editkey (this->ctx, this->key, this);
+}
+
+
 /* Remove unusable parts from a key. */
 gpgme_error_t
 GpgKeyEdit::cleanKey (void)

Modified: trunk/Src/wptKeyEditCB.cpp
===================================================================
--- trunk/Src/wptKeyEditCB.cpp	2006-04-28 10:28:06 UTC (rev 206)
+++ trunk/Src/wptKeyEditCB.cpp	2006-04-28 10:28:24 UTC (rev 207)
@@ -653,9 +653,24 @@
 }
 
 
+static const char*
+cmd_minimize_handler (GpgKeyEdit *ctx, status_code_t code, const char *key)
+{
+    if (!strcmp (key, "keyedit.prompt") && !ctx->cmd_sent) {
+	ctx->cmd_sent = 1;
+	return "minimize";
+    }
+    if (!strcmp (key, "keyedit.prompt")) {
+	ctx->reset ();
+	return "save";
+    }
+
+    return NULL;
+}
+
 /* 'clean' command handler. */
 static const char*
-cmd_clean_handler (GpgKeyEdit *ctx, gpgme_status_code_t code, const char *key)
+cmd_clean_handler (GpgKeyEdit *ctx, status_code_t code, const char *key)
 {
     if (!strcmp (key, "keyedit.prompt") && !ctx->cmd_sent) {
 	ctx->cmd_sent = 1;
@@ -793,6 +808,10 @@
 	out = cmd_notation_handler (ke, code, key);
 	break;
 
+    case GPG_EDITKEY_MINIMIZE:
+	out = cmd_minimize_handler (ke, code, key);
+	break;
+
     case GPG_EDITKEY_CLEAN:
 	out = cmd_clean_handler (ke, code, key);
 	break;

Modified: trunk/Src/wptKeyEditDlgs.cpp
===================================================================
--- trunk/Src/wptKeyEditDlgs.cpp	2006-04-28 10:28:06 UTC (rev 206)
+++ trunk/Src/wptKeyEditDlgs.cpp	2006-04-28 10:28:24 UTC (rev 207)
@@ -1178,7 +1178,8 @@
     listview_ctrl_t lv = NULL;
     gpgme_key_t key;
     gpgme_key_sig_t ks;
-    gpgme_user_id_t u;
+    gpgme_user_id_t u2;
+    struct native_uid_s *u;
     int nuids = 0, rc, j, u_attr;
     struct listview_column_s cols[] = {
         {0,  72, (char *)_("Validity")},
@@ -1213,7 +1214,8 @@
     }
 
     listview_set_ext_style (lv);
-    for (j = 0, u=key->uids; j < nuids; u=u->next, j++) {
+    for (j = 0, u2 = key->uids, u=k->ext->uids; j < nuids; 
+	 u2=u2->next, u=u->next, j++) {
 	if (u->revoked)
 	    attr = _("Revoked");
 	else {
@@ -1227,7 +1229,7 @@
 	if (u->email)
 	    listview_add_sub_item (lv, j, 2, u->email);
 
-	ks = get_selfsig (u, k->keyid, 1);
+	ks = get_selfsig (u2, k->keyid, 1);
 	if (ks)
 	    listview_add_sub_item (lv, j, 3, get_key_created (ks->timestamp));
     }

Modified: trunk/Src/wptKeyManager.cpp
===================================================================
--- trunk/Src/wptKeyManager.cpp	2006-04-28 10:28:06 UTC (rev 206)
+++ trunk/Src/wptKeyManager.cpp	2006-04-28 10:28:24 UTC (rev 207)
@@ -78,23 +78,23 @@
 
 /* Return a general description of the key @key. */
 char*
-km_key_get_info (gpgme_key_t pk, int is_sec)
+km_key_get_info (winpt_key_t key, int is_sec)
 {
+    gpgme_key_t pk;
     const char *fmt = "%s %04d%s/0x%s %s\n  \"%s\"";
-    char *p, *uid;
+    char *p;
     int n;
 
+    pk = key->ctx;
     n = strlen (fmt) + 8 + 2 + 16 + 12 + strlen (pk->uids->uid) + 32;
     p = new char[n+1];
     if (!p)
 	BUG (NULL);
-    uid = utf8_to_native (pk->uids->uid);
     _snprintf (p, n, fmt, is_sec? "sec" : "pub",
 	       pk->subkeys->length,
 	       get_key_pubalgo2 (pk->subkeys->pubkey_algo),
 	       pk->subkeys->keyid+8, get_key_created (pk->subkeys->timestamp),
-	       uid);
-    safe_free (uid);
+	       key->ext->uids->uid);
     return p;
 }
 
@@ -674,7 +674,7 @@
     gpgme_error_t err;
     gpgme_ctx_t ctx;
     gpgme_key_t *rset;
-    gpgme_key_t key;
+    winpt_key_s key2;
     char *p;
     int with_seckey=0, seckey_type=0, confirm=0;
     int i, rc, n, k_pos=0;
@@ -701,21 +701,25 @@
     rset = (gpgme_key_t *)calloc (i+1, sizeof (gpgme_key_t));
     if (!rset)
 	BUG (NULL);
+    memset (&key2, 0, sizeof (key2));
     for (i = 0; i < n; i++) {
-        if (listview_get_item_state(lv, i)) {
-	    key = km_get_key_ptr (lv, i, NULL);
+	
+
+        if (listview_get_item_state(lv, i)) {	    
+	    key2.ctx = km_get_key_ptr (lv, i, &key2.ext);
+
 	    seckey_type = km_check_for_seckey (lv, i, NULL);
             if (confirm && !seckey_type) {
-		p = km_key_get_info (key, 0);
+		p = km_key_get_info (&key2, 0);
 		rc = log_box (_("Key Manager"), MB_YESNO|MB_ICONWARNING,
                               _("Do you really want to delete this key?\n\n"
 			        "%s"), p);
                 if (rc == IDYES)
-		    rset[k_pos++] = key;
+		    rset[k_pos++] = key2.ctx;
 		free_if_alloc (p);
             }
             else if (confirm) {
-		p = km_key_get_info (key, 1);
+		p = km_key_get_info (&key2, 1);
 		rc = log_box (_("Key Manager"), MB_YESNO|MB_ICONWARNING,                
                               _("Do you really want to delete this KEY PAIR?\n\n"
 				"Please remember that you are not able to decrypt\n"
@@ -728,14 +732,14 @@
 					"Only the public key and the secret key \n"
 					"placeholder will be deleted.\n"), 
 					_("Key Manager"), MB_OK);
-		    rset[k_pos++] = key;
+		    rset[k_pos++] = key2.ctx;
 		}
                 with_seckey = 1;
 		free_if_alloc (p);
             }
 	    else {
 		with_seckey = 1;
-		rset[k_pos++] = key;
+		rset[k_pos++] = key2.ctx;
 	    }
         }
     }
@@ -1011,11 +1015,12 @@
 int
 km_get_key (listview_ctrl_t lv, int pos, winpt_key_t k)
 {
+    struct keycache_s *c;
     gpgme_key_t key;
 
     if (pos == -1)
 	return -1;
-    key = km_get_key_ptr (lv, pos, NULL);
+    key = km_get_key_ptr (lv, pos, &c);
     memset (k, 0, sizeof (*k));
     strncpy (k->tmp_keyid, key->subkeys->keyid+8, 8);
     k->keyid = k->tmp_keyid;
@@ -1024,7 +1029,8 @@
     k->is_v3 = km_key_is_v3 (lv, pos);
     k->flags = km_get_key_status (lv, pos);
     k->ctx = key;
-    k->uid = key->uids->uid;
+    k->ext = c;
+    k->uid = c->uids->uid;
     return 0;
 }
 

Modified: trunk/Src/wptKeyManagerDlg.cpp
===================================================================
--- trunk/Src/wptKeyManagerDlg.cpp	2006-04-28 10:28:06 UTC (rev 206)
+++ trunk/Src/wptKeyManagerDlg.cpp	2006-04-28 10:28:24 UTC (rev 207)
@@ -63,6 +63,7 @@
 
 static subclass_s keylist_proc;
 
+/* Handle to the global image list. */
 HIMAGELIST glob_imagelist;
 
 struct km_info_s {
@@ -71,6 +72,7 @@
     int ypos_sep;
     int ypercent_sep;
 
+    /* Different kind of windows. */
     HWND dlg;
     HWND hwnd_sep;
     HWND toolbar;
@@ -208,12 +210,12 @@
 /* Restore the width of the columns from the registry.
    If no bitstring was found, the default size is used. */
 int
-restore_column_info (listview_ctrl_t hd)
+restore_column_info (struct km_info_s *kmi)
 {
     WORD *buf;
     HKEY root;
     DWORD type;
-    DWORD size = hd->cols*sizeof (WORD), i;
+    DWORD size = kmi->lv->cols*sizeof (WORD), i;
     LONG ec;
 
     ec = RegOpenKeyEx (HKEY_CURRENT_USER, "Software\\WinPT", 0,
@@ -225,9 +227,9 @@
     if (!buf)
 	BUG (NULL);
     ec = RegQueryValueEx (root, "KMColumnSize", NULL, &type, 
-			  (BYTE*)buf, &size);
-    RegCloseKey (root);
+			  (BYTE*)buf, &size);    
     if (ec != ERROR_SUCCESS) {
+	RegCloseKey (root);
 	free_if_alloc (buf);
 	return -1;
     }
@@ -240,30 +242,37 @@
 	}
     }
     for (i=0; i < size/2; i++)
-	listview_set_column_width (hd, i, buf[i]);
+	listview_set_column_width (kmi->lv, i, buf[i]);
     free_if_alloc (buf);
+
+    size = sizeof (kmi->keylist_sortby);
+    ec = RegQueryValueEx (root, "KMSortBy", NULL, &type,
+			  (BYTE*)&kmi->keylist_sortby, &size);
+    if (ec != ERROR_SUCCESS)
+	kmi->keylist_sortby = KEY_SORT_USERID;
+    RegCloseKey (root);
     return 0;
 }
 
 
 /* Save the current column width to the registry. */
 int
-save_column_info (listview_ctrl_t hd)
-{
+save_column_info (struct km_info_s *kmi)
+{    
+    HKEY root;
     WORD *buf;
-    HKEY root;
     LONG ec;
     int i;
 
-    buf = new WORD[hd->cols];
+    buf = new WORD[kmi->lv->cols];
     if (!buf)
 	BUG (NULL);
-    for (i=0; i < hd->cols; i++) {
+    for (i=0; i < kmi->lv->cols; i++) {
 	LVCOLUMN lvc;
 
 	memset (&lvc, 0, sizeof (lvc));
 	lvc.mask = LVCF_WIDTH;
-	ListView_GetColumn (hd->ctrl, i, &lvc);
+	ListView_GetColumn (kmi->lv->ctrl, i, &lvc);
 	buf[i] = lvc.cx;
     }
 
@@ -275,7 +284,12 @@
     }
 
     ec = RegSetValueEx (root, "KMColumnSize", 0, REG_BINARY,
-			(const BYTE*)buf, 2*hd->cols);
+			(const BYTE*)buf, 2*kmi->lv->cols);
+    if (ec == ERROR_SUCCESS) {
+	ec = RegSetValueEx (root, "KMSortBy", 0, REG_DWORD_BIG_ENDIAN,
+			    (const BYTE*)&kmi->keylist_sortby, 
+			    sizeof (kmi->keylist_sortby));
+    }
     RegCloseKey (root);
     free_if_alloc (buf);
     return ec == ERROR_SUCCESS? 0 : -1;
@@ -1196,7 +1210,8 @@
 	do_center_window (dlg, kmi);
         do_resize_window (dlg, kmi);
         update_ui_items (dlg, kmi->lv);
-	restore_column_info (kmi->lv);
+	restore_column_info (kmi);
+	keylist_sort (kmi->lv, kmi->keylist_sortby);
 
 	SetDlgItemText (dlg, IDC_KEYMISC_GTEXT, _("Groups"));
 	SetClassLong (dlg, GCL_HICON, (LONG)LoadIcon (glob_hinst, 
@@ -1206,7 +1221,7 @@
         return TRUE;
         
     case WM_DESTROY:
-	save_column_info (kmi->lv);
+	save_column_info (kmi);
 	if (kmi->lv) {
             keylist_delete (kmi->lv);
             kmi->lv = NULL;       

Modified: trunk/Src/wptKeylist.cpp
===================================================================
--- trunk/Src/wptKeylist.cpp	2006-04-28 10:28:06 UTC (rev 206)
+++ trunk/Src/wptKeylist.cpp	2006-04-28 10:28:24 UTC (rev 207)
@@ -176,7 +176,6 @@
 }
 
 
-
 const char*
 get_key_algo (gpgme_key_t key, int keyidx)
 {
@@ -195,9 +194,18 @@
     strcpy (alg, get_key_pubalgo (key->subkeys->pubkey_algo));
     n = count_subkeys (key);
     if (n > 1) {
-	k = get_nth_key (key, n-1);
+	do {
+	    k = get_nth_key (key, --n);
+	    if (k->revoked || k->expired)
+		continue;
+	    else
+		break;
+	} while (n > 0);
 	subalg = get_key_pubalgo (k->pubkey_algo);
-	_snprintf (algo_id, DIM (algo_id)-1, "%s/%s", alg, subalg);
+	if (k == key->subkeys)
+	    _snprintf (algo_id, DIM (algo_id)-1, "%s", subalg);
+	else
+	    _snprintf (algo_id, DIM (algo_id)-1, "%s/%s", alg, subalg);
 	return algo_id;
     }
     return get_key_pubalgo (key->subkeys->pubkey_algo);

Modified: trunk/Src/wptKeysigDlg.cpp
===================================================================
--- trunk/Src/wptKeysigDlg.cpp	2006-04-28 10:28:06 UTC (rev 206)
+++ trunk/Src/wptKeysigDlg.cpp	2006-04-28 10:28:24 UTC (rev 207)
@@ -116,7 +116,7 @@
 BOOL CALLBACK
 sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
 {
-    static gpgme_key_sig_t ks;
+    gpgme_key_sig_t ks;
     gpgme_key_t issuer;
     char tmpbuf[256];
     struct {
@@ -146,6 +146,7 @@
 	SetDlgItemText (dlg, IDC_SIGPROPS_EXPSTR, _("Expire date"));
 	SetDlgItemText (dlg, IDC_SIGPROPS_KEYINF, _("Issuer key"));
 	SetDlgItemText (dlg, IDC_SIGPROPS_KEYIDINF, _("Issuer key ID"));
+	SetDlgItemText (dlg, IDC_SIGPROPS_POLICINF, _("Policy URL"));
 	ks = (gpgme_key_sig_t)lparam;
 	if (!ks)
 	    BUG (0);
@@ -203,6 +204,10 @@
 	    if (ctx.expired)
 		CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED);
 	}
+	/* XXX: gpgme does not support cert policy URLs yet. */
+	if (ks->notations && !ks->notations->name && ks->notations->value)
+	    SetDlgItemText (dlg, IDC_SIGPROPS_POLIC, ks->notations->value);
+
 	SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable"));
 	SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably"));
 	SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));

Modified: trunk/Src/wptListView.cpp
===================================================================
--- trunk/Src/wptListView.cpp	2006-04-28 10:28:06 UTC (rev 206)
+++ trunk/Src/wptListView.cpp	2006-04-28 10:28:24 UTC (rev 207)
@@ -419,11 +419,12 @@
 
 
 int
-listview_find (listview_ctrl_t ctx, const char * str)
+listview_find (listview_ctrl_t ctx, const char *str)
 {
     LVFINDINFO inf;
     int pos;
 
+    /* XXX: allow to make a substring search. */
     memset (&inf, 0, sizeof (inf));
     inf.flags = LVFI_STRING|LVFI_PARTIAL;
     inf.psz = str;

Modified: trunk/Src/wptMAPI.cpp
===================================================================
--- trunk/Src/wptMAPI.cpp	2006-04-28 10:28:06 UTC (rev 206)
+++ trunk/Src/wptMAPI.cpp	2006-04-28 10:28:24 UTC (rev 207)
@@ -153,12 +153,13 @@
 
 /* Same as mapi_send_pubkey but there is an additional note. */
 int
-mapi_send_pubkey_ext (gpgme_key_t to, const char *keyfile, int flags)
+mapi_send_pubkey_ext (winpt_key_t key, const char *keyfile, int flags)
 {
     LHANDLE hd;
     MapiMessage *msg;
     MapiRecipDesc *recip;
     MapiFileDesc *attch;
+    gpgme_key_t to = key->ctx;
     char *p, *kinf;
     const char *s;
     int rc;
@@ -185,7 +186,7 @@
         "to verify its signatures.\n"
         "\n"
         "If you don't have WinPT, you can download it at http://www.winpt.org";
-    kinf = km_key_get_info (to, 0);
+    kinf = km_key_get_info (key, 0);
     p = (char*)malloc (strlen (s) + strlen (kinf) + 2);
     sprintf (p, s, kinf);
     free_if_alloc (kinf);
@@ -238,8 +239,10 @@
 int
 mapi_send_pubkey (const char *keyid, char *keyfile)
 {
-    gpgme_key_t key;
+    winpt_key_s key;
 
-    get_pubkey (keyid, &key);
-    return mapi_send_pubkey_ext (key, keyfile, 0);
+    memset (&key, 0, sizeof (key));
+    if (winpt_get_pubkey (keyid, &key))
+	return -1;
+    return mapi_send_pubkey_ext (&key, keyfile, 0);
 }



More information about the Winpt-commits mailing list