[Winpt-commits] r121 - in trunk: . Include Po Src

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Mon Dec 12 12:20:00 CET 2005


Author: twoaday
Date: 2005-12-12 12:19:56 +0100 (Mon, 12 Dec 2005)
New Revision: 121

Added:
   trunk/Src/wptClipboard.cpp
   trunk/Src/wptGPGMEData.cpp
   trunk/Src/wptGroupManager.cpp
Removed:
   trunk/w32gpgme/
Modified:
   trunk/ChangeLog
   trunk/Include/ChangeLog
   trunk/Include/wptGPG.h
   trunk/Include/wptKeyManager.h
   trunk/Include/wptW32API.h
   trunk/Makefile.am
   trunk/Po/de.po
   trunk/Src/ChangeLog
   trunk/Src/Makefile.am
   trunk/Src/WinPT-en.rc
   trunk/Src/WinPT.cpp
   trunk/Src/resource.h
   trunk/Src/wptClipEditDlg.cpp
   trunk/Src/wptGPGUtil.cpp
   trunk/Src/wptKeyCache.cpp
   trunk/Src/wptKeyEditDlgs.cpp
   trunk/Src/wptKeyManager.cpp
   trunk/Src/wptKeyManagerDlg.cpp
   trunk/Src/wptListView.cpp
   trunk/Src/wptMAPI.cpp
   trunk/Src/wptMainProc.cpp
   trunk/Src/wptW32API.cpp
   trunk/configure.ac
Log:
2005-12-11  Timo Schulz  <ts at g10code.com>
 
        * wptW32API.cpp (get_file_version): New.
        * wptGPGUtil.cpp (create_process): Always hide window.
        * wptClipEditDlg.cpp (clipedit_dlg_proc): Use 'Close'
        instead of 'Exit'.
        * wptKeyManager.cpp (km_http_import): New filename
        generation code.
        (km_send_to_mail_recipient): Cleanups.
        * wptKeyEditDlg.cpp (showpref_dlg_proc): Localize dialog.
        * wptKeyManagerDlg.cpp (update_ui_items): Handle the case
        when multiple keys are selected.
        (popup_multiple): New.
        * WinPT.cpp (WinMain): Check that the PTD.dll and WinPT.exe
        file versions are equal. Rewrote --keymanager code.
         
Removed temporary w32gpgme dirctory, all code is now in Src.
Changed configure files.



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/ChangeLog	2005-12-12 11:19:56 UTC (rev 121)
@@ -1,3 +1,8 @@
+2005-12-11  Timo Schulz  <ts at g10code.com>
+
+	* configure.ac: Remove w32gpgme Makefile. It is not
+	needed any longer.
+	
 2005-11-25  Timo Schulz  <ts at g10code.com>
 
 	* config.h.in: Removed unused WINPT_IPC directive.

Modified: trunk/Include/ChangeLog
===================================================================
--- trunk/Include/ChangeLog	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Include/ChangeLog	2005-12-12 11:19:56 UTC (rev 121)
@@ -1,3 +1,7 @@
+2005-12-11  Timo Schulz  <ts at g10code.com>
+
+	* wptGPG.h: New prototypes.
+	
 2005-12-08  Timo Schulz  <ts at g10code.com>
 
 	* wptKeyEdit.h (cleanKey): New.

Modified: trunk/Include/wptGPG.h
===================================================================
--- trunk/Include/wptGPG.h	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Include/wptGPG.h	2005-12-12 11:19:56 UTC (rev 121)
@@ -21,7 +21,7 @@
 #ifndef WPT_GPG_H
 #define WPT_GPG_H
 
-#include "w32gpgme.h"
+#include <gpgme.h>
 #include "wptKeyCache.h"
 #include "wptNLS.h"
 
@@ -71,34 +71,34 @@
 };
 
 struct gpg_option_s {
-    struct gpg_option_s * next;
-    char * name;
-    char * val;
+    struct gpg_option_s *next;
+    char *name;
+    char *val;
     unsigned int used:1;
     int type;  
 };
-typedef struct gpg_option_s * gpg_option_t;
+typedef struct gpg_option_s *gpg_option_t;
 
 struct gpg_member_s {
     struct gpg_member_s * next;
-    char * name;
+    char *name;
     unsigned int used:1;  
 };
-typedef struct gpg_member_s * gpg_member_t;
+typedef struct gpg_member_s *gpg_member_t;
 
 struct gpg_group_s {
-    struct gpg_group_s * next;
-    struct gpg_member_s * list;
-    char * name;
+    struct gpg_group_s *next;
+    struct gpg_member_s *list;
+    char *name;
     unsigned int used:1;  
 };
-typedef struct gpg_group_s * gpg_group_t;
+typedef struct gpg_group_s *gpg_group_t;
 
 struct gpg_optfile_s {
-    struct gpg_option_s * list;
-    struct gpg_group_s * grp;
+    struct gpg_option_s *list;
+    struct gpg_group_s *grp;
 };
