[Winpt-commits] r204 - in trunk: Include Src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Apr 26 08:37:26 CEST 2006


Author: twoaday
Date: 2006-04-26 08:37:23 +0200 (Wed, 26 Apr 2006)
New Revision: 204

Modified:
   trunk/Include/wptW32API.h
   trunk/Src/ChangeLog
   trunk/Src/wptFileManagerDlg.cpp
   trunk/Src/wptImportList.cpp
   trunk/Src/wptKeyEditDlgs.cpp
   trunk/Src/wptKeyRevokeDlg.cpp
   trunk/Src/wptKeyRevokersDlg.cpp
   trunk/Src/wptKeygenDlg.cpp
   trunk/Src/wptKeylist.cpp
   trunk/Src/wptKeysigDlg.cpp
   trunk/Src/wptKeysignDlg.cpp
   trunk/Src/wptListView.cpp
   trunk/Src/wptMDSumDlg.cpp
   trunk/Src/wptPassphraseCB.cpp
   trunk/Src/wptSigList.cpp
   trunk/Src/wptSigTreeDlg.cpp
   trunk/Src/wptVerifyList.cpp
   trunk/Src/wptW32API.cpp
Log:
2006-04-25  Timo Schulz  <ts at g10code.de>
                                                                                
        * wptFileManagerDlg.cpp (file_manager_dlg_proc): Handle IDCANCEL.
        * wptMDSumDlg.cpp (hash_selected_files): New.
        (mdsum_dlg_proc): Cleanups.
        * wptKeysignDlg.cpp (keysign_dlg_proc): Fix segv.
                                                                                
2006-04-23  Timo Schulz  <ts at g10code.de>
                                                                                
        * wptW32API.cpp (SetDlgItemText_utf8): New.
        (SetWindowText_utf8): New.
        (GetDlgItemText_utf8): New.
        * wptListView.cpp (listview_add_sub_item): Internal
        utf8 support.



Modified: trunk/Include/wptW32API.h
===================================================================
--- trunk/Include/wptW32API.h	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Include/wptW32API.h	2006-04-26 06:37:23 UTC (rev 204)
@@ -83,6 +83,10 @@
 const char* get_locale_date (long tm_t, char *buf, DWORD buflen);
 int get_temp_name (char *buf, DWORD buflen, const char *name);
 
+void SetWindowText_utf8 (HWND hwnd, const char *txt);
+void SetDlgItemText_utf8 (HWND dlg, int id, const char *txt);
+int GetDlgItemText_utf8 (HWND dlg, int id, char **r_txt);
+
 #define listbox_add_string(lb, string) \
     SendMessage( (lb), LB_ADDSTRING, 0, (LPARAM)(LPCSTR)(string) )
 

Modified: trunk/Src/ChangeLog
===================================================================
--- trunk/Src/ChangeLog	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Src/ChangeLog	2006-04-26 06:37:23 UTC (rev 204)
@@ -1,3 +1,18 @@
+2006-04-25  Timo Schulz  <ts at g10code.de>
+
+	* wptFileManagerDlg.cpp (file_manager_dlg_proc): Handle IDCANCEL.
+	* wptMDSumDlg.cpp (hash_selected_files): New.
+	(mdsum_dlg_proc): Cleanups.
+	* wptKeysignDlg.cpp (keysign_dlg_proc): Fix segv.
+	
+2006-04-23  Timo Schulz  <ts at g10code.de>
+
+	* wptW32API.cpp (SetDlgItemText_utf8): New.
+	(SetWindowText_utf8): New.
+	(GetDlgItemText_utf8): New.
+	* wptListView.cpp (listview_add_sub_item): Internal
+	utf8 support.
+	
 2006-04-22  Timo Schulz  <ts at g10code.de>
 
 	* wptKeyEditDlgs.cpp (addrevoker_dlg_proc): Encode

Modified: trunk/Src/wptFileManagerDlg.cpp
===================================================================
--- trunk/Src/wptFileManagerDlg.cpp	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Src/wptFileManagerDlg.cpp	2006-04-26 06:37:23 UTC (rev 204)
@@ -608,7 +608,11 @@
 	return FALSE;
 
     case WM_COMMAND:
