[Winpt-commits] r255 - trunk/Src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Aug 1 18:37:27 CEST 2006


Author: twoaday
Date: 2006-08-01 18:37:23 +0200 (Tue, 01 Aug 2006)
New Revision: 255

Modified:
   trunk/Src/ChangeLog
   trunk/Src/WinPT-en.rc
   trunk/Src/WinPT.cpp
   trunk/Src/resource.h
   trunk/Src/wptCurrWnd.cpp
   trunk/Src/wptGPG.cpp
   trunk/Src/wptGPGME.cpp
   trunk/Src/wptGPGOptDlg.cpp
   trunk/Src/wptKeyManager.cpp
   trunk/Src/wptKeyManagerDlg.cpp
   trunk/Src/wptKeysigDlg.cpp
   trunk/Src/wptKeysignDlg.cpp
   trunk/Src/wptMainProc.cpp
   trunk/Src/wptPassphraseCB.cpp
   trunk/Src/wptW32API.cpp
Log:


Modified: trunk/Src/ChangeLog
===================================================================
--- trunk/Src/ChangeLog	2006-08-01 16:37:11 UTC (rev 254)
+++ trunk/Src/ChangeLog	2006-08-01 16:37:23 UTC (rev 255)
@@ -1,5 +1,32 @@
-2007-07-28  Timo Schulz  <ts at g10code.de>
+2006-08-01  Timo Schulz  <ts at g10code.de>
 
+	* wptGPG.cpp (get_last_gnupg_access): Enhanced.
+	(gnupg_display_error): Removed unused code.
+	* wptPassphraseCB.cpp (parse_gpg_description): Text output
+	is now more human readable.
+	* wptKeyManager.cpp (km_refresh_from_keyserver): Return an
+	error code in all cases.
+	
+2006-07-31  Timo Schulz  <ts at g10code.de>
+
+	* wptMainProc.cpp (clip_gpg_dlg): Merge in the current window
+	handling code.
+	* wptCurrWnd.cpp (wnd_msg_em_set_pos): Reset pos to 0, not 1.
+	* wptKeyEditDlgs.cpp (keyedit_main_dlg_proc): Disable sorting
+	for list view controls.
+	
+2006-07-30  Timo Schulz  <ts at g10code.de>
+
+	* wptKeyManagerDlg.cpp (keymanager_dlg_proc): Change menu style.
+	* wptKeySignDlg.cpp (keysign_dlg_proc): List all user IDs.
+	(display_keyinfo): New.
+	* wptKeySigDlg.cpp (init_datepicker_from_time): New.
+	(keysig_dlg_proc): List creation time.
+	* wptKeyManager.cpp (km_send_to_mail_recipient): Fix file
+	handling.
+	
+2006-07-28  Timo Schulz  <ts at g10code.de>
+
 	* wptKeyManager.cpp (lv_del_confirmed_keys): New.
 	* wptKeyEditDlgs.cpp (keyedit_addsubkey_dlg_proc): Automatically
 	adjust key size.

Modified: trunk/Src/WinPT-en.rc
===================================================================
--- trunk/Src/WinPT-en.rc	2006-08-01 16:37:11 UTC (rev 254)
+++ trunk/Src/WinPT-en.rc	2006-08-01 16:37:23 UTC (rev 255)
@@ -120,11 +120,11 @@
 END
 
 IDD_WINPT_SIGPROPS DIALOG DISCARDABLE  0, 0, 246, 159
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
 CAPTION "Signature Properties"
 FONT 8, "MS Sans Serif"
 BEGIN
-    GROUPBOX        "Signature Info",IDC_STATIC,2,3,239,128
+    GROUPBOX        "Signature Info",IDC_STATIC,2,1,239,133
     EDITTEXT        IDC_SIGPROPS_INFO,9,18,219,13,ES_AUTOHSCROLL | 
                     ES_READONLY
     LTEXT           "Issuer key",IDC_SIGPROPS_KEYINF,9,36,111,8
@@ -134,23 +134,27 @@
     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 | 
+    EDITTEXT        IDC_SIGPROPS_POLIC,9,80,157,12,ES_AUTOHSCROLL | 
                     ES_READONLY
-    LTEXT           "Expire date",IDC_SIGPROPS_EXPSTR,9,100,40,8
+    LTEXT           "Class",IDC_SIGPROPS_CLASSINF,170,82,25,8
+    EDITTEXT        IDC_SIGPROPS_CLASS,198,80,40,12,ES_AUTOHSCROLL | 
+                    ES_READONLY
+    LTEXT           "Creation date",IDC_SIGPROPS_CREATSTR,9,101,53,8
+    CONTROL         "DateTimePicker1",IDC_SIGPROPS_CREATDATE,
+                    "SysDateTimePick32",DTS_RIGHTALIGN | WS_DISABLED | 
+                    WS_TABSTOP,62,99,57,12
+    LTEXT           "Expire date",IDC_SIGPROPS_EXPSTR,126,100,40,8
     CONTROL         "DateTimePicker1",IDC_SIGPROPS_EXPDATE,"SysDateTimePick32",
-                    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
+                    DTS_RIGHTALIGN | WS_DISABLED | WS_TABSTOP,171,99,60,12
     CONTROL         "Exportable",IDC_SIGPROPS_EXP,"Button",BS_AUTOCHECKBOX | 
-                    BS_FLAT | WS_TABSTOP,9,118,53,10
+                    BS_FLAT | WS_TABSTOP,9,120,53,10
     CONTROL         "Non-revocably",IDC_SIGPROPS_NREV,"Button",
-                    BS_AUTOCHECKBOX | BS_FLAT | WS_TABSTOP,64,118,67,10
+                    BS_AUTOCHECKBOX | BS_FLAT | WS_TABSTOP,64,120,67,10
     CONTROL         "Revoked",IDC_SIGPROPS_REV,"Button",BS_AUTOCHECKBOX | 
-                    BS_FLAT | WS_TABSTOP,133,118,50,10
+                    BS_FLAT | WS_TABSTOP,133,120,50,10
     CONTROL         "Expired",IDC_SIGPROPS_EXPIRED,"Button",BS_AUTOCHECKBOX | 
-                    BS_FLAT | WS_TABSTOP,186,118,50,10
-    DEFPUSHBUTTON   "OK",IDOK,191,135,50,14
+                    BS_FLAT | WS_TABSTOP,186,120,50,10
+    DEFPUSHBUTTON   "OK",IDOK,191,137,50,14
 END
 
 IDD_WINPT_KEYEDIT_SHOWPREF DIALOG DISCARDABLE  0, 0, 144, 172
@@ -353,7 +357,7 @@
 BEGIN
     CONTROL         "List1",IDC_KEYSERVER_LIST,"SysListView32",LVS_REPORT | 
                     LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | 
-                    WS_BORDER | WS_TABSTOP,6,5,173,100
+                    LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,6,5,173,100
     PUSHBUTTON      "Set &default",IDC_KEYSERVER_DEFAULT,66,106,48,13
     PUSHBUTTON      "C&hange proxy",IDC_KEYSERVER_PROXSETT,117,106,61,13
     GROUPBOX        "",IDC_STATIC,5,128,171,36
@@ -462,34 +466,34 @@
     LTEXT           "Info",IDC_KEYCACHE_INFO,10,9,162,8
 END
 
-IDD_WINPT_KEYSIGN DIALOG DISCARDABLE  0, 0, 286, 207
+IDD_WINPT_KEYSIGN DIALOG DISCARDABLE  0, 0, 286, 218
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Key Signing"
 FONT 8, "MS Sans Serif"
 BEGIN
-    LTEXT           "Infos",IDC_KEYSIGN_INFOS,5,7,268,66
+    LTEXT           "Infos",IDC_KEYSIGN_INFOS,7,9,268,85
     CONTROL         "Sign &local only (non exportable signature)",
                     IDC_KEYSIGN_LOCAL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
-                    5,83,170,10
+                    5,100,170,10
     CONTROL         "Signature &expires on",IDC_KEYSIGN_EXPSIG,"Button",
-                    BS_AUTOCHECKBOX | WS_TABSTOP,5,96,83,10
+                    BS_AUTOCHECKBOX | WS_TABSTOP,5,113,83,10
     CONTROL         "DateTimePicker1",IDC_KEYSIGN_EXPIRES,"SysDateTimePick32",
-                    DTS_RIGHTALIGN | WS_TABSTOP,89,94,69,14
+                    DTS_RIGHTALIGN | WS_TABSTOP,89,111,69,14
     CONTROL         "&Ask for certification level",IDC_KEYSIGN_ASKLEVEL,
-                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,109,112,10
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,126,112,10
     CONTROL         "Sign &non-revocably",IDC_KEYSIGN_NREV,"Button",
-                    BS_AUTOCHECKBOX | WS_TABSTOP,5,122,100,10
-    COMBOBOX        IDC_KEYSIGN_KEYLIST,5,137,219,49,CBS_DROPDOWNLIST | 
+                    BS_AUTOCHECKBOX | WS_TABSTOP,5,139,100,10
+    COMBOBOX        IDC_KEYSIGN_KEYLIST,5,154,219,49,CBS_DROPDOWNLIST | 
                     WS_VSCROLL | WS_TABSTOP