-typedef struct gpg_optfile_s * gpg_optfile_t;
+typedef struct gpg_optfile_s *gpg_optfile_t;
 
 
 struct passphrase_cb_s {
@@ -214,6 +214,21 @@
 char * get_key_userid (const char *keyid);
 int check_passwd_quality (const char *pass, int strict);
 
+/*-- wptClipboard.cpp --*/
+gpgme_error_t gpg_clip_istext_avail (int *r_val);
+gpgme_error_t gpg_clip_is_secured (int *r_type, int *r_val);
+gpgme_error_t gpg_clip_get_pgptype (int *r_type);
+gpgme_error_t gpg_clip_parse_pgpid (const char *data, int *r_type);
+
+/* wptGPGMEData.cpp --*/
+gpgme_error_t gpg_data_new_from_clipboard (gpgme_data_t *r_dh, int wraplen);
+void	     gpg_data_release_and_set_clipboard (gpgme_data_t dh, int chg_ver);
+size_t       gpg_data_readline (gpgme_data_t dh, char *line, size_t nbytes);
+
+gpgme_error_t gpg_data_release_and_set_file (gpgme_data_t dh, const char *fname);
+gpgme_error_t  gpg_data_mail_quote (gpgme_data_t *r_dh);
+gpgme_error_t  gpg_data_extract_plaintext (gpgme_data_t sig, gpgme_data_t *r_plain);
+
 /*-- wptGPGUtil.cpp --*/
 gpgme_error_t gpg_rebuild_cache (char **r_inf);
 gpgme_error_t gpg_get_version (char **r_inf);

Modified: trunk/Include/wptKeyManager.h
===================================================================
--- trunk/Include/wptKeyManager.h	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Include/wptKeyManager.h	2005-12-12 11:19:56 UTC (rev 121)
@@ -70,7 +70,7 @@
 int km_send_to_mail_recipient( listview_ctrl_t lv, HWND dlg );
 void km_refresh_from_keyserver(listview_ctrl_t lv, HWND dlg);
 void km_update_default_key_str( HWND dlg);
-void km_complete_status_bar( HWND sb, listview_ctrl_t lv);
+void km_update_status_bar( HWND sb, listview_ctrl_t lv);
 int km_check_if_protected( listview_ctrl_t lv, int pos );
 int km_enable_disable_key( listview_ctrl_t lv, HWND dlg, int pos, int enable );
 void km_set_clip_info( const char *uid );

Modified: trunk/Include/wptW32API.h
===================================================================
--- trunk/Include/wptW32API.h	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Include/wptW32API.h	2005-12-12 11:19:56 UTC (rev 121)
@@ -21,7 +21,7 @@
 #ifndef WPT_W32_API_H
 #define WPT_W32_API_H
 
-/*#include "wptCrypto.h"*/
+#include "wptCrypto.h"
 #include "wptUtil.h"
 
 struct reminder_ctx_s {
@@ -53,6 +53,8 @@
 int file_exist_check (const char *fname);
 int dir_exist_check (const char *dir);
 DWORD get_file_size (const char *fname);
+int get_file_version (const char *fname, WORD *major, WORD *minor,
+		      WORD *patch1, WORD *patch2);
 
 int get_window_contents( HWND old_hwnd, curr_wnd_ctx *ctx, int *r_hotkey );
 int set_window_contents( HWND old_hwnd, curr_wnd_ctx *ctx );

Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Makefile.am	2005-12-12 11:19:56 UTC (rev 121)
@@ -20,7 +20,7 @@
 
 EXTRA_DIST = autogen.sh README.SVN keyserver.conf
 
-SUBDIRS = Po Gnupg w32gpgme PTD Src Include Ico icons m4
+SUBDIRS = Po Gnupg PTD Src Include Ico icons m4
 
 dist-hook:
 	echo "$(VERSION)" > $(distdir)/VERSION

Modified: trunk/Po/de.po
===================================================================
--- trunk/Po/de.po	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Po/de.po	2005-12-12 11:19:56 UTC (rev 121)
@@ -2119,13 +2119,6 @@
 msgid "Please select one of the servers."
 msgstr "Bitte einen der Server auswählen."
 
-#, c-format
-msgid ""
-"Please update your PTD.dll to the newest version, the version (%s) you use "
-"is too old."
-msgstr ""
-"Bitte aktualisieren Sie Ihre PTD.dll auf die aktuelle Version, Ihre Version "
-"(%s) ist zu alt."
 
 # c:\oss\winpt-gpgme\src\wptCardDlg.cpp:649
 msgid "Please use plain ASCII charset for the fields."
@@ -2152,8 +2145,6 @@
 msgid "Primary user ID can not be deleted!"
 msgstr "Primäre Benutzerkennung kann nicht gelöscht werden!"
 
-msgid "Privacy Tray Dynamic (PTD)"
-msgstr "Privacy Tray Dynamic (PTD)"
 
 msgid "Protocol"
 msgstr "Protokoll"
@@ -3323,3 +3314,14 @@
 msgid "WARNING: multiple keys matched request.\n\n"
 msgstr "WARNUNG: Mehrere Schlüssel wurden gefunden.\n\n"
 
+msgid "MDC feature"
+msgstr "Unterstützt MDC"
+
+#, c-format
+msgid ""
+"The PTD.dll file has a different version than WinPT.exe\n"
+"Please update the PTD.dll to version %d.%d.%d"
+msgstr ""
+"Die PTD.dll Datei hat eine andere Version als WinPT.exe\n"
+"Bitte updaten Sie die PTD.dll auf die Version %d.%d.%d"
+

Modified: trunk/Src/ChangeLog
===================================================================
--- trunk/Src/ChangeLog	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/ChangeLog	2005-12-12 11:19:56 UTC (rev 121)
@@ -1,3 +1,19 @@
+2005-12-11  Timo Schulz  <ts at g10code.com>
+
+	* wptW32API.cpp (get_file_version): New.
+	* wptGPGUtil.cpp (create_process): Always hide window.
+	* wptClipEditDlg.cpp (clipedit_dlg_proc): Use 'Close'
+	instead of 'Exit'.
+	* wptKeyManager.cpp (km_http_import): New filename
+	generation code.
+	(km_send_to_mail_recipient): Cleanups.
+	* wptKeyEditDlg.cpp (showpref_dlg_proc): Localize dialog.
+	* wptKeyManagerDlg.cpp (update_ui_items): Handle the case
+	when multiple keys are selected.
+	(popup_multiple): New.
+	* WinPT.cpp (WinMain): Check that the PTD.dll and WinPT.exe
+	file versions are equal. Rewrote --keymanager code.
+	
 2005-12-08  Timo Schulz  <ts at g10code.com>
 
 	* wptKeyserverDlg.cpp (show_imported_keys): Enhanced.

Modified: trunk/Src/Makefile.am
===================================================================
--- trunk/Src/Makefile.am	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/Makefile.am	2005-12-12 11:19:56 UTC (rev 121)
@@ -14,7 +14,7 @@
 bin_PROGRAMS = WinPT
 EXTRA_DIST = versioninfo.rc.in 
 
-AM_CPPFLAGS = -I$(top_srcdir)/w32gpgme -I$(top_srcdir)/Include \
+AM_CPPFLAGS = -I$(top_srcdir)/Include \
               -I$(top_srcdir)/Gnupg -I$(top_srcdir)/PTD  \
               -DWIN32 -D_WINDOWS -D_MBCS
 AM_CFLAGS   = -fexceptions  $(GPGME_CFLAGS)
@@ -112,15 +112,18 @@
 	wptKeyEditCB.cpp \
         wptFileCBS.cpp \
 	wptKeyCache.cpp \
-        wptUtil.cpp
+        wptUtil.cpp \
+	wptClipboard.cpp \
+	wptGPGMEData.cpp \
+	wptGroupManager.cpp
 
 
 WinPT_SOURCES = $(resource_files) $(dialog_files) $(code_files)
-WinPT_LDADD = WinPT-en.o -L../w32gpgme -L../Gnupg\
-              -lw32gpgme -lgnupg ../PTD/PTD.dll \
+WinPT_LDADD = WinPT-en.o -L../Gnupg\
+              -lgnupg ../PTD/PTD.dll \
 	      $(GPGME_LIBS) $(W32LIBS) \
               -lcomctl32 -lkernel32 -luser32 -lcomdlg32 -ladvapi32 \
-              -lshell32 -lgdi32 -loleaut32
+              -lshell32 -lgdi32 -loleaut32 -lversion
 
 WinPT-en.o: $(resource_files)
 

Modified: trunk/Src/WinPT-en.rc
===================================================================
--- trunk/Src/WinPT-en.rc	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/WinPT-en.rc	2005-12-12 11:19:56 UTC (rev 121)
@@ -185,7 +185,7 @@
 FONT 8, "MS Sans Serif"
 BEGIN
     LTEXT           "Key Info Dummy",IDC_SHOWPREF_INFO,4,3,130,8
-    GROUPBOX        "Preferences",IDC_STATIC,2,31,136,87
+    GROUPBOX        "Preferences",IDC_SHOWPREF_PREFINF,2,31,136,87
     LTEXT           "Ciphers",IDC_STATIC,8,42,24,8
     LISTBOX         IDC_SHOWPREF_CIPHERS,8,50,61,60,LBS_NOINTEGRALHEIGHT | 
                     WS_VSCROLL | WS_TABSTOP
@@ -195,7 +195,7 @@
     LTEXT           "Compression",IDC_STATIC,72,80,41,8
     LISTBOX         IDC_SHOWPREF_ZIP,72,91,61,20,LBS_NOINTEGRALHEIGHT | 
                     WS_VSCROLL | WS_TABSTOP
-    DEFPUSHBUTTON   "OK",IDOK,88,122,50,14
+    DEFPUSHBUTTON   "&OK",IDOK,88,122,50,14
     CONTROL         "MDC feature",IDC_SHOWPREF_MDC,"Button",BS_AUTOCHECKBOX | 
                     BS_FLAT | WS_DISABLED | WS_TABSTOP,4,16,102,10
 END
@@ -322,7 +322,7 @@
     PUSHBUTTON      "Clea&r",IDC_CLIPEDIT_CLEAR,144,217,42,15
     PUSHBUTTON      "&Save",IDC_CLIPEDIT_SAVE,187,217,42,15
     PUSHBUTTON      "&Load",IDC_CLIPEDIT_LOAD,230,217,42,15
-    DEFPUSHBUTTON   "&Exit",IDOK,282,217,43,15
+    DEFPUSHBUTTON   "&Close",IDOK,282,217,43,15
 END
 
 IDD_WINPT_ENCRYPT DIALOG DISCARDABLE  0, 0, 354, 210
@@ -508,7 +508,7 @@
                     "Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,108,112,10
     CONTROL         "Sign &non-revocably",IDC_KEYSIGN_NREV,"Button",
                     BS_AUTOCHECKBOX | WS_TABSTOP,5,121,100,10
-    COMBOBOX        IDC_KEYSIGN_KEYLIST,5,135,232,49,CBS_DROPDOWNLIST | 
+    COMBOBOX        IDC_KEYSIGN_KEYLIST,5,135,192,49,CBS_DROPDOWNLIST | 
                     WS_VSCROLL | WS_TABSTOP
     LTEXT           "Passphrase",IDC_KEYSIGN_PWDINF,5,153,44,8
     EDITTEXT        IDC_KEYSIGN_PASSPHRASE,53,151,144,13,ES_PASSWORD | 
@@ -1058,8 +1058,8 @@
 CAPTION "Wipe Free Space"
 FONT 8, "MS Sans Serif"
 BEGIN
-    DEFPUSHBUTTON   "&OK",IDOK,106,192,50,14
-    PUSHBUTTON      "&Cancel",IDCANCEL,160,192,50,14
+    DEFPUSHBUTTON   "&OK",IDOK,106,195,50,14
+    PUSHBUTTON      "&Cancel",IDCANCEL,160,195,50,14
     LTEXT           "The procedure will overwrite the free space with random pattern of the specified drive to make sure that no sentensive data will remain. If you delete a file, the sections are marked as deleted but the data is still available and can be easily recovered.",
                     IDC_STATIC,12,23,192,43
     LTEXT           "Drive to wipe:",IDC_STATIC,12,140,44,8
@@ -1776,7 +1776,7 @@
         LEFTMARGIN, 4
         RIGHTMARGIN, 215
         TOPMARGIN, 3
-        BOTTOMMARGIN, 208
+        BOTTOMMARGIN, 211
     END
 
     IDD_WINPT_CONFDELCLIP, DIALOG

Modified: trunk/Src/WinPT.cpp
===================================================================
--- trunk/Src/WinPT.cpp	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/WinPT.cpp	2005-12-12 11:19:56 UTC (rev 121)
@@ -127,14 +127,15 @@
     if (defkey)
 	err = gpg_keycache_find_key (kc, defkey, 0, &key);
     else
-	msg_box (NULL, _("No useable secret key found."), _("WinPT Error"), MB_ERR);
+	msg_box (NULL, _("No useable secret key found."), 
+		 _("WinPT Error"), MB_ERR);
     free_if_alloc (defkey);
     return err? -1 : 0;
 }
 
 
 /* Return the WinPT program file name (with full pathname). */
-static const char *
+static const char*
 get_prog_part (const char * fname, int use_cwd)
 {
     static char program[512];
@@ -188,7 +189,7 @@
 	return rc;
     }
     /* We enable smartcard support for GPG: >= 2 or >= 1.4.3 */
-    if (ma > 1 || pa >= 3)
+    if (ma > 1 || pa >= 3)    
 	scard_support = 1;
 
     gpgver[0] = ma;
@@ -203,7 +204,7 @@
 static int
 load_keyserver_conf (int quiet)
 {
-    const char * t;
+    const char *t;
     int rc;
 
     if (reg_prefs.kserv_conf)
@@ -236,37 +237,58 @@
     reg_prefs.use_viewer = 0; /* XXX */
 }
 
-char* multi_gnupg_path (void);
 
-const char * fm_get_file_type (const char *fname, int *r_type);
-
 /* Main entry point. */
 int WINAPI
 WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd)
 {
     WNDCLASS wc = {0, winpt_main_proc, 0, 0, hinst, 0, 0, 0, 0, PGM_NAME};
     HACCEL accel_tab;
-    int rc, ec, created = 0, nfiles = 0;
+    MSG msg;
+    HWND hwnd = NULL;
+    WORD ver[3], ptdver[4];
+    int rc, ec, created = 0;
     int first_start = 0, start_gpgprefs = 0;
     int winpt_inst_found = 0;
+    int start_manager = 0;
     const char *s;
-    MSG msg;
-    HWND hwnd = NULL;
 
     glob_hinst = hinst;
-
     if (cmdline && stristr (cmdline, "--stop")) {
 	hwnd = FindWindow ("WinPT", "WinPT");
 	if (hwnd != NULL)
 	    PostMessage (hwnd, WM_DESTROY, 0, 0);
 	return 0;
     }
-    
-#ifdef _DEBUG
+
+    /*
+    OSVERSIONINFO osinf;
+    memset (&osinf, 0, sizeof (osinf));
+    if (GetVersionEx (&osinf) && 
+	osinf.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS &&
+	osinf.dwMinorVersion == 0) {
+	msg_box (NULL, "WinPT propably does not work on Windows 95 without restrictions",
+	         "WinPT Warning", MB_INFO);
+    }
+    */
+
+    #ifdef _DEBUG
     gpg_set_debug_mode (1);
     debug = 1;
-#endif
+    #endif
 
+    get_file_version ("WinPT.exe", &ver[0], &ver[1], &ver[2], &ver[3]);
+    get_file_version ("PTD.dll", &ptdver[0], &ptdver[1], 
+				 &ptdver[2], &ptdver[3]);
+    /* XXX
+    if (ptdver[0] != ver[0] || ptdver[1] != ver[1]|| ptdver[2] != ver[2]) {
+	log_box (_("WinPT Error"), MB_ERR, 
+		 _("The PTD.dll file has a different version than WinPT.exe\n"
+		   "Please update the PTD.dll to version %d.%d.%d"),
+		   ver[0], ver[1], ver[2]);
+	return 0;
+    }
+    */
     if (gpg_md_selftest ()) {
 	msg_box (NULL, _("Cryptographic selftest failed."),
 		 _("WinPT Error"), MB_ERR);
@@ -290,8 +312,8 @@
 	mobile = 1;
     }
 
-    load_gettext (winpt_inst_found);    
     set_default_kserver ();
+    load_gettext (winpt_inst_found);
 
     if (!mobile) {
 	regist_inst_gnupg (1);
@@ -320,17 +342,17 @@
 		   "Please check the GPG registry settings:\n%s."),
 		 winpt_strerror (rc));
 	s = get_fileopen_dlg (GetActiveWindow (),
-                              _("Select GPG Public Keyring"),
-                              _("GPG Keyrings (*.gpg)\0*.gpg\0\0"),
-                              NULL);
+			      _("Select GPG Public Keyring"),
+			      _("GPG Keyrings (*.gpg)\0*.gpg\0\0"),
+			      NULL);
 	if (s != NULL) {
 	    size_t n;
-	    char * p = strrchr (s, '\\');
+	    char *p = strrchr (s, '\\');
 	    if (!p)
 		BUG (0);
 	    n = p - s;
 	    if (n) {
-		char * file = new char[n+1];
+		char *file = new char[n+1];
 		if (!file)
 		    BUG (NULL);
 		memset (file, 0, n);
@@ -355,8 +377,7 @@
 			     "correct  this problem?"), _("WinPT Error"),
 			     MB_INFO|MB_YESNO) == IDYES)
 	    start_gpgprefs = 1;
-	else 
-	{
+	else {
 	    msg_box (NULL, winpt_strerror (rc), _("WinPT Error"), MB_ERR);
 	    return 0;
 	}
@@ -386,11 +407,10 @@
 	else if (rc)
 	    return 0;
     }
-
+    
     init_gnupg_table ();
 