-        switch( LOWORD( wparam ) ) {        
+        switch (LOWORD (wparam)) {
+	case IDCANCEL:
+	    EndDialog (dlg, FALSE);
+	    return TRUE;
+
         case ID_FILEMISC_QUIT:
             EndDialog (dlg, TRUE);
             return TRUE;

Modified: trunk/Src/wptImportList.cpp
===================================================================
--- trunk/Src/wptImportList.cpp	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Src/wptImportList.cpp	2006-04-26 06:37:23 UTC (rev 204)
@@ -22,10 +22,9 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
-
+#include <ctype.h>
 #include <windows.h>
 #include <sys/types.h>
-#include <ctype.h>
 
 #include "wptTypes.h"
 #include "wptGPG.h"
@@ -145,7 +144,7 @@
 	case 1:
 	    if (rectype != KEY_primary)
 		break;
-	    for (s = pend; *s && !isdigit ((unsigned int)*s); s++) {
+	    for (s = pend; *s && !isdigit (*s); s++) {
 		switch (*s) {
 		case 'd': c->disabled = 1;break;
 		case 'e': c->expired = 1; break;
@@ -289,7 +288,6 @@
 static int
 implist_add_key (listview_ctrl_t lv, int pos, import_key_t key)
 {	
-    char *uid = NULL;
     char buf[128], * desc;
     const char *t;
     u32 tt, tt2=0;
@@ -297,17 +295,9 @@
     if (listview_add_item( lv, " " ))
 	return WPTERR_GENERAL;
     t = key->uid;
-    if (!t || strlen (t) < 5) {
+    if (!t || strlen (t) < 5)
 	t = _("Invalid user ID");
-	listview_add_sub_item (lv, pos, IMPL_COL_UID, t);
-    }
-    else {
-	uid = utf8_to_native (t);
-	if (uid) {
-	    listview_add_sub_item (lv, pos, IMPL_COL_UID, uid);
-	    safe_free (uid);
-	}
-    }
+    listview_add_sub_item (lv, pos, IMPL_COL_UID, t);
 
     tt = key->length;
     if (key->subkey_length > 0)
@@ -440,7 +430,7 @@
     }
 
     err = gpgme_data_new_from_mem (&list, out, strlen (out), 1);
-    safe_free (out);
+    free (out);
     if (err) {
 	msg_box (NULL, gpgme_strerror (err), _("Import"), MB_ERR);
 	if (is_tmp) 

Modified: trunk/Src/wptKeyEditDlgs.cpp
===================================================================
--- trunk/Src/wptKeyEditDlgs.cpp	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Src/wptKeyEditDlgs.cpp	2006-04-26 06:37:23 UTC (rev 204)
@@ -150,6 +150,7 @@
 void get_userid_preflist (char **r_prefs, int * r_flags);
 char* get_subkey_keyid (const char *keyid);
 
+void ComboBox_AddString_utf8 (HWND cb, const char *txt);
 
 static GpgKeyEdit*
 create_GpgKeyEdit (const char *keyid)
@@ -171,7 +172,6 @@
     gpg_keycache_t pub;
     gpgme_key_t key;
     const char *s, *kid;
-    char *u;
     int i, n;
 
     pub = keycache_get_ctx (1);
@@ -187,10 +187,7 @@
 	kid = key->subkeys->keyid;
 	if (!s || !strcmp (kid+8, keyid))
 	    continue;
-	u = utf8_to_native (s);
-	SendDlgItemMessage (dlg, IDC_ADDREV_KEYLIST, CB_ADDSTRING, 
-			    0, (WPARAM)(char *)u);
-	free (u);
+	ComboBox_AddString_utf8 (GetDlgItem (dlg, IDC_ADDREV_KEYLIST), s);
     }
     gpg_keycache_rewind (pub);
     n = SendDlgItemMessage( dlg, IDC_ADDREV_KEYLIST, CB_GETCOUNT, 0, 0 );
@@ -209,26 +206,20 @@
 		   const char *utf8_name, const char *email, 
 		   const char *utf8_comment)
 {
-    char *p, *uid, *com;
+    char *p;
     size_t n;
     
     n = strlen (utf8_name) + strlen (email) + 16;
     if (utf8_comment)
 	n += strlen (utf8_comment);
-    uid = utf8_to_native (utf8_name);    
     p = new char[n+1];
     if (!p)
 	BUG (NULL);
     if (utf8_comment) {
-	com = utf8_to_native (utf8_comment);
-	if (!com)
-	    BUG (NULL);
-	sprintf (p, "%s (%s)", uid, com);
-	free_if_alloc (com);
+	sprintf (p, "%s (%s)", utf8_name, utf8_comment);
     }
     else
-	sprintf (p, "%s", uid);
-    free (uid);
+	sprintf (p, "%s", utf8_name);
 
     listview_add_item (lv, "");
     listview_add_sub_item (lv, 0, 0, _("Ultimate" ));
@@ -440,7 +431,7 @@
     static keyedit_cb_t cb;
     gpgme_error_t err;
     GpgKeyEdit *ke;
-    char uid[128], *utf8_uid;
+    char *uid=NULL;
 
     switch (msg) {
     case WM_INITDIALOG:
@@ -467,20 +458,20 @@
 
     case WM_COMMAND:
 	switch (LOWORD (wparam)) {
-	case IDOK:	    
-	    if( !GetDlgItemText( dlg, IDC_ADDREV_KEYLIST, uid, sizeof uid-1 ) ) {
-		msg_box( dlg, _("Please select a user ID."), _("Add Revoker"), MB_ERR );
+	case IDOK:
+	    if (!GetDlgItemText_utf8 (dlg, IDC_ADDREV_KEYLIST, &uid)) {
+		msg_box (dlg, _("Please select a user ID."), _("Add Revoker"), MB_ERR);
 		return FALSE;
 	    }
-	    utf8_uid = native_to_utf8 (uid);
+	
 	    ke = create_GpgKeyEdit (cb->keyid);
 	    if (cb->pass)
 		ke->setPassphrase (cb->pass);
 	    else
 		ke->setNoPassphrase (true);
-	    err = ke->addDesignatedRevoker (utf8_uid);
-	    free_if_alloc (utf8_uid);
+	    err = ke->addDesignatedRevoker (uid);
 	    delete ke;
+	    safe_free (uid);
 	    if (err) {
 		msg_box (dlg, gpgme_strerror (err), _("Add Revoker"), MB_ERR);
 		return TRUE;
@@ -513,7 +504,7 @@
     GpgKeyEdit *ke;
     char *utf8_name = NULL;
     char *utf8_comment = NULL;
-    char name[128], email[128], comment[128];
+    char email[128];
     int rc;
     
     switch (msg) {
@@ -538,17 +529,20 @@
         switch ( LOWORD( wparam ) )  {
         case IDOK:
 	    keygen = (keygen_cb_t)ctx->opaque;
-            rc = GetDlgItemText (dlg, IDC_ADDUID_NAME, name, sizeof name-1);
+            rc = GetDlgItemText_utf8 (dlg, IDC_ADDUID_NAME, &utf8_name);
             if (!rc || rc < 5) {
-                msg_box( dlg, _("Please enter a name (min. 5 chars.)"), _("UserID"), MB_ERR );
+                msg_box (dlg, _("Please enter a name (min. 5 chars.)"), 
+			 _("UserID"), MB_ERR);
+		free_if_alloc (utf8_name);
                 return FALSE;
             }
-	    if (strchr (name, '@')) {
-		msg_box( dlg, _("Please enter the email address in the email field and not in the name field"), _("UserID"), MB_INFO );
+	    if (strchr (utf8_name, '@')) {
+		msg_box (dlg, _("Please enter the email address in the email field and not in the name field"), 
+			 _("UserID"), MB_INFO);
 		return FALSE;
 	    }
-	                           
-            if( !GetDlgItemText( dlg, IDC_ADDUID_EMAIL, email, sizeof email -1 ) ) {
+
+            if( !GetDlgItemText (dlg, IDC_ADDUID_EMAIL, email, sizeof (email) -1)) {
                 msg_box( dlg, _("Please enter an email address."), _("UserID"), MB_ERR );
                 return FALSE;
             }
@@ -557,11 +551,7 @@
 		return FALSE;
 	    }
             
-            rc = GetDlgItemText (dlg, IDC_ADDUID_COMMENT, 
-				 comment, sizeof comment -1);
-	    if (rc > 0)
-		utf8_comment = native_to_utf8 (comment);
-	    utf8_name = native_to_utf8 (name);	    
+            rc = GetDlgItemText_utf8 (dlg, IDC_ADDUID_COMMENT, &utf8_comment);
 
 	    ke = create_GpgKeyEdit (ctx->keyid);
 	    if (ctx->is_protected)
@@ -1234,22 +1224,12 @@
 	    u_attr = (int)u->validity;
 	    attr = get_key_trust2 (NULL, u_attr, 0, 0);
 	}
-	listview_add_sub_item( lv, j, 0, (char *)attr );	
-
+	listview_add_sub_item (lv, j, 0, (char *)attr);
 	/* XXX: add comment if available */
-	attr = u->name;
-	if (attr) {
-	    char *uid = utf8_to_native (attr);
-	    if (uid) {
-		listview_add_sub_item (lv, j, 1, uid);
-		free (uid);
-	    }
-	}
-	else
-	    listview_add_sub_item (lv, j, 1, _("Invalid user ID"));
-	attr = u->email;
-	if (attr)
-	    listview_add_sub_item (lv, j, 2, attr);
+	listview_add_sub_item (lv, j, 1, 
+			       u->name? u->name : _("Invalid user ID"));
+	if (u->email)
+	    listview_add_sub_item (lv, j, 2, u->email);
 
 	ks = get_selfsig (u, k->keyid, 1);
 	if (ks)

Modified: trunk/Src/wptKeyRevokeDlg.cpp
===================================================================
--- trunk/Src/wptKeyRevokeDlg.cpp	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Src/wptKeyRevokeDlg.cpp	2006-04-26 06:37:23 UTC (rev 204)
@@ -104,9 +104,9 @@
     gpgme_error_t err;
     HWND list;
     int idx, use_desc;
-    char desc[256], file[256];
+    char file[256];
     char pwd[256];
-    char *p = NULL;
+    char *desc=NULL;
     char *inp_data = NULL, *revcert=NULL;
     const char *warning =
 	_("Please move this certificate to a medium where it can be"
@@ -151,7 +151,7 @@
                 return TRUE;
             }
             use_desc = 1;
-            if (!GetDlgItemText (dlg, IDC_KEYREVOKE_TEXT, desc, sizeof (desc)-1))
+            if (!GetDlgItemText_utf8 (dlg, IDC_KEYREVOKE_TEXT, &desc))
                 use_desc = 0;
             if (!GetDlgItemText (dlg, IDC_KEYREVOKE_PWD, pwd, sizeof (pwd)-1)) {
 		msg_box (dlg, _("Please enter the passphrase."), 
@@ -159,9 +159,7 @@
                 return TRUE;
             }
           
-	    p = use_desc? native_to_utf8 (desc) : NULL;
-	    inp_data = generate_revoke_input (idx, p, pwd);
-
+	    inp_data = generate_revoke_input (idx, desc, pwd);
             err = gpg_revoke_cert (inp_data, k->keyid, &revcert);
 	    wipememory (pwd, sizeof (pwd));
 	    wipememory (inp_data, strlen (inp_data));
@@ -175,7 +173,7 @@
 		release_cert_as_file (revcert, file);
 	    }
 	    safe_free (inp_data);
-	    free_if_alloc (p);
+	    free_if_alloc (desc);
 	    EndDialog (dlg, TRUE);
             return TRUE;
             

Modified: trunk/Src/wptKeyRevokersDlg.cpp
===================================================================
--- trunk/Src/wptKeyRevokersDlg.cpp	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Src/wptKeyRevokersDlg.cpp	2006-04-26 06:37:23 UTC (rev 204)
@@ -87,7 +87,7 @@
     gpg_desig_rev_t rev=NULL, r;
     listview_ctrl_t lv;
     const char *alg;
-    char *uid = NULL;
+    const char *uid = NULL;
     char keyid[32];
 
     ke = new GpgKeyEdit (key);
@@ -105,16 +105,15 @@
 	BUG (0);
     for (r = rev; r; r = r->next) {
 	if (get_pubkey (r->fpr+32, &revkey))
-	    uid = strdup (_("user ID not found"));
+	    uid = _("user ID not found");
 	else
-	    uid = utf8_to_native (revkey->uids->name);
+	    uid = revkey->uids->name;
 	_snprintf (keyid, sizeof (keyid)-1, "0x%s", r->fpr+32);
 	listview_add_item (lv, "");
 	alg = get_key_pubalgo (r->pubkey_algo);
 	listview_add_sub_item (lv, 0, REV_COL_ALGO, alg);
 	listview_add_sub_item (lv, 0, REV_COL_KEYID, keyid);
 	listview_add_sub_item (lv, 0, REV_COL_NAME, uid);
-	safe_free (uid);
     }
 
     delete ke;
@@ -169,11 +168,8 @@
 		    key_update = 1;
 		    if (get_pubkey (keyid, &key))
 			BUG (NULL);
-		    if (key->uids && key->uids->name) {
-			char *uid = utf8_to_native (key->uids->name);
-			listview_add_sub_item (lv, idx, REV_COL_NAME, uid);
-			free (uid);
-		    }
+		    if (key->uids && key->uids->name)			
+			listview_add_sub_item (lv, idx, REV_COL_NAME, key->uids->name);
 		}
 	    }
 	    else {

Modified: trunk/Src/wptKeygenDlg.cpp
===================================================================
--- trunk/Src/wptKeygenDlg.cpp	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Src/wptKeygenDlg.cpp	2006-04-26 06:37:23 UTC (rev 204)
@@ -33,8 +33,8 @@
 #include "wptW32API.h"
 #include "wptVersion.h"
 #include "wptErrors.h"
-#include "wptUTF8.h"
 
+
 /* All valid key generation combination. */
 enum gpg_keytype_t {
     GPG_KEYGEN_NONE    = 0,
@@ -92,7 +92,7 @@
 	"Key-Usage: %s\n"	
 	"Name-Real: %s\n"	
 	"Name-Comment: %s\n"
-        "Name-Email: %s\n"
+	"Name-Email: %s\n"
 	"Expire-Date: %s\n"
 	"Passphrase: %s\n"
 	"</GnupgKeyParms>\n";
@@ -354,7 +354,8 @@
     static genkey_s *ctx;
     SYSTEMTIME st;
     gpgme_error_t err;
-    char name[128] = {0}, email[128] = {0}, comment[128] = {0};
+    char *utf8_name =NULL, *utf8_comment = NULL;
+    char email[128];
     char *pwd;
     char t[64], *expire = NULL, *fpr=NULL;
     int bits, use_comment, keytype = 0;
@@ -413,26 +414,30 @@
                 if (id == IDNO)
                     bits = DFAULT_KEYSIZE;
             }
-            if (!GetDlgItemText (dlg, IDC_KEYGEN_NAME, name, sizeof (name) - 1)) {
-                msg_box( dlg, _("Please enter the name."), _("Key Generation"), MB_ERR);
+            if (!GetDlgItemText_utf8 (dlg, IDC_KEYGEN_NAME, &utf8_name)) {
+                msg_box (dlg, _("Please enter the name."), _("Key Generation"), MB_ERR);
                 return FALSE;
             }
-	    if (strchr (name, '@')) {
+	    if (strchr (utf8_name, '@')) {
 		msg_box (dlg, _("Please do not enter the email address in the name field."),
 			 _("Key Generation"), MB_INFO);
+		free_if_alloc (utf8_name);
 		return FALSE;
 	    }
             if (!GetDlgItemText (dlg, IDC_KEYGEN_EMAIL, email, sizeof (email) -1)
                 || check_email_address (email)) {
                 msg_box (dlg, _("Please enter a valid email address."),
 			 _("Key Generation"), MB_ERR);
+		free_if_alloc (utf8_name);
                 return FALSE;
             }
-            use_comment = GetDlgItemText(dlg, IDC_KEYGEN_COMMENT, 
-					 comment, sizeof (comment) -1);
-	    if (use_comment > 0 && strchr (comment, '@')) {
+            use_comment = GetDlgItemText_utf8 (dlg, IDC_KEYGEN_COMMENT, 
+					       &utf8_comment);
+	    if (use_comment > 0 && strchr (utf8_comment, '@')) {
 		msg_box (dlg, _("Please do NOT enter the email address in the comment field."),
 			 _("Key Generation"), MB_INFO);
+		free_if_alloc (utf8_name);
+		free_if_alloc (utf8_comment);
 		return FALSE;
 	    }
             keytype = SendDlgItemMessage (dlg, IDC_KEYGEN_KEYTYPE, CB_GETCURSEL, 0, 0) + 1;
@@ -447,34 +452,26 @@
             pwd = request_passphrase2 (_("Key Generation"), PASSDLG_STRICT, &cancel);
 	    if (cancel) {
 		sfree_if_alloc (pwd);
+		free_if_alloc (utf8_name);
+		free_if_alloc (utf8_comment);
 		return FALSE;
 	    }
 	    if (!pwd) {
                 msg_box (dlg, _("Please enter the passphrase."), 
 			 _("Key Generation"), MB_ERR);
+		free_if_alloc (utf8_name);
+		free_if_alloc (utf8_comment);
                 return FALSE;
             }
 
-            if (!use_comment && !strlen (comment)) {
-                char *utf8_name;
-		utf8_name = native_to_utf8 (name);
-		if (!utf8_name)
-		    BUG (0);
+            if (!use_comment && !strlen (utf8_comment))
                 p = gpg_genkey_params (keytype, bits, utf8_name, NULL, 
 				       email, expire, pwd);
-                free_if_alloc (utf8_name);
-            }
-            else {
-                char *utf8_name, *utf8_comment;
-		utf8_name = native_to_utf8 (name);
-		utf8_comment = native_to_utf8 (comment);
-		if( !utf8_name || !utf8_comment )
-		    BUG (0);
+            else
                 p = gpg_genkey_params (keytype, bits, utf8_name, utf8_comment, 
 				       email, expire, pwd);
-                free_if_alloc (utf8_name);
-                free_if_alloc (utf8_comment);
-            }
+	    free_if_alloc (utf8_name);
+	    free_if_alloc (utf8_comment);
             keygen_cb_dlg_create ();
             err = gpg_genkey (p, keygen_cb, &fpr);
 	    sfree_if_alloc (pwd);
@@ -521,8 +518,8 @@
     static genkey_s *ctx;
     static int pubkey_algo = GPG_KEYGEN_DSA_ELG;
     gpgme_error_t err;
-    char name[128], email[128];
-    char * utf8_name, * p, *fpr=NULL;
+    char email[128];
+    char *utf8_name=NULL, * p, *fpr=NULL;
     char * pass = NULL;
     int cancel = 0;
     
@@ -546,11 +543,11 @@
 	break;
 
     case WM_SYSCOMMAND:
-	if( LOWORD( wparam ) == SC_CLOSE )
-	    EndDialog( dlg, FALSE );
+	if (LOWORD (wparam) == SC_CLOSE)
+	    EndDialog (dlg, FALSE);
 
     case WM_COMMAND:
-	switch( LOWORD( wparam ) ) {
+	switch (LOWORD( wparam)) {
 	case IDC_KEYWIZARD_EXPERT:
 	    DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYGEN, dlg,
 			    keygen_dlg_proc, 0);
@@ -558,33 +555,35 @@
 	    break;
 
 	case IDOK:
-	    if( !GetDlgItemText( dlg, IDC_KEYWIZARD_NAME, name, sizeof name-1 ) ) {
-		msg_box( dlg, _("Please enter the name."), 
-			 _("Key Generation Wizard"), MB_ERR );
+	    if (!GetDlgItemText_utf8 (dlg, IDC_KEYWIZARD_NAME, &utf8_name)) {
+		msg_box (dlg, _("Please enter the name."), 
+			 _("Key Generation Wizard"), MB_ERR);
 		return FALSE;
 	    }
-	    if (strchr (name, '@')) {
+	    if (strchr (utf8_name, '@')) {
 		msg_box (dlg, _("Please do not enter the email address in the name field."),
 			 _("Key Generation Wizard"), MB_WARN);
+		free_if_alloc (utf8_name);
 		return FALSE;
 	    }
 	    if (!GetDlgItemText(dlg, IDC_KEYWIZARD_EMAIL, email, sizeof email-1 )
 		|| check_email_address (email)) { 
 		msg_box (dlg, _("Please enter a valid email address."), 
 		         _("Key Generation Wizard"), MB_ERR);
+		free_if_alloc (utf8_name);
 		return FALSE;
 	    }
 	    if (strchr (email, '<') || strchr (email, '>')) {
 		msg_box (dlg, _("Please do not add '<' or '>' to the email address."),
 			 _("Key Generation Wizard"), MB_WARN);
+		free_if_alloc (utf8_name);
 		return FALSE;
 	    }
 	    pass = request_passphrase2 (_("Key Generation"), PASSDLG_STRICT, &cancel);
-	    if (cancel)
+	    if (cancel) {
+		free_if_alloc (utf8_name);
 		return FALSE;
-	    utf8_name = native_to_utf8 (name);
-	    if (!utf8_name)
-		BUG (0);
+	    }
 	    if (IsDlgButtonChecked (dlg, IDC_KEYWIZARD_USERSA))
 		pubkey_algo = GPG_KEYGEN_DSA_RSA;
 	    p = gpg_genkey_params (pubkey_algo, DFAULT_KEYSIZE, utf8_name, 
@@ -604,8 +603,7 @@
 		free_if_alloc (fpr);
                 return FALSE;
             }
-            status_box( dlg, _("Key Generation completed"), _("GnuPG Status") );
-            
+            status_box (dlg, _("Key Generation completed"), _("GnuPG Status"));
 	    keycache_update (0, fpr);
 	    keycache_update (1, fpr);
 	    free_if_alloc (fpr);

Modified: trunk/Src/wptKeylist.cpp
===================================================================
--- trunk/Src/wptKeylist.cpp	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Src/wptKeylist.cpp	2006-04-26 06:37:23 UTC (rev 204)
@@ -733,13 +733,8 @@
 	attr = _("Invalid User ID");
 	listview_add_sub_item (lv, 0, idx++, attr);
     }	
-    else {
-	char *uid = utf8_to_native (attr);
-	if (uid) {
-	    listview_add_sub_item (lv, 0, idx++, uid);
-	    free (uid);
-	}
-    }
+    else	
+	listview_add_sub_item (lv, 0, idx++, attr);
     k = get_nth_key (key, keyidx);
     if (k && k->keyid) {
 	_snprintf (fmt, sizeof fmt -1, "0x%s", k->keyid + 8);
@@ -838,18 +833,15 @@
 keylist_upd_key (listview_ctrl_t lv, int pos, gpgme_key_t key)
 {
     const char *s;
-    char *uid, *p;
+    char *p;
     char tmp[32];
 
     listview_set_item2 (lv, pos, (void *)key);
     /* the only mode we support is KYLIST_LIST in the Key Manager */
     
     s = key->uids->uid;
-    if (s) {
-	uid = utf8_to_native (s);
-	listview_add_sub_item (lv, pos, KM_COL_UID, uid);
-	free (uid);
-    }
+    if (s)
+	listview_add_sub_item (lv, pos, KM_COL_UID, s);
 
     s = key->subkeys->keyid;
     if (s) {

Modified: trunk/Src/wptKeysigDlg.cpp
===================================================================
--- trunk/Src/wptKeysigDlg.cpp	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Src/wptKeysigDlg.cpp	2006-04-26 06:37:23 UTC (rev 204)
@@ -128,6 +128,7 @@
 	int _class;
     } ctx;
     const char *fmt_templ = _("%s %s signature");
+    const char *s;
 
     switch (msg) {
     case WM_SYSCOMMAND:
@@ -168,13 +169,11 @@
 	SetDlgItemInt (dlg, IDC_SIGPROPS_CLASS, ctx._class, FALSE);
 	if (ctx.exportable)
 	    CheckDlgButton (dlg, IDC_SIGPROPS_EXP, BST_CHECKED);
-	if (!get_pubkey (ks->keyid+8, &issuer)) {
-	    char *uid = utf8_to_native (issuer->uids->uid);
-	    SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, uid);
-	    safe_free (uid);
-	}
+	if (!get_pubkey (ks->keyid+8, &issuer))
+	    s = issuer->uids->uid;
 	else
-	    SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, _("  user ID not found"));
+	    s = _("  user ID not found");
+	SetDlgItemText_utf8 (dlg, IDC_SIGPROPS_ISSUER, s);
 	if (ks->expires == 0) {
 	    ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE);
 	    ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE);
@@ -382,7 +381,7 @@
     static struct winpt_key_s *k;
     gpgme_key_sig_t ks;
     HWND sl;
-    char inf[384], *utf8_uid;
+    char inf[384];
     int idx = 0;    
     
     switch (msg) {
@@ -390,12 +389,9 @@
         k = (winpt_key_t) lparam;
 	if (!k)
 	    BUG (0);
-        if (k->uid) {
-	    utf8_uid = utf8_to_native (k->uid);
-            _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), utf8_uid);
-	    safe_free (utf8_uid);
-	}
-        SetWindowText (dlg, inf);
+        if (k->uid)
+            _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid);
+        SetWindowText_utf8 (dlg, inf);
         SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));
 	SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));
 

Modified: trunk/Src/wptKeysignDlg.cpp
===================================================================
--- trunk/Src/wptKeysignDlg.cpp	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Src/wptKeysignDlg.cpp	2006-04-26 06:37:23 UTC (rev 204)
@@ -258,8 +258,6 @@
             dlg_fatal_error (dlg, "could not get dialog param.");
         SetWindowText (dlg, _("Key Signing"));
         key = (winpt_key_t) lparam;
-        s = key->ctx->uids->uid;
-	uid = utf8_to_native (s);
         _snprintf (keymsg, sizeof keymsg -1,
                    _("pub %d/%s  created: %s    expires: %s\n\n"
                      "Primary key fingerprint: %s\n\n"
@@ -270,15 +268,15 @@
                    get_key_created (key->ctx->subkeys->timestamp),
 		   get_expire_date (key->ctx),
                    get_printable_fpr (key->ctx->subkeys->fpr),
-                   uid);
-        safe_free (uid);
+                   key->ctx->uids->uid);
 	s = key->ctx->subkeys->keyid;
 	if (do_fill_seckeylist (dlg, s)) {
 	    msg_box (dlg, _("No valid secret key found."), _("Key Signing"), MB_ERR);
 	    EndDialog (dlg, FALSE);
+	    break;
 	}
 	do_check_protection (dlg);
-        SetDlgItemText (dlg, IDC_KEYSIGN_INFOS, keymsg);
+        SetDlgItemText_utf8 (dlg, IDC_KEYSIGN_INFOS, keymsg);
         SetDlgItemText (dlg, IDC_KEYSIGN_LOCAL, _("Sign local only (non exportable signature)"));
 	SetDlgItemText (dlg, IDC_KEYSIGN_EXPSIG, _("Signature expires on"));
 	SetDlgItemText (dlg, IDC_KEYSIGN_NREV, _("Sign non-revocably"));

Modified: trunk/Src/wptListView.cpp
===================================================================
--- trunk/Src/wptListView.cpp	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Src/wptListView.cpp	2006-04-26 06:37:23 UTC (rev 204)
@@ -34,6 +34,7 @@
 #include "wptTypes.h"
 #include "wptGPG.h"
 #include "wptKeylist.h"
+#include "wptUTF8.h"
 #include "resource.h"
 
 
@@ -198,9 +199,13 @@
 
 
 void
-listview_add_sub_item( listview_ctrl_t ctx, int pos, int col, const char *text )
-{	
-    ListView_SetItemText( ctx->ctrl, pos, col, (char *)text );
+listview_add_sub_item (listview_ctrl_t ctx, int pos, int col, const char *text)
+{
+    char *utf8_txt;
+
+    utf8_txt = utf8_to_native (text);
+    ListView_SetItemText (ctx->ctrl, pos, col, utf8_txt);
+    safe_free (utf8_txt);
 }
 
 

Modified: trunk/Src/wptMDSumDlg.cpp
===================================================================
--- trunk/Src/wptMDSumDlg.cpp	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Src/wptMDSumDlg.cpp	2006-04-26 06:37:23 UTC (rev 204)
@@ -38,8 +38,9 @@
 static const char*
 printable_digest (byte *mdbuf, size_t n)
 {
-    static char mdasc[64];
+    static char mdasc[128];
     size_t i;
+
     for (i = 0; i < n; i++)
 	sprintf (mdasc+2*i, "%02X", mdbuf[i]);
     return mdasc;
@@ -47,59 +48,77 @@
 
 
 static const char*
-id2algo (int mdalgo)
+id2algo (gpgme_hash_algo_t mdalgo)
 {
-    gpgme_hash_algo_t md = (gpgme_hash_algo_t)mdalgo;
-
-    switch (md) {
+    switch (mdalgo) {
     case GPGME_MD_MD5:	    return "MD5";
     case GPGME_MD_SHA1:	    return "SHA1";
     case GPGME_MD_RMD160:   return "RMD160";
     case GPGME_MD_SHA256:   return "SHA256";
-    default: return "";
     }
     return "";
 }
 
 
+/* Hash the selected file from the FM listview control in @md.
+   Add the results to the listview @lv. */
+static void
+hash_selected_files (md_file_s *md, listview_ctrl_t lv)
+{
+    BYTE mdbuf[32];
+    char fname[256+1];
+    int i;
+    size_t n;
+
+    for (i = 0; i < listview_count_items( md->lv, 0 ); i++) {
+	if( listview_get_item_state (md->lv, i)) {
+	    listview_get_item_text (md->lv, i, 1, fname, sizeof (fname)-1);
+	    if (!gpg_md_hash_file (md->mdalgo, fname, mdbuf, &n)) {
+		listview_add_item (lv, "");
+		listview_add_sub_item (lv, 0, 0, printable_digest (mdbuf, n));
+		listview_add_sub_item (lv, 0, 1, fname);	
+	    }   
+	}	
+    }
+}
+
+
+static int
+tool_avail (gpgme_hash_algo_t mdalgo)
+{
+    if (mdalgo == GPGME_MD_SHA1 || mdalgo == GPGME_MD_MD5)
+	return 1;
+    return 0;
+}
+
+
 /* Dialog box procedure to show and calculate file digests. */
 BOOL CALLBACK
 mdsum_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
 {
     static listview_ctrl_t lv;
-    static struct md_file_s * md;
+    static struct md_file_s *md;
     struct listview_column_s cols[] = {
         {0, 264, (char *)_("Digest")},
         {1, 128, (char *)_("Name")},
         {0, 0, 0}
     };
     gpgme_data_t sumlist;
-    const char *name;
-    char fname[300], mdasc[64];
-    byte mdbuf[20];
+    const char *name, *algname;
+    char fname[300], mdasc[128];
     int i;
-    size_t n;
 
     switch( msg ) {
     case WM_INITDIALOG:
 	md = (md_file_s *)lparam;
-	if( !md )
-	    BUG( NULL );	
-	if( listview_new( &lv ) )
-	    BUG( NULL );
-	lv->ctrl = GetDlgItem( dlg, IDC_MDSUM_LIST );
-	for( i = 0; i < cols[i].width; i++ )
-	    listview_add_column( lv, &cols[i] );
-	for( i = 0; i < listview_count_items( md->lv, 0 ); i++ ) {
-	    if( listview_get_item_state( md->lv, i ) ) {
-		listview_get_item_text( md->lv, i, 1, fname, sizeof (fname)-1 );
-		if( !gpg_md_hash_file( md->mdalgo, fname, mdbuf, &n ) ) {
-		    listview_add_item( lv, "" );
-		    listview_add_sub_item( lv, 0, 0, printable_digest( mdbuf, n ) );
-		    listview_add_sub_item( lv, 0, 1, fname );
-		}
-	    }
-	}
+	if (!md)
+	    BUG (NULL);
+	if( listview_new (&lv))
+	    BUG (NULL);
+	lv->ctrl = GetDlgItem (dlg, IDC_MDSUM_LIST);
+	for (i = 0; i < cols[i].width; i++)
+	    listview_add_column( lv, &cols[i]);
+	hash_selected_files (md, lv);
 	SetDlgItemText (dlg, IDC_MDSUM_COPY, _("&Save..."));
 	SetDlgItemText (dlg, IDOK, _("&Close"));
 	SetDlgItemText (dlg, IDC_MDSUM_TOCLIP, _("Save to clipboard"));
@@ -113,8 +132,8 @@
 	return TRUE;
 
     case WM_DESTROY:
-	if( lv ) {
-	    listview_release( lv );
+	if (lv) {
+	    listview_release (lv);
 	    lv = NULL;
 	}
 	break;
@@ -125,12 +144,22 @@
 	    EndDialog (dlg, TRUE);
 	    break;
 
+	case IDCANCEL:
+	    EndDialog (dlg, FALSE);
+	    break;
+
 	case IDC_MDSUM_COPY:
+	    algname = id2algo ((gpgme_hash_algo_t)md->mdalgo);
 	    if (gpgme_data_new (&sumlist))
 		BUG(0);
-	    if (md->mdalgo == (int)GPGME_MD_RMD160) {
-		const char *s = "# warning rmd160sum is not yet available\r\n";
+	    if (!tool_avail ((gpgme_hash_algo_t)md->mdalgo)) {
+		const char *s;
+
+		s = "#warning '";
 		gpgme_data_write (sumlist, s, strlen (s));
+		gpgme_data_write (sumlist, algname, strlen (algname));
+		s = " ' sum is not yet available\r\n";
+		gpgme_data_write (sumlist, s, strlen (s));
 	    }
 	    for (i = 0; i < listview_count_items (lv, 0); i++) {
 		listview_get_item_text (lv, i, 0, mdasc, DIM (mdasc)-1);
@@ -145,7 +174,7 @@
 		gpg_data_release_and_set_clipboard (sumlist, 0);
 		break;
 	    }
-	    _snprintf (fname, sizeof (fname)-1, "%s_sums.txt", id2algo (md->mdalgo));
+	    _snprintf (fname, sizeof (fname)-1, "%s_sums.txt", algname);
 	    name = get_filesave_dlg (dlg, _("Select file to save checksums"), 
 				     NULL, fname);
 	    if (name && *name) {

Modified: trunk/Src/wptPassphraseCB.cpp
===================================================================
--- trunk/Src/wptPassphraseCB.cpp	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Src/wptPassphraseCB.cpp	2006-04-26 06:37:23 UTC (rev 204)
@@ -1,5 +1,5 @@
 /* wptPassphraseCB.cpp - GPGME Passphrase Callback
- *	Copyright (C) 2001, 2002, 2003, 2005 Timo Schulz
+ *	Copyright (C) 2001, 2002, 2003, 2005, 2006 Timo Schulz
  *	Copyright (C) 2005 g10 Code GmbH
  *
  * This file is part of WinPT.
@@ -34,7 +34,6 @@
 #include "wptCommonCtl.h"
 #include "wptContext.h"
 #include "wptDlgs.h"
-#include "wptUTF8.h"
 #include "wptErrors.h"
 #include "wptTypes.h"
 #include "wptKeylist.h"
@@ -50,6 +49,8 @@
     ((cmd) == GPG_CMD_DECRYPT? IDC_DECRYPT_HIDE : IDC_DECRYPT_SIGN_HIDE)
 
 
+void ListBox_AddString_utf8 (HWND lb, const char *txt);
+
 /* Overwrite passphrase and free memory. */
 static void
 burn_passphrase (char **pwd)
@@ -116,25 +117,22 @@
 		get_pubkey (r->keyid, &key);
 		if (key) {
 		    gpgme_user_id_t u = key->uids;
-		    char *uid;
 
 		    id = u->name;
 		    if (!id)
 			id = _("Invalid User ID");
-		    uid = utf8_to_native (id);
-		    n = 32+strlen (uid)+1+4+strlen (r->keyid)+1;
+		    n = 32+strlen (id)+1+4+strlen (r->keyid)+1;
 		    if (u->email)
 			n += strlen (u->email)+1;
 		    info = new char [n+1];
 		    if (!info)
 			BUG (NULL);
 		    if (!u->email || strlen (u->email) < 1)
-			sprintf (info, "%s (%s, 0x%s)", uid,
+			sprintf (info, "%s (%s, 0x%s)", id,
 				 get_key_pubalgo (r->pubkey_algo), r->keyid+8);
 		    else
-			sprintf (info, "%s <%s> (%s, 0x%s)", uid, u->email,
+			sprintf (info, "%s <%s> (%s, 0x%s)", id, u->email,
 				 get_key_pubalgo (r->pubkey_algo), r->keyid+8);
-		    free (uid);
 		}
 		else {
 		    info = new char [32 + strlen (r->keyid)+1 + 4];
@@ -143,7 +141,7 @@
 		    sprintf (info, _("Unknown key ID (%s, 0x%s)"), 
 			     get_key_pubalgo (r->pubkey_algo), r->keyid+8);
 		}
-		listbox_add_string (GetDlgItem (dlg, IDC_DECRYPT_LIST), info);
+		ListBox_AddString_utf8 (GetDlgItem (dlg, IDC_DECRYPT_LIST), info);
 		free_if_alloc (info);
 	    }
 	}
@@ -167,11 +165,11 @@
 		free_if_alloc (info);
 	    }
 	    else
-		SetDlgItemText (dlg, IDC_DECRYPT_MSG, c->info);
+		SetDlgItemText_utf8 (dlg, IDC_DECRYPT_MSG, c->info);
 	}
 	else {
-	    SetFocus( GetDlgItem (dlg, IDC_DECRYPT_SIGN_PWD));
-	    SetDlgItemText (dlg, IDC_DECRYPT_SIGN_MSG, c->info);
+	    SetFocus (GetDlgItem (dlg, IDC_DECRYPT_SIGN_PWD));
+	    SetDlgItemText_utf8 (dlg, IDC_DECRYPT_SIGN_MSG, c->info);
 	}
 	center_window (dlg, NULL);
 	SetForegroundWindow (dlg);
@@ -276,7 +274,7 @@
     gpgme_pubkey_algo_t algo;
     char usedkey[16+1];
     char mainkey[16+1];
-    char *uid, *p;
+    char *p;
     int n=0;
 
     algo = (gpgme_pubkey_algo_t)0;
@@ -297,21 +295,18 @@
     uid_hint += 16; /* skip keyid */
     uid_hint += 1;  /* space */
 
-    uid = utf8_to_native (uid_hint);
-
     if (strcmp (usedkey, mainkey))
 	_snprintf (desc, size-1, 
 		   _("You need a passphrase to unlock the secret key for\n"
 		     "user: \"%s\"\n"
 		     "%s key, ID %s (main key ID %s)\n"),
-		   uid, get_key_pubalgo (algo), usedkey+8, mainkey+8);
+		   uid_hint, get_key_pubalgo (algo), usedkey+8, mainkey+8);
     else if (!strcmp (usedkey, mainkey))
 	_snprintf (desc, size-1,
 		   _("You need a passphrase to unlock the secret key for\n"
 		     "user: \"%s\"\n"
 		     "%s key, ID %s\n"),
-		     uid, get_key_pubalgo (algo), usedkey+8);
-    free (uid);
+		     uid_hint, get_key_pubalgo (algo), usedkey+8);
     return 0;
 }
 

Modified: trunk/Src/wptSigList.cpp
===================================================================
--- trunk/Src/wptSigList.cpp	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Src/wptSigList.cpp	2006-04-26 06:37:23 UTC (rev 204)
@@ -26,14 +26,15 @@
 #include <windows.h>
 #include <time.h>
 
+#include "resource.h"
 #include "wptGPG.h"
 #include "wptCommonCtl.h"
 #include "wptKeylist.h"
 #include "wptNLS.h"
-#include "wptUTF8.h"
 #include "wptErrors.h"
 #include "wptTypes.h"
 #include "wptW32API.h"
+#include "wptVersion.h"
 
 
 /* Is the given signature an user-id signature? */
@@ -56,7 +57,7 @@
 	{5,  68, (char *)_("Expiration")},
 	{6,  56, (char *)_("Algorithm")},
 	{0,   0, NULL}
-    };	
+    };
     int j, rc = 0;
     
     rc = listview_new (&c);
@@ -146,10 +147,8 @@
     else
 	attr = uid->uid;
     if (attr && strlen (attr)) {
-	char *uid_utf8 = utf8_to_native (attr);
-	char *p = uid? m_strdup (uid_utf8) : indent_string (uid_utf8, 2);
+	char *p = uid? m_strdup (attr) : indent_string (attr, 2);
 	listview_add_sub_item (lv, pos, 0, p);
-	free (uid_utf8);
 	free_if_alloc (p);
     }
     else {

Modified: trunk/Src/wptSigTreeDlg.cpp
===================================================================
--- trunk/Src/wptSigTreeDlg.cpp	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Src/wptSigTreeDlg.cpp	2006-04-26 06:37:23 UTC (rev 204)
@@ -147,7 +147,7 @@
     static HIMAGELIST hil;
     HICON ico[2];
     NMHDR *nft;
-    char inf[300], *p;
+    char inf[300];
 
     switch (msg) {
     case WM_INITDIALOG:
@@ -159,13 +159,11 @@
 	tree = GetDlgItem (dlg, IDC_VKEYSIG_TREE);
 	hil = treeview_set_image_list (tree, ico, 2);
 	sigtree_load (tree, key->ctx);
-	p = utf8_to_native (key->ctx->uids->name);
 	_snprintf (inf, sizeof (inf)-1, 
 		   _("Signature Tree for \"%s\" (0x%s)"), 
-		   p, key->ctx->subkeys->keyid+8);
-	safe_free (p);
+		   key->ctx->uids->uid/*p*/, key->ctx->subkeys->keyid+8);
 	SetDlgItemText (dlg, IDC_VKEYSIG_EDIT, _("Edit..."));
-	SetWindowText (dlg, inf);
+	SetWindowText_utf8 (dlg, inf);
 	SetForegroundWindow (dlg);
 	break;
 

Modified: trunk/Src/wptVerifyList.cpp
===================================================================
--- trunk/Src/wptVerifyList.cpp	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Src/wptVerifyList.cpp	2006-04-26 06:37:23 UTC (rev 204)
@@ -32,7 +32,6 @@
 #include "wptKeylist.h"
 #include "wptNLS.h"
 #include "wptErrors.h"
-#include "wptUTF8.h"
 #include "wptW32API.h"
 
 
@@ -193,10 +192,7 @@
     else
 	attr = key->uids->name;
 
-    uid = utf8_to_native (attr);
-    listview_add_sub_item (lv, 0, VER_COL_UID, (char *)uid);
-    free (uid);
-
+    listview_add_sub_item (lv, 0, VER_COL_UID, attr);
     return 0;
 }
 
@@ -208,7 +204,7 @@
 {
     gpgme_signature_t sig = log->sig;
     gpgme_key_t key = NULL;
-    const char *attr;    
+    const char *attr;
     char t[64], *name;
     int off = 0;
 
@@ -251,13 +247,8 @@
 	off = strlen (sig->fpr) == 40? 32 : 24;
     _snprintf (t, sizeof (t)-1, "0x%s", sig->fpr + off);
     listview_add_sub_item (lv, 0, VER_COL_KEYID, t);
-
-    if (log->user_id)
-	name = utf8_to_native (log->user_id);
-    else
-	name = strdup (_("user ID not found"));
-
-    listview_add_sub_item (lv, 0, VER_COL_UID, name);
-    free (name);
+    listview_add_sub_item (lv, 0, VER_COL_UID, 
+			   log->user_id? 
+			   log->user_id : _("user ID not found"));
     return 0;
 }

Modified: trunk/Src/wptW32API.cpp
===================================================================
--- trunk/Src/wptW32API.cpp	2006-04-22 18:38:01 UTC (rev 203)
+++ trunk/Src/wptW32API.cpp	2006-04-26 06:37:23 UTC (rev 204)
@@ -35,6 +35,7 @@
 #include "wptW32API.h"
 #include "wptErrors.h"
 #include "wptVersion.h"
+#include "wptUTF8.h"
 #include "wptTypes.h"
 
 
@@ -590,6 +591,72 @@
 }
 
 
+/* SetDlgItemText replacement with UTF8 support. */  
+void
+SetDlgItemText_utf8 (HWND dlg, int id, const char *txt)
+{
+    char *utf8_txt;
+
+    utf8_txt = utf8_to_native (txt);
+    SetDlgItemText (dlg, id, utf8_txt);
+    safe_free (utf8_txt);
+}
+
+/* SetWindowText replacement with UTF8 support. */
+void
+SetWindowText_utf8 (HWND hwnd, const char *txt)
+{
+    char *utf8_txt;
+
+    utf8_txt = utf8_to_native (txt);
+    SetWindowText (hwnd, utf8_txt);
+    safe_free (utf8_txt);
+}
+
+
+void
+ListBox_AddString_utf8 (HWND lb, const char *txt)
+{
+    char *utf8_txt;
+
+    utf8_txt = utf8_to_native (txt);
+    SendMessage (lb, LB_ADDSTRING, 0, (LPARAM)(LPCSTR)(utf8_txt));
+    safe_free (utf8_txt);
+}
+
+
+void
+ComboBox_AddString_utf8 (HWND cb, const char *txt)
+{
+
+    char *utf8_txt;
+
+    utf8_txt = utf8_to_native (txt);
+    SendMessage ((cb), CB_ADDSTRING, 0, (LPARAM)(LPCSTR)(utf8_txt));
+    safe_free (utf8_txt);
+}
+
+
+/* GetDlgItemText replacement with UTF8 support. */
+int
+GetDlgItemText_utf8 (HWND dlg, int id, char **r_txt)
+{
+    int len = GetWindowTextLength (GetDlgItem (dlg, id));
+    char *txt;
+
+    *r_txt = NULL;
+    if (len < 1)
+	return 0;
+    txt = new char[len+2];
+    if (!txt)
+	BUG (NULL);
+    GetDlgItemText (dlg, id, txt, len+1);
+    *r_txt = native_to_utf8 (txt);
+    free_if_alloc (txt);
+    return len;
+}
+
+
 struct reminder_hd_s {
     int msecs;
     HWND dlg;



More information about the Winpt-commits mailing list