-    LTEXT           "Passphrase",IDC_KEYSIGN_PWDINF,5,155,44,8
-    EDITTEXT        IDC_KEYSIGN_PASSPHRASE,53,153,170,13,ES_PASSWORD | 
+    LTEXT           "Passphrase",IDC_KEYSIGN_PWDINF,5,172,44,8
+    EDITTEXT        IDC_KEYSIGN_PASSPHRASE,53,170,170,13,ES_PASSWORD | 
                     ES_AUTOHSCROLL
     CONTROL         "&Hide typing",IDC_KEYSIGN_HIDE,"Button",BS_AUTOCHECKBOX | 
-                    WS_TABSTOP,127,168,74,9
-    PUSHBUTTON      "&Show photo",IDC_KEYSIGN_SHOWIMG,2,189,67,14,
-                    WS_DISABLED
-    DEFPUSHBUTTON   "&OK",IDOK,174,189,50,14
-    PUSHBUTTON      "&Cancel",IDCANCEL,227,188,54,15
+                    WS_TABSTOP,127,185,74,9
+    PUSHBUTTON      "&Show photo",IDC_KEYSIGN_SHOWIMG,2,200,67,14
+    DEFPUSHBUTTON   "&OK",IDOK,174,200,50,14
+    PUSHBUTTON      "&Cancel",IDCANCEL,227,199,54,15
+    GROUPBOX        "",IDC_STATIC,3,1,278,95
 END
 
 IDD_WINPT_GPGPREFS DIALOG DISCARDABLE  0, 0, 222, 242
@@ -849,21 +853,21 @@
                     ES_WANTRETURN | WS_DISABLED
 END
 
-IDD_WINPT_DECRYPT_SIGN DIALOG DISCARDABLE  0, 0, 237, 122
+IDD_WINPT_DECRYPT_SIGN DIALOG DISCARDABLE  0, 0, 235, 127
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "Signing"
 FONT 8, "MS Sans Serif"
 BEGIN
-    GROUPBOX        "",IDC_STATIC,7,4,220,52
-    LTEXT           "Passphrase info",IDC_DECRYPT_SIGN_MSG,13,15,210,38
+    GROUPBOX        "",IDC_STATIC,5,4,226,52
+    LTEXT           "Passphrase info",IDC_DECRYPT_SIGN_MSG,13,14,210,40
     LTEXT           "Please enter your passphrase",IDC_DECRYPT_SIGN_PWDINFO,
-                    7,59,211,8
-    EDITTEXT        IDC_DECRYPT_SIGN_PWD,7,71,219,12,ES_PASSWORD | 
+                    7,63,211,8
+    EDITTEXT        IDC_DECRYPT_SIGN_PWD,7,75,219,12,ES_PASSWORD | 
                     ES_AUTOHSCROLL
     CONTROL         "&Hide Typing",IDC_DECRYPT_SIGN_HIDE,"Button",
-                    BS_AUTOCHECKBOX | WS_TABSTOP,159,85,71,10
-    DEFPUSHBUTTON   "&OK",IDOK,131,105,48,14
-    PUSHBUTTON      "&Cancel",IDCANCEL,181,105,47,14
+                    BS_AUTOCHECKBOX | WS_TABSTOP,153,89,71,10
+    DEFPUSHBUTTON   "&OK",IDOK,131,107,48,14
+    PUSHBUTTON      "&Cancel",IDCANCEL,181,107,47,14
 END
 
 IDD_WINPT_GROUP DIALOG DISCARDABLE  0, 0, 178, 66
@@ -1128,9 +1132,11 @@
 FONT 8, "MS Sans Serif"
 BEGIN
     CONTROL         "List2",IDC_KEYEDIT_KEYLIST,"SysListView32",LVS_REPORT | 
-                    LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,4,3,281,59
+                    LVS_SINGLESEL | LVS_NOSORTHEADER | WS_BORDER | 
+                    WS_TABSTOP,4,3,281,59
     CONTROL         "List1",IDC_KEYEDIT_UIDLIST,"SysListView32",LVS_REPORT | 
-                    LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,4,66,281,58
+                    LVS_SINGLESEL | LVS_NOSORTHEADER | WS_BORDER | 
+                    WS_TABSTOP,4,66,281,58
     LTEXT           "Command>",IDC_KEYEDIT_CMDINF,110,134,42,8
     COMBOBOX        IDC_KEYEDIT_CMD,154,132,84,108,CBS_DROPDOWNLIST | 
                     WS_VSCROLL | WS_TABSTOP
@@ -1525,7 +1531,7 @@
         LEFTMARGIN, 3
         RIGHTMARGIN, 281
         TOPMARGIN, 3
-        BOTTOMMARGIN, 203
+        BOTTOMMARGIN, 214
     END
 
     IDD_WINPT_GPGPREFS, DIALOG
@@ -1683,9 +1689,9 @@
     IDD_WINPT_DECRYPT_SIGN, DIALOG
     BEGIN
         LEFTMARGIN, 4
-        RIGHTMARGIN, 230
+        RIGHTMARGIN, 231
         TOPMARGIN, 3
-        BOTTOMMARGIN, 116
+        BOTTOMMARGIN, 121
     END
 
     IDD_WINPT_GROUP, DIALOG
@@ -2065,6 +2071,13 @@
         MENUITEM "Search...\tCtrl+F",           ID_KEYMISC_FIND
         MENUITEM SEPARATOR
         MENUITEM "Select All\tCtrl+A",          ID_KEYMISC_SELALL
+        MENUITEM SEPARATOR
+        POPUP "&Preferences..."
+        BEGIN
+            MENUITEM "GPG Options",                 ID_KEYMISC_GPGOPT
+            MENUITEM "GPG Preferences",             ID_KEYMISC_GPGPREFS
+            MENUITEM "WinPT Preferences",           ID_KEYMISC_WINPTPREFS
+        END
     END
     POPUP "View"
     BEGIN
@@ -2114,14 +2127,10 @@
         MENUITEM "Show",                        ID_GROUP_SHOW
     END
     MENUITEM "Key&server",                  ID_KEYMISC_SENDRECV
-    POPUP "&GPG"
-    BEGIN
-        MENUITEM "&Options",                    ID_KEYMISC_GPGOPT
-        MENUITEM "&Preferences",                ID_KEYMISC_GPGPREFS
-    END
     POPUP "&?"
     BEGIN
         MENUITEM "WinPT &Website",              ID_KEYMISC_WEBSITE
+        MENUITEM "&Project Website",            ID_KEYMISC_DEVWWW
         MENUITEM SEPARATOR
         MENUITEM "&Info",                       ID_KEYMISC_INFO
     END

Modified: trunk/Src/WinPT.cpp
===================================================================
--- trunk/Src/WinPT.cpp	2006-08-01 16:37:11 UTC (rev 254)
+++ trunk/Src/WinPT.cpp	2006-08-01 16:37:23 UTC (rev 255)
@@ -58,18 +58,25 @@
 
 
 /* Load the key cache and rebuild the signature cache. */
-void
+int
 update_keycache (HWND hwnd)
 {
+    int err;
+
     refresh_cache_s rcs = {0};
     rcs.kr_reload = 0; 
     rcs.kr_update = 1;
     rcs.tr_update = 1;
-    DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, hwnd,
+    err = DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, hwnd,
 		    keycache_dlg_proc, (LPARAM)&rcs);
-    /* XXX: the dialog return 0 when an error occurs.
-	    in this case figure out if the gpg env is OK
-	    and supress dialogs to configure gpg. */
+    if (err) {
+	char *cfg = get_gnupg_config ();
+	if (cfg && check_gnupg_options (cfg, 0) == WPTERR_FILE_EXIST)
+	    msg_box (NULL, _("The gpg.conf contains at least one argument which points to a non-existing file."), "WinPT", MB_ERR);
+	free_if_alloc (cfg);
+	return -1;
+    }
+    return 0;
 }
 
 