-    nfiles = fm_parse_command_line (cmdline);
-    if (nfiles > 0) {
+    if (fm_parse_command_line (cmdline) > 0) {
 	free_gnupg_table ();
 	return 0;
     }
@@ -411,30 +431,15 @@
 	   to open the key manager. Otherwise start a new instance.
 	 */
 	HWND tray = FindWindow ("WinPT", "WinPT");
+	if (stristr (cmdline, "keymanager"))
+	    start_manager = ID_WINPT_KEY;
+	else
+	    start_manager = ID_WINPT_CARD;
 	if (tray != NULL) {
-	    PostMessage (tray, WM_COMMAND, ID_WINPT_KEY, 0);
+	    PostMessage (tray, WM_COMMAND, start_manager, 0);
 	    free_gnupg_table ();
 	    return 0;
 	}
-	update_keycache (GetDesktopWindow ());
-	if (stristr (cmdline, "keymanager"))
-	    dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYMISC,
-			    GetDesktopWindow(), keymanager_dlg_proc, 0,
-			    _("Key Manager"), IDS_WINPT_KEYMISC);  
-	else {
-	    gpg_card_t crd = gpg_card_load ();
-	    if (crd)
-		dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_CARD_EDIT,
-				  GetDesktopWindow(), card_edit_dlg_proc,
-				  (LPARAM)crd, _("Card Manager"),
-				  IDS_WINPT_CARD_EDIT);
-	    gpg_card_release (crd);
-	}
-	/*
-	keycache_release (0);
-	free_gnupg_table ();
-	return 0;
-	*/
     }
 
     /* If we found another WinPT instance, just quit to avoid it
@@ -446,7 +451,8 @@
     }
 
     if (cmdline) {
-	if (stristr (cmdline, "--enable-debug") || stristr (cmdline, "--debug")) {
+	if (stristr (cmdline, "--enable-debug") || 
+	    stristr (cmdline, "--debug")) {
 	    gpg_set_debug_mode (1);
 	    winpt_debug_msg ();
 	    debug = 1;
@@ -489,7 +495,6 @@
     
     if (start_gpgprefs) {
 	char *ring;
-
 	DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd,
 			gpgprefs_dlg_proc, 0);
 	ring = get_gnupg_keyring (0, !NO_STRICT);
@@ -558,7 +563,7 @@
 	    }
 	}
 	if (check_default_key (c)) {
-	    char * p = get_gnupg_default_key ();
+	    char *p = get_gnupg_default_key ();
 	    log_box (_("WinPT Error"), MB_ERR, 
 		     _("Default key from the GPG options file could not be found.\n"
 		       "Please check your gpg.conf (options) to correct this:\n\n"
@@ -573,6 +578,9 @@
 			    elgamal_warn_dlg_proc, 0);
     }
 
+    if (start_manager)
+	PostMessage (hwnd, WM_COMMAND, start_manager, 0);
+
     accel_tab = LoadAccelerators (glob_hinst, (LPCTSTR)IDR_WINPT_ACCELERATOR);
     keyring_check_last_access (); /* init */
     while (GetMessage (&msg, hwnd, 0, 0)) {

Modified: trunk/Src/resource.h
===================================================================
--- trunk/Src/resource.h	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/resource.h	2005-12-12 11:19:56 UTC (rev 121)
@@ -607,6 +607,7 @@
 #define IDC_IMPSTAT_NUIDINF             1493
 #define IDC_IMPSTAT_NSUBKINF            1494
 #define IDC_IMPSTAT_NSIGINF             1495
+#define IDC_SHOWPREF_PREFINF            1496
 #define ID_GPG_ENCRYPT                  40003
 #define ID_GPG_DECRYPT                  40004
 #define ID_GPG_SIGN                     40005
@@ -777,7 +778,7 @@
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        230
 #define _APS_NEXT_COMMAND_VALUE         40176
-#define _APS_NEXT_CONTROL_VALUE         1496
+#define _APS_NEXT_CONTROL_VALUE         1497
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif

Modified: trunk/Src/wptClipEditDlg.cpp
===================================================================
--- trunk/Src/wptClipEditDlg.cpp	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/wptClipEditDlg.cpp	2005-12-12 11:19:56 UTC (rev 121)
@@ -34,15 +34,14 @@
 
 #ifdef _MSC_VER
 #include "winpt_header.h"
-                                                                                
+
 static DWORD help_arr[] = {
-        IDC_CLIPEDIT_SEND,  WPT_CLIPEDIT_COPY,
-	IDC_CLIPEDIT_CLEAR, WPT_CLIPEDIT_CLEAR,
-	IDC_CLIPEDIT_LOAD,  WPT_CLIPEDIT_LOAD,
-	IDC_CLIPEDIT_SAVE,  WPT_CLIPEDIT_SAVE,
-	IDC_CLIPEDIT_QUOTE, WPT_CLIPEDIT_QUOTE,
-	0, 0
-};
+    IDC_CLIPEDIT_SEND,	WPT_CLIPEDIT_COPY,
+    IDC_CLIPEDIT_CLEAR,	WPT_CLIPEDIT_CLEAR,
+    IDC_CLIPEDIT_LOAD,	WPT_CLIPEDIT_LOAD,
+    IDC_CLIPEDIT_SAVE,	WPT_CLIPEDIT_SAVE,
+    IDC_CLIPEDIT_QUOTE,	WPT_CLIPEDIT_QUOTE,
+    0, 0};
 #endif
 
 /* Load the clipboard contents into the text field in @dlg.
@@ -190,6 +189,8 @@
 BOOL CALLBACK 
 clip_edit_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
 {
+    static DWORD cookie = 0;
+
     switch (msg)  {
     case WM_INITDIALOG:
 	SetWindowText (dlg, _("Clipboard Editor"));
@@ -198,13 +199,22 @@
 	SetDlgItemText (dlg, IDC_CLIPEDIT_LOAD, _("&Load"));	
 	SetDlgItemText (dlg, IDC_CLIPEDIT_SAVE, _("&Save"));
 	SetDlgItemText (dlg, IDC_CLIPEDIT_QUOTE, _("Add quotes")); 
-	SetDlgItemText (dlg, IDOK, _("&Exit"));
+	SetDlgItemText (dlg, IDOK, _("&Close"));
 
+	html_help_init (&cookie);
         load_clipboard (dlg);
 	center_window (dlg, NULL);
 	SetForegroundWindow (dlg);
 	return TRUE;
         
+    case WM_DESTROY:
+	html_help_deinit ();
+	break;
+
+    case WM_HELP:
+	html_help_dispatch (lparam, "winpt.chm::winpt_texts.txt", help_arr);
+	break;
+
     case WM_SYSCOMMAND:
 	if (LOWORD (wparam) == SC_CLOSE)
 	    EndDialog (dlg, TRUE);

Added: trunk/Src/wptClipboard.cpp
===================================================================
--- trunk/Src/wptClipboard.cpp	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/wptClipboard.cpp	2005-12-12 11:19:56 UTC (rev 121)
@@ -0,0 +1,319 @@
+/* wptClipboard.cpp
+ *	Copyright (C) 2001, 2002, 2003, 2005 Timo Schulz
+ *	Copyright (C) 2005 g10 Code GmbH
+ *
+ * This file is part of WinPT.
+ *
+ * WinPT is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * WinPT is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with WinPT; if not, write to the Free Software Foundation, 
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <windows.h>
+#include <gpgme.h>
+
+#include "wptW32API.h"
+#include "wptCrypto.h"
+#include "wptVersion.h"
+#include "wptGPG.h"
+
+gpgme_error_t gpg_data_wrap_lines (gpgme_data_t *r_dh, size_t wraplen);
+
+/* XXX: define clipboard errors. */
+
+/* Check if the clipboard contains text. @r_val contains
+   one text data is available.
+   Return value: 0 on success. */
+gpgme_error_t
+gpg_clip_istext_avail (int *r_val)
+{    
+    HANDLE clipmem;
+    char *clipdata;
+    
+    if (!r_val)
+	return gpg_error (GPG_ERR_INV_ARG);
+    if (OpenClipboard (NULL) == FALSE)
+	return gpg_error (GPG_ERR_NO_DATA);
+    
+    *r_val = 0;
+    clipmem = GetClipboardData (CF_TEXT);
+    if (!clipmem)
+	goto leave;
+
+    clipdata = (char *) GlobalLock (clipmem);
+    if (!clipdata)
+	goto leave;
+    if (strlen (clipdata) > 0)
+	*r_val = 1;
+    GlobalUnlock (clipmem);
+
+leave:
+    CloseClipboard ();
+    return 0;
+}
+
+
+/* Figure out what kind of PGP data is stored in @data.
+   @r_type contains the ORed types on success.
+   Return value: 0 on success. */
+gpgme_error_t
+gpg_clip_parse_pgpid (const char *data, int *r_type)
+{
+    int type;
+
+    if (!data)
+	return gpg_error (GPG_ERR_INV_ARG);
+    if (strlen (data) < 19) {
+	*r_type = 0;
+	return 0;
+    }
+    type = 0;
+    if (strstr( data, "BEGIN PGP MESSAGE") )
+	type |= PGP_MESSAGE;
+    if (strstr (data, "BEGIN PGP SIGNED MESSAGE"))
+	type |= PGP_CLEARSIG;
+    if (strstr (data, "BEGIN PGP SIGNATURE"))
+	type |= PGP_SIG;
+    if (strstr (data, "BEGIN PGP PUBLIC KEY BLOCK"))
+	type |= PGP_PUBKEY;
+    if (strstr (data, "BEGIN PGP PRIVATE KEY BLOCK") 
+	|| strstr (data, "BEGIN PGP SECRET KEY BLOCK"))
+	type |= PGP_SECKEY;
+    if (strstr (data, "- -----BEGIN"))
+	type |= PGP_DASH_ESCAPED;
+    *r_type = type;
+    return 0;
+}
+
+
+/* Check if the clipboard is already OpenPGP protected.
+   @r_type optional returns the type and @r_val contains
+   1 for yes.
+   Return value: 0 on success. */
+gpgme_error_t
+gpg_clip_is_secured (int *r_type, int *r_val)
+{
+    int rc = 0;
+    HANDLE clipmem;
+    char *clipdata;
+    
+    if (!r_val)
+	return gpg_error (GPG_ERR_INV_ARG);
+    if( OpenClipboard (NULL) == FALSE )
+	return gpg_error (GPG_ERR_INTERNAL);
+    clipmem = GetClipboardData( CF_TEXT );
+    if( !clipmem ) {
+	*r_val = 0;
+	goto leave;
+    }
+    clipdata = (char *) GlobalLock( clipmem );
+    if (!clipdata) {
+	*r_val = 0;	
+	goto leave;	
+    }
+    if (strstr (clipdata, "-----BEGIN PGP") 
+	&& strstr (clipdata, "-----END PGP"))
+	*r_val = 1;
+    GlobalUnlock (clipmem);
+    gpg_clip_parse_pgpid (clipdata, r_type);
+
+leave:
+    CloseClipboard ();
+    return rc;
+}
+
+
+gpgme_error_t
+gpg_clip_get_pgptype (int *r_type)
+{
+    gpgme_error_t rc = 0;
+    HANDLE clipmem;
+    char *clipdata;
+    
+    if (OpenClipboard (NULL) == FALSE)
+	return gpg_error (GPG_ERR_INTERNAL);
+    clipmem = GetClipboardData (CF_TEXT);
+    if (!clipmem) {
+	rc = gpg_error (GPG_ERR_NO_DATA);
+	goto leave;
+    }
+    clipdata = (char *)GlobalLock( clipmem );
+    if (!clipdata) {
+	rc = gpg_error (GPG_ERR_NO_DATA);
+	goto leave;
+    }    
+    gpg_clip_parse_pgpid (clipdata, r_type);
+    GlobalUnlock (clipmem);
+    
+leave:
+    CloseClipboard ();
+    return rc;
+}
+
+
+/* Retrieve the thext of the clipboard.
+   Return value: the text as a string, NULL otherwise. */
+static char*
+get_w32_clip_text (void)
+{
+    char *private_clip = NULL;
+    char *clip = NULL;
+    size_t size;
+    HANDLE cb;
+    
+    if (!OpenClipboard (NULL))
+        return NULL;
+    cb = GetClipboardData (CF_TEXT);
+    if (!cb)
+        goto leave;
+    private_clip = (char *)GlobalLock (cb);
+    if (!private_clip)
+        goto leave;
+    size = strlen (private_clip);
+    clip = (char*)malloc (size + 1);
+    if (!clip) {
+        GlobalUnlock (cb);
+        goto leave;
+    }
+    memcpy (clip, private_clip, size);
+    clip[size] = '\0';
+    GlobalUnlock(cb);
+    
+leave:
+    CloseClipboard ();
+    return clip;
+}
+
+
+/* Set the new clipboard data to @data. */
+static void
+set_w32_clip_text (const char *data, int size)
+{
+    HANDLE cb;
+    char *private_data;
+    
+    if (!OpenClipboard(NULL))
+	return;
+    EmptyClipboard ();
+    cb = GlobalAlloc (GHND, size+1);
+    if (!cb)
+        goto leave;
+    private_data = (char*)GlobalLock (cb);
+    if (!private_data)
+        goto leave;
+    memcpy (private_data, data, size);
+    private_data[size] = '\0';
+    SetClipboardData (CF_TEXT, cb);
+    GlobalUnlock (cb);
+    
+leave:    
+    CloseClipboard ();
+    GlobalFree (cb);
+}
+
+
+/* Retrieve the clipboard data and create a new gpgme
+   data object @r_dh and return it. If @wraplen is > 0
+   wrap lines of the buffer.
+   Return value: 0 on success. */
+gpgme_error_t
+gpg_data_new_from_clipboard (gpgme_data_t *r_dh, int wraplen)
+{
+    gpgme_error_t err = 0;
+    gpgme_data_t dh;
+    char *clip_text = NULL;
+
+    if (!r_dh)
+	return gpg_error (GPG_ERR_INV_ARG);
+    *r_dh = NULL;
+    clip_text = get_w32_clip_text ();
+    if (!clip_text)
+        return gpg_error (GPG_ERR_NO_DATA);
+    err = gpgme_data_new_from_mem (&dh, clip_text, strlen (clip_text), 1);
+    if (clip_text)
+	free (clip_text);
+    if (wraplen > 0)
+	gpg_data_wrap_lines (&dh, wraplen);
+    
+    *r_dh = dh;
+    return err;
+}
+
+
+/* Search for the armor header 'Version:' in @r_dh and
+   add the WinPT version. On success @r_dh is replaced
+   with the modified data.
+   Return value: 0 on success. */
+static gpgme_error_t
+gpg_data_change_version (gpgme_data_t *r_dh)
+{
+    gpgme_error_t err = 0;
+    gpgme_data_t mdh;
+    char line[128+32];
+    int n;
+
+    if (!r_dh)
+	return gpg_error (GPG_ERR_INV_ARG);
+    
+    err = gpgme_data_new (&mdh);
+    if (err)
+        return err;
+
+    gpgme_data_rewind (*r_dh);
+    while ((n=gpg_data_readline (*r_dh, line, 128)) > 0) {
+        if (strlen (line) > 14 &&
+            !strncmp (line, "Version: GnuPG", 14)  &&
+            !strstr (line, "WinPT "PGM_VERSION)) {
+            line[strlen (line) - 2] = '\0';
+            strcat (line, " - " );
+            strcat (line, "WinPT "PGM_VERSION);
+            strcat (line, "\r\n");
+        }
+	gpgme_data_write (mdh, line, strlen (line));
+    }
+
+    gpgme_data_write (mdh, "", 1);
+    gpgme_data_rewind (mdh);
+    gpgme_data_release (*r_dh);
+    *r_dh = mdh;
+    return err;
+}
+
+/* Release a gpgme data object @dh and write the contents of
+   the object to the clipboard. If @chg_ver is set, modify the
+   Version: header and add WinPT information. */
+void
+gpg_data_release_and_set_clipboard (gpgme_data_t dh, int chg_ver)
+{
+    gpgme_data_t in;
+    char *clip_text;
+    size_t n;
+    
+    if (!dh)
+	return;
+
+    in = dh;
+    if (chg_ver)
+	gpg_data_change_version (&in);
+
+    clip_text = gpgme_data_release_and_get_mem (in, &n);
+    if (clip_text && *clip_text) {
+        set_w32_clip_text (clip_text, n);
+	memset (clip_text, 0xFF, n);
+	gpgme_free (clip_text);
+    }
+}

