[Winpt-commits] r123 - in trunk: . Po Src
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Wed Dec 14 10:01:48 CET 2005
Author: twoaday
Date: 2005-12-14 10:01:45 +0100 (Wed, 14 Dec 2005)
New Revision: 123
Modified:
trunk/NEWS
trunk/Po/de.po
trunk/Src/ChangeLog
trunk/Src/resource.h
trunk/Src/wptCommonDlg.cpp
trunk/Src/wptKeyCache.cpp
trunk/Src/wptKeyEditDlgs.cpp
trunk/Src/wptKeyManager.cpp
trunk/Src/wptKeyManagerDlg.cpp
trunk/THANKS
Log:
2005-12-13 Timo Schulz <ts at g10code.com>
* wptCommonDlg.cpp (http_dlg_proc): Localized missing elements.
* wptKeyManagerDlg.cpp (change_edit_menu): New.
(change_key_menu): Renamed from...
(menu_gpg_readonly): ..this.
(clip_contains_pgpkey): New.
(update_ui_items): Do not allow to sign expired keys.
(keymanager_dlg_proc): Same for popup menu.
* wptKeyPropsDlg.cpp (parse_preflist): Fixed string handling.
* wptKeyCache.cpp (copy_uid_prefs):
(gpg_keycache_sync): Copy uid prefs so the key property
dialog show the correct values. Thanks to Shane.
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2005-12-12 16:21:10 UTC (rev 122)
+++ trunk/NEWS 2005-12-14 09:01:45 UTC (rev 123)
@@ -687,4 +687,5 @@
* Do not register file extensions if GPGee is available.
* Backup to home path will now use the correct directory
($APPDATA) and not the folder where gpg.exe is located.
-
\ No newline at end of file
+* Display the correct preferred cipher in the key property dialog.
+* Fix a lot of minor user handling problems in the Key Manager.
Modified: trunk/Po/de.po
===================================================================
--- trunk/Po/de.po 2005-12-12 16:21:10 UTC (rev 122)
+++ trunk/Po/de.po 2005-12-14 09:01:45 UTC (rev 123)
@@ -1492,7 +1492,7 @@
msgstr "Schlüsselimport"
msgid "Key Import HTTP"
-msgstr "Key Import HTTP"
+msgstr "Schlüssel Import HTTP"
msgid "Key Import Statistics"
msgstr "Schlüsselimport-Statistiken"
@@ -3325,3 +3325,8 @@
"Die PTD.dll Datei hat eine andere Version als WinPT.exe\n"
"Bitte updaten Sie die PTD.dll auf die Version %d.%d.%d"
+msgid "Enter URL to retrieve the public key"
+msgstr "Bitte URL eingeben um öff. Schlüssel zu empfangen"
+
+msgid "HTTP Key Import"
+msgstr "HTTP Schlüssel Import"
Modified: trunk/Src/ChangeLog
===================================================================
--- trunk/Src/ChangeLog 2005-12-12 16:21:10 UTC (rev 122)
+++ trunk/Src/ChangeLog 2005-12-14 09:01:45 UTC (rev 123)
@@ -1,3 +1,17 @@
+2005-12-13 Timo Schulz <ts at g10code.com>
+
+ * wptCommonDlg.cpp (http_dlg_proc): Localized missing elements.
+ * wptKeyManagerDlg.cpp (change_edit_menu): New.
+ (change_key_menu): Renamed from...
+ (menu_gpg_readonly): ..this.
+ (clip_contains_pgpkey): New.
+ (update_ui_items): Do not allow to sign expired keys.
+ (keymanager_dlg_proc): Same for popup menu.
+ * wptKeyPropsDlg.cpp (parse_preflist): Fixed string handling.
+ * wptKeyCache.cpp (copy_uid_prefs):
+ (gpg_keycache_sync): Copy uid prefs so the key property
+ dialog show the correct values. Thanks to Shane.
+
2005-12-11 Timo Schulz <ts at g10code.com>
* wptW32API.cpp (get_file_version): New.
Modified: trunk/Src/resource.h
===================================================================
--- trunk/Src/resource.h 2005-12-12 16:21:10 UTC (rev 122)
+++ trunk/Src/resource.h 2005-12-14 09:01:45 UTC (rev 123)
@@ -771,13 +771,14 @@
#define ID_FILEMISC_MD_SHA256 40173
#define ID_FILECTX_ENCRYPT_ZIP 40174
#define ID_FILEMISC_ENCRYPT_ZIP 40175
+#define ID_KEYMISC_DELETE2 40176
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 230
-#define _APS_NEXT_COMMAND_VALUE 40176
+#define _APS_NEXT_COMMAND_VALUE 40177
#define _APS_NEXT_CONTROL_VALUE 1497
#define _APS_NEXT_SYMED_VALUE 101
#endif
Modified: trunk/Src/wptCommonDlg.cpp
===================================================================
--- trunk/Src/wptCommonDlg.cpp 2005-12-12 16:21:10 UTC (rev 122)
+++ trunk/Src/wptCommonDlg.cpp 2005-12-14 09:01:45 UTC (rev 123)
@@ -17,7 +17,6 @@
* 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
@@ -62,7 +61,10 @@
SetWindowText (dlg, ctx->desc);
if (ctx->title != NULL)
SetDlgItemText (dlg, IDC_HTTP_TITLE, ctx->title);
- SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
+ else
+ SetDlgItemText (dlg, IDC_HTTP_TITLE, _("Enter URL to retrieve the public key"));
+ SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
+ SetWindowText (dlg, _("HTTP Key Import"));
SetForegroundWindow (dlg);
break;
Modified: trunk/Src/wptKeyCache.cpp
===================================================================
--- trunk/Src/wptKeyCache.cpp 2005-12-12 16:21:10 UTC (rev 122)
+++ trunk/Src/wptKeyCache.cpp 2005-12-14 09:01:45 UTC (rev 123)
@@ -120,18 +120,18 @@
if (secring) {
parse_secring (ctx, kid, secring);
if (!pubring) {
- safe_free(pkt);
+ safe_free (pkt);
return 0;
}
}
inp = gpg_iobuf_open (pubring);
if (!inp) {
- safe_free( pkt );
+ safe_free (pkt);
return gpg_error (GPG_ERR_KEYRING_OPEN);
}
- gpg_iobuf_ioctl( inp, 3, 1, NULL ); /* disable cache */
+ gpg_iobuf_ioctl (inp, 3, 1, NULL); /* disable cache */
- gpg_init_packet( pkt );
+ gpg_init_packet (pkt);
while (gpg_parse_packet (inp, pkt) != -1) {
if (pkt->pkttype == PKT_PUBLIC_KEY) {
strcpy (keyid, "");
@@ -517,6 +517,22 @@
}
+static unsigned char*
+copy_uid_prefs (const unsigned char *prefs)
+{
+ unsigned char *p;
+ size_t pos=0;
+
+ while (prefs[pos] != 0)
+ pos++;
+ p = (unsigned char*)calloc (1, pos+1);
+ if (!p)
+ abort ();
+ memcpy (p, prefs, pos);
+ return p;
+}
+
+
gpgme_error_t
gpg_keycache_sync (gpg_keycache_t pub, gpg_keycache_t sec)
{
@@ -532,6 +548,7 @@
c_sec->gloflags.divert_to_card = c->gloflags.divert_to_card;
if (!c->gloflags.divert_to_card)
c->gloflags.divert_to_card = key_divert_to_card (key);
+ c->sym_prefs = copy_uid_prefs (c_sec->sym_prefs);
c->pubpart = c_sec;
c->pubpart->key = key;
}
Modified: trunk/Src/wptKeyEditDlgs.cpp
===================================================================
--- trunk/Src/wptKeyEditDlgs.cpp 2005-12-12 16:21:10 UTC (rev 122)
+++ trunk/Src/wptKeyEditDlgs.cpp 2005-12-14 09:01:45 UTC (rev 123)
@@ -1511,13 +1511,21 @@
}
+#define CIPHER 11
+#define HASH 11
+#define COMPR 4
+
static int
parse_preflist (HWND dlg, const char *list)
{
- char *p, buf[128] = {0}, *pbuf = buf;
- const char *ciphers[11] = {0, "IDEA", "3DES", "CAST5", "BLOWFISH", 0, 0, "AES", "AES192", "AES256", "TWOFISH"};
- const char *hash[11] = {0, "MD5", "SHA1", "RMD160", 0, 0, 0, 0, "SHA256", "SHA384", "SHA512"};
- const char *compress[4] = {0, "ZIP", "ZLIB", "BZIP2"};
+ char buf[128] = {0};
+ char *p, *pbuf = buf;
+ const char *ciphers[CIPHER] = {"", "IDEA", "3DES",
+ "CAST5", "BLOWFISH", "", "",
+ "AES", "AES192", "AES256", "TWOFISH"};
+ const char *hash[HASH] = {"", "MD5", "SHA1", "RMD160", "",
+ "", "", "", "SHA256", "SHA384", "SHA512"};
+ const char *compress[COMPR] = {"", "ZIP", "ZLIB", "BZIP2"};
int n=0;
strncpy (buf, list, 127);
@@ -1527,15 +1535,18 @@
n++;
switch (*p) {
case 'S':
- SendDlgItemMessage (dlg, IDC_SHOWPREF_CIPHERS, LB_ADDSTRING, 0, (LPARAM)(const char*)ciphers[algid % 11]);
+ SendDlgItemMessage (dlg, IDC_SHOWPREF_CIPHERS, LB_ADDSTRING, 0,
+ (LPARAM)(const char*)ciphers[algid % CIPHER]);
break;
case 'H':
- SendDlgItemMessage (dlg, IDC_SHOWPREF_HASH, LB_ADDSTRING, 0, (LPARAM)(const char*)hash[algid % 10]);
+ SendDlgItemMessage (dlg, IDC_SHOWPREF_HASH, LB_ADDSTRING, 0,
+ (LPARAM)(const char*)hash[algid % HASH]);
break;
case 'Z':
- SendDlgItemMessage (dlg, IDC_SHOWPREF_ZIP, LB_ADDSTRING, 0, (LPARAM)(const char*)compress[algid % 4]);
+ SendDlgItemMessage (dlg, IDC_SHOWPREF_ZIP, LB_ADDSTRING, 0,
+ (LPARAM)(const char*)compress[algid % COMPR]);
break;
default:
Modified: trunk/Src/wptKeyManager.cpp
===================================================================
--- trunk/Src/wptKeyManager.cpp 2005-12-12 16:21:10 UTC (rev 122)
+++ trunk/Src/wptKeyManager.cpp 2005-12-14 09:01:45 UTC (rev 123)
@@ -539,6 +539,9 @@
if (res->secret_imported == 0 && fm_stat.import.has_seckey == 1)
res->secret_imported = 1;
+ /* XXX: if we import a key pair but the secret key comes first,
+ no_{valid}_user_id is 1 even so the public key, which comes
+ later is valid and self-signed. */
print_import_status (res);
if (res->no_user_id > 0) {
msg_box (dlg, _("Key without a self signature was dectected!\n"
Modified: trunk/Src/wptKeyManagerDlg.cpp
===================================================================
--- trunk/Src/wptKeyManagerDlg.cpp 2005-12-12 16:21:10 UTC (rev 122)
+++ trunk/Src/wptKeyManagerDlg.cpp 2005-12-14 09:01:45 UTC (rev 123)
@@ -18,7 +18,6 @@
* 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
@@ -43,13 +42,25 @@
#include "wptKeyEdit.h"
#include "wptRegistry.h"
+/* Name and ID of the separator window. */
#define KM_SEPARATOR_ID 10000
#define WINDOWCLASS_SEPARATOR_CHILD "WINPT_SEP_CHILD"
-//#define KM_SEPARATOR_HEIGHT 5
+/* Virtual key codes. */
+#ifndef VK_F
+#define VK_F 70
+#endif
+#ifndef VK_A
+#define VK_A 65
+#endif
+#ifndef VK_C
+#define VK_C 67
+#endif
+#ifndef VK_P
+#define VK_P 80
+#endif
static subclass_s keylist_proc;
-static int km_index = -1;
HIMAGELIST glob_imagelist;
@@ -64,9 +75,11 @@
HWND statbar;
listview_ctrl_t lv;
+ int lv_idx;
int keylist_sortby;
};
+/* Toolbar button structure. */
struct mybuttons {
long icon;
long command;
@@ -82,19 +95,7 @@
};
-#ifndef VK_F
-#define VK_F 70
-#endif
-#ifndef VK_A
-#define VK_A 65
-#endif
-#ifndef VK_C
-#define VK_C 67
-#endif
-#ifndef VK_P
-#define VK_P 80
-#endif
-
+/* Subclass the keylist listview control to allow extended commands. */
static BOOL CALLBACK
keylist_subclass_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
@@ -109,11 +110,11 @@
int virt_key = (int)wparam;
switch (virt_key) {
case VK_SPACE:
- send_cmd_id( keylist_proc.dlg, ID_KEYMISC_PROPS );
+ send_cmd_id (keylist_proc.dlg, ID_KEYMISC_PROPS);
break;
case VK_DELETE:
- send_cmd_id( keylist_proc.dlg, ID_KEYMISC_DELETE );
+ send_cmd_id (keylist_proc.dlg, ID_KEYMISC_DELETE);
break;
case VK_INSERT:
@@ -130,16 +131,13 @@
case VK_C:
if (GetAsyncKeyState (VK_CONTROL)) {
lv.ctrl = GetDlgItem (keylist_proc.dlg, IDC_KEYMISC_KEYLIST);
- km_index = listview_get_curr_pos (&lv);
km_clip_export (keylist_proc.dlg, &lv);
}
break;
case VK_P:
- if (GetAsyncKeyState (VK_CONTROL)) {
- km_index = -1;
+ if (GetAsyncKeyState (VK_CONTROL))
km_clip_import (keylist_proc.dlg);
- }
break;
case VK_F:
@@ -152,12 +150,12 @@
break;
}
- return CallWindowProc( keylist_proc.old, dlg, msg, wparam, lparam );
-} /* keylist_subclass_proc */
+ return CallWindowProc (keylist_proc.old, dlg, msg, wparam, lparam);
+}
static HWND
-load_toolbar (HWND dlg, struct km_info * kmi)
+load_toolbar (HWND dlg, struct km_info *kmi)
{
HWND tbwnd;
TBSAVEPARAMS tbsp;
@@ -175,7 +173,7 @@
WS_CHILD|TBSTYLE_TOOLTIPS|TBSTYLE_FLAT|CCS_ADJUSTABLE,
0, 0, 0, 0, dlg, (HMENU)IDR_WINPT_KMTB, glob_hinst, NULL);
if (tbwnd) {
- SendMessage (tbwnd, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
+ SendMessage (tbwnd, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
SendMessage (tbwnd, TB_SETIMAGELIST, 0, (LPARAM)glob_imagelist);
SendMessage (tbwnd, TB_AUTOSIZE, 0, 0);
ShowWindow (tbwnd, SW_SHOW);
@@ -185,18 +183,19 @@
tbsp.pszSubKey = "Software\\WinPT";
tbsp.pszValueName = "KM_toolbar";
if (SendMessage(tbwnd, TB_SAVERESTORE, FALSE, (LPARAM)&tbsp ) == 0)
- SendMessage (tbwnd, TB_ADDBUTTONS, sizeof(tb_buttons) / sizeof(tb_buttons[0]), (LONG)&tb_buttons[0]);
+ SendMessage (tbwnd, TB_ADDBUTTONS, sizeof(tb_buttons) / sizeof(tb_buttons[0]),
+ (LONG)&tb_buttons[0]);
}
return tbwnd;
-} /* load_toolbar */
+}
/* Center window @dlg. */
static void
-do_center_window (HWND dlg, struct km_info * kmi)
+do_center_window (HWND dlg, struct km_info *kmi)
{
RECT rect;
- char * p;
+ char *p;
int pos_x = 0, pos_y = 0;
/* Find bottom of keylist */
@@ -207,7 +206,7 @@
p = get_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_X");
if (p && !strcmp (p, " ")) {
- free_if_alloc (p);
+ free_if_alloc (p);
center_window (dlg, NULL);
return;
}
@@ -217,7 +216,7 @@
p = get_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_Y");
if (p && !strcmp (p, " ")) {
free_if_alloc (p);
- center_window(dlg, NULL);
+ center_window (dlg, NULL);
return;
}
else if (p)
@@ -230,7 +229,7 @@
if (pos_x < 0 || pos_y < 0)
pos_x = pos_y = 0;
- if (pos_x > GetSystemMetrics (SM_CXSCREEN)
+ if (pos_x > GetSystemMetrics (SM_CXSCREEN)
|| pos_y > GetSystemMetrics (SM_CYSCREEN)) {
pos_x = pos_y = 0;
}
@@ -239,21 +238,22 @@
}
+/* Resize the key manager window with the information from @kmi. */
static void
-do_resize_window( HWND dlg, struct km_info *kmi)
+do_resize_window (HWND dlg, struct km_info *kmi)
{
HWND h;
RECT rclient, rect;
BOOL bRepaint = FALSE;
/* Get rect of client area and make life easier */
- GetClientRect( dlg, &rclient );
+ GetClientRect (dlg, &rclient);
/* Move toolbar to the top of the window */
if (kmi->toolbar) {
- GetWindowRect(kmi->toolbar, &rect);
- ScreenToClient(dlg, (POINT*)&rect);
- ScreenToClient(dlg, (POINT*)&(rect.right));
+ GetWindowRect (kmi->toolbar, &rect);
+ ScreenToClient (dlg, (POINT*)&rect);
+ ScreenToClient (dlg, (POINT*)&(rect.right));
rclient.top += rect.bottom - rect.top;
MoveWindow (kmi->toolbar, 0, 0, rclient.right - rclient.left,
@@ -262,48 +262,70 @@
/* Move statusbar to the bottom of the window */
if (kmi->statbar) {
- GetWindowRect( kmi->statbar, &rect );
- ScreenToClient(dlg, (POINT*)&rect);
- ScreenToClient(dlg, (POINT*)&(rect.right));
+ GetWindowRect (kmi->statbar, &rect);
+ ScreenToClient (dlg, (POINT*)&rect);
+ ScreenToClient (dlg, (POINT*)&(rect.right));
rclient.bottom -= rect.bottom - rect.top;
- MoveWindow (kmi->statbar, 0, rclient.bottom, rclient.right - rclient.left,
+ MoveWindow (kmi->statbar, 0, rclient.bottom,
+ rclient.right - rclient.left,
rect.bottom - rect.top, bRepaint);
}
- // Obtain separator information and move it to the desired posistion
+ /* Obtain separator information and move it to the desired posistion */
if (kmi->ypercent_sep)
kmi->ypos_sep = (rclient.bottom - rclient.top) * kmi->ypercent_sep / 100;
else
kmi->ypercent_sep = kmi->ypos_sep * 100 / (rclient.bottom - rclient.top);
- // Don't move away
+ /* Don't move away */
if (kmi->ypos_sep+5 > rclient.bottom)
kmi->ypos_sep = rclient.bottom - 5;
if (kmi->ypos_sep < rclient.top)
kmi->ypos_sep = rclient.top;
- MoveWindow (kmi->hwnd_sep, 0, kmi->ypos_sep, (rclient.right - rclient.left), 5, bRepaint);
+ MoveWindow (kmi->hwnd_sep, 0, kmi->ypos_sep,
+ (rclient.right - rclient.left), 5, bRepaint);
- // Place the keylist above the separator
- h = GetDlgItem( dlg, IDC_KEYMISC_KEYLIST );
+ /* Place the keylist above the separator */
+ h = GetDlgItem (dlg, IDC_KEYMISC_KEYLIST);
MoveWindow (h, rclient.left, rclient.top, rclient.right - rclient.left,
kmi->ypos_sep - rclient.top, bRepaint);
rclient.top = kmi->ypos_sep + 5 + 8;
/* Place the group text and the group box below the separator */
- h = GetDlgItem( dlg, IDC_KEYMISC_GTEXT );
- MoveWindow( h, rclient.left, rclient.top, 100, 14, bRepaint);
+ h = GetDlgItem (dlg, IDC_KEYMISC_GTEXT);
+ MoveWindow (h, rclient.left, rclient.top, 100, 14, bRepaint);
rclient.top += 18;
- h = GetDlgItem( dlg, IDC_KEYMISC_GROUP );
+ h = GetDlgItem (dlg, IDC_KEYMISC_GROUP);
MoveWindow (h, rclient.left, rclient.top, rclient.right - rclient.left,
- (rclient.bottom < rclient.top) ? 0 : rclient.bottom - rclient.top, bRepaint);
+ (rclient.bottom < rclient.top) ?
+ 0 : rclient.bottom - rclient.top, bRepaint);
/* Repaint the whole thing */
InvalidateRect (dlg, NULL, TRUE);
-} /* do_resize_window */
+}
+/* Return true if the clipboard contains an OpenPGP key. */
+static bool
+clip_contains_pgpkey (void)
+{
+ char *ctxt;
+ bool val = false;
+
+ ctxt = get_clip_text (NULL);
+ if (!ctxt || strlen (ctxt) < 512)
+ val = false;
+ else if (strstr (ctxt, "BEGIN PGP") && strstr (ctxt, "KEY BLOCK") &&
+ strstr (ctxt, "END PGP"))
+ val = true;
+ free_if_alloc (ctxt);
+ return val;
+}
+
+
+/* Show a mini popup menu to import keys. */
static void
do_create_minpopup (HWND dlg)
{
@@ -312,7 +334,7 @@
char * s;
POINT p;
- if (gpg_read_only)
+ if (gpg_read_only || !clip_contains_pgpkey ())
return;
hm = CreatePopupMenu ();
if (!hm)
@@ -329,79 +351,81 @@
GetCursorPos (&p);
TrackPopupMenu (hm, 0, p.x, p.y, 0, dlg, NULL);
DestroyMenu (hm);
-} /* do_create_minpopup */
+}
+/* Reload the key cache if requested. */
static void
do_check_cache (listview_ctrl_t lv, HWND dlg, HWND sb)
{
gpg_keycache_t cache;
- if( keycache_get_reload( ) ) {
- keycache_reload( dlg );
- keycache_set_reload( 0 );
- cache = keycache_get_ctx( 1 );
- if( !cache )
- BUG( dlg );
- keylist_reload( lv, cache, KEYLIST_LIST, KEY_SORT_USERID );
+ if (keycache_get_reload ()) {
+ keycache_reload (dlg);
+ keycache_set_reload (0);
+ cache = keycache_get_ctx (1);
+ if (!cache)
+ BUG (dlg);
+ keylist_reload (lv, cache, KEYLIST_LIST, KEY_SORT_USERID);
km_update_status_bar (sb, lv);
}
-} /* do_check_cache */
+}
long CALLBACK
-separator_wnd_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
+separator_wnd_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
static POINT last_mouse_pos;
- RECT rect;
-
+
if (msg == WM_CREATE)
- SetWindowLong (hwnd, GWL_USERDATA, (long)(((CREATESTRUCT*)lparam)->lpCreateParams));
+ SetWindowLong (hwnd, GWL_USERDATA,
+ (long)(((CREATESTRUCT*)lparam)->lpCreateParams));
switch (msg) {
case WM_PAINT:
PAINTSTRUCT ps;
+ RECT rect;
HPEN hpen;
GetClientRect (hwnd, &rect);
BeginPaint (hwnd, &ps);
- // Background
+ /* Background */
FillRect (ps.hdc, &rect, (HBRUSH)(COLOR_3DFACE+1));
- // The lines from the light into the dark
+ /* The lines from the light into the dark */
MoveToEx(ps.hdc, 0,0, NULL);
- if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DHILIGHT))) != NULL) {
- SelectObject(ps.hdc, (LPVOID)hpen);
- LineTo(ps.hdc, rect.right, 0);
- DeleteObject(hpen);
+ if ((hpen = CreatePen (PS_SOLID, 0, GetSysColor(COLOR_3DHILIGHT))) != NULL) {
+ SelectObject (ps.hdc, (LPVOID)hpen);
+ LineTo (ps.hdc, rect.right, 0);
+ DeleteObject (hpen);
}
MoveToEx(ps.hdc, 0, 1, NULL);
- if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DLIGHT))) != NULL) {
- SelectObject(ps.hdc, (LPVOID)hpen);
- LineTo(ps.hdc, rect.right, rect.bottom);
- DeleteObject(hpen);
+ if ((hpen = CreatePen (PS_SOLID, 0, GetSysColor(COLOR_3DLIGHT))) != NULL) {
+ SelectObject (ps.hdc, (LPVOID)hpen);
+ LineTo (ps.hdc, rect.right, rect.bottom);
+ DeleteObject (hpen);
}
MoveToEx(ps.hdc, 0, rect.bottom-1, NULL);
- if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DSHADOW))) != NULL) {
- SelectObject(ps.hdc, (LPVOID)hpen);
- LineTo(ps.hdc, rect.right, rect.bottom-1);
- DeleteObject(hpen);
+ if ((hpen = CreatePen (PS_SOLID, 0, GetSysColor(COLOR_3DSHADOW))) != NULL) {
+ SelectObject (ps.hdc, (LPVOID)hpen);
+ LineTo (ps.hdc, rect.right, rect.bottom-1);
+ DeleteObject (hpen);
}
MoveToEx(ps.hdc, 0, rect.bottom, NULL);
if ((hpen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DDKSHADOW))) != NULL) {
- SelectObject(ps.hdc, (LPVOID)hpen);
- LineTo(ps.hdc, rect.right, rect.bottom);
- DeleteObject(hpen);
+ SelectObject (ps.hdc, (LPVOID)hpen);
+ LineTo (ps.hdc, rect.right, rect.bottom);
+ DeleteObject (hpen);
}
EndPaint (hwnd, &ps);
return 0;
case WM_LBUTTONDOWN:
- last_mouse_pos.x = LOWORD(lparam);
- last_mouse_pos.y = HIWORD(lparam);
+ last_mouse_pos.x = LOWORD (lparam);
+ last_mouse_pos.y = HIWORD (lparam);
ClientToScreen (hwnd, &last_mouse_pos);
SetCapture (hwnd);
return 0;
@@ -414,26 +438,28 @@
if (wparam == MK_LBUTTON) {
struct km_info *kmi;
POINT p;
+ RECT r;
- if ((kmi = (struct km_info *)GetWindowLong (hwnd, GWL_USERDATA)) == NULL)
+ kmi = (struct km_info *)GetWindowLong (hwnd, GWL_USERDATA);
+ if (kmi == NULL)
break;
- // Calculate mouse movement
+ /* Calculate mouse movement */
p.x = LOWORD(lparam);
p.y = HIWORD(lparam);
ClientToScreen (hwnd, &p);
- GetWindowRect (hwnd, &rect);
- rect.top += (short)(p.y - last_mouse_pos.y);
- rect.bottom += (short)(p.y - last_mouse_pos.y);
+ GetWindowRect (hwnd, &r);
+ r.top += (short)(p.y - last_mouse_pos.y);
+ r.bottom += (short)(p.y - last_mouse_pos.y);
last_mouse_pos.y = p.y;
- // Apply mouse movement to window. Beware the MoveWindow is relaive
- // to parent NOT screen
- MapWindowPoints (NULL, GetParent(hwnd), (POINT*)&rect, 2);
- kmi->ypos_sep = rect.top;
- kmi->ypercent_sep = 0; // This forces do_resize_window to use abs. position
+ /* Apply mouse movement to window. Beware the MoveWindow is relaive
+ to parent NOT screen */
+ MapWindowPoints (NULL, GetParent(hwnd), (POINT*)&r, 2);
+ kmi->ypos_sep = r.top;
+ kmi->ypercent_sep = 0; /* This forces do_resize_window to use abs. position */
do_resize_window (GetParent(hwnd), kmi);
return 0;
}
@@ -443,6 +469,7 @@
}
+/* Register the separator window with @dlg as the parent window. */
static HWND
regist_sep_wnd (HWND dlg, struct km_info * kmi)
{
@@ -466,10 +493,9 @@
0, 400, 2000, 5, dlg, (HMENU) 0, glob_hinst, kmi);
ShowWindow (h, SW_SHOW);
return h;
-} /* regist_sep_wnd */
+}
-
#define enable_button(hwnd, cid) \
SendMessage ((hwnd), TB_ENABLEBUTTON, (cid), MAKELONG (key_selected, 0))
@@ -486,7 +512,7 @@
int key_has_sec = 0;
int key_inv = 0;
int mult_resids[] = {ID_KEYMISC_PROPS, ID_KEYMISC_SIGN, ID_KEYMISC_EDITKEY,
- ID_KEYMISC_CHECKSIGS, ID_KEYMISC_REVCERT, 0};
+ ID_KEYMISC_CHECKSIGS, ID_KEYMISC_REVCERT, 0};
int i;
/* Get some states */
@@ -497,7 +523,8 @@
if (key_selected) {
i = listview_get_curr_pos (lv);
key_has_sec = km_check_for_seckey (lv, i, NULL) ? TRUE : FALSE;
- key_inv = km_get_key_status (lv, i) & KM_FLAG_REVOKED;
+ key_inv = km_get_key_status (lv, i) & KM_FLAG_REVOKED ||
+ km_get_key_status (lv, i) & KM_FLAG_EXPIRED;
}
/* Enable / disable toolbar buttons */
@@ -517,14 +544,15 @@
set_menu_state (hmenu, ID_KEYMISC_SIGN, key_selected && !key_inv ? MF_ENABLED : MF_GRAYED);
set_menu_state (hmenu, ID_KEYMISC_EDITKEY, key_selected? MF_ENABLED : MF_GRAYED);
set_menu_state (hmenu, ID_KEYMISC_CHECKSIGS, key_selected? MF_ENABLED : MF_GRAYED);
-
+
/* Disable some menu items when multiple keys are selected. */
if (listview_count_items (lv, 1) > 1) {
for (i=0; mult_resids[i] != 0; i++)
set_menu_state (hmenu, mult_resids[i], MF_GRAYED);
- }
+ }
}
+
/* Disable some context menu items when multiple keys are selected. */
static void
popup_multiple (HWND dlg, HMENU hm)
@@ -533,24 +561,23 @@
ID_KEYCTX_EDIT,
ID_KEYCTX_SIGN,
ID_KEYCTX_REV,
- ID_KEYCTX_ENABLE,
- ID_KEYCTX_DISABLE,
- ID_KEYCTX_ADDKEY,
- ID_KEYCTX_ADDPHOTO,
- ID_KEYCTX_ADDUID,
- ID_KEYCTX_ADDREV,
- ID_KEYCTX_LISTSIGS,
- ID_KEYCTX_MAXTRUST,
- ID_KEYCTX_PROPS,
- ID_KEYCTX_SENDMAIL,
- 0
- };
+ ID_KEYCTX_ENABLE,
+ ID_KEYCTX_DISABLE,
+ ID_KEYCTX_ADDKEY,
+ ID_KEYCTX_ADDPHOTO,
+ ID_KEYCTX_ADDUID,
+ ID_KEYCTX_ADDREV,
+ ID_KEYCTX_LISTSIGS,
+ ID_KEYCTX_MAXTRUST,
+ ID_KEYCTX_PROPS,
+ ID_KEYCTX_SENDMAIL,
+ 0};
int i;
for (i=0; i < resids[i] != 0; i++)
set_menu_state (hm, resids[i], MF_GRAYED);
}
-
+
/* The items which are shown when GPG is in read-only mode. */
static void
popup_gpg_readonly (HWND dlg, HMENU hm)
@@ -579,9 +606,30 @@
}
+/* Change the 'Edit' menu based on the current state. */
static void
-menu_gpg_readonly (HWND dlg, HMENU hm, int id)
+change_edit_menu (listview_ctrl_t lv, HMENU hm, int id)
{
+ int no_sel;
+
+ if (id != 1 /*EDIT_MENU*/)
+ return;
+
+ if (!clip_contains_pgpkey ())
+ set_menu_state (hm, ID_KEYMISC_PASTE, MF_GRAYED);
+ else
+ set_menu_state (hm, ID_KEYMISC_PASTE, MF_ENABLED);
+ no_sel = listview_get_curr_pos (lv) == -1? 1 : 0;
+ set_menu_state (hm, ID_KEYMISC_DELETE2, no_sel? MF_GRAYED: MF_ENABLED);
+ set_menu_state (hm, ID_KEYMISC_COPY, no_sel? MF_GRAYED : MF_ENABLED);
+}
+
+
+
+/* Show limited key menu entries when GPG is in read-only mode. */
+static void
+change_key_menu (HMENU hm, int id)
+{
int key_resids[] = {
ID_KEYMISC_SIGN,
ID_KEYMISC_DELETE,
@@ -611,7 +659,7 @@
case 0: return;
case 3: resids = key_resids; break;
case 1: resids = edit_resids;break;
- default: resids = edit_resids; return;
+ default:resids = edit_resids; break;
}
for (i=0; resids[i] != 0; i++)
@@ -619,6 +667,8 @@
}
+/* Return a user-friendly name for a key derrived from
+ name. If @is_secret is 1, a secret key name will be generated. */
static char*
gen_export_filename (const char *keyid, int is_secret)
{
@@ -643,6 +693,7 @@
}
+/* Reload a single key in the cache. */
static void
update_key (listview_ctrl_t lv, int pos, const char *keyid, int keypair)
{
@@ -663,7 +714,7 @@
static HWND
setup_status_bar (HWND dlg, listview_ctrl_t lv)
{
- HWND statbar;
+ HWND statbar;
RECT r;
int partpos[3];
int i;
@@ -684,11 +735,11 @@
}
+/* Dialog box procedure for the Key Manager. */
BOOL CALLBACK
keymanager_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
struct km_info *kmi;
- /*static km_group_s *gc = NULL;*/
static HMENU menu = NULL;
static int refresh_keys = 0;
INITCOMMONCONTROLSEX icex;
@@ -696,15 +747,14 @@
HMENU hm;
gpg_keycache_t c;
gpgme_key_t key;
- /*km_group_cb_s gcb; XXX */
struct genkey_s genkey;
struct winpt_key_s k = {0};
struct URL_ctx_s *url;
refresh_cache_s rcs = {0};
char keyid[48], uid[128], type[32], *name;
- const char *t, * host;
+ const char *t, *host;
u16 port = 0;
- int idx = 0, i=0, rc;
+ int l_idx = 0, i=0, rc;
if ((msg != WM_INITDIALOG)
&& ((kmi = (struct km_info*)GetWindowLong (dlg, GWL_USERDATA)) == NULL))
@@ -714,20 +764,19 @@
case WM_INITDIALOG:
kmi = new struct km_info;
memset (kmi, 0, sizeof (struct km_info));
+ 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);
-
- SetWindowText( dlg, _("Key Manager") );
- menu = LoadMenu( glob_hinst, (LPCSTR)IDR_WINPT_KEYMISC );
+ SetWindowText (dlg, _("Key Manager"));
+ menu = LoadMenu (glob_hinst, (LPCSTR)IDR_WINPT_KEYMISC);
set_menu_text_bypos (menu, 0, _("File"));
set_menu_text_bypos (menu, 1, _("Edit"));
set_menu_text_bypos (menu, 2, _("View"));
set_menu_text_bypos (menu, 3, _("Key"));
set_menu_text_bypos (menu, 4, _("Groups"));
-
set_menu_text (menu, ID_KEYMISC_EDITKEY, _("Edit"));
set_menu_text (menu, ID_KEYMISC_MAIL, _("Send Mail..."));
set_menu_text (menu, ID_KEYMISC_OT, _("Ownertrust")); /* XXX */
@@ -742,6 +791,7 @@
set_menu_text (menu, ID_KEYMISC_EDIT, _("Edit"));
set_menu_text (menu, ID_KEYMISC_SIGN, _("&Sign"));
set_menu_text (menu, ID_KEYMISC_DELETE, _("&Delete"));
+ set_menu_text (menu, ID_KEYMISC_DELETE2, _("&Delete"));
set_menu_text (menu, ID_KEYMISC_REVCERT, _("&Revoke"));
set_menu_text (menu, ID_KEYMISC_CHECKSIGS, _("&List Signatures"));
set_menu_text (menu, ID_KEYMISC_TRUSTPATH, _("List Trust Path"));
@@ -757,37 +807,39 @@
set_menu_text (menu, ID_KEYMISC_REFRESH_KEYS, _("Refresh &Keys (Keyserver)"));
set_menu_text (menu, ID_KEYMISC_INFO, _("Info") );
set_menu_text (menu, ID_KEYMISC_HELP, _("&Help"));
-
+
+ /* XXX: implement help code. */
+ set_menu_state (menu, ID_KEYMISC_HELP, MF_GRAYED);
+
SetMenu (dlg, menu);
- if( keyring_check_last_access() )
- keycache_set_reload( 1 );
- if( keycache_get_reload( ) )
- keycache_reload( dlg );
- c = keycache_get_ctx( KEYCACHE_PUB );
- if( !c )
- BUG( NULL );
+ if (keyring_check_last_access ())
+ keycache_set_reload (1);
+ if (keycache_get_reload ())
+ keycache_reload (dlg);
+ c = keycache_get_ctx (KEYCACHE_PUB);
+ if (!c)
+ BUG (NULL);
kmi->keylist_sortby = KEY_SORT_USERID;
- Header_SetImageList(ListView_GetHeader(GetDlgItem( dlg, IDC_KEYMISC_KEYLIST )),
+ Header_SetImageList(ListView_GetHeader (GetDlgItem (dlg, IDC_KEYMISC_KEYLIST)),
glob_imagelist);
- kmi->lv = keylist_load( GetDlgItem( dlg, IDC_KEYMISC_KEYLIST ), c,
- NULL, KEYLIST_LIST, kmi->keylist_sortby );
+ kmi->lv = keylist_load (GetDlgItem (dlg, IDC_KEYMISC_KEYLIST), c,
+ NULL, KEYLIST_LIST, kmi->keylist_sortby);
/* init subclassing for the listview */
- kl = GetDlgItem( dlg, IDC_KEYMISC_KEYLIST );
+ kl = GetDlgItem (dlg, IDC_KEYMISC_KEYLIST);
keylist_proc.dlg = dlg;
keylist_proc.current = (WNDPROC)keylist_subclass_proc;
keylist_proc.old = (WNDPROC)GetWindowLong( kl, GWL_WNDPROC );
- if( keylist_proc.old ) {
- if( !SetWindowLong( kl, GWL_WNDPROC, (LONG)keylist_proc.current) ) {
- msg_box( dlg, _("Could not set keylist window procedure."), _("Key Manager"), MB_ERR );
- BUG( NULL );
+ if (keylist_proc.old) {
+ if( !SetWindowLong (kl, GWL_WNDPROC, (LONG)keylist_proc.current)) {
+ msg_box (dlg, _("Could not set keylist window procedure."),
+ _("Key Manager"), MB_ERR);
+ BUG (NULL);
}
}
#if 0
- km_groups_new( &gc, GetDlgItem( dlg, IDC_KEYMISC_GROUP ) );
- km_groups_load( gc );
+ km_groups_new (&gc, GetDlgItem (dlg, IDC_KEYMISC_GROUP));
+ km_groups_load (gc);
#endif
- SetClassLong (dlg, GCL_HICON, (LONG)LoadIcon (glob_hinst, (LPCTSTR)IDI_WINPT));
-
kmi->statbar = setup_status_bar (dlg, kmi->lv);
SetWindowLong (dlg, GWL_USERDATA, (LONG)kmi);
kmi->toolbar = load_toolbar (dlg, kmi);
@@ -795,8 +847,10 @@
do_center_window (dlg, kmi);
do_resize_window (dlg, kmi);
update_ui_items (dlg, kmi->lv);
-
+
SetDlgItemText (dlg, IDC_KEYMISC_GTEXT, _("Groups"));
+ SetClassLong (dlg, GCL_HICON, (LONG)LoadIcon (glob_hinst,
+ (LPCTSTR)IDI_WINPT));
SetForegroundWindow (dlg);
return TRUE;
@@ -804,28 +858,20 @@
if (kmi->lv) {
keylist_delete (kmi->lv);
kmi->lv = NULL;
-
- /*
- if (gc) {
- km_groups_release (gc);
- gc = NULL;
- }*/
- imagelist_destroy ();
+ }
+ imagelist_destroy ();
- char buf[32];
- ltoa (kmi->pos_x, buf, 10);
- set_reg_entry( HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_X", buf );
- ltoa (kmi->pos_y, buf, 10);
- set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_Y", buf);
- /* Remove runtime information. This should be the last action taken here. */
- delete kmi; kmi = NULL;
- SetWindowLong (dlg, GWL_USERDATA, 0);
- keycache_set_reload (refresh_keys);
- return FALSE;
+ ltoa (kmi->pos_x, type, 10);
+ set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_X", type);
+ ltoa (kmi->pos_y, type, 10);
+ set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "KM_Pos_Y", type);
+ /* Remove runtime information. This should be the last action taken here. */
+ delete kmi; kmi = NULL;
+ SetWindowLong (dlg, GWL_USERDATA, 0);
+ keycache_set_reload (refresh_keys);
+ return FALSE;
- case WM_MOVE:
- /* kmi->pos_x = (int)(short)LOWORD(lparam);
- kmi->pos_y = (int)(short)HIWORD(lparam); */
+ case WM_MOVE:
RECT r;
GetWindowRect (dlg, &r);
kmi->pos_x = r.left;
@@ -838,21 +884,20 @@
break;
case WM_NOTIFY:
- NMHDR * notify;
+ NMHDR *notify;
POINT p;
HMENU popup;
notify = (NMHDR *)lparam;
- if (notify == NULL)
+ if (!notify)
break;
- switch (notify->code)
- {
+ switch (notify->code) {
case TBN_QUERYDELETE:
- SetWindowLong(dlg, DWL_MSGRESULT, TRUE);
+ SetWindowLong (dlg, DWL_MSGRESULT, TRUE);
return TRUE;
case TBN_QUERYINSERT:
- SetWindowLong(dlg, DWL_MSGRESULT, TRUE);
+ SetWindowLong (dlg, DWL_MSGRESULT, TRUE);
return TRUE;
case TBN_GETBUTTONINFO:
@@ -921,8 +966,8 @@
return TRUE;
case LVN_ITEMCHANGED:
- if (((LPNMLISTVIEW)lparam)->uNewState) /* item selected? */
- {
+ if (((LPNMLISTVIEW)lparam)->uNewState) { /* item selected? */
+ kmi->lv_idx = listview_get_curr_pos (kmi->lv);
update_ui_items (dlg, kmi->lv);
return TRUE;
}
@@ -930,7 +975,8 @@
case NM_RCLICK:
if (notify->idFrom == IDC_KEYMISC_KEYLIST) {
- if (listview_get_curr_pos (kmi->lv) == -1)
+ l_idx =listview_get_curr_pos (kmi->lv);
+ if (l_idx == -1)
return TRUE; /* Popup only when a item was selected */
do_check_cache (kmi->lv, dlg, kmi->statbar);
GetCursorPos (&p);
@@ -957,51 +1003,54 @@
set_menu_text (popup, ID_KEYCTX_SETPREFKS, _("Set preferred Keyserver URL"));
set_menu_text (popup, ID_KEYCTX_SENDMAIL, _("Send Key to Mail Recipient"));
set_menu_text (popup, ID_KEYCTX_SETDEFKEY, _("Set as Default Key"));
+
+ set_menu_text (popup, ID_KEYCTX_ADDKEY, _("Key..."));
+ set_menu_text (popup, ID_KEYCTX_ADDUID, _("User ID..."));
+ set_menu_text (popup, ID_KEYCTX_ADDPHOTO, _("Photo ID..."));
+ set_menu_text (popup, ID_KEYCTX_ADDREV, _("Revoker..."));
+
/* change popup texts */
set_menu_text_bypos (popup, 0, _("Key Attributes"));
set_menu_text_bypos (popup, 6, _("Add"));
set_menu_text_bypos (popup, 19, _("Send to Keyserver"));
-
- set_menu_text (popup, ID_KEYCTX_ADDKEY, _("Key..."));
- set_menu_text (popup, ID_KEYCTX_ADDUID, _("User ID..."));
- set_menu_text (popup, ID_KEYCTX_ADDPHOTO, _("Photo ID..."));
- set_menu_text (popup, ID_KEYCTX_ADDREV, _("Revoker..."));
-
- idx = listview_get_curr_pos (kmi->lv);
- if (km_check_for_seckey (kmi->lv, idx, &i))
+
+ if (km_check_for_seckey (kmi->lv, l_idx, &i))
set_menu_state (popup, ID_KEYCTX_SETDEFKEY, MF_ENABLED);
if (i == 0)
set_menu_state (popup, ID_KEYCTX_MAXTRUST, MF_ENABLED);
- if (!km_check_for_seckey (kmi->lv, idx, NULL)) {
- set_menu_state( popup, ID_KEYCTX_REV, MF_DISABLED|MF_GRAYED );
- set_menu_state( popup, ID_KEYCTX_ADDKEY, MF_DISABLED|MF_GRAYED );
- set_menu_state( popup, ID_KEYCTX_ADDUID, MF_DISABLED|MF_GRAYED );
- set_menu_state( popup, ID_KEYCTX_ADDREV, MF_DISABLED|MF_GRAYED );
- set_menu_state( popup, ID_KEYCTX_ADDPHOTO, MF_DISABLED|MF_GRAYED );
+ if (!km_check_for_seckey (kmi->lv, l_idx, NULL)) {
+ set_menu_state (popup, ID_KEYCTX_REV, MF_DISABLED|MF_GRAYED);
+ set_menu_state (popup, ID_KEYCTX_ADDKEY, MF_DISABLED|MF_GRAYED);
+ set_menu_state (popup, ID_KEYCTX_ADDUID, MF_DISABLED|MF_GRAYED);
+ set_menu_state (popup, ID_KEYCTX_ADDREV, MF_DISABLED|MF_GRAYED);
+ set_menu_state (popup, ID_KEYCTX_ADDPHOTO, MF_DISABLED|MF_GRAYED );
set_menu_state (popup, ID_KEYCTX_SETPREFKS, MF_DISABLED|MF_GRAYED);
}
- else if( km_check_for_seckey (kmi->lv, idx, NULL)
- && km_key_is_v3 (kmi->lv, idx)) {
+ else if (km_check_for_seckey (kmi->lv, l_idx, NULL) &&
+ km_key_is_v3 (kmi->lv, l_idx)) {
/* PGP 2 keys, version 3 have no no support for photo-id's,
designated revokers and secondary keys. */
set_menu_state (popup, ID_KEYCTX_ADDKEY, MF_DISABLED|MF_GRAYED);
set_menu_state (popup, ID_KEYCTX_ADDREV, MF_DISABLED|MF_GRAYED);
set_menu_state (popup, ID_KEYCTX_ADDPHOTO, MF_DISABLED|MF_GRAYED);
}
- if( km_get_key_status( kmi->lv, idx ) & KM_FLAG_DISABLED )
- set_menu_state( popup, ID_KEYCTX_DISABLE, MF_DISABLED|MF_GRAYED );
+ if (km_get_key_status( kmi->lv, l_idx ) & KM_FLAG_DISABLED)
+ set_menu_state (popup, ID_KEYCTX_DISABLE, MF_DISABLED|MF_GRAYED);
else
- set_menu_state( popup, ID_KEYCTX_ENABLE, MF_DISABLED|MF_GRAYED );
- if (km_get_key_status (kmi->lv, idx) & KM_FLAG_REVOKED)
+ set_menu_state (popup, ID_KEYCTX_ENABLE, MF_DISABLED|MF_GRAYED);
+ if (km_get_key_status (kmi->lv, l_idx) & KM_FLAG_REVOKED ||
+ km_get_key_status (kmi->lv, l_idx) & KM_FLAG_EXPIRED)
set_menu_state (popup, ID_KEYCTX_SIGN, MF_DISABLED|MF_GRAYED);
- if (mapi_init())
+ if (!clip_contains_pgpkey ())
+ 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);
set_menu_text (popup, ID_KEYCTX_KS_DEFAULT, host);
popup_gpg_readonly (dlg, popup);
if (listview_count_items (kmi->lv, 1) > 1)
- popup_multiple (dlg, popup);
+ popup_multiple (dlg, popup);
TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);
DestroyMenu (popup);
DestroyMenu (hm);
@@ -1013,8 +1062,8 @@
if( TreeView_GetSelection( tree ) ) {
GetCursorPos( &p );
hm = LoadMenu( glob_hinst, MAKEINTRESOURCE(IDR_WINPT_GROUP_CTX) );
- popup = GetSubMenu( hm, 0 );
- if( km_index == -1 )
+ popup = GetSubMenu (hm, 0);
+ if (km_index == -1) /* XXX */
set_menu_state( popup, ID_GROUP_PASTE, MF_DISABLED|MF_GRAYED );
set_menu_text( popup, ID_GROUP_PASTE, _("Paste into this group") );
set_menu_text( popup, ID_GROUP_DELETE, _("Delete") );
@@ -1029,9 +1078,9 @@
case LVN_COLUMNCLICK:
if (notify->idFrom == IDC_KEYMISC_KEYLIST) {
- NMLISTVIEW * nml = (LPNMLISTVIEW) lparam;
+ NMLISTVIEW *nft = (LPNMLISTVIEW) lparam;
int sortby = 0;
- switch (nml->iSubItem) {
+ switch (nft->iSubItem) {
case 0: sortby = KEY_SORT_USERID; break;
case 1: sortby = KEY_SORT_KEYID; break;
case 2: sortby = KEY_SORT_IS_SECRET; break;
@@ -1053,7 +1102,6 @@
break;
}
break;
- }
case WM_WINDOWPOSCHANGING:
if (((WINDOWPOS*)lparam)->cx < 400)
@@ -1067,30 +1115,33 @@
return TRUE;
case WM_SYSCOMMAND:
- if( LOWORD (wparam) == SC_CLOSE )
- EndDialog( dlg, TRUE );
+ if (LOWORD (wparam) == SC_CLOSE)
+ EndDialog (dlg, TRUE);
return FALSE;
case WM_MENUSELECT:
- menu_gpg_readonly (dlg, (HMENU)lparam, LOWORD (wparam));
+ change_edit_menu (kmi->lv, (HMENU)lparam, LOWORD (wparam));
+ change_key_menu ((HMENU)lparam, LOWORD (wparam));
break;
case WM_INITMENUPOPUP:
if ((UINT)LOWORD (lparam) == 3) {
- HMENU m = (HMENU)wparam;
- set_menu_text_bypos (m, 0, _("New"));
+ HMENU h = (HMENU)wparam;
+ set_menu_text_bypos (h, 0, _("New"));
}
return FALSE;
case WM_COMMAND:
+ /* Allow at least 'Exit' in such a case. */
if (gnupg_access_keyring (1) && LOWORD (wparam) != ID_KEYMISC_QUIT) {
- msg_box( dlg, _("Could not access public keyring"), _("Key Manager"), MB_ERR );
+ msg_box (dlg, _("Could not access public keyring"),
+ _("Key Manager"), MB_ERR);
return FALSE;
}
- do_check_cache( kmi->lv, dlg, kmi->statbar );
- switch( LOWORD( wparam ) ) {
+ do_check_cache (kmi->lv, dlg, kmi->statbar);
+ switch( LOWORD (wparam)) {
case ID_KEYMISC_QUIT:
- EndDialog( dlg, TRUE );
+ EndDialog (dlg, TRUE);
return TRUE;
case ID_KEYMISC_MAIL:
@@ -1104,19 +1155,21 @@
break;
case ID_KEYMISC_DELETE:
- km_delete_keys (kmi->lv, dlg);
+ case ID_KEYMISC_DELETE2:
+ if (!km_delete_keys (kmi->lv, dlg))
+ km_update_status_bar (kmi->statbar, kmi->lv);
return TRUE;
- case ID_KEYMISC_SIGN:
- if ( (idx = listview_get_curr_pos( kmi->lv )) == -1 ) {
- msg_box( dlg, _("Please select a key."), _("Key Manager"),
- MB_ERR );
+ case ID_KEYMISC_SIGN:
+ if (kmi->lv_idx == -1) {
+ msg_box (dlg, _("Please select a key."),
+ _("Key Manager"), MB_ERR);
return TRUE;;
}
- if (km_check_key_status (kmi->lv, idx))
+ if (km_check_key_status (kmi->lv, kmi->lv_idx))
return TRUE;
- key = (gpgme_key_t)listview_get_item2 (kmi->lv, idx);
- listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1);
+ key = (gpgme_key_t)listview_get_item2 (kmi->lv, kmi->lv_idx);
+ listview_get_item_text (kmi->lv, kmi->lv_idx, 1, keyid, DIM (keyid)-1);
memset (&k, 0, sizeof (k));
k.ctx = key;
k.keyid = keyid;
@@ -1124,26 +1177,27 @@
keysign_dlg_proc, (LPARAM)&k,
_("Key Signing"), IDS_WINPT_KEYSIGN);
if (k.update)
- update_key (kmi->lv, idx, k.keyid, 0);
+ update_key (kmi->lv, kmi->lv_idx, k.keyid, 0);
return TRUE;
case ID_KEYMISC_REVCERT:
- idx = listview_get_curr_pos( kmi->lv );
- if( idx == -1 ) {
- msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR );
+ if (kmi->lv_idx == -1) {
+ msg_box (dlg, _("Please select a key."), _("Key Manager"), MB_ERR);
return TRUE;
}
- listview_get_item_text( kmi->lv, idx, 0, uid, sizeof uid -1 );
- listview_get_item_text( kmi->lv, idx, 1, keyid, sizeof keyid-1 );
- if ( !km_check_for_seckey( kmi->lv, idx, NULL ) ) {
- msg_box( dlg, _("There is no secret key available!"), _("Key Manager"), MB_ERR );
+ listview_get_item_text (kmi->lv, kmi->lv_idx, 0, uid, sizeof uid-1);
+ listview_get_item_text (kmi->lv, kmi->lv_idx, 1, keyid, sizeof keyid-1);
+ if ( !km_check_for_seckey( kmi->lv, kmi->lv_idx, NULL ) ) {
+ msg_box (dlg, _("There is no secret key available!"),
+ _("Key Manager"), MB_ERR);
return TRUE;
}
{
- char rinf[128];
- listview_get_item_text (kmi->lv, idx, 5, rinf, sizeof (rinf) -1);
- if (strchr (rinf, 'R')) {
+ char state[64];
+ listview_get_item_text (kmi->lv, kmi->lv_idx, 5,
+ state, sizeof (state) -1);
+ if( strchr (state, 'R' )) {
msg_box (dlg, _("Key already revoked!"),
_("Key Manager"), MB_INFO);
return TRUE;
@@ -1153,23 +1207,22 @@
memset (&k, 0, sizeof (k));
k.key_pair = 1;
k.keyid = keyid;
- k.is_protected = km_check_if_protected (kmi->lv, idx);
+ k.is_protected = km_check_if_protected (kmi->lv, kmi->lv_idx);
dialog_box_param(glob_hinst, (LPCSTR)IDD_WINPT_KEYREVOKE, dlg,
key_revoke_dlg_proc, (LPARAM)&k,
_("Key Revocation"), IDS_WINPT_KEYREVOKE);
return TRUE;
case ID_KEYMISC_TRUSTPATH:
- idx = listview_get_curr_pos( kmi->lv );
- if( idx == -1 ) {
- msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR );
+ if (kmi->lv_idx == -1) {
+ msg_box (dlg, _("Please select a key."), _("Key Manager"), MB_ERR);
return TRUE;
}
- listview_get_item_text( kmi->lv, idx, 0, uid, sizeof uid -1 );
- listview_get_item_text( kmi->lv, idx, 1, keyid, sizeof keyid -1 );
- if( km_check_for_seckey( kmi->lv, idx, NULL ) ) {
+ listview_get_item_text( kmi->lv, kmi->lv_idx, 0, uid, sizeof uid -1 );
+ listview_get_item_text( kmi->lv, kmi->lv_idx, 1, keyid, sizeof keyid -1 );
+ if( km_check_for_seckey( kmi->lv, kmi->lv_idx, NULL ) ) {
msg_box( dlg, _("It does not make any sense with a key pair!"), _("Key Manager"), MB_OK );
- return FALSE;
+ return TRUE;
}
memset (&k, 0, sizeof (k));
k.keyid = keyid;
@@ -1179,87 +1232,85 @@
_("List Trust Path"), IDS_WINPT_KEYTRUST );
return TRUE;
- case ID_KEYMISC_CHECKSIGS:
- idx = listview_get_curr_pos (kmi->lv);
- if( idx == -1 ) {
- msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR );
- return FALSE;
+ case ID_KEYMISC_CHECKSIGS:
+ if (kmi->lv_idx == -1) {
+ msg_box (dlg, _("Please select a key."), _("Key Manager"), MB_ERR);
+ return TRUE;
}
- listview_get_item_text (kmi->lv, idx, 0, uid, DIM (uid)-1);
- listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1);
+ listview_get_item_text (kmi->lv, kmi->lv_idx, 0, uid, DIM (uid)-1);
+ listview_get_item_text (kmi->lv, kmi->lv_idx, 1, keyid, DIM (keyid)-1);
memset (&k, 0, sizeof (k));
k.keyid = keyid;
k.uid = uid;
- k.ctx = (gpgme_key_t)listview_get_item2 (kmi->lv, idx);
+ k.ctx = (gpgme_key_t)listview_get_item2 (kmi->lv, kmi->lv_idx);
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYSIG, dlg,
keysig_dlg_proc, (LPARAM)&k,
_("Key Signature List" ), IDS_WINPT_KEYSIG);
return TRUE;
- case ID_KEYMISC_PROPS:
- idx = listview_get_curr_pos( kmi->lv );
- if( idx == -1 ) {
+ case ID_KEYMISC_PROPS:
+ if (kmi->lv_idx == -1) {
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR );
- return FALSE;
+ return TRUE;
}
- listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1);
- listview_get_item_text (kmi->lv, idx, 2, type, DIM (type)-1);
+ listview_get_item_text (kmi->lv, kmi->lv_idx, 1, keyid, DIM (keyid)-1);
+ listview_get_item_text (kmi->lv, kmi->lv_idx, 2, type, DIM (type)-1);
memset (&k, 0, sizeof (k));
k.key_pair = 0;
k.keyid = keyid;
if( !strcmp( type, "pub/sec" ) || !strcmp( type, "pub/crd" ) )
k.key_pair = 1;
k.callback.ctl = kmi->lv;
- k.callback.idx = idx;
- k.is_v3 = km_key_is_v3 (kmi->lv, idx);
+ k.callback.idx = kmi->lv_idx;
+ k.is_v3 = km_key_is_v3 (kmi->lv, kmi->lv_idx);
dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_KEYPROPS, dlg,
keyprops_dlg_proc, (LPARAM)&k,
_("Key Properties"), IDS_WINPT_KEYPROPS );
if (k.callback.new_val != 0) {
t = get_key_trust_str (k.callback.new_val);
- listview_add_sub_item (kmi->lv, idx, 6, t);
+ listview_add_sub_item (kmi->lv, kmi->lv_idx, 6, t);
}
return TRUE;
case ID_KEYMISC_RECACHE:
/* If there is already a reload request, don't bother the user with a message. */
- if (keycache_get_reload () == 1)
- idx = IDYES;
+ if (keycache_get_reload() == 1)
+ l_idx = IDYES;
else {
char inf[256];
_snprintf (inf, sizeof (inf) -1,
_("This is only useful when the keyring has been "
"modified (sign a key...).\n"
"Do you really want to reload the keycache?"));
- idx = msg_box (dlg, inf, _("Key Manager"), MB_YESNO);
+ l_idx = msg_box (dlg, inf, _("Key Manager"), MB_YESNO);
}
- if( idx == IDYES ) {
+ if (l_idx == IDYES) {
rcs.kr_reload = rcs.kr_update = 1;
rcs.tr_update = 0;
- DialogBoxParam( glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, dlg,
- keycache_dlg_proc, (LPARAM)&rcs );
- c = keycache_get_ctx( 1 );
- if( !c )
- BUG( dlg );
- keylist_reload( kmi->lv, c, KEYLIST_LIST, KEY_SORT_USERID );
+ DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, dlg,
+ keycache_dlg_proc, (LPARAM)&rcs);
+ c = keycache_get_ctx (1);
+ if (!c)
+ BUG (dlg);
+ keylist_reload (kmi->lv, c, KEYLIST_LIST, KEY_SORT_USERID);
refresh_keys = 0;
}
return TRUE;
case ID_KEYMISC_REBUILD:
- name=NULL;
+ name = NULL;
gpg_rebuild_cache (&name);
- if (name) {
- char *p = strchr (name, '\n');
- show_msg (dlg, 2000, p? name + (p-name)+1 : name);
- free (name);
+ if (name != NULL) {
+ char *line = strchr (name, '\n');
+ show_msg (dlg, 2000, line? name + (line-name)+1 : name);
+ safe_free (name);
}
return TRUE;
case ID_KEYMISC_NEWKEY:
memset (&genkey, 0, sizeof (genkey));
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYGEN, dlg,
- keygen_dlg_proc, (LPARAM)&genkey, _("Key Generation"),
+ keygen_dlg_proc, (LPARAM)&genkey, _("Key Generation"),
IDS_WINPT_KEYGEN);
if (genkey.newkey != NULL) {
keylist_add_key (kmi->lv, KEYLIST_LIST, genkey.newkey);
@@ -1268,22 +1319,24 @@
return TRUE;
case ID_KEYMISC_CARDNEW:
- if( !scard_support ) {
- msg_box( dlg, _("Smart Card support is not available."), _("Key Manager"), MB_INFO );
+ if (!scard_support) {
+ msg_box (dlg, _("Smart Card support is not available."),
+ _("Key Manager"), MB_INFO);
return TRUE;
}
- dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_CARD_KEYGEN, dlg,
+ dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_CARD_KEYGEN, dlg,
card_keygen_dlg_proc, 0, _("Card Key Generation"),
- IDS_WINPT_CARD_KEYGEN );
+ IDS_WINPT_CARD_KEYGEN);
/* XXX: use new code */
- if( keycache_get_reload() )
- send_cmd_id( dlg, ID_KEYMISC_RECACHE );
+ if (keycache_get_reload ())
+ send_cmd_id (dlg, ID_KEYMISC_RECACHE);
return TRUE;
case ID_KEYMISC_KEYWIZARD:
memset (&genkey, 0, sizeof (genkey));
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYWIZARD, dlg,
- keygen_wizard_dlg_proc, (LPARAM)&genkey, _("Key Generation Wizard"),
+ keygen_wizard_dlg_proc, (LPARAM)&genkey,
+ _("Key Generation Wizard"),
IDS_WINPT_KEYWIZARD);
if (genkey.newkey != NULL) {
keylist_add_key (kmi->lv, KEYLIST_LIST, genkey.newkey);
@@ -1293,9 +1346,9 @@
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"), IDS_WINPT_KEYSERVER);
+ dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYSERVER, dlg,
+ keyserver_dlg_proc, (LPARAM)&genkey, _("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);
@@ -1328,15 +1381,14 @@
break;
case ID_KEYMISC_EXPORT:
- idx = listview_get_curr_pos (kmi->lv);
- if (idx == -1) {
+ if (kmi->lv_idx == -1) {
msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR );
return TRUE;
}
if (listview_count_items (kmi->lv, 1) > 1)
name = m_strdup ("Exported_GPG_Keys.asc");
else {
- listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1);
+ listview_get_item_text (kmi->lv, kmi->lv_idx, 1, keyid, DIM (keyid)-1);
name = gen_export_filename (keyid, 0);
}
t = get_filesave_dlg (dlg, _("Choose Name for Key File"), NULL, name);
@@ -1347,41 +1399,40 @@
return TRUE;
case ID_KEYMISC_EXPORT_PRIVKEY:
- idx = listview_get_curr_pos( kmi->lv );
- if( idx == -1 ) {
- msg_box( dlg, _("Please select a key."), _("Key Manager"), MB_ERR );
+ if (kmi->lv_idx == -1) {
+ msg_box (dlg, _("Please select a key."), _("Key Manager"), MB_ERR);
return TRUE;
}
- if( !km_check_for_seckey( kmi->lv, idx, NULL ) ) {
- msg_box( dlg, _("There is no corresponding secret key for this key."),
- _("Key Manager"), MB_ERR );
+ if( !km_check_for_seckey( kmi->lv, kmi->lv_idx, NULL ) ) {
+ msg_box (dlg, _("There is no corresponding secret key for this key."),
+ _("Key Manager"), MB_ERR);
return TRUE;
}
- if( listview_count_items( kmi->lv, 1 ) > 1 ) {
- msg_box( dlg, _("You can only export one secret key."), _("Key Manager"), MB_ERR );
+ if (listview_count_items (kmi->lv, 1) > 1) {
+ msg_box (dlg, _("You can only export one secret key."),
+ _("Key Manager"), MB_ERR);
return TRUE;
}
- idx = msg_box( dlg,
+ i = msg_box (dlg,
_("This operation will export your *SECRET* key!\n\n"
"Never send this key to ANYONE, it should be available\n"
"ONLY on your machine and you may use this function\n"
"to copy the key to a safe place.\n\n"
"Do you really want to export the key?"),
- _("WARNING"), MB_INFO|MB_YESNO );
- if( idx == IDYES ) {
- idx = listview_get_curr_pos( kmi->lv );
- listview_get_item_text( kmi->lv, idx, 1, keyid, sizeof (keyid)-8 );
+ _("WARNING"), MB_INFO|MB_YESNO);
+ if( i == IDYES ) {
+ listview_get_item_text( kmi->lv, kmi->lv_idx, 1, keyid, sizeof (keyid)-8 );
name = gen_export_filename (keyid, 1);
t = get_filesave_dlg (dlg, _("Choose Name for Key File"), NULL, name);
if (t != NULL)
km_privkey_export (dlg, kmi->lv, t);
}
- return TRUE;
+ return TRUE;
case ID_KEYMISC_INFO:
- dialog_box_param( glob_hinst, (LPCSTR)IDD_WINPT_ABOUT, glob_hwnd,
+ dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_ABOUT, glob_hwnd,
about_winpt_dlg_proc, 0, _("About WinPT"),
- IDS_WINPT_ABOUT );
+ IDS_WINPT_ABOUT);
break;
case ID_KEYMISC_HELP:
@@ -1394,27 +1445,25 @@
_("Ownertrust"), IDS_WINPT_OWNERTRUST );
break;
- case ID_KEYMISC_EDITKEY:
- idx = listview_get_curr_pos (kmi->lv);
- if (idx == -1)
+ case ID_KEYMISC_EDITKEY:
+ if (kmi->lv_idx == -1)
break;
- listview_get_item_text (kmi->lv, idx, 1, keyid, sizeof (keyid)-1);
+ listview_get_item_text (kmi->lv, kmi->lv_idx, 1, keyid, sizeof (keyid)-1);
/* XXX: pub/crd = secret key does not work */
memset (&k, 0, sizeof (k));
- k.is_protected = km_check_if_protected (kmi->lv, idx);
- k.key_pair = km_check_for_seckey (kmi->lv, idx, NULL);
+ k.is_protected = km_check_if_protected (kmi->lv, kmi->lv_idx);
+ k.key_pair = km_check_for_seckey (kmi->lv, kmi->lv_idx, NULL);
k.keyid = keyid;
- k.is_v3 = km_key_is_v3 (kmi->lv, idx);
- k.flags = km_get_key_status (kmi->lv, idx);
+ k.is_v3 = km_key_is_v3 (kmi->lv, kmi->lv_idx);
+ k.flags = km_get_key_status (kmi->lv, kmi->lv_idx);
dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYEDIT, dlg,
keyedit_main_dlg_proc, (LPARAM)&k,
_("Key Edit"), IDS_KEYCTX_EDIT);
if (k.update)
- update_key (kmi->lv, idx, keyid, 1);
+ update_key (kmi->lv, kmi->lv_idx, keyid, 1);
break;
case ID_KEYMISC_COPY:
- km_index = listview_get_curr_pos (kmi->lv);
km_clip_export (dlg, kmi->lv);
break;
@@ -1423,12 +1472,11 @@
break;
case ID_KEYMISC_PASTE:
- km_index = -1;
km_clip_import (dlg);
break;
case ID_KEYCTX_SETPREFKS:
- listview_get_item_text (kmi->lv, idx, 1, keyid, DIM(keyid)-1);
+ listview_get_item_text (kmi->lv, kmi->lv_idx, 1, keyid, DIM(keyid)-1);
memset (&k, 0, sizeof (k));
k.keyid = keyid;
keyedit_set_pref_keyserver (&k, dlg);
@@ -1477,51 +1525,47 @@
break;
case ID_KEYCTX_ADDKEY:
- idx = listview_get_curr_pos (kmi->lv);
- listview_get_item_text( kmi->lv, idx, 1, keyid, DIM (keyid)-1);
+ listview_get_item_text (kmi->lv, kmi->lv_idx, 1, keyid, DIM (keyid)-1);
memset (&k, 0, sizeof (k));
- k.key_pair = km_check_for_seckey (kmi->lv, idx, NULL);
- k.is_protected = km_check_if_protected (kmi->lv, idx);
+ k.key_pair = km_check_for_seckey (kmi->lv, kmi->lv_idx, NULL);
+ k.is_protected = km_check_if_protected (kmi->lv, kmi->lv_idx);
k.keyid = keyid;
keyedit_add_subkey (&k, dlg, NULL);
if (k.update)
- update_key (kmi->lv, idx, keyid, 1);
+ update_key (kmi->lv, kmi->lv_idx, keyid, 1);
break;
case ID_KEYCTX_ADDUID:
- idx = listview_get_curr_pos (kmi->lv);
- listview_get_item_text( kmi->lv, idx, 1, keyid, DIM (keyid)-1);
+ listview_get_item_text( kmi->lv, kmi->lv_idx, 1, keyid, DIM (keyid)-1);
memset (&k, 0, sizeof (k));
- k.key_pair = km_check_for_seckey (kmi->lv, idx, NULL);
- k.is_protected = km_check_if_protected (kmi->lv, idx);
+ k.key_pair = km_check_for_seckey (kmi->lv, kmi->lv_idx, NULL);
+ k.is_protected = km_check_if_protected (kmi->lv, kmi->lv_idx);
k.keyid = keyid;
keyedit_add_userid (&k, dlg, NULL);
if (k.update)
- update_key (kmi->lv, idx, keyid, 1);
+ update_key (kmi->lv, kmi->lv_idx, keyid, 1);
break;
case ID_KEYCTX_ADDREV:
- idx = listview_get_curr_pos (kmi->lv);
- listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1);
+ listview_get_item_text (kmi->lv, kmi->lv_idx, 1, keyid, DIM (keyid)-1);
memset (&k, 0, sizeof (k));
k.keyid = keyid;
- k.is_protected = km_check_if_protected (kmi->lv, idx);
- k.key_pair = km_check_for_seckey( kmi->lv, idx, NULL );
+ k.is_protected = km_check_if_protected (kmi->lv, kmi->lv_idx);
+ k.key_pair = km_check_for_seckey( kmi->lv, kmi->lv_idx, NULL );
keyedit_add_revoker (&k, dlg);
if (k.update)
- update_key (kmi->lv, idx, keyid, 1);
+ update_key (kmi->lv, kmi->lv_idx, keyid, 1);
break;
case ID_KEYCTX_ADDPHOTO:
- idx = listview_get_curr_pos (kmi->lv);
- listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1);
+ listview_get_item_text (kmi->lv, kmi->lv_idx, 1, keyid, DIM (keyid)-1);
memset (&k, 0, sizeof (k));
k.keyid = keyid;
- k.is_protected = km_check_if_protected (kmi->lv, idx);
- k.key_pair = km_check_for_seckey (kmi->lv, idx, NULL);
+ k.is_protected = km_check_if_protected (kmi->lv, kmi->lv_idx);
+ k.key_pair = km_check_for_seckey (kmi->lv, kmi->lv_idx, NULL);
keyedit_add_photo (&k, dlg);
if (k.update)
- update_key (kmi->lv, idx, keyid, 1);
+ update_key (kmi->lv, kmi->lv_idx, keyid, 1);
break;
case ID_KEYCTX_KS_NL:
@@ -1543,50 +1587,46 @@
case ID_KEYCTX_UID_COPY:
/* XXX: add generic function to support multiple selection
with a callback */
- idx = listview_get_curr_pos( kmi->lv );
- listview_get_item_text( kmi->lv, idx, 0, uid, sizeof uid-1 );
+ listview_get_item_text( kmi->lv, kmi->lv_idx, 0, uid, sizeof uid-1 );
set_clip_text( NULL, uid, strlen( uid ) );
break;
case ID_KEYCTX_KEYID_COPY:
- idx = listview_get_curr_pos( kmi->lv );
- listview_get_item_text( kmi->lv, idx, 1, uid, sizeof uid-1 );
- set_clip_text( NULL, uid, strlen( uid ) );
+ listview_get_item_text (kmi->lv, kmi->lv_idx, 1, uid, sizeof uid-1);
+ set_clip_text (NULL, uid, strlen (uid));
break;
case ID_KEYCTX_FPR_COPY:
- idx = listview_get_curr_pos( kmi->lv );
- key = (gpgme_key_t) listview_get_item2 (kmi->lv, idx);
+ key = (gpgme_key_t) listview_get_item2 (kmi->lv, kmi->lv_idx);
if (key) {
- const char * s = get_key_fpr (key);
- set_clip_text (NULL, s? s : "", s? strlen (s): 0);
+ t = get_key_fpr (key);
+ set_clip_text (NULL, t? t : "", t? strlen (t): 0);
}
break;
case ID_KEYCTX_KINFO_COPY:
- idx = listview_get_curr_pos( kmi->lv );
- listview_get_item_text( kmi->lv, idx, 1, uid, sizeof uid-1 );
+ listview_get_item_text( kmi->lv, kmi->lv_idx, 1, uid, sizeof uid-1 );
km_set_clip_info( uid );
break;
case ID_KEYCTX_COPY:
- km_index = listview_get_curr_pos (kmi->lv);
km_clip_export (dlg, kmi->lv);
break;
- case ID_KEYCTX_PASTE:
- km_index = -1;
+ case ID_KEYCTX_PASTE:
km_clip_import (dlg);
break;
case ID_KEYCTX_DISABLE:
- idx = listview_get_curr_pos (kmi->lv);
- km_enable_disable_key (kmi->lv, dlg, idx, 0);
- break;
-
case ID_KEYCTX_ENABLE:
- idx = listview_get_curr_pos (kmi->lv);
- km_enable_disable_key (kmi->lv, dlg, idx, 1);
+ i = LOWORD (wparam) == ID_KEYCTX_ENABLE? 1 : 0;
+ listview_get_item_text (kmi->lv, kmi->lv_idx, KM_COL_KEYID,
+ keyid, DIM (keyid)-1);
+ rc = km_enable_disable_key (kmi->lv, dlg, kmi->lv_idx, i);
+ if (!rc)
+ update_key (kmi->lv, kmi->lv_idx, keyid, 0);
+ /* XXX: switching a key from disabled -> enabled. does not
+ change the validity field in the KM. */
break;
case ID_KEYCTX_LISTSIGS:
@@ -1594,43 +1634,27 @@
break;
case ID_KEYCTX_MAXTRUST:
- idx = listview_get_curr_pos (kmi->lv);
- listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1);
- rc = km_set_implicit_trust (dlg, kmi->lv, idx);
+ listview_get_item_text (kmi->lv, kmi->lv_idx, 1, keyid, DIM (keyid)-1);
+ rc = km_set_implicit_trust (dlg, kmi->lv, kmi->lv_idx);
if (!rc)
- update_key (kmi->lv, idx, keyid, 0);
+ update_key (kmi->lv, kmi->lv_idx, keyid, 0);
break;
case ID_KEYCTX_SETDEFKEY:
- idx = listview_get_curr_pos (kmi->lv);
- if (!km_check_key_status (kmi->lv, idx)) {
- listview_get_item_text (kmi->lv, idx, 1, keyid, DIM (keyid)-1);
+ if (!km_check_key_status (kmi->lv, kmi->lv_idx)) {
+ listview_get_item_text (kmi->lv, kmi->lv_idx, 1, keyid, DIM (keyid)-1);
rc = set_gnupg_default_key (keyid);
if (rc)
- msg_box( dlg, winpt_strerror (rc), _("Key Manager"), MB_ERR);
+ msg_box (dlg, winpt_strerror (rc), _("Key Manager"), MB_ERR);
km_update_default_key_str (kmi->statbar);
}
break;
- #if 0 /* XXX */
case ID_GROUP_NEW:
- memset (&gcb, 0, sizeof (gcb));
- gcb.gc = gc;
- dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_GROUP, glob_hwnd,
- group_manager_dlg_proc, (LPARAM)&gcb, _("New Group"),
- IDS_WINPT_GROUP);
- if( gcb.use_name )
- treeview_add_item( GetDlgItem(dlg, IDC_KEYMISC_GROUP), NULL, gcb.name );
- return TRUE;
-
case ID_GROUP_PASTE:
- km_groups_add (gc, kmi->lv, km_index);
- break;
-
case ID_GROUP_DELETE:
- km_groups_del (gc);
- break;
- #endif
+ /* XXX: Implement group manager. */
+ return TRUE;
}
break;
Modified: trunk/THANKS
===================================================================
--- trunk/THANKS 2005-12-12 16:21:10 UTC (rev 122)
+++ trunk/THANKS 2005-12-14 09:01:45 UTC (rev 123)
@@ -57,6 +57,7 @@
PPLF pgpenfrancias at bigfoot.com
Ralf Kreutzmann ralf.kreutzmann at equipmente.de
Richard V. Wielgosz rich at cnylug.org
+Shane M. Coughlan shane at shaneland.co.uk
Susumu Takahashi s.takahashi at tortoise.jp
Scirè Salvatore scires at tin.it
Thomas Henlich henlich at mmers1.mw.tu-dresden.de
More information about the Winpt-commits
mailing list