From 07c9ff590e89f00ae3cd480096206842762b3fd9 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sat, 20 Jan 2007 05:42:30 +0000 Subject: [PATCH] NIM - Context sensitive system tray menu and more Adds context sensitive menus for renew and destroy to the system tray menu. Select either all identities or one of the identities with credentials. Increases the API to 1.1.9 and adds a new interactive callback mechanism. ticket: new component: windows git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19077 dc483132-0cff-0310-8789-dd5450dbe970 --- src/windows/identity/apiversion.txt | 11 + src/windows/identity/config/Makefile.w2k | 6 +- src/windows/identity/config/Makefile.w32 | 6 +- src/windows/identity/doc/footer.html | 2 +- src/windows/identity/doc/main_page.h | 5 +- src/windows/identity/kcreddb/identity.c | 7 +- .../identity/plugins/common/dynimport.c | 30 +- src/windows/identity/ui/credfuncs.c | 36 +++ src/windows/identity/ui/credfuncs.h | 4 + src/windows/identity/ui/intaction.h | 44 +++ src/windows/identity/ui/lang/en_us/khapp.rc | 7 + src/windows/identity/ui/main.c | 3 +- src/windows/identity/ui/mainmenu.c | 287 +++++++++++++++++- src/windows/identity/ui/mainmenu.h | 3 + src/windows/identity/ui/mainwnd.c | 39 ++- src/windows/identity/ui/newcredwnd.c | 4 +- src/windows/identity/ui/reqdaemon.c | 6 +- src/windows/identity/ui/resource.h | 7 + src/windows/identity/ui/toolbar.c | 7 +- src/windows/identity/ui/uibind.c | 58 ++++ src/windows/identity/uilib/action.c | 18 +- src/windows/identity/uilib/actions.csv | 4 + src/windows/identity/uilib/khactiondef.h | 9 +- src/windows/identity/uilib/khuidefs.h | 7 + 24 files changed, 569 insertions(+), 41 deletions(-) create mode 100644 src/windows/identity/ui/intaction.h create mode 100644 src/windows/identity/ui/uibind.c diff --git a/src/windows/identity/apiversion.txt b/src/windows/identity/apiversion.txt index 4399861e8..9681ccc1c 100644 --- a/src/windows/identity/apiversion.txt +++ b/src/windows/identity/apiversion.txt @@ -1,4 +1,5 @@ # Copyright (c) 2004 Massachusetts Institute of Technology +# Copyright (c) 2007 Secure Endpoints Inc. # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files @@ -214,3 +215,13 @@ Date=(TBD) +KCDB_OP_DELCONFIG # notification that the configuration information for an identity is to be removed. + + +#---------------------------------------------------------------- +Version=7 +AppVersion=1.1.9.0 +Date=(TBD) +# Released with KFW 3.2.0 + ++KHUI_ACTION_UICB +# Internal action to dispatch a UI callback \ No newline at end of file diff --git a/src/windows/identity/config/Makefile.w2k b/src/windows/identity/config/Makefile.w2k index b9902bd90..f2977786c 100644 --- a/src/windows/identity/config/Makefile.w2k +++ b/src/windows/identity/config/Makefile.w2k @@ -4,7 +4,7 @@ # in the build tree. # # Copyright (c) 2004,2005,2006 Massachusetts Institute of Technology -# Copyright (c) 2006 Secure Endpoints Inc. +# Copyright (c) 2006,2007 Secure Endpoints Inc. # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files @@ -47,7 +47,7 @@ KHIMAIRA_WIN32_CONFIG=1 # Version info NETIDMGR_VERSION_MAJOR=1 NETIDMGR_VERSION_MINOR=1 -NETIDMGR_VERSION_PATCH=8 +NETIDMGR_VERSION_PATCH=9 NETIDMGR_VERSION_AUX=0 NETIDMGR_RELEASEDESC= @@ -58,7 +58,7 @@ NETIDMGR_RELEASEDESC= # # Changes to the API version numbers should be documented in # apiversion.txt at the root of the source tree. -NETIDMGR_VERSION_API=6 +NETIDMGR_VERSION_API=7 # Minimum backwards compatible version. API versions from # NETIDMGR_VERSION_API_MINCOMPAT through NETIDMGR_VERSION_API diff --git a/src/windows/identity/config/Makefile.w32 b/src/windows/identity/config/Makefile.w32 index 8ede1dbae..e327a7075 100644 --- a/src/windows/identity/config/Makefile.w32 +++ b/src/windows/identity/config/Makefile.w32 @@ -4,7 +4,7 @@ # in the build tree. # # Copyright (c) 2004,2005,2006 Massachusetts Institute of Technology -# Copyright (c) 2006 Secure Endpoints Inc. +# Copyright (c) 2006,2007 Secure Endpoints Inc. # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files @@ -47,7 +47,7 @@ KHIMAIRA_WIN32_CONFIG=1 # Version info NETIDMGR_VERSION_MAJOR=1 NETIDMGR_VERSION_MINOR=1 -NETIDMGR_VERSION_PATCH=8 +NETIDMGR_VERSION_PATCH=9 NETIDMGR_VERSION_AUX=0 NETIDMGR_RELEASEDESC= @@ -58,7 +58,7 @@ NETIDMGR_RELEASEDESC= # # Changes to the API version numbers should be documented in # apiversion.txt at the root of the source tree. -NETIDMGR_VERSION_API=6 +NETIDMGR_VERSION_API=7 # Minimum backwards compatible version. API versions from # NETIDMGR_VERSION_API_MINCOMPAT through NETIDMGR_VERSION_API diff --git a/src/windows/identity/doc/footer.html b/src/windows/identity/doc/footer.html index 13314c2b0..fb3b621ce 100644 --- a/src/windows/identity/doc/footer.html +++ b/src/windows/identity/doc/footer.html @@ -5,7 +5,7 @@
Generated on $datetime for $projectname $projectnumber by Doxygen $doxygenversion
- © 2004 Massachusetts Institute of Technology. Contact khimaira@mit.edu
+ © 2004-2007 Massachusetts Institute of Technology. Contact khimaira@mit.edu
diff --git a/src/windows/identity/doc/main_page.h b/src/windows/identity/doc/main_page.h index 415a8e3f3..34b3d1d72 100644 --- a/src/windows/identity/doc/main_page.h +++ b/src/windows/identity/doc/main_page.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Massachusetts Institute of Technology + * Copyright (c) 2007 Secure Endpoints Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -39,7 +40,7 @@ - \subpage bugs - \subpage releases - © 2004 Massachusetts Institute of Technology + © 2004-2007 Massachusetts Institute of Technology */ /*! @@ -49,7 +50,7 @@ \section license_l MIT License - Copyright © 2004 Massachusetts Institute of Technology + Copyright © 2004,2005,2006,2007 Massachusetts Institute of Technology Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/src/windows/identity/kcreddb/identity.c b/src/windows/identity/kcreddb/identity.c index 6057b6f2c..3f6020682 100644 --- a/src/windows/identity/kcreddb/identity.c +++ b/src/windows/identity/kcreddb/identity.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Massachusetts Institute of Technology + * Copyright (c) 2007 Secure Endpoints Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -998,9 +999,8 @@ kcdb_identity_get_attr(khm_handle vid, /* we should never hit this case */ #ifdef DEBUG assert(FALSE); -#else - code = KHM_ERROR_INVALID_OPERATION; #endif + code = KHM_ERROR_INVALID_OPERATION; } else { #endif code = type->dup( @@ -1091,9 +1091,8 @@ kcdb_identity_get_attr_string(khm_handle vid, if(attrib->flags & KCDB_ATTR_FLAG_COMPUTED) { #ifdef DEBUG assert(FALSE); -#else - code = KHM_ERROR_INVALID_OPERATION; #endif + code = KHM_ERROR_INVALID_OPERATION; } else { #endif if(kcdb_buf_exist(&id->buf, slot)) { diff --git a/src/windows/identity/plugins/common/dynimport.c b/src/windows/identity/plugins/common/dynimport.c index 311e4cf93..b3d764476 100644 --- a/src/windows/identity/plugins/common/dynimport.c +++ b/src/windows/identity/plugins/common/dynimport.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Massachusetts Institute of Technology +* Copyright (c) 2007 Secure Endpoints Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -25,8 +26,7 @@ /* $Id$ */ #include -#include -#include +#include #include HINSTANCE hKrb4 = 0; @@ -364,30 +364,36 @@ khm_int32 init_imports(void) { OSVERSIONINFO osvi; int imp_rv = 1; -#define CKRV if(!imp_rv) goto _err_ret +#define CKRV(m) \ + do { \ + if(!imp_rv) { \ + _reportf(L"Can't locate all required exports from module [%S]", (m)); \ + goto _err_ret; \ + } \ + } while (FALSE) #ifndef _WIN64 imp_rv = LoadFuncs(KRB4_DLL, k4_fi, &hKrb4, 0, 1, 0, 0); - CKRV; + CKRV(KRB4_DLL); #endif imp_rv = LoadFuncs(KRB5_DLL, k5_fi, &hKrb5, 0, 1, 0, 0); - CKRV; + CKRV(KRB5_DLL); imp_rv = LoadFuncs(COMERR_DLL, ce_fi, &hComErr, 0, 0, 1, 0); - CKRV; + CKRV(COMERR_DLL); imp_rv = LoadFuncs(SERVICE_DLL, service_fi, &hService, 0, 1, 0, 0); - CKRV; + CKRV(SERVICE_DLL); imp_rv = LoadFuncs(SECUR32_DLL, lsa_fi, &hSecur32, 0, 1, 1, 1); - CKRV; + CKRV(SECUR32_DLL); imp_rv = LoadFuncs(KRB524_DLL, k524_fi, &hKrb524, 0, 1, 1, 1); - CKRV; + CKRV(KRB524_DLL); imp_rv = LoadFuncs(PROFILE_DLL, profile_fi, &hProfile, 0, 1, 0, 0); - CKRV; + CKRV(PROFILE_DLL); imp_rv = LoadFuncs(CCAPI_DLL, ccapi_fi, &hCCAPI, 0, 1, 0, 0); /* CCAPI_DLL is optional. No error check. */ @@ -405,7 +411,7 @@ khm_int32 init_imports(void) { { // Windows 9x imp_rv = LoadFuncs(TOOLHELPDLL, toolhelp_fi, &hToolHelp32, 0, 1, 0, 0); - CKRV; + CKRV(TOOLHELPDLL); hPsapi = 0; } @@ -413,7 +419,7 @@ khm_int32 init_imports(void) { { // Windows NT imp_rv = LoadFuncs(PSAPIDLL, psapi_fi, &hPsapi, 0, 1, 0, 0); - CKRV; + CKRV(PSAPIDLL); hToolHelp32 = 0; } diff --git a/src/windows/identity/ui/credfuncs.c b/src/windows/identity/ui/credfuncs.c index 530ef0852..dcb70480e 100644 --- a/src/windows/identity/ui/credfuncs.c +++ b/src/windows/identity/ui/credfuncs.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Massachusetts Institute of Technology + * Copyright (c) 2007 Secure Endpoints Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -504,6 +505,41 @@ void khm_cred_destroy_creds(khm_boolean sync, khm_boolean quiet) _end_task(); } +void khm_cred_destroy_identity(khm_handle identity) +{ + khui_action_context * pctx; + wchar_t idname[KCDB_IDENT_MAXCCH_NAME]; + khm_size cb; + + if (identity == NULL) + return; + + pctx = PMALLOC(sizeof(*pctx)); +#ifdef DEBUG + assert(pctx); +#endif + + khui_context_create(pctx, + KHUI_SCOPE_IDENT, + identity, + KCDB_CREDTYPE_INVALID, + NULL); + + cb = sizeof(idname); + kcdb_identity_get_name(identity, idname, &cb); + + _begin_task(KHERR_CF_TRANSITIVE); + _report_sr1(KHERR_NONE, IDS_CTX_DESTROY_ID, _dupstr(idname)); + _describe(); + + kmq_post_message(KMSG_CRED, + KMSG_CRED_DESTROY_CREDS, + 0, + (void *) pctx); + + _end_task(); +} + void khm_cred_renew_identity(khm_handle identity) { khui_new_creds * c; diff --git a/src/windows/identity/ui/credfuncs.h b/src/windows/identity/ui/credfuncs.h index 677d27945..379573ff5 100644 --- a/src/windows/identity/ui/credfuncs.h +++ b/src/windows/identity/ui/credfuncs.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Massachusetts Institute of Technology + * Copyright (c) 2007 Secure Endpoints Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -34,6 +35,9 @@ void khm_cred_destroy_creds(khm_boolean sync, khm_boolean quiet); +void +khm_cred_destroy_identity(khm_handle identity); + void khm_cred_renew_identity(khm_handle identity); diff --git a/src/windows/identity/ui/intaction.h b/src/windows/identity/ui/intaction.h new file mode 100644 index 000000000..2b4a66a1f --- /dev/null +++ b/src/windows/identity/ui/intaction.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2007 Secure Endpoints Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* $Id$ */ + +#ifndef __NETIDMGR_ACTION_H_INTERNAL +#define __NETIDMGR_ACTION_H_INTERNAL + +/* Internal declarations for exports and data structured used in + nidmgr32.dll and netidmgr.exe */ + +extern HWND khui_hwnd_main; + +typedef struct tag_khui_ui_callback_data { + khm_int32 magic; + khm_ui_callback cb; + void * rock; + khm_int32 rv; +} khui_ui_callback_data; + +#define KHUI_UICBDATA_MAGIC 0x8a08572a + +#endif diff --git a/src/windows/identity/ui/lang/en_us/khapp.rc b/src/windows/identity/ui/lang/en_us/khapp.rc index 96e8de6a5..862872dae 100644 --- a/src/windows/identity/ui/lang/en_us/khapp.rc +++ b/src/windows/identity/ui/lang/en_us/khapp.rc @@ -782,6 +782,13 @@ STRINGTABLE BEGIN IDS_NC_REN_FAILED_TITLE_I "Failed to renew creds for %s" IDS_CFG_IDNAME_NON "No identity selected. Please select an identity and try again." + IDS_MENU_DESTROY_CRED "Destroy ..." + IDS_MENU_RENEW_CRED "Renew ..." + IDS_ACTION_DESTROY_ALL "All identities" + IDS_ACTION_RENEW_ALL "All identities" + IDS_IDACTION_RENEW "Renew credentials for %s" + IDS_IDACTION_DESTROY "Destroy credentials for %s" + IDS_CTX_DESTROY_ID "Destroying identity %1!s!" END #endif // English (U.S.) resources diff --git a/src/windows/identity/ui/main.c b/src/windows/identity/ui/main.c index e2210782f..c05fa6b7f 100644 --- a/src/windows/identity/ui/main.c +++ b/src/windows/identity/ui/main.c @@ -352,10 +352,11 @@ int _n_ui_propsheets = 0; void khm_add_property_sheet(khui_property_sheet * s) { if(_n_ui_propsheets < MAX_UI_PROPSHEETS) _ui_propsheets[_n_ui_propsheets++] = s; + else { #ifdef DEBUG - else assert(FALSE); #endif + } } void khm_del_property_sheet(khui_property_sheet * s) { diff --git a/src/windows/identity/ui/mainmenu.c b/src/windows/identity/ui/mainmenu.c index fc3a64b0c..c99cafafd 100644 --- a/src/windows/identity/ui/mainmenu.c +++ b/src/windows/identity/ui/mainmenu.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Massachusetts Institute of Technology + * Copyright (c) 2007 Secure Endpoints Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -561,6 +562,289 @@ LRESULT khm_menu_notify_main(LPNMHDR notice) { return ret; } +struct identity_action_map { + khm_handle identity; + khm_int32 renew_cmd; + khm_int32 destroy_cmd; + int refreshcycle; +}; + +#define IDMAP_ALLOC_INCR 8 + +struct identity_action_map * id_action_map = NULL; +khm_size n_id_action_map = 0; +khm_size nc_id_action_map = 0; + +int idcmd_refreshcycle = 0; + +static struct identity_action_map * +create_identity_cmd_map(khm_handle ident) { + + struct identity_action_map * actmap; + wchar_t idname[KCDB_IDENT_MAXCCH_NAME]; + wchar_t fmt[128]; + wchar_t tooltip[KHUI_MAXCCH_SHORT_DESC]; + khm_size cb; + + if (n_id_action_map + 1 > nc_id_action_map) { + nc_id_action_map = UBOUNDSS(n_id_action_map + 1, + IDMAP_ALLOC_INCR, + IDMAP_ALLOC_INCR); +#ifdef DEBUG + assert(nc_id_action_map > n_id_action_map + 1); +#endif + id_action_map = PREALLOC(id_action_map, + nc_id_action_map * sizeof(id_action_map[0])); +#ifdef DEBUG + assert(id_action_map); +#endif + ZeroMemory(&id_action_map[n_id_action_map], + sizeof(id_action_map[0]) * (nc_id_action_map - n_id_action_map)); + } + + actmap = &id_action_map[n_id_action_map]; + n_id_action_map++; + + cb = sizeof(idname); + kcdb_identity_get_name(ident, idname, &cb); + + actmap->identity = ident; + kcdb_identity_hold(ident); + + fmt[0] = L'\0'; + LoadString(khm_hInstance, IDS_IDACTION_RENEW, + fmt, ARRAYLENGTH(fmt)); + StringCbPrintf(tooltip, sizeof(tooltip), fmt, idname); + + actmap->renew_cmd = + khui_action_create(NULL, idname, tooltip, NULL, + KHUI_ACTIONTYPE_TRIGGER, NULL); + + fmt[0] = L'\0'; + LoadString(khm_hInstance, IDS_IDACTION_DESTROY, + fmt, ARRAYLENGTH(fmt)); + StringCbPrintf(tooltip, sizeof(tooltip), fmt, idname); + + actmap->destroy_cmd = + khui_action_create(NULL, idname, tooltip, NULL, + KHUI_ACTIONTYPE_TRIGGER, NULL); + + actmap->refreshcycle = idcmd_refreshcycle; + + return actmap; +} + +static void +purge_identity_cmd_map(void) { + khm_size i; + + for (i=0; i < n_id_action_map; i++) { + khm_handle ident; + + if (id_action_map[i].refreshcycle != idcmd_refreshcycle) { + ident = id_action_map[i].identity; + id_action_map[i].identity = NULL; + kcdb_identity_release(ident); + + khui_action_delete(id_action_map[i].renew_cmd); + khui_action_delete(id_action_map[i].destroy_cmd); + + id_action_map[i].renew_cmd = 0; + id_action_map[i].destroy_cmd = 0; + } + } +} + +static struct identity_action_map * +get_identity_cmd_map(khm_handle ident) { + khm_size i; + + for (i=0; i < n_id_action_map; i++) { + if (kcdb_identity_is_equal(id_action_map[i].identity, + ident)) + break; + } + + if (i < n_id_action_map) { + id_action_map[i].refreshcycle = idcmd_refreshcycle; + return &id_action_map[i]; + } else { + return create_identity_cmd_map(ident); + } +} + +static khm_int32 +get_identity_renew_command(khm_handle ident) { + struct identity_action_map * map; + + map = get_identity_cmd_map(ident); + + if (map) + return map->renew_cmd; + else + return 0; +} + +static khm_int32 +get_identity_destroy_command(khm_handle ident) { + struct identity_action_map * map; + + map = get_identity_cmd_map(ident); + + if (map) + return map->destroy_cmd; + else + return 0; +} + +void +khm_refresh_identity_menus(void) { + khui_menu_def * renew_def = NULL; + khui_menu_def * dest_def = NULL; + wchar_t * idlist = NULL; + wchar_t * idname = NULL; + khm_size cb = 0; + khm_size n_idents = 0; + khm_size t; + khm_int32 rv = KHM_ERROR_SUCCESS; + + idcmd_refreshcycle++; + + do { + if (idlist) + PFREE(idlist); + idlist = NULL; + cb = 0; + + rv = kcdb_identity_enum(KCDB_IDENT_FLAG_ACTIVE | KCDB_IDENT_FLAG_EMPTY, + KCDB_IDENT_FLAG_ACTIVE, + NULL, + &cb, + &n_idents); + if (rv != KHM_ERROR_TOO_LONG || cb == 0 || cb == sizeof(wchar_t) * 2) + break; + + idlist = PMALLOC(cb); +#ifdef DEBUG + assert(idlist); +#endif + + rv = kcdb_identity_enum(KCDB_IDENT_FLAG_ACTIVE | KCDB_IDENT_FLAG_EMPTY, + KCDB_IDENT_FLAG_ACTIVE, + idlist, + &cb, + &n_idents); + if (rv == KHM_ERROR_TOO_LONG) + continue; + + if (KHM_FAILED(rv)) { + /* something else went wrong. hmm. */ + if (idlist) + PFREE(idlist); + idlist = NULL; + } + break; + + } while(TRUE); + + renew_def = khui_find_menu(KHUI_MENU_RENEW_CRED); + dest_def = khui_find_menu(KHUI_MENU_DESTROY_CRED); +#ifdef DEBUG + assert(renew_def); + assert(dest_def); +#endif + + t = khui_menu_get_size(renew_def); + while(t) { + khui_menu_remove_action(renew_def, 0); + t--; + } + khui_menu_insert_action(renew_def, 0, KHUI_ACTION_RENEW_ALL, 0); + + t = khui_menu_get_size(dest_def); + while(t) { + khui_menu_remove_action(dest_def, 0); + t--; + } + khui_menu_insert_action(dest_def, 0, KHUI_ACTION_DESTROY_ALL, 0); + + if (idlist != NULL && n_idents > 0) { + khui_menu_insert_action(renew_def, 1, KHUI_MENU_SEP, 0); + khui_menu_insert_action(dest_def, 1, KHUI_MENU_SEP, 0); + } + + for (idname = idlist; idname && idname[0]; + idname = multi_string_next(idname)) { + khm_handle identity = NULL; + + if (KHM_FAILED(kcdb_identity_create(idname, 0, &identity))) { +#ifdef DEBUG + assert(FALSE); +#endif + continue; + } + + khui_menu_insert_action(renew_def, 1000, + get_identity_renew_command(identity), + 0); + + khui_menu_insert_action(dest_def, 1000, + get_identity_destroy_command(identity), + 0); + } + + if (idlist) + PFREE(idlist); + + purge_identity_cmd_map(); +} + +khm_boolean +khm_check_identity_menu_action(khm_int32 act_id) { + + if (act_id == KHUI_ACTION_DESTROY_ALL) { + khm_size i; + + for (i=0; i < n_id_action_map; i++) { + if (id_action_map[i].identity != NULL) { + khm_cred_destroy_identity(id_action_map[i].identity); + } + } + + return TRUE; + } else if (act_id == KHUI_ACTION_RENEW_ALL) { + khm_size i; + + for (i=0; i < n_id_action_map; i++) { + if (id_action_map[i].identity != NULL) { + khm_cred_renew_identity(id_action_map[i].identity); + } + } + + return TRUE; + } else { + khm_size i; + + for (i=0; i < n_id_action_map; i++) { + if (id_action_map[i].identity == NULL) + continue; + + if (id_action_map[i].renew_cmd == act_id) { + khm_cred_renew_identity(id_action_map[i].identity); + return TRUE; + } + + if (id_action_map[i].destroy_cmd == act_id) { + khm_cred_destroy_identity(id_action_map[i].identity); + return TRUE; + } + } + } + + return FALSE; +} + + HMENU khui_hmenu_main = NULL; void khm_menu_refresh_items(void) { @@ -625,9 +909,8 @@ void khm_menu_create_main(HWND parent) { if(!hwtb) { #ifdef DEBUG assert(FALSE); -#else - return; #endif + return; } khui_main_menu_toolbar = hwtb; diff --git a/src/windows/identity/ui/mainmenu.h b/src/windows/identity/ui/mainmenu.h index 7f718c26c..a0f64a0a6 100644 --- a/src/windows/identity/ui/mainmenu.h +++ b/src/windows/identity/ui/mainmenu.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Massachusetts Institute of Technology + * Copyright (c) 2007 Secure Endpoints Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -46,6 +47,8 @@ void khm_menu_track_current(void); LRESULT khm_menu_measure_item(WPARAM wParam, LPARAM lparam); LRESULT khm_menu_draw_item(WPARAM wParam, LPARAM lparam); void khm_menu_refresh_items(void); +khm_boolean khm_check_identity_menu_action(khm_int32 act_id); +void khm_refresh_identity_menus(void); static HMENU mm_create_menu_from_def(khui_menu_def * def, BOOL main); static void mm_show_panel_def(khui_menu_def * def, LONG x, LONG y); diff --git a/src/windows/identity/ui/mainwnd.c b/src/windows/identity/ui/mainwnd.c index eba23e40e..71e09dfac 100644 --- a/src/windows/identity/ui/mainwnd.c +++ b/src/windows/identity/ui/mainwnd.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Massachusetts Institute of Technology + * Copyright (c) 2007 Secure Endpoints Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -25,6 +26,7 @@ /* $Id$ */ #include +#include #include ATOM khm_main_window_class; @@ -62,8 +64,9 @@ mw_restart_refresh_timer(HWND hwnd) { &timeout))) timeout = MW_REFRESH_TIMEOUT; khc_close_space(csp_cw); - } else + } else { timeout = MW_REFRESH_TIMEOUT; + } timeout *= 1000; /* convert to milliseconds */ @@ -172,6 +175,27 @@ khm_process_query_app_ver(khm_query_app_version * papp_ver) { papp_ver->code = KHM_ERROR_SUCCESS; } +static void +khm_ui_cb(LPARAM lParam) { + khui_ui_callback_data * pcbdata; + + pcbdata = (khui_ui_callback_data *) lParam; + + if (pcbdata == NULL || pcbdata->magic != KHUI_UICBDATA_MAGIC) { +#ifdef DEBUG + assert(FALSE); +#endif + return; + } + +#ifdef DEBUG + assert(pcbdata->cb); +#endif + + /* make the call */ + pcbdata->rv = (*pcbdata->cb)(khm_hwnd_main, pcbdata->rock); +} + LRESULT CALLBACK khm_main_wnd_proc(HWND hwnd, UINT uMsg, @@ -339,6 +363,10 @@ khm_main_wnd_proc(HWND hwnd, return SendMessage(khm_hwnd_main_cred, uMsg, wParam, lParam); + case KHUI_ACTION_UICB: + khm_ui_cb(lParam); + break; + /* menu commands */ case KHUI_PACTION_MENU: if(HIWORD(lParam) == 1) @@ -408,6 +436,12 @@ khm_main_wnd_proc(HWND hwnd, { khui_action * act; + /* check if this is an identity menu action. (custom + actions that were created for renewing or + destroying specific identities). */ + if (khm_check_identity_menu_action(LOWORD(wParam))) + break; + act = khui_find_action(LOWORD(wParam)); if (act && act->listener) { kmq_post_sub_msg(act->listener, KMSG_ACT, KMSG_ACT_ACTIVATE, act->cmd, NULL); @@ -568,6 +602,9 @@ khm_main_wnd_proc(HWND hwnd, } else if (m->type == KMSG_CRED && m->subtype == KMSG_CRED_ADDR_CHANGE) { khm_cred_addr_change(); + } else if (m->type == KMSG_CRED && + m->subtype == KMSG_CRED_ROOTDELTA) { + khm_refresh_identity_menus(); } else if (m->type == KMSG_KMM && m->subtype == KMSG_KMM_I_DONE) { kmq_post_message(KMSG_ACT, KMSG_ACT_BEGIN_CMDLINE, 0, 0); diff --git a/src/windows/identity/ui/newcredwnd.c b/src/windows/identity/ui/newcredwnd.c index b876b0297..75ebef4d8 100644 --- a/src/windows/identity/ui/newcredwnd.c +++ b/src/windows/identity/ui/newcredwnd.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Massachusetts Institute of Technology + * Copyright (c) 2007 Secure Endpoints Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -1372,9 +1373,8 @@ static LRESULT nc_handle_wm_nc_notify(HWND hwnd, } else { #ifdef DEBUG assert(FALSE); -#else - continue; #endif + continue; } } diff --git a/src/windows/identity/ui/reqdaemon.c b/src/windows/identity/ui/reqdaemon.c index 684f6c74a..b95f02daf 100644 --- a/src/windows/identity/ui/reqdaemon.c +++ b/src/windows/identity/ui/reqdaemon.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Massachusetts Institute of Technology + * Copyright (c) 2007 Secure Endpoints Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -171,12 +172,11 @@ reqdaemonwnd_proc(HWND hwnd, pdlginfo->out.ccache, &cb); kcdb_identity_release(out_ident); - } + } else { #ifdef DEBUG - else { assert(FALSE); - } #endif + } *atsign++ = 0; diff --git a/src/windows/identity/ui/resource.h b/src/windows/identity/ui/resource.h index b8dc0ec04..f430fe0b0 100644 --- a/src/windows/identity/ui/resource.h +++ b/src/windows/identity/ui/resource.h @@ -294,6 +294,13 @@ #define IDS_NC_PWD_FAILED_TITLE_I 287 #define IDS_NC_REN_FAILED_TITLE_I 288 #define IDS_CFG_IDNAME_NON 289 +#define IDS_MENU_DESTROY_CRED 290 +#define IDS_MENU_RENEW_CRED 291 +#define IDS_ACTION_DESTROY_ALL 292 +#define IDS_ACTION_RENEW_ALL 293 +#define IDS_IDACTION_RENEW 294 +#define IDS_IDACTION_DESTROY 295 +#define IDS_CTX_DESTROY_ID 296 #define IDC_NC_USERNAME 1007 #define IDC_NC_PASSWORD 1008 #define IDC_NC_CREDTEXT_LABEL 1009 diff --git a/src/windows/identity/ui/toolbar.c b/src/windows/identity/ui/toolbar.c index 7157563e4..f3781b930 100644 --- a/src/windows/identity/ui/toolbar.c +++ b/src/windows/identity/ui/toolbar.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Massachusetts Institute of Technology + * Copyright (c) 2007 Secure Endpoints Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -312,9 +313,8 @@ void khm_create_standard_toolbar(HWND rebar) { if (!def) { #ifdef DEBUG assert(FALSE); -#else - return; #endif + return; } hwtb = CreateWindowEx(0 @@ -340,9 +340,8 @@ void khm_create_standard_toolbar(HWND rebar) { if(!hwtb) { #ifdef DEBUG assert(FALSE); -#else - return; #endif + return; } hiList = ImageList_Create( diff --git a/src/windows/identity/ui/uibind.c b/src/windows/identity/ui/uibind.c new file mode 100644 index 000000000..ac5e13626 --- /dev/null +++ b/src/windows/identity/ui/uibind.c @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2007 Secure Endpoints Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* $Id$ */ + +#include +#include + +#ifdef DEBUG +#include +#endif + +KHMEXP khm_int32 KHMAPI +khui_request_UI_callback(khm_ui_callback cb, void * rock) { + + khui_ui_callback_data cbdata; + +#ifdef DEBUG + assert(khui_hwnd_main); +#endif + + if (khui_hwnd_main == NULL) + return KHM_ERROR_NOT_READY; + + ZeroMemory(&cbdata, sizeof(cbdata)); + cbdata.magic = KHUI_UICBDATA_MAGIC; + cbdata.cb = cb; + cbdata.rock = rock; + cbdata.rv = KHM_ERROR_NOT_IMPLEMENTED; + + SendMessage(khui_hwnd_main, WM_COMMAND, + MAKEWPARAM(KHUI_ACTION_UICB, 0), + (LPARAM) &cbdata); + + return KHM_ERROR_SUCCESS; +} + diff --git a/src/windows/identity/uilib/action.c b/src/windows/identity/uilib/action.c index 78fd3a821..a7ab184fa 100644 --- a/src/windows/identity/uilib/action.c +++ b/src/windows/identity/uilib/action.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Massachusetts Institute of Technology + * Copyright (c) 2007 Secure Endpoints Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -26,6 +27,7 @@ #define NOEXPORT #include +#include #include #include @@ -164,8 +166,8 @@ khui_action_ref khui_menu_ico_ctx_normal[] = { MENU_DEFACTION(KHUI_ACTION_CLOSE_APP), MENU_SEP(), MENU_ACTION(KHUI_ACTION_NEW_CRED), - MENU_ACTION(KHUI_ACTION_RENEW_CRED), - MENU_ACTION(KHUI_ACTION_DESTROY_CRED), + MENU_SUBMENU(KHUI_MENU_RENEW_CRED), + MENU_SUBMENU(KHUI_MENU_DESTROY_CRED), MENU_SEP(), MENU_ACTION(KHUI_ACTION_EXIT), MENU_END() @@ -181,6 +183,16 @@ khui_action_ref khui_menu_columns[] = { MENU_END() }; +khui_action_ref khui_menu_destroy_cred[] = { + MENU_DEFACTION(KHUI_ACTION_DESTROY_ALL), + MENU_END() +}; + +khui_action_ref khui_menu_renew_cred[] = { + MENU_DEFACTION(KHUI_ACTION_RENEW_ALL), + MENU_END() +}; + khui_action_ref khui_pmenu_tok_sel[] = { MENU_ACTION(KHUI_ACTION_RENEW_CRED), MENU_ACTION(KHUI_ACTION_DESTROY_CRED), @@ -204,6 +216,8 @@ khui_menu_def khui_all_menus[] = { CONSTMENU(KHUI_MENU_OPTIONS, KHUI_MENUSTATE_CONSTANT | KHUI_MENUSTATE_SYSTEM, khui_menu_options), CONSTMENU(KHUI_MENU_HELP, KHUI_MENUSTATE_CONSTANT | KHUI_MENUSTATE_SYSTEM, khui_menu_help), CONSTMENU(KHUI_MENU_COLUMNS, KHUI_MENUSTATE_CONSTANT | KHUI_MENUSTATE_SYSTEM, khui_menu_columns), + CONSTMENU(KHUI_MENU_RENEW_CRED, KHUI_MENUSTATE_CONSTANT | KHUI_MENUSTATE_SYSTEM, khui_menu_renew_cred), + CONSTMENU(KHUI_MENU_DESTROY_CRED, KHUI_MENUSTATE_CONSTANT | KHUI_MENUSTATE_SYSTEM, khui_menu_destroy_cred), /* toolbars */ CONSTMENU(KHUI_TOOLBAR_STANDARD, KHUI_MENUSTATE_CONSTANT | KHUI_MENUSTATE_SYSTEM, khui_toolbar_standard), diff --git a/src/windows/identity/uilib/actions.csv b/src/windows/identity/uilib/actions.csv index 50c19d4f5..88ac44052 100644 --- a/src/windows/identity/uilib/actions.csv +++ b/src/windows/identity/uilib/actions.csv @@ -7,6 +7,8 @@ KHUI_MENU_HELP,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_MENU_HELP,0,IDH_MENU_HELP, KHUI_MENU_LAYOUT,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_MENU_LAYOUT,0,0,0 KHUI_MENU_TOOLBARS,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_MENU_TOOLBARS,0,0,0 KHUI_MENU_COLUMNS,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_ACTION_CHOOSE_COLS,0,IDH_ACTION_CHOOSE_COLS,0 +KHUI_MENU_DESTROY_CRED,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_MENU_DESTROY_CRED,0,0,0 +KHUI_MENU_RENEW_CRED,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_MENU_RENEW_CRED,0,0,0 KHUI_ACTION_PROPERTIES,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_ACTION_PROPERTIES,IDS_ACTIONT_PROPERTIES,IDH_ACTION_PROPERTIES,0 KHUI_ACTION_EXIT,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_ACTION_EXIT,IDS_ACTIONT_EXIT,IDH_ACTION_EXIT,0 KHUI_ACTION_SET_DEF_ID,KHUI_ACTIONTYPE_TRIGGER | KHUI_ACTIONTYPE_TOGGLE,,0,0,0,0,0,IDS_ACTION_SET_DEF_ID,IDS_ACTIONT_SET_DEF_ID,IDH_ACTION_SET_DEF_ID,0 @@ -34,6 +36,8 @@ KHUI_ACTION_HELP_ABOUT,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_ACTION_HELP_ABOUT, KHUI_ACTION_OPEN_APP,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_ACTION_OPEN_APP,0,0,0 KHUI_ACTION_CLOSE_APP,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_ACTION_CLOSE_APP,0,0,0 KHUI_ACTION_IMPORT,KHUI_ACTIONTYPE_TRIGGER,,IDB_IMPORT,0,IDB_IMPORT_DIS,IDB_IMPORT_SM,IDB_IMPORT_SM_DIS,IDS_ACTION_IMPORT,IDS_ACTIONT_IMPORT,0,0 +KHUI_ACTION_DESTROY_ALL,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_ACTION_DESTROY_ALL,0,0,0 +KHUI_ACTION_RENEW_ALL,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_ACTION_RENEW_ALL,0,0,0 KHUI_PACTION_OK,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_PACTION_OK,0,0,0 KHUI_PACTION_CANCEL,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_PACTION_CANCEL,0,0,0 KHUI_PACTION_CLOSE,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_PACTION_CLOSE,0,0,0 diff --git a/src/windows/identity/uilib/khactiondef.h b/src/windows/identity/uilib/khactiondef.h index 68bbf9137..31866ba27 100644 --- a/src/windows/identity/uilib/khactiondef.h +++ b/src/windows/identity/uilib/khactiondef.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Massachusetts Institute of Technology + * Copyright (c) 2007 Secure Endpoints Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -65,6 +66,9 @@ #define KHUI_ACTION_LAYOUT_CUST (KHUI_ACTION_BASE + 30) #define KHUI_ACTION_OPT_APPEAR (KHUI_ACTION_BASE + 31) #define KHUI_ACTION_LAYOUT_RELOAD (KHUI_ACTION_BASE + 32) +#define KHUI_ACTION_RENEW_ALL (KHUI_ACTION_BASE + 33) +#define KHUI_ACTION_DESTROY_ALL (KHUI_ACTION_BASE + 34) +#define KHUI_ACTION_UICB (KHUI_ACTION_BASE + 35) /*@}*/ /*! \name Pseudo actions @@ -105,6 +109,7 @@ context. #define KHUI_PACTION_PGUP (KHUI_PACTION_BASE + 26) #define KHUI_PACTION_PGUP_EXTEND (KHUI_PACTION_BASE + 27) #define KHUI_PACTION_PGDN_EXTEND (KHUI_PACTION_BASE + 28) + /*@}*/ /*! \name Menus @@ -135,7 +140,9 @@ Stock menus. #define KHUI_PMENU_TOK_SEL (KHUI_MENU_BASE + 10) #define KHUI_PMENU_ID_SEL (KHUI_MENU_BASE + 11) -/* Next menu: 14 */ +#define KHUI_MENU_DESTROY_CRED (KHUI_MENU_BASE + 16) +#define KHUI_MENU_RENEW_CRED (KHUI_MENU_BASE + 17) + /*@}*/ /*! \name Toolbars diff --git a/src/windows/identity/uilib/khuidefs.h b/src/windows/identity/uilib/khuidefs.h index de2897925..7df605cc7 100644 --- a/src/windows/identity/uilib/khuidefs.h +++ b/src/windows/identity/uilib/khuidefs.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Massachusetts Institute of Technology + * Copyright (c) 2007 Secure Endpoints Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -87,6 +88,12 @@ khm_get_lib_version(khm_version * libver, khm_ui_4 * apiver); KHMEXP khm_ui_4 KHMAPI khm_get_commctl_version(khm_version * pdvi); +typedef khm_int32 +(KHMAPI *khm_ui_callback)(HWND hwnd_main_wnd, void * rock); + +KHMEXP khm_int32 KHMAPI +khui_request_UI_callback(khm_ui_callback cb, void * rock); + /*!@}*/ #endif -- 2.26.2