Added: trunk/Src/wptGPGMEData.cpp
===================================================================
--- trunk/Src/wptGPGMEData.cpp	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/wptGPGMEData.cpp	2005-12-12 11:19:56 UTC (rev 121)
@@ -0,0 +1,224 @@
+#include <windows.h>
+#include <malloc.h>
+#include <string.h>
+#include <stdio.h>
+#include <gpgme.h>
+
+#include "wptUtil.h"
+#include "wptGPG.h"
+
+/* Implement a word based line break. @inp is the input buffer
+   and @wraplen is the maximal line length.
+   Return value: the wrapped buffer on success. */
+char*
+wrap_lines (char *inp, size_t inlen, size_t wraplen, size_t *r_len)
+{
+    char *out;
+    char *p, *inp_ptr;
+    int end_is_le=0, add_le=0;
+    size_t n;
+
+    inp[inlen] = 0;
+    if (inp[inlen-2] == '\r' && inp[inlen-1] == '\n')
+	end_is_le = 1;
+    out = (char *)calloc (1, 4*inlen/3+2+1);
+    if (!out)
+	return NULL;
+    n = 0;
+    inp_ptr = inp;
+    while ((p = strsep (&inp_ptr, " \n"))) {
+	if (strlen (p) == 0) {
+	    strcat (out, " ");
+	    n++;
+	    continue;
+	}
+	/* if we find an existing \r\n pair, we generate a break
+	   at the given position and reset the counter. */
+	if (p[strlen (p)-1] == '\r') {
+	    p[strlen (p)-1]=0;
+	    add_le=1;
+	}
+	else
+	    add_le=0;
+	if (n + strlen (p) > wraplen) {
+	    strcat (out, "\r\n");
+	    n = 0;
+	}
+	else if (n > 0 || add_le) {
+	    strcat (out, " ");
+	    n++;
+	}
+
+	n += strlen (p);
+	strcat (out, p);
+	if (add_le) {
+	    strcat (out, "\r\n");
+	    n = 0;
+	}
+    }
+    if (end_is_le)
+	strcat (out, "\r\n");
+    *r_len = strlen (out);
+    return out;
+}
+
+
+/* Wrap the lines of @r_dh with a line length of @wraplen.
+   @r_dh will be released and on success it contains the
+   handle to the wrapped data.
+   Return value: 0 on success. */
+gpgme_error_t
+gpg_data_wrap_lines (gpgme_data_t *r_dh, size_t wraplen)
+{	
+    gpgme_error_t err;
+    gpgme_data_t mdh;
+    char *raw = NULL;
+    char *p = NULL;
+    size_t nlen;
+    
+    err = gpgme_data_new (&mdh);
+    if (err)
+        return err;
+
+    raw = gpgme_data_release_and_get_mem (*r_dh, &nlen);
+    if (!raw) {
+	gpgme_data_release (mdh);
+	return gpg_error (GPG_ERR_INV_ARG);
+    }
+	
+    p = wrap_lines (raw, nlen, wraplen, &nlen);
+    if (p) {    
+	gpgme_data_write (mdh, p, nlen);    
+	gpgme_data_rewind (mdh);    
+	free (p);
+    }
+    gpgme_free (raw);
+    *r_dh = mdh;
+    return 0;
+}
+
+
+/* Prepend '> ' to each line into @r_dh. On success @r_dh
+   contains a handle to the quoted data. 
+   Return value: 0 on success. */
+gpgme_error_t
+gpg_data_mail_quote (gpgme_data_t *r_dh)
+{
+    gpgme_data_t dh;
+    char buf[128];
+
+    if (!*r_dh)
+	return gpg_error (GPG_ERR_INV_ARG);
+    gpgme_data_new (&dh);
+    while (gpg_data_readline (*r_dh, buf, 127)) {
+	gpgme_data_write (dh, "> ", 2);
+	gpgme_data_write (dh, buf, strlen (buf));
+    }
+    gpgme_data_release (*r_dh);
+    *r_dh = dh;
+    return 0;
+}
+
+
+/* Extract the plaintext data from the escaped data object @sig.
+   The plaintxt is stored in @r_plain.
+   Return value: 0 on success. */
+gpgme_error_t
+gpg_data_extract_plaintext (gpgme_data_t sig, gpgme_data_t *r_plain)
+{
+    gpgme_data_t plain;
+    gpgme_error_t err;
+    char line[128+32];
+    int pos = 0;
+    int sig_begin = 0;
+    
+    if (r_plain)
+	*r_plain = NULL;
+    err = gpgme_data_new (&plain);
+    if (err)
+        return err;
+    
+    while (gpg_data_readline (sig, line, 128) > 0) {
+        if (!strncmp (line, "-----BEGIN PGP SIGNED MESSAGE", 29) ||
+            !strncmp (line, "Version:", 8) ||
+            !strncmp (line, "Comment:", 8) ||
+            !strncmp (line, "Charset:", 8) ||
+            !strncmp (line, "Hash:", 5) ||
+	    !strncmp (line, "MessageID", 9))
+            continue;
+        if (strlen (line) <= 2)
+            break; /* parsed all headers, now we reached the body */
+    }
+    /* XXX handle multi dash escaped sequences */
+    while (gpg_data_readline (sig, line, 128) > 0 ) {
+        if (!strncmp( line, "-----BEGIN PGP SIGNATURE", 24))
+            break; /* end of plaintext */
+        if (!strncmp (line, "- -", 3))
+            pos = 2;
+	gpgme_data_write (plain, line+pos, strlen (line+pos));
+        pos = 0;
+    }
+    gpgme_data_write (plain, "", 1);
+    if (r_plain)
+	*r_plain = plain;
+    else
+	gpgme_data_release (plain);
+    return err;
+}
+
+
+/* Release the data in @dh and store the contents in the file @fname.
+   Return value: 0 on success. */
+gpgme_error_t
+gpg_data_release_and_set_file (gpgme_data_t dh, const char *fname)
+{
+    char *p = NULL;
+    FILE *fp;
+    size_t n;
+    
+    fp = fopen (fname, "wb");
+    if (fp == NULL)
+	return gpg_error (GPG_ERR_ENOENT);
+    
+    p = gpgme_data_release_and_get_mem (dh, &n);
+    if (p) {
+        fwrite (p, 1, n, fp);
+        fflush (fp);
+	memset (p, 0xFF, n);
+	gpgme_free (p);
+    }
+    fclose (fp);
+    return 0;
+}
+
+
+/* Try to read a line, terminated by \n from the given
+   gpgme data object @dh into @line. 
+   Return value: numbers of chars read. */
+size_t
+gpg_data_readline (gpgme_data_t dh, char *line, size_t nbytes)
+{
+    char ch = 0;
+    int nread = 0, pos = 0;
+
+    if (!dh)
+	return 0;
+    
+    memset (line, 0, nbytes);
+    while ((nread=gpgme_data_read (dh, &ch, 1)) > 0) {
+        if (!nread)
+            break;
+        if (ch == '\n') {
+            line[pos++] = ch;
+            line[pos++] = '\0';
+            break;
+        }
+        line[pos++] = ch;
+        if (pos > (int)nbytes) {
+            line[pos++] = '\0';
+            break;
+        }
+    }
+    
+    return pos;
+}

Modified: trunk/Src/wptGPGUtil.cpp
===================================================================
--- trunk/Src/wptGPGUtil.cpp	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/wptGPGUtil.cpp	2005-12-12 11:19:56 UTC (rev 121)
@@ -1,5 +1,6 @@
-/* wptGPGUtil.cpp - GPG helper functions
+/* wptGPGUtil.cpp - GPG util functions
  *	Copyright (C) 2005 g10 Code GmbH
+ *	Copyright (C) 2005 Timo Schulz
  *
  * This file is part of WinPT.
  *
@@ -17,6 +18,7 @@
  * along with WinPT; if not, write to the Free Software Foundation, 
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
+
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -24,10 +26,10 @@
 #include <windows.h>
 #include <sys/stat.h>
 
+#include "gpgme.h"
+#include "wptTypes.h"
 #include "wptErrors.h"
-#include "gpgme.h"
 
-
 #define NROFHEXDIGITS 2  
 /* Convert two hexadecimal digits from STR to the value they
    represent.  Returns -1 if one of the characters is not a
@@ -152,7 +154,7 @@
     len += 1;
     p = (char*)calloc (1, len+1);
     if (!p)
-	abort ();
+	BUG (NULL);
     len = ExpandEnvironmentStrings (path, p, len);
     if (!len) {
 	free (p);
@@ -180,7 +182,7 @@
         goto leave;
     result = (char*)calloc (1, (n1=nbytes+1));
     if (!result)
-        abort ();
+        BUG (NULL);
     if (RegQueryValueEx (key_handle, name, 0, &type, (BYTE*)result, &n1)) {
         free (result); 
 	result = NULL;
@@ -204,19 +206,22 @@
 create_tmpfile (const char *name)
 {    
     HANDLE out;
-    SECURITY_ATTRIBUTES sattr;
+    SECURITY_ATTRIBUTES sec_attr;
     char tmp[300]; 
 
-    memset (&sattr, 0, sizeof sattr);
-    sattr.bInheritHandle = TRUE;
-    sattr.lpSecurityDescriptor = NULL;
-    sattr.nLength = sizeof sattr;
+    memset (&sec_attr, 0, sizeof sec_attr);
+    sec_attr.bInheritHandle = TRUE;
+    sec_attr.lpSecurityDescriptor = NULL;
+    sec_attr.nLength = sizeof sec_attr;
 
     GetTempPath (sizeof (tmp)-1 - strlen (name)-1, tmp);
     strcat (tmp, name);
     out = CreateFile (tmp, GENERIC_READ|GENERIC_WRITE, 
-		      FILE_SHARE_WRITE, &sattr,
+		      FILE_SHARE_WRITE, &sec_attr,
 		      OPEN_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
+    if (out == INVALID_HANDLE_VALUE)
+	log_debug ("create_tmpfile: CreateFile failed ec=%d\r\n",
+		   (int)GetLastError ());
     return out;
 }
 
@@ -235,8 +240,11 @@
     sec_attr.bInheritHandle = TRUE;
     sec_attr.nLength = sizeof sec_attr;
 
-    if (!CreatePipe (&r, &w, &sec_attr, 4096))
+    if (!CreatePipe (&r, &w, &sec_attr, 4096)) {
+	log_debug ("create_in_pipe: CreatePipeFailed ec=%d\r\n", 
+		   (int)GetLastError ());
 	return NULL;
+    }
 
     WriteFile (w, dat, strlen (dat), &n, NULL);
     CloseHandle (w);
@@ -258,7 +266,7 @@
     n = GetFileSize (out, NULL);
     p = (char*)calloc (1, n+1);
     if (!p)
-	abort ();
+	BUG (NULL);
     ReadFile (out, p, n, &n, NULL);
     p[n] = 0;
     return p;
@@ -279,15 +287,16 @@
     memset (&si, 0, sizeof (si));
     si.cb = sizeof si;
     if (in || out)
-	si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
+	si.dwFlags = STARTF_USESTDHANDLES;
     if (out)
 	si.hStdOutput = out;
     if (in)
 	si.hStdInput = in;
+    si.dwFlags |= STARTF_USESHOWWINDOW;
     si.wShowWindow = SW_HIDE;
     if (!CreateProcess (NULL, (char*)cmd, NULL, NULL, TRUE, 0, 
-		        NULL, NULL, &si, &pi)) {
-	log_debug ("create_process: CreateProcess() failed ec=%d\r\n",
+			NULL, NULL, &si, &pi)) {
+	log_debug ("create_process: CreateProcess failed ec=%d\r\n", 
 		   (int)GetLastError ());
 	return -1;
     }
@@ -314,7 +323,7 @@
     cmd = (char*)calloc (1, strlen (p) + strlen (keyid) 
 			    + strlen (outfile) + 64 + 2);
     if (!cmd)
-	abort ();
+	BUG (NULL);
     sprintf (cmd, "%s --yes --output \"%s\" --export-secret-key %s", 
 	     p, outfile, keyid);
     if (create_process (cmd, NULL, NULL))
@@ -329,11 +338,11 @@
 }
 
 
-/* If EXPORTFLAG is 1, export the ownertrust data to the
-   buffer DATA. Otherwise import the ownertrust data from DATA.
+/* If @export is 1, export the ownertrust data to the
+   buffer @data. Otherwise import the ownertrust data from @data.
    Return value: 0 on success. */
 gpgme_error_t