@@ -730,6 +737,7 @@
 	if (!check_crypto_engine ()) {
 	    DestroyWindow (hwnd);
 	    free_gnupg_table ();
+	    keycache_release (1);
 	    return 0;
 	}
 	if (!is_gpg4win_installed ()) {
@@ -739,10 +747,14 @@
     }
     else {
 	gpg_keycache_t c, sec_c;
-	update_keycache (hwnd);
+	if (update_keycache (hwnd)) {
+	    DestroyWindow (hwnd);
+	    free_gnupg_table ();
+	    keycache_release (1);
+	    return 0;
+	}
 	c = keycache_get_ctx (1);
-	if (!c || !gpg_keycache_get_size (c)) {
-	    gnupg_display_error ();
+	if (!gpg_keycache_get_size (c)) {
 	    msg_box (hwnd, _("The keycache was not initialized or is empty.\n"
 			     "Please check your GPG config (keyrings, pathes...)"),
 			     _("WinPT Error"), MB_ERR);
@@ -757,6 +769,7 @@
 	    else {
 		DestroyWindow (hwnd);
 		free_gnupg_table ();
+		keycache_release (1);
 		return 0;
 	    }
 	}

Modified: trunk/Src/resource.h
===================================================================
--- trunk/Src/resource.h	2006-08-01 16:37:11 UTC (rev 254)
+++ trunk/Src/resource.h	2006-08-01 16:37:23 UTC (rev 255)
@@ -661,6 +661,8 @@
 #define IDC_VERIFY_SIGNOT               1533
 #define IDC_PASSWD_KEYINF               1534
 #define IDC_SHOWPHOTO_IMG               1535
+#define IDC_SIGPROPS_CREATSTR           1537
+#define IDC_SIGPROPS_CREATDATE          1538
 #define ID_GPG_ENCRYPT                  40003
 #define ID_GPG_DECRYPT                  40004
 #define ID_GPG_SIGN                     40005
@@ -846,14 +848,16 @@
 #define ID_CLIPEDIT_ENC                 40195
 #define ID_CLIPEDIT_DEC                 40196
 #define ID_KEYCTX_EMAIL_COPY            40197
+#define ID_KEYMISC_WINPTPREFS           40198
+#define ID_KEYMISC_DEVWWW               40199
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        251
-#define _APS_NEXT_COMMAND_VALUE         40198
-#define _APS_NEXT_CONTROL_VALUE         1537
+#define _APS_NEXT_COMMAND_VALUE         40200
+#define _APS_NEXT_CONTROL_VALUE         1539
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif

Modified: trunk/Src/wptCurrWnd.cpp
===================================================================
--- trunk/Src/wptCurrWnd.cpp	2006-08-01 16:37:11 UTC (rev 254)
+++ trunk/Src/wptCurrWnd.cpp	2006-08-01 16:37:23 UTC (rev 255)
@@ -1,5 +1,5 @@
 /* wptCurrWnd.cpp - Current window code
- *	Copyright (C) 2001-2004 Timo Schulz
+ *	Copyright (C) 2001-2004, 2006 Timo Schulz
  *
  * This file is part of WinPT.
  *
@@ -28,14 +28,16 @@
 #include "wptErrors.h"
 #include "wptVersion.h"
 
-#define KEYDOWN( vcode, scode ) keybd_event( (vcode), (scode), 0, 0 )
-#define KEYUP( vcode, scode)	keybd_event( (vcode), (scode), KEYEVENTF_KEYUP, 0 )
+#define KEYDOWN(vcode, scode) keybd_event ((vcode), (scode), 0, 0)
+#define KEYUP(vcode, scode)	keybd_event ((vcode), (scode), KEYEVENTF_KEYUP, 0)
 
     
-extern "C" HWND PTD_get_curr_hwnd( void );
-extern "C" BOOL PTD_keyb_send( UINT *keys, UINT n_keys );
-extern "C" int PTD_is_used( void );
+extern "C" HWND PTD_get_curr_hwnd (void);
+extern "C" BOOL PTD_keyb_send (UINT *keys, UINT n_keys);
+extern "C" int PTD_is_used (void);
 
+
+/* Clear the clipboard contents. */
 static void
 clip_clear (void)
 {
@@ -52,66 +54,68 @@
 {
     HANDLE clipmem;
 
-    /* Arrrgg: it seems that we've to wait until the remote thread		  
-       processed the message. W32 said it does, but I don't think so :-((. */
-    Sleep( 400 );
+    /* Little backoff time to make sure the clipboard now really 
+       contains all data. */
+    Sleep (400);
 		
-    if( OpenClipboard( NULL ) == FALSE )    
+    if (OpenClipboard (NULL) == FALSE) 
 	return WPTERR_CLIP_OPEN;
-    clipmem = GetClipboardData( CF_TEXT );
-    if( clipmem == NULL ) {
-	CloseClipboard( );	
+    clipmem = GetClipboardData (CF_TEXT);
+    if (clipmem == NULL) {
+	CloseClipboard ();
 	return WPTERR_CLIP_GET;	
     }
-    CloseClipboard( );
+    CloseClipboard ();
     return 0;
 }
 
 
 /* Fabricate a "select all" keystroke sequence. */
 static void
-wnd_msg_markall (void)
+wnd_msg_selectall (void)
 {
     unsigned keys[4] = {0};
 
-    if( PTD_is_used() ) {
+    if (PTD_is_used ()) {
 	keys[0] = VK_CONTROL | 0x8000;
 	keys[1] = 'A' | 0x8000;	
 	keys[2] = 'A';	
 	keys[3] = VK_CONTROL;	
-	PTD_keyb_send( keys, 4 );
+	PTD_keyb_send (keys, 4);
 
     }
     else {
-	KEYDOWN( VK_CONTROL, 0x1d );	
-	KEYDOWN( (BYTE)'A', 0x1e );	
-	KEYUP( (BYTE)'A', 0x1e );
-	KEYUP( VK_CONTROL, 0x1d );	
+	KEYDOWN (VK_CONTROL, 0x1d);
+	KEYDOWN ((BYTE)'A', 0x1e);
+	KEYUP ((BYTE)'A', 0x1e);
+	KEYUP (VK_CONTROL, 0x1d);
     }
 }
 
 
+/* Fabricate a "paste" keystrok sequence. */
 static void
 wnd_msg_paste (void)
 {
     unsigned keys[4] = {0};
 
-    if( PTD_is_used() ) {
+    if (PTD_is_used ()) {
 	keys[0] = VK_CONTROL | 0x8000;
 	keys[1] = 'V' | 0x8000;
 	keys[2] = 'V';
 	keys[3] = VK_CONTROL;
-	PTD_keyb_send( keys, 4 );	
+	PTD_keyb_send (keys, 4);
     }
     else {
-	KEYDOWN( VK_CONTROL, 0x1d );	
-	KEYDOWN( (BYTE)'V', 0x2f );	
-	KEYUP( (BYTE)'V', 0x2f );	
-	KEYUP( VK_CONTROL, 0x1d );	
+	KEYDOWN (VK_CONTROL, 0x1d);
+	KEYDOWN ((BYTE)'V', 0x2f);
+	KEYUP ((BYTE)'V', 0x2f);
+	KEYUP (VK_CONTROL, 0x1d);
     }
 }
 
 
+/* Fabricate a "copy" keystroke sequence. */
 static void
 wnd_msg_copy (void)
 {
@@ -133,114 +137,113 @@
 }
 
 
+/* Set the position inside the edit control @hwnd. */
 static inline void
-wnd_msg_em_set_pos( HWND hwnd, int begin )
+wnd_msg_em_set_pos (HWND hwnd, int begin)
 {
-    SendMessage( hwnd, EM_SETSEL, 0, begin? 1 : -1 );
+    SendMessage (hwnd, EM_SETSEL, 0, begin? 0 : -1);
 }
 
 
+/* Get the current window and return it in @r_main.
+   Return value: The Window with the keyboard focus. */
 static HWND
-get_curr_wnd( HWND main, int hotkey, HWND *r_main )
+get_curr_wnd (HWND main, int use_hotkey, HWND *r_main)
 {
     HWND prev, fg;
 
-    if( hotkey )
-	prev = GetForegroundWindow();
+    if (use_hotkey)
+	prev = GetForegroundWindow ();
     else {
-	if( r_main )
-	    *r_main = GetNextWindow( main, GW_HWNDNEXT );
+	if (r_main)
+	    *r_main = GetNextWindow (main, GW_HWNDNEXT);
 	return PTD_get_curr_hwnd( );
     }
 
-    SetForegroundWindow( prev );
+    SetForegroundWindow (prev);
+    AttachThreadInput (GetCurrentThreadId(),
+		       GetWindowThreadProcessId (prev, NULL),
+		       TRUE);
+    fg = GetFocus ();
+    AttachThreadInput (GetCurrentThreadId (),
+			GetWindowThreadProcessId (prev, NULL),
+			FALSE);
 
-    AttachThreadInput( GetCurrentThreadId(),
-			GetWindowThreadProcessId( prev, NULL ),
-			TRUE );
-    fg = GetFocus();
-    AttachThreadInput( GetCurrentThreadId(),
-			GetWindowThreadProcessId( prev, NULL ),
-			FALSE );
-
-    if( r_main )
+    if (r_main)
 	*r_main = prev;
-
     return fg;
 }
 
 
 int
-get_window_contents( HWND old_hwnd, curr_wnd_ctx *ctx, int *r_hotkey )
+get_window_contents (HWND old_hwnd, curr_wnd_ctx *ctx, int *r_hotkey)
 {
     HWND hwnd;
     int rc = 1, hotkey = 0;
     
-    if( r_hotkey )
+    if (r_hotkey)
 	hotkey = *r_hotkey;
 	
-    hwnd = get_curr_wnd( old_hwnd, hotkey, &ctx->main );
-    if( hwnd == NULL )
+    hwnd = get_curr_wnd (old_hwnd, hotkey, &ctx->main);
+    if (!hwnd)
 	return rc;
     ctx->focus = hwnd;
-    clip_clear( );
+    clip_clear ();
 	
-    AttachThreadInput( GetCurrentThreadId( ),
-			GetWindowThreadProcessId( hwnd, NULL ),	
-			TRUE );
-    SetFocus( hwnd );
-	
+    AttachThreadInput (GetCurrentThreadId (),
+		       GetWindowThreadProcessId (hwnd, NULL),
+		       TRUE);
+    SetFocus (hwnd);
     /* First we try to send a simple clipboard copying command and check
        if the clipboard contains some text. */
-    SendMessage( hwnd, WM_COPY, 0, 0 );
-    if( !clip_check( ) ) {
+    SendMessage (hwnd, WM_COPY, 0, 0);
+    if (!clip_check ()) {
 	rc = 0; 
 	goto leave;
     }
     /* Then the check if the window is an edit control */
-    wnd_msg_em_set_pos( hwnd, 0 );
-    SendMessage( hwnd, WM_COPY, 0, 0 );
-    if( !clip_check( ) ) {
+    wnd_msg_em_set_pos (hwnd, 0);
+    SendMessage (hwnd, WM_COPY, 0, 0);
+    if (!clip_check ()) {
 	rc = 0; 
 	goto leave;
     }
 	
     /* The last try is to send a mark all and copy to clipboard command */
-    wnd_msg_markall ();
+    wnd_msg_selectall ();
     wnd_msg_copy ();
-    if( !clip_check( ) )
+    if (!clip_check ())
 	rc = 0;
 
 leave:
-    AttachThreadInput( GetCurrentThreadId( ),					   
-			GetWindowThreadProcessId( hwnd, NULL ),				   
-			FALSE );
-    if( r_hotkey )
+    AttachThreadInput (GetCurrentThreadId (),
+		       GetWindowThreadProcessId (hwnd, NULL),
+		       FALSE);
+    if (r_hotkey)
 	*r_hotkey = 0; /* reset: we need this in any case */
-    
     return rc;
 }
 
 
 int
-set_window_contents( HWND old_hwnd, curr_wnd_ctx *ctx )
+set_window_contents (HWND old_hwnd, curr_wnd_ctx *ctx)
 {
-    HWND hwnd, lost;	
+    HWND hwnd, lost;
 	
     hwnd = ctx->focus;
-    if( IsIconic( ctx->main ) )
-	ShowWindow( hwnd, SW_SHOWNORMAL );
-    SetForegroundWindow( hwnd );
+    if (IsIconic (ctx->main))
+	ShowWindow (hwnd, SW_SHOWNORMAL);
+    SetForegroundWindow (hwnd);
 	
-    AttachThreadInput( GetCurrentThreadId( ),
-			GetWindowThreadProcessId( hwnd, NULL ),
-			TRUE );
+    AttachThreadInput (GetCurrentThreadId (),
+		       GetWindowThreadProcessId (hwnd, NULL),
+		       TRUE);
 	
-    lost = SetFocus( hwnd );
+    lost = SetFocus (hwnd);
 
-    wnd_msg_em_set_pos( hwnd, 0 );
+    wnd_msg_em_set_pos (hwnd, 0);
     wnd_msg_paste ();
-    wnd_msg_em_set_pos( hwnd, 1 );
+    wnd_msg_em_set_pos (hwnd, 1);
 	
     AttachThreadInput( GetCurrentThreadId(),
 			GetWindowThreadProcessId( hwnd, NULL ),

Modified: trunk/Src/wptGPG.cpp
===================================================================
--- trunk/Src/wptGPG.cpp	2006-08-01 16:37:11 UTC (rev 254)
+++ trunk/Src/wptGPG.cpp	2006-08-01 16:37:23 UTC (rev 255)
@@ -43,21 +43,23 @@
 #define GPG_REG_EXE	"gpgProgram"	/* registry name for the binary. */
 #define GPG_REG_HOME	"HomeDir"	/* registry name of the home dir. */
 
-struct gpg_watcher_s {
-    FILETIME	last_access;
+/* Context to monitor GPG file changes. */
+struct gpg_monitor_s {
+    FILETIME	last_access;	/* last write access. */
     FILETIME	access;
-    char	*object;
-    int		modified;
+    char	*object;	/* name of the object. */
+    char	*fpath_object;	/* full path to the object. */
+    int		modified;	/* 1 = modified. */
 };
+typedef struct gpg_monitor_s *gpg_monitor_t;
 
-
-/* XXX need to watch for gpg.conf due to the fact keyring entries could be changed */
-static const char * gpg_objs[] = {"pubring.gpg", "secring.gpg", "trustdb.gpg"};
-static gpg_watcher_s gpg_table[3];
+static const char *gpg_objs[] = {"pubring.gpg", "secring.gpg", "trustdb.gpg"};
+static gpg_monitor_s gpg_table[3];
 static int gpg_table_count = DIM (gpg_table);
 
-int idea_available = 0;
+int idea_available = 0;	/* if the IDEA extension is available. */
 
+
 static int check_keyring (char ** r_path);
 
 
@@ -104,8 +106,7 @@
    A value of NULL indicates an error. */
 char*
 get_gnupg_cfgfile (void)
-{    
-    char *p = NULL;
+{
     char *optfile = NULL;
     char *path = NULL;
     size_t nlen = 0;
@@ -120,7 +121,6 @@
     _snprintf (optfile, nlen, "%s\\"GPG_CONF, path);
 
     free_if_alloc (path);
-    free_if_alloc (p);
     return optfile;
 }
 
@@ -181,7 +181,7 @@
 /* Retrieve the first usable secret key from cache.
    If no usable was found, @ret_no_useable is 1. 
    Return value: the keyid of the secret key. */
-static char *
+static char*
 default_key_from_cache (int *ret_no_useable)
 {    
     gpgme_key_t key, pk;
@@ -211,8 +211,7 @@
    Return value: 0 on success. */
 int
 gnupg_load_config (void)
-{
-    int rc;
+{    
     gpg_optfile_t opt;
     gpg_option_t o;
     char *conf;
@@ -220,8 +219,7 @@
     conf = get_gnupg_cfgfile ();
     if (!conf)
 	return -1;
-    rc = parse_gpg_options (conf, &opt);
-    if (rc) {
+    if (parse_gpg_options (conf, &opt)) {
 	free_if_alloc (conf);
 	return -1;
     }
@@ -261,13 +259,12 @@
     gpg_optfile_t opt = NULL;
     gpg_option_t e;
     char *keyid = NULL, *optfile = NULL;
-    int no_usable=0, rc = 0;
+    int no_usable=0;
 
     optfile = get_gnupg_cfgfile ();
     if (!optfile)
 	return default_key_from_cache (&no_usable);
-    rc = parse_gpg_options (optfile, &opt);
-    if (rc) {
+    if (parse_gpg_options (optfile, &opt)) {
 	free_if_alloc (optfile);
 	return default_key_from_cache (&no_usable);
     }
@@ -396,8 +393,10 @@
 }
 
 
-int
-check_gnupg_cfgfile (const char *fname, int *r_secrings, int *r_pubrings)
+/* Count the keyring entries in the gpg.conf file.
+   Return value: 0 on success. */
+static int
+cfgfile_count_keyrings (const char *fname, int *r_secrings, int *r_pubrings)
 {
     gpg_optfile_t opt;    
     gpg_option_t e;
@@ -468,7 +467,7 @@
 	    return WPTERR_GPG_KEYRINGS;
 	rc = file_exist_check (optfile);
 	if (!rc && get_file_size (optfile) > 0) {
-	    rc = check_gnupg_cfgfile (optfile, &secrings, &pubrings);
+	    rc = cfgfile_count_keyrings (optfile, &secrings, &pubrings);
 	    if (!rc && secrings > 0 && pubrings > 0) {
 		free_if_alloc (optfile);
 		return 0; /* found two keyrings in the option file */
@@ -489,7 +488,7 @@
 
 
 static int
-create_gpg_options (void)
+create_gpg_conf (void)
 {
     FILE *fp;
     char *s, *optfile;
@@ -519,15 +518,14 @@
 {
     FILE *fp;
     char *p = NULL, *optfile = NULL;
-    int fsize, rc = 0;
+    int fsize;
 	
     optfile = get_gnupg_cfgfile ();
-    if (optfile == NULL)
+    if (!optfile)
 	return NULL;
     fsize = get_file_size (optfile);
     if (!fsize) {
-	rc = create_gpg_options ();
-	if (rc)
+	if (create_gpg_conf ())
 	    return NULL;
 	fsize = get_file_size (optfile);
     }
@@ -593,7 +591,7 @@
 set_gnupg_options (const char *buf, size_t buflen)
 {
     FILE *fp;	
-    char *optfile = NULL;
+    char *optfile;
 
     optfile = get_gnupg_cfgfile ();
     if (!optfile)
@@ -611,14 +609,29 @@
 }
 
 
-/*
- * Check if the line contains a valid GPG argument.
- */
+/* Check if the parameter for the option @buf is an existing file name.
+   Return value: 0 on success. */
 static int
+check_arg_file_exist (const char *buf)
+{
+    const char *s = "load-extension ";
+
+    /* XXX: this is a bit of a kludge because we just
+            detect errors for 'load-extension'. */
+    if (!strncmp (buf, s, strlen (s)))
+	buf += strlen (s);
+    else
+	return 0;
+    return file_exist_check (buf);
+}
+
+
+/* Check if the line contains a valid GPG argument. */
+static int
 check_line (const char *buf)
 {
     int j, len;
-    int rc = 0;
+    int rc;
 
     if (*buf == '#' || *buf == '\r' || *buf == '\n')
 	return 1;
@@ -628,71 +641,64 @@
 	if (!strncmp (valid_gpg_args[j], buf, len))
 	    rc = 1;
     }
-
     return rc;
 }
 
 
 int
-check_gnupg_options (const char *buf)
+check_gnupg_options (const char *buf, int showerr)
 {
     char line[1024];
-    int nbytes = 0;
+    int nbytes = 0, lineno=0;
     unsigned j;
 	
-    for ( j = 0; j<strlen( buf ) && j < sizeof(line); j++ ) {
+    for  (j = 0; j < strlen (buf) && j < sizeof (line); j++) {
 	line[nbytes++] = buf[j];
-	if ( buf[j] == '\n' || j == ( strlen( buf ) - 1 ) ) {
+	if (buf[j] == '\n' || j == (strlen (buf) - 1)) {
 	    line[nbytes] = '\0';
-	    if( !check_line( line ) ) {
-		msg_box( NULL, line, "options", MB_OK );
+	    lineno++;
+	    if (!check_line (line)) {
+		if (showerr)
+		    log_box ("GPG Config File", MB_ERR, 
+			     "gpg.conf:%d: invalid keyword '%s'",
+			     lineno, line);
 		return 1;	
 	    }
+	    if (check_arg_file_exist (line))
+		return WPTERR_FILE_EXIST;
 	    nbytes = 0;
-	}	
+	}
     }
-
     return 0;
 }
 
 
 /* Store the last access of the file inside the watcher @ctx. */
 static int
-get_last_gnupg_access (gpg_watcher_s *ctx)
+get_last_gnupg_access (gpg_monitor_t ctx)
 {
     HANDLE fd;
-    char *path;
-    char *file;
 
-    path = get_gnupg_path ();
-    file =  make_filename (path, ctx->object, NULL);
-    fd = CreateFile (file, GENERIC_READ, FILE_SHARE_READ, NULL, 
-		     OPEN_ALWAYS, 0, NULL);
-    if (fd == INVALID_HANDLE_VALUE) {
-	free_if_alloc (path);
-	free_if_alloc (file);
+    fd = CreateFile (ctx->fpath_object, GENERIC_READ, FILE_SHARE_READ, 
+		     NULL, OPEN_ALWAYS, 0, NULL);
+    if (fd == INVALID_HANDLE_VALUE)
 	return WPTERR_FILE_OPEN;
-    }
     GetFileTime (fd, NULL, NULL, &ctx->access);
     CloseHandle (fd);
-    free_if_alloc (path);
-    free_if_alloc (file);
     return 0;
 }
 
 
 /* Check if the file inside watcher @ctx was modified. */
 static void
-check_last_gnupg_access (gpg_watcher_s *ctx)
+check_last_gnupg_access (gpg_monitor_t ctx)
 {		
     ctx->modified = 0;
 
     if (ctx->last_access.dwHighDateTime != ctx->access.dwHighDateTime &&
 	ctx->last_access.dwLowDateTime != ctx->access.dwLowDateTime)
 	ctx->modified = 1;
-    
-    /* XXX: find a better way. without it, winpt --keymanager loads
-            the key cache twice. */
+
     if (ctx->last_access.dwLowDateTime == 0)
 	ctx->modified = 0;
 
@@ -701,47 +707,54 @@
 }
 
 
-/* Init GPG watcher table for all monitored files. */
+/* Init GPG monitor table for all monitored files. */
 void
 init_gnupg_table (void)
 {	
-    char *p;
+    char *path;
     int j;
 
+    path = get_gnupg_path ();
     for (j = 0; j < gpg_table_count; j++) {
-	p = gpg_table[j].object = m_strdup (gpg_objs[j]);
+	gpg_table[j].object = m_strdup (gpg_objs[j]);
+	gpg_table[j].fpath_object = make_filename (path, gpg_objs[j], NULL);
 	memset (&gpg_table[j].access, 0, sizeof (FILETIME));
 	memset (&gpg_table[j].last_access, 0, sizeof (FILETIME));
 	gpg_table[j].modified = 0;
     }
+    free_if_alloc (path);
 }
 
 
+/* Release the GPG monitor table. */
 void
 free_gnupg_table (void)
 {
     int j;
 
-    for (j=0; j < gpg_table_count; j++)
+    for (j=0; j < gpg_table_count; j++) {
 	free_if_alloc (gpg_table[j].object);
+	free_if_alloc (gpg_table[j].fpath_object);
+    }
 }
 
 
 /* Return the amount of files modified since the last call. */
 int
 keyring_check_last_access (void)
-{	
-    int rc, j;
+{
+    int nfiles;
+    int pos;
 
-    rc = 0;
-    for (j = 0; j < gpg_table_count; j++) {
-	get_last_gnupg_access (&gpg_table[j]);
-	check_last_gnupg_access (&gpg_table[j]);
-	if (gpg_table[j].modified)
-	    rc++;	
+    nfiles = 0;
+    for (pos = 0; pos < gpg_table_count; pos++) {
+	get_last_gnupg_access (&gpg_table[pos]);
+	check_last_gnupg_access (&gpg_table[pos]);
+	if (gpg_table[pos].modified)
+	    nfiles++;
     }
 
-    return rc;
+    return nfiles;
 }
 
 
@@ -764,7 +777,8 @@
 	    *r_type = PGP_SIG;
 	return "SIGNED";
     }
-    else if  (!stricmp (file_ext, ".gpg") || !stricmp (file_ext, ".pgp")) {
+    else if  (!stricmp (file_ext, ".gpg") || 
+	      !stricmp (file_ext, ".pgp")) {
 	if (r_type) 
 	    *r_type = PGP_MESSAGE;
 	return "ENCRYPTED";
@@ -774,12 +788,12 @@
 
 
 char*
-get_gnupg_keyring_from_options (const char * fname, int pub)
+get_gnupg_keyring_from_options (const char *fname, int pub)
 {
     gpg_optfile_t opt;
     gpg_option_t e;
-    char * kring = NULL;
-    int rc = 0;
+    char *kring = NULL;
+    int rc;
 
     rc = parse_gpg_options (fname, &opt);
     if (rc)
@@ -796,12 +810,12 @@
 }
 
 
-
-/* XXX: does not work with write-protected floppies */
+/* Check if the device file @fname is stored on, is write-protected. */
 static int
 my_access (const char *fname)
 {
     HANDLE hd;
+
     hd = CreateFile (fname, GENERIC_WRITE, FILE_SHARE_WRITE, 
 		     NULL, OPEN_EXISTING, 0, NULL);
     if (hd == INVALID_HANDLE_VALUE)
@@ -867,8 +881,8 @@
 int
 gnupg_check_homedir (void)
 {	
-    char *homedir = NULL;
-    int val = 0;
+    char *homedir;
+    int val;
     int rc = 0;
 
     homedir = get_reg_entry_gpg (GPG_REG_HOME);
@@ -895,8 +909,8 @@
 int
 gnupg_copy_keyrings (void)
 {
-    const char * pring, * sring;
-    char * file = NULL, * path = NULL;
+    const char *pring, *sring;
+    char *file = NULL, *path = NULL;
     int id = 0, rc = 0;
     HWND hwnd;
     
@@ -957,8 +971,8 @@
 void
 gnupg_backup_options (void)
 {
-    char *cfgfile = NULL;
-    char bak[512];
+    char *cfgfile;
+    char bak[MAX_PATH+32];
 
     cfgfile = get_gnupg_cfgfile ();
     if (!cfgfile)
@@ -977,11 +991,7 @@
     BOOL rc;
 
     src = make_filename (srcpath, srcn, "gpg");
-    if (!src)
-        BUG (NULL);
     dst = make_filename (dstpath, dstn, "gpg");
-    if (!dst)
-        BUG (NULL);
     rc = CopyFile (src, dst, FALSE);
     free_if_alloc (src);
     free_if_alloc (dst);
@@ -1005,7 +1015,7 @@
     if (!*r_path)
 	return 0;
     p = make_filename (*r_path, "pubring", "gpg");
-    if (!p || get_file_size (p) <= 0)
+    if (get_file_size (p) <= 0)
 	return 0;
 
     opt = get_gnupg_cfgfile ();
@@ -1081,7 +1091,7 @@
 	else {
 	    rc = 0;
 	    fclose (fp);
-	    remove (tmpfile);
+	    DeleteFile (tmpfile);
 	}
 	free_if_alloc (tmpfile);
 	if (!fp || rc == IDCANCEL)
@@ -1101,36 +1111,6 @@
 }
 
 
-/* Display GPG error from file if possible. */
-void
-gnupg_display_error (void)
-{	
-    char tmpath[512], *errstr;
-    size_t size = 0;
-    FILE *fp;
-
-    get_temp_name (tmpath, sizeof (tmpath), "gpg_stderr");
-    size = get_file_size (tmpath);
-    if (file_exist_check (tmpath) || size <= 0)
-	return;
-    fp = fopen( tmpath, "rb" );
-    if (!fp) {
-	msg_box (NULL, _("No GPG error description available."),
-		 _("GPG Error"), MB_INFO);
-	return;
-    }
-    errstr = new char[size+1];
-    if (!errstr)
-	BUG (0);
-    fread (errstr, 1, size, fp);
-    errstr[size] = '\0';
-    fclose (fp);
-    msg_box (NULL, errstr, _("GPG Error"), MB_INFO);
-    free_if_alloc (errstr);
-}
-
-
-
 /* check that the requested GPG keyring exist and.
    Return value: 0 for success. */
 int

Modified: trunk/Src/wptGPGME.cpp
===================================================================
--- trunk/Src/wptGPGME.cpp	2006-08-01 16:37:11 UTC (rev 254)
+++ trunk/Src/wptGPGME.cpp	2006-08-01 16:37:23 UTC (rev 255)
@@ -58,8 +58,8 @@
 void
 keycache_release (int cleanup)
 {
+    char tmpbuf[64];
     int n = gpg_keycache_get_size (pub);
-    char tmpbuf[64];
 
     /* XXX: update the value when the cache has changed. */
     sprintf (tmpbuf, "%d", n);

Modified: trunk/Src/wptGPGOptDlg.cpp
===================================================================
--- trunk/Src/wptGPGOptDlg.cpp	2006-08-01 16:37:11 UTC (rev 254)
+++ trunk/Src/wptGPGOptDlg.cpp	2006-08-01 16:37:23 UTC (rev 255)
@@ -72,7 +72,7 @@
                 return FALSE;		
             }
             optbuf[nbytes] = '\0';
-            if( check_gnupg_options( optbuf ) ) {
+            if( check_gnupg_options( optbuf, 1 ) ) {
                 msg_box( dlg, _("File contains invalid GnuPG keywords!"), _("GPG Config"), MB_ERR );
                 free_if_alloc( optbuf );
                 return FALSE;

Modified: trunk/Src/wptKeyManager.cpp
===================================================================
--- trunk/Src/wptKeyManager.cpp	2006-08-01 16:37:11 UTC (rev 254)
+++ trunk/Src/wptKeyManager.cpp	2006-08-01 16:37:23 UTC (rev 255)
@@ -843,9 +843,8 @@
     gpgme_error_t rc;
     GPGME *ctx;
     struct keycache_s *c;
-    char *fname;
-    int pos;
-    int n;
+    char *fname, *uid;
+    int pos, n;
 
     if (listview_count_items (lv, 1) > 1) {
 	msg_box (dlg, _("Please only select one key."), 
@@ -858,11 +857,11 @@
 	return WPTERR_GENERAL;
     }
     key = km_get_key_ptr (lv, pos, &c);
-
-    n = strlen (c->uids->name)+1 + MAX_PATH + 5;
+    uid = m_strdup (c->uids->name);
+    secure_filename (uid, strlen (uid));
+    n = strlen (uid) + 1 + MAX_PATH + 5;
     fname = new char[n+1];
-    get_temp_name (fname, n-5, c->uids->name);
-    secure_filename (fname, strlen (fname));
+    get_temp_name (fname, n-5-strlen (uid)-1, uid);
     strcat (fname, ".asc");
     ctx = new GPGME ();
     ctx->setArmor (true);
@@ -874,13 +873,14 @@
 
     delete ctx;
     free_if_alloc (fname);
+    free_if_alloc (uid);
     return rc;
 }
 
 
 /* Refresh the selected key in the listview @lv at position @pos.
    Legal flags are 0 = single key. */
-static void
+static int
 km_refresh_one_key (listview_ctrl_t lv, HWND dlg, int pos, int flags)
 {
     winpt_key_s pk;
@@ -913,6 +913,7 @@
 	if (!flags && !err)
 	    keycache_update (0, keyid);
     }
+    return err;
 }
 
 
@@ -920,7 +921,8 @@
 int
 km_refresh_from_keyserver (listview_ctrl_t lv, HWND dlg)
 {
-    int cnt, id, i;    
+    int cnt, id, i;
+    int err = 0;
 
     cnt = listview_count_items (lv, 0);
     if (listview_count_items (lv, 1) == cnt) {
@@ -935,14 +937,14 @@
 	}
     }
     if (listview_count_items (lv, 1) == 1)
-	km_refresh_one_key (lv, dlg, listview_get_curr_pos (lv), 0);
+	err = km_refresh_one_key (lv, dlg, listview_get_curr_pos (lv), 0);
     else {
 	for (i=0; i < cnt; i++) {
 	    if (listview_get_item_state (lv, i))
 		km_refresh_one_key (lv, dlg, i, KM_KS_REFRESH);	
 	}
     }
-    return 0;
+    return err;
 }
 
 

Modified: trunk/Src/wptKeyManagerDlg.cpp
===================================================================
--- trunk/Src/wptKeyManagerDlg.cpp	2006-08-01 16:37:11 UTC (rev 254)
+++ trunk/Src/wptKeyManagerDlg.cpp	2006-08-01 16:37:23 UTC (rev 255)
@@ -993,8 +993,9 @@
     set_menu_text (menu, ID_KEYMISC_EXPORT, _("&Export..."));
     set_menu_text (menu, ID_KEYMISC_IMPORT, _("&Import..."));
     set_menu_text (menu, ID_KEYMISC_PROPS, _("&Properties"));
-    set_menu_text (menu, ID_KEYMISC_GPGOPT, _("Options"));
-    set_menu_text (menu, ID_KEYMISC_GPGPREFS, _("Preferences"));
+    set_menu_text (menu, ID_KEYMISC_GPGOPT, _("GPG &Options"));
+    set_menu_text (menu, ID_KEYMISC_GPGPREFS, _("&GPG Preferences"));
+    set_menu_text (menu, ID_KEYMISC_WINPTPREFS, _("&WinPT Preferences"));
     set_menu_text (menu, ID_KEYMISC_SENDRECV, _("Keyserver") );
     set_menu_text (menu, ID_KEYMISC_EXPORT_PRIVKEY, _("E&xport Secret Key"));
     set_menu_text (menu, ID_KEYMISC_RECACHE, _("Re&load Key Cache"));
@@ -1638,15 +1639,11 @@
 	break;
 
     case WM_INITMENUPOPUP:
-	if ((UINT)LOWORD (lparam) == 3) {
-	    HMENU h = (HMENU)wparam;
-	    set_menu_text_bypos (h, 0, _("New"));
-	}
-	/* XXX: before we can use it, we need to find a way to
-	        update the gpg access timestamp after each operation.
-	if (keyring_check_last_access ())
-	    reload_keylist (kmi);
-	*/
+	hm = (HMENU)wparam;
+	if ((UINT)LOWORD (lparam) == 3)
+	    set_menu_text_bypos (hm, 0, _("New"));
+	else if ((UINT)LOWORD (lparam) == 1)
+	    set_menu_text_bypos (hm, 8, _("Preferences..."));
 	return FALSE;
 
     case WM_COMMAND:
@@ -1821,6 +1818,12 @@
 	    refresh_keylist (kmi);
             return TRUE;
             
+	case ID_KEYMISC_WINPTPREFS:
+	    dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_PREFS,
+			      dlg, prefs_dlg_proc, 0,
+			      _("WinPT Preferences"), 0);
+	    break;
+
         case ID_KEYMISC_GPGPREFS:
             rc = dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GPGPREFS, 
 				   dlg, gpgprefs_dlg_proc, 0, 
@@ -1906,6 +1909,11 @@
 			      IDS_WINPT_ABOUT);
 	    break;
 
+	case ID_KEYMISC_DEVWWW:
+	    ShellExecute (dlg, "open", "http://wald.intevation.org/projects/winpt",
+			  NULL, NULL, SW_SHOW);
+	    break;
+
 	case ID_KEYMISC_WEBSITE:
 	    ShellExecute (dlg, "open", "http://www.winpt.org", 
 			  NULL, NULL, SW_SHOW);

Modified: trunk/Src/wptKeysigDlg.cpp
===================================================================
--- trunk/Src/wptKeysigDlg.cpp	2006-08-01 16:37:11 UTC (rev 254)
+++ trunk/Src/wptKeysigDlg.cpp	2006-08-01 16:37:23 UTC (rev 255)
@@ -113,6 +113,22 @@
 }
 
 
+/* Initialize a datepicker control with the time given in @t. */
+static void
+init_datepicker_from_time (HWND picker, time_t t)
+{
+    SYSTEMTIME st;
+    struct tm *tm;
+
+    tm = localtime (&t);
+    memset (&st, 0, sizeof st);
+    st.wYear = tm->tm_year+1900;
+    st.wMonth = tm->tm_mon+1;
+    st.wDay = tm->tm_mday;
+    DateTime_SetSystemtime (picker, GDT_VALID, &st);
+}
+
+
 /* Dialog box procedure to display the signature properties. */
 BOOL CALLBACK
 sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
@@ -142,6 +158,7 @@
 	SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));
 	SetDlgItemText (dlg, IDC_SIGPROPS_CLASSINF, _("Class"));
 	SetDlgItemText (dlg, IDC_SIGPROPS_EXPSTR, _("Expire date"));
+	SetDlgItemText (dlg, IDC_SIGPROPS_CREATSTR, _("Creation date"));
 	SetDlgItemText (dlg, IDC_SIGPROPS_KEYINF, _("Issuer key"));
 	SetDlgItemText (dlg, IDC_SIGPROPS_KEYIDINF, _("Issuer key ID"));
 	SetDlgItemText (dlg, IDC_SIGPROPS_POLICINF, _("Policy URL"));
@@ -175,25 +192,17 @@
 	else
 	    s = _("  user ID not found");
 	SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, s);
+
+	init_datepicker_from_time (GetDlgItem (dlg, IDC_SIGPROPS_CREATDATE),
+				    ks->timestamp);
 	if (ks->expires == 0) {
 	    ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE);
 	    ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE);
 	}
 	else {
-	    SYSTEMTIME st;
-	    struct tm *tm;
-	    time_t now = time (NULL);
-	    time_t tmp = ks->expires;
-
-	    tm = localtime (&tmp);
-	    memset (&st, 0, sizeof st);
-	    st.wYear = tm->tm_year+1900;
-	    st.wMonth = tm->tm_mon+1;
-	    st.wDay = tm->tm_mday;
-	    DateTime_SetSystemtime (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE),
-				    GDT_VALID, &st);
-
-	    if (now > ks->expires)
+	    init_datepicker_from_time (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE),
+					ks->expires);
+	    if (time (NULL) > ks->expires)
 		ctx.expired = 1;
 	    if (ctx.expired)
 		CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED);

Modified: trunk/Src/wptKeysignDlg.cpp
===================================================================
--- trunk/Src/wptKeysignDlg.cpp	2006-08-01 16:37:11 UTC (rev 254)
+++ trunk/Src/wptKeysignDlg.cpp	2006-08-01 16:37:23 UTC (rev 255)
@@ -290,6 +290,41 @@
 }
 
 
+/* Display all needed information about the key @key in the dialog @dlg. */
+static void
+display_keyinfo (HWND dlg, winpt_key_t key)
+{
+    gpgme_data_t kinf;
+    struct native_uid_s *u;
+    char tmp[256], *p;
+    size_t len;
+
+    gpgme_data_new (&kinf);
+    _snprintf (tmp, sizeof (tmp) -1,
+                   _("pub %d/0x%s  created: %s    expires: %s\n\n"
+                     "Primary key fingerprint: %s\n\n"),
+                   key->ctx->subkeys->length,
+		   key->ctx->subkeys->keyid+8,
+                   get_key_created (key->ctx->subkeys->timestamp),
+		   get_expire_date (key->ctx),
+                   get_printable_fpr (key->ctx->subkeys->fpr));
+    gpgme_data_write (kinf, tmp, strlen (tmp));
+    for (len=0, u = key->ext->uids; u; u = u->next, len++) {
+	if (len > 2)
+	    break;
+	gpgme_data_write (kinf, "\t\"", 2);
+	gpgme_data_write (kinf, u->uid, strlen (u->uid));
+	gpgme_data_write (kinf, "\"\n", 2);
+    }
+    p = (char*)_("\n\nAre you really sure that you want to sign this key with YOUR key?\n");
+    gpgme_data_write (kinf, p, strlen (p));
+    gpgme_data_write (kinf, "\0", 1);
+    p = gpgme_data_release_and_get_mem (kinf, &len);
+    SetDlgItemText (dlg, IDC_KEYSIGN_INFOS, p);
+    gpgme_free (p);
+}
+
+
 /* Dialog box procedure to sign a key. */
 BOOL CALLBACK
 keysign_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
@@ -299,7 +334,7 @@
     gpgme_error_t err;
     gpgme_key_t k;
     SYSTEMTIME st;
-    char keymsg[2048], *pwd;
+    char keymsg[64], *pwd;
     const char *keyid, *s;
     int type, expires=0, idx;
     int sig_class = 0;
@@ -308,18 +343,7 @@
     case WM_INITDIALOG:
         key = (winpt_key_t) lparam;
 	if (!key)
-	    BUG (0);
-        _snprintf (keymsg, sizeof keymsg -1,
-                   _("pub %d/%s  created: %s    expires: %s\n\n"
-                     "Primary key fingerprint: %s\n\n"
-                     "\t%s\n\n"
-                     "\nAre you really sure that you want to sign this key with YOUR key?\n"),
-                   key->ctx->subkeys->length,
-		   key->ctx->subkeys->keyid+8,
-                   get_key_created (key->ctx->subkeys->timestamp),
-		   get_expire_date (key->ctx),
-                   get_printable_fpr (key->ctx->subkeys->fpr),
-                   key->ext->uids->uid);
+	    BUG (0);        
 	s = key->ctx->subkeys->keyid;
 	if (do_fill_seckeylist (dlg, s)) {
 	    msg_box (dlg, _("No valid secret key found."), _("Key Signing"), MB_ERR);
@@ -327,7 +351,7 @@
 	    return TRUE;
 	}
 	do_check_protection (dlg);
-        SetDlgItemText (dlg, IDC_KEYSIGN_INFOS, keymsg);
+	display_keyinfo (dlg, key);
         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"));
@@ -343,8 +367,8 @@
 	EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_EXPIRES), FALSE);
 	if (reg_prefs.expert == 0)
 	    ShowWindow (GetDlgItem (dlg, IDC_KEYSIGN_NREV), SW_HIDE);
-	if (key->ext && key->ext->attrib.len > 0)
-	    EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_SHOWIMG), TRUE);
+	if (key->ext && key->ext->attrib.len == 0)
+	    ShowWindow (GetDlgItem (dlg, IDC_KEYSIGN_SHOWIMG), SW_HIDE);
 	if (!reg_prefs.gpg.ask_cert_level)
 	    EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_ASKLEVEL), FALSE);
 	if (!reg_prefs.gpg.ask_cert_expire)
@@ -402,7 +426,8 @@
 		}
 		else
 		    expires = 1;
-		sprintf (keymsg, "%04d-%02d-%02d", st.wYear, st.wMonth, st.wDay);
+		_snprintf (keymsg, sizeof (keymsg)-1, "%04d-%02d-%02d", 
+			   st.wYear, st.wMonth, st.wDay);
 	    }
 
 	    /* XXX: check for --ask-cert-level and --ask-cert-expire in the gpg.conf

Modified: trunk/Src/wptMainProc.cpp
===================================================================
--- trunk/Src/wptMainProc.cpp	2006-08-01 16:37:11 UTC (rev 254)
+++ trunk/Src/wptMainProc.cpp	2006-08-01 16:37:23 UTC (rev 255)
@@ -43,11 +43,10 @@
 #include "wptUTF8.h"
 #include "wptKeyManager.h"
 #include "wptCard.h"
-#include "wptCryptdisk.h"
 #include "wptCardEdit.h"
 
 
-void update_keycache (HWND hwnd);
+int update_keycache (HWND hwnd);
 
 /* Command for the Key Manager dialog. (0=no command) */
 static int cmd = 0;
@@ -134,108 +133,69 @@
 }
 
 
-static gpgme_error_t
-currwnd_gpg_dlg (HWND hwnd, UINT id, int *ret_set)
+/* Handle the various command requests for the clipboard
+   and the current window. */
+static void
+clip_gpg_dlg (HWND hwnd, UINT id, int *r_upd_window)
 {
     gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);
     int type;
+    int disable_viewer = 0;
     
-    if (ret_set)
-	*ret_set = 1;
-    switch (id) {
-    case ID_WINPT_CURRWND_SYMENC:
-	gpg_clip_sym_encrypt ();
-	break;
-
-    case ID_WINPT_CURRWND_ENCRYPT:
-        dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd,
-                          clip_encrypt_dlg_proc, 0, 
-                          _("Encryption"), IDS_WINPT_ENCRYPT);
-        break;
-        
-    case ID_WINPT_CURRWND_SIGNENCRYPT:
-        dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd,
-                          clip_signenc_dlg_proc, 0, 
-                          _("Sign & Encrypt"), IDS_WINPT_SIGNENC );
-        break;
-        
-    case ID_WINPT_CURRWND_SIGN:
-        dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd,
-                          clip_sign_dlg_proc, 0, 
-                          _("Signing"), IDS_WINPT_SIGN );
-        break;
-        
-    case ID_WINPT_CURRWND_DECRYPT_VERIFY:
-	err = gpg_clip_get_pgptype (&type);
-        if (err) {
-	    msg_box (hwnd, gpgme_strerror (err), _("Clipboard"), MB_ERR);
-            break;
-        }
-        if ((type & PGP_MESSAGE) && !(type & PGP_CLEARSIG)) {
-            /* It makes only sense to insert the data in the window if it's
-               really a ciphertext. Verfied data doesn't need this. */
-            err = clip_decrypt_dlg (hwnd, reg_prefs.use_viewer);
-            if (!err && ret_set)
-		*ret_set = 0;
-        }
-	else if ((type & PGP_PUBKEY) && !(type & PGP_CLEARSIG))
-	    km_clip_import (GetDesktopWindow (), NULL, NULL);
-        else {
-            dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,
-                              clip_verify_dlg_proc, 0, 
-                              _("Verify"), IDS_WINPT_VERIFY );
-            err  = gpg_error (GPG_ERR_EOF); /* make sure window is not updated. */
-        }
-        break;
+    if (r_upd_window) {
+	*r_upd_window = 1;
+	/* for the current window mode it makes no sense to
+	   use the clipboard viewer for decryption because the
+	   text will be pasted directly into the window. */
+	disable_viewer = 1;
     }
-    
-    return err;
-}
-
-
-static void
-clip_gpg_dlg (HWND hwnd, UINT id)
-{
-    gpgme_error_t err;
-    int type;
-    
     if ((id == ID_WINPT_SIGN || id == ID_WINPT_SIGNENCRYPT)
 	&& gnupg_access_keyring (0)) {
 	msg_box (hwnd, _("Could not access secret keyring."), _("Sign"), MB_ERR);
 	return;
     }
     
-    switch( id ) {
+    switch (id) {
     case ID_WINPT_SYMENC:
-        gpg_clip_sym_encrypt ();
+    case ID_WINPT_CURRWND_SYMENC:
+        err = gpg_clip_sym_encrypt ();
+	if (err && r_upd_window)
+	    *r_upd_window = 0;
         break;
         
     case ID_WINPT_ENCRYPT:
-        dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd, 
+    case ID_WINPT_CURRWND_ENCRYPT:
+        dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_ENCRYPT, hwnd, 
                           clip_encrypt_dlg_proc, 0,
-                          _("Encryption"), IDS_WINPT_ENCRYPT );
+                          _("Encryption"), IDS_WINPT_ENCRYPT);
         break;
         
     case ID_WINPT_SIGN:
-        dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd, 
+    case ID_WINPT_CURRWND_SIGN:
+        dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_SIGN, hwnd, 
                           clip_sign_dlg_proc, 0, 
-                          _("Signing"), IDS_WINPT_SIGN );
+                          _("Signing"), IDS_WINPT_SIGN);
         break;
         
     case ID_WINPT_SIGNENCRYPT:
-        dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd, 
+    case ID_WINPT_CURRWND_SIGNENCRYPT:
+        dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_SIGNENC, hwnd, 
                           clip_signenc_dlg_proc, 0, 
-                          _("Sign & Encrypt"), IDS_WINPT_SIGNENC );
+                          _("Sign & Encrypt"), IDS_WINPT_SIGNENC);
         break;
         
     case ID_WINPT_DECRYPT_VERIFY:
+    case ID_WINPT_CURRWND_DECRYPT_VERIFY:
 	err = gpg_clip_get_pgptype (&type);
 	if (err) {
-	    msg_box( hwnd, gpgme_strerror( err ), _("Clipboard"), MB_ERR );
+	    msg_box (hwnd, gpgme_strerror (err), _("Clipboard"), MB_ERR);
+	    if (r_upd_window)
+		*r_upd_window = 0;
 	    break;
 	}
-        if((type & PGP_MESSAGE) && !(type & PGP_CLEARSIG))
-            err = clip_decrypt_dlg (hwnd, reg_prefs.use_viewer);
+        if ((type & PGP_MESSAGE) && !(type & PGP_CLEARSIG))
+            err = clip_decrypt_dlg (hwnd, disable_viewer? 
+					  0 : reg_prefs.use_viewer);
         else if ((type & PGP_SIG) && !(type & PGP_CLEARSIG)) {
             text_input_s input;
             gpgme_data_t sig;
@@ -243,7 +203,9 @@
             memset (&input, 0, sizeof (input));
             err = gpg_data_new_from_clipboard (&sig, 0);
 	    if (err) {
-		msg_box (hwnd, gpgme_strerror( err ),_("Verify"), MB_ERR);
+		msg_box (hwnd, gpgme_strerror (err),_("Verify"), MB_ERR);
+		if (r_upd_window)
+		    *r_upd_window = 0;
 		return;
 	    }
             input.type = 0;
@@ -261,16 +223,26 @@
                 input.length = 0;
 		free_if_alloc (input.data);
             }
+	    if (r_upd_window)
+		*r_upd_window = 0;
         }
         else if (type & PGP_CLEARSIG) {
-            dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,
-                              clip_verify_dlg_proc, 0, 
-                              _("Verify"), IDS_WINPT_VERIFY );
+            dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_VERIFY, hwnd,
+                              clip_verify_dlg_proc, 0,
+                              _("Verify"), IDS_WINPT_VERIFY);
+	    if (r_upd_window)
+		*r_upd_window = 0;
         }
