[Winpt-commits] r72 - trunk/Src
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Mon Nov 7 13:48:35 CET 2005
Author: twoaday
Date: 2005-11-07 13:48:34 +0100 (Mon, 07 Nov 2005)
New Revision: 72
Modified:
trunk/Src/ChangeLog
trunk/Src/wptMainProc.cpp
Log:
Patch for better encrypt-only environment.
Modified: trunk/Src/ChangeLog
===================================================================
--- trunk/Src/ChangeLog 2005-11-05 12:32:29 UTC (rev 71)
+++ trunk/Src/ChangeLog 2005-11-07 12:48:34 UTC (rev 72)
@@ -1,3 +1,8 @@
+2005-11-07 Timo Schulz <ts at g10code.com>
+
+ * wptMainProc.cpp (winpt_main_proc): Disable
+ some menu items when no secret key is available.
+
2005-11-05 Timo Schulz <ts at g10code.com>
More minor changes to avoid GCC warnings.
Modified: trunk/Src/wptMainProc.cpp
===================================================================
--- trunk/Src/wptMainProc.cpp 2005-11-05 12:32:29 UTC (rev 71)
+++ trunk/Src/wptMainProc.cpp 2005-11-07 12:48:34 UTC (rev 72)
@@ -59,7 +59,7 @@
gpgme_key_t key;
char tmp[128+64+1];
- switch( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
pc = keycache_get_ctx (1);
while (!gpg_keycache_next_key (pc, 0, &key)) {
@@ -292,9 +292,19 @@
else
msg_box (hwnd, _("Unknown OpenPGP type."), _("Clipboard"), MB_ERR);
}
-} /* clip_gpg_dlg */
+}
+static bool
+secret_key_available (void)
+{
+ gpg_keycache_t sec = keycache_get_ctx (0);
+ if (!sec || gpg_keycache_get_size (sec) == 0)
+ return false;
+ return true;
+}
+
+
/* Load the Card Manager with the current card. */
static void
load_smartcard (void)
@@ -394,7 +404,7 @@
Shell_NotifyIcon (NIM_DELETE, &NID);
PostQuitMessage (0);
ExitProcess (0);
- return 0;
+ break;
case WM_USER:
switch (lparam) {
@@ -408,7 +418,7 @@
GetCursorPos (&p);
hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT));
popup = GetSubMenu (hm, 0);
-#ifndef LANG_DE
+
set_menu_text( popup, ID_WINPT_FILE, _("File Manager") );
set_menu_text( popup, ID_WINPT_KEY, _("Key Manager") );
set_menu_text( popup, ID_WINPT_CARD, _("Card Manager") );
@@ -425,6 +435,7 @@
set_menu_text (popup, ID_WINPT_QUIT, _("Exit"));
set_menu_text (popup, ID_WINPT_SYMENC, _("Symmetric"));
set_menu_text (popup, ID_WINPT_ENCRYPT, _("Encrypt"));
+ set_menu_text (popup, ID_WINPT_SIGN, _("Sign"));
set_menu_text (popup, ID_WINPT_SIGNENCRYPT, _("Sign && Encrypt"));
set_menu_text (popup, ID_WINPT_DECRYPT, _("Decrypt/Verify"));
set_menu_text (popup, ID_WINPT_VERIFY, _("Verify"));
@@ -432,16 +443,21 @@
set_menu_text (popup, ID_WINPT_CURRWND_SIGNENCRYPT, _("Sign && Encrypt"));
set_menu_text (popup, ID_WINPT_CURRWND_DECRYPT_VERIFY, _("Decrypt/Verify"));
set_menu_text (popup, ID_WINPT_CURRWND_SIGN, _("Sign"));
+ if (!secret_key_available ()) {
+ set_menu_state (popup, ID_WINPT_SIGN, MF_DISABLED|MF_GRAYED);
+ set_menu_state (popup, ID_WINPT_CURRWND_SIGN, MF_DISABLED|MF_GRAYED);
+ set_menu_state (popup, ID_WINPT_SIGNENCRYPT, MF_DISABLED|MF_GRAYED);
+ set_menu_state (popup, ID_WINPT_CURRWND_SIGNENCRYPT, MF_DISABLED|MF_GRAYED);
+ }
/* change popup texts */
set_menu_text_bypos (popup, 6, _("Clipboard"));
set_menu_text_bypos (popup, 7, _("Current Window"));
set_menu_text_bypos (popup, 9, _("Preferences"));
-#endif
- TrackPopupMenu( popup, TPM_RIGHTALIGN, p.x, p.y, 0, hwnd, NULL );
- PostMessage( hwnd, WM_USER, 0, 0 );
- DestroyMenu( popup );
- DestroyMenu( hm );
+ TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, hwnd, NULL);
+ PostMessage (hwnd, WM_USER, 0, 0);
+ DestroyMenu (popup);
+ DestroyMenu (hm);
break;
case WM_LBUTTONDBLCLK:
More information about the Winpt-commits
mailing list