-gpg_manage_ownertrust (char **data, int exportflag)
+gpg_manage_ownertrust (char **data, int do_export)
 {
     gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);
     HANDLE out = NULL, in = NULL;
@@ -347,11 +356,11 @@
 
     cmd = (char*)calloc (1, strlen (p) + 64 + 1);
     if (!cmd)
-	abort ();  
+	BUG (NULL);
     sprintf (cmd, "%s %s", p, 
-	     exportflag? "--export-ownertrust" : "--import-ownertrust");
+	     do_export? "--export-ownertrust" : "--import-ownertrust");
 
-    if (exportflag)
+    if (do_export)
 	out = create_tmpfile ("gpg_ot_out");
     else {
 	DWORD nw;
@@ -391,7 +400,7 @@
 	return gpg_error (GPG_ERR_INV_ARG);
     cmd = (char*)calloc (1, strlen (p) + 64);
     if (!cmd)
-	abort ();
+	BUG (NULL);
     sprintf (cmd, "%s --logger-fd=1 --rebuild-keydb-caches", p);
 
     if (r_inf)
@@ -424,7 +433,7 @@
 	return gpg_error (GPG_ERR_INV_ARG);
     cmd = (char*)calloc (1, strlen (p) + 32);
     if (!cmd)
-	abort ();
+	BUG (NULL);
     sprintf (cmd, "%s --version", p);
 
     out = create_tmpfile ("gpg_out");
@@ -456,7 +465,7 @@
 
     cmd = (char*)calloc (1, strlen (p) + strlen (fname) + 2+2 + 64);
     if (!cmd)
-	abort ();
+	BUG (NULL);
     sprintf (cmd, "%s --fixed-list-mode --with-colons \"%s\"", p, fname);
 
     out = create_tmpfile ("gpg_keys");
@@ -491,7 +500,7 @@
 	n += strlen (cmt) + 1;
     p = (char*)calloc (1, n+1);
     if (!p)
-	abort ();
+	BUG (NULL);
     sprintf (p, fmt, code, cmt? cmt : "", cmt? "\n" : "", pass? pass : "");
     return p;
 }
@@ -517,7 +526,7 @@
 
     cmd = (char*)calloc (1, strlen (p) + strlen (keyid)+1 + 128);
     if (!cmd)
-	abort ();
+	BUG (NULL);
     sprintf (cmd, "%s --pgp7 --command-fd=0 --status-fd=2 --gen-revoke %s", 
 	     p, keyid);
 
@@ -559,7 +568,7 @@
 
     cmd = (char*)calloc (1, strlen (p) + strlen (keyid)+1 + 128);
     if (!cmd)
-	abort ();
+	BUG (NULL);
     sprintf (cmd, "%s --with-colons --fixed-list-mode --list-keys \"%s\"",
 	     p, keyid);
 

Added: trunk/Src/wptGroupManager.cpp
===================================================================
--- trunk/Src/wptGroupManager.cpp	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/wptGroupManager.cpp	2005-12-12 11:19:56 UTC (rev 121)
@@ -0,0 +1,261 @@
+/* XXX: Re-implement the code. */
+
+#if 0
+gpg_optfile_t
+km_groupdb_open (void)
+{	
+    gpg_optfile_t opt;
+    char * optfile;
+    int err = 0;
+    
+    optfile = get_gnupg_cfgfile();
+    if( !optfile )
+	BUG( NULL );
+    if( parse_gpg_options( optfile, &opt ) )
+	err = 1;
+    free_if_alloc( optfile );
+    return err? NULL : opt;
+} /* km_groupdb_open */
+
+
+int
+km_groupdb_expand_recipients( const char *name, gpgme_recipients_t rset )
+{   
+    gpg_keycache_t kc;
+    gpgme_key_t pk;
+    gpg_optfile_t opt;
+    gpg_group_t grp;    
+    gpg_member_t mbr;
+    int no_trust = 0, n;
+ 
+    kc = keycache_get_ctx( 1 );
+    if( !kc )
+	BUG( NULL );
+
+    opt = km_groupdb_open( );
+    if( !opt )
+	return WPTERR_FILE_OPEN;
+    
+    grp = find_group( opt, name );
+    if( !grp )
+	return WPTERR_GENERAL;
+    
+    /* we are paranoid and check that all group members exist in the
+       key cache. there is no need that it is really the real key, but
+       an entry should be available. the rest is up to GPG. */
+    for( mbr = grp->list; mbr; mbr = mbr->next ) {
+	if( gpgme_keycache_find_key( kc, mbr->name, 0, &pk ) )
+	    BUG( NULL );
+	n = count_userids (pk);
+	while( n-- ) {
+	    gpgme_user_id_t u = get_nth_userid (pk, n);
+	    const char * s =  u->uid;
+	    if( s && stristr( s, mbr->name )
+		&& u->validity < 3 )
+		no_trust++;
+	}
+    }
+
+    gpgme_recipients_add_name( rset, name );
+    release_gpg_options( opt );
+    
+    return no_trust;
+} /* km_groupdb_expand_recipients */
+
+
+static HTREEITEM
+km_tv_insert_item( HWND tree, HTREEITEM parent, const char *text )
+{
+    TVINSERTSTRUCT tvis;
+    HTREEITEM node;
+    
+    memset( &tvis, 0, sizeof tvis );
+    tvis.hParent = parent;
+    tvis.hInsertAfter = TVI_LAST;
+    tvis.item.mask = TVIF_TEXT;
+    tvis.item.pszText = (char *)text;
+    node = TreeView_InsertItem( tree, &tvis );
+    return node;
+} /* km_tv_insert_item */
+
+
+int
+km_groups_new( km_group_t *r_gc, HWND ctrl )
+{
+    km_group_t gc;
+    
+    gc = new km_group_s;
+    if (!gc)
+        BUG (NULL);
+    gc->tree = ctrl;
+    gc->gh = km_groupdb_open ();
+    *r_gc = gc;
+    return 0;
+} /* km_groups_new */
+
+
+void
+km_groups_sync( km_group_t gc )
+{
+    char * optfile;
+
+    optfile = get_gnupg_cfgfile ();
+    if( !optfile )
+	BUG( NULL );
+    commit_gpg_options( optfile, gc->gh );
+    free_if_alloc( optfile );
+    gc->need_sync = 0;
+} /* km_groups_sync */
+
+
+void
+km_groups_release (km_group_t gc)
+{
+    if( gc ) {
+	/* xxx: this reset the default key (sync=1) */
+	gc->need_sync=0;
+	if (gc->need_sync)
+	    km_groups_sync (gc);
+	if (gc->gh)
+	    release_gpg_options( gc->gh );
+	gc->gh = NULL;
+	gc->tree = NULL;
+	delete gc;
+    }    
+} /* km_groups_release */
+
+
+int
+km_groups_load( km_group_t gc )
+{    
+    HTREEITEM n;
+    gpg_group_t grp, g;
+    gpg_member_t mbr;
+    u32 gid = 0; 
+    
+    if( !gc->gh )
+	return 0;
+    grp = gc->gh->grp;
+    if( !grp )
+	return 0; /* no groups */
+        
+    for( g = grp; g; g = g->next ) {
+	n = km_tv_insert_item( gc->tree, NULL, g->name );
+	for( mbr = g->list; mbr; mbr = mbr->next ) {
+	    if( mbr->used && mbr->name )
+		km_tv_insert_item( gc->tree, n, mbr->name );
+	}
+    }
+    DragAcceptFiles( gc->tree, TRUE );
+    gc->need_sync = 0;
+    return 0;
+} /* km_groups_load */
+
+
+int
+km_groups_add (km_group_t gc, listview_ctrl_t lv, int km_index)
+{
+    TVITEM tvi;
+    char uid[128], valid[64], text[128];
+    int i_valid;
+    
+    memset( &tvi, 0, sizeof tvi );
+    tvi.hItem = TreeView_GetSelection( gc->tree );
+    tvi.pszText = text;
+    tvi.cchTextMax = sizeof text -1;
+    tvi.mask = TVIF_TEXT;
+    TreeView_GetItem( gc->tree, &tvi );
+    
+    
+    listview_get_item_text( lv, km_index, 0, uid, sizeof uid -1 );
+    listview_get_item_text( lv, km_index, 5, valid, sizeof valid -1 );
+    
+    if( strstr( valid, "Ultimate" ) )
+	i_valid = 5;    
+    else if( !strstr( valid, "Full" ) )
+        i_valid = 4;
+    else if( !strstr( valid, "Marginal" ) )
+        i_valid = 3;
+    else
+        i_valid = 0;
+    
+    /* we can't add the full name. one way would be to use the first
+       text until a space appears. 
+    group_add_entry(&gc->gh, gid, i_valid, uid);
+    treeview_add_item(gc->tree, tvi.hItem, uid);
+    */
+    gc->need_sync = 1;
+    
+    return 0;
+} /* km_groups_add */
+
+
+static int
+km_groups_del_main( km_group_t gc )
+{
+    TVITEM tvi;
+    char text[128];
+    int id;
+    
+    memset( &tvi, 0, sizeof tvi );
+    tvi.hItem = TreeView_GetSelection( gc->tree );
+    tvi.pszText = text;
+    tvi.cchTextMax = sizeof text -1;
+    tvi.mask = TVIF_TEXT;
+    TreeView_GetItem( gc->tree, &tvi );
+                             
+    id = log_box( _("Key Manager"), MB_INFO_ASK, 
+		   _("Do you really want to delete this group?\n\n%s"), text);
+    if( id == IDNO )
+        return 0;
+    delete_group( gc->gh, text );    
+    TreeView_DeleteItem( gc->tree, &tvi );
+    gc->need_sync = 1;
+    
+    return 0;
+} /* km_groups_del */
+
+
+static int
+km_groups_del_entry( km_group_t gc )
+{
+    TVITEM tvi;
+    HTREEITEM root;
+    int id;
+    char text[128], info[256];
+    gpg_group_t	 grp = NULL;
+    
+    memset( &tvi, 0, sizeof tvi );
+    tvi.hItem = TreeView_GetSelection( gc->tree );
+    tvi.pszText = text;
+    tvi.cchTextMax = sizeof text-1;
+    tvi.mask = TVIF_TEXT;
+    TreeView_GetItem( gc->tree, &tvi );
+    
+    _snprintf( info, sizeof info -1,
+              _("Do you really want to delete this entry?\n\n%s"), text );
+    
+    id = msg_box( gc->tree, info, _("Key Manager"), MB_INFO_ASK );
+    if( id == IDNO )
+        return 0;
+
+    root = TreeView_GetParent( gc->tree, tvi.hItem );
+    if( root ) {
+    }
+    
+    delete_member( gc->gh, /*fixme*/NULL, text );
+    TreeView_DeleteItem( gc->tree, &tvi );
+    gc->need_sync = 1;
+    return 0;
+} /* km_groups_del_entry */
+
+
+int
+km_groups_del( km_group_t gc )
+{
+    if ( TreeView_GetParent( gc->tree, TreeView_GetSelection( gc->tree ) ) )
+        return km_groups_del_entry( gc );
+    else
+        return km_groups_del_main( gc );
+} /* km_groups_del */
+#endif

Modified: trunk/Src/wptKeyCache.cpp
===================================================================
--- trunk/Src/wptKeyCache.cpp	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/wptKeyCache.cpp	2005-12-12 11:19:56 UTC (rev 121)
@@ -17,6 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
+
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -27,8 +28,8 @@
 #include <malloc.h>
 #include <ctype.h>
 #include <assert.h>
+#include <gpgme.h>
 
-#include "w32gpgme.h"
 #include "wptKeyCache.h"
 #include "openpgp.h"
 #include "wptNLS.h"
@@ -53,6 +54,7 @@
 }
 #endif
 
+
 /* Parse the secret keyring and retrieve some additional information
    for each key which was found. */
 static void

Modified: trunk/Src/wptKeyEditDlgs.cpp
===================================================================
--- trunk/Src/wptKeyEditDlgs.cpp	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/wptKeyEditDlgs.cpp	2005-12-12 11:19:56 UTC (rev 121)
@@ -1561,7 +1561,8 @@
 	cb = (keyedit_callback_s *)lparam;
 	if (cb == NULL)
 	    BUG (dlg);
