NIM: Identity Configuration Panel Fixes
authorJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 24 Aug 2007 14:23:14 +0000 (14:23 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 24 Aug 2007 14:23:14 +0000 (14:23 +0000)
In the identity configuration panel of Network Identity Manager, the
user can specify a new identity which can then be configured.

The existing code didn't check if the identity specified by the user
already exists.  The patch adds the check.  If the identity already
exists, the user is notified as such.

Another bug prevented the user from configuring an identity that was
added back in following the deletion of the same identity during the
same session.  The deleted status of the identity was not reset when
it was added back.

Additionally, this patch adds code that has already been added to the
new credentials dialog to apply Windows XP theme textures to the child
dialogs used as tab panels in the configuration dialog.  Child dialogs
don't automatically adjust the theme settings based on whether it is
nested inside a tab control.  The theme must be applied manually.

ticket: new
component: windows

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19853 dc483132-0cff-0310-8789-dd5450dbe970

src/windows/identity/ui/cfg_identities_wnd.c

index 5e307922476a4d2171639bf1721c335410347c18..46efe242bca4a35581580b94bd5fc90021352da1 100644 (file)
@@ -26,6 +26,9 @@
 
 #include<khmapp.h>
 #include<assert.h>
+#if _WIN32_WINNT >= 0x0501
+#include<uxtheme.h>
+#endif
 
 static khui_config_node
 get_window_node(HWND hwnd) {
@@ -93,6 +96,9 @@ add_subpanels(HWND hwnd,
 #ifdef DEBUG
         assert(hwnd_panel);
 #endif
+#if _WIN32_WINNT >= 0x0501
+        EnableThemeDialogTexture(hwnd_panel, ETDT_ENABLETAB);
+#endif
 
         ShowWindow(hwnd_panel, SW_HIDE);
 
@@ -299,8 +305,9 @@ typedef struct tag_ident_data {
     wchar_t * idname;
     int lv_idx;
 
-    BOOL removed;
+    BOOL removed;               /* this identity was marked for removal */
     BOOL applied;
+    BOOL purged;                /* this identity was actually removed */
 
     khm_int32 flags;
 
@@ -456,6 +463,8 @@ write_params_ident(ident_data * d) {
         assert(!(flags & KCDB_IDENT_FLAG_CONFIG));
 #endif
 
+        d->purged = TRUE;
+
     } else {
 
         if (d->saved.monitor != d->work.monitor)
@@ -478,7 +487,7 @@ write_params_ident(ident_data * d) {
 
     d->applied = TRUE;
 
-    if (d->hwnd)
+    if (d->hwnd && !d->removed)
         PostMessage(d->hwnd, KHUI_WM_CFG_NOTIFY,
                     MAKEWPARAM(0, WMCFG_UPDATE_STATE), 0);
 
@@ -965,6 +974,7 @@ khm_cfg_add_ident_proc(HWND hwnd,
             khm_handle csp_ident = NULL;
             khm_size cb;
             khm_int32 rv = KHM_ERROR_SUCCESS;
+            khm_int32 flags = 0;
 
             d = (add_ident_data *)(LONG_PTR)
                 GetWindowLongPtr(hwnd, DWLP_USER);
@@ -990,6 +1000,23 @@ khm_cfg_add_ident_proc(HWND hwnd,
             cb = sizeof(idname);
             kcdb_identity_get_name(ident, idname, &cb);
 
+            /* check if the identity is already in the
+               configuration */
+            if (KHM_SUCCEEDED(kcdb_identity_get_flags(ident, &flags)) &&
+                (flags & KCDB_IDENT_FLAG_CONFIG)) {
+
+                wchar_t fmt[256];
+
+                LoadString(khm_hInstance, IDS_CFG_IDNAME_EXT,
+                           fmt, ARRAYLENGTH(fmt));
+                StringCbPrintf(err_msg, sizeof(err_msg), fmt, idname);
+
+                kcdb_identity_release(ident);
+                ident = NULL;
+
+                goto show_failure;
+            }
+
             /* now we have to create the identity configuration. */
             if (KHM_FAILED(rv = kcdb_identity_get_config(ident,
                                                          KHM_FLAG_CREATE,
@@ -1001,6 +1028,7 @@ khm_cfg_add_ident_proc(HWND hwnd,
                 StringCbPrintf(err_msg, sizeof(err_msg), fmt, rv);
 
                 kcdb_identity_release(ident);
+                ident = NULL;
 
                 goto show_failure;
             }
@@ -1247,8 +1275,17 @@ find_ident_by_node(khui_config_node node) {
             break;
     }
 
-    if (i < (int)cfg_idents.n_idents)
+    if (i < (int)cfg_idents.n_idents) {
+        if (cfg_idents.idents[i].purged) {
+            /* we are re-creating a purged identity */
+            cfg_idents.idents[i].purged = FALSE;
+            cfg_idents.idents[i].removed = FALSE;
+            cfg_idents.idents[i].applied = FALSE;
+
+            read_params_ident(&cfg_idents.idents[i]);
+        }
         return &cfg_idents.idents[i];
+    }
 
     /* there is no identity data for this configuration node.  We try
        to create it. */
@@ -1463,11 +1500,14 @@ khm_cfg_id_tab_proc(HWND hwnd,
                 cont = (BOOL *) lParam;
                 d = find_ident_by_node(idata->ctx_node);
                 write_params_ident(d);
-                if (d->removed && cont)
-                    *cont = FALSE;
-                khui_cfg_set_flags_inst(idata, KHUI_CNFLAG_APPLIED,
-                                        KHUI_CNFLAG_APPLIED | 
-                                        KHUI_CNFLAG_MODIFIED);
+                if (d->removed) {
+                    if (cont)
+                        *cont = FALSE;
+                } else {
+                    khui_cfg_set_flags_inst(idata, KHUI_CNFLAG_APPLIED,
+                                            KHUI_CNFLAG_APPLIED | 
+                                            KHUI_CNFLAG_MODIFIED);
+                }
                 break;
 
             case WMCFG_UPDATE_STATE: