return FALSE;\r
}\r
\r
+typedef struct tag_k4_id_data {\r
+ khui_config_init_data cfg;\r
+ khm_int32 gettix; /* get tickets? */\r
+ khm_boolean is_default_ident;\r
+} k4_id_data;\r
+\r
+void\r
+k4_id_read_params(k4_id_data * d) {\r
+ wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
+ khm_size cb;\r
+ khm_handle ident = NULL;\r
+ khm_handle csp_ident = NULL;\r
+ khm_handle csp_idk4 = NULL;\r
+ khm_int32 flags = 0;\r
+ khm_int32 t;\r
+\r
+ khc_read_int32(csp_params, L"Krb4NewCreds", &d->gettix);\r
+\r
+ *idname = 0;\r
+ cb = sizeof(idname);\r
+ khui_cfg_get_name(d->cfg.ctx_node, idname, &cb);\r
+\r
+ kcdb_identity_create(idname, 0, &ident);\r
+\r
+ if (ident == NULL) {\r
+ d->gettix = 0;\r
+ goto done;\r
+ }\r
+\r
+ kcdb_identity_get_flags(ident, &flags);\r
+\r
+ if (!(flags & KCDB_IDENT_FLAG_DEFAULT)) {\r
+ d->gettix = 0;\r
+ goto done;\r
+ }\r
+\r
+ d->is_default_ident = TRUE;\r
+\r
+ if (d->gettix == 0)\r
+ goto done;\r
+\r
+ if (KHM_FAILED(kcdb_identity_get_config(ident, 0, &csp_ident)))\r
+ goto done;\r
+\r
+ if (KHM_FAILED(khc_open_space(csp_ident, CSNAME_KRB4CRED,\r
+ 0, &csp_idk4)))\r
+ goto close_config;\r
+\r
+ if (KHM_SUCCEEDED(khc_read_int32(csp_idk4, L"Krb4NewCreds", &t)) &&\r
+ !t)\r
+ d->gettix = 1;\r
+\r
+ close_config:\r
+ if (csp_ident)\r
+ khc_close_space(csp_ident);\r
+\r
+ if (csp_idk4)\r
+ khc_close_space(csp_idk4);\r
+\r
+ done:\r
+ if (ident)\r
+ kcdb_identity_release(ident);\r
+\r
+ return;\r
+}\r
+\r
+khm_boolean\r
+k4_id_write_params(HWND hwnd, k4_id_data * d) {\r
+ wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
+ khm_size cb_idname = sizeof(idname);\r
+ khm_handle ident = NULL;\r
+ khm_int32 flags = 0;\r
+ khm_handle csp_ident = NULL;\r
+ khm_handle csp_idk4 = NULL;\r
+ khm_int32 gettix = 0;\r
+ khm_boolean applied = FALSE;\r
+\r
+ khui_cfg_get_name(d->cfg.ctx_node, idname, &cb_idname);\r
+\r
+ kcdb_identity_create(idname, 0, &ident);\r
+\r
+ if (ident == NULL)\r
+ return FALSE;\r
+\r
+ kcdb_identity_get_flags(ident, &flags);\r
+\r
+ if (!(flags & KCDB_IDENT_FLAG_DEFAULT))\r
+ goto done_apply;\r
+\r
+ if (IsDlgButtonChecked(hwnd, IDC_CFG_GETTIX) == BST_CHECKED)\r
+ gettix = TRUE;\r
+\r
+ if (KHM_FAILED(kcdb_identity_get_config(ident, KHM_FLAG_CREATE,\r
+ &csp_ident)))\r
+ goto done_apply;\r
+\r
+ if (KHM_FAILED(khc_open_space(csp_ident, CSNAME_KRB4CRED,\r
+ KHM_FLAG_CREATE | KCONF_FLAG_WRITEIFMOD,\r
+ &csp_idk4)))\r
+ goto done_apply;\r
+\r
+ khc_write_int32(csp_idk4, L"Krb4NewCreds", gettix);\r
+\r
+ applied = TRUE;\r
+\r
+ done_apply:\r
+ if (ident)\r
+ kcdb_identity_release(ident);\r
+\r
+ if (csp_ident)\r
+ khc_close_space(csp_ident);\r
+ \r
+ if (csp_idk4)\r
+ khc_close_space(csp_idk4);\r
+\r
+ return applied;\r
+}\r
+\r
INT_PTR CALLBACK\r
krb4_id_config_proc(HWND hwnd,\r
UINT uMsg,\r
switch(uMsg) {\r
case WM_INITDIALOG:\r
{\r
- wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
- khm_size cb;\r
- khui_config_init_data * d;\r
- khm_handle ident = NULL;\r
- khm_handle csp_ident = NULL;\r
- khm_handle csp_idk4 = NULL;\r
- khm_int32 gettix = 0;\r
- khm_int32 flags = 0;\r
- khm_int32 t;\r
- khm_boolean is_default_ident = FALSE;\r
-\r
- d = PMALLOC(sizeof(khui_config_init_data));\r
+ k4_id_data * d;\r
+\r
+ d = PMALLOC(sizeof(k4_id_data));\r
\r
if (!d)\r
break;\r
\r
ZeroMemory(d, sizeof(*d));\r
\r
- *d = *((khui_config_init_data *) lParam);\r
+ d->cfg = *((khui_config_init_data *) lParam);\r
\r
#pragma warning(push)\r
#pragma warning(disable: 4244)\r
SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);\r
#pragma warning(pop)\r
\r
- khc_read_int32(csp_params, L"Krb4NewCreds", &gettix);\r
- if (gettix == 0)\r
- goto set_ui;\r
-\r
- *idname = 0;\r
- cb = sizeof(idname);\r
- khui_cfg_get_name(d->ctx_node, idname, &cb);\r
-\r
- kcdb_identity_create(idname, 0, &ident);\r
-\r
- if (ident == NULL) {\r
- gettix = 0;\r
- goto set_ui;\r
- }\r
+ k4_id_read_params(d);\r
\r
- kcdb_identity_get_flags(ident, &flags);\r
-\r
- if (!(flags & KCDB_IDENT_FLAG_DEFAULT)) {\r
- gettix = 0;\r
- goto set_ui;\r
- }\r
-\r
- is_default_ident = TRUE;\r
+ CheckDlgButton(hwnd, IDC_CFG_GETTIX,\r
+ (d->gettix)?BST_CHECKED: BST_UNCHECKED);\r
+ EnableWindow(GetDlgItem(hwnd, IDC_CFG_GETTIX),\r
+ d->is_default_ident);\r
\r
- if (KHM_FAILED(kcdb_identity_get_config(ident, 0, &csp_ident)))\r
- goto set_ui;\r
+ }\r
+ break;\r
\r
- if (KHM_FAILED(khc_open_space(csp_ident, CSNAME_KRB4CRED,\r
- 0, &csp_idk4)))\r
- goto close_config;\r
+ case WM_COMMAND:\r
+ {\r
+ k4_id_data * d;\r
\r
- if (KHM_SUCCEEDED(khc_read_int32(csp_idk4, L"Krb4NewCreds", &t)) &&\r
- !t)\r
- gettix = 0;\r
+ d = (k4_id_data *) (LONG_PTR)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
\r
- close_config:\r
- if (csp_ident)\r
- khc_close_space(csp_ident);\r
+ if (wParam == MAKEWPARAM(IDC_CFG_GETTIX,\r
+ BN_CLICKED)) {\r
+ int gettix = 0;\r
+ int modified = 0;\r
\r
- if (csp_idk4)\r
- khc_close_space(csp_idk4);\r
+ gettix = (IsDlgButtonChecked(hwnd, IDC_CFG_GETTIX) ==\r
+ BST_CHECKED);\r
\r
- set_ui:\r
- CheckDlgButton(hwnd, IDC_CFG_GETTIX,\r
- (gettix)?BST_CHECKED: BST_UNCHECKED);\r
- EnableWindow(GetDlgItem(hwnd, IDC_CFG_GETTIX),\r
- is_default_ident);\r
+ modified = (!!gettix != !!d->gettix);\r
\r
- if (ident)\r
- kcdb_identity_release(ident);\r
+ khui_cfg_set_flags_inst(&d->cfg,\r
+ ((modified)?KHUI_CNFLAG_MODIFIED: 0),\r
+ KHUI_CNFLAG_MODIFIED);\r
+ }\r
}\r
break;\r
\r
case KHUI_WM_CFG_NOTIFY:\r
{\r
- khui_config_init_data * d;\r
+ k4_id_data * d;\r
\r
- d = (khui_config_init_data *) (LONG_PTR)\r
+ d = (k4_id_data *) (LONG_PTR)\r
GetWindowLongPtr(hwnd, DWLP_USER);\r
\r
if (!d)\r
break;\r
\r
if (HIWORD(wParam) == WMCFG_APPLY) {\r
- wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
- khm_size cb_idname = sizeof(idname);\r
- khm_handle ident = NULL;\r
- khm_int32 flags = 0;\r
- khm_handle csp_ident = NULL;\r
- khm_handle csp_idk4 = NULL;\r
- khm_int32 gettix = 0;\r
- khm_int32 applied = FALSE;\r
-\r
- khui_cfg_get_name(d->ctx_node, idname, &cb_idname);\r
-\r
- kcdb_identity_create(idname, 0, &ident);\r
-\r
- if (ident == NULL)\r
- break;\r
-\r
- kcdb_identity_get_flags(ident, &flags);\r
-\r
- if (!(flags & KCDB_IDENT_FLAG_DEFAULT))\r
- goto done_apply;\r
-\r
- if (IsDlgButtonChecked(hwnd, IDC_CFG_GETTIX) == BST_CHECKED)\r
- gettix = TRUE;\r
-\r
- if (KHM_FAILED(kcdb_identity_get_config(ident, KHM_FLAG_CREATE,\r
- &csp_ident)))\r
- goto done_apply;\r
-\r
- if (KHM_FAILED(khc_open_space(csp_ident, CSNAME_KRB4CRED,\r
- KHM_FLAG_CREATE | KCONF_FLAG_WRITEIFMOD,\r
- &csp_idk4)))\r
- goto done_apply;\r
-\r
- khc_write_int32(csp_idk4, L"Krb4NewCreds", gettix);\r
-\r
- applied = TRUE;\r
-\r
- done_apply:\r
- if (ident)\r
- kcdb_identity_release(ident);\r
-\r
- if (csp_ident)\r
- khc_close_space(csp_ident);\r
+ khm_int32 applied;\r
\r
- if (csp_idk4)\r
- khc_close_space(csp_idk4);\r
+ applied = k4_id_write_params(hwnd, d);\r
\r
- khui_cfg_set_flags_inst(d,\r
+ khui_cfg_set_flags_inst(&d->cfg,\r
((applied)? KHUI_CNFLAG_APPLIED: 0),\r
(KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED));\r
}\r
\r
case WM_DESTROY:\r
{\r
- khui_config_init_data * d;\r
+ k4_id_data * d;\r
\r
- d = (khui_config_init_data *) (LONG_PTR)\r
+ d = (k4_id_data *) (LONG_PTR)\r
GetWindowLongPtr(hwnd, DWLP_USER);\r
\r
if (!d)\r