-	listview_get_item_text (cb->lv, listview_get_curr_pos (cb->lv), 2, buf, DIM (buf)-1);
+	pos = listview_get_curr_pos (cb->lv);
+	listview_get_item_text (cb->lv, pos, 2, buf, DIM (buf)-1);
 	SetDlgItemText (dlg, IDC_SHOWPREF_INFO, buf);
 	pos = do_find_userid (((winpt_key_t)cb->opaque)->keyid, buf, &inf);
 	if (inf) {
@@ -1581,6 +1582,8 @@
 		CheckDlgButton (dlg, IDC_SHOWPREF_MDC, BST_CHECKED);
 	}
 	SetWindowText (dlg, _("Key Preferences"));
+	SetDlgItemText (dlg, IDC_SHOWPREF_MDC, _("MDC feature"));
+	SetDlgItemText (dlg, IDC_SHOWPREF_PREFINF, _("Preferences"));	
 	SetForegroundWindow (dlg);
 	break;
 

Modified: trunk/Src/wptKeyManager.cpp
===================================================================
--- trunk/Src/wptKeyManager.cpp	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/wptKeyManager.cpp	2005-12-12 11:19:56 UTC (rev 121)
@@ -18,6 +18,7 @@
  * along with WinPT; if not, write to the Free Software Foundation, 
  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
  */
+
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -129,6 +130,8 @@
 }
 
 
+/* Check if the key has a good status.
+   Return value: 0 on success. */
 int
 km_check_key_status (listview_ctrl_t lv, int pos)
 {
@@ -146,9 +149,10 @@
     }
 
     return 0;
-} /* km_check_key_status */
+}
 
 
+/* Return all key flags ORed. */
 int
 km_get_key_status (listview_ctrl_t lv, int pos)
 {
@@ -168,7 +172,7 @@
     if (key->disabled)
 	flags |= KM_FLAG_DISABLED;
     return flags;
-} /* km_get_key_status */
+}
 
 
 /* Interface to enable or disable a key (@enable = 1 then enable).
@@ -187,10 +191,8 @@
 	BUG (NULL);
 
     err = enable? ke->enable () : ke->disable ();
-    if (!err) {
+    if (!err)
 	show_msg (dlg, 1500, _("Key status changed."));
-	keycache_set_reload (1); /* XXX: set update flag */
-    }
     else
 	msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR);
     delete ke;
@@ -270,8 +272,9 @@
     
     rset = keylist_enum_recipients (lv, KEYLIST_LIST, &n);
     if (!n) {
-        msg_box (dlg, _("No key was selected for export."), _("Key Manager"), MB_ERR);
-        rc = WPTERR_GENERAL; 
+        msg_box (dlg, _("No key was selected for export."), 
+		 _("Key Manager"), MB_ERR);
+        rc = WPTERR_GENERAL;
 	goto leave;
     }
     
@@ -291,7 +294,7 @@
 leave:
     free (rset);
     return rc;
-} /* km_clip_export */
+}
 
 
 /* Export the selected secret key from @lv into @fname.
@@ -356,26 +359,28 @@
     /*gpgme_set_comment (ctx, "Generated by WinPT "PGM_VERSION);*/
     patt = gpg_keylist_to_pattern (rset, n);
     
-    err = gpgme_op_export( ctx, patt, 0, keydata);
+    err = gpgme_op_export (ctx, patt, 0, keydata);
     if( err ) {
-        msg_box( dlg, gpgme_strerror( err ), _("Key Manager"), MB_ERR );
+        msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR);
         goto leave;
     }
-        
-    log_box( _("Key Manager"), MB_OK, 
-	     _("Key(s) successfully saved in '%s'."), fname );
+
+    log_box (_("Key Manager"), MB_OK, 
+	     _("Key(s) successfully saved in '%s'."), fname);
     
 leave:
-    err = gpg_data_release_and_set_file( keydata, fname );
+    err = gpg_data_release_and_set_file (keydata, fname);
     if (err)
 	log_box (_("Key Manager"), MB_OK,
 		 _("Could not save data to '%s'."), fname);
     gpgme_release (ctx);
     free (patt);
     return (int)err;
-} /* km_file_export */
+}
 
 
+/* Read a dash escaped key from the clipboard
+   unescape it and write it back. */
 static int
 extract_dash_escaped_key (void)
 {
@@ -384,7 +389,7 @@
 
     err = gpg_data_new_from_clipboard (&inp, 0);
     if (err) {
-	msg_box (NULL, gpgme_strerror( err ), _("Key Manager"), MB_ERR);
+	msg_box (NULL, gpgme_strerror (err), _("Key Manager"), MB_ERR);
 	return -1;
     }
     gpg_data_extract_plaintext (inp, &plain);
@@ -392,7 +397,7 @@
     gpgme_data_release (inp);
 
     return 0;
-} /* extract_dash_escaped_key */
+}
 
 
 /* Import keys from the clipboard. */
@@ -405,18 +410,21 @@
     int has_data = 0;
     
     if (!gpg_clip_istext_avail (&has_data) && !has_data) {
-        msg_box( dlg, winpt_strerror (WPTERR_CLIP_ISEMPTY), _("Key Manager"), MB_ERR);
+        msg_box (dlg, winpt_strerror (WPTERR_CLIP_ISEMPTY), 
+		 _("Key Manager"), MB_ERR);
         return WPTERR_CLIP_ISEMPTY;
     }
     err = gpg_clip_is_secured (&pgptype, &has_data);
     if (err)
 	msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR);
     if (!has_data) {
-        msg_box (dlg, _("No valid OpenPGP data found."), _("Key Manager"), MB_ERR);
+        msg_box (dlg, _("No valid OpenPGP data found."), 
+		 _("Key Manager"), MB_ERR);
         return WPTERR_GENERAL;
     }
     if (!(pgptype & PGP_PUBKEY) && !(pgptype & PGP_SECKEY)) {
-	msg_box (dlg, _("No valid OpenPGP keys found."), _("Key Manager"), MB_ERR);
+	msg_box (dlg, _("No valid OpenPGP keys found."), 
+		 _("Key Manager"), MB_ERR);
 	return WPTERR_GENERAL;
     }
     if (pgptype & PGP_DASH_ESCAPED) {
@@ -461,7 +469,8 @@
     fp = fopen (p, "wb");
     if (!fp) {
 	free_if_alloc (p);
-	log_box (_("Key Import HTTP"), MB_ERR, "%s: %s", p, winpt_strerror (WPTERR_FILE_CREAT));
+	log_box (_("Key Import HTTP"), MB_ERR, "%s: %s", p, 
+		 winpt_strerror (WPTERR_FILE_CREAT));
 	return WPTERR_FILE_CREAT;
     }
 
@@ -571,7 +580,7 @@
     
     if (listview_get_curr_pos (lv) == -1) {
         msg_box (dlg, _("Please select a key."), _("Key Manager"), MB_ERR);
-        return WPTERR_GENERAL;
+        return -1;
     }
         
     if (listview_count_items (lv, 1) > 8) {
@@ -589,12 +598,12 @@
     rset = (gpgme_key_t *)calloc (n+1, sizeof (gpgme_key_t));
     if (!rset)
 	BUG (NULL);
-    for( i = 0; i < n; i++ ) {
-        if( listview_get_item_state( lv, i ) ) {
-            listview_get_item_text( lv, i, 0, uid, sizeof uid - 1 );
-            listview_get_item_text( lv, i, 1, keyid, sizeof keyid - 1 );
-	    listview_get_item_text( lv, i, 3, keylen, sizeof keylen - 1 );
-	    listview_get_item_text( lv, i, 7, date, sizeof date - 1 );
+    for (i = 0; i < n; i++) {
+        if( listview_get_item_state(lv, i)) {
+            listview_get_item_text (lv, i, 0, uid, sizeof uid - 1);
+            listview_get_item_text (lv, i, 1, keyid, sizeof keyid - 1);
+	    listview_get_item_text (lv, i, 3, keylen, sizeof keylen - 1);
+	    listview_get_item_text (lv, i, 7, date, sizeof date - 1);
 	    seckey_type = km_check_for_seckey (lv, i, NULL);
             if (confirm && !seckey_type) {
 		rc = log_box( _("Key Manager"), MB_YESNO|MB_ICONWARNING,
@@ -608,18 +617,19 @@
                 with_seckey = 0;
             }
             else if (confirm) {
-		rc = log_box( _("Key Manager"), MB_YESNO|MB_ICONWARNING,                
+		rc = log_box (_("Key Manager"), MB_YESNO|MB_ICONWARNING,                
                               _("Do you really want to delete this KEY PAIR?\n\n"
 				"Please remember that you are not able to decrypt\n"
 				"messages you stored with this key any longer.\n"
 				"\n"
 			        "pub/sec %s %s %s\n"
-			        "  \"%s\""), keylen, keyid, date, uid );
+			        "  \"%s\""), keylen, keyid, date, uid);
                 if( rc == IDYES ) {
 		    if (seckey_type == 2)
-			msg_box( dlg, _("The actual secret key is stored on a smartcard.\n"
+			msg_box (dlg, _("The actual secret key is stored on a smartcard.\n"
 					"Only the public key and the secret key \n"
-					"placeholder will be deleted.\n"), _("Key Manager"), MB_OK );
+					"placeholder will be deleted.\n"), 
+					_("Key Manager"), MB_OK);
 		    get_pubkey (keyid, &k);
 		    rset[k_pos++] = k;
 		}
@@ -650,7 +660,7 @@
 	    n--;
     }
     if (n == 0)
-	show_msg (dlg, 1500, _("GnuPG Status: Finished"));
+	show_msg (dlg, 1500, _("GnuPG Status: Finished"));	
     gpgme_release (ctx);
     listview_del_items (lv);
     delete_keys_from_cache (rset, k_pos);
@@ -660,20 +670,21 @@
 }
 
 
+/* Send the select key in @lv to the keyserver @host:@port. */
 int
-km_send_to_keyserver (listview_ctrl_t lv, HWND dlg, const char * host, u16 port)
+km_send_to_keyserver (listview_ctrl_t lv, HWND dlg, const char *host, u16 port)
 {
     char keyid[32];
     const char *t;
     int id;
     
-    id = listview_get_curr_pos( lv );
-    if( id == -1 ) {
+    id = listview_get_curr_pos (lv);
+    if (id == -1) {
 	msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR );
 	return WPTERR_GENERAL;
     }
 
-    listview_get_item_text( lv, id, 1, keyid, sizeof keyid - 1 );
+    listview_get_item_text (lv, id, 1, keyid, sizeof keyid - 1);
     id = log_box (_("Key Manager"), MB_YESNO,
 		  _("Do you really want to send '%s' to keyserver %s?"),
 		    keyid, host);
@@ -685,7 +696,7 @@
     }
 
     return 0;
-} /* km_send_to_keyserver */
+}
 
 
 /* Send the selected key in @lv via MAPI to a mail recipient. */
@@ -696,11 +707,11 @@
     gpgme_ctx_t ctx=NULL;
     gpgme_data_t out;
     gpgme_error_t rc;
-    const char *s;
-    char keyid[32], tmp[192+256];
+    char keyid[32], tmp[128];
+    char *fname;
     int pos;
 
-    if (listview_count_items (lv, 1 ) > 1) {
+    if (listview_count_items (lv, 1) > 1) {
 	msg_box (dlg, _("Please only select one key."), 
 		 _("Key Manager"), MB_INFO|MB_OK);
 	return WPTERR_GENERAL;
@@ -710,14 +721,19 @@
 	msg_box (dlg, _("Please select a key."), _("Key Manager"), MB_ERR);
 	return WPTERR_GENERAL;
     }
-    listview_get_item_text(lv, pos, 1, keyid, sizeof keyid-1);
+    listview_get_item_text(lv, pos, 1, keyid, sizeof (keyid)-1);
     if (get_pubkey (keyid, &key))
 	BUG (NULL);
-    s = key->uids->name;
-    GetTempPath (sizeof tmp-1, tmp);
-    strncat (tmp, s, sizeof tmp-200);
-    strncat (tmp, ".asc", sizeof tmp-200);
 
+    GetTempPath (sizeof (tmp)-1, tmp);
+    if (tmp[strlen (tmp)-1] == '\\')
+	tmp[strlen (tmp)-1] = 0;
+    fname = make_filename (tmp, key->uids->name, "asc");
+    for (pos=0; pos < (int)strlen (fname); pos++) {
+	if (fname[pos] == ' ')
+	    fname[pos] = '_';
+    }
+
     rc = gpgme_new (&ctx);
     if (rc)
 	BUG (NULL);
@@ -730,10 +746,11 @@
     if (rc)
 	msg_box (dlg, gpgme_strerror (rc), _("Key Manager"), MB_ERR);
     else
-	mapi_send_pubkey (keyid, tmp);
+	mapi_send_pubkey (keyid, fname);
 
-    gpg_data_release_and_set_file (out, tmp);
+    gpg_data_release_and_set_file (out, fname);
     gpgme_release (ctx);
+    free_if_alloc (fname);
     return rc;
 }
 
@@ -749,17 +766,18 @@
 	idx = pos;
     else
 	idx = listview_get_curr_pos (lv);
-    if (idx != -1) 
-    {
-	listview_get_item_text (lv, idx, 1, keyid, sizeof keyid - 1);
+    if (idx != -1) {
+	listview_get_item_text (lv, idx, 1, keyid, sizeof (keyid) - 1);
 	t = keyid;
 	if (!strncmp (keyid, "0x", 2))
 	    t += 2;
-	hkp_recv_key (dlg, default_keyserver, default_keyserver_port, t, 0, KM_KS_REFRESH);
+	hkp_recv_key (dlg, default_keyserver, default_keyserver_port, 
+		      t, 0, KM_KS_REFRESH);
     }
 }
 
 
+/* Refresh all keys from the default keyserver. */
 void
 km_refresh_from_keyserver (listview_ctrl_t lv, HWND dlg)
 {
@@ -773,7 +791,8 @@
     }
     idx = listview_count_items (lv, 0);
     if (listview_count_items (lv, 1) == idx) {
-        id = msg_box (dlg, _("Do you really want to refresh all keys in the keyring?"), _("Key Manager"), MB_YESNO);
+        id = msg_box (dlg, _("Do you really want to refresh all keys in the keyring?"), 
+		      _("Key Manager"), MB_YESNO);
         if (id == IDNO)
             return;
         for (i = 0; i < idx; i++)
@@ -787,7 +806,7 @@
 		km_refresh_one_key (lv, dlg, i);
 	}
     }
-} /* km_refresh_from_keyserver */
+}
 
 
 void