-        else if ((type & PGP_PUBKEY) || (type & PGP_SECKEY))
+        else if ((type & PGP_PUBKEY) || (type & PGP_SECKEY)) {
 	    km_clip_import (GetDesktopWindow (), NULL, NULL);
-        else
+	    if (r_upd_window)
+		*r_upd_window = 0;
+	}
+        else {
             msg_box (hwnd, _("Unknown OpenPGP type."), _("Clipboard"), MB_ERR);
+	    if (r_upd_window)
+		*r_upd_window = 0;
+	}
     }
 }
 
@@ -530,7 +502,7 @@
 			 _("Clipboard"), MB_ERR);
 		break;
 	    }
-            clip_gpg_dlg (hwnd, (int)wparam);
+            clip_gpg_dlg (hwnd, (int)wparam, NULL);
             break;
 
             /** Current window operations **/
@@ -547,8 +519,8 @@
 			winpt_strerror (WPTERR_CURR_WND));
                 break;
             }
-            rc = currwnd_gpg_dlg (hwnd, (UINT)wparam, &set_wc);
-            if (!rc && set_wc)
+            clip_gpg_dlg (hwnd, (int)wparam, &set_wc);
+            if (set_wc == 1)
                 set_window_contents (hwnd, &currwnd);
             break;
             

