[Winpt-commits] r193 - trunk/Src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sat Apr 1 14:36:42 CEST 2006
Author: twoaday
Date: 2006-04-01 14:36:35 +0200 (Sat, 01 Apr 2006)
New Revision: 193
Removed:
trunk/Src/winpt_km.bmp
Modified:
trunk/Src/ChangeLog
trunk/Src/Makefile.am
trunk/Src/WinPT-en.rc
trunk/Src/WinPT.cpp
trunk/Src/resource.h
trunk/Src/versioninfo.rc.in
trunk/Src/wptAboutDlgs.cpp
trunk/Src/wptCardDlg.cpp
trunk/Src/wptCardPCSC.c
trunk/Src/wptClipSignDlg.cpp
trunk/Src/wptCommonDlg.cpp
trunk/Src/wptCryptdisk.cpp
trunk/Src/wptFileManager.cpp
trunk/Src/wptFileManagerDlg.cpp
trunk/Src/wptGPGMEData.cpp
trunk/Src/wptGPGPrefsDlg.cpp
trunk/Src/wptGPGUtil.cpp
trunk/Src/wptKeyEditDlgs.cpp
trunk/Src/wptKeyManager.cpp
trunk/Src/wptKeyManagerDlg.cpp
trunk/Src/wptKeyRevokersDlg.cpp
trunk/Src/wptKeyserver.cpp
trunk/Src/wptListView.cpp
trunk/Src/wptMAPI.cpp
trunk/Src/wptMainProc.cpp
trunk/Src/wptNLS.c
trunk/Src/wptRegistry.cpp
trunk/Src/wptSafeEditCtrl.cpp
trunk/Src/wptSigTreeDlg.cpp
trunk/Src/wptSymEnc.cpp
trunk/Src/wptUTF8.cpp
trunk/Src/wptVerifyList.cpp
trunk/Src/wptW32API.cpp
Log:
2006-03-31 Timo Schulz <ts at g10code.de>
* wptCommonDlg.cpp (nls_load_langlist): New.
(nsl_set_language): New.
(nls_dlg_proc): New.
(select_language): New. Allow user to select the language.
* wptNLS.c (get_gettext_langid): Updated available languages.
* WinPT.cpp (WinMain): Allow to select the languag on first
start in non-installer environments.
* wptVerifyList.cpp (verlist_build): Simplified.
(verlist_add_sig_log): Likewise.
* wptListview.cpp (listview_set_column_width,
listview_get_selected_item): New.
* wptKeyManager.cpp (gpg_clip_export): Merged into..
(km_clip_export): ..this function.
Modified: trunk/Src/ChangeLog
===================================================================
--- trunk/Src/ChangeLog 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/ChangeLog 2006-04-01 12:36:35 UTC (rev 193)
@@ -1,3 +1,41 @@
+2006-03-31 Timo Schulz <ts at g10code.de>
+
+ * wptCommonDlg.cpp (nls_load_langlist): New.
+ (nsl_set_language): New.
+ (nls_dlg_proc): New.
+ (select_language): New. Allow user to select the language.
+ * wptNLS.c (get_gettext_langid): Updated available languages.
+ * WinPT.cpp (WinMain): Allow to select the languag on first
+ start in non-installer environments.
+ * wptVerifyList.cpp (verlist_build): Simplified.
+ (verlist_add_sig_log): Likewise.
+ * wptListview.cpp (listview_set_column_width,
+ listview_get_selected_item): New.
+ * wptKeyManager.cpp (gpg_clip_export): Merged into..
+ (km_clip_export): ..this function.
+
+2006-03-30 Timo Schulz <ts at g10code.de>
+
+ * wptW32API.cpp (insert_menu_item): New.
+ * wptSigTreeDlg.cpp (create_popup): Use it.
+ (sigtree_dlg_proc): Only show the name of the owner in the title.
+ * wptMainProc.cpp (init_common_controls): Initialize all
+ common controls here.
+ * wptKeyManagerDlg.cpp (keymanager_dlg_proc): Drop static
+ keyserver menu concept. Add all keyservers dynamically.
+
+2006-03-29 Timo Schulz <ts at g10code.de>
+
+ * wptKeyManager.cpp (km_refresh_one_key): Fix problem
+ with preferred keyserver.
+ * wptCommonDlg.cpp (check_URL): Allow non-http URL.
+ * wptKeyEditDlgs.cpp (subkey_subclass_proc,
+ uid_subclass_proc): Disable shortcuts for non keypairs.
+ * wptMainProc.cpp (winpt_main_proc): No user interaction
+ on automatic shutdown. Thanks to Werner.
+ * wptGPGUtil.cpp (xcalloc): New.
+ (gpg_rebuild_cache): Use --batch.
+
2006-03-26 Timo Schulz <ts at g10code.de>
* wptSigTreeDlg.cpp (sigtree_load): Always use UTF8.
Modified: trunk/Src/Makefile.am
===================================================================
--- trunk/Src/Makefile.am 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/Makefile.am 2006-04-01 12:36:35 UTC (rev 193)
@@ -27,7 +27,6 @@
Sign.ico \
WinPT-en.rc \
winpt2.ico \
- winpt_km.bmp \
pubkey.ico \
keypair.ico
Modified: trunk/Src/WinPT-en.rc
===================================================================
--- trunk/Src/WinPT-en.rc 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/WinPT-en.rc 2006-04-01 12:36:35 UTC (rev 193)
@@ -173,7 +173,19 @@
BS_FLAT | WS_DISABLED | WS_TABSTOP,4,16,102,10
END
+IDD_WINPT_LANGUAGE DIALOG DISCARDABLE 0, 0, 149, 74
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Native Language Support"
+FONT 8, "MS Sans Serif"
+BEGIN
+ LTEXT "Please select a language",IDC_LANGUAGE_INFO,9,6,117,10
+ COMBOBOX IDC_LANGUAGE_LIST,9,19,103,41,CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "&OK",IDOK,41,56,50,14
+ PUSHBUTTON "&Cancel",IDCANCEL,93,56,50,14
+END
+
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
@@ -213,6 +225,14 @@
TOPMARGIN, 3
BOTTOMMARGIN, 138
END
+
+ IDD_WINPT_LANGUAGE, DIALOG
+ BEGIN
+ LEFTMARGIN, 2
+ RIGHTMARGIN, 144
+ TOPMARGIN, 1
+ BOTTOMMARGIN, 70
+ END
END
#endif // APSTUDIO_INVOKED
@@ -245,7 +265,7 @@
// Dialog
//
-IDD_WINPT_ABOUT DIALOG DISCARDABLE 0, 0, 269, 231
+IDD_WINPT_ABOUT DIALOG DISCARDABLE 0, 0, 269, 226
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About WinPT"
FONT 8, "MS Sans Serif"
@@ -253,26 +273,25 @@
DEFPUSHBUTTON "&OK",IDOK,208,11,50,14
PUSHBUTTON "&About GPG...",IDC_ABOUT_GPG,208,28,50,14
PUSHBUTTON "&Help",IDC_ABOUT_HELP,208,45,50,14
- ICON IDI_WINPT,IDC_STATIC,17,13,20,20
+ ICON IDI_WINPT,IDC_STATIC,17,13,21,20
LTEXT "Windows Privacy Tray",IDC_STATIC,45,11,72,8
LTEXT "Version 0.1.1 (2001-01-29)",IDC_WINPT_VERSION,45,22,129,
8
LTEXT "Copyright (C) 2006 Timo Schulz <twoaday at freakmail.de>",
IDC_STATIC,8,42,182,8
LTEXT "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.",
- IDC_ABOUT_GPL1,10,141,223,36
- GROUPBOX "Warranty",IDC_ABOUT_GPLINF,6,127,240,91
+ IDC_ABOUT_GPL1,10,137,223,36
+ GROUPBOX "Warranty",IDC_ABOUT_GPLINF,6,123,240,91
LTEXT "WinPT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABLITY or FITNESS FOR A PARTICULAR PURPOSE. See the General Public License for more details.",
- IDC_ABOUT_GPL2,10,181,231,34
+ IDC_ABOUT_GPL2,10,177,231,34
LTEXT "Please report any BUGS or suggestions for WinPT to <winpt at freakmail.de>",
- IDC_ABOUT_BUGS,8,114,247,8
- LTEXT "GPG Made Easy (gpgme), Copyright (C) 2005 g10 Code GmbH",
- IDC_STATIC,8,69,200,8
+ IDC_ABOUT_BUGS,8,110,247,8
LTEXT "A free open source privacy tray for Windows based on GnuPG.",
- IDC_ABOUT_INFO,8,86,234,8
+ IDC_ABOUT_INFO,8,82,234,8
LTEXT "For more information you can visit the homepage: http://www.winpt.org",
- IDC_ABOUT_URL,8,94,245,8
- LTEXT "Third party software:",IDC_STATIC,8,59,65,8
+ IDC_ABOUT_URL,8,90,245,8
+ LTEXT "The AUTHORS files contains a list of all contributors and co-authors.",
+ IDC_ABOUT_AUTHORS,6,64,250,8
END
IDD_WINPT_CLIPEDIT DIALOG DISCARDABLE 0, 0, 331, 236
@@ -329,24 +348,23 @@
PUSHBUTTON "&Cancel",IDCANCEL,165,150,49,14
END
-IDD_WINPT_KEYSERVER DIALOG DISCARDABLE 0, 0, 219, 215
+IDD_WINPT_KEYSERVER DIALOG DISCARDABLE 0, 0, 209, 186
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Keyserver Access"
FONT 8, "MS Sans Serif"
BEGIN
CONTROL "List1",IDC_KEYSERVER_LIST,"SysListView32",LVS_REPORT |
LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING |
- WS_BORDER | WS_TABSTOP,6,5,208,133
- LTEXT "Proxy: none",IDC_KEYSERVER_PROXY,6,145,146,9
- PUSHBUTTON "C&hange",IDC_KEYSERVER_PROXSETT,168,142,46,13
- GROUPBOX "",IDC_STATIC,5,157,209,36
+ WS_BORDER | WS_TABSTOP,6,5,194,100
+ PUSHBUTTON "C&hange proxy",IDC_KEYSERVER_PROXSETT,138,106,61,13
+ GROUPBOX "",IDC_STATIC,5,128,193,36
LTEXT "Please enter the key ID or email address you search for",
- IDC_KEYSERVER_INFO,8,165,199,8
- EDITTEXT IDC_KEYSERVER_SEARCH,8,177,198,12,ES_AUTOHSCROLL
- DEFPUSHBUTTON "&Receive",IDC_KEYSERVER_RECV,5,196,46,14
- PUSHBUTTON "&Search",IDC_KEYSERVER_INDEX,53,196,36,14
- PUSHBUTTON "Set &default",IDC_KEYSERVER_DEFAULT,119,196,48,14
- PUSHBUTTON "&Close",IDCANCEL,169,196,45,14
+ IDC_KEYSERVER_INFO,8,138,187,8
+ EDITTEXT IDC_KEYSERVER_SEARCH,8,150,182,12,ES_AUTOHSCROLL
+ DEFPUSHBUTTON "&Receive",IDC_KEYSERVER_RECV,5,169,46,14
+ PUSHBUTTON "&Search",IDC_KEYSERVER_INDEX,53,169,36,14
+ PUSHBUTTON "Set &default",IDC_KEYSERVER_DEFAULT,107,169,48,14
+ PUSHBUTTON "&Close",IDCANCEL,157,169,45,14
END
IDD_WINPT_SIGN DIALOG DISCARDABLE 0, 0, 299, 125
@@ -416,13 +434,13 @@
WS_TABSTOP,6,7,451,190,WS_EX_ACCEPTFILES
END
-IDD_WINPT_ABOUTGPG DIALOG DISCARDABLE 0, 0, 344, 154
+IDD_WINPT_ABOUTGPG DIALOG DISCARDABLE 0, 0, 272, 162
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About the GNU Privacy Guard"
FONT 8, "MS Sans Serif"
BEGIN
- LTEXT "About GPG",IDC_ABOUTGPG_INFO,9,8,314,122
- DEFPUSHBUTTON "&OK",IDOK,281,132,50,14
+ LTEXT "About GPG",IDC_ABOUTGPG_INFO,9,8,250,122
+ DEFPUSHBUTTON "&OK",IDOK,213,141,50,14
END
IDD_WINPT_KEYEDIT_OWNERTRUST DIALOG DISCARDABLE 0, 0, 183, 114
@@ -1359,17 +1377,6 @@
PUSHBUTTON "&Cancel",IDCANCEL,131,45,50,14
END
-IDD_WINPT_INFODLG DIALOG DISCARDABLE 0, 0, 260, 66
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "Dialog"
-FONT 8, "MS Sans Serif"
-BEGIN
- DEFPUSHBUTTON "Button1",IDOK,151,50,50,14
- PUSHBUTTON "Button2",IDCANCEL,205,50,50,14
- ICON "",IDC_INFODLG_ICO,11,14,20,20
- LTEXT "Static",IDC_INFODLG_TEXT,44,14,196,29
-END
-
IDD_WINPT_KEYSERVER_ADD DIALOG DISCARDABLE 0, 0, 186, 101
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Edit Keyserver"
@@ -1412,7 +1419,7 @@
LEFTMARGIN, 3
RIGHTMARGIN, 262
TOPMARGIN, 7
- BOTTOMMARGIN, 224
+ BOTTOMMARGIN, 219
END
IDD_WINPT_CLIPEDIT, DIALOG
@@ -1442,9 +1449,9 @@
IDD_WINPT_KEYSERVER, DIALOG
BEGIN
LEFTMARGIN, 3
- RIGHTMARGIN, 214
+ RIGHTMARGIN, 204
TOPMARGIN, 3
- BOTTOMMARGIN, 211
+ BOTTOMMARGIN, 182
END
IDD_WINPT_SIGN, DIALOG
@@ -1482,9 +1489,9 @@
IDD_WINPT_ABOUTGPG, DIALOG
BEGIN
LEFTMARGIN, 4
- RIGHTMARGIN, 337
+ RIGHTMARGIN, 265
TOPMARGIN, 4
- BOTTOMMARGIN, 147
+ BOTTOMMARGIN, 155
END
IDD_WINPT_KEYEDIT_OWNERTRUST, DIALOG
@@ -1903,14 +1910,6 @@
BOTTOMMARGIN, 59
END
- IDD_WINPT_INFODLG, DIALOG
- BEGIN
- LEFTMARGIN, 1
- RIGHTMARGIN, 255
- TOPMARGIN, 1
- BOTTOMMARGIN, 64
- END
-
IDD_WINPT_KEYSERVER_ADD, DIALOG
BEGIN
LEFTMARGIN, 3
@@ -2182,15 +2181,6 @@
BEGIN
MENUITEM "Default Keyserver", ID_KEYCTX_KS_DEFAULT
MENUITEM SEPARATOR
- MENUITEM "hkp://wwwkeys.nl.pgp.net", ID_KEYCTX_KS_NL
- MENUITEM "hkp://wwwkeys.pl.pgp.net", ID_KEYCTX_KS_PL
- MENUITEM "hkp://wwwkeys.at.pgp.net", ID_KEYCTX_KS_AT
- MENUITEM "hkp://wwwkeys.ch.pgp.net", ID_KEYCTX_KS_CH
- MENUITEM "hkp://wwwkeys.de.pgp.net", ID_KEYCTX_KS_DE
- MENUITEM "hkp://wwwkeys.dk.pgp.net", ID_KEYCTX_KS_DK
- MENUITEM "hkp://wwwkeys.cz.pgp.net", ID_KEYCTX_KS_CZ
- MENUITEM "hkp://wwwkeys.es.pgp.net", ID_KEYCTX_KS_ES
- MENUITEM "hkp://wwwkeys.uk.pgp.net", ID_KEYCTX_KS_UK
END
MENUITEM SEPARATOR
MENUITEM "Set as Default Key", ID_KEYCTX_SETDEFKEY, GRAYED
Modified: trunk/Src/WinPT.cpp
===================================================================
--- trunk/Src/WinPT.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/WinPT.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -86,25 +86,14 @@
}
-/* Return the name of the gettext language file. */
-static char*
-get_gettext_lang (void)
-{
- char *fname;
- fname = get_reg_entry_mo ();
- if (!fname)
- return NULL;
- return fname;
-}
-
-
/* Initialize the gettext sub system. */
static void
-load_gettext (int prev_inst)
+load_gettext (void)
{
char *nls = NULL;
- nls = get_gettext_lang ();
+ /* Return the name of the gettext language file. */
+ nls = get_reg_entry_mo ();
if (nls != NULL) {
set_gettext_file ("winpt", nls);
free_if_alloc (nls);
@@ -216,7 +205,7 @@
check_default_key (gpg_keycache_t kc)
{
gpgme_key_t key;
- gpgme_error_t err = GPG_ERR_NO_ERROR;
+ gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);
char *defkey;
defkey = get_gnupg_default_key ();
@@ -268,7 +257,7 @@
static bool
check_crypto_engine (void)
{
- int ma=0, mi=0, pa=0;
+ int ma = 0, mi = 0, pa = 0;
int rc;
rc = check_gnupg_engine (NEED_GPG_VERSION, &ma, &mi, &pa);
@@ -285,7 +274,7 @@
return false;
}
/* 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;
@@ -301,7 +290,7 @@
load_keyserver_conf (int quiet)
{
char *buf;
- const char *t;
+ const char *t, *conf;
int rc;
/* Create $APPDATA\winpt if needed. */
@@ -317,13 +306,12 @@
/* Check for $APPDATA\winpt\keyserver.conf */
buf = make_special_filename (CSIDL_APPDATA, "winpt\\keyserver.conf", NULL);
- if (!file_exist_check (get_prog_part ("keyserver.conf", 0)))
- t = get_prog_part ("keyserver.conf", 0);
+ conf = get_prog_part ("keyserver.conf", 0);
+ if (!file_exist_check (conf))
+ t = conf;
else
t = "keyserver.conf";
if (file_exist_check (t) == 0 && file_exist_check (buf) != 0) {
- //log_box (_("Keyserver"), MB_INFO,
- // _("keyserver.conf will be copied to \"%s\"\r\n"), buf);
if (!CopyFile (t, buf, FALSE)) {
MessageBox (NULL, _("Failed to copy the keyserver.conf"),
_("Keyserver"), MB_ERR);
@@ -437,12 +425,12 @@
HACCEL accel_tab;
MSG msg;
HWND hwnd = NULL;
- WORD ver[3], ptdver[4];
+ /*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;
+ const char *s;
glob_hinst = hinst;
if (cmdline && stristr (cmdline, "--stop")) {
@@ -452,26 +440,16 @@
return 0;
}
- /*
- 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
+ /* XXX
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"
@@ -505,7 +483,7 @@
}
set_default_keyserver ();
- load_gettext (winpt_inst_found);
+ load_gettext ();
if (!mobile_mode_active) {
regist_inst_gnupg (1);
@@ -733,6 +711,10 @@
free_gnupg_table ();
return 0;
}
+ if (!is_gpg4win_installed ()) {
+ select_language ();
+ load_gettext ();
+ }
}
else {
gpg_keycache_t c, sec_c;
Modified: trunk/Src/resource.h
===================================================================
--- trunk/Src/resource.h 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/resource.h 2006-04-01 12:36:35 UTC (rev 193)
@@ -164,6 +164,7 @@
#define IDD_WINPT_KEYSIG_TREE 241
#define IDI_KEY_SIG 242
#define IDI_USERID 243
+#define IDD_WINPT_LANGUAGE 245
#define IDC_CLIPEDIT_SEND 1000
#define IDC_CLIPEDIT_CLEAR 1001
#define IDC_CLIPEDIT_CLIPTEXT 1002
@@ -642,6 +643,9 @@
#define IDC_PROXY_PROTO 1517
#define IDC_PROXY_AUTHINF 1518
#define IDC_GPGPREFS_ASKEXPIRE 1520
+#define IDC_ABOUT_AUTHORS 1522
+#define IDC_LANGUAGE_INFO 1523
+#define IDC_LANGUAGE_LIST 1524
#define ID_GPG_ENCRYPT 40003
#define ID_GPG_DECRYPT 40004
#define ID_GPG_SIGN 40005
@@ -820,9 +824,9 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 245
+#define _APS_NEXT_RESOURCE_VALUE 246
#define _APS_NEXT_COMMAND_VALUE 40186
-#define _APS_NEXT_CONTROL_VALUE 1521
+#define _APS_NEXT_CONTROL_VALUE 1525
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
Modified: trunk/Src/versioninfo.rc.in
===================================================================
--- trunk/Src/versioninfo.rc.in 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/versioninfo.rc.in 2006-04-01 12:36:35 UTC (rev 193)
@@ -36,7 +36,7 @@
VALUE "FileDescription", "Windows Privacy Tray (WinPT)\0"
VALUE "FileVersion", "@VERSION@\0"
VALUE "InternalName", "WinPT\0"
- VALUE "LegalCopyright", " Copyright (C) 2005 Timo Schulz\0"
+ VALUE "LegalCopyright", " Copyright (C) 2006 Timo Schulz\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "WinPT.exe\0"
VALUE "PrivateBuild", "\0"
Deleted: trunk/Src/winpt_km.bmp
===================================================================
(Binary files differ)
Modified: trunk/Src/wptAboutDlgs.cpp
===================================================================
--- trunk/Src/wptAboutDlgs.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptAboutDlgs.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -57,6 +57,8 @@
msg_box (dlg, gpgme_strerror (rc), _("About GnuPG"), MB_ERR);
return FALSE;
}
+ SetDlgItemText (dlg, IDC_ABOUT_AUTHORS,
+ _("The AUTHORS files contains a list of all contributors and co-authors."));
SetDlgItemText (dlg, IDC_ABOUTGPG_INFO, gpg_version);
free (gpg_version);
center_window (dlg, NULL);
Modified: trunk/Src/wptCardDlg.cpp
===================================================================
--- trunk/Src/wptCardDlg.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptCardDlg.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -120,26 +120,6 @@
}
-#if 0 /* @unused@ */
-int
-show_card_status (void)
-{
- int rc = 0;
- int cardstat;
-
- cardstat = pcsc_get_card_status ();
- if ((cardstat & CARD_STATE_UNAWARE) || (cardstat & CARD_STATE_UNAVAIL))
- rc = WPTERR_NOREADER;
- else if (cardstat & CARD_STATE_EMPTY)
- rc = WPTERR_NOCARD;
- if (rc) {
- msg_box (NULL, winpt_strerror (rc), _("Card Manager"), MB_ERR);
- return -1;
- }
- return 0;
-} /* show_card_status */
-#endif
-
/* Check if there is a card in the reader and analyze the
returned information.
Return value: card context or NULL on error. */
Modified: trunk/Src/wptCardPCSC.c
===================================================================
--- trunk/Src/wptCardPCSC.c 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptCardPCSC.c 2006-04-01 12:36:35 UTC (rev 193)
@@ -18,14 +18,16 @@
* 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
+#if 0 /* not needed right now. */
#include <stdio.h>
-#include <stdio.h>
#include <windows.h>
+#ifndef __MINGW32__
+#include <winscard.h>
+#endif
#include "gpgme.h"
#include "wptTypes.h"
@@ -36,15 +38,14 @@
mingw does not come with winscard and we dlopen the stuff
anyway. */
typedef unsigned long pcsc_context_t;
-
struct pcsc_readerstate_s
{
- const char *reader;
- void *user_data;
- unsigned long current_state;
- unsigned long event_state;
- unsigned long atrlen;
- unsigned char atr[33];
+ const char *reader;
+ void *user_data;
+ unsigned long current_state;
+ unsigned long event_state;
+ unsigned long atrlen;
+ unsigned char atr[33];
};
typedef struct pcsc_readerstate_s *pcsc_readerstate_t;
@@ -110,6 +111,7 @@
#define PCSC_E_READER_UNAVAILABLE 0x80100017
#define PCSC_W_REMOVED_CARD 0x80100069
+
/* Possible card states. */
enum card_state_t {
CARD_STATE_NONE=0,
@@ -294,7 +296,7 @@
if (rc == PCSC_E_TIMEOUT)
continue;
if (rc)
- ; /* FIXME: What is this?? */
+ ; /* FIXME: What is this?? */
/* next reader */
curr_rd++;
@@ -332,3 +334,4 @@
stat |= CARD_STATE_EXCLUSI;
return stat;
}
+#endif
Modified: trunk/Src/wptClipSignDlg.cpp
===================================================================
--- trunk/Src/wptClipSignDlg.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptClipSignDlg.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -144,19 +144,6 @@
}
-/* Return -1 if no key is selected, the index otherwise. */
-static int
-get_selected_key (listview_ctrl_t lv)
-{
- int i;
- for (i=0; i < listview_count_items (lv, 0); i++) {
- if (listview_get_item_state (lv, i))
- return i;
- }
- return -1;
-}
-
-
static listview_ctrl_t
on_init_dialog (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
@@ -240,7 +227,7 @@
listview_get_item_text (lv, 0, 1, signer, sizeof signer-1);
no_signer = 0;
}
- else if ((lv_idx = get_selected_key (lv)) == -1) {
+ else if ((lv_idx = listview_get_selected_item (lv)) == -1) {
rc = log_box (_("Signing"), MB_YESNO,
_("No key was chosen.\nUse the GPG default key '%s'?"),
signer);
Modified: trunk/Src/wptCommonDlg.cpp
===================================================================
--- trunk/Src/wptCommonDlg.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptCommonDlg.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -25,13 +25,13 @@
#include <ctype.h>
#include "resource.h"
-
#include "wptTypes.h"
#include "wptW32API.h"
#include "wptVersion.h"
#include "wptGPG.h"
#include "wptCommonCtl.h"
#include "wptContext.h"
+#include "wptRegistry.h"
/* check if the given buf contains a valid URL. */
@@ -41,8 +41,6 @@
size_t i;
const char *allowed = "-./#_:";
- if (strncmp (buf, "http://", 7))
- return -1;
if (!strchr (buf, ':'))
return -1;
if (!strstr (buf, "//"))
@@ -158,100 +156,129 @@
return m_strdup (ctx.url);
}
-#if 0
-struct infodlg_s {
- const char *title;
- const char *button_1;
- const char *button_2;
- const char *text;
- HICON ico;
- int retval;
-};
-/* Dialog box procedure for the info dialog. */
+/* Initialize the language list based on the .mo files
+ found in the dirctory @modpath. */
+static int
+nls_load_langlist (HWND dlg, const char *modpath)
+{
+ WIN32_FIND_DATA fnd;
+ HWND cb;
+ HANDLE hd;
+ char *pattern = NULL;
+ int i;
+
+ cb = GetDlgItem (dlg, IDC_LANGUAGE_LIST);
+ combox_add_string (cb, lang_list[0].name);
+ SendMessage (cb, CB_SETCURSEL, 0, 0);
+
+ memset (&fnd, 0, sizeof (fnd));
+ pattern = make_filename (modpath, "*.mo", NULL);
+ hd = FindFirstFile (pattern, &fnd);
+ if (hd == INVALID_HANDLE_VALUE) {
+ free_if_alloc (pattern);
+ return -1;
+ }
+
+ do {
+ for (i=0; lang_list[i].id != NULL; i++) {
+ if (!strnicmp (fnd.cFileName, lang_list[i].id, 2))
+ combox_add_string (cb, lang_list[i].name);
+ }
+ memset (&fnd, 0, sizeof (fnd));
+ } while (FindNextFile (hd, &fnd) != FALSE);
+ FindClose (hd);
+ free_if_alloc (pattern);
+ return 0;
+}
+
+
+/* Set the default language for the program.
+ The $lang.mo file is copied either to the selected
+ folder or the directory specified by @modpath.
+ The output name of the file is winpt.mo (example: de.mo -> winpt.mo). */
+static int
+nls_set_language (HWND dlg, const char *modpath)
+{
+ HWND cb = GetDlgItem (dlg, IDC_LANGUAGE_LIST);
+ int pos = SendMessage (cb, CB_GETCURSEL, 0, 0);
+ const char *folder;
+ char *src, *dst;
+
+ /* default langauge is English. */
+ if (pos == 0 || pos == CB_ERR)
+ return 0;
+
+ folder = get_folder_dlg (dlg, _("Choose Locale Directory"), modpath);
+ if (!folder)
+ return 0;
+
+ src = make_filename (modpath, lang_list[pos].id, "mo");
+ dst = make_filename (folder, "winpt", "mo");
+
+ if (!CopyFile (src, dst, FALSE)) {
+ msg_box (dlg, _("Could not create winpt.mo file"),
+ _("WinPT Error"), MB_ERR);
+ pos = -1;
+ }
+ else
+ set_reg_entry_mo (folder);
+ free_if_alloc (src);
+ free_if_alloc (dst);
+ return pos;
+}
+
+
static BOOL CALLBACK
-infodlg_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
+nls_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
- static struct infodlg_s *ctx;
+ static char modpath[MAX_PATH+1];
+ int langid = 0, n;
switch (msg) {
case WM_INITDIALOG:
- ctx = (struct infodlg_s *)lparam;
- if (!ctx)
- EndDialog (dlg, FALSE);
- if (ctx->title)
- SetWindowText (dlg, ctx->title);
- if (ctx->text)
- SetDlgItemText (dlg, IDC_INFODLG_TEXT, ctx->text);
- if (ctx->button_1)
- SetDlgItemText (dlg, IDOK, ctx->button_1);
- if (ctx->button_2)
- SetDlgItemText (dlg, IDCANCEL, ctx->button_2);
- if (ctx->ico != NULL) {
- SendMessage (GetDlgItem (dlg, IDC_INFODLG_ICO), STM_SETICON,
- (WPARAM)(HICON)ctx->ico, 0);
+ if ((n=GetModuleFileName (NULL, modpath, MAX_PATH-1)) > 0) {
+ while (n-- > 0) {
+ if (modpath[n] == '\\') {
+ modpath[n] = 0;
+ break;
+ }
+ }
}
+ n = nls_load_langlist (dlg, modpath);
+ if (n == -1)
+ EndDialog (dlg, -1);
+ SetWindowText (dlg, _("Native Language Support"));
+ SetDlgItemText (dlg, IDC_LANGUAGE_INFO, _("Please select a language"));
+ SetDlgItemText (dlg, IDOK, _("&OK"));
+ SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
+ center_window (dlg, NULL);
SetForegroundWindow (dlg);
- return TRUE;
+ break;
case WM_COMMAND:
switch (LOWORD (wparam)) {
case IDOK:
- ctx->retval = IDOK;
- EndDialog (dlg, TRUE);
+ langid = nls_set_language (dlg, modpath);
+ EndDialog (dlg, langid);
break;
case IDCANCEL:
- ctx->retval = IDCANCEL;
- EndDialog (dlg, FALSE);
+ EndDialog (dlg, -1);
break;
}
break;
}
+
return FALSE;
}
int
-InfoBox (HWND hwnd, LPCTSTR text, LPCTSTR title, UINT type)
+select_language (void)
{
- struct infodlg_s inf;
-
- memset (&inf, 0, sizeof (inf));
- inf.text = text;
- inf.title = title;
- if (type & MB_YESNO) {
- inf.button_1 = _("Yes");
- inf.button_2 = _("No");
- }
- else {
- inf.button_1 = _("OK");
- inf.button_2 = _("Cancel");
- }
- if (type & MB_ICONERROR)
- inf.ico = LoadIcon (NULL, IDI_ERROR);
- else if (type & MB_ICONWARNING)
- inf.ico = LoadIcon (NULL, IDI_EXCLAMATION);
- else if (type & MB_ICONINFORMATION)
- inf.ico = LoadIcon (NULL, IDI_INFORMATION);
- DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_INFODLG, hwnd,
- infodlg_dlg_proc, (LPARAM)&inf);
- return inf.retval;
+ DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_LANGUAGE, GetDesktopWindow (),
+ nls_dlg_proc, 0);
+ return 0;
}
-
-int
-InfoBoxEx (HWND hwnd, LPCTSTR text, LPCTSTR title, UINT type, ...)
-{
- va_list arg_ptr;
- char buf[2048];
- int id;
-
- va_start (arg_ptr, type);
- _vsnprintf (buf, sizeof (buf)-1, text, arg_ptr);
- id = InfoBox (hwnd, buf, title, type);
- va_end (arg_ptr);
- return id;
-}
-#endif
-
Modified: trunk/Src/wptCryptdisk.cpp
===================================================================
--- trunk/Src/wptCryptdisk.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptCryptdisk.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -150,7 +150,7 @@
static int
cryptdisk_mount (int devnum,
const char * imgfile,
- u32 size,
+ DWORD size,
const char * hdlet)
{
HWND h;
@@ -393,7 +393,7 @@
static int
-check_freespace (const char * imgfile, u32 size)
+check_freespace (const char * imgfile, DWORD size)
{
ULARGE_INTEGER tocaller, total, totfree;
char buf[128] = {0};
@@ -432,7 +432,7 @@
const char * s;
char imgfile[128], key[128], drv[3];
int i;
- u32 size=0;
+ DWORD size=0;
switch (msg) {
case WM_INITDIALOG:
Modified: trunk/Src/wptFileManager.cpp
===================================================================
--- trunk/Src/wptFileManager.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptFileManager.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -117,7 +117,7 @@
void
remove_crit_file_attrs (const char *fname, int force)
{
- u32 fattr;
+ DWORD fattr;
int id = 0;
if (file_exist_check (fname))
Modified: trunk/Src/wptFileManagerDlg.cpp
===================================================================
--- trunk/Src/wptFileManagerDlg.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptFileManagerDlg.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -324,7 +324,7 @@
/* default is to produce detached signatures */
c->sigmode = GPGME_SIG_MODE_DETACH;
}
- lv_idx = listview_get_curr_pos (lv);
+ lv_idx = listview_get_selected_item (lv);
if (lv_idx == -1) {
if (listview_count_items (lv, 0) == 1)
lv_idx = 0;
Modified: trunk/Src/wptGPGMEData.cpp
===================================================================
--- trunk/Src/wptGPGMEData.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptGPGMEData.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -133,7 +133,7 @@
if (!*r_dh)
return gpg_error (GPG_ERR_INV_ARG);
gpgme_data_new (&dh);
- while (gpg_data_readline (*r_dh, buf, 127)) {
+ while (gpg_data_readline (*r_dh, buf, sizeof (buf)-1)) {
gpgme_data_write (dh, "> ", 2);
gpgme_data_write (dh, buf, strlen (buf));
}
Modified: trunk/Src/wptGPGPrefsDlg.cpp
===================================================================
--- trunk/Src/wptGPGPrefsDlg.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptGPGPrefsDlg.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -323,7 +323,7 @@
return TRUE;
case IDC_GPGPREFS_LOCDLG:
- folder = get_folder_dlg (dlg, _("Choose locale directory"), NULL);
+ folder = get_folder_dlg (dlg, _("Choose Locale Directory"), NULL);
if (folder)
SetDlgItemText (dlg, IDC_GPGPREFS_LOCALE, folder);
return TRUE;
Modified: trunk/Src/wptGPGUtil.cpp
===================================================================
--- trunk/Src/wptGPGUtil.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptGPGUtil.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -36,6 +36,17 @@
#include "openpgp.h"
+/* safe wrapper around calloc. */
+static void*
+xcalloc (size_t n, size_t m)
+{
+ void *p = calloc (n, m);
+ if (!p)
+ BUG (0);
+ return p;
+}
+
+
#define NROFHEXDIGITS 2
/* Convert two hexadecimal digits from STR to the value they
represent. Returns -1 if one of the characters is not a
@@ -81,9 +92,7 @@
}
else {
/* The converted string will never be larger than the original string. */
- dest = (char*)malloc (strlen (src) + 1);
- if (!dest)
- return gpg_error (GPG_ERR_ENOMEM);
+ dest = (char*)xcalloc (1,strlen (src) + 1);
*destp = dest;
}
@@ -146,6 +155,8 @@
return 0;
}
+
+
/* Replace %foo% entries with its real values.
Return value: expanded path or NULL on error. */
static char *
@@ -158,9 +169,7 @@
if (!len)
return NULL;
len += 1;
- p = (char*)calloc (1, len+1);
- if (!p)
- BUG (NULL);
+ p = (char*)xcalloc (1, len+1);
len = ExpandEnvironmentStrings (path, p, len);
if (!len) {
free (p);
@@ -186,9 +195,7 @@
nbytes = 1;
if (RegQueryValueEx (key_handle, name, 0, NULL, NULL, &nbytes))
goto leave;
- result = (char*)calloc (1, (n1=nbytes+1));
- if (!result)
- BUG (NULL);
+ result = (char*)xcalloc (1, (n1=nbytes+1));
if (RegQueryValueEx (key_handle, name, 0, &type, (BYTE*)result, &n1)) {
free (result);
result = NULL;
@@ -205,6 +212,7 @@
return result;
}
+
static char*
read_gpg_program (void)
{
@@ -276,9 +284,7 @@
FlushFileBuffers (out);
SetFilePointer (out, 0, NULL, FILE_BEGIN);
n = GetFileSize (out, NULL);
- p = (char*)calloc (1, n+1);
- if (!p)
- BUG (NULL);
+ p = (char*)xcalloc (1, n+1);
ReadFile (out, p, n, &n, NULL);
p[n] = 0;
if (nread)
@@ -335,10 +341,8 @@
p = read_gpg_program ();
if (!p)
return gpg_error (GPG_ERR_INV_ARG);
- cmd = (char*)calloc (1, strlen (p) + strlen (keyid)
+ cmd = (char*)xcalloc (1, strlen (p) + strlen (keyid)
+ strlen (outfile) + 64 + 2);
- if (!cmd)
- BUG (NULL);
sprintf (cmd, "%s --yes --output \"%s\" --export-secret-key %s",
p, outfile, keyid);
if (create_process (cmd, NULL, NULL, NULL))
@@ -368,9 +372,7 @@
if (!p)
return gpg_error (GPG_ERR_INV_ARG);
- cmd = (char*)calloc (1, strlen (p) + 64 + 1);
- if (!cmd)
- BUG (NULL);
+ cmd = (char*)xcalloc (1, strlen (p) + 64 + 1);
sprintf (cmd, "%s %s", p,
do_export? "--export-ownertrust" : "--import-ownertrust");
@@ -406,16 +408,16 @@
{
gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);
HANDLE out = NULL;
+ const char *fmt;
char *p;
char *cmd;
p = read_gpg_program ();
if (!p)
return gpg_error (GPG_ERR_INV_ARG);
- cmd = (char*)calloc (1, strlen (p) + 64);
- if (!cmd)
- BUG (NULL);
- sprintf (cmd, "%s --logger-fd=1 --rebuild-keydb-caches", p);
+ fmt = "%s --logger-fd=1 --batch --rebuild-keydb-caches";
+ cmd = (char*)xcalloc (1, strlen (p) + strlen (fmt) + 32);
+ sprintf (cmd, fmt, p);
if (r_inf)
out = create_tmpfile ("gpg_rebuild_cache");
@@ -444,9 +446,7 @@
p = read_gpg_program ();
if (!p)
return gpg_error (GPG_ERR_INV_ARG);
- cmd = (char*)calloc (1, strlen (p) + 32);
- if (!cmd)
- BUG (NULL);
+ cmd = (char*)xcalloc (1, strlen (p) + 32);
sprintf (cmd, "%s --version", p);
out = create_tmpfile ("gpg_out");
@@ -475,9 +475,7 @@
if (!p)
return gpg_error (GPG_ERR_INV_ARG);
- cmd = (char*)calloc (1, strlen (p) + strlen (fname) + 2+2 + 64);
- if (!cmd)
- BUG (NULL);
+ cmd = (char*)xcalloc (1, strlen (p) + strlen (fname) + 2+2 + 64);
sprintf (cmd, "%s --fixed-list-mode --with-colons \"%s\"", p, fname);
out = create_tmpfile ("gpg_keys");
@@ -511,9 +509,7 @@
n += strlen (pass) + 1;
if (cmt)
n += strlen (cmt) + 1;
- p = (char*)calloc (1, n+1);
- if (!p)
- BUG (NULL);
+ p = (char*)xcalloc (1, n+1);
sprintf (p, fmt, code, cmt? cmt : "", cmt? "\n" : "", pass? pass : "");
return p;
}
@@ -536,9 +532,7 @@
if (!p)
return gpg_error (GPG_ERR_INV_ARG);
- cmd = (char*)calloc (1, strlen (p) + strlen (keyid)+1 + 128);
- if (!cmd)
- BUG (NULL);
+ cmd = (char*)xcalloc (1, strlen (p) + strlen (keyid)+1 + 128);
sprintf (cmd, "%s --pgp7 --command-fd=0 --status-fd=2 --gen-revoke %s",
p, keyid);
@@ -585,9 +579,7 @@
n = strlen (p) + 128;
if (keyid)
n += strlen (keyid) + 1;
- cmd = (char*)calloc (1, n+1);
- if (!cmd)
- BUG (NULL);
+ cmd = (char*)xcalloc (1, n+1);
hdat = create_tmpfile ("gpg_uat_data");
herr = create_tmpfile ("gpg_uat_status");
/* XXX: add --list-options show-unsuable-uid to display
@@ -645,7 +637,7 @@
n += strlen (*new_keyfile)+1;
for (i=0; i < (int)nkeys; i++)
n += strlen (keys[i])+1+2;
- cmd = (char*)calloc (1, n+1);
+ cmd = (char*)xcalloc (1, n+1);
sprintf (cmd, fmt, p, *new_keyfile, tmpdir, tmpnam);
for (i=0; i < (int)nkeys; i++) {
strcat (cmd, keys[i]);
@@ -677,9 +669,7 @@
if (!p)
return gpg_error (GPG_ERR_INV_ARG);
- cmd = (char*)calloc (1, strlen (p) + strlen (keyid)+1 + 128);
- if (!cmd)
- BUG (NULL);
+ cmd = (char*)xcalloc (1, strlen (p) + strlen (keyid)+1 + 128);
sprintf (cmd, "%s --with-colons --fixed-list-mode --list-keys \"%s\"",
p, keyid);
@@ -747,7 +737,7 @@
memset (&afx, 0, sizeof (afx));
gpg_iobuf_push_filter (inp, gpg_armor_filter, &afx);
}
- pkt = (PACKET *)calloc(1, sizeof *pkt);
+ pkt = (PACKET *)xcalloc(1, sizeof *pkt);
gpg_init_packet (pkt);
while (!quit && (rc = gpg_parse_packet (inp, pkt)) != -1) {
switch (pkt->pkttype) {
@@ -755,10 +745,8 @@
enc = pkt->pkt.pubkey_enc;
if (!enc)
break;
- l = (gpgme_recipient_t)calloc (1, sizeof *l);
- if (!l)
- BUG (NULL);
- l->keyid = (char*)calloc (1, 16+1);
+ l = (gpgme_recipient_t)xcalloc (1, sizeof *l);
+ l->keyid = (char*)xcalloc (1, 16+1);
_snprintf (l->keyid, 16, "%08lX%08lX", enc->keyid[0], enc->keyid[1]);
l->pubkey_algo = (gpgme_pubkey_algo_t)enc->pubkey_algo;
l->status = 0;
@@ -822,7 +810,7 @@
*value = NULL;
p = read_gpg_program ();
fmt = "%s --with-colons --list-options show-sig-subpackets=%d --list-sigs %s";
- cmd = (char*)calloc (1, strlen (fmt) + strlen (p) + strlen (key) + 32 + 1);
+ cmd = (char*)xcalloc (1, strlen (fmt) + strlen (p) + strlen (key) + 32 + 1);
sprintf (cmd, fmt, p, subpktid, key);
out = create_tmpfile ("gpg_subpackets");
@@ -836,7 +824,7 @@
if (p && (spk=strstr (p, "spk"))) {
char *end = strstr (spk, "\n");
if (end) {
- *value = (char*)calloc (1, (end-spk)+1);
+ *value = (char*)xcalloc (1, (end-spk)+1);
memcpy (*value, spk, (end-spk)-1);
}
}
Modified: trunk/Src/wptKeyEditDlgs.cpp
===================================================================
--- trunk/Src/wptKeyEditDlgs.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptKeyEditDlgs.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -1765,6 +1765,8 @@
/* XXX: add a hint that also all signatures will be deleted? */
listview_get_item_text (lv, j, UID_COL_NAME, name, DIM(name) -1);
_snprintf (inf, DIM (inf)-1, _("user ID \"%s\".\n\n"
+ "All signatures on this user ID will be also deleted."
+ "\n\n"
"Do you really want to delete this user ID?"),
name);
if (msg_box (dlg, inf, _("Key Edit"), MB_YESNO|MB_ICONWARNING) == IDNO)
@@ -1790,21 +1792,28 @@
}
delete ke;
return err? FALSE : TRUE;
-} /* do_editkey_deluid */
+}
-
+/* Subclass routine for the subkey listview control to allow shortcuts. */
static BOOL CALLBACK
-subkey_subclass_proc( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam )
+subkey_subclass_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
- switch( msg ) {
+ int virt_key = 0;
+ winpt_key_t key;
+
+ switch (msg) {
case WM_KEYUP:
- int virt_key = (int)wparam;
- switch( virt_key ) {
+ virt_key = (int)wparam;
+ key = (winpt_key_t)keyedit_subkey_proc.opaque;
+ if (!key || !key->key_pair)
+ break;
+
+ switch (virt_key) {
case VK_DELETE:
- SendDlgItemMessage( keyedit_subkey_proc.dlg, IDC_KEYEDIT_CMD,
- CB_SETCURSEL, CMD_DELKEY, 0 );
- send_cmd_id( keyedit_subkey_proc.dlg, IDOK );
+ SendDlgItemMessage (keyedit_subkey_proc.dlg, IDC_KEYEDIT_CMD,
+ CB_SETCURSEL, CMD_DELKEY, 0);
+ send_cmd_id (keyedit_subkey_proc.dlg, IDOK);
break;
case VK_INSERT:
@@ -1814,16 +1823,23 @@
break;
}
}
- return CallWindowProc( keyedit_subkey_proc.old, dlg, msg, wparam, lparam );
-} /* subkey_subclass_proc */
+ return CallWindowProc (keyedit_subkey_proc.old, dlg, msg, wparam, lparam);
+}
static BOOL CALLBACK
uid_subclass_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
- switch( msg ) {
+ int virt_key = 0;
+ winpt_key_t key;
+
+ switch (msg) {
case WM_KEYUP:
- int virt_key = (int)wparam;
+ virt_key = (int)wparam;
+ key = (winpt_key_t)keyedit_uid_proc.opaque;
+ if (!key || !key->key_pair)
+ break;
+
switch (virt_key) {
case VK_DELETE:
SendDlgItemMessage (keyedit_uid_proc.dlg, IDC_KEYEDIT_CMD,
@@ -1838,12 +1854,14 @@
break;
}
}
- return CallWindowProc( keyedit_uid_proc.old, dlg, msg, wparam, lparam );
-} /* uid_subclass_proc */
+ return CallWindowProc (keyedit_uid_proc.old, dlg, msg, wparam, lparam);
+}
+/* Enable the key @k when @enable is 1, disable it otherwise. */
static void
-do_editkey_enable_disable (winpt_key_t k, HWND dlg, listview_ctrl_t lv, int enable)
+do_editkey_enable_disable (winpt_key_t k, HWND dlg,
+ listview_ctrl_t lv, int enable)
{
km_enable_disable_key (lv, dlg, 0, enable);
k->update = 1;
@@ -1863,6 +1881,8 @@
}
+/* Start the dialog to list and display the status of all
+ signatures for this key. */
static void
do_editkey_check (winpt_key_t k, HWND dlg)
{
@@ -1943,6 +1963,7 @@
return LB_ERR;
}
+
/* Dialog box procedure for the edit key dialog. */
BOOL CALLBACK
keyedit_main_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
@@ -1952,36 +1973,42 @@
int cmd;
HWND item;
- switch( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
k = (winpt_key_t)lparam;
if (!k)
BUG (NULL);
do_init_cmdlist (dlg, k->key_pair);
lvsub = subkey_list_init (dlg, k);
- if( !lvsub )
- BUG( NULL );
+ if (!lvsub)
+ BUG (0);
lvuid = userid_list_init (dlg, k);
- if( !lvuid )
- BUG( NULL );
- item = GetDlgItem( dlg, IDC_KEYEDIT_KEYLIST );
+ if (!lvuid)
+ BUG (0);
+ item = GetDlgItem (dlg, IDC_KEYEDIT_KEYLIST);
+ keyedit_subkey_proc.opaque = (void*)k;
keyedit_subkey_proc.dlg = dlg;
keyedit_subkey_proc.current = (WNDPROC)subkey_subclass_proc;
- keyedit_subkey_proc.old = (WNDPROC)GetWindowLong( item, GWL_WNDPROC );
- if( keyedit_subkey_proc.old ) {
- if( !SetWindowLong( item, GWL_WNDPROC, (LONG)keyedit_subkey_proc.current ) ) {
- msg_box( dlg, _("Could not set subkey window procedure."), _("Key Edit"), MB_ERR );
- BUG( NULL );
+ keyedit_subkey_proc.old = (WNDPROC)GetWindowLong (item, GWL_WNDPROC);
+ if (keyedit_subkey_proc.old) {
+ if( !SetWindowLong (item, GWL_WNDPROC,
+ (LONG)keyedit_subkey_proc.current)) {
+ msg_box (dlg, _("Could not set subkey window procedure."),
+ _("Key Edit"), MB_ERR);
+ BUG (0);
}
}
- item = GetDlgItem( dlg, IDC_KEYEDIT_UIDLIST );
+ item = GetDlgItem (dlg, IDC_KEYEDIT_UIDLIST);
+ keyedit_uid_proc.opaque = (void*)k;
keyedit_uid_proc.dlg = dlg;
keyedit_uid_proc.current = (WNDPROC)uid_subclass_proc;
- keyedit_uid_proc.old = (WNDPROC)GetWindowLong( item, GWL_WNDPROC );
- if( keyedit_uid_proc.old ) {
- if( !SetWindowLong( item, GWL_WNDPROC, (LONG)keyedit_uid_proc.current ) ) {
- msg_box( dlg, _("Could not set user ID window procedure."), _("Key Edit"), MB_ERR );
- BUG( NULL );
+ keyedit_uid_proc.old = (WNDPROC)GetWindowLong (item, GWL_WNDPROC);
+ if (keyedit_uid_proc.old) {
+ if (!SetWindowLong (item, GWL_WNDPROC,
+ (LONG)keyedit_uid_proc.current)) {
+ msg_box (dlg, _("Could not set user ID window procedure."),
+ _("Key Edit"), MB_ERR);
+ BUG (0);
}
}
if (k->ctx->revoked) {
@@ -1997,12 +2024,12 @@
return TRUE;
case WM_DESTROY:
- if( lvsub ) {
- listview_release( lvsub );
+ if (lvsub) {
+ listview_release (lvsub);
lvsub = NULL;
}
- if( lvuid ) {
- listview_release( lvuid );
+ if (lvuid) {
+ listview_release (lvuid);
lvuid = NULL;
}
break;
@@ -2065,4 +2092,3 @@
}
return FALSE;
}
-
Modified: trunk/Src/wptKeyManager.cpp
===================================================================
--- trunk/Src/wptKeyManager.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptKeyManager.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -103,26 +103,6 @@
}
-#if 0
-/* Quoted the user-id given by @uid. If @uid is already
- quoted @uid is returned without any modifications.
- Return value: quoted @uid. */
-char*
-km_quote_uid (const char *uid)
-{
- char *q;
-
- if (*uid == '"' && uid[strlen (uid)-1] == '"')
- return m_strdup (uid);
- q = new char[strlen (uid) + 4];
- if (!q)
- BUG (NULL);
- _snprintf (q, strlen (uid) + 3, "\"%s\"", uid);
- return q;
-}
-#endif
-
-
/* Check if list view @lv contains a secret key at position @pos.
If utrust is valid, set it to 1 if the key is valid -1 otherwise.
Return value: 1 normal key, 2 smart card key. */
@@ -198,7 +178,7 @@
if (pos == -1)
return 0;
key = (gpgme_key_t)listview_get_item2 (lv, pos);
- if (key == NULL)
+ if (!key)
return 0;
if (key->expired)
@@ -259,50 +239,14 @@
}
-/* Export the keys given in @rset to the clipboard.
- Return value: 0 on success. */
-static gpgme_error_t
-gpg_clip_export (gpgme_key_t *rset, int n)
-{
- gpgme_error_t err = 0;
- gpgme_ctx_t ctx = NULL;
- gpgme_data_t keydata = NULL;
- char *patt=NULL;
-
- err = gpgme_new (&ctx);
- if (err)
- return err;
- gpgme_set_armor (ctx, 1);
- err = gpgme_data_new (&keydata);
- if (err)
- goto leave;
-
- patt = gpg_keylist_to_pattern (rset, n);
- if (!patt) {
- err = gpg_error (GPG_ERR_ENOMEM);
- goto leave;
- }
-
- err = gpgme_op_export (ctx, patt, 0, keydata);
- if (err)
- goto leave;
-
- gpg_data_release_and_set_clipboard (keydata, 1);
-
-leave:
- if (patt)
- free (patt);
- gpgme_release (ctx);
- return err;
-}
-
-
/* Export the selected keys in @lv to the clipboard. */
int
km_clip_export (HWND dlg, listview_ctrl_t lv)
{
gpgme_error_t err;
gpgme_key_t *rset;
+ GPGME *ctx;
+ char *patt=NULL;
char buf[256];
int n=0;
int rc=0;
@@ -311,13 +255,18 @@
if (!n) {
msg_box (dlg, _("No key was selected for export."),
_("Key Manager"), MB_ERR);
- rc = WPTERR_GENERAL;
- goto leave;
+ return WPTERR_GENERAL;
}
- err = gpg_clip_export (rset, n);
+ patt = gpg_keylist_to_pattern (rset, n);
+
+ ctx = new GPGME ();
+ if (!ctx)
+ BUG (0);
+ ctx->setArmor (true);
+ err = ctx->exportToClipboard (patt);
if (err) {
- msg_box( dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR);
+ msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR);
rc = WPTERR_GENERAL;
goto leave;
}
@@ -329,7 +278,9 @@
show_msg (dlg, 1500, _("GnuPG Status: Finished"));
leave:
- free (rset);
+ safe_free (rset);
+ safe_free (patt);
+ delete ctx;
return rc;
}
@@ -540,7 +491,7 @@
return WPTERR_GENERAL;
}
- get_temp_name (tmpfile, sizeof (tmpfile), "winpt_file_http.tmp");
+ get_temp_name (tmpfile, sizeof (tmpfile)-1, "winpt_http.tmp");
fp = fopen (tmpfile, "wb");
if (!fp) {
log_box (_("Key Import HTTP"), MB_ERR, "%s: %s", tmpfile,
@@ -912,7 +863,8 @@
/* In single refresh mode, try to use the users preferred keyserver. */
if (flags == 0 &&
!winpt_get_pubkey (key->subkeys->keyid+8, &pk) &&
- !gpg_keycache_update_attr (pk.ext, KC_ATTR_PREFKSERV, 0))
+ !gpg_keycache_update_attr (pk.ext, KC_ATTR_PREFKSERV, 0)
+ && pk.ext->pref_keyserver)
pref_kserv = pk.ext->pref_keyserver;
_snprintf (keyid, sizeof (keyid)-1, "%s", key->subkeys->keyid+8);
err = hkp_recv_key (dlg, pref_kserv, default_keyserver_port,
Modified: trunk/Src/wptKeyManagerDlg.cpp
===================================================================
--- trunk/Src/wptKeyManagerDlg.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptKeyManagerDlg.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -239,14 +239,8 @@
return -1;
}
}
- for (i=0; i < size/2; i++) {
- LVCOLUMN lvc;
-
- memset (&lvc, 0, sizeof (lvc));
- lvc.mask = LVCF_WIDTH;
- lvc.cx = buf[i];
- ListView_SetColumn (hd->ctrl, i, &lvc);
- }
+ for (i=0; i < size/2; i++)
+ listview_set_column_width (hd, i, buf[i]);
free_if_alloc (buf);
return 0;
}
@@ -431,24 +425,14 @@
do_create_minpopup (HWND dlg)
{
HMENU hm;
- MENUITEMINFO mi;
- char * s;
POINT p;
if (gpg_read_only || !clip_contains_pgpkey ())
return;
hm = CreatePopupMenu ();
if (!hm)
- BUG( NULL );
- memset (&mi, 0, sizeof mi);
- mi.cbSize = sizeof mi;
- s = (char *)_("Paste Key from Clipboard");
- mi.fType = MF_STRING;
- mi.dwTypeData = s;
- mi.cch = strlen (s);
- mi.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE;
- mi.wID = ID_KEYCTX_PASTE;
- InsertMenuItem (hm, 0, FALSE, &mi);
+ BUG (0);
+ insert_menu_item (hm, 0, ID_KEYCTX_PASTE, _("Paste Key from Clipboard"));
GetCursorPos (&p);
TrackPopupMenu (hm, 0, p.x, p.y, 0, dlg, NULL);
DestroyMenu (hm);
@@ -1138,8 +1122,7 @@
BOOL CALLBACK
keymanager_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
- struct km_info_s *kmi;
- INITCOMMONCONTROLSEX icex;
+ struct km_info_s *kmi = NULL;
HWND kl;
HMENU hm;
gpg_keycache_t c;
@@ -1155,15 +1138,24 @@
if ((msg != WM_INITDIALOG)
&& ((kmi = (struct km_info_s*)GetWindowLong (dlg, GWL_USERDATA)) == NULL))
return FALSE;
+
+ /* handle dynamic popup items in the keyserver menu. */
+ if (msg == WM_COMMAND && LOWORD (wparam) >= WM_APP &&
+ LOWORD (wparam) <= WM_APP+MAX_KEYSERVERS) {
+ l_idx = LOWORD (wparam)-WM_APP;
+ if (l_idx < 0)
+ return TRUE;
+ host = kserver_get_hostname (l_idx, 0, &port);
+ if (host != NULL)
+ km_send_to_keyserver (kmi->lv, dlg, host, port);
+ return TRUE;
+ }
switch (msg) {
case WM_INITDIALOG:
kmi = new struct km_info_s;
memset (kmi, 0, sizeof (struct km_info_s));
kmi->lv_idx = -1;
- icex.dwSize = sizeof (INITCOMMONCONTROLSEX);
- icex.dwICC = ICC_BAR_CLASSES;
- InitCommonControlsEx (&icex);
kmi->hwnd_sep = regist_sep_wnd (dlg, kmi);
imagelist_load (dlg);
translate_menu_strings (dlg);
@@ -1231,7 +1223,6 @@
return FALSE;
case WM_SHOWWINDOW:
- /*refresh_keylist (kmi);*/
break;
case WM_MOVE:
@@ -1394,9 +1385,17 @@
set_menu_state (popup, ID_KEYCTX_PASTE, MF_DISABLED|MF_GRAYED);
if (mapi_init ())
set_menu_state (popup, ID_KEYCTX_SENDMAIL, MF_DISABLED|MF_GRAYED);
+
/* Override 'Default Keyserver' with the actual name. */
host = kserver_get_hostname (0, -1, &port);
+ if (!host)
+ host = DEF_HKP_KEYSERVER;
set_menu_text (popup, ID_KEYCTX_KS_DEFAULT, host);
+ {
+ HMENU ks = GetSubMenu (popup, 19);
+ for (i=0; server[i].name != NULL; i++)
+ insert_menu_item (ks, i+2, WM_APP+i, server[i].name);
+ }
popup_gpg_readonly (dlg, popup);
if (listview_count_items (kmi->lv, 1) > 1)
popup_multiple (dlg, popup);
@@ -1915,18 +1914,6 @@
update_key (kmi->lv, kmi->lv_idx, k.tmp_keyid, 1);
break;
- case ID_KEYCTX_KS_NL:
- case ID_KEYCTX_KS_PL:
- case ID_KEYCTX_KS_AT:
- case ID_KEYCTX_KS_DE:
- case ID_KEYCTX_KS_DK:
- case ID_KEYCTX_KS_CZ:
- case ID_KEYCTX_KS_ES:
- case ID_KEYCTX_KS_UK:
- host = kserver_get_hostname (LOWORD (wparam) - 40107, 0, &port);
- km_send_to_keyserver (kmi->lv, dlg, host, port);
- break;
-
case ID_KEYCTX_RECVFROM:
km_refresh_from_keyserver (kmi->lv, dlg);
if (updated_keys_avail ())
Modified: trunk/Src/wptKeyRevokersDlg.cpp
===================================================================
--- trunk/Src/wptKeyRevokersDlg.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptKeyRevokersDlg.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -88,6 +88,7 @@
listview_ctrl_t lv;
const char *alg;
char *uid = NULL;
+ char keyid[32];
ke = new GpgKeyEdit (key);
if (!ke)
@@ -107,10 +108,11 @@
uid = strdup (_("user ID not found"));
else
uid = utf8_to_native (revkey->uids->name);
+ _snprintf (keyid, sizeof (keyid)-1, "0x%s", r->fpr+32);
listview_add_item (lv, "");
alg = get_key_pubalgo (r->pubkey_algo);
listview_add_sub_item (lv, 0, REV_COL_ALGO, alg);
- listview_add_sub_item (lv, 0, REV_COL_KEYID, r->fpr+32);
+ listview_add_sub_item (lv, 0, REV_COL_KEYID, keyid);
listview_add_sub_item (lv, 0, REV_COL_NAME, uid);
safe_free (uid);
}
Modified: trunk/Src/wptKeyserver.cpp
===================================================================
--- trunk/Src/wptKeyserver.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptKeyserver.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -44,17 +44,9 @@
keyserver server[MAX_KEYSERVERS] = {0};
keyserver_proxy_s proxy = {0};
static const char *server_list[] = {
- "hkp://wwwkeys.nl.pgp.net",
- "hkp://wwwkeys.pl.pgp.net",
- "hkp://wwwkeys.at.pgp.net",
- "hkp://wwwkeys.ch.pgp.net",
- "hkp://wwwkeys.de.pgp.net",
- "hkp://wwwkeys.dk.pgp.net",
- "hkp://wwwkeys.cz.pgp.net",
- "hkp://wwwkeys.es.pgp.net",
- "hkp://wwwkeys.eu.pgp.net",
- "hkp://wwwkeys.uk.pgp.net",
- "hkp://wwwkeys.us.pgp.net",
+ "hkp://gnv.us.ks.cryptnet.net",
+ "hkp://keyserver.kjsl.com",
+ "hkp://sks.keyserver.penguin.de",
"hkp://subkeys.pgp.net",
"ldap://keyserver.pgp.com",
NULL
@@ -63,7 +55,6 @@
static char hkp_errmsg[1024]; /* Holds the error message from the server */
static int hkp_err = 0; /* != 0 indicates an error occurred. */
-static DWORD conf_timestamp = 0;/* timestamp of the configuration fiele. */
/* Default keyserver and port. */
char *default_keyserver = NULL;
@@ -564,8 +555,7 @@
/* Load the keyserver config file @conf. */
int
kserver_load_conf (const char *conf)
-{
- struct stat statbuf;
+{
FILE *fp;
char buf[1024], *s, *p;
char *user = NULL, *pass = NULL;
@@ -660,8 +650,6 @@
return WPTERR_CONFIG_FILE;
}
- if (!stat (conf, &statbuf))
- conf_timestamp = statbuf.st_mtime;
return 0;
}
Modified: trunk/Src/wptListView.cpp
===================================================================
--- trunk/Src/wptListView.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptListView.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -67,10 +67,23 @@
if (ctx->hil)
ImageList_Destroy (ctx->hil);
delete ctx;
-} /* listview_release */
+}
int
+listview_set_column_width (listview_ctrl_t ctx, int col, int width)
+{
+ LVCOLUMN lvc;
+
+ memset (&lvc, 0, sizeof (lvc));
+ lvc.mask = LVCF_WIDTH;
+ lvc.cx = width;
+ ListView_SetColumn (ctx->ctrl, col, &lvc);
+ return 0;
+}
+
+
+int
listview_add_column (listview_ctrl_t ctx, listview_column_t col)
{
int rc = 0;
@@ -248,6 +261,24 @@
}
+/* Return the index of the selected item.
+ Support both selections and checkboxes. */
+int
+listview_get_selected_item (listview_ctrl_t lv)
+{
+ int pos, i;
+
+ pos = listview_get_curr_pos (lv);
+ if (pos != -1)
+ return pos;
+ for (i=0; i < listview_count_items (lv, 0); i++) {
+ if (listview_get_item_state (lv, i))
+ return i;
+ }
+ return -1;
+}
+
+
/* Return if the given element is selected or if the ext
style is used, if the checkbox is activated. */
int
Modified: trunk/Src/wptMAPI.cpp
===================================================================
--- trunk/Src/wptMAPI.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptMAPI.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -234,45 +234,7 @@
}
-#if 0
-/* Send a public key stored in @keyfile with the keyid @keyid
- via the MAPI mechanism to a mail recipient.
- Return value: SUCCESS_SUCCESS on succes. */
-int
-mapi_send_pubkey2 (const char *keyid, char *keyfile)
-{
- LHANDLE hd;
- const char * fmt;
- char * keyinf = NULL;
- int rc;
- if (!init)
- return 0;
-
- fmt = _("GPG Public Key of %s");
- keyinf = new char[strlen (fmt) + strlen (keyid) + 2];
- if (!keyinf)
- BUG (0);
- sprintf (keyinf, fmt, keyid);
- rc = mapi_logon (0, NULL, NULL, MAPI_LOGON_UI, 0, &hd);
- if (rc != SUCCESS_SUCCESS) {
- MessageBox (NULL, _("MAPI Login failed."), "MAPI", MB_ICONWARNING|MB_OK);
- goto fail;
- }
- rc = mapi_send_documents (0, ";", keyfile, keyinf, 0);
- if (rc == MAPI_E_USER_ABORT)
- rc = SUCCESS_SUCCESS;
- if (rc != SUCCESS_SUCCESS)
- MessageBox (NULL, _("Could not sent mail."), "MAPI", MB_ICONERROR|MB_OK);
-
-fail:
- mapi_logoff (hd, 0, 0, 0);
- free_if_alloc (keyinf);
- return rc;
-}
-#endif
-
-
int
mapi_send_pubkey (const char *keyid, char *keyfile)
{
Modified: trunk/Src/wptMainProc.cpp
===================================================================
--- trunk/Src/wptMainProc.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptMainProc.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -292,13 +292,14 @@
gpg_card_t card;
card = gpg_card_load ();
- if (card) {
- dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_CARD_EDIT,
- GetDesktopWindow (), card_edit_dlg_proc,
- (LPARAM)card,
- _("Card Edit"), IDS_WINPT_CARD_EDIT);
- gpg_card_release (card);
- }
+ if (!card)
+ return;
+
+ dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_CARD_EDIT,
+ GetDesktopWindow (), card_edit_dlg_proc,
+ (LPARAM)card,
+ _("Card Edit"), IDS_WINPT_CARD_EDIT);
+ gpg_card_release (card);
}
@@ -317,6 +318,18 @@
}
+static void
+init_common_controls (void)
+{
+ INITCOMMONCONTROLSEX cce;
+
+ /* date control, toolbar, trackbar, ... */
+ cce.dwSize = sizeof (INITCOMMONCONTROLSEX);
+ cce.dwICC = ICC_DATE_CLASSES|ICC_BAR_CLASSES;
+ InitCommonControlsEx (&cce);
+}
+
+
/* Main message loop for the tray window. */
LRESULT CALLBACK
winpt_main_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
@@ -324,8 +337,7 @@
static NOTIFYICONDATA NID;
static DWORD cookie;
static int use_hotkey = 0;
- INITCOMMONCONTROLSEX cce;
- LPARAM param;
+ static int manual_shutdown = 0;
HWND wnd;
gpgme_error_t err;
curr_wnd_ctx currwnd = {0};
@@ -348,19 +360,16 @@
msg_box (hwnd, _("Could not set current window mode hooks."),
_("WinPT Error"), MB_OK);
mapi_init ();
- /* init common controls: date control. */
- cce.dwSize = sizeof (INITCOMMONCONTROLSEX);
- cce.dwICC = ICC_DATE_CLASSES;
- InitCommonControlsEx (&cce);
+ init_common_controls ();
html_help_init (&cookie);
LoadLibrary ("RichEd32.Dll");
+ manual_shutdown = 0;
break;
case WM_ENDSESSION:
case WM_DESTROY:
case WM_CLOSE:
case WM_QUIT:
- /*cryptdisk_cleanup ();*/
mapi_deinit ();
wsock_end ();
keycache_release (1);
@@ -373,7 +382,7 @@
html_help_deinit (cookie);
if (!gpg_clip_istext_avail (&has_data) && has_data) {
int chk = get_reg_winpt_flag ("WipeClipboard");
- if (chk == -1 && msg != WM_ENDSESSION)
+ if (chk == -1 && manual_shutdown)
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CONFDELCLIP,
GetDesktopWindow (), confirm_delclipboard_dlg,
0);
@@ -400,19 +409,11 @@
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT));
popup = GetSubMenu (hm, 0);
- set_menu_text( popup, ID_WINPT_FILE, _("File Manager") );
- set_menu_text( popup, ID_WINPT_KEY, _("Key Manager") );
- set_menu_text( popup, ID_WINPT_CARD, _("Card Manager") );
+ set_menu_text (popup, ID_WINPT_FILE, _("File Manager"));
+ set_menu_text (popup, ID_WINPT_KEY, _("Key Manager"));
+ set_menu_text (popup, ID_WINPT_CARD, _("Card Manager"));
if (!scard_support)
set_menu_state (popup, ID_WINPT_CARD, MF_DISABLED|MF_GRAYED);
- /*
- if (!cryptdisk_available ()) {
- set_menu_state (popup, ID_WINPT_CDISKNEW, MF_DISABLED|MF_GRAYED);
- set_menu_state (popup, ID_WINPT_CDISKMOUNT, MF_DISABLED|MF_GRAYED);
- set_menu_state (popup, ID_WINPT_CDISKUNMOUNT, MF_DISABLED|MF_GRAYED);
- }
- */
-
set_menu_text (popup, ID_WINPT_EDIT, _("Edit Clipboard"));
set_menu_text (popup, ID_WINPT_ABOUT, _("About..."));
set_menu_text (popup, ID_WINPT_QUIT, _("Exit"));
@@ -512,18 +513,19 @@
case ID_WINPT_SIGN:
case ID_WINPT_SIGNENCRYPT:
case ID_WINPT_DECRYPT_VERIFY:
- err = gpg_clip_istext_avail( &has_data );
- if( err ) {
- msg_box( hwnd, gpgme_strerror( err ),_("Clipboard"), MB_ERR );
+ err = gpg_clip_istext_avail (&has_data);
+ if (err) {
+ msg_box (hwnd, gpgme_strerror (err),_("Clipboard"), MB_ERR);
break;
}
- if( !has_data ) {
- msg_box( hwnd, winpt_strerror (WPTERR_CLIP_EMPTY),_("Clipboard"), MB_ERR );
+ if (!has_data) {
+ msg_box (hwnd, winpt_strerror (WPTERR_CLIP_EMPTY),
+ _("Clipboard"), MB_ERR);
break;
}
clip_gpg_dlg (hwnd, (int)wparam);
break;
-
+
/** Current window operations **/
case ID_WINPT_CURRWND_SYMENC:
case ID_WINPT_CURRWND_ENCRYPT:
@@ -561,11 +563,9 @@
ShowWindow (wnd, SW_RESTORE);
if (wnd)
SetForegroundWindow (wnd);
- param = 0;
- if (cmd)
- param = (LPARAM)cmd;
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYMISC,
- GetDesktopWindow(), keymanager_dlg_proc, param,
+ GetDesktopWindow(), keymanager_dlg_proc,
+ cmd != 0? (LPARAM)cmd : 0,
_("Key Manager"), IDS_WINPT_KEYMISC);
cmd = 0;
break;
@@ -599,29 +599,9 @@
if (rc == TRUE)
update_keycache (GetDesktopWindow ());
break;
-
- /*
- case ID_WINPT_CDISKNEW:
- DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_NEW,
- GetDesktopWindow (), cryptdisk_new_dlg_proc, 0);
- break;
-
- case ID_WINPT_CDISKMOUNT:
- DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_MOUNT,
- GetDesktopWindow (), cryptdisk_mount_dlg_proc, 0);
- break;
-
- case ID_WINPT_CDISKUNMOUNT:
- DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CDISK_UMOUNT,
- GetDesktopWindow (), cryptdisk_umount_dlg_proc, 0);
- break;
-
- case ID_WINPT_CDISKUMOUNTALL:
- cryptdisk_unmount (0, 0);
- break;
- */
case ID_WINPT_QUIT:
+ manual_shutdown = 1;
SendMessage (hwnd, WM_DESTROY, 0, 0);
break;
}
Modified: trunk/Src/wptNLS.c
===================================================================
--- trunk/Src/wptNLS.c 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptNLS.c 2006-04-01 12:36:35 UTC (rev 193)
@@ -32,20 +32,9 @@
#include <sys/stat.h>
#include <windows.h>
-#include "wptTypes.h"
#include "wptNLS.h"
-/* Missing W32 functions. */
-static char *
-w32_stpcpy (char *a,const char *b)
-{
- while( *b )
- *a++ = *b++;
- *a = 0;
- return (char*)a;
-}
-
/* The magic number of the GNU message catalog format. */
#define MAGIC 0x950412de
#define MAGIC_SWAPPED 0xde120495
@@ -53,56 +42,79 @@
/* Revision number of the currently used .mo (binary) file format. */
#define MO_REVISION_NUMBER 0
+#define SWAPIT(flag, data) ((flag) ? do_swap_u32(data) : (data) )
+
+/* We assume to have `unsigned long int' value with at least 32 bits. */
+#define HASHWORDBITS 32
+
+/* The so called `hashpjw' function by P.J. Weinberger
+ [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
+ 1986, 1987 Bell Telephone Laboratories, Inc.] */
+
/* Header for binary .mo file format. */
struct mo_file_header {
- u32 magic; /* The magic number. */
- u32 revision; /* The revision number of the file format. */
- u32 nstrings; /* The number of strings pairs. */
- u32 orig_tab_offset; /* Offset of table with start offsets of original
- strings. */
- u32 trans_tab_offset; /* Offset of table with start offsets of translation
- strings. */
- u32 hash_tab_size; /* Size of hashing table. */
- u32 hash_tab_offset; /* Offset of first hashing entry. */
+ DWORD magic; /* The magic number. */
+ DWORD revision; /* The revision number of the file format. */
+ DWORD nstrings; /* The number of strings pairs. */
+ DWORD orig_tab_offset; /* Offset of table with start offsets of original
+ strings. */
+ DWORD trans_tab_offset; /* Offset of table with start offsets of translation
+ strings. */
+ DWORD hash_tab_size; /* Size of hashing table. */
+ DWORD hash_tab_offset; /* Offset of first hashing entry. */
};
struct string_desc {
- u32 length; /* Length of addressed string. */
- u32 offset; /* Offset of string in file. */
+ DWORD length; /* Length of addressed string. */
+ DWORD offset; /* Offset of string in file. */
};
struct loaded_domain {
char *data;
int must_swap;
- u32 nstrings;
+ DWORD nstrings;
char *mapped;
struct string_desc *orig_tab;
struct string_desc *trans_tab;
- u32 hash_size;
- u32 *hash_tab;
+ DWORD hash_size;
+ DWORD *hash_tab;
};
+/* List of all available languages. */
+struct lang_table_s lang_list[] = {
+ {"en", "English", LANG_ENGLISH},
+ {"de", "German", LANG_GERMAN},
+ {"fr", "French", LANG_FRENCH},
+ {"jp", "Japanese", LANG_JAPANESE},
+ {NULL, 0}
+};
+
+/* The current domain. */
static struct loaded_domain *the_domain;
-static u32
-do_swap_u32( u32 i )
+
+static DWORD
+do_swap_u32 (DWORD i)
{
- return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
+ return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
}
-#define SWAPIT(flag, data) ((flag) ? do_swap_u32(data) : (data) )
+/* Missing W32 functions. */
+static char*
+w32_stpcpy (char *a,const char *b)
+{
+ while (*b)
+ *a++ = *b++;
+ *a = 0;
+ return (char*)a;
+}
-/* We assume to have `unsigned long int' value with at least 32 bits. */
-#define HASHWORDBITS 32
-/* The so called `hashpjw' function by P.J. Weinberger
- [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
- 1986, 1987 Bell Telephone Laboratories, Inc.] */
-static u32
-hash_string( const char *str_param )
+static DWORD
+hash_string (const char *str_param)
{
unsigned long int hval, g;
const char *str = str_param;
@@ -118,7 +130,7 @@
}
}
return hval;
-} /* hash_string */
+}
static struct loaded_domain *
@@ -137,7 +149,7 @@
return NULL; /* can't open the file */
/* we must know about the size of the file */
if( fstat( fileno(fp ), &st )
- || (size = (size_t)st.st_size) != st.st_size
+ || (size = (size_t)st.st_size) != (size_t)st.st_size
|| size < sizeof (struct mo_file_header) ) {
fclose( fp );
return NULL;
@@ -152,7 +164,7 @@
to_read = size;
read_ptr = (char *) data;
do {
- long int nb = fread( read_ptr, 1, to_read, fp );
+ size_t nb = fread( read_ptr, 1, to_read, fp );
if( nb < to_read ) {
fclose (fp);
free(data);
@@ -189,7 +201,7 @@
domain->trans_tab = (struct string_desc *)
((char *) data + SWAPIT(domain->must_swap, data->trans_tab_offset));
domain->hash_size = SWAPIT(domain->must_swap, data->hash_tab_size);
- domain->hash_tab = (u32 *)
+ domain->hash_tab = (DWORD *)
((char *) data + SWAPIT(domain->must_swap, data->hash_tab_offset));
break;
@@ -211,12 +223,8 @@
} /* load_domain */
-/****************
- * Set the file used for translations. Pass a NULL to disable
- * translation. A new filename may be set at anytime.
- * WARNING: After changing the filename you shoudl not access any data
- * retrieved by gettext().
- */
+/* Set the file used for translations. Pass a NULL to disable translation.
+ A new filename may be set at anytime. */
int
set_gettext_file( const char *filename, const char *nls_dir )
{
@@ -255,11 +263,11 @@
}
the_domain = domain;
return 0;
-} /* set_gettext_file */
+}
static const char*
-get_string( struct loaded_domain *domain, u32 idx )
+get_string( struct loaded_domain *domain, DWORD idx )
{
char *p = domain->data + SWAPIT(domain->must_swap,
domain->trans_tab[idx].offset);
@@ -267,8 +275,9 @@
domain->mapped[idx] = 1;
}
return (const char*)p;
-} /* get_string */
+}
+
const char *
gettext( const char *msgid )
{
@@ -282,11 +291,11 @@
/* Locate the MSGID and its translation. */
if( domain->hash_size > 2 && domain->hash_tab ) {
/* Use the hashing table. */
- u32 len = strlen (msgid);
- u32 hash_val = hash_string (msgid);
- u32 idx = hash_val % domain->hash_size;
- u32 incr = 1 + (hash_val % (domain->hash_size - 2));
- u32 nstr = SWAPIT (domain->must_swap, domain->hash_tab[idx]);
+ DWORD len = strlen (msgid);
+ DWORD hash_val = hash_string (msgid);
+ DWORD idx = hash_val % domain->hash_size;
+ DWORD incr = 1 + (hash_val % (domain->hash_size - 2));
+ DWORD nstr = SWAPIT (domain->must_swap, domain->hash_tab[idx]);
if ( !nstr ) /* Hash table entry is empty. */
goto not_found;
@@ -340,27 +349,21 @@
} /* gettext */
-/* Map the user specific language ID to a
- gettext conform language string.
+/* Map the user specific language ID to a gettext conform language string.
Example: LANG_GERMAN -> "de" */
const char*
get_gettext_langid (void)
{
- struct {
- const char *id;
- int langid;
- } lang_table[] = {
- {"de", LANG_GERMAN},
- {NULL, 0},
- };
LANGID lang;
int i;
lang = GetUserDefaultLangID ();
+ if (PRIMARYLANGID (lang) == LANG_ENGLISH)
+ return NULL;
- for (i=0; lang_table[i].id; i++) {
- if (PRIMARYLANGID (lang) == lang_table[i].langid)
- return lang_table[i].id;
+ for (i=0; lang_list[i].id; i++) {
+ if (PRIMARYLANGID (lang) == lang_list[i].langid)
+ return lang_list[i].id;
}
return NULL;
}
Modified: trunk/Src/wptRegistry.cpp
===================================================================
--- trunk/Src/wptRegistry.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptRegistry.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -455,8 +455,8 @@
return p;
lang = get_gettext_langid ();
- if (!lang)
- return NULL;
+ if (!lang)
+ return NULL;
pp = new char[strlen ("share\\xxxxx\\locale\\LC_MESSAGES")+8];
if (!pp)
BUG (NULL);
Modified: trunk/Src/wptSafeEditCtrl.cpp
===================================================================
--- trunk/Src/wptSafeEditCtrl.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptSafeEditCtrl.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -243,7 +243,7 @@
UINT
SafeGetDlgItemText (HWND dlg, int id, char *buf, int buflen)
{
- /* XXX: use memset (buf, 0, buflen)? */
+ memset (buf, 0, buflen);
SendDlgItemMessage (dlg, id, WM_SAFE_GETTEXT, (WPARAM)buf, (LPARAM)buflen);
return strlen (buf);
}
Modified: trunk/Src/wptSigTreeDlg.cpp
===================================================================
--- trunk/Src/wptSigTreeDlg.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptSigTreeDlg.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -29,6 +29,7 @@
#include "wptCommonCtl.h"
#include "wptContext.h"
#include "wptUTF8.h"
+#include "wptW32API.h"
/* ID to display signature properties. */
@@ -106,22 +107,12 @@
create_popup (HWND dlg)
{
HMENU hm;
- MENUITEMINFO mi;
POINT p;
- char *s;
hm = CreatePopupMenu ();
if (!hm)
- BUG( NULL );
- memset (&mi, 0, sizeof mi);
- mi.cbSize = sizeof mi;
- s = (char *)_("Signature &Properties");
- mi.fType = MF_STRING;
- mi.dwTypeData = s;
- mi.cch = strlen (s);
- mi.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE;
- mi.wID = _ID_SIGCTX_PROPS;
- InsertMenuItem (hm, 0, FALSE, &mi);
+ BUG (0);
+ insert_menu_item (hm, 0, _ID_SIGCTX_PROPS, _("Signature &Properties"));
GetCursorPos (&p);
TrackPopupMenu (hm, 0, p.x, p.y, 0, dlg, NULL);
DestroyMenu (hm);
@@ -156,7 +147,7 @@
static HIMAGELIST hil;
HICON ico[2];
NMHDR *nft;
- char inf[256], *p;
+ char inf[300], *p;
switch (msg) {
case WM_INITDIALOG:
@@ -168,8 +159,10 @@
tree = GetDlgItem (dlg, IDC_VKEYSIG_TREE);
hil = treeview_set_image_list (tree, ico, 2);
sigtree_load (tree, key->ctx);
- p = utf8_to_native (key->ctx->uids->uid);
- _snprintf (inf, sizeof (inf)-1, _("Signature Tree for \"%s\""), p);
+ p = utf8_to_native (key->ctx->uids->name);
+ _snprintf (inf, sizeof (inf)-1,
+ _("Signature Tree for \"%s\" (0x%s)"),
+ p, key->ctx->subkeys->keyid+8);
safe_free (p);
SetDlgItemText (dlg, IDC_VKEYSIG_EDIT, _("Edit..."));
SetWindowText (dlg, inf);
Modified: trunk/Src/wptSymEnc.cpp
===================================================================
--- trunk/Src/wptSymEnc.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptSymEnc.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -1,5 +1,5 @@
/* wptSymEnc.cpp - Symmetric encryption support
- * Copyright (C) 2002, 2003, 2004, 2005 Timo Schulz
+ * Copyright (C) 2002, 2003, 2004, 2005, 2006 Timo Schulz
*
* This file is part of WinPT.
*
Modified: trunk/Src/wptUTF8.cpp
===================================================================
--- trunk/Src/wptUTF8.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptUTF8.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -1,4 +1,4 @@
-/* wptUTF8.cpp - UTF8 conversation
+/* wptUTF8.cpp - UTF8 conversation
* Copyright (C) 2002, 2004, 2005, 2006 Timo Schulz
*
* This file is part of WinPT.
@@ -113,8 +113,9 @@
}
+/* Return -1 if the string contains any 8-bit characters. */
int
-is_8bit_string (const char * str)
+is_8bit_string (const char *str)
{
size_t i;
Modified: trunk/Src/wptVerifyList.cpp
===================================================================
--- trunk/Src/wptVerifyList.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptVerifyList.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -36,6 +36,17 @@
#include "wptW32API.h"
+/* Symbolic column IDs */
+enum {
+ VER_COL_NAME = 0,
+ VER_COL_STAT = 1,
+ VER_COL_SIGNED = 2,
+ VER_COL_TRUST = 3,
+ VER_COL_KEYID = 4,
+ VER_COL_UID = 5
+};
+
+
/* Extract the file name part out of the given path in @path.
Return value: file part or NULL on error. */
static char*
@@ -90,41 +101,30 @@
Return value: 0 on success. */
int
verlist_build (listview_ctrl_t *lv, HWND ctrl, int fm_mode)
-{
- int j, rc = 0;
- struct listview_ctrl_s * c;
- struct listview_column_s fm_verlist[] = {
- {0, 100, (char *)_("Name") },
- {1, 120, (char *)_("Status") },
- {2, 115, (char *)_("Signed") },
- {3, 58, (char *)_("Trust") },
- {4, 160, (char *)_("User ID") },
- {5, 0, NULL}
-
+{
+ struct listview_ctrl_s *c;
+ struct listview_column_s verlist[] = {
+ {0, 100, (char *)_("Name")},
+ {1, 140, (char *)_("Status") },
+ {2, 120, (char *)_("Signed") },
+ {3, 58, (char *)_("Trust") },
+ {4, 80, (char *)_("Key ID" )},
+ {5, 160, (char *)_("User ID") },
+ {6, 0, NULL}
};
- struct listview_column_s verlist[] = {
- {0, 140, (char *)_("Status") },
- {1, 120, (char *)_("Signed") },
- {2, 58, (char *)_("Trust") },
- {3, 80, (char *)_("Key ID" )},
- {4, 160, (char *)_("User ID") },
- {5, 0, NULL}
- };
+ int j;
+ int rc;
rc = listview_new (&c);
if (rc)
return rc;
-
c->ctrl = ctrl;
- if( fm_mode ) {
- for( j = 0; fm_verlist[j].fieldname; j++ )
- listview_add_column( c, &fm_verlist[j] );
- }
- else {
- for( j = 0; verlist[j].fieldname; j++ )
- listview_add_column( c, &verlist[ j ] );
- }
- listview_set_ext_style( c );
+
+ for(j=0; verlist[j].fieldname; j++)
+ listview_add_column (c, &verlist[j]);
+ if (!fm_mode)
+ listview_set_column_width (c, 0, 60);
+ listview_set_ext_style (c);
*lv = c;
return 0;
}
@@ -153,29 +153,30 @@
if (listview_add_item (lv, " "))
return WPTERR_GENERAL;
-
+
+ listview_add_sub_item (lv, 0, VER_COL_NAME, "Clipboard");
+
get_pubkey (sig->fpr, &key);
-
if (sig->summary == 0 && gpg_err_code (sig->status) == GPG_ERR_NO_ERROR)
attr = get_gpg_sigstat (GPGME_SIGSUM_GREEN);
else
attr = get_gpg_sigstat (sig->summary);
if (attr)
- listview_add_sub_item (lv, 0, 0, (char *)attr);
+ listview_add_sub_item (lv, 0, VER_COL_STAT, (char *)attr);
attr = strtimestamp (sig->timestamp);
- listview_add_sub_item (lv, 0, 1, (char *)attr);
+ listview_add_sub_item (lv, 0, VER_COL_SIGNED, (char *)attr);
attr = _("Unknown");
if (key) {
key_attr = key->uids->validity;
attr = get_key_trust2 (NULL, key_attr, 0, 0);
}
- listview_add_sub_item (lv, 0, 2, (char *)attr);
+ listview_add_sub_item (lv, 0, VER_COL_TRUST, (char *)attr);
attr = sig->fpr;
if (!attr || strlen (attr) < 8)
- listview_add_sub_item (lv, 0, 3, "????????");
+ listview_add_sub_item (lv, 0, VER_COL_KEYID, "????????");
else {
if (strlen (attr) == 40)
attr += 32;
@@ -184,22 +185,18 @@
else
attr += 8;
_snprintf (keyid, sizeof keyid -1, "0x%s", attr);
- listview_add_sub_item (lv, 0, 3, keyid);
+ listview_add_sub_item (lv, 0, VER_COL_KEYID, keyid);
}
- if (!key) {
- attr = _("Invalid User ID");
- listview_add_sub_item( lv, 0, 4, (char *)attr );
- }
- else {
+ if (!key)
+ attr = _("user ID not found");
+ else
attr = key->uids->name;
- uid = utf8_to_native (attr);
- if (uid) {
- listview_add_sub_item( lv, 0, 4, (char *)uid );
- free (uid);
- }
- }
+ uid = utf8_to_native (attr);
+ listview_add_sub_item (lv, 0, VER_COL_UID, (char *)uid);
+ free (uid);
+
return 0;
}
@@ -213,6 +210,7 @@
gpgme_key_t key = NULL;
const char *attr;
char t[64], *name;
+ int off = 0;
if (listview_add_item (lv, "")) {
log_debug ("verlist_add_sig_log: listview_add_item() failed.\n");
@@ -223,9 +221,9 @@
name = extract_filename (log->file);
if (name)
- listview_add_sub_item (lv, 0, 0, name);
+ listview_add_sub_item (lv, 0, VER_COL_NAME, name);
else
- listview_add_sub_item (lv, 0, 0, log->file);
+ listview_add_sub_item (lv, 0, VER_COL_NAME, log->file);
free_if_alloc (name);
if (sig->summary == 0 && gpg_err_code (sig->status) == GPG_ERR_NO_ERROR)
@@ -233,35 +231,33 @@
else
attr = get_gpg_sigstat (sig->summary);
if (attr)
- listview_add_sub_item (lv, 0, 1, attr);
+ listview_add_sub_item (lv, 0, VER_COL_STAT, attr);
- if (sig->timestamp > 0) {
+ if (sig->timestamp > 0)
attr = strtimestamp (sig->timestamp);
- listview_add_sub_item (lv, 0, 2, attr);
- }
else
- listview_add_sub_item (lv, 0, 2, "No time");
-
- attr = _("Unknown");
+ attr = "No time";
+ listview_add_sub_item (lv, 0, VER_COL_SIGNED, attr);
+
if (key)
attr = get_key_trust2 (NULL, key->uids->validity, 0, 0);
- listview_add_sub_item (lv, 0, 3, attr);
+ else
+ attr = _("Unknown");
+ listview_add_sub_item (lv, 0, VER_COL_TRUST, attr);
- attr = sig->fpr;
- if (!log->use_uid && strlen (attr) == 40) {
- _snprintf (t, sizeof (t)-1, "0x%s", attr + 32);
- listview_add_sub_item (lv, 0, 4, t);
- }
- else if (!log->use_uid && strlen( attr ) == 32) {
- _snprintf (t, sizeof (t)-1, "0x%s", attr + 24);
- listview_add_sub_item (lv, 0, 4, t);
- }
- else if (log->user_id) {
- char *p = utf8_to_native (log->user_id);
- if (p) {
- listview_add_sub_item (lv, 0, 4, p);
- free (p);
- }
- }
+ if (strlen (sig->fpr) == 16)
+ off = 8;
+ else
+ off = strlen (sig->fpr) == 40? 32 : 24;
+ _snprintf (t, sizeof (t)-1, "0x%s", sig->fpr + off);
+ listview_add_sub_item (lv, 0, VER_COL_KEYID, t);
+
+ if (log->user_id)
+ name = utf8_to_native (log->user_id);
+ else
+ name = strdup (_("user ID not found"));
+
+ listview_add_sub_item (lv, 0, VER_COL_UID, name);
+ free (name);
return 0;
}
Modified: trunk/Src/wptW32API.cpp
===================================================================
--- trunk/Src/wptW32API.cpp 2006-04-01 12:36:22 UTC (rev 192)
+++ trunk/Src/wptW32API.cpp 2006-04-01 12:36:35 UTC (rev 193)
@@ -41,6 +41,24 @@
extern "C" void _SHFree (void *p);
+
+/* Insert a new item into the menu @hm at position @pos. */
+void
+insert_menu_item (HMENU hm, int pos, UINT m_id, const char *text)
+{
+ MENUITEMINFO mi;
+
+ memset (&mi, 0, sizeof mi);
+ mi.cbSize = sizeof mi;
+ mi.fType = MF_STRING;
+ mi.dwTypeData = (char *)text;
+ mi.cch = strlen (text);
+ mi.wID = m_id;
+ mi.fMask = MIIM_ID|MIIM_DATA| MIIM_TYPE;
+ InsertMenuItem (hm, pos, FALSE, &mi);
+}
+
+
static void
set_menu_text_ext (HMENU menu, int by_pos, int m_uid, const char *text)
{
@@ -108,8 +126,8 @@
id can be either FILE_OPEN or FILE_SAVE.
The return value is the file name or NULL if cancel was chosen. */
const char *
-get_filename_dlg (HWND hwnd, int id, const char * title,
- const char * filter, const char * name)
+get_filename_dlg (HWND hwnd, int id, const char *title,
+ const char *filter, const char *name)
{
static char file[512] = "";
OPENFILENAME open;
More information about the Winpt-commits
mailing list