@@ -797,7 +816,7 @@
     
     key_get_clip_info (uid, buf, 255);    
     set_clip_text (NULL, buf, strlen (buf));
-} /* km_set_clip_info */
+}
 
 
 
@@ -843,10 +862,11 @@
 
 /* Count all keys and show from @lv results in the status bar @sb. */
 void
-km_complete_status_bar (HWND sb, listview_ctrl_t lv)
+km_update_status_bar (HWND sb, listview_ctrl_t lv)
 {
     char txt_sec[128], txt_pub[128];
-    int nkeys = 0, nsec = 0, i;
+    int nkeys = 0, nsec = 0;
+    int i;
 
     nkeys = listview_count_items (lv, 0);
     for (i = 0; i < nkeys; i++) {
@@ -911,278 +931,3 @@
     }
     free_if_alloc (name);
 }
-
-
-
-void
-km_dump_key (gpgme_key_t key)
-{
-#if _DEBUG
-    log_box ("DEBUG", MB_OK,
-	     "%d %d %s %d\n%s", key->subkeys->length,
-	     key->subkeys->pubkey_algo,
-	     key->subkeys->keyid,
-	     key->subkeys->timestamp,
-	     key->uids->uid);
-#endif
-}
-
-#if 0
-gpg_optfile_t
-km_groupdb_open (void)
-{	
-    gpg_optfile_t opt;
-    char * optfile;
-    int err = 0;
-    
-    optfile = get_gnupg_cfgfile();
-    if( !optfile )
-	BUG( NULL );
-    if( parse_gpg_options( optfile, &opt ) )
-	err = 1;
-    free_if_alloc( optfile );
-    return err? NULL : opt;
-} /* km_groupdb_open */
-
-
-int
-km_groupdb_expand_recipients( const char *name, gpgme_recipients_t rset )
-{   
-    gpg_keycache_t kc;
-    gpgme_key_t pk;
-    gpg_optfile_t opt;
-    gpg_group_t grp;    
-    gpg_member_t mbr;
-    int no_trust = 0, n;
- 
-    kc = keycache_get_ctx( 1 );
-    if( !kc )
-	BUG( NULL );
-
-    opt = km_groupdb_open( );
-    if( !opt )
-	return WPTERR_FILE_OPEN;
-    
-    grp = find_group( opt, name );
-    if( !grp )
-	return WPTERR_GENERAL;
-    
-    /* we are paranoid and check that all group members exist in the
-       key cache. there is no need that it is really the real key, but
-       an entry should be available. the rest is up to GPG. */
-    for( mbr = grp->list; mbr; mbr = mbr->next ) {
-	if( gpgme_keycache_find_key( kc, mbr->name, 0, &pk ) )
-	    BUG( NULL );
-	n = count_userids (pk);
-	while( n-- ) {
-	    gpgme_user_id_t u = get_nth_userid (pk, n);
-	    const char * s =  u->uid;
-	    if( s && stristr( s, mbr->name )
-		&& u->validity < 3 )
-		no_trust++;
-	}
-    }
-
-    gpgme_recipients_add_name( rset, name );
-    release_gpg_options( opt );
-    
-    return no_trust;
-} /* km_groupdb_expand_recipients */
-
-
-static HTREEITEM
-km_tv_insert_item( HWND tree, HTREEITEM parent, const char *text )
-{
-    TVINSERTSTRUCT tvis;
-    HTREEITEM node;
-    
-    memset( &tvis, 0, sizeof tvis );
-    tvis.hParent = parent;
-    tvis.hInsertAfter = TVI_LAST;
-    tvis.item.mask = TVIF_TEXT;
-    tvis.item.pszText = (char *)text;
-    node = TreeView_InsertItem( tree, &tvis );
-    return node;
-} /* km_tv_insert_item */
-
-
-int
-km_groups_new( km_group_t *r_gc, HWND ctrl )
-{
-    km_group_t gc;
-    
-    gc = new km_group_s;
-    if (!gc)
-        BUG (NULL);
-    gc->tree = ctrl;
-    gc->gh = km_groupdb_open ();
-    *r_gc = gc;
-    return 0;
-} /* km_groups_new */
-
-
-void
-km_groups_sync( km_group_t gc )
-{
-    char * optfile;
-
-    optfile = get_gnupg_cfgfile ();
-    if( !optfile )
-	BUG( NULL );
-    commit_gpg_options( optfile, gc->gh );
-    free_if_alloc( optfile );
-    gc->need_sync = 0;
-} /* km_groups_sync */
-
-
-void
-km_groups_release (km_group_t gc)
-{
-    if( gc ) {
-	/* xxx: this reset the default key (sync=1) */
-	gc->need_sync=0;
-	if (gc->need_sync)
-	    km_groups_sync (gc);
-	if (gc->gh)
-	    release_gpg_options( gc->gh );
-	gc->gh = NULL;
-	gc->tree = NULL;
-	delete gc;
-    }    
-} /* km_groups_release */
-
-
-int
-km_groups_load( km_group_t gc )
-{    
-    HTREEITEM n;
-    gpg_group_t grp, g;
-    gpg_member_t mbr;
-    u32 gid = 0; 
-    
-    if( !gc->gh )
-	return 0;
-    grp = gc->gh->grp;
-    if( !grp )
-	return 0; /* no groups */
-        
-    for( g = grp; g; g = g->next ) {
-	n = km_tv_insert_item( gc->tree, NULL, g->name );
-	for( mbr = g->list; mbr; mbr = mbr->next ) {
-	    if( mbr->used && mbr->name )
-		km_tv_insert_item( gc->tree, n, mbr->name );
-	}
-    }
-    DragAcceptFiles( gc->tree, TRUE );
-    gc->need_sync = 0;
-    return 0;
-} /* km_groups_load */
-
-
-int
-km_groups_add( km_group_t gc, listview_ctrl_t lv, int km_index )
-{
-    TVITEM tvi;
-    char uid[128], valid[64], text[128];
-    int i_valid;
-    
-    memset( &tvi, 0, sizeof tvi );
-    tvi.hItem = TreeView_GetSelection( gc->tree );
-    tvi.pszText = text;
-    tvi.cchTextMax = sizeof text -1;
-    tvi.mask = TVIF_TEXT;
-    TreeView_GetItem( gc->tree, &tvi );
-    
-    
-    listview_get_item_text( lv, km_index, 0, uid, sizeof uid -1 );
-    listview_get_item_text( lv, km_index, 5, valid, sizeof valid -1 );
-    
-    if( strstr( valid, "Ultimate" ) )
-	i_valid = 5;    
-    else if( !strstr( valid, "Full" ) )
-        i_valid = 4;
-    else if( !strstr( valid, "Marginal" ) )
-        i_valid = 3;
-    else
-        i_valid = 0;
-    
-    /* we can't add the full name. one way would be to use the first
-       text until a space appears. 
-    group_add_entry(&gc->gh, gid, i_valid, uid);
-    treeview_add_item(gc->tree, tvi.hItem, uid);
-    */
-    gc->need_sync = 1;
-    
-    return 0;
-} /* km_groups_add */
-
-
-static int
-km_groups_del_main( km_group_t gc )
-{
-    TVITEM tvi;
-    char text[128];
-    int id;
-    
-    memset( &tvi, 0, sizeof tvi );
-    tvi.hItem = TreeView_GetSelection( gc->tree );
-    tvi.pszText = text;
-    tvi.cchTextMax = sizeof text -1;
-    tvi.mask = TVIF_TEXT;
-    TreeView_GetItem( gc->tree, &tvi );
-                             
-    id = log_box( _("Key Manager"), MB_INFO_ASK, 
-		   _("Do you really want to delete this group?\n\n%s"), text);
-    if( id == IDNO )
-        return 0;
-    delete_group( gc->gh, text );    
-    TreeView_DeleteItem( gc->tree, &tvi );
-    gc->need_sync = 1;
-    
-    return 0;
-} /* km_groups_del */
-
-
-static int
-km_groups_del_entry( km_group_t gc )
-{
-    TVITEM tvi;
-    HTREEITEM root;
-    int id;
-    char text[128], info[256];
-    gpg_group_t	 grp = NULL;
-    
-    memset( &tvi, 0, sizeof tvi );
-    tvi.hItem = TreeView_GetSelection( gc->tree );
-    tvi.pszText = text;
-    tvi.cchTextMax = sizeof text-1;
-    tvi.mask = TVIF_TEXT;
-    TreeView_GetItem( gc->tree, &tvi );
-    
-    _snprintf( info, sizeof info -1,
-              _("Do you really want to delete this entry?\n\n%s"), text );
-    
-    id = msg_box( gc->tree, info, _("Key Manager"), MB_INFO_ASK );
-    if( id == IDNO )
-        return 0;
-
-    root = TreeView_GetParent( gc->tree, tvi.hItem );
-    if( root ) {
-    }
-    
-    delete_member( gc->gh, /*fixme*/NULL, text );
-    TreeView_DeleteItem( gc->tree, &tvi );
-    gc->need_sync = 1;
-    return 0;
-} /* km_groups_del_entry */
-
-
-int
-km_groups_del( km_group_t gc )
-{
-    if ( TreeView_GetParent( gc->tree, TreeView_GetSelection( gc->tree ) ) )
-        return km_groups_del_entry( gc );
-    else
-        return km_groups_del_main( gc );
-} /* km_groups_del */
-#endif

Modified: trunk/Src/wptKeyManagerDlg.cpp
===================================================================
--- trunk/Src/wptKeyManagerDlg.cpp	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/wptKeyManagerDlg.cpp	2005-12-12 11:19:56 UTC (rev 121)
@@ -344,7 +344,7 @@
 	if( !cache )
 	    BUG( dlg );
 	keylist_reload( lv, cache, KEYLIST_LIST, KEY_SORT_USERID );
-	km_complete_status_bar (sb, lv);
+	km_update_status_bar (sb, lv);
     }
 } /* do_check_cache */
 