Modified: trunk/Src/wptPassphraseCB.cpp
===================================================================
--- trunk/Src/wptPassphraseCB.cpp	2006-08-01 16:37:11 UTC (rev 254)
+++ trunk/Src/wptPassphraseCB.cpp	2006-08-01 16:37:23 UTC (rev 255)
@@ -1,5 +1,5 @@
 /* wptPassphraseCB.cpp - GPGME Passphrase Callback
- *	Copyright (C) 2001, 2002, 2003, 2005, 2006 Timo Schulz
+ *	Copyright (C) 2001, 2002-2006 Timo Schulz
  *	Copyright (C) 2005 g10 Code GmbH
  *
  * This file is part of WinPT.
@@ -41,17 +41,18 @@
 #include "wptRegistry.h"
 #include "wptUTF8.h"
 
-const char* get_symkey_algo (int algo);
 
+/* Return the control ID dependent on the mode (sign or decrypt). */
 #define item_ctrl_id(cmd) \
     ((cmd) == GPG_CMD_DECRYPT? IDC_DECRYPT_PWD : IDC_DECRYPT_SIGN_PWD)
 
 #define item_ctrl_id2(cmd) \
     ((cmd) == GPG_CMD_DECRYPT? IDC_DECRYPT_HIDE : IDC_DECRYPT_SIGN_HIDE)
 
