[Winpt-commits] r130 - trunk/Src
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Fri Dec 30 15:06:40 CET 2005
Author: twoaday
Date: 2005-12-30 15:06:39 +0100 (Fri, 30 Dec 2005)
New Revision: 130
Modified:
trunk/Src/ChangeLog
trunk/Src/WinPT-en.rc
trunk/Src/resource.h
trunk/Src/wptAboutDlgs.cpp
trunk/Src/wptGPGPrefsDlg.cpp
trunk/Src/wptKeyManager.cpp
trunk/Src/wptKeyManagerDlg.cpp
trunk/Src/wptKeygenDlg.cpp
trunk/Src/wptMDSumDlg.cpp
trunk/Src/wptPassphraseDlg.cpp
trunk/Src/wptPreferencesDlg.cpp
Log:
2005-12-29 Timo Schulz <ts at g10code.com>
* wptKeygenDlg.cpp (keygen_dlg_proc): Request passphrase dynamically.
(gpg_genkey_params): Simplified.
* wptPreferencesDlg.cpp (prefs_dlg_proc): Fix problem with mutal
exclusion of the dialog items.
* wptAboutDlgs.cpp (about_winpt_dlg_proc): Allow to use ESC to
quit the dialog.
* wptKeyManagerDlg.cpp (keymanager_dlg_proc): Likewise.
* wptMDSumDlg.cpp (mdsum_dlg_proc): Handle WM_SYSCOMMAND.
(id2algo): New.
Prepare 0.11.4 release.
Modified: trunk/Src/ChangeLog
===================================================================
--- trunk/Src/ChangeLog 2005-12-30 13:56:10 UTC (rev 129)
+++ trunk/Src/ChangeLog 2005-12-30 14:06:39 UTC (rev 130)
@@ -1,3 +1,15 @@
+2005-12-29 Timo Schulz <ts at g10code.com>
+
+ * wptKeygenDlg.cpp (keygen_dlg_proc): Request passphrase dynamically.
+ (gpg_genkey_params): Simplified.
+ * wptPreferencesDlg.cpp (prefs_dlg_proc): Fix problem with mutal
+ exclusion of the dialog items.
+ * wptAboutDlgs.cpp (about_winpt_dlg_proc): Allow to use ESC to
+ quit the dialog.
+ * wptKeyManagerDlg.cpp (keymanager_dlg_proc): Likewise.
+ * wptMDSumDlg.cpp (mdsum_dlg_proc): Handle WM_SYSCOMMAND.
+ (id2algo): New.
+
2005-12-28 Timo Schulz <ts at g10code.com>
* wptKeyserverDlg.cpp (show_imported_keys): Decode user IDs.
@@ -1139,7 +1151,7 @@
* WinPT.cpp (load_keyserver_conf): New. Factored out some code
from WinMain ().
- (WinMain): Load keyserver config at the begin. Thanks to Bodo Aßner
+ (WinMain): Load keyserver config at the begin. Thanks to Bodo AÃner
* wptKeyserverDlg.cpp (keyserver_dlg_proc): If there is no keyserver
in the list control, add at least the internal default HKP server.
* wptKeygenDlg.cpp (keygen_wizard_dlg_proc): NLS support.
Modified: trunk/Src/WinPT-en.rc
===================================================================
--- trunk/Src/WinPT-en.rc 2005-12-30 13:56:10 UTC (rev 129)
+++ trunk/Src/WinPT-en.rc 2005-12-30 14:06:39 UTC (rev 130)
@@ -394,7 +394,7 @@
PUSHBUTTON "&Cancel",IDCANCEL,242,103,50,14
END
-IDD_WINPT_KEYGEN DIALOG DISCARDABLE 0, 0, 174, 213
+IDD_WINPT_KEYGEN DIALOG DISCARDABLE 0, 0, 188, 167
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Key Generation"
FONT 8, "MS Sans Serif"
@@ -402,32 +402,24 @@
LTEXT "NOTE: Key generation can be a lengthy process! Please wait until you get the message that key generation was finished.",
IDC_KEYGEN_INFO,8,10,157,24
LTEXT "Key &type",IDC_KEYGEN_KEYTYPEINF,8,43,49,10
- COMBOBOX IDC_KEYGEN_KEYTYPE,74,42,92,61,CBS_DROPDOWNLIST |
+ COMBOBOX IDC_KEYGEN_KEYTYPE,74,42,107,61,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "Subkey size in &bits",IDC_KEYGEN_SUBKEYINF,8,61,59,8
EDITTEXT IDC_KEYGEN_SUBKEYBITS,74,58,20,14
LTEXT "1024-4096",IDC_STATIC,99,60,35,8
LTEXT "&Real name",IDC_KEYGEN_NAMEINF,8,79,57,8
- EDITTEXT IDC_KEYGEN_NAME,74,76,91,13,ES_AUTOHSCROLL
+ EDITTEXT IDC_KEYGEN_NAME,74,76,107,13,ES_AUTOHSCROLL
LTEXT "&Comment (optional)",IDC_KEYGEN_COMMINF,8,96,61,8
- EDITTEXT IDC_KEYGEN_COMMENT,74,93,91,13,ES_AUTOHSCROLL
+ EDITTEXT IDC_KEYGEN_COMMENT,74,93,107,13,ES_AUTOHSCROLL
LTEXT "Email &address",IDC_KEYGEN_EMAILINF,8,112,55,8
- EDITTEXT IDC_KEYGEN_EMAIL,74,109,92,12,ES_AUTOHSCROLL
+ EDITTEXT IDC_KEYGEN_EMAIL,74,109,107,12,ES_AUTOHSCROLL
LTEXT "&Expire date",IDC_KEYGEN_EXPINF,8,126,53,8
CONTROL "&Never",IDC_KEYGEN_EXPNEVER,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,75,127,35,10
+ WS_TABSTOP,75,127,44,10
CONTROL "DateTimePicker1",IDC_KEYGEN_EXPDATE,"SysDateTimePick32",
- DTS_RIGHTALIGN | WS_TABSTOP,112,125,54,12
- LTEXT "&Passphrase",IDC_KEYGEN_PWDINF,8,142,53,8
- EDITTEXT IDC_KEYGEN_PASSPHRASE,74,140,91,13,ES_PASSWORD |
- ES_AUTOHSCROLL
- LTEXT "&Repeat passphrase",IDC_KEYGEN_REPWDINF,8,159,62,8
- EDITTEXT IDC_KEYGEN_PWDCHECK,74,158,91,14,ES_PASSWORD |
- ES_AUTOHSCROLL
- CONTROL "&Hide Typing",IDC_KEYGEN_HIDEPWD,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,74,175,83,8
- DEFPUSHBUTTON "&Start",IDOK,63,191,50,14
- PUSHBUTTON "&Cancel",IDCANCEL,115,191,50,14
+ DTS_RIGHTALIGN | WS_TABSTOP,126,125,54,12
+ DEFPUSHBUTTON "&Start",IDOK,80,148,50,14
+ PUSHBUTTON "&Cancel",IDCANCEL,132,148,50,14
END
IDD_WINPT_SIGNENC DIALOG DISCARDABLE 0, 0, 386, 197
@@ -1474,9 +1466,9 @@
IDD_WINPT_KEYGEN, DIALOG
BEGIN
LEFTMARGIN, 3
- RIGHTMARGIN, 167
+ RIGHTMARGIN, 181
TOPMARGIN, 4
- BOTTOMMARGIN, 208
+ BOTTOMMARGIN, 162
END
IDD_WINPT_SIGNENC, DIALOG
@@ -2023,6 +2015,7 @@
MENUITEM "Unmount...", ID_WINPT_CDISKUNMOUNT
MENUITEM "Unmount all disks", ID_WINPT_CDISKUMOUNTALL
END
+ MENUITEM SEPARATOR
MENUITEM "About...", ID_WINPT_ABOUT
MENUITEM "Exit", ID_WINPT_QUIT
END
@@ -2144,6 +2137,8 @@
POPUP "&?"
BEGIN
MENUITEM "&Help", ID_KEYMISC_HELP
+ MENUITEM "WinPT &Website", ID_KEYMISC_WEBSITE
+ MENUITEM SEPARATOR
MENUITEM "&Info", ID_KEYMISC_INFO
END
END
Modified: trunk/Src/resource.h
===================================================================
--- trunk/Src/resource.h 2005-12-30 13:56:10 UTC (rev 129)
+++ trunk/Src/resource.h 2005-12-30 14:06:39 UTC (rev 130)
@@ -780,13 +780,14 @@
#define ID_KEYMISC_VIEWCIPHER 40178
#define ID_KEYMISC_VIEWTYPE 40179
#define ID_KEYMISC_VIEWCREAT 40180
+#define ID_KEYMISC_WEBSITE 40181
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 230
-#define _APS_NEXT_COMMAND_VALUE 40181
+#define _APS_NEXT_COMMAND_VALUE 40182
#define _APS_NEXT_CONTROL_VALUE 1502
#define _APS_NEXT_SYMED_VALUE 101
#endif
Modified: trunk/Src/wptAboutDlgs.cpp
===================================================================
--- trunk/Src/wptAboutDlgs.cpp 2005-12-30 13:56:10 UTC (rev 129)
+++ trunk/Src/wptAboutDlgs.cpp 2005-12-30 14:06:39 UTC (rev 130)
@@ -73,6 +73,10 @@
case IDOK:
EndDialog (dlg, TRUE);
return TRUE;
+
+ case IDCANCEL:
+ EndDialog (dlg, FALSE);
+ return TRUE;
}
break;
}
@@ -146,6 +150,10 @@
case IDOK:
EndDialog (dlg, TRUE);
return TRUE;
+
+ case IDCANCEL:
+ EndDialog (dlg, FALSE);
+ return TRUE;
}
break;
}
Modified: trunk/Src/wptGPGPrefsDlg.cpp
===================================================================
--- trunk/Src/wptGPGPrefsDlg.cpp 2005-12-30 13:56:10 UTC (rev 129)
+++ trunk/Src/wptGPGPrefsDlg.cpp 2005-12-30 14:06:39 UTC (rev 130)
@@ -284,6 +284,10 @@
if (s)
SetDlgItemText (dlg, IDC_GPGPREFS_EXEDIR, s);
return TRUE;
+
+ case IDCANCEL:
+ EndDialog (dlg, FALSE);
+ return TRUE;
}
break;
}
Modified: trunk/Src/wptKeyManager.cpp
===================================================================
--- trunk/Src/wptKeyManager.cpp 2005-12-30 13:56:10 UTC (rev 129)
+++ trunk/Src/wptKeyManager.cpp 2005-12-30 14:06:39 UTC (rev 130)
@@ -50,6 +50,11 @@
#include "wptUTF8.h"
+/* Macros to change the cursor */
+#define op_begin() SetCursor (LoadCursor (NULL, IDC_WAIT))
+#define op_end() SetCursor (LoadCursor (NULL, IDC_ARROW))
+
+
/* Return a user friendly key representation in @buf of
the key given by @keyid. */
static void
@@ -557,9 +562,9 @@
goto leave;
}
- SetCursor (LoadCursor (NULL, IDC_WAIT));
+ op_begin ();
err = gpgme_op_import (ctx, keydata);
- SetCursor (LoadCursor (NULL, IDC_ARROW));
+ op_end ();
if (err) {
msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR);
goto leave;
@@ -687,6 +692,7 @@
if (err)
BUG (NULL);
n = k_pos;
+ op_begin ();
for (i=0; i < k_pos; i++) {
err = gpgme_op_delete (ctx, rset[i], with_seckey);
if (err)
@@ -694,6 +700,7 @@
else
n--;
}
+ op_end ();
if (n == 0)
show_msg (dlg, 1500, _("GnuPG Status: Finished"));
gpgme_release (ctx);
Modified: trunk/Src/wptKeyManagerDlg.cpp
===================================================================
--- trunk/Src/wptKeyManagerDlg.cpp 2005-12-30 13:56:10 UTC (rev 129)
+++ trunk/Src/wptKeyManagerDlg.cpp 2005-12-30 14:06:39 UTC (rev 130)
@@ -885,6 +885,28 @@
}
+/* Helper to handle the help file. If @check is 1
+ the existence of the file is checked.
+ Otherwise the help file will be loaded. */
+static bool
+start_help (HWND dlg, int check)
+{
+ DWORD n;
+ char path[MAX_PATH+1+32];
+
+ n = GetModuleFileName (NULL, path, sizeof (path)-1-32);
+ if (!n)
+ return false;
+ path[n] = 0;
+ while (n-- && path[n] != '\\')
+ ;
+ path[n+1] = 0;
+ strcat (path, "winpt.chm");
+ if (!check)
+ ShellExecute (dlg, "open", path, NULL, NULL, SW_SHOW);
+ return file_exist_check (path) == 0? true : false;
+}
+
/* Translate all menu strings. */
static void
translate_menu_strings (HWND dlg)
@@ -934,8 +956,8 @@
set_menu_text (menu, ID_KEYMISC_VIEWTYPE, _("Type"));
set_menu_text (menu, ID_KEYMISC_VIEWCREAT, _("Creation"));
- /* XXX: implement help code. */
- set_menu_state (menu, ID_KEYMISC_HELP, MF_GRAYED);
+ if (!start_help (NULL, 1))
+ set_menu_state (menu, ID_KEYMISC_HELP, MF_GRAYED);
SetMenu (dlg, menu);
}
@@ -978,6 +1000,7 @@
}
+
/* Dialog box procedure for the Key Manager. */
BOOL CALLBACK
keymanager_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
@@ -1594,8 +1617,13 @@
IDS_WINPT_ABOUT);
break;
+ case ID_KEYMISC_WEBSITE:
+ ShellExecute (dlg, "open", "http://www.winpt.org",
+ NULL, NULL, SW_SHOW);
+ break;
+
case ID_KEYMISC_HELP:
- ShellExecute (dlg, "open", "winpt.chm", NULL, NULL, SW_SHOW);
+ start_help (dlg, 0);
break;
case ID_KEYMISC_OT:
@@ -1847,6 +1875,10 @@
case ID_GROUP_DELETE:
/* XXX: Implement group manager. */
return TRUE;
+
+ case IDCANCEL:
+ EndDialog (dlg, TRUE);
+ return TRUE;
}
break;
Modified: trunk/Src/wptKeygenDlg.cpp
===================================================================
--- trunk/Src/wptKeygenDlg.cpp 2005-12-30 13:56:10 UTC (rev 129)
+++ trunk/Src/wptKeygenDlg.cpp 2005-12-30 14:06:39 UTC (rev 130)
@@ -119,30 +119,18 @@
if (keytype == GPG_KEYGEN_NONE)
return NULL;
- if( comment && *comment ) {
- size = strlen (key_params_with_comment)
- + 16
- + strlen( user )
- + addsize
- + strlen( comment )
- + strlen( email )
- + strlen( passphrase ) + 32;
- }
- else {
- size = strlen( key_params )
- + 16
- + strlen( user )
- + strlen( email )
- + strlen( passphrase )
- + addsize
- + 32;
- }
- if( expdate )
- size += strlen( expdate );
- p = (char *)malloc( size+1 );
- if( !p )
- return NULL;
- if( comment && *comment ) {
+ size = strlen (user) + strlen (email) + strlen (passphrase) + addsize + 48;
+ if (comment && *comment)
+ size += strlen (key_params_with_comment) + strlen (comment);
+ else
+ size += strlen (key_params);
+ if (expdate)
+ size += strlen (expdate) + 1;
+ p = (char *)malloc (size+1);
+ if (!p)
+ BUG (0);
+ /* XXX: simply the whole switch-case code. */
+ if (comment && *comment) {
switch( keytype ) {
case GPG_KEYGEN_DSA_ELG:
sprintf (p, key_params_with_comment,
@@ -289,9 +277,10 @@
static void
backup_keyrings (HWND dlg)
{
+ const char *name;
+ char *path = NULL;
+ char *keyring = NULL;
int id;
- char *path = NULL, *keyring = NULL;
- const char * name;
path = get_gnupg_path ();
if (!path)
@@ -304,24 +293,26 @@
"Backup your keyrings now?"),
_("WARNING - Important hint" ), MB_YESNO);
if (id == IDYES) {
- name = get_filesave_dlg( dlg, _("Destination for Public Keyring"), NULL, "pubring.gpg" );
+ name = get_filesave_dlg (dlg, _("Destination for Public Keyring"),
+ NULL, "pubring.gpg");
if( name ) {
- keyring = make_filename( path, "pubring", "gpg" );
- if( !CopyFile( keyring, name, FALSE ) )
- log_box( _("Key Generation"), MB_ERR,
- _("Could not copy %s -> %s"), keyring, name );
- free_if_alloc( keyring );
+ keyring = make_filename (path, "pubring", "gpg");
+ if( !CopyFile (keyring, name, FALSE))
+ log_box (_("Key Generation"), MB_ERR,
+ _("Could not copy %s -> %s"), keyring, name);
+ free_if_alloc (keyring);
}
- name = get_filesave_dlg( dlg, _("Destination for Secret Keyring"), NULL, "secring.gpg" );
+ name = get_filesave_dlg (dlg, _("Destination for Secret Keyring"),
+ NULL, "secring.gpg");
if( name ) {
- keyring = make_filename( path, "secring", "gpg" );
- if( !CopyFile( keyring, name, FALSE ) )
- log_box( _("Key Generation"), MB_ERR,
- _("Could not copy %s -> %s"), keyring, name );
- free_if_alloc( keyring );
+ keyring = make_filename (path, "secring", "gpg");
+ if (!CopyFile (keyring, name, FALSE))
+ log_box (_("Key Generation"), MB_ERR,
+ _("Could not copy %s -> %s"), keyring, name);
+ free_if_alloc (keyring);
}
}
- free_if_alloc( path );
+ free_if_alloc (path);
}
@@ -329,17 +320,17 @@
static void
fill_keytype_box (HWND dlg)
{
- HWND cb = GetDlgItem (dlg, IDC_KEYGEN_KEYTYPE );
+ HWND cb = GetDlgItem (dlg, IDC_KEYGEN_KEYTYPE);
-#define addstr( cb, str ) \
- SendMessage( (cb), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)(str) )
- addstr( cb, _("DSA and ELG (default)") );
- addstr( cb, _("DSA and RSA") );
- addstr( cb, _("DSA sign only") );
- addstr( cb, _("RSA sign only") );
- addstr( cb, _("RSA sign and encrypt") );
- addstr( cb, _("RSA and RSA (PGP)") );
- SendMessage( cb, CB_SETCURSEL, 0, 0 );
+#define addstr(cb, str) \
+ SendMessage ((cb), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)(str))
+ addstr (cb, _("DSA and ELG (default)"));
+ addstr (cb, _("DSA and RSA"));
+ addstr (cb, _("DSA sign only"));
+ addstr (cb, _("RSA sign only"));
+ addstr (cb, _("RSA sign and encrypt"));
+ addstr (cb, _("RSA and RSA (PGP)") );
+ SendMessage (cb, CB_SETCURSEL, 0, 0);
#undef addstr
}
@@ -355,7 +346,7 @@
if (st->wYear > t.wYear || st->wMonth > t.wMonth)
return 1;
else if (st->wYear < t.wYear || st->wMonth < t.wMonth || st->wDay < t.wDay)
- return 0;
+ return 0;
return 1;
}
@@ -368,32 +359,30 @@
SYSTEMTIME st;
gpgme_error_t err;
char name[128] = {0}, email[128] = {0}, comment[128] = {0};
- char pwd[128], pwd2[128];
+ char *pwd;
char t[64], *expire = NULL, *fpr=NULL;
- int bits, use_comment, keytype = 0;
- char * p;
+ int bits, use_comment, keytype = 0;
+ int cancel = 0;
+ char *p;
switch ( msg ) {
case WM_INITDIALOG:
if (lparam != 0)
ctx = (genkey_s *)lparam;
- SetWindowText( dlg, _("Key Generation") );
- SetDlgItemText( dlg, IDC_KEYGEN_INFO,
+ SetWindowText (dlg, _("Key Generation"));
+ SetDlgItemText(dlg, IDC_KEYGEN_INFO,
_("NOTE: Key generation can be a lengthy process! Please wait until "
- "you get the message that key generation was finished.") );
- SetDlgItemText( dlg, IDC_KEYGEN_SUBKEYINF, _("Subkey size in &bits"));
- SetDlgItemText( dlg, IDC_KEYGEN_NAMEINF, _("&Real name") );
- SetDlgItemText( dlg, IDC_KEYGEN_COMMINF, _("&Comment (optional)") );
- SetDlgItemText( dlg, IDC_KEYGEN_EMAILINF, _("Email &address") );
- SetDlgItemText( dlg, IDC_KEYGEN_EXPINF, _("&Expire date"));
- SetDlgItemText( dlg, IDC_KEYGEN_PWDINF, _("&Passphrase") );
- SetDlgItemText( dlg, IDC_KEYGEN_REPWDINF, _("&Repeat passphrase") );
- SetDlgItemText( dlg, IDC_KEYGEN_KEYTYPEINF, _("Key &type") );
+ "you get the message that key generation was finished."));
+ SetDlgItemText (dlg, IDC_KEYGEN_SUBKEYINF, _("Subkey size in &bits"));
+ SetDlgItemText (dlg, IDC_KEYGEN_NAMEINF, _("&Real name"));
+ SetDlgItemText (dlg, IDC_KEYGEN_COMMINF, _("&Comment (optional)"));
+ SetDlgItemText (dlg, IDC_KEYGEN_EMAILINF, _("Email &address"));
+ SetDlgItemText (dlg, IDC_KEYGEN_EXPINF, _("&Expire date"));
+ SetDlgItemText (dlg, IDC_KEYGEN_KEYTYPEINF, _("Key &type"));
SetDlgItemText (dlg, IDC_KEYGEN_EXPNEVER, _("&Never"));
- SetDlgItemText (dlg, IDC_KEYGEN_HIDEPWD, _("&Hide Typing"));
SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
- SetDlgItemInt (dlg, IDC_KEYGEN_SUBKEYBITS, 2048, FALSE);
+ SetDlgItemInt (dlg, IDC_KEYGEN_SUBKEYBITS, DFAULT_KEYSIZE, FALSE);
CheckDlgButton (dlg, IDC_KEYGEN_HIDEPWD, BST_CHECKED);
CheckDlgButton (dlg, IDC_KEYGEN_EXPNEVER, BST_CHECKED);
EnableWindow (GetDlgItem (dlg, IDC_KEYGEN_EXPDATE), FALSE);
@@ -403,11 +392,8 @@
return TRUE;
case WM_SYSCOMMAND:
- if (LOWORD (wparam) == SC_CLOSE) {
- SetDlgItemText (dlg, IDC_KEYGEN_PASSPHRASE, "");
- SetDlgItemText (dlg, IDC_KEYGEN_PWDCHECK, "");
+ if (LOWORD (wparam) == SC_CLOSE)
EndDialog (dlg, TRUE);
- }
return FALSE;
case WM_COMMAND:
@@ -416,18 +402,8 @@
int never = IsDlgButtonChecked (dlg, IDC_KEYGEN_EXPNEVER);
EnableWindow (GetDlgItem (dlg, IDC_KEYGEN_EXPDATE), !never);
}
- if (HIWORD (wparam) == BN_CLICKED
- && LOWORD (wparam) == IDC_KEYGEN_HIDEPWD) {
- HWND hwnd_a = GetDlgItem (dlg, IDC_KEYGEN_PASSPHRASE);
- HWND hwnd_b = GetDlgItem (dlg, IDC_KEYGEN_PWDCHECK);
- int hide = IsDlgButtonChecked (dlg, IDC_KEYGEN_HIDEPWD);
- SendMessage (hwnd_a, EM_SETPASSWORDCHAR, hide? '*' : 0, 0);
- SetFocus (hwnd_a);
- SendMessage (hwnd_b, EM_SETPASSWORDCHAR, hide? '*' : 0, 0);
- SetFocus (hwnd_b);
- }
- switch( LOWORD( wparam ) ) {
+ switch (LOWORD (wparam)) {
case IDOK:
bits = GetDlgItemInt (dlg, IDC_KEYGEN_SUBKEYBITS, NULL, FALSE);
if (bits < 1024 || bits > 4096) {
@@ -436,13 +412,13 @@
return FALSE;
}
if (bits > DFAULT_KEYSIZE) {
- int id = msg_box (dlg, _("Do you really need such a large key?"),
+ int id = msg_box (dlg, _("Do you really need such a large key?"),
_("Key Generation"), MB_YESNO);
if (id == IDNO)
bits = DFAULT_KEYSIZE;
}
- if( !GetDlgItemText( dlg, IDC_KEYGEN_NAME, name, sizeof name - 1 ) ) {
- msg_box( dlg, _("Please enter the name."), _("Key Generation"), MB_ERR );
+ if (!GetDlgItemText (dlg, IDC_KEYGEN_NAME, name, sizeof (name) - 1)) {
+ msg_box( dlg, _("Please enter the name."), _("Key Generation"), MB_ERR);
return FALSE;
}
if (strchr (name, '@')) {
@@ -450,16 +426,17 @@
_("Key Generation"), MB_INFO);
return FALSE;
}
- if( !GetDlgItemText(dlg, IDC_KEYGEN_EMAIL, email, sizeof email -1 )
- || !strchr( email, '@') ) {
- msg_box( dlg, _("Please enter a valid email address."),
- _("Key Generation"), MB_ERR );
+ if (!GetDlgItemText (dlg, IDC_KEYGEN_EMAIL, email, sizeof (email) -1)
+ || !strchr (email, '@')) {
+ msg_box (dlg, _("Please enter a valid email address."),
+ _("Key Generation"), MB_ERR);
return FALSE;
}
- use_comment = GetDlgItemText( dlg, IDC_KEYGEN_COMMENT, comment, sizeof comment -1 );
- if( use_comment > 0 && strchr( comment, '@' ) ) {
- msg_box( dlg, _("Please do NOT enter the email address in the comment field."),
- _("Key Generation"), MB_INFO );
+ use_comment = GetDlgItemText(dlg, IDC_KEYGEN_COMMENT,
+ comment, sizeof (comment) -1);
+ if (use_comment > 0 && strchr (comment, '@')) {
+ msg_box (dlg, _("Please do NOT enter the email address in the comment field."),
+ _("Key Generation"), MB_INFO);
return FALSE;
}
keytype = SendDlgItemMessage (dlg, IDC_KEYGEN_KEYTYPE, CB_GETCURSEL, 0, 0) + 1;
@@ -470,68 +447,41 @@
_snprintf (t, DIM (t)-1, "%04d-%02d-%02d", st.wYear, st.wMonth, st.wDay);
expire = t;
}
-
- if( !GetDlgItemText( dlg, IDC_KEYGEN_PASSPHRASE, pwd, sizeof pwd -1 ) ) {
- msg_box( dlg, _("Please enter the passphrase."),
- _("Key Generation"), MB_ERR );
- return FALSE;
- }
- else if (check_passwd_quality (pwd, 0)) {
- int id = msg_box( dlg, _("Your passphrase should be at least 8 characters"
- " long\nand should contain non-alphabetic characters."
- "\n\nStill proceed?"),
- _("Key Generation"), MB_ICONWARNING|MB_YESNO );
- if( id == IDNO ) {
- SetDlgItemText( dlg, IDC_KEYGEN_PASSPHRASE, "" );
- SetDlgItemText( dlg, IDC_KEYGEN_PWDCHECK, "" );
- return FALSE;
- }
- }
- if( !GetDlgItemText( dlg, IDC_KEYGEN_PWDCHECK, pwd2, sizeof pwd2 -1 ) ) {
- msg_box( dlg, _("Please repeat the passphrase."),
- _("Key Generation"), MB_ERR );
- return FALSE;
- }
- if( strcmp( pwd, pwd2 ) ) {
- msg_box( dlg, _("Passphrases are NOT identical!" ),
- _("Key Generation"), MB_ERR );
- wipememory (pwd, sizeof (pwd));
- wipememory (pwd2, sizeof (pwd2));
- return FALSE;
- }
- if( is_8bit_string( pwd ) ) {
- msg_box( dlg, _("The passphrase contains 8-bit characters.\n"
- "It is not suggested to use charset specific characters."),
- _("Key Generation"), MB_ERR );
- wipememory (pwd, sizeof (pwd));
- wipememory (pwd2, sizeof (pwd2));
- SetDlgItemText( dlg, IDC_KEYGEN_PASSPHRASE, "" );
- SetDlgItemText( dlg, IDC_KEYGEN_PWDCHECK, "" );
+
+ pwd = request_passphrase2 (_("Key Generation"), PASSDLG_STRICT, &cancel);
+ if (cancel) {
+ sfree_if_alloc (pwd);
return FALSE;
}
-
- if( !use_comment && !strlen( comment ) ) {
+ if (!pwd) {
+ msg_box (dlg, _("Please enter the passphrase."),
+ _("Key Generation"), MB_ERR);
+ return FALSE;
+ }
+
+ if (!use_comment && !strlen (comment)) {
char *utf8_name;
utf8_name = wincp_to_utf8 (name, strlen (name));
- if( !utf8_name )
- BUG( dlg );
- p = gpg_genkey_params( keytype, bits, utf8_name, NULL, email, expire, pwd );
- free( utf8_name );
+ if (!utf8_name)
+ BUG (0);
+ p = gpg_genkey_params (keytype, bits, utf8_name, NULL,
+ email, expire, pwd);
+ safe_free (utf8_name);
}
else {
char *utf8_name, *utf8_comment;
utf8_name = wincp_to_utf8 (name, strlen (name));
utf8_comment = wincp_to_utf8 (comment, strlen (comment));
if( !utf8_name || !utf8_comment )
- BUG( dlg );
- p = gpg_genkey_params( keytype, bits, utf8_name, utf8_comment, email, expire, pwd );
- free( utf8_name );
- free( utf8_comment );
+ BUG (0);
+ p = gpg_genkey_params (keytype, bits, utf8_name, utf8_comment,
+ email, expire, pwd);
+ safe_free (utf8_name);
+ safe_free (utf8_comment);
}
- keygen_cb_dlg_create( );
+ keygen_cb_dlg_create ();
err = gpg_genkey (p, keygen_cb, &fpr);
- wipememory (pwd, sizeof (pwd));
- wipememory (pwd2, sizeof (pwd2));
+ sfree_if_alloc (pwd);
if (p) {
wipememory (p, strlen (p)); /* burn the passphrase! */
free (p);
@@ -539,8 +489,7 @@
keygen_cb_dlg_destroy ();
keygen_cb (NULL, NULL, 0, 0, 0); /* flush */
if (err) {
- if (fpr)
- free (fpr);
+ safe_free (fpr);
msg_box (dlg, gpgme_strerror (err), _("Key Generation"), MB_ERR);
return FALSE;
}
@@ -558,8 +507,6 @@
return TRUE;
case IDCANCEL:
- SetDlgItemText (dlg, IDC_KEYGEN_PASSPHRASE, "");
- SetDlgItemText (dlg, IDC_KEYGEN_PWDCHECK, "");
EndDialog (dlg, FALSE);
return FALSE;
}
Modified: trunk/Src/wptMDSumDlg.cpp
===================================================================
--- trunk/Src/wptMDSumDlg.cpp 2005-12-30 13:56:10 UTC (rev 129)
+++ trunk/Src/wptMDSumDlg.cpp 2005-12-30 14:06:39 UTC (rev 130)
@@ -32,8 +32,8 @@
#include "wptContext.h"
#include "wptNLS.h"
#include "wptErrors.h"
-#include "wptCrypto.h"
+
/* Return a printable digest of the buffer @mdbuf. */
static const char*
printable_digest (byte *mdbuf, size_t n)
@@ -46,6 +46,21 @@
}
+static const char*
+id2algo (int mdalgo)
+{
+ gpgme_hash_algo_t md = (gpgme_hash_algo_t)mdalgo;
+
+ switch (md) {
+ case GPGME_MD_MD5: return "MD5";
+ case GPGME_MD_SHA1: return "SHA1";
+ case GPGME_MD_RMD160: return "RMD160";
+ case GPGME_MD_SHA256: return "SHA256";
+ }
+ return "";
+}
+
+
/* Dialog box procedure to show and calculate file digests. */
BOOL CALLBACK
mdsum_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
@@ -58,6 +73,7 @@
{0, 0, 0}
};
gpgme_data_t sumlist;
+ const char *name;
char fname[300], mdasc[64];
byte mdbuf[20];
int i;
@@ -89,6 +105,11 @@
SetForegroundWindow (dlg);
break;
+ case WM_SYSCOMMAND:
+ if (wparam == SC_CLOSE)
+ EndDialog (dlg, TRUE);
+ return TRUE;
+
case WM_DESTROY:
if( lv ) {
listview_release( lv );
@@ -105,7 +126,7 @@
case IDC_MDSUM_COPY:
if (gpgme_data_new (&sumlist))
BUG(0);
- if (md->mdalgo == 3) {/* rmd160 */
+ if (md->mdalgo == (int)GPGME_MD_RMD160) {
const char *s = "# warning rmd160sum is not yet available\r\n";
gpgme_data_write (sumlist, s, strlen (s));
}
@@ -118,10 +139,13 @@
gpgme_data_write (sumlist, fname, strlen (fname));
gpgme_data_write (sumlist, "\r\n", 2);
}
- const char *name = get_filesave_dlg (dlg, _("Select file to save checksums"), NULL, NULL);
+ _snprintf (fname, sizeof (fname)-1, "%s_sums.txt", id2algo (md->mdalgo));
+ name = get_filesave_dlg (dlg, _("Select file to save checksums"),
+ NULL, fname);
if (name && *name) {
gpg_data_release_and_set_file (sumlist, name);
- log_box (_("File Manager"), MB_OK, "Checksums successfully saved in '%s'", name);
+ log_box (_("File Manager"), MB_OK,
+ _("Checksums successfully saved in '%s'"), name);
}
else
gpgme_data_release (sumlist);
Modified: trunk/Src/wptPassphraseDlg.cpp
===================================================================
--- trunk/Src/wptPassphraseDlg.cpp 2005-12-30 13:56:10 UTC (rev 129)
+++ trunk/Src/wptPassphraseDlg.cpp 2005-12-30 14:06:39 UTC (rev 130)
@@ -66,7 +66,6 @@
SetDlgItemText (dlg, IDC_PASSWD_INFO, _("Enter Passphrase"));
SetDlgItemText (dlg, IDC_PASSWD_HIDE, _("&Hide Typing"));
SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
-
SetFocus (GetDlgItem (dlg, IDC_PASSWD_PWD ));
center_window2 (dlg, NULL, HWND_TOPMOST);
center_window (dlg, NULL);
@@ -85,7 +84,7 @@
switch (LOWORD (wparam)) {
case IDOK:
pwd->cancel = 0;
- nbytes = GetDlgItemText( dlg, IDC_PASSWD_PWD, pwd->pwd, DIM (pwd->pwd)-1);
+ nbytes = GetDlgItemText (dlg, IDC_PASSWD_PWD, pwd->pwd, DIM (pwd->pwd)-1);
if (!nbytes)
strcpy (pwd->pwd, "");
else if (pwd->strict && check_passwd_quality (pwd->pwd, 0)) {
Modified: trunk/Src/wptPreferencesDlg.cpp
===================================================================
--- trunk/Src/wptPreferencesDlg.cpp 2005-12-30 13:56:10 UTC (rev 129)
+++ trunk/Src/wptPreferencesDlg.cpp 2005-12-30 14:06:39 UTC (rev 130)
@@ -218,6 +218,8 @@
!IsDlgButtonChecked (dlg, IDC_PREFS_BAKUSER))
CheckDlgButton (dlg, IDC_PREFS_BAKHOME, BST_CHECKED);
}
+ if (IsDlgButtonChecked (dlg, IDC_PREFS_BAKHOME))
+ EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), FALSE);
break;
case IDC_PREFS_BAKHOME:
More information about the Winpt-commits
mailing list