[Winpt-commits] r147 - trunk/Src
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Fri Jan 13 15:21:18 CET 2006
Author: twoaday
Date: 2006-01-13 15:21:16 +0100 (Fri, 13 Jan 2006)
New Revision: 147
Modified:
trunk/Src/ChangeLog
trunk/Src/WinPT-en.rc
trunk/Src/resource.h
trunk/Src/wptAboutDlgs.cpp
trunk/Src/wptGPGPrefsDlg.cpp
trunk/Src/wptKeyCache.cpp
trunk/Src/wptKeyManagerDlg.cpp
trunk/Src/wptKeyserver.cpp
trunk/Src/wptKeyserverDlg.cpp
trunk/Src/wptKeyserverSearchDlg.cpp
trunk/Src/wptPreferencesDlg.cpp
Log:
2006-11-13 Timo Schulz <ts at g10code.com>
* wptPreferencesDlg.cpp (prefs_dlg_proc): Changed translation.
* wptGPGPrefsDlg.cpp (gpgprefs_dlg_proc): Likewise.
* wptAboutDlgs.cpp (about_dlg_proc): Make sure GPG about
dialog isn't shown twice.
* wptKeyCache.cpp (gpg_keycache_next_updated_key): New.
(gpg_keycache_update_key): Set update flag.
* wptKeyManagerDlg.cpp (refresh_keylist): New.
(keymanager_dlg_proc): Use new refresh system for keyservers.
* wptKeyserverSearchDlg.cpp (kserver_search_dlg_proc):
Update keycache.
* wptKeyserverDlg.cpp (hkp_dlg_proc): Likewise.
* wptKeyserver.cpp (socket_read_ext): New.
(kserver_recv_key_ext): New.
(kserver_read_config, kserver_write_config): Removed.
Modified: trunk/Src/ChangeLog
===================================================================
--- trunk/Src/ChangeLog 2006-01-13 14:20:51 UTC (rev 146)
+++ trunk/Src/ChangeLog 2006-01-13 14:21:16 UTC (rev 147)
@@ -1,3 +1,20 @@
+2006-11-13 Timo Schulz <ts at g10code.com>
+
+ * wptPreferencesDlg.cpp (prefs_dlg_proc): Changed translation.
+ * wptGPGPrefsDlg.cpp (gpgprefs_dlg_proc): Likewise.
+ * wptAboutDlgs.cpp (about_dlg_proc): Make sure GPG about
+ dialog isn't shown twice.
+ * wptKeyCache.cpp (gpg_keycache_next_updated_key): New.
+ (gpg_keycache_update_key): Set update flag.
+ * wptKeyManagerDlg.cpp (refresh_keylist): New.
+ (keymanager_dlg_proc): Use new refresh system for keyservers.
+ * wptKeyserverSearchDlg.cpp (kserver_search_dlg_proc):
+ Update keycache.
+ * wptKeyserverDlg.cpp (hkp_dlg_proc): Likewise.
+ * wptKeyserver.cpp (socket_read_ext): New.
+ (kserver_recv_key_ext): New.
+ (kserver_read_config, kserver_write_config): Removed.
+
2006-01-12 Timo Schulz <ts at g10code.com>
* wptListView.cpp (listview_set_image_list): Make icons
Modified: trunk/Src/WinPT-en.rc
===================================================================
--- trunk/Src/WinPT-en.rc 2006-01-13 14:20:51 UTC (rev 146)
+++ trunk/Src/WinPT-en.rc 2006-01-13 14:21:16 UTC (rev 147)
@@ -526,17 +526,17 @@
GROUPBOX "",IDC_STATIC,5,4,208,67
LTEXT "GnuPG home directory (where both keyrings are located)",
IDC_GPGPREFS_HOMEINF,12,12,181,8
- EDITTEXT IDC_GPGPREFS_HOMEDIR,12,22,171,12,ES_AUTOHSCROLL
- PUSHBUTTON "..",IDC_GPGPREFS_HOMEDLG,188,23,20,13
+ EDITTEXT IDC_GPGPREFS_HOMEDIR,12,22,152,12,ES_AUTOHSCROLL
+ PUSHBUTTON "Browse...",IDC_GPGPREFS_HOMEDLG,167,21,41,14
LTEXT "GnuPG exe file location (full path with added gpg.exe)",
IDC_GPGPREFS_EXEINF,12,41,170,8
- EDITTEXT IDC_GPGPREFS_EXEDIR,12,52,173,12,ES_AUTOHSCROLL
- PUSHBUTTON "..",IDC_GPGREFS_EXEDLG,188,51,20,13
+ EDITTEXT IDC_GPGPREFS_EXEDIR,12,52,152,12,ES_AUTOHSCROLL
+ PUSHBUTTON "Browse...",IDC_GPGREFS_EXEDLG,167,51,41,14
GROUPBOX "",IDC_STATIC,6,76,209,37
LTEXT "Locale directory (to access the translation files)",
IDC_GPGPREFS_LOCALINF,12,85,148,8
- EDITTEXT IDC_GPGPREFS_LOCALE,12,96,172,12,ES_AUTOHSCROLL
- PUSHBUTTON "..",IDC_GPGPREFS_LOCDLG,188,96,20,13
+ EDITTEXT IDC_GPGPREFS_LOCALE,12,96,152,12,ES_AUTOHSCROLL
+ PUSHBUTTON "Browse...",IDC_GPGPREFS_LOCDLG,167,95,41,14
GROUPBOX "General GPG options",IDC_GPGPREFS_ALLOPTINF,5,116,210,
74
CONTROL "Ask for the signature class during key sign",
@@ -646,7 +646,7 @@
PUSHBUTTON "&Cancel",IDCANCEL,119,107,50,14
END
-IDD_WINPT_PREFS DIALOG DISCARDABLE 0, 0, 267, 285
+IDD_WINPT_PREFS DIALOG DISCARDABLE 0, 0, 292, 285
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "WinPT Preferences"
FONT 8, "MS Sans Serif"
@@ -656,7 +656,7 @@
EDITTEXT IDC_PREFS_CACHETIME,124,7,25,13
LTEXT "(CTRL+ALT+F to clear the cache)",IDC_PREFS_CACHEHINT,
151,9,108,8
- GROUPBOX "General options",IDC_PREFS_ALLOPTINF,8,23,245,113
+ GROUPBOX "General options",IDC_PREFS_ALLOPTINF,8,23,271,113
LTEXT "Word wrap cleartext &signatures at column",
IDC_PREFS_WWINFO,13,34,139,8
EDITTEXT IDC_PREFS_WORDWRAP,156,32,14,13
@@ -676,7 +676,7 @@
WS_VSCROLL | WS_TABSTOP
LTEXT "Keyserver &config",IDC_PREFS_KSINF,13,119,76,8
EDITTEXT IDC_PREFS_KSERVER,100,119,124,12,ES_AUTOHSCROLL
- PUSHBUTTON "...",IDC_PREFS_KSELFILE,225,119,22,12
+ PUSHBUTTON "Browse...",IDC_PREFS_KSELFILE,225,119,48,14
GROUPBOX "Clipboard hotkeys",IDC_PREFS_CLIPINF,8,137,112,70
LTEXT "Encrypt CTRL+ALT+",IDC_STATIC,13,152,67,8
EDITTEXT IDC_PREFS_CLIP_ENCRYPT,83,150,10,12
@@ -686,7 +686,7 @@
EDITTEXT IDC_PREFS_CLIP_SIGNENC,73,175,9,12
LTEXT "Sign && Encrypt CTRL+ALT+",IDC_STATIC,13,191,89,8
EDITTEXT IDC_PREFS_CLIP_SIGN,103,189,9,13
- GROUPBOX "Current window hotkeys",IDC_PREFS_CURRINF,127,137,127,
+ GROUPBOX "Current window hotkeys",IDC_PREFS_CURRINF,127,137,152,
70
LTEXT "Encrypt ALT+SHIFT+",IDC_STATIC,134,152,69,8
EDITTEXT IDC_PREFS_CWS_ENCRYPT,210,150,9,12
@@ -699,7 +699,7 @@
CONTROL "&Disable hotkeys (Not recommended!)",
IDC_PREFS_DISABLE_HOTKEYS,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,8,210,159,10
- GROUPBOX "",IDC_STATIC,8,229,246,38
+ GROUPBOX "",IDC_STATIC,8,229,271,38
CONTROL "&Automatic keyring backup when WinPT closes",
IDC_PREFS_AUTOBACKUP,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,14,228,195,11
@@ -708,7 +708,7 @@
CONTROL "Backup to:",IDC_PREFS_BAKUSER,"Button",
BS_AUTORADIOBUTTON,24,252,55,10
EDITTEXT IDC_PREFS_BAKPATH,80,251,130,12,ES_AUTOHSCROLL
- PUSHBUTTON "...",IDC_PREFS_BAKSELECT,212,250,23,12
+ PUSHBUTTON "Browse...",IDC_PREFS_BAKSELECT,212,250,47,14
DEFPUSHBUTTON "&OK",IDOK,151,270,50,14
PUSHBUTTON "&Cancel",IDCANCEL,203,270,50,14
END
@@ -1413,7 +1413,18 @@
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
+
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
@@ -1593,7 +1604,7 @@
IDD_WINPT_PREFS, DIALOG
BEGIN
LEFTMARGIN, 3
- RIGHTMARGIN, 261
+ RIGHTMARGIN, 286
TOPMARGIN, 3
BOTTOMMARGIN, 283
END
@@ -1925,6 +1936,14 @@
TOPMARGIN, 1
BOTTOMMARGIN, 59
END
+
+ IDD_WINPT_INFODLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 1
+ RIGHTMARGIN, 255
+ TOPMARGIN, 1
+ BOTTOMMARGIN, 64
+ END
END
#endif // APSTUDIO_INVOKED
Modified: trunk/Src/resource.h
===================================================================
--- trunk/Src/resource.h 2006-01-13 14:20:51 UTC (rev 146)
+++ trunk/Src/resource.h 2006-01-13 14:21:16 UTC (rev 147)
@@ -158,6 +158,7 @@
#define IDI_KEY_SEARCH 234
#define IDI_KEY_NEW 235
#define IDI_COMPUTER 236
+#define IDD_WINPT_INFODLG 237
#define IDC_CLIPEDIT_SEND 1000
#define IDC_CLIPEDIT_CLEAR 1001
#define IDC_CLIPEDIT_CLIPTEXT 1002
@@ -619,6 +620,8 @@
#define IDC_FILE_SIG_SIGINF 1498
#define IDC_FILE_SIG_OPTINF 1499
#define IDC_ABOUT_GPLINF 1501
+#define IDC_INFODLG_TEXT 1502
+#define IDC_INFODLG_ICO 1503
#define ID_GPG_ENCRYPT 40003
#define ID_GPG_DECRYPT 40004
#define ID_GPG_SIGN 40005
@@ -793,9 +796,9 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 237
+#define _APS_NEXT_RESOURCE_VALUE 238
#define _APS_NEXT_COMMAND_VALUE 40182
-#define _APS_NEXT_CONTROL_VALUE 1502
+#define _APS_NEXT_CONTROL_VALUE 1504
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
Modified: trunk/Src/wptAboutDlgs.cpp
===================================================================
--- trunk/Src/wptAboutDlgs.cpp 2006-01-13 14:20:51 UTC (rev 146)
+++ trunk/Src/wptAboutDlgs.cpp 2006-01-13 14:21:16 UTC (rev 147)
@@ -36,8 +36,8 @@
static DWORD help_arr[] = {
IDC_ABOUT_HELP, WPT_ABOUT_HELP,
- IDC_ABOUT_GPG, WPT_ABOUT_GPG,
- IDOK, WPT_ABOUT_OK,
+ IDC_ABOUT_GPG, WPT_ABOUT_GPG,
+ IDOK, WPT_ABOUT_OK,
0, 0};
#endif
@@ -73,7 +73,7 @@
case IDOK:
EndDialog (dlg, TRUE);
return TRUE;
-
+
case IDCANCEL:
EndDialog (dlg, FALSE);
return TRUE;
@@ -115,10 +115,9 @@
SetDlgItemText (dlg, IDC_ABOUT_GPG, _("&About GPG..."));
SetDlgItemText (dlg, IDC_ABOUT_HELP, _("&Help"));
SetDlgItemText (dlg, IDC_WINPT_VERSION, PACKAGE_FULL_VERSION);
+ /* XXX provide full CHM help file. */
+ EnableWindow (GetDlgItem (dlg, IDC_ABOUT_HELP), FALSE);
- /* XXX provide full CHM help file. */
- EnableWindow (GetDlgItem (dlg, IDC_ABOUT_HELP), FALSE);
-
center_window (dlg, NULL);
SetForegroundWindow (dlg);
return TRUE;
@@ -139,8 +138,9 @@
case WM_COMMAND:
switch (LOWORD (wparam)) {
case IDC_ABOUT_GPG:
- DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_ABOUTGPG, GetDesktopWindow(),
- about_gpg_dlg_proc, 0);
+ dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_ABOUTGPG,
+ GetDesktopWindow(), about_gpg_dlg_proc,
+ 0, _("About the GNU Privacy Guard"), 0);
return TRUE;
case IDC_ABOUT_HELP:
@@ -150,7 +150,7 @@
case IDOK:
EndDialog (dlg, TRUE);
return TRUE;
-
+
case IDCANCEL:
EndDialog (dlg, FALSE);
return TRUE;
Modified: trunk/Src/wptGPGPrefsDlg.cpp
===================================================================
--- trunk/Src/wptGPGPrefsDlg.cpp 2006-01-13 14:20:51 UTC (rev 146)
+++ trunk/Src/wptGPGPrefsDlg.cpp 2006-01-13 14:21:16 UTC (rev 147)
@@ -136,6 +136,9 @@
SetDlgItemText (dlg, IDC_GPGPREFS_CMTINF, _("Comment in armored files"));
SetDlgItemText (dlg, IDC_GPGPREFS_ENCINF, _("Encrypt to this key"));
SetDlgItemText (dlg, IDC_GPGPREFS_ALLOPTINF, _("General GPG options"));
+ SetDlgItemText (dlg, IDC_GPGPREFS_HOMEDLG, _("Browse..."));
+ SetDlgItemText (dlg, IDC_GPGREFS_EXEDLG, _("Browse..."));
+ SetDlgItemText (dlg, IDC_GPGPREFS_LOCDLG, _("Browse..."));
gpg4win = load_gpg4win_values (dlg);
if (!gpg4win)
Modified: trunk/Src/wptKeyCache.cpp
===================================================================
--- trunk/Src/wptKeyCache.cpp 2006-01-13 14:20:51 UTC (rev 146)
+++ trunk/Src/wptKeyCache.cpp 2006-01-13 14:21:16 UTC (rev 147)
@@ -501,7 +501,28 @@
}
+/* Return the next key which was updated. Before it is
+ returned the update flag is cleared.
+ Return value: 0 on success. */
gpgme_error_t
+gpg_keycache_next_updated_key (gpg_keycache_t ctx,
+ struct keycache_s **r_obj)
+{
+ struct keycache_s *c;
+
+ for (c = ctx->item; c; c = c->next) {
+ if (c->flags == 1) {
+ c->flags = 0;
+ *r_obj = c;
+ return 0;
+ }
+ }
+ return gpg_error (GPG_ERR_NOT_FOUND);
+}
+
+
+
+gpgme_error_t
gpg_keycache_update_key (gpg_keycache_t ctx, int is_sec,
void *opaque, const char *keyid)
{
@@ -523,7 +544,7 @@
log_debug ("keycache update: keyid=%s %p\r\n", keyid, pub);
gpgme_key_release (fndkey);
c->key = key;
- c->flags = 0;
+ c->flags = 1;
if (is_sec && pub != NULL &&
!gpg_keycache_find_key (pub, keyid, 0, &fndkey)) {
log_debug ("keycache update: set public part %p\r\n", fndkey);
@@ -546,6 +567,8 @@
c->gloflags.divert_to_card = c_new->gloflags.divert_to_card;
}
}
+ if (c)
+ c->flags = 1;
}
return 0;
}
Modified: trunk/Src/wptKeyManagerDlg.cpp
===================================================================
--- trunk/Src/wptKeyManagerDlg.cpp 2006-01-13 14:20:51 UTC (rev 146)
+++ trunk/Src/wptKeyManagerDlg.cpp 2006-01-13 14:21:16 UTC (rev 147)
@@ -1015,7 +1015,22 @@
}
+/* Add all recently updated keys in the cache to the list. */
+static void
+refresh_keylist (listview_ctrl_t lv)
+{
+ struct keycache_s *ctx;
+ gpg_keycache_t kc;
+ kc = keycache_get_ctx (1);
+ while (!gpg_keycache_next_updated_key (kc, &ctx)) {
+ keylist_add_key (lv, KEYLIST_LIST, ctx->key);
+ /*msg_box (NULL, ctx->key->uids->name, "debug", MB_OK);*/
+ }
+ keylist_sort (lv, KEY_SORT_USERID);
+}
+
+
/* Dialog box procedure for the Key Manager. */
BOOL CALLBACK
keymanager_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
@@ -1555,14 +1570,10 @@
return TRUE;
case ID_KEYMISC_SENDRECV:
- memset (&genkey, 0, sizeof (genkey));
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYSERVER, dlg,
- keyserver_dlg_proc, (LPARAM)&genkey, _("Keyserver Access"),
+ keyserver_dlg_proc, 0, _("Keyserver Access"),
IDS_WINPT_KEYSERVER);
- if (genkey.newkey != NULL) {
- keylist_add_key (kmi->lv, KEYLIST_LIST, genkey.newkey);
- keylist_sort (kmi->lv, KEY_SORT_USERID);
- }
+ refresh_keylist (kmi->lv);
return TRUE;
case ID_KEYMISC_GPGPREFS:
Modified: trunk/Src/wptKeyserver.cpp
===================================================================
--- trunk/Src/wptKeyserver.cpp 2006-01-13 14:20:51 UTC (rev 146)
+++ trunk/Src/wptKeyserver.cpp 2006-01-13 14:21:16 UTC (rev 147)
@@ -56,7 +56,6 @@
"hkp://wwwkeys.eu.pgp.net",
"hkp://wwwkeys.uk.pgp.net",
"hkp://wwwkeys.us.pgp.net",
- "hkp://gnv.us.ks.cryptnet.net",
"hkp://subkeys.pgp.net",
"ldap://keyserver.pgp.com",
NULL
@@ -67,8 +66,9 @@
static int hkp_err = 0; /* != 0 indicates an error occurred. */
static DWORD conf_timestamp = 0;/* timestamp of the configuration fiele. */
-char *default_keyserver = NULL;
-WORD default_keyserver_port = 0;
+/* Default keyserver and port. */
+char *default_keyserver = NULL;
+WORD default_keyserver_port = 0;
/* Basic64 encode the input @inputstr to @outputstr. */
@@ -83,8 +83,8 @@
res = temp;
res = (res << 8) | (inputstr[i] & 0xFF);
switch (index++) {
- case 0: outputstr[len++] = base64code[res >> 2 & 0x3F]; res &= 0x3; break;
- case 1: outputstr[len++] = base64code[res >> 4 & 0x3F]; res &= 0xF; break;
+ case 0: outputstr[len++] = base64code[res >> 2 & 0x3F]; res &= 0x3; break;
+ case 1: outputstr[len++] = base64code[res >> 4 & 0x3F]; res &= 0xF; break;
case 2: outputstr[len++] = base64code[res >> 6 & 0x3F];
outputstr[len++] = base64code[res & 0x3F]; res = index = 0; break;
}
@@ -233,7 +233,45 @@
return 0;
}
+/* Read much data as possible from the socket @fd and
+ return the data in @buffer. Caller must free data.
+ Return value: 0 on success. */
+int
+sock_read_ext (int fd, char **buffer, int *r_bufferlen)
+{
+ gpgme_data_t dh;
+ char buf[1024], *p;
+ size_t n=0;
+ int nread, rc;
+ gpgme_data_new (&dh);
+ while (n < 10) {
+ rc = sock_select (fd, 1);
+ if (rc == SOCKET_ERROR) {
+ gpgme_data_release (dh);
+ return rc;
+ }
+ else if (!rc)
+ n++;
+ else {
+ nread = recv (fd, buf, sizeof (buf), 0);
+ if (nread == SOCKET_ERROR)
+ return SOCKET_ERROR;
+ else if (!nread)
+ break;
+ gpgme_data_write (dh, buf, nread);
+ }
+ }
+ gpg_data_putc (dh, '\0');
+ p = gpgme_data_release_and_get_mem (dh, &n);
+ *buffer = m_strdup (p);
+ if (r_bufferlen)
+ *r_bufferlen = n;
+ gpgme_free (p);
+ return 0;
+}
+
+
/* Write the buffer @buf with the length @buflen to a socket @fd. */
static int
sock_write (int fd, const char *buf, int buflen)
@@ -294,7 +332,6 @@
int i;
free_if_alloc (default_keyserver);
- default_keyserver = NULL;
for (i=0; i < MAX_KEYSERVERS; i++) {
if (server[i].used)
free_if_alloc (server[i].name);
@@ -483,8 +520,9 @@
}
+/* Load the keyserver config file @conf. */
int
-kserver_load_conf (const char * conf)
+kserver_load_conf (const char *conf)
{
struct stat statbuf;
FILE *fp;
@@ -511,12 +549,13 @@
if (user && pass)
kserver_update_proxyuser (user, pass);
else if (user && !pass || !user && pass) {
- msg_box( NULL, _("Invalid proxy configuration."
+ msg_box (NULL, _("Invalid proxy configuration."
"You need to set a user and a password"
- "to use proxy authentication!"), _("Proxy Error"), MB_ERR );
+ "to use proxy authentication!"),
+ _("Proxy Error"), MB_ERR);
}
/* check if the host has a http:// prefix and skip it */
- if( proxy.host && !strncmp( proxy.host, "http://", 7 ) ) {
+ if (proxy.host && !strncmp (proxy.host, "http://", 7)) {
char *host = m_strdup (proxy.host+7);
if (!host)
BUG (0);
@@ -527,7 +566,7 @@
free_if_alloc (pass);
pos = 0;
- while( fp && !feof( fp ) ) {
+ while (fp && !feof (fp)) {
s = fgets (buf, sizeof (buf)-1, fp);
if (!s)
break;
@@ -564,9 +603,9 @@
memcpy (server[pos].name, s, (p-s));
}
pos++;
- if (pos > MAX_KEYSERVERS)
- {
- msg_box (NULL, _("The keyserver limit is exceeded"), _("Keyserver Warning"), MB_INFO);
+ if (pos > MAX_KEYSERVERS) {
+ msg_box (NULL, _("The keyserver limit is exceeded"),
+ _("Keyserver Warning"), MB_INFO);
break;
}
}
@@ -576,13 +615,13 @@
/* only issue an error if the config file exist but it has no valid entries. */
keyserver_set_default (NULL, HKP_PORT);
if (!no_config)
- return WPTERR_CONFIG_FILE;
+ return WPTERR_CONFIG_FILE;
}
if (!stat (conf, &statbuf))
conf_timestamp = statbuf.st_mtime;
return 0;
-} /* kserver_load_conf */
+}
/* Return the proxy host and port if available. Null otherwise. */
@@ -767,10 +806,9 @@
}
-/* Interface for receiving a public key. */
int
-kserver_recvkey (const char *hostname, WORD port, const char *keyid,
- char *key, int maxkeylen)
+kserver_recvkey_ext (const char *hostname, WORD port, const char *keyid,
+ char **r_key, int *r_keylen)
{
char *request = NULL;
int conn_fd;
@@ -811,14 +849,16 @@
goto leave;
}
- rc = sock_read( conn_fd, key, maxkeylen, &n );
- if( rc == SOCKET_ERROR ) {
+ rc = sock_read_ext (conn_fd, r_key, &n);
+ if (rc == SOCKET_ERROR) {
rc = WPTERR_WINSOCK_RECVKEY;
goto leave;
}
- log_debug("%s\r\n", key);
- rc = check_hkp_response (key, 1);
+ if (r_keylen)
+ *r_keylen = n;
+ log_debug("%s\r\n", *r_key);
+ rc = check_hkp_response (*r_key, 1);
if (rc)
goto leave;
@@ -830,7 +870,30 @@
return rc;
}
+/* Interface for receiving a public key. */
+int
+kserver_recvkey (const char *hostname, WORD port, const char *keyid,
+ char *key, int maxkeylen)
+{
+ char *tmpkey;
+ int rc, nread=0;
+ /* XXX: just a wrapper around the new method, replace it
+ soon as possible. */
+ rc = kserver_recvkey_ext (hostname, port, keyid, &tmpkey, &nread);
+ if (rc)
+ return rc;
+
+ if (nread > maxkeylen) {
+ free_if_alloc (tmpkey);
+ return WPTERR_GENERAL;
+ }
+ strcpy (key, tmpkey);
+ free_if_alloc (tmpkey);
+ return 0;
+}
+
+
/* Interface to send a public key. */
int
kserver_sendkey (const char *hostname, WORD port, const char *pubkey, int len )
@@ -911,7 +974,8 @@
}
else {
_snprintf (request, n,
- "GET /pks/lookup?op=index&search=%s HTTP/1.0\r\n\r\n", enc_keyid);
+ "GET /pks/lookup?op=index&search=%s HTTP/1.0\r\n\r\n",
+ enc_keyid);
}
log_debug ("kserver_search_init:\r\n%s\r\n", request);
@@ -964,9 +1028,9 @@
p = strtok (buf, "-");
while (p != NULL) {
switch (pos) {
- case 0: st.wYear = (WORD)atoi (p); pos++; break;
+ case 0: st.wYear = (WORD)atoi (p); pos++; break;
case 1: st.wMonth = (WORD)atoi (p); pos++; break;
- case 2: st.wDay = (WORD)atoi (p); pos++; break;
+ case 2: st.wDay = (WORD)atoi (p); pos++; break;
default: break;
}
p = strtok (NULL, "-");
@@ -1052,122 +1116,25 @@
}
-static int
-add_node( keyserver_cfgfile *cfg, const char *entry )
-{
- keyserver_node *node;
- char *p = NULL;
-
- p = strchr( entry, '=' );
- if( p == NULL )
- return WPTERR_GENERAL;
- node = new keyserver_node;
- if( !node )
- BUG (NULL);
-
- memset( node, 0, sizeof *node );
- node->used = 1;
-
- node->host.used = 1;
- node->host.proto = proto_from_URL( entry );
- memcpy( node->host.name, entry+7, p-entry-7 );
- node->next = cfg->list;
- cfg->list = node;
-
- return 0;
-} /* add_node */
-
-
+/* Replace all current proxy items with the items
+ from the context @ctx. */
void
-kserver_change_proxy( keyserver_proxy_ctx *ctx )
+kserver_change_proxy (keyserver_proxy_ctx *ctx)
{
proxy.port = ctx->port;
free_if_alloc (proxy.host);
- proxy.host = ctx->host? m_strdup( ctx->host ) : NULL;
- free_if_alloc( proxy.pass );
- proxy.pass = ctx->pass? m_strdup( ctx->pass ) : NULL;
- free_if_alloc( proxy.user );
- proxy.user = ctx->user? m_strdup( ctx->user ) : NULL;
- set_reg_proxy_prefs( proxy.host, proxy.port, proxy.user, proxy.pass );
-} /* kserver_change_proxy */
-
-
-int
-kserver_read_config( const char *fname, keyserver_cfgfile **ret_cfg )
-{
- FILE *fp;
- keyserver_cfgfile *cfg;
- char buf[256];
- int rc = 0;
-
- *ret_cfg = NULL;
- fp = fopen( fname, "rb" );
- if( fp == NULL )
- return WPTERR_FILE_OPEN;
-
- cfg = new keyserver_cfgfile;
- if ( !cfg )
- BUG( NULL );
- memset( cfg, 0, sizeof *cfg );
-
- while ( !feof( fp ) ) {
- if ( fgets( buf, sizeof(buf)-1, fp ) == NULL )
- break;
- if ( *buf == '\r' || *buf == '\n' || *buf == '#' )
- continue;
- buf[strlen(buf) -2] = '\0';
- if ( !strncmp( buf, "use_proxy=", 10 ) ) {
- char *p = strchr(buf, ':');
- if (!p)
- continue;
- cfg->proxy.port = atol( buf+(p-buf+1) );
- buf[p-buf] = '\0';
- cfg->proxy.host = m_strdup( buf+10 );
- }
- else if ( !strncmp( buf, "proxy_user=", 11 ) )
- cfg->proxy.user = m_strdup( buf+11 );
- else if ( !strncmp( buf, "proxy_pass=", 11 ) )
- cfg->proxy.pass = m_strdup( buf+11 );
- if ( !strncmp( buf, "http://", 7 )
- || !strncmp( buf, "hkp://", 6 )
- || !strncmp( buf, "ldap://", 7 ) ) {
- add_node( cfg, buf );
- cfg->nlist++;
- }
- }
-
- fclose( fp );
- *ret_cfg = cfg;
-
- return rc;
-} /* kserver_read_config */
-
-
-int
-kserver_write_config( const char * fname, keyserver_cfgfile * cfg )
-{
-
- return 0;
+ proxy.host = ctx->host? m_strdup (ctx->host) : NULL;
+ free_if_alloc (proxy.pass);
+ proxy.pass = ctx->pass? m_strdup (ctx->pass) : NULL;
+ free_if_alloc (proxy.user);
+ proxy.user = ctx->user? m_strdup (ctx->user) : NULL;
+ set_reg_proxy_prefs (proxy.host, proxy.port, proxy.user, proxy.pass);
}
-void
-kserver_cfgfile_release( keyserver_cfgfile *cfg )
-{
- keyserver_node *k, *k2;
-
- proxy_release( &cfg->proxy );
- for( k = cfg->list; cfg->nlist--; k = k2 ) {
- k2 = k->next;
- free_if_alloc( k );
- }
- free_if_alloc( cfg );
-} /* kserver_cfgfile_release */
-
-
/* Release mbmers in the proxy context @ctx. */
void
-proxy_release( keyserver_proxy_ctx *ctx )
+proxy_release (keyserver_proxy_ctx *ctx)
{
free_if_alloc (ctx->host);
free_if_alloc (ctx->pass);
@@ -1204,7 +1171,7 @@
/* Receive an key via LDAP from host @host with the keyid @keyid.
@key contains the key on success. */
-int
+int
ldap_recvkey (const char *host, const char *keyid, char *key, int maxkeylen)
{
FILE *inp;
Modified: trunk/Src/wptKeyserverDlg.cpp
===================================================================
--- trunk/Src/wptKeyserverDlg.cpp 2006-01-13 14:20:51 UTC (rev 146)
+++ trunk/Src/wptKeyserverDlg.cpp 2006-01-13 14:21:16 UTC (rev 147)
@@ -253,7 +253,15 @@
proto, flags, NULL);
}
+int
+hkp_recv_key2 (HWND dlg, const char *kserver, WORD port,
+ const char *pattern, int proto, char **r_fpr)
+{
+ return keyserver_recv_key (dlg, kserver, port, pattern, proto, 0,
+ r_fpr);
+}
+
#define my_iskeychar(a) (((a) >='0' && (a) <= '9' ) || ((a) >= 'A' && (a) <= 'F'))
static int
@@ -430,16 +438,13 @@
{
static listview_ctrl_t lv = NULL;
static int lv_idx = 0;
- static struct genkey_s *key;
keyserver_ctx ksc;
char kserver[128], pattern[128];
- char proto[16];
+ char proto[16], *fpr = NULL;
int rc, proto_nr = 0;
switch (msg) {
case WM_INITDIALOG:
- if (lparam != 0)
- key = (struct genkey_s*)lparam;
SetWindowText (dlg, _("Keyserver Access"));
SetDlgItemText (dlg, IDC_KEYSERVER_RECV, _("&Receive"));
SetDlgItemText (dlg, IDC_KEYSERVER_SEND,
@@ -555,12 +560,10 @@
}
rc = keyserver_recv_key (dlg, kserver, kserver_get_port (lv),
pattern, proto_nr, 0,
- key? &key->fpr : NULL);
- if (!rc && key->fpr != NULL) {
- keycache_update (0, key->fpr);
- get_pubkey (key->fpr, &key->newkey);
- /* we do not need the fingerprint any longer. */
- free_if_alloc (key->fpr);
+ &fpr);
+ if (!rc && fpr != NULL) {
+ keycache_update (0, fpr);
+ free_if_alloc (fpr);
}
return TRUE;
Modified: trunk/Src/wptKeyserverSearchDlg.cpp
===================================================================
--- trunk/Src/wptKeyserverSearchDlg.cpp 2006-01-13 14:20:51 UTC (rev 146)
+++ trunk/Src/wptKeyserverSearchDlg.cpp 2006-01-13 14:21:16 UTC (rev 147)
@@ -1,5 +1,5 @@
/* wptKeyserverSearchDlg.cpp - Keyserver Searching
- * Copyright (C) 2001-2005 Timo Schulz
+ * Copyright (C) 2001-2006 Timo Schulz
*
* This file is part of WinPT.
*
@@ -35,6 +35,12 @@
#include "wptNLS.h"
+int
+hkp_recv_key2 (HWND dlg, const char *kserver, WORD port,
+ const char *pattern, int proto, char **r_fpr);
+
+
+/* Dialog box procedur for keyserver searching. */
BOOL CALLBACK
hkpsearch_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
@@ -48,12 +54,11 @@
{3, 256, (char *)_("User ID")},
{0, 0, NULL}
};
- char t[32], info[384];
+ char t[32], info[384], *fpr = NULL;
int i, rc;
int conn_fd = 0;
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
ksc = (keyserver_ctx *)lparam;
if (!ksc)
@@ -72,13 +77,13 @@
listview_set_ext_style (lv);
rc = kserver_search_init (ksc->name, ksc->port, ksc->pattern, &conn_fd);
if (rc) {
- msg_box (dlg, winpt_strerror (rc), _("Keyserver - search init"), MB_ERR);
+ msg_box (dlg, winpt_strerror (rc), _("Keyserver Search"), MB_ERR);
EndDialog (dlg, FALSE);
return FALSE;
}
rc = kserver_search_chkresp (conn_fd);
if (rc) {
- msg_box (dlg, winpt_strerror (rc), _("Keyserver - check response"), MB_ERR);
+ msg_box (dlg, winpt_strerror (rc), _("Keyserver Search"), MB_ERR);
closesocket (conn_fd);
EndDialog (dlg, FALSE);
return FALSE;
@@ -124,15 +129,19 @@
case IDC_HKPSEARCH_RECV:
if ((i = listview_get_curr_pos (lv)) == -1) {
- msg_box (dlg, _("Please select a key."), _("Keyserver"), MB_ERR);
+ msg_box (dlg, _("Please select a key."), _("Keyserver Search"), MB_ERR);
return FALSE;
}
listview_get_item_text (lv, i, 1, t, sizeof (t) -1);
- hkp_recv_key (dlg, ksc->name, ksc->port, t, 0, 0);
+ rc = hkp_recv_key2 (dlg, ksc->name, ksc->port, t, 0, &fpr);
+ if (!rc && fpr != NULL) {
+ keycache_update (0, fpr);
+ free_if_alloc (fpr);
+ }
return TRUE;
}
break;
}
return FALSE;
-} /* hkpsearch_dlg_proc */
+}
Modified: trunk/Src/wptPreferencesDlg.cpp
===================================================================
--- trunk/Src/wptPreferencesDlg.cpp 2006-01-13 14:20:51 UTC (rev 146)
+++ trunk/Src/wptPreferencesDlg.cpp 2006-01-13 14:21:16 UTC (rev 147)
@@ -146,6 +146,8 @@
SetDlgItemText (dlg, IDC_PREFS_ALLOPTINF, _("General options"));
SetDlgItemText (dlg, IDC_PREFS_CLIPINF, _("Clipboard hotkeys"));
SetDlgItemText (dlg, IDC_PREFS_CURRINF, _("Current window hotkeys"));
+ SetDlgItemText (dlg, IDC_PREFS_KSELFILE, _("Browse..."));
+ SetDlgItemText (dlg, IDC_PREFS_BAKSELECT, _("Browse..."));
SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
SetDlgItemInt (dlg, IDC_PREFS_CACHETIME, reg_prefs.cache_time, TRUE);
More information about the Winpt-commits
mailing list