-
+const char* get_symkey_algo (int algo);
 void ListBox_AddString_utf8 (HWND lb, const char *txt);
 
+
 /* Overwrite passphrase and free memory. */
 static void
 burn_passphrase (char **pwd)
@@ -179,7 +180,6 @@
 
 	case WM_SYSCOMMAND:
 	    if (LOWORD (wparam) == SC_CLOSE) {
-		SetDlgItemText (dlg, item_ctrl_id (c->gpg_cmd), "");
 		c->cancel = 1;
 		EndDialog (dlg, TRUE);
 	    }
@@ -225,9 +225,9 @@
 		res = gpgme_op_decrypt_result (c->gpg);
 		if (!res)
 		    res_sig = gpgme_op_sign_result (c->gpg);		
-		if (reg_prefs.cache_time > 0 && !c->is_card &&
+		if (!c->is_card && reg_prefs.cache_time > 0 && 
 		    (res || res_sig)) {
-		    if (agent_get_cache (c->keyid, &item))			
+		    if (agent_get_cache (c->keyid, &item))
 			agent_unlock_cache_entry (&item);
 		    else 
 			agent_put_cache (c->keyid, c->pwd, reg_prefs.cache_time);
@@ -303,15 +303,15 @@
     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"),
+		   _("You need a passphrase to unlock the secret key for user:\n"
+		     "\"%s\"\n"
+		     "%s key, ID 0x%s (main key ID 0x%s)\n"),
 		   uid, 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"),
+		   _("You need a passphrase to unlock the secret key for user:\n"
+		     "\"%s\"\n"
+		     "%s key, ID 0x%s\n"),
 		     uid, get_key_pubalgo (algo), usedkey+8);
     safe_free (uid);
     return 0;

Modified: trunk/Src/wptW32API.cpp
===================================================================
--- trunk/Src/wptW32API.cpp	2006-08-01 16:37:11 UTC (rev 254)
+++ trunk/Src/wptW32API.cpp	2006-08-01 16:37:23 UTC (rev 255)
@@ -306,13 +306,15 @@
     char *p;
     size_t size = 0;
 
-    if( path && *path )
-	size += strlen( path );
-    if( file && *file )
-	size += strlen( file );
+    if (path && *path)
+	size += strlen (path);
+    if (file && *file)
+	size += strlen (file);
     if( ext && *ext )
 	size += strlen( ext );
     p = new char[size + 4];
+    if (!p)
+	BUG (0);
     memset( p, 0, size );
     if( path ) {
 	strcat( p, path );



More information about the Winpt-commits mailing list