@@ -480,10 +480,14 @@
 void
 update_ui_items (HWND hwnd, listview_ctrl_t lv)
 {
-    int key_selected = 0, key_has_sec = 0;
-    int i, key_inv = 0;
     HWND hwnd_child;
     HMENU hmenu;
+    int key_selected = 0;
+    int key_has_sec = 0;
+    int key_inv = 0;
+    int mult_resids[] = {ID_KEYMISC_PROPS, ID_KEYMISC_SIGN, ID_KEYMISC_EDITKEY,
+	                 ID_KEYMISC_CHECKSIGS, ID_KEYMISC_REVCERT, 0};
+    int i;
     
     /* Get some states */
     key_selected = SendMessage (GetDlgItem (hwnd, IDC_KEYMISC_KEYLIST), 
@@ -513,8 +517,39 @@
     set_menu_state (hmenu, ID_KEYMISC_SIGN, key_selected && !key_inv ? MF_ENABLED : MF_GRAYED);
     set_menu_state (hmenu, ID_KEYMISC_EDITKEY, key_selected? MF_ENABLED : MF_GRAYED);
     set_menu_state (hmenu, ID_KEYMISC_CHECKSIGS, key_selected? MF_ENABLED : MF_GRAYED);
+    
+    /* Disable some menu items when multiple keys are selected. */
+    if (listview_count_items (lv, 1) > 1) {
+	for (i=0; mult_resids[i] != 0; i++)
+	    set_menu_state (hmenu, mult_resids[i], MF_GRAYED);
+    }    
 }
 
+/* Disable some context menu items when multiple keys are selected. */
+static void
+popup_multiple (HWND dlg, HMENU hm)
+{
+    int resids[] = {
+	ID_KEYCTX_EDIT,
+	ID_KEYCTX_SIGN,
+	ID_KEYCTX_REV,
+        ID_KEYCTX_ENABLE,
+        ID_KEYCTX_DISABLE,
+        ID_KEYCTX_ADDKEY,
+        ID_KEYCTX_ADDPHOTO,
+        ID_KEYCTX_ADDUID,
+        ID_KEYCTX_ADDREV,
+        ID_KEYCTX_LISTSIGS,
+        ID_KEYCTX_MAXTRUST,
+        ID_KEYCTX_PROPS,
+        ID_KEYCTX_SENDMAIL,
+        0
+    };
+    int i;
+    for (i=0; i < resids[i] != 0; i++)
+	set_menu_state (hm, resids[i], MF_GRAYED);
+}
+ 
 
 /* The items which are shown when GPG is in read-only mode. */
 static void
@@ -643,7 +678,7 @@
     SendMessage (statbar, SB_SETPARTS, (WPARAM)3, (LPARAM)partpos);
 
     km_update_default_key_str (statbar);
-    km_complete_status_bar (statbar, lv);
+    km_update_status_bar (statbar, lv);
 
     return statbar;
 }
@@ -965,6 +1000,8 @@
 		host = kserver_get_hostname (0, -1, &port);
 		set_menu_text (popup, ID_KEYCTX_KS_DEFAULT, host);
 		popup_gpg_readonly (dlg, popup);
+		if (listview_count_items (kmi->lv, 1) > 1)
+		    popup_multiple (dlg, popup);		
 		TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);
 		DestroyMenu (popup);
 		DestroyMenu (hm);

Modified: trunk/Src/wptListView.cpp
===================================================================
--- trunk/Src/wptListView.cpp	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/wptListView.cpp	2005-12-12 11:19:56 UTC (rev 121)
@@ -351,18 +351,3 @@
     return pos;
 }
 
-/** Some functions to make the handling with TreeView Controls easier **/
-int
-treeview_add_item( HWND tree, HTREEITEM parent, const char *text )
-{	
-    TVINSERTSTRUCT tvis;
-	
-    memset( &tvis, 0, sizeof tvis );
-    tvis.hParent = parent;
-    tvis.hInsertAfter = TVI_LAST;
-    tvis.item.mask = TVIF_TEXT;
-    tvis.item.pszText = (char *)text;
-    TreeView_InsertItem( tree, &tvis );
-
-    return 0;
-} /* treeview_add_item */

Modified: trunk/Src/wptMAPI.cpp
===================================================================
--- trunk/Src/wptMAPI.cpp	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/wptMAPI.cpp	2005-12-12 11:19:56 UTC (rev 121)
@@ -25,15 +25,13 @@
 #include <stdio.h>
 #include <mapi.h>
 
-extern HINSTANCE glob_hinst;
-
 #include "resource.h"
 #include "wptTypes.h"
 #include "wptErrors.h"
 #include "wptW32API.h"
 #include "wptGPG.h"
+#include "wptVersion.h"
 
-
 static LPMAPILOGON	    mapi_logon = NULL; 
 static LPMAPILOGOFF	    mapi_logoff = NULL;     
 static LPMAPISENDDOCUMENTS  mapi_send_documents = NULL; 

Modified: trunk/Src/wptMainProc.cpp
===================================================================
--- trunk/Src/wptMainProc.cpp	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/wptMainProc.cpp	2005-12-12 11:19:56 UTC (rev 121)
@@ -46,7 +46,6 @@
 #include "wptCardEdit.h"
 #include "wptCrypto.h"
 
-extern HWND activ_hwnd;
 static int cmd = 0;
 static int wipe_contents = 0;
 
@@ -87,31 +86,6 @@
 }
 
 
-/* @unused
-static int
-cleanup_tmp_files (void)
-{
-    struct _finddata_t dat;
-    char tmp[384];
-    long hd;
-
-    if (GetTempPath (sizeof (tmp)-1, tmp) == FALSE ||
-	SetCurrentDirectory (tmp) == FALSE) {
-	winpt_errmsg ("GetTempPath", 0);
-	return WPTERR_GENERAL;
-    }
-    hd = _findfirst ("gpgmeOUT*", &dat);
-    if (hd == -1)
-	return 0;
-    do {
-	secure_unlink (dat.name, WIPE_MODE_SIMPLE);
-    } while (_findnext (hd, &dat) == 0);
-    _findclose (hd);
-    return 0;
-}
-*/
-
-
 /* Dialog box procedure to confirm to delete the clipboard contents. */
 static BOOL CALLBACK
 confirm_delclipboard_dlg (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
@@ -122,7 +96,7 @@
 	SetDlgItemText (dlg, IDC_CONFDELCLIP_BRAIN, _("&Remember the answer"));
 	SetDlgItemText (dlg, IDC_CONFDELCLIP_INFO, _("Do you want to delete the contents from the clipboard?"));
 	SetDlgItemText (dlg, IDYES, _("&Yes"));
-	SetDlgItemText (dlg, IDNO, _("&No"));	
+	SetDlgItemText (dlg, IDNO, _("&No"));
 	center_window (dlg, NULL);
 	SetForegroundWindow (dlg);
 	break;
@@ -311,7 +285,7 @@
 
 /* Load the Card Manager with the current card. */
 static void
-load_smartcard (void)
+load_card_manager (void)
 {
     gpg_card_t card;
 
@@ -321,8 +295,7 @@
 			  GetDesktopWindow (), card_edit_dlg_proc, 
 			  (LPARAM)card,
 			  _("Card Edit"), IDS_WINPT_CARD_EDIT);
-	gpg_card_release (card); 
-	card = NULL;	
+	gpg_card_release (card);
     }
 }
 
@@ -587,7 +560,7 @@
             break;
 
 	case ID_WINPT_CARD:
-	    load_smartcard ();
+	    load_card_manager ();
 	    break;
             
         case ID_WINPT_EDIT:

Modified: trunk/Src/wptW32API.cpp
===================================================================
--- trunk/Src/wptW32API.cpp	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/Src/wptW32API.cpp	2005-12-12 11:19:56 UTC (rev 121)
@@ -1,5 +1,5 @@
 /* wptW32API.cpp - Common W32 API functions
- *	Copyright (C) 2001, 2002, 2003 Timo Schulz
+ *	Copyright (C) 2001, 2002, 2003, 2005 Timo Schulz
  *
  * This file is part of WinPT.
  *
@@ -17,6 +17,7 @@
  * along with WinPT; if not, write to the Free Software Foundation, 
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
+
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -75,7 +76,7 @@
 {	
     MENUITEMINFO mii;
 
-    memset( &mii, 0, sizeof (mii) );
+    memset (&mii, 0, sizeof (mii));
     mii.cbSize = sizeof (mii);
     mii.fMask = MIIM_STATE;
     mii.fState = state;
@@ -134,7 +135,7 @@
     return get_filename_dlg (hwnd, CDLG_FILE_SAVE, title, filter, name);
 }
 
-const char *
+const char*
 get_fileopen_dlg (HWND hwnd, const char *title, const char *filter,
 		  const char *name)
 {
@@ -145,11 +146,11 @@
 /* Use the common dialog to allow the user to select a folder.
    The return value is either the folder path or NULL if cancel was chosen. */
 const char*
-get_folder_dlg (HWND hwnd, const char * title, const char * name)
+get_folder_dlg (HWND hwnd, const char *title, const char *name)
 {
     static char folder[MAX_PATH+1] = "";
     BROWSEINFO bi;
-    ITEMIDLIST * il;
+    ITEMIDLIST *il;
 
     memset (&bi, 0, sizeof (bi));
     bi.hwndOwner = hwnd;
@@ -261,7 +262,9 @@
 }
 
 
-/* Make a file name out of the path, the file and an extension. */
+/* Make a file name out of the path @path, the file @file and 
+   an extension. @ext.
+   Return value: the full file name on success. */
 char*
 make_filename (const char *path, const char *file, const char *ext)
 {
@@ -288,12 +291,12 @@
 	strcat( p, ext );
     }
     return p;
-} /* make_filename */
+}
 
 
-/* return 0 if it exists, otherwise >0. */
+/* return 0 if the file @fname exists, otherwise >0. */
 int
-file_exist_check (const char * fname)
+file_exist_check (const char *fname)
 {
     struct stat st;
     if (stat (fname, &st) == -1)
@@ -391,48 +394,16 @@
 }
 
 
-void
-set_active_window( HWND dlg)
-{	
-    activ_hwnd = dlg;
-} /* set_active_window */
-
-void
-reset_active_window( void )
-{	
-    activ_hwnd = NULL;
-} /* reset_active_window */
-
-
-static DWORD CALLBACK 
-reminder_thread (void *ctx)
-{
-    reminder_ctx_s *c = (reminder_ctx_s *)ctx;
-
-    Sleep( c->msecs );
-    SetForegroundWindow( activ_hwnd );
-
-    return 0;
-} /* reminder_thread */
-
-
-HANDLE
-window_reminder( struct reminder_ctx_s *ctx )
-{
-    DWORD tid = 0;
-    
-    return CreateThread( NULL, 0, reminder_thread, ctx, 0, &tid );
-} /* window_reminder */
-
-
+/* Safe strdup version (C++ version). */
 char*
 m_strdup (const char *str)
 {
-    char * p = new char[strlen (str) + 1];
-    if (p)
-	strcpy (p, str);
+    char *p = new char[strlen (str) + 1];
+    if (!p)
+	BUG (NULL);
+    strcpy (p, str);
     return p;
-} /* m_strdup */
+}
 
 
 /* Center the hwndChild relative to parent.
@@ -484,3 +455,82 @@
 {
     center_window2 (hwndChild, hwndParent, NULL);
 }
+
+
+/* Retrieve the product verion of the given file @fname.
+   Format: MAJOR.MINOR.PATCH1.PATCH2
+   Return value: 0 on success. */
+int
+get_file_version (const char *fname, WORD *major, WORD *minor, 
+		  WORD *patch1, WORD *patch2)
+{
+    VS_FIXEDFILEINFO *inf = {0};
+    char file[MAX_PATH+1] = {0};
+    LPVOID buf, data;
+    DWORD arg;
+    DWORD size;
+    UINT qlen;
+
+    strncpy (file, fname, MAX_PATH);
+    size = GetFileVersionInfoSize (file, &arg);
+    if (!size)
+	return -1;
+    buf = (LPVOID)new CHAR[size];
+    if (!buf)
+	BUG (NULL);
+    GetFileVersionInfo (file, 0, size, buf);
+
+    qlen=0;
+    VerQueryValue (buf, "\\", &data, &qlen);
+    if (!qlen) {
+	delete [] (char*)buf;
+	return -1;
+    }
+    inf = (VS_FIXEDFILEINFO*)data;
+
+    if (major)
+	*major = HIWORD (inf->dwProductVersionMS);
+    if (minor)
+	*minor = LOWORD (inf->dwProductVersionMS);
+    if (patch1)
+	*patch1 = HIWORD (inf->dwProductVersionLS);	
+    if (patch2)
+	*patch2 = LOWORD (inf->dwProductVersionLS);
+
+    delete [] (char*)buf;
+    return 0;
+}
+
+
+void
+set_active_window( HWND dlg)
+{	
+    activ_hwnd = dlg;
+} /* set_active_window */
+
+void
+reset_active_window( void )
+{	
+    activ_hwnd = NULL;
+} /* reset_active_window */
+
+
+static DWORD CALLBACK 
+reminder_thread (void *ctx)
+{
+    reminder_ctx_s *c = (reminder_ctx_s *)ctx;
+
+    Sleep( c->msecs );
+    SetForegroundWindow( activ_hwnd );
+
+    return 0;
+} /* reminder_thread */
+
+
+HANDLE
+window_reminder( struct reminder_ctx_s *ctx )
+{
+    DWORD tid = 0;
+    
+    return CreateThread( NULL, 0, reminder_thread, ctx, 0, &tid );
+} /* window_reminder */

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2005-12-09 14:27:59 UTC (rev 120)
+++ trunk/configure.ac	2005-12-12 11:19:56 UTC (rev 121)
@@ -236,7 +236,6 @@
 Ico/Makefile
 icons/Makefile
 m4/Makefile
-w32gpgme/Makefile
 Gnupg/Makefile
 Po/Makefile
 ])



More information about the Winpt-commits mailing list