[Winpt-commits] r262 - trunk/Src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sat Sep 30 12:24:35 CEST 2006
Author: twoaday
Date: 2006-09-30 12:24:34 +0200 (Sat, 30 Sep 2006)
New Revision: 262
Modified:
trunk/Src/ChangeLog
trunk/Src/WinPT.cpp
trunk/Src/wptCardPCSC.c
trunk/Src/wptCommonDlg.cpp
trunk/Src/wptFileManager.cpp
trunk/Src/wptFileManagerDlg.cpp
trunk/Src/wptGPGME.cpp
trunk/Src/wptGPGMEWrapper.cpp
trunk/Src/wptHTTP.cpp
trunk/Src/wptKeyManager.cpp
trunk/Src/wptKeyManagerDlg.cpp
trunk/Src/wptKeyserverDlg.cpp
trunk/Src/wptKeyserverSearchDlg.cpp
trunk/Src/wptMainProc.cpp
trunk/Src/wptRegistry.cpp
trunk/Src/wptVerifyList.cpp
Log:
Modified: trunk/Src/ChangeLog
===================================================================
--- trunk/Src/ChangeLog 2006-09-30 10:24:23 UTC (rev 261)
+++ trunk/Src/ChangeLog 2006-09-30 10:24:34 UTC (rev 262)
@@ -1,3 +1,25 @@
+2006-08-30 Timo Schulz <twoaday at freakmail.de>
+
+ * wptRegistry.cpp (get_reg_entry): Do not use static buffers.
+ * wptKeyserverDlg.cpp (add_pattern_to_combox): New.
+ (save_pattern_from_combox): New.
+ * wptKeyManagerDlg.cpp (keymanager_dlg_proc): Solve icon problem.
+ * wptGPGMEWrapper.c (importFromBuffer): New.
+ * WinPT.cpp (check_crypto_engine): Only enable PC/SC when the
+ system really has smart card services enabled.
+ * wptKeyManger.cpp (km_http_import): Stricter error checking.
+ * wptFileManager.cpp (fm_send_file): Use at least MAX_PATH
+ for the file name.
+
+2006-08-24 Timo Schulz <twoaday at freakmail.de>
+
+ * wptHTTP.cpp (extraHostInfo): Handle case when no doc were given.
+ (get): Better error handling.
+ (head): Likewise.
+ * wptGPGME.cpp (sigsum_to_index): Just map the index without
+ any checks.
+ * wptCommonDlg.cpp (check_URL): Be more strict.
+
2006-08-11 Timo Schulz <ts at g10code.de>
* wptGPGMEWrapper.cpp (importFromFile): New.
Modified: trunk/Src/WinPT.cpp
===================================================================
--- trunk/Src/WinPT.cpp 2006-09-30 10:24:23 UTC (rev 261)
+++ trunk/Src/WinPT.cpp 2006-09-30 10:24:34 UTC (rev 262)
@@ -44,6 +44,7 @@
void remove_crit_file_attrs (const char *fname, int force);
BOOL user_is_admin (void);
+extern "C" int pcsc_available (void);
/* Global variables. */
HINSTANCE glob_hinst; /* global instance for the dialogs */
@@ -286,7 +287,7 @@
return false;
}
/* We enable smartcard support for GPG: >= 2 or >= 1.4.3 */
- if (ma > 1 || pa >= 3)
+ if ((ma > 1 || pa >= 4) && pcsc_available ())
scard_support = 1;
gpgver[0] = ma;
Modified: trunk/Src/wptCardPCSC.c
===================================================================
--- trunk/Src/wptCardPCSC.c 2006-09-30 10:24:23 UTC (rev 261)
+++ trunk/Src/wptCardPCSC.c 2006-09-30 10:24:34 UTC (rev 262)
@@ -1,6 +1,5 @@
/* wptCardPCSC.cpp - PC/SC card API interface
- * Copyright (C) 2003 Timo Schulz
- * Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ * Copyright (C) 2003, 2006 Timo Schulz
*
* This file is part of WinPT.
*
@@ -22,11 +21,15 @@
#include <config.h>
#endif
-#if 0 /* not needed right now. */
#include <stdio.h>
#include <windows.h>
#ifndef __MINGW32__
#include <winscard.h>
+#else
+/* mingw32 has no win32 smartcard API definitions. */
+typedef ULONG_PTR SCARDCONTEXT;
+#define SCARD_SCOPE_SYSTEM 2
+#define SCARD_S_SUCCESS NO_ERROR
#endif
#include "gpgme.h"
@@ -34,131 +37,11 @@
#include "wptCard.h"
-/* Definitions usually found in winscard.h but not used here becuase
- 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];
-};
-
-typedef struct pcsc_readerstate_s *pcsc_readerstate_t;
-
-/* PC/SC constants and function pointer. */
-#define PCSC_SCOPE_USER 0
-#define PCSC_SCOPE_TERMINAL 1
-#define PCSC_SCOPE_SYSTEM 2
-#define PCSC_SCOPE_GLOBAL 3
-
-#define PCSC_PROTOCOL_T0 1
-#define PCSC_PROTOCOL_T1 2
-#define PCSC_PROTOCOL_RAW 4
-
-#define PCSC_SHARE_EXCLUSIVE 1
-#define PCSC_SHARE_SHARED 2
-#define PCSC_SHARE_DIRECT 3
-
-#define PCSC_LEAVE_CARD 0
-#define PCSC_RESET_CARD 1
-#define PCSC_UNPOWER_CARD 2
-#define PCSC_EJECT_CARD 3
-
-#define PCSC_UNKNOWN 0x0001
-#define PCSC_ABSENT 0x0002 /* Card is absent. */
-#define PCSC_PRESENT 0x0004 /* Card is present. */
-#define PCSC_SWALLOWED 0x0008 /* Card is present and electrical connected. */
-#define PCSC_POWERED 0x0010 /* Card is powered. */
-#define PCSC_NEGOTIABLE 0x0020 /* Card is awaiting PTS. */
-#define PCSC_SPECIFIC 0x0040 /* Card is ready for use. */
-
-#define PCSC_STATE_UNAWARE 0x0000 /* Want status. */
-#define PCSC_STATE_IGNORE 0x0001 /* Ignore this reader. */
-#define PCSC_STATE_CHANGED 0x0002 /* State has changed. */
-#define PCSC_STATE_UNKNOWN 0x0004 /* Reader unknown. */
-#define PCSC_STATE_UNAVAILABLE 0x0008 /* Status unavailable. */
-#define PCSC_STATE_EMPTY 0x0010 /* Card removed. */
-#define PCSC_STATE_PRESENT 0x0020 /* Card inserted. */
-#define PCSC_STATE_ATRMATCH 0x0040 /* ATR matches card. */
-#define PCSC_STATE_EXCLUSIVE 0x0080 /* Exclusive Mode. */
-#define PCSC_STATE_INUSE 0x0100 /* Shared mode. */
-#define PCSC_STATE_MUTE 0x0200 /* Unresponsive card. */
-
-/* Some PC/SC error codes. */
-#define PCSC_E_CANCELLED 0x80100002
-#define PCSC_E_CANT_DISPOSE 0x8010000E
-#define PCSC_E_INSUFFICIENT_BUFFER 0x80100008
-#define PCSC_E_INVALID_ATR 0x80100015
-#define PCSC_E_INVALID_HANDLE 0x80100003
-#define PCSC_E_INVALID_PARAMETER 0x80100004
-#define PCSC_E_INVALID_TARGET 0x80100005
-#define PCSC_E_INVALID_VALUE 0x80100011
-#define PCSC_E_NO_MEMORY 0x80100006
-#define PCSC_E_UNKNOWN_READER 0x80100009
-#define PCSC_E_TIMEOUT 0x8010000A
-#define PCSC_E_SHARING_VIOLATION 0x8010000B
-#define PCSC_E_NO_SMARTCARD 0x8010000C
-#define PCSC_E_UNKNOWN_CARD 0x8010000D
-#define PCSC_E_PROTO_MISMATCH 0x8010000F
-#define PCSC_E_NOT_READY 0x80100010
-#define PCSC_E_SYSTEM_CANCELLED 0x80100012
-#define PCSC_E_NOT_TRANSACTED 0x80100016
-#define PCSC_E_READER_UNAVAILABLE 0x80100017
-#define PCSC_W_REMOVED_CARD 0x80100069
-
-
-/* Possible card states. */
-enum card_state_t {
- CARD_STATE_NONE=0,
- CARD_STATE_UNAWARE,
- CARD_STATE_UNAVAIL,
- CARD_STATE_PRESENT,
- CARD_STATE_EXCLUSI,
- CARD_STATE_EMPTY,
- CARD_STATE_INUSE,
- CARD_STATE_MUTE
-};
-
-#define MAX_READERS 8
-
-struct pcsc_reader_s {
- struct pcsc_readerstate_s reader_states[MAX_READERS];
- int nreaders;
- char * readers[MAX_READERS];
-};
-typedef struct pcsc_reader_s *pcsc_reader_t;
-
-
static LONG (WINAPI *pcsc_establish_context) (unsigned long scope,
const void *reserved1,
const void *reserved2,
unsigned long *r_context);
static LONG (WINAPI *pcsc_release_context) (unsigned long context);
-static LONG (WINAPI *pcsc_list_readers) (unsigned long context,
- const char *groups,
- char *readers,
- unsigned long *readerslen);
-static LONG (WINAPI *pcsc_connect) (unsigned long context,
- const char *reader,
- unsigned long share_mode,
- unsigned long preferred_protocols,
- unsigned long *r_card,
- unsigned long *r_active_protocol);
-static LONG (WINAPI *pcsc_disconnect) (unsigned long card,
- unsigned long disposition);
-static LONG (WINAPI *pcsc_status) (unsigned long card,
- char *reader, unsigned long *readerlen,
- unsigned long *r_state, unsigned long *r_protocol,
- unsigned char *atr, unsigned long *atrlen);
-static LONG (WINAPI *pcsc_get_status_change)(unsigned long ctx,
- unsigned long timeout,
- pcsc_readerstate_t readerstate,
- unsigned long creaders);
static int pcsc_init = 0;
@@ -174,164 +57,48 @@
} while (0)
-int
-pcsc_loadlib (int scard_support)
+static int
+pcsc_loadlib (void)
{
HMODULE hlib;
FARPROC a;
- if (!scard_support || pcsc_init)
+ if (pcsc_init)
return 0;
hlib = LoadLibrary ("WINSCARD");
if (!hlib)
goto fail;
load_one_fnc (pcsc_establish_context, hlib, "SCardEstablishContext");
load_one_fnc (pcsc_release_context, hlib, "SCardReleaseContext");
- load_one_fnc (pcsc_list_readers, hlib, "SCardListReadersA");
- load_one_fnc (pcsc_connect, hlib, "SCardConnectA");
- load_one_fnc (pcsc_disconnect, hlib, "SCardDisconnect");
- load_one_fnc (pcsc_status, hlib, "SCardStatusA");
- load_one_fnc (pcsc_get_status_change, hlib, "SCardGetStatusChangeA");
goto success;
fail:
- FreeLibrary (hlib);
+ if (hlib != NULL)
+ FreeLibrary (hlib);
return -1;
+
success:
pcsc_init = 1;
- FreeLibrary (hlib);
return 0;
}
-void
-pcsc_free_readers (pcsc_reader_t rd)
-{
- int i;
-
- if (!rd)
- return;
-
- for (i=0; i < rd->nreaders; i++)
- safe_free (rd->readers[i]);
- safe_free (rd);
-}
-
-
-const char *
-pcsc_get_reader (pcsc_reader_t rd, int idx, int * ret_nrd)
-{
- if (!rd)
- return NULL;
- if (idx == -1 && ret_nrd) {
- *ret_nrd = rd->nreaders;
- return NULL;
- }
- if (idx >= rd->nreaders)
- idx=0;
- return rd->readers[idx];
-}
-
-
+/* Return != 0 if the PC/SC smart card interface is available.
+ The purpose of the function is to disable smart card releation
+ commands on systems with no scard readers. */
int
-pcsc_scan_readers (pcsc_reader_t * ret_rd)
+pcsc_available (void)
{
- pcsc_reader_t rd;
- pcsc_context_t hctx;
- struct pcsc_readerstate_s rdstat;
- DWORD readers;
- LPSTR rdrstr;
- char * p;
- int i;
- int rc, curr_rd=0;
+ SCARDCONTEXT ctx;
+ LONG err;
- *ret_rd = NULL;
- if (!pcsc_init)
- return -1;
-
- rc = pcsc_establish_context (PCSC_SCOPE_SYSTEM, NULL, NULL, &hctx);
- if (rc)
- return -1;
-
- rc = pcsc_list_readers (hctx, NULL, NULL, &readers);
- if (rc)
- return -1;
-
- rdrstr = malloc (sizeof(char)*readers);
- if (!rdrstr)
- BUG (0);
-
- rc = pcsc_list_readers (hctx, NULL, rdrstr, &readers);
- if (rc) {
- safe_free (rdrstr);
- return -1;
- }
-
- rd = calloc (1, sizeof *rd);
- if (!rd)
- BUG (0);
-
- p = rdrstr;
- while ((*p != '\0') && (rd->nreaders < MAX_READERS)) {
- rd->readers[rd->nreaders] = strdup (p);
- p += strlen (p)+1;
- rd->nreaders++;
- }
-
- if (!rd->nreaders) {
- safe_free (rdrstr);
- safe_free (rd);
+ if (pcsc_loadlib ())
return 0;
- }
- /* set the initial states */
- for (i=0; i<rd->nreaders; i++) {
- rd->reader_states[i].reader = rd->readers[i];
- rd->reader_states[i].current_state = PCSC_STATE_EMPTY;
- }
-
- while (1) {
- rdstat = rd->reader_states[curr_rd];
- rc = pcsc_get_status_change (hctx, 0, &rdstat, 1);
- if (rc == PCSC_E_TIMEOUT)
- continue;
- if (rc)
- ; /* FIXME: What is this?? */
-
- /* next reader */
- curr_rd++;
- if (curr_rd >= rd->nreaders)
- curr_rd = 0;
- }
-
- safe_free (rdrstr);
- *ret_rd = rd;
- rc = pcsc_release_context (hctx);
- if (rc)
+ err = pcsc_establish_context (SCARD_SCOPE_SYSTEM, NULL, NULL, &ctx);
+ if (err == SCARD_S_SUCCESS) {
+ pcsc_release_context (ctx);
return -1;
+ }
return 0;
}
-
-
-int
-pcsc_get_card_status (void)
-{
- pcsc_reader_t rd;
- struct pcsc_readerstate_s rdstat;
- int rc, stat=0;
-
- rc = pcsc_scan_readers (&rd);
- if (rc)
- return -1;
- rdstat = rd->reader_states[0];
- if (rdstat.current_state & PCSC_STATE_UNAVAILABLE)
- stat |= CARD_STATE_UNAVAIL;
- if (rdstat.current_state & PCSC_STATE_EMPTY)
- stat |= CARD_STATE_EMPTY;
- if (rdstat.current_state & PCSC_STATE_INUSE)
- stat |= CARD_STATE_INUSE;
- if (rdstat.current_state & PCSC_STATE_EXCLUSIVE)
- stat |= CARD_STATE_EXCLUSI;
- return stat;
-}
-#endif
Modified: trunk/Src/wptCommonDlg.cpp
===================================================================
--- trunk/Src/wptCommonDlg.cpp 2006-09-30 10:24:23 UTC (rev 261)
+++ trunk/Src/wptCommonDlg.cpp 2006-09-30 10:24:34 UTC (rev 262)
@@ -20,8 +20,9 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+
+#include <windows.h>
#include <ctype.h>
-#include <windows.h>
#include "resource.h"
#include "wptTypes.h"
@@ -33,13 +34,16 @@
#include "wptRegistry.h"
-/* check if the given buf contains a valid URL. */
+/* check if the given buf contains a valid URL.
+ for the moment we hardcode HTTP urls. */
static int
check_URL (const char *buf)
{
size_t i;
const char *allowed = "-./#_:~&?=";
+ if (strncmp (buf, "http", 4))
+ return -1;
if (!strchr (buf, ':'))
return -1;
if (!strstr (buf, "//"))
Modified: trunk/Src/wptFileManager.cpp
===================================================================
--- trunk/Src/wptFileManager.cpp 2006-09-30 10:24:23 UTC (rev 261)
+++ trunk/Src/wptFileManager.cpp 2006-09-30 10:24:34 UTC (rev 262)
@@ -101,7 +101,7 @@
is_floppy_disc (const char *fname)
{
char drv[32] = {0};
- int max = sizeof (drv)-1;
+ int max = DIM (drv)-1;
int i=0;
if (!strstr (fname, ":\\"))
@@ -262,7 +262,7 @@
fp = fopen (fname, "rb");
if (!fp)
return "UNKNOWN";
- p = fgets (header, sizeof (header) - 1, fp);
+ p = fgets (header, DIM (header) - 1, fp);
fclose (fp);
if (!p)
return "UNKNOWN";
@@ -504,7 +504,7 @@
memset (name, 0, sizeof (name));
for (i = 0; i < listview_count_items (lv, 0); i++) {
- listview_get_item_text (lv, i, FM_COL_NAME, name, sizeof (name) - 1);
+ listview_get_item_text (lv, i, FM_COL_NAME, name, DIM (name) - 1);
if (!strcmp (name, file))
return 1; /* found */
}
@@ -578,7 +578,7 @@
memset (name, 0, sizeof (name));
nfiles = DragQueryFile (dd_files, 0xFFFFFFFF, NULL, 0);
for (i = 0; i < nfiles; i++) {
- DragQueryFile (dd_files, i, name, sizeof (name) -1);
+ DragQueryFile (dd_files, i, name, DIM (name) -1);
if (is_directory (name))
rc = fm_add_dir_files (fm->lv, &fm->model, name);
else
@@ -640,7 +640,7 @@
open.lpstrFilter = "All Files (*.*)\0*.*\0\0";
open.hwndOwner = dlg;
open.lpstrFile = file;
- open.nMaxFile = sizeof (file) - 1;
+ open.nMaxFile = DIM (file) - 1;
open.Flags = OFN_ALLOWMULTISELECT|OFN_EXPLORER ;
memset (file, 0, sizeof file);
@@ -650,7 +650,7 @@
/* It is possible that multiple files are returned
and then they are separated by \0 chars. */
s = file;
- len = sizeof (file)-1;
+ len = DIM (file)-1;
for (;;) {
if (len < 2 || (*s == '\0' && *(s+1) == '\0'))
break;
@@ -690,7 +690,7 @@
pkt = (PACKET *)calloc (1, sizeof *pkt);
if (!fname) {
- get_temp_name (tmpfile, sizeof (tmpfile)-1, "gpgme.tmp");
+ get_temp_name (tmpfile, DIM (tmpfile)-1, "gpgme.tmp");
gpg_data_new_from_clipboard (&dat, 0);
gpg_data_release_and_set_file (dat, tmpfile);
@@ -747,7 +747,7 @@
{
char type[128];
- listview_get_item_text (lv, pos, 0, type, sizeof (type)-1);
+ listview_get_item_text (lv, pos, 0, type, DIM (type)-1);
return !strcmp (type, "SIGNED-DETACH")? 1 : 0;
}
@@ -758,7 +758,7 @@
char status[128];
int rc = 0;
- listview_get_item_text (lv, pos, 0, status, sizeof (status) - 1);
+ listview_get_item_text (lv, pos, 0, status, DIM (status) - 1);
switch (fm_cmd) {
case FM_ENCRYPT:
@@ -862,7 +862,7 @@
if (ctx->sigmode != GPGME_SIG_MODE_CLEAR)
return 0;
- listview_get_item_text (lv, -1, FM_COL_NAME, name, sizeof (name)-1);
+ listview_get_item_text (lv, -1, FM_COL_NAME, name, DIM (name)-1);
if (stristr (name, ".TXT"))
return 0;
f = fopen (name, "rb");
@@ -963,7 +963,7 @@
for( i = 0, n = 0; i < listview_count_items( lv, 0 ); i++ ) {
if( !listview_get_item_state( lv, i ) )
continue;
- listview_get_item_text( lv, i, 0, status, sizeof (status) -1 );
+ listview_get_item_text( lv, i, 0, status, DIM (status) -1 );
if (!strcmp( status, "ENCRYPTED" ) && fm_cmd == FM_DECRYPT)
n++;
if (!strcmp( status, "UNKNOWN" ) && fm_cmd == FM_SIGN)
@@ -990,7 +990,7 @@
for (i = 0; i < listview_count_items (lv, 0); i++) {
if (!listview_get_item_state (lv, i))
continue;
- listview_get_item_text (lv, i, 1, fname, sizeof (fname) - 1);
+ listview_get_item_text (lv, i, 1, fname, DIM (fname) - 1);
if( file_exist_check (fname) && !is_directory (fname)) {
log_box (_("File Manager"), MB_ERR,
_("\"%s\" does not exist"), fname);
@@ -1042,7 +1042,7 @@
/* remove wipe files from the list */
n = listview_count_items (lv, 0);
while (n--) {
- listview_get_item_text (lv, n, 0, status, sizeof (status) - 1);
+ listview_get_item_text (lv, n, 0, status, DIM (status) - 1);
if (!strcmp (status, "WIPED"))
listview_del_item (lv, n);
}
@@ -1534,8 +1534,8 @@
char file[256], *fname = NULL;
int del_end = 0;
- listview_get_item_text (lv, pos, FM_COL_STAT, stat, sizeof (stat)-1);
- listview_get_item_text (lv, pos, FM_COL_NAME, file, sizeof (file)-1);
+ listview_get_item_text (lv, pos, FM_COL_STAT, stat, DIM (stat)-1);
+ listview_get_item_text (lv, pos, FM_COL_NAME, file, DIM (file)-1);
if (strcmp (stat, "UNKNOWN"))
return 0;
fname = make_filename (NULL, file, "asc");
@@ -1610,7 +1610,7 @@
title = _("Selected Output File");
if (is_openpgp_ext (name)) {
- _snprintf (fname, sizeof (fname) - 1, "%s", name);
+ _snprintf (fname, DIM (fname) - 1, "%s", name);
fname[strlen (fname) - 4] = '\0';
if (file_exist_check (fname) == 0 && detached)
file = fname;
@@ -1916,7 +1916,7 @@
continue;
if (idx == -1)
idx = i;
- listview_get_item_text (lv, i, 1, name, sizeof (name)-1);
+ listview_get_item_text (lv, i, 1, name, DIM (name)-1);
pk_list_add (&list, name);
}
@@ -1968,6 +1968,7 @@
pk_list_add (&list, p);
free_if_alloc (p);
}
+ /* XXX: support to scan sub directories also. */
while (FindNextFile (hd, &findbuf)) {
if (strcmp (findbuf.cFileName, ".") && strcmp (findbuf.cFileName, "..")) {
p = make_filename (name, findbuf.cFileName, NULL);
@@ -2058,10 +2059,10 @@
int
fm_send_file (listview_ctrl_t lv)
{
- char name[128];
+ char name[MAX_PATH+1];
int rc;
- rc = listview_get_item_text (lv, -1, FM_COL_NAME, name, sizeof (name)-1);
+ rc = listview_get_item_text (lv, -1, FM_COL_NAME, name, DIM (name)-1);
if (rc != -1)
mapi_send_ascfile (name);
return 0;
Modified: trunk/Src/wptFileManagerDlg.cpp
===================================================================
--- trunk/Src/wptFileManagerDlg.cpp 2006-09-30 10:24:23 UTC (rev 261)
+++ trunk/Src/wptFileManagerDlg.cpp 2006-09-30 10:24:34 UTC (rev 262)
@@ -530,6 +530,8 @@
BUG (NULL);
}
}
+ SendMessage (dlg, WM_SETICON, (WPARAM)ICON_SMALL,
+ (LPARAM)LoadIcon (glob_hinst, (LPCTSTR)IDI_WINPT));
SetMenu (dlg, fm->menu);
if (!always_ontop)
set_menu_state (fm->menu, ID_FILEMISC_ONTOP, MFS_UNCHECKED);
Modified: trunk/Src/wptGPGME.cpp
===================================================================
--- trunk/Src/wptGPGME.cpp 2006-09-30 10:24:23 UTC (rev 261)
+++ trunk/Src/wptGPGME.cpp 2006-09-30 10:24:34 UTC (rev 262)
@@ -256,25 +256,24 @@
static int
sigsum_to_index (gpgme_sigsum_t sum)
{
- /* xxx: gpgme should set _valid if the sig is good but the
- key has been expired; check the code */
- if ((sum & GPGME_SIGSUM_VALID) && (sum & GPGME_SIGSUM_SIG_EXPIRED))
+ if (sum & GPGME_SIGSUM_RED)
+ return 2;
+ else if (sum & GPGME_SIGSUM_SIG_EXPIRED)
return 8;
- if ((sum & GPGME_SIGSUM_VALID) && (sum & GPGME_SIGSUM_KEY_REVOKED))
+ else if (sum & GPGME_SIGSUM_KEY_REVOKED)
return 7;
- if ((sum & GPGME_SIGSUM_VALID) && (sum & GPGME_SIGSUM_KEY_EXPIRED))
+ else if (sum & GPGME_SIGSUM_KEY_EXPIRED)
return 6;
- if (sum & GPGME_SIGSUM_GREEN)
+ else if (sum & GPGME_SIGSUM_GREEN)
return 1;
- else if (sum & GPGME_SIGSUM_RED)
- return 2;
else if (sum & GPGME_SIGSUM_KEY_MISSING)
return 3;
return 0;
}
-/* Return a humand readable description for the signature status @sum. */
+/* Return a humand readable description for the signature status @sum.
+ Warning: this function does not consider the validity of the key. */
const char*
get_gpg_sigstat (gpgme_sigsum_t sum)
{
Modified: trunk/Src/wptGPGMEWrapper.cpp
===================================================================
--- trunk/Src/wptGPGMEWrapper.cpp 2006-09-30 10:24:23 UTC (rev 261)
+++ trunk/Src/wptGPGMEWrapper.cpp 2006-09-30 10:24:34 UTC (rev 262)
@@ -67,6 +67,27 @@
}
+/* Import keys from a memory buffer.
+ Return value: 0 on success. */
+gpgme_error_t
+GPGME::importFromBuffer (const char *indata)
+{
+ gpgme_data_t keydata = NULL;
+ gpgme_error_t err;
+
+ err = gpgme_data_new_from_mem (&keydata, indata, strlen (indata), 1);
+ if (err)
+ return err;
+
+ op_begin ();
+ err = gpgme_op_import (ctx, keydata);
+ op_end ();
+
+ gpgme_data_release (keydata);
+ return err;
+}
+
+
/* Import the keys from the clipboard.
Return value: 0 on success. */
gpgme_error_t
Modified: trunk/Src/wptHTTP.cpp
===================================================================
--- trunk/Src/wptHTTP.cpp 2006-09-30 10:24:23 UTC (rev 261)
+++ trunk/Src/wptHTTP.cpp 2006-09-30 10:24:34 UTC (rev 262)
@@ -12,10 +12,6 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with WinPT; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -58,8 +54,11 @@
wHTTP::wHTTP (const char *_url)
{
reset ();
- extractHostInfo (_url, &this->host, &this->url);
- /* XXX: if the connection fails, return the error code to the user. */
+
+ if (extractHostInfo (_url, &this->host, &this->url))
+ return;
+
+ /* FIXME: we should throw an exception in case of an error. */
if (!sendRequest (this->host, this->port, this->url))
parseResponse (&statcode);
}
@@ -84,10 +83,14 @@
int
wHTTP::head (const char *_url)
{
+ int err;
+
safe_free (host);
safe_free (url);
- extractHostInfo (_url, &this->host, &this->url);
+ err = extractHostInfo (_url, &this->host, &this->url);
+ if (err)
+ return err;
method = HTTP_HEAD;
if (!sendRequest (host, port, url))
@@ -101,10 +104,14 @@
int
wHTTP::get (const char *_url)
{
+ int err;
+
safe_free (host);
safe_free (url);
- extractHostInfo (_url, &this->host, &this->url);
+ err = extractHostInfo (_url, &this->host, &this->url);
+ if (err)
+ return err;
method = HTTP_GET;
if (!sendRequest (this->host, this->port, this->url))
@@ -310,9 +317,9 @@
@host and also return the resource part of the url in @new_url. */
int
wHTTP::extractHostInfo (const char *_url, char **_host, char **new_url)
-{
+{
+ char tmpbuf[2*MAX_PATH+1];
char *p;
- char tmpbuf[512];
*_host = NULL;
*new_url = NULL;
@@ -328,13 +335,12 @@
p = strtok (tmpbuf+7, "/");
if (!p)
return WPTERR_GENERAL;
- *_host = strdup (p);
+ *_host = strdup (p);
p = strchr (_url, '/');
- if (!p) {
- safe_free (*_host);
- return WPTERR_GENERAL;
- }
- *new_url = strdup (p);
+ if (!p) /* document were given so we assume the root '/'. */
+ *new_url = strdup ("/");
+ else
+ *new_url = strdup (p);
return 0;
}
@@ -434,7 +440,7 @@
return WPTERR_GENERAL;
do {
- rc = readLine (buf, 299, 1, &nn, NULL);
+ rc = readLine (buf, DIM (buf)-1, 1, &nn, NULL);
if (rc)
return rc;
if (nn == 2)
@@ -483,7 +489,7 @@
}
do {
- rc = readLine (buf, sizeof (buf)-1, 1, &n, &eof);
+ rc = readLine (buf, DIM (buf)-1, 1, &n, &eof);
if (rc)
return rc;
if (n > 0)
Modified: trunk/Src/wptKeyManager.cpp
===================================================================
--- trunk/Src/wptKeyManager.cpp 2006-09-30 10:24:23 UTC (rev 261)
+++ trunk/Src/wptKeyManager.cpp 2006-09-30 10:24:34 UTC (rev 262)
@@ -297,7 +297,7 @@
goto leave;
}
if (n == 1) {
- key_get_clip_info (rset[0]->subkeys->keyid, buf, sizeof (buf)-1);
+ key_get_clip_info (rset[0]->subkeys->keyid, buf, DIM (buf)-1);
set_clip_text2 (NULL, buf, strlen (buf), 0);
}
@@ -490,14 +490,14 @@
FILE *fp;
wHTTP *hd;
char tmpfile[MAX_PATH+64];
- int rc = 0;
+ int rc = 0, err = 0;
if (strncmp (url, "http://", 7)) {
log_box (_("Key Import HTTP"), MB_ERR, _("Invalid HTTP URL: %s"), url);
return WPTERR_GENERAL;
}
- get_temp_name (tmpfile, sizeof (tmpfile)-1, "winpt_http.tmp");
+ get_temp_name (tmpfile, DIM (tmpfile)-1, "winpt_http.tmp");
fp = fopen (tmpfile, "wb");
if (!fp) {
log_box (_("Key Import HTTP"), MB_ERR, "%s: %s", tmpfile,
@@ -505,11 +505,15 @@
return WPTERR_FILE_CREAT;
}
+ op_begin ();
hd = new wHTTP (url);
if (hd->getStatusCode () == HTTP_STAT_200)
- hd->readData (fp);
- else {
- log_box (_("Key Import HTTP"), MB_ERR,
+ err = hd->readData (fp);
+ else
+ err = WPTERR_KEYSERVER_NOTFOUND;
+ op_end ();
+ if (err) {
+ log_box (_("HTTP Key Import"), MB_ERR,
_("Could not fetch key from URL: %s"), url);
rc = WPTERR_GENERAL;
}
@@ -870,7 +874,7 @@
pref_kserv = pk.ext->pref_keyserver;
pref_kserv_port = pk.ext->pref_keyserver_port;
}
- _snprintf (keyid, sizeof (keyid)-1, "%s", key->subkeys->keyid+8);
+ _snprintf (keyid, DIM (keyid)-1, "%s", key->subkeys->keyid+8);
err = hkp_recv_key (dlg, pref_kserv, pref_kserv_port,
keyid, 0, flags);
/* if we receive just a single key (no refresh mode), update it. */
@@ -917,7 +921,7 @@
{
char buf[256];
- key_get_clip_info (uid, buf, sizeof (buf)-1);
+ key_get_clip_info (uid, buf, DIM (buf)-1);
set_clip_text (NULL, buf, strlen (buf));
}
Modified: trunk/Src/wptKeyManagerDlg.cpp
===================================================================
--- trunk/Src/wptKeyManagerDlg.cpp 2006-09-30 10:24:23 UTC (rev 261)
+++ trunk/Src/wptKeyManagerDlg.cpp 2006-09-30 10:24:34 UTC (rev 262)
@@ -1104,6 +1104,7 @@
keylist_sort (kmi->lv, kmi->keylist_sortby);
update_status_bar (kmi->statbar, kmi->lv);
keyring_check_last_access ();
+ SetForegroundWindow (kmi->dlg);
}
@@ -1145,34 +1146,18 @@
}
-static void
-reload_keylist (struct km_info_s *kmi)
-{
- gpg_keycache_t c;
-
- keycache_reload (kmi->dlg);
- c = keycache_get_ctx (1);
- keylist_reload (kmi->lv, c, KEYLIST_LIST, kmi->keylist_sortby);
- update_status_bar (kmi->statbar, kmi->lv);
- keyring_check_last_access ();
-}
-
-
/* Reload the entire key cache and update the listview. */
static void
reload_keycache (struct km_info_s *kmi)
{
- refresh_cache_s rcs = {0};
gpg_keycache_t c;
- rcs.kr_reload = rcs.kr_update = 1;
- rcs.tr_update = 0;
- DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, kmi->dlg,
- keycache_dlg_proc, (LPARAM)&rcs);
+ keycache_reload (kmi->dlg);
c = keycache_get_ctx (1);
keylist_reload (kmi->lv, c, KEYLIST_LIST, kmi->keylist_sortby);
update_status_bar (kmi->statbar, kmi->lv);
SetForegroundWindow (kmi->dlg);
+ keyring_check_last_access ();
}
@@ -1180,7 +1165,7 @@
static void
km_gui_import (struct km_info_s *kmi, int cmd_id, void *param)
{
- int newkeys=0, newsks=0;
+ int newkeys = 0, newsks = 0;
int err = 0;
switch (cmd_id) {
@@ -1205,8 +1190,7 @@
if (!err && !newsks && (newkeys > 0 && newkeys < KM_PRELOAD_KEYS))
refresh_keylist (kmi);
else if (!err) /* avoid to spawn too much processes. */
- reload_keylist (kmi);
-
+ reload_keycache (kmi);
SetForegroundWindow (kmi->dlg);
}
@@ -1358,14 +1342,15 @@
restore_column_info (kmi);
keylist_sort (kmi->lv, kmi->keylist_sortby);
+ SendMessage (dlg, WM_SETICON, (WPARAM)ICON_SMALL,
+ (LPARAM)LoadIcon (glob_hinst, (LPCTSTR)IDI_WINPT));
SetDlgItemText (dlg, IDC_KEYMISC_GTEXT, _("Groups"));
SetDlgItemText (dlg, ID_GROUP_SHOW, _("&Show"));
SetDlgItemText (dlg, ID_GROUP_NEW, _("&New..."));
- SetClassLong (dlg, GCL_HICON, (LONG)LoadIcon (glob_hinst,
- (LPCTSTR)IDI_WINPT));
SetForegroundWindow (dlg);
kmi->magic = SetTimer (dlg, 1, 1000, NULL);
return TRUE;
+
case WM_TIMER:
KillTimer (dlg, kmi->magic);
Modified: trunk/Src/wptKeyserverDlg.cpp
===================================================================
--- trunk/Src/wptKeyserverDlg.cpp 2006-09-30 10:24:23 UTC (rev 261)
+++ trunk/Src/wptKeyserverDlg.cpp 2006-09-30 10:24:34 UTC (rev 262)
@@ -40,6 +40,7 @@
#include "wptKeyManager.h"
#include "wptDlgs.h"
#include "wptUTF8.h"
+#include "wptRegistry.h"
char* get_reg_entry_keyserver (const char *);
@@ -172,11 +173,10 @@
keyserver_recv_key (HWND dlg, const char *kserver, WORD port,
const char *pattern, int proto, int flags,
char **r_fpr)
-{
- gpgme_ctx_t ctx = NULL;
- gpgme_data_t keydata = NULL;
+{
gpgme_import_result_t import_res = NULL;
gpgme_error_t err;
+ GPGME *gpg = NULL;
char *rawkey = NULL;
int keylen = 0;
int rc;
@@ -214,23 +214,21 @@
_("Keyserver"), MB_ERR);
goto leave;
}
- if (gpgme_new (&ctx))
- BUG (NULL);
- gpgme_data_new_from_mem (&keydata, rawkey, strlen (rawkey), 1);
- err = gpgme_op_import (ctx, keydata);
+ gpg = new GPGME ();
+ err = gpg->importFromBuffer (rawkey);
if (err) {
msg_box (dlg, gpgme_strerror (err), _("Import"), MB_ERR);
goto leave;
}
- import_res = gpgme_op_import_result (ctx);
+ import_res = gpg->importGetResult ();
if (import_res && r_fpr)
*r_fpr = m_strdup (import_res->imports->fpr);
/* if we use the refresh mode, a lot of keys will be fetched and thus only
a summarize at the end is presented and not for each key. */
- if (!(flags & KM_KS_REFRESH)) {
+ if (import_res && !(flags & KM_KS_REFRESH)) {
show_imported_keys (import_res);
- if (import_res && import_res->unchanged == import_res->considered) {
+ if (import_res->unchanged == import_res->considered) {
rc = WPTERR_GENERAL; /* no keys updated. */
goto leave;
}
@@ -238,10 +236,8 @@
leave:
free_if_alloc (rawkey);
- if (ctx != NULL)
- gpgme_release (ctx);
- if (keydata != NULL)
- gpgme_data_release (keydata);
+ if (gpg != NULL)
+ delete gpg;
return rc;
}
@@ -563,6 +559,57 @@
return FALSE;
}
+
+/* Add search pattern @patt to the combo box if it is
+ not already available in the list. */
+static void
+add_pattern_to_combox (HWND dlg, int ctlid, const char *patt)
+{
+ int err;
+
+ err = SendDlgItemMessage (dlg, ctlid, CB_FINDSTRINGEXACT,
+ 0, (LPARAM)(LPCSTR)patt);
+ if (err != CB_ERR)
+ return;
+ SendDlgItemMessage (dlg, IDC_KEYSERVER_SEARCH, CB_ADDSTRING,
+ 0, (LPARAM)(LPCSTR)patt);
+}
+
+static void
+load_pattern_to_combox (HWND dlg, int ctlid, const char *rkey_name)
+{
+}
+
+static void
+save_pattern_from_combox (HWND dlg, int ctlid, const char *rkey_name)
+{
+ char *p, tmp[64];
+ int i;
+ int n, len=0;
+
+ n = SendDlgItemMessage (dlg, ctlid, CB_GETCOUNT, 0, 0);
+ if (n == 0 || n == CB_ERR)
+ return;
+ /* it is very unlikely that the combox contain hundred of pattern
+ but even so we limit the value to 16 which should be sufficient. */
+ if (n > 16) n = 16;
+ for (i=0; i < n; i++)
+ len += SendDlgItemMessage (dlg, ctlid, CB_GETLBTEXTLEN,
+ (WPARAM)i, 0) + 1 + 1;
+ p = new char[len+1];
+ memset (p, 0, len+1);
+ for (i=0; i < n; i++) {
+ memset (tmp, 0, sizeof (tmp));
+ SendDlgItemMessage (dlg, ctlid, CB_GETLBTEXT,
+ (WPARAM)i, (LPARAM)tmp);
+ strcat (p, tmp);
+ strcat (p, "$");
+ }
+ set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", rkey_name, p);
+ free_if_alloc (p);
+}
+
+
/* Dialog box procedure to access keyservers. */
BOOL CALLBACK
keyserver_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
@@ -633,6 +680,7 @@
lv = NULL;
}
lv_idx = 0;
+ save_pattern_from_combox (dlg, IDC_KEYSERVER_SEARCH, "KSsearch");
return FALSE;
case WM_SYSCOMMAND:
@@ -655,7 +703,7 @@
if (!GetDlgItemText (dlg, IDC_KEYSERVER_SEARCH, pattern, sizeof (pattern)-1)) {
msg_box (dlg, _("Please enter the search pattern."),
_("Keyserver"), MB_INFO);
- return FALSE;
+ return TRUE;
}
if (lv_idx != -1) {
@@ -673,14 +721,14 @@
hkpsearch_dlg_proc, (LPARAM) &ksc);
return TRUE;
- case IDC_KEYSERVER_RECV:
+ case IDC_KEYSERVER_RECV:
memset (&kserver, 0, sizeof (kserver));
if (!lv_idx) {
lv_idx = kserver_get_pos (lv);
if (lv_idx == -1) {
msg_box (dlg, _("Please select one of the keyservers."),
_("Keyserver"), MB_INFO);
- return FALSE;
+ return TRUE;
}
}
listview_get_item_text (lv, lv_idx, KS_COL_NAME,
@@ -698,6 +746,7 @@
_("Keyserver"), MB_INFO);
return FALSE;
}
+ add_pattern_to_combox (dlg, IDC_KEYSERVER_SEARCH, pattern);
if (proto_nr == KSPROTO_LDAP && strchr (pattern, '@')) {
msg_box (dlg, _("Only keyids are allowed."),
_("Keyserver"), MB_INFO);
@@ -707,13 +756,13 @@
if (strchr (pattern, '@') || strchr (pattern, ' ')) {
msg_box (dlg, _("Only enter the name of the user."),
_("Keyserver"), MB_INFO);
- return FALSE;
+ return TRUE;
}
}
else if (check_pattern (pattern)) {
msg_box (dlg, _("Only email addresses or keyids are allowed."),
_("Keyserver"), MB_INFO);
- return FALSE;
+ return TRUE;
}
rc = keyserver_recv_key (dlg, kserver, kserver_get_port (lv),
pattern, proto_nr, 0,
Modified: trunk/Src/wptKeyserverSearchDlg.cpp
===================================================================
--- trunk/Src/wptKeyserverSearchDlg.cpp 2006-09-30 10:24:23 UTC (rev 261)
+++ trunk/Src/wptKeyserverSearchDlg.cpp 2006-09-30 10:24:34 UTC (rev 262)
@@ -30,12 +30,12 @@
#include "wptErrors.h"
#include "wptTypes.h"
#include "wptGPG.h"
-#include "wptContext.h" /* for passphrase_s */
#include "wptDlgs.h"
#include "wptNLS.h"
#include "wptKeylist.h"
+/* Default threshold for key items. */
#define MAX_N_KEYS 64
@@ -58,15 +58,16 @@
{4, 256, (char *)_("User ID")},
{0, 0, NULL}
};
- char info[384];
- int i;
listview_ctrl_t lv = NULL;
-
+ char info[300];
+ int i;
+
SetDlgItemText (dlg, IDC_HKPSEARCH_RECV, _("&Receive"));
SetDlgItemText (dlg, IDOK, _("&Cancel"));
- _snprintf (info, sizeof (info) - 1,
- _("Connect to '%s' to search for \"%s\""),
- ((keyserver_ctx *)lparam)->name, ((keyserver_ctx *)lparam)->pattern);
+ _snprintf (info, DIM (info) - 1,
+ _("Connect to '%s' to search for \"%s\""),
+ ((keyserver_ctx *)lparam)->name,
+ ((keyserver_ctx *)lparam)->pattern);
SetDlgItemText (dlg, IDC_HKPSEARCH_INFO, info);
SetWindowText (dlg, _("Keyserver Searching"));
SetForegroundWindow (dlg);
@@ -112,10 +113,10 @@
if (!key)
continue;
- _snprintf (bits, sizeof (bits) - 1, "%d", key->bits);
- _snprintf (algo, sizeof (algo)-1, "%s",
+ _snprintf (bits, DIM (bits) - 1, "%d", key->bits);
+ _snprintf (algo, DIM (algo)-1, "%s",
get_key_pubalgo ((gpgme_pubkey_algo_t)key->algo));
- _snprintf (keyid, sizeof (keyid)-1, "0x%s", key->keyid);
+ _snprintf (keyid, DIM (keyid)-1, "0x%s", key->keyid);
uid = key->main_uid? key->main_uid->uid : "";
listview_add_item (lv, " ");
listview_add_sub_item (lv, 0, KSS_COL_BITS, bits);
@@ -149,7 +150,7 @@
if (!listview_get_item_state (lv, n))
continue;
- listview_get_item_text (lv, n, KSS_COL_KEYID, keyid, sizeof (keyid)-1);
+ listview_get_item_text (lv, n, KSS_COL_KEYID, keyid, DIM (keyid)-1);
rc = hkp_recv_key2 (dlg, ksc->name, ksc->port, keyid, 0, &fpr);
if (!rc && fpr != NULL) {
keycache_update (0, fpr);
@@ -174,7 +175,7 @@
lv = on_init_dialog (dlg, msg, wparam, lparam);
if (search_hkp_keys (dlg, ksc, lv)) {
EndDialog (dlg, FALSE);
- return FALSE;
+ return TRUE;
}
return TRUE;
@@ -185,11 +186,6 @@
}
return FALSE;
- case WM_SYSCOMMAND:
- if (LOWORD (wparam) == SC_CLOSE)
- EndDialog (dlg, TRUE);
- return FALSE;
-
case WM_COMMAND:
switch (LOWORD (wparam)) {
case IDOK:
Modified: trunk/Src/wptMainProc.cpp
===================================================================
--- trunk/Src/wptMainProc.cpp 2006-09-30 10:24:23 UTC (rev 261)
+++ trunk/Src/wptMainProc.cpp 2006-09-30 10:24:34 UTC (rev 262)
@@ -22,6 +22,8 @@
#include <config.h>
#endif
+#define _WIN32_IE 0x0600
+
#include <windows.h>
#include <commctrl.h>
#include <io.h>
Modified: trunk/Src/wptRegistry.cpp
===================================================================
--- trunk/Src/wptRegistry.cpp 2006-09-30 10:24:23 UTC (rev 261)
+++ trunk/Src/wptRegistry.cpp 2006-09-30 10:24:34 UTC (rev 262)
@@ -309,36 +309,35 @@
and the key given in @key.
Return value is the value or NULL otherwise. */
char*
-get_reg_entry (HKEY root_key, const char * dir, const char * key)
+get_reg_entry (HKEY root_key, const char *dir, const char *key)
{
- int rc;
- char text[384] = {0};
- DWORD nbytes, type;
HKEY reg_key = NULL;
- char * p = NULL;
-
+ char *p = NULL, *pp;
+ DWORD type = REG_SZ, nbytes = 0;
+ int rc;
+
rc = RegOpenKeyEx (root_key, dir, 0, KEY_QUERY_VALUE, ®_key);
- if( !rc_ok( rc ) )
+ if (!rc_ok (rc))
goto leave;
- nbytes = sizeof (text) - 1;
- type = REG_SZ;
-
- rc = RegQueryValueEx (reg_key, key, 0, &type, (BYTE *)&text, &nbytes);
- if (!rc_ok (rc) || !nbytes)
+ rc = RegQueryValueEx (reg_key, key, NULL, &type, NULL, &nbytes);
+ if (!rc_ok (rc))
goto leave;
-
- if (type == REG_EXPAND_SZ && strchr (text, '%'))
- p = expand_path (text);
- else {
- p = new char[nbytes + 1];
- if (!p)
- BUG (0);
- memcpy (p, text, nbytes);
- p[nbytes] = '\0';
+ if (!nbytes)
+ goto leave; /* empty */
+ p = new char[nbytes+1];
+ if (!p)
+ BUG (0);
+ rc = RegQueryValueEx (reg_key, key, NULL, &type, (BYTE*)p, &nbytes);
+ if (!rc_ok (rc))
+ goto leave;
+ if (type == REG_EXPAND_SZ && strchr (p, '%')) {
+ pp = p;
+ p = expand_path (pp);
+ free_if_alloc (pp);
}
-
+
leave:
- if (reg_key)
+ if (reg_key != NULL)
RegCloseKey (reg_key);
return p;
}
@@ -370,26 +369,26 @@
set_reg_key( HKEY root_key, const char * dir, const char * key,
const char * value )
{
- int rc = 0;
+ int rc;
HKEY reg_key;
- rc = RegOpenKeyEx( root_key, dir, 0, KEY_WRITE, ®_key );
- if( !rc_ok( rc ) )
+ rc = RegOpenKeyEx (root_key, dir, 0, KEY_WRITE, ®_key);
+ if (!rc_ok (rc))
return WPTERR_REGISTRY;
- rc = RegSetValueEx( reg_key, key, 0, REG_SZ, (BYTE *)value, strlen( value ) );
- if( !rc_ok( rc ) ) {
- if ( RegCreateKey( root_key, key, ®_key ) != ERROR_SUCCESS ) {
- rc = WPTERR_REGISTRY;
+ rc = RegSetValueEx (reg_key, key, 0, REG_SZ, (BYTE *)value, strlen (value));
+ if (!rc_ok (rc)) {
+ if (RegCreateKey (root_key, key, ®_key) != ERROR_SUCCESS) {
+ rc = WPTERR_REGISTRY;
goto leave;
}
- rc = RegSetValueEx( reg_key, key, 0, REG_SZ, (BYTE *)value, strlen( value ) );
- if ( !rc_ok( rc ) )
+ rc = RegSetValueEx (reg_key, key, 0, REG_SZ, (BYTE *)value, strlen (value));
+ if (!rc_ok (rc))
rc = WPTERR_REGISTRY;
}
leave:
- RegCloseKey( reg_key );
+ RegCloseKey (reg_key);
return rc;
}
@@ -712,9 +711,9 @@
int
-set_reg_entry_keyserver (const char * name, const char * val)
+set_reg_entry_keyserver (const char *name, const char *val)
{
- return set_reg_entry( HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", name, val );
+ return set_reg_entry (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", name, val);
}
static int
Modified: trunk/Src/wptVerifyList.cpp
===================================================================
--- trunk/Src/wptVerifyList.cpp 2006-09-30 10:24:23 UTC (rev 261)
+++ trunk/Src/wptVerifyList.cpp 2006-09-30 10:24:34 UTC (rev 262)
@@ -130,18 +130,18 @@
ShowWindow (vlv->infctl, SW_HIDE);
return;
}
-
- if (sig->exp_timestamp > (DWORD)time (NULL))
+ /* XXX: if the summary does not contain GPGME_SIGSUM_GREEN, issue a warning. */
+ if (sig->validity != GPGME_VALIDITY_MARGINAL &&
+ sig->validity != GPGME_VALIDITY_FULL &&
+ sig->validity != GPGME_VALIDITY_ULTIMATE &&
+ !(sig->summary & GPGME_SIGSUM_KEY_MISSING)) {
SendMessage (vlv->infctl, WM_SETTEXT, 0, (LPARAM)(char*)
- _("The signature is expired!"));
- else if (sig->validity != GPGME_VALIDITY_MARGINAL &&
- sig->validity != GPGME_VALIDITY_FULL &&
- sig->validity != GPGME_VALIDITY_ULTIMATE &&
- !(sig->summary & GPGME_SIGSUM_KEY_MISSING)) {
- SendMessage (vlv->infctl, WM_SETTEXT, 0, (LPARAM)(char*)
_("WARNING: This key is not certified with a trusted signature!\r\n"
" There is no indication that the signature belongs to the owner.\r\n"));
}
+ else if (sig->exp_timestamp > (DWORD)time (NULL))
+ SendMessage (vlv->infctl, WM_SETTEXT, 0, (LPARAM)(char*)
+ _("The signature is expired!"));
else {
char *pka_info = get_pka_status (sig);
if (pka_info != NULL) {
More information about the Winpt-